summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/WebView/WebHTMLRepresentation.mm
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/WebView/WebHTMLRepresentation.mm')
-rw-r--r--WebKit/mac/WebView/WebHTMLRepresentation.mm94
1 files changed, 52 insertions, 42 deletions
diff --git a/WebKit/mac/WebView/WebHTMLRepresentation.mm b/WebKit/mac/WebView/WebHTMLRepresentation.mm
index 41ce9f9..2699472 100644
--- a/WebKit/mac/WebView/WebHTMLRepresentation.mm
+++ b/WebKit/mac/WebView/WebHTMLRepresentation.mm
@@ -29,6 +29,7 @@
#import "WebHTMLRepresentation.h"
#import "DOMElementInternal.h"
+#import "DOMNodeInternal.h"
#import "DOMRangeInternal.h"
#import "WebArchive.h"
#import "WebBasePluginPackage.h"
@@ -66,6 +67,8 @@ using namespace HTMLNames;
WebDataSource *dataSource;
BOOL hasSentResponseToPlugin;
+ BOOL includedInWebKitStatistics;
+
id <WebPluginManualLoader> manualLoader;
NSView *pluginView;
}
@@ -110,23 +113,22 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
return staticSupportedImageMIMETypes.get();
}
-- init
+- (id)init
{
self = [super init];
if (!self)
return nil;
_private = [[WebHTMLRepresentationPrivate alloc] init];
-
- ++WebHTMLRepresentationCount;
-
+
return self;
}
- (void)dealloc
{
- --WebHTMLRepresentationCount;
-
+ if (_private && _private->includedInWebKitStatistics)
+ --WebHTMLRepresentationCount;
+
[_private release];
[super dealloc];
@@ -134,7 +136,8 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)finalize
{
- --WebHTMLRepresentationCount;
+ if (_private && _private->includedInWebKitStatistics)
+ --WebHTMLRepresentationCount;
[super finalize];
}
@@ -148,6 +151,11 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)setDataSource:(WebDataSource *)dataSource
{
_private->dataSource = dataSource;
+
+ if (!_private->includedInWebKitStatistics && [[dataSource webFrame] _isIncludedInWebKitStatistics]) {
+ _private->includedInWebKitStatistics = YES;
+ ++WebHTMLRepresentationCount;
+ }
}
- (BOOL)_isDisplayingWebArchive
@@ -158,23 +166,24 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource
{
WebFrame *webFrame = [dataSource webFrame];
- if (webFrame) {
- if (!_private->pluginView)
- [webFrame _receivedData:data textEncodingName:[[_private->dataSource response] textEncodingName]];
-
- // If the document is a stand-alone media document, now is the right time to cancel the WebKit load
- Frame* coreFrame = core(webFrame);
- if (coreFrame->document() && coreFrame->document()->isMediaDocument())
- coreFrame->loader()->documentLoader()->cancelMainResourceLoad(coreFrame->loader()->client()->pluginWillHandleLoadError(coreFrame->loader()->documentLoader()->response()));
-
- if (_private->pluginView) {
- if (!_private->hasSentResponseToPlugin) {
- [_private->manualLoader pluginView:_private->pluginView receivedResponse:[dataSource response]];
- _private->hasSentResponseToPlugin = YES;
- }
-
- [_private->manualLoader pluginView:_private->pluginView receivedData:data];
+ if (!webFrame)
+ return;
+
+ if (!_private->pluginView)
+ [webFrame _commitData:data];
+
+ // If the document is a stand-alone media document, now is the right time to cancel the WebKit load
+ Frame* coreFrame = core(webFrame);
+ if (coreFrame->document()->isMediaDocument())
+ coreFrame->loader()->documentLoader()->cancelMainResourceLoad(coreFrame->loader()->client()->pluginWillHandleLoadError(coreFrame->loader()->documentLoader()->response()));
+
+ if (_private->pluginView) {
+ if (!_private->hasSentResponseToPlugin) {
+ [_private->manualLoader pluginView:_private->pluginView receivedResponse:[dataSource response]];
+ _private->hasSentResponseToPlugin = YES;
}
+
+ [_private->manualLoader pluginView:_private->pluginView receivedData:data];
}
}
@@ -187,25 +196,26 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
{
- WebFrame *frame = [dataSource webFrame];
+ WebFrame* webFrame = [dataSource webFrame];
if (_private->pluginView) {
[_private->manualLoader pluginViewFinishedLoading:_private->pluginView];
return;
}
- if (frame) {
- if (![self _isDisplayingWebArchive]) {
- // Telling the frame we received some data and passing nil as the data is our
- // way to get work done that is normally done when the first bit of data is
- // received, even for the case of a document with no data (like about:blank).
- [frame _receivedData:nil textEncodingName:[[_private->dataSource response] textEncodingName]];
- }
-
- WebView *webView = [frame webView];
- if ([webView isEditable])
- core(frame)->applyEditingStyleToBodyElement();
+ if (!webFrame)
+ return;
+
+ if (![self _isDisplayingWebArchive]) {
+ // Telling the frame we received some data and passing nil as the data is our
+ // way to get work done that is normally done when the first bit of data is
+ // received, even for the case of a document with no data (like about:blank).
+ [webFrame _commitData:nil];
}
+
+ WebView *webView = [webFrame webView];
+ if ([webView isEditable])
+ core(webFrame)->editor()->applyEditingStyleToBodyElement();
}
- (BOOL)canProvideDocumentSource
@@ -275,11 +285,11 @@ static HTMLFormElement* formElementFromDOMElement(DOMElement *element)
HTMLFormElement* formElement = formElementFromDOMElement(form);
if (!formElement)
return nil;
- Vector<HTMLFormControlElement*>& elements = formElement->formElements;
+ const Vector<HTMLFormControlElement*>& elements = formElement->associatedElements();
AtomicString targetName = name;
for (unsigned i = 0; i < elements.size(); i++) {
HTMLFormControlElement* elt = elements[i];
- if (elt->formControlName() == targetName)
+ if (elt->name() == targetName)
return kit(elt);
}
return nil;
@@ -295,15 +305,15 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
{
HTMLInputElement* inputElement = inputElementFromDOMElement(element);
return inputElement
- && inputElement->inputType() == HTMLInputElement::TEXT
+ && inputElement->isTextField()
+ && !inputElement->isPasswordField()
&& inputElement->autoComplete();
}
- (BOOL)elementIsPassword:(DOMElement *)element
{
HTMLInputElement* inputElement = inputElementFromDOMElement(element);
- return inputElement
- && inputElement->inputType() == HTMLInputElement::PASSWORD;
+ return inputElement && inputElement->isPasswordField();
}
- (DOMElement *)formForElement:(DOMElement *)element
@@ -314,7 +324,7 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
- (DOMElement *)currentForm
{
- return kit(core([_private->dataSource webFrame])->currentForm());
+ return kit(core([_private->dataSource webFrame])->selection()->currentForm());
}
- (NSArray *)controlsInForm:(DOMElement *)form
@@ -323,7 +333,7 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
if (!formElement)
return nil;
NSMutableArray *results = nil;
- Vector<HTMLFormControlElement*>& elements = formElement->formElements;
+ const Vector<HTMLFormControlElement*>& elements = formElement->associatedElements();
for (unsigned i = 0; i < elements.size(); i++) {
if (elements[i]->isEnumeratable()) { // Skip option elements, other duds
DOMElement* de = kit(elements[i]);