summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/objc/DOMHTML.mm
diff options
context:
space:
mode:
authorFeng Qian <fqian@google.com>2009-06-17 12:12:20 -0700
committerFeng Qian <fqian@google.com>2009-06-17 12:12:20 -0700
commit5f1ab04193ad0130ca8204aadaceae083aca9881 (patch)
tree5a92cd389e2cfe7fb67197ce14b38469462379f8 /WebCore/bindings/objc/DOMHTML.mm
parent194315e5a908cc8ed67d597010544803eef1ac59 (diff)
downloadexternal_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.zip
external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.gz
external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.bz2
Get WebKit r44544.
Diffstat (limited to 'WebCore/bindings/objc/DOMHTML.mm')
-rw-r--r--WebCore/bindings/objc/DOMHTML.mm111
1 files changed, 56 insertions, 55 deletions
diff --git a/WebCore/bindings/objc/DOMHTML.mm b/WebCore/bindings/objc/DOMHTML.mm
index baf5774..8c0d30b 100644
--- a/WebCore/bindings/objc/DOMHTML.mm
+++ b/WebCore/bindings/objc/DOMHTML.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
@@ -25,20 +25,27 @@
*/
#import "config.h"
-#import "DOMHTML.h"
-#import "CSSHelper.h"
+#import "DOMDocumentFragmentInternal.h"
#import "DOMExtensions.h"
-#import "DOMInternal.h"
+#import "DOMHTMLCollectionInternal.h"
+#import "DOMHTMLDocumentInternal.h"
+#import "DOMHTMLInputElementInternal.h"
+#import "DOMHTMLSelectElementInternal.h"
+#import "DOMHTMLTextAreaElementInternal.h"
+#import "DOMNodeInternal.h"
#import "DOMPrivate.h"
#import "DocumentFragment.h"
#import "FrameView.h"
+#import "HTMLCollection.h"
#import "HTMLDocument.h"
#import "HTMLInputElement.h"
-#import "HTMLObjectElement.h"
#import "HTMLSelectElement.h"
+#import "HTMLTextAreaElement.h"
+#import "Page.h"
#import "Range.h"
#import "RenderTextControl.h"
+#import "Settings.h"
#import "markup.h"
//------------------------------------------------------------------------------------------
@@ -48,13 +55,13 @@
- (DOMDocumentFragment *)createDocumentFragmentWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL
{
- return [DOMDocumentFragment _wrapDocumentFragment:createFragmentFromMarkup([self _document], markupString, [baseURL absoluteString]).get()];
+ return kit(createFragmentFromMarkup(core(self), markupString, [baseURL absoluteString]).get());
}
- (DOMDocumentFragment *)createDocumentFragmentWithText:(NSString *)text
{
// FIXME: Since this is not a contextual fragment, it won't handle whitespace properly.
- return [DOMDocumentFragment _wrapDocumentFragment:createFragmentFromText([self _document]->createRange().get(), text).get()];
+ return kit(createFragmentFromText(core(self)->createRange().get(), text).get());
}
@end
@@ -63,7 +70,7 @@
- (DOMDocumentFragment *)_createDocumentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString
{
- NSURL *baseURL = [self _document]->completeURL(WebCore::parseURL(baseURLString));
+ NSURL *baseURL = core(self)->completeURL(WebCore::parseURL(baseURLString));
return [self createDocumentFragmentWithMarkupString:markupString baseURL:baseURL];
}
@@ -74,49 +81,40 @@
@end
-#pragma mark DOM EXTENSIONS
+#ifdef BUILDING_ON_TIGER
+@implementation DOMHTMLDocument (DOMHTMLDocumentOverrides)
-@implementation DOMHTMLInputElement(FormAutoFillTransition)
+- (DOMNode *)firstChild
+{
+ WebCore::HTMLDocument* coreHTMLDocument = core(self);
+ if (!coreHTMLDocument->page() || !coreHTMLDocument->page()->settings()->needsTigerMailQuirks())
+ return kit(coreHTMLDocument->firstChild());
+
+ WebCore::Node* child = coreHTMLDocument->firstChild();
+ while (child && child->nodeType() == WebCore::Node::DOCUMENT_TYPE_NODE)
+ child = child->nextSibling();
+
+ return kit(child);
+}
+
+@end
+#endif
+
+@implementation DOMHTMLInputElement (FormAutoFillTransition)
- (BOOL)_isTextField
{
- // We could make this public API as-is, or we could change it into a method that returns whether
- // the element is a text field or a button or ... ?
- static NSArray *textInputTypes = nil;
-#ifndef NDEBUG
- static NSArray *nonTextInputTypes = nil;
-#endif
-
- NSString *fieldType = [self type];
-
- // No type at all is treated as text type
- if ([fieldType length] == 0)
- return YES;
-
- if (textInputTypes == nil)
- textInputTypes = [[NSSet alloc] initWithObjects:@"text", @"password", @"search", @"isindex", nil];
-
- BOOL isText = [textInputTypes containsObject:[fieldType lowercaseString]];
-
-#ifndef NDEBUG
- if (nonTextInputTypes == nil)
- nonTextInputTypes = [[NSSet alloc] initWithObjects:@"checkbox", @"radio", @"submit", @"reset", @"file", @"hidden", @"image", @"button", @"range", nil];
-
- // Catch cases where a new input type has been added that's not in these lists.
- ASSERT(isText || [nonTextInputTypes containsObject:[fieldType lowercaseString]]);
-#endif
-
- return isText;
+ return core(self)->isTextField();
}
- (NSRect)_rectOnScreen
{
// Returns bounding rect of text field, in screen coordinates.
NSRect result = [self boundingBox];
- if (![self _HTMLInputElement]->document()->view())
+ if (!core(self)->document()->view())
return result;
- NSView* view = [self _HTMLInputElement]->document()->view()->documentView();
+ NSView* view = core(self)->document()->view()->documentView();
result = [view convertRect:result toView:nil];
result.origin = [[view window] convertBaseToScreen:result.origin];
return result;
@@ -124,7 +122,7 @@
- (void)_replaceCharactersInRange:(NSRange)targetRange withString:(NSString *)replacementString selectingFromIndex:(int)index
{
- WebCore::HTMLInputElement* inputElement = [self _HTMLInputElement];
+ WebCore::HTMLInputElement* inputElement = core(self);
if (inputElement) {
WebCore::String newValue = inputElement->value();
newValue.replace(targetRange.location, targetRange.length, replacementString);
@@ -135,7 +133,7 @@
- (NSRange)_selectedRange
{
- WebCore::HTMLInputElement* inputElement = [self _HTMLInputElement];
+ WebCore::HTMLInputElement* inputElement = core(self);
if (inputElement) {
int start = inputElement->selectionStart();
int end = inputElement->selectionEnd();
@@ -149,9 +147,7 @@
// This notifies the input element that the content has been autofilled
// This allows WebKit to obey the -webkit-autofill pseudo style, which
// changes the background color.
- WebCore::HTMLInputElement* inputElement = [self _HTMLInputElement];
- if (inputElement)
- inputElement->setAutofilled(filled);
+ core(self)->setAutofilled(filled);
}
@end
@@ -160,30 +156,35 @@
- (void)_activateItemAtIndex:(int)index
{
- if (WebCore::HTMLSelectElement* select = [self _HTMLSelectElement])
+ if (WebCore::HTMLSelectElement* select = core(self))
select->setSelectedIndex(index);
}
@end
@implementation DOMHTMLInputElement (FormPromptAdditions)
+
- (BOOL)_isEdited
{
- WebCore::RenderObject *renderer = [self _node]->renderer();
- if (renderer && [self _isTextField])
- return static_cast<WebCore::RenderTextControl *>(renderer)->isUserEdited();
-
- return NO;
+ WebCore::RenderObject *renderer = core(self)->renderer();
+ return renderer && [self _isTextField] && static_cast<WebCore::RenderTextControl *>(renderer)->isUserEdited();
}
+
@end
@implementation DOMHTMLTextAreaElement (FormPromptAdditions)
+
- (BOOL)_isEdited
{
- WebCore::RenderObject *renderer = [self _node]->renderer();
- if (renderer)
- return static_cast<WebCore::RenderTextControl *>(renderer)->isUserEdited();
-
- return NO;
+ WebCore::RenderObject* renderer = core(self)->renderer();
+ return renderer && static_cast<WebCore::RenderTextControl*>(renderer)->isUserEdited();
}
+
@end
+
+Class kitClass(WebCore::HTMLCollection* collection)
+{
+ if (collection->type() == WebCore::SelectOptions)
+ return [DOMHTMLOptionsCollection class];
+ return [DOMHTMLCollection class];
+}