Changeset 21681 in webkit
- Timestamp:
- May 23, 2007 4:00:20 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r21671 r21681 1 2007-05-23 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Darin. 4 5 Update tests for http://bugs.webkit.org/show_bug.cgi?id=13830 6 Auto-generate JS DOM bindings for HTMLDocument and most of 7 the rest of HTMLElement 8 9 - Corrects prototype chain for JSHTMLDocument and adds test 10 for HTMLFormElement. 11 12 * fast/dom/prototype-chain-expected.txt: 13 * fast/dom/prototype-chain.html: 14 1 15 2007-05-23 Kevin McCullough <kmccullough@apple.com> 2 16 -
trunk/LayoutTests/fast/dom/prototype-chain-expected.txt
r20145 r21681 3 3 NOTE: This test will start failing if you change the layout of a related prototype chain in WebCore. That does not necessarily mean that you have done something wrong; you may just need to check in new results. 4 4 5 ----- [object HTMLDocument] ( 7prototypes) -----5 ----- [object HTMLDocument] (6 prototypes) ----- 6 6 7 7 [object Object] … … 14 14 15 15 [object DocumentPrototype] 16 17 [object DOMHTMLDocumentPrototype]18 16 19 17 [object HTMLDocumentPrototype] … … 36 34 37 35 [object HTMLDivElementPrototype] 36 37 ----- [object HTMLFormElement] (8 prototypes) ----- 38 39 [object Object] 40 41 [object DOMNodePrototype] 42 43 [object NodePrototype] 44 45 [object DOMEventTargetNodePrototype] 46 47 [object ElementPrototype] 48 49 [object HTMLElementPrototype] 50 51 [object HTMLElementPrototype] 52 53 [object HTMLFormElementPrototype] 38 54 39 55 ----- [object UIEvent] (4 prototypes) ----- -
trunk/LayoutTests/fast/dom/prototype-chain.html
r13150 r21681 37 37 e = document.getElementById("div"); 38 38 printPrototypes(e); 39 40 e = document.createElement("form"); 41 printPrototypes(e); 39 42 40 43 e = document.createEvent("UIEvents"); -
trunk/WebCore/ChangeLog
r21679 r21681 1 2007-05-23 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Darin. 4 5 Part two of patch for http://bugs.webkit.org/show_bug.cgi?id=13830 6 Auto-generate JS DOM bindings for HTMLDocument and most of the rest 7 of HTMLElement 8 9 - Just the HTMLDocument part. 10 11 * WebCore.pro: 12 * WebCore.xcodeproj/project.pbxproj: 13 * bindings/js/JSHTMLDocumentCustom.cpp: Added. 14 (WebCore::JSHTMLDocument::canGetItemsForName): 15 (WebCore::JSHTMLDocument::nameGetter): 16 (WebCore::JSHTMLDocument::all): 17 (WebCore::JSHTMLDocument::setAll): 18 (WebCore::JSHTMLDocument::location): 19 (WebCore::JSHTMLDocument::setLocation): 20 (WebCore::JSHTMLDocument::open): 21 (WebCore::writeHelper): 22 (WebCore::JSHTMLDocument::write): 23 (WebCore::JSHTMLDocument::writeln): 24 (WebCore::JSHTMLDocument::clear): 25 * bindings/js/kjs_dom.cpp: 26 (KJS::toJS): 27 * bindings/js/kjs_dom.h: 28 * bindings/js/kjs_html.cpp: 29 * bindings/js/kjs_html.h: 30 * bindings/objc/DOMPrivate.h: 31 * bindings/scripts/CodeGeneratorJS.pm: Add [Deletable] property 32 for Document.all and fix HasOverridingNameGetter to allow correct 33 prototype chain 34 * dom/Document.cpp: 35 (WebCore::Document::plugins): adds alias to embeds() for bindings 36 * dom/Document.h: 37 * html/HTMLDocument.cpp: 38 (WebCore::HTMLDocument::width): 39 (WebCore::HTMLDocument::height): 40 (WebCore::HTMLDocument::dir): 41 (WebCore::HTMLDocument::setDir): 42 (WebCore::HTMLDocument::designMode): 43 (WebCore::HTMLDocument::setDesignMode): 44 (WebCore::HTMLDocument::bgColor): 45 (WebCore::HTMLDocument::setBgColor): 46 (WebCore::HTMLDocument::fgColor): 47 (WebCore::HTMLDocument::setFgColor): 48 (WebCore::HTMLDocument::alinkColor): 49 (WebCore::HTMLDocument::setAlinkColor): 50 (WebCore::HTMLDocument::linkColor): 51 (WebCore::HTMLDocument::setLinkColor): 52 (WebCore::HTMLDocument::vlinkColor): 53 (WebCore::HTMLDocument::setVlinkColor): 54 (WebCore::HTMLDocument::captureEvents): 55 (WebCore::HTMLDocument::releaseEvents): 56 * html/HTMLDocument.h: 57 * html/HTMLDocument.idl: 58 1 59 2007-05-23 David Hyatt <hyatt@apple.com> 2 60 -
trunk/WebCore/WebCore.pro
r21634 r21681 268 268 bindings/js/JSDocumentCustom.cpp \ 269 269 bindings/js/JSHTMLAnchorElementCustom.cpp \ 270 bindings/js/JSHTMLDocumentCustom.cpp \ 270 271 bindings/js/JSHTMLElementWrapperFactory.cpp \ 271 272 bindings/js/JSHTMLFormElementCustom.cpp \ -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r21655 r21681 2775 2775 BC51579F0C03BBD3008BB0EE /* DOMHTMLMarqueeElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5156E50C03B741008BB0EE /* DOMHTMLMarqueeElement.h */; }; 2776 2776 BC5157DD0C03BC22008BB0EE /* DOMHTMLFrameElementPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC5156F30C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h */; }; 2777 BC51580B0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */; }; 2777 2778 BC588AF00BFA6CF900EE679E /* HTMLParserErrorCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */; }; 2778 2779 BC588B4B0BFA723C00EE679E /* HTMLParserErrorCodes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC588B4A0BFA723C00EE679E /* HTMLParserErrorCodes.cpp */; }; … … 2786 2787 BC6DB4740A1A90FB00E5CD14 /* GlyphPageTreeNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6DB4730A1A90FB00E5CD14 /* GlyphPageTreeNode.cpp */; }; 2787 2788 BC6DB4D40A1AFEEF00E5CD14 /* GlyphPageTreeNodeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6DB4D30A1AFEEF00E5CD14 /* GlyphPageTreeNodeMac.cpp */; }; 2789 BC6E2B1A0C04B93600444EF8 /* DOMHTMLDocumentPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */; }; 2790 BC6E2B290C04B95400444EF8 /* DOMHTMLDocumentPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */; }; 2788 2791 BC7F44A80B9E324E00A9D081 /* ImageObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7F44A70B9E324E00A9D081 /* ImageObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2789 2792 BCA169A20BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCA169A00BFD55B40019CA76 /* JSHTMLTableCaptionElement.cpp */; }; … … 2982 2985 dstSubfolderSpec = 1; 2983 2986 files = ( 2987 BC6E2B290C04B95400444EF8 /* DOMHTMLDocumentPrivate.h in Copy Generated Headers */, 2984 2988 BC5156E80C03B741008BB0EE /* DOMHTMLMarqueeElement.h in Copy Generated Headers */, 2985 2989 BC5156F40C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h in Copy Generated Headers */, … … 6011 6015 BC5156E70C03B741008BB0EE /* DOMHTMLMarqueeElementInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLMarqueeElementInternal.h; sourceTree = "<group>"; }; 6012 6016 BC5156F30C03B7DC008BB0EE /* DOMHTMLFrameElementPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLFrameElementPrivate.h; sourceTree = "<group>"; }; 6017 BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLDocumentCustom.cpp; sourceTree = "<group>"; }; 6013 6018 BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLParserErrorCodes.h; sourceTree = "<group>"; }; 6014 6019 BC588B4A0BFA723C00EE679E /* HTMLParserErrorCodes.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserErrorCodes.cpp; sourceTree = "<group>"; }; … … 6023 6028 BC6DB4730A1A90FB00E5CD14 /* GlyphPageTreeNode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageTreeNode.cpp; sourceTree = "<group>"; }; 6024 6029 BC6DB4D30A1AFEEF00E5CD14 /* GlyphPageTreeNodeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageTreeNodeMac.cpp; sourceTree = "<group>"; }; 6030 BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLDocumentPrivate.h; sourceTree = "<group>"; }; 6025 6031 BC7B2AF80450824100A8000F /* ScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBar.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 6026 6032 BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformScrollBarMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; … … 7636 7642 85BCBC110ABBA87D00381160 /* DOMHTMLDocument.h */, 7637 7643 85BCBC120ABBA87D00381160 /* DOMHTMLDocument.mm */, 7644 BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */, 7638 7645 85DF2EEB0AA387CB00AD64C5 /* DOMHTMLElement.h */, 7639 7646 85DF2EEC0AA387CB00AD64C5 /* DOMHTMLElement.mm */, … … 9064 9071 929264760B61FC7200B41D34 /* JSDocumentCustom.cpp */, 9065 9072 BCF411770BFCC76A00125622 /* JSHTMLAnchorElementCustom.cpp */, 9073 BC51580A0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp */, 9066 9074 938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */, 9067 9075 938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */, … … 11370 11378 BC51579F0C03BBD3008BB0EE /* DOMHTMLMarqueeElement.h in Headers */, 11371 11379 BC5157DD0C03BC22008BB0EE /* DOMHTMLFrameElementPrivate.h in Headers */, 11380 BC6E2B1A0C04B93600444EF8 /* DOMHTMLDocumentPrivate.h in Headers */, 11372 11381 ); 11373 11382 runOnlyForDeploymentPostprocessing = 0; … … 12758 12767 BC5156E90C03B741008BB0EE /* DOMHTMLMarqueeElement.mm in Sources */, 12759 12768 ABAF22080C03B1C700B0BCF0 /* ChromeMac.mm in Sources */, 12769 BC51580B0C03D404008BB0EE /* JSHTMLDocumentCustom.cpp in Sources */, 12760 12770 ); 12761 12771 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/js/kjs_dom.cpp
r21470 r21681 1072 1072 } 1073 1073 1074 JSValue* toJS(ExecState* exec, PassRefPtr<NodeList>l)1075 { 1076 return cacheDOMObject<NodeList, DOMNodeList>(exec, l .get());1074 JSValue* toJS(ExecState* exec, NodeList* l) 1075 { 1076 return cacheDOMObject<NodeList, DOMNodeList>(exec, l); 1077 1077 } 1078 1078 -
trunk/WebCore/bindings/js/kjs_dom.h
r20214 r21681 138 138 JSValue* toJS(ExecState*, PassRefPtr<WebCore::Node>); 139 139 JSValue* toJS(ExecState*, WebCore::NamedNodeMap*); 140 JSValue* toJS(ExecState*, PassRefPtr<WebCore::NodeList>);140 JSValue* toJS(ExecState*, WebCore::NodeList*); 141 141 JSValue* toJS(ExecState*, WebCore::EventTarget*); 142 142 JSObject* getNodeConstructor(ExecState*); -
trunk/WebCore/bindings/js/kjs_html.cpp
r21651 r21681 71 71 int id; 72 72 }; 73 74 /*75 @begin JSHTMLDocumentPrototypeTable 876 clear JSHTMLDocument::Clear DontDelete|Function 077 open JSHTMLDocument::Open DontDelete|Function 078 close JSHTMLDocument::Close DontDelete|Function 079 write JSHTMLDocument::Write DontDelete|Function 180 writeln JSHTMLDocument::WriteLn DontDelete|Function 181 getElementsByName JSHTMLDocument::GetElementsByName DontDelete|Function 182 captureEvents JSHTMLDocument::CaptureEvents DontDelete|Function 083 releaseEvents JSHTMLDocument::ReleaseEvents DontDelete|Function 084 @end85 */86 KJS_IMPLEMENT_PROTOTYPE_FUNCTION(JSHTMLDocumentPrototypeFunction)87 KJS_IMPLEMENT_PROTOTYPE("DOMHTMLDocument", JSHTMLDocumentPrototype, JSHTMLDocumentPrototypeFunction)88 89 JSValue *JSHTMLDocumentPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)90 {91 if (!thisObj->inherits(&JSHTMLDocument::info))92 return throwError(exec, TypeError);93 HTMLDocument &doc = *static_cast<HTMLDocument*>(static_cast<JSHTMLDocument*>(thisObj)->impl());94 95 switch (id) {96 case JSHTMLDocument::Clear: // even IE doesn't support that one...97 //doc.clear(); // TODO98 return jsUndefined();99 case JSHTMLDocument::Open:100 // For compatibility with other browsers, pass open calls with more than 2 parameters to the window.101 if (args.size() > 2) {102 Frame *frame = doc.frame();103 if (frame) {104 Window *window = Window::retrieveWindow(frame);105 if (window) {106 JSObject* functionObject = window->get(exec, "open")->getObject();107 if (!functionObject || !functionObject->implementsCall())108 return throwError(exec, TypeError);109 return functionObject->call(exec, window, args);110 }111 }112 return jsUndefined();113 }114 // In the case of two parameters or fewer, do a normal document open.115 doc.open();116 return jsUndefined();117 case JSHTMLDocument::Close:118 doc.close();119 return jsUndefined();120 case JSHTMLDocument::Write:121 case JSHTMLDocument::WriteLn: {122 // DOM only specifies single string argument, but NS & IE allow multiple123 // or no arguments124 String str = "";125 for (int i = 0; i < args.size(); i++)126 str += args[i]->toString(exec);127 if (id == JSHTMLDocument::WriteLn)128 str += "\n";129 doc.write(str);130 return jsUndefined();131 }132 case JSHTMLDocument::GetElementsByName:133 return toJS(exec, doc.getElementsByName(args[0]->toString(exec)).get());134 case JSHTMLDocument::CaptureEvents:135 case JSHTMLDocument::ReleaseEvents:136 // Do nothing for now. These are NS-specific legacy calls.137 break;138 }139 140 return jsUndefined();141 }142 143 144 // FIXME: functions should be in the prototype145 const ClassInfo JSHTMLDocument::info =146 { "DOMHTMLDocument", &JSDocument::info, &HTMLDocumentTable, 0 };147 /* Source for HTMLDocumentTable. Use "make hashtables" to regenerate.148 @begin HTMLDocumentTable 30149 title JSHTMLDocument::Title DontDelete150 referrer JSHTMLDocument::Referrer DontDelete|ReadOnly151 domain JSHTMLDocument::Domain DontDelete152 body JSHTMLDocument::Body DontDelete153 location JSHTMLDocument::Location DontDelete154 cookie JSHTMLDocument::Cookie DontDelete155 images JSHTMLDocument::Images DontDelete|ReadOnly156 embeds JSHTMLDocument::Embeds DontDelete|ReadOnly157 plugins JSHTMLDocument::Embeds DontDelete|ReadOnly158 applets JSHTMLDocument::Applets DontDelete|ReadOnly159 links JSHTMLDocument::Links DontDelete|ReadOnly160 forms JSHTMLDocument::Forms DontDelete|ReadOnly161 anchors JSHTMLDocument::Anchors DontDelete|ReadOnly162 scripts JSHTMLDocument::Scripts DontDelete|ReadOnly163 all JSHTMLDocument::All164 bgColor JSHTMLDocument::BgColor DontDelete165 fgColor JSHTMLDocument::FgColor DontDelete166 alinkColor JSHTMLDocument::AlinkColor DontDelete167 linkColor JSHTMLDocument::LinkColor DontDelete168 vlinkColor JSHTMLDocument::VlinkColor DontDelete169 lastModified JSHTMLDocument::LastModified DontDelete|ReadOnly170 height JSHTMLDocument::Height DontDelete|ReadOnly171 width JSHTMLDocument::Width DontDelete|ReadOnly172 dir JSHTMLDocument::Dir DontDelete173 designMode JSHTMLDocument::DesignMode DontDelete174 #potentially obsolete array properties175 # layers176 # plugins177 # tags178 #potentially obsolete properties179 # embeds180 # ids181 @end182 */183 184 JSHTMLDocument::JSHTMLDocument(ExecState* exec, HTMLDocument *d)185 : JSDocument(exec, d)186 {187 setPrototype(JSHTMLDocumentPrototype::self(exec));188 }189 190 JSValue *JSHTMLDocument::namedItemGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)191 {192 JSHTMLDocument *thisObj = static_cast<JSHTMLDocument*>(slot.slotBase());193 HTMLDocument &doc = *static_cast<HTMLDocument*>(thisObj->impl());194 195 String name = propertyName;196 RefPtr<HTMLCollection> collection = doc.documentNamedItems(name);197 198 if (collection->length() == 1) {199 Node* node = collection->firstItem();200 Frame *frame;201 if (node->hasTagName(iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))202 return Window::retrieve(frame);203 return toJS(exec, node);204 } else if (collection->length() == 0)205 return jsUndefined();206 207 return getHTMLCollection(exec, collection.get());208 }209 210 JSValue *JSHTMLDocument::getValueProperty(ExecState* exec, int token) const211 {212 HTMLDocument& doc = *static_cast<HTMLDocument*>(impl());213 214 FrameView* view = doc.view();215 Frame* frame = doc.frame();216 217 HTMLElement* body = doc.body();218 HTMLBodyElement* bodyElement = (body && body->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(body) : 0;219 220 switch (token) {221 case Title:222 return jsString(doc.title());223 case Referrer:224 return jsString(doc.referrer());225 case Domain:226 return jsString(doc.domain());227 case Body:228 return toJS(exec, body);229 case Location:230 if (!frame)231 return jsNull();232 if (Window* win = Window::retrieveWindow(frame))233 return win->location();234 return jsUndefined();235 case Cookie:236 return jsString(doc.cookie());237 case Images:238 return getHTMLCollection(exec, doc.images().get());239 case Embeds:240 return getHTMLCollection(exec, doc.embeds().get());241 case Applets:242 return getHTMLCollection(exec, doc.applets().get());243 case Links:244 return getHTMLCollection(exec, doc.links().get());245 case Forms:246 return getHTMLCollection(exec, doc.forms().get());247 case Anchors:248 return getHTMLCollection(exec, doc.anchors().get());249 case Scripts:250 return getHTMLCollection(exec, doc.scripts().get());251 case All:252 // If "all" has been overwritten, return the overwritten value253 if (JSValue *v = getDirect("all"))254 return v;255 else256 return getAllHTMLCollection(exec, doc.all().get());257 case BgColor:258 if (!bodyElement)259 return jsUndefined();260 return jsString(bodyElement->bgColor());261 case FgColor:262 if (!bodyElement)263 return jsUndefined();264 return jsString(bodyElement->text());265 case AlinkColor:266 if (!bodyElement)267 return jsUndefined();268 return jsString(bodyElement->aLink());269 case LinkColor:270 if (!bodyElement)271 return jsUndefined();272 return jsString(bodyElement->link());273 case VlinkColor:274 if (!bodyElement)275 return jsUndefined();276 return jsString(bodyElement->vLink());277 case LastModified:278 return jsString(doc.lastModified());279 case Height:280 return jsNumber(view ? view->contentsHeight() : 0);281 case Width:282 return jsNumber(view ? view->contentsWidth() : 0);283 case Dir:284 if (!body)285 return jsString("");286 return jsString(body->dir());287 case DesignMode:288 return jsString(doc.inDesignMode() ? "on" : "off");289 default:290 ASSERT(0);291 return jsUndefined();292 }293 }294 295 bool JSHTMLDocument::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)296 {297 HTMLDocument &doc = *static_cast<HTMLDocument*>(impl());298 299 String name = propertyName;300 if (doc.hasNamedItem(name) || doc.hasDocExtraNamedItem(name)) {301 slot.setCustom(this, namedItemGetter);302 return true;303 }304 305 return getStaticValueSlot<JSHTMLDocument, JSDocument>(exec, &HTMLDocumentTable, this, propertyName, slot);306 }307 308 void JSHTMLDocument::put(ExecState* exec, const Identifier &propertyName, JSValue *value, int attr)309 {310 lookupPut<JSHTMLDocument, JSDocument>(exec, propertyName, value, attr, &HTMLDocumentTable, this);311 }312 313 void JSHTMLDocument::putValueProperty(ExecState* exec, int token, JSValue *value, int /*attr*/)314 {315 DOMExceptionTranslator exception(exec);316 HTMLDocument &doc = *static_cast<HTMLDocument*>(impl());317 HTMLElement* body = doc.body();318 HTMLBodyElement* bodyElement = (body && body->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(body) : 0;319 320 switch (token) {321 case Title:322 doc.setTitle(valueToStringWithNullCheck(exec, value));323 break;324 case Body:325 doc.setBody(toHTMLElement(value), exception);326 break;327 case Domain: // not part of the DOM328 doc.setDomain(value->toString(exec));329 break;330 case Cookie:331 doc.setCookie(valueToStringWithNullCheck(exec, value));332 break;333 case Location:334 if (Frame* frame = doc.frame()) {335 DeprecatedString str = value->toString(exec);336 337 // When assigning location, IE and Mozilla both resolve the URL338 // relative to the frame where the JavaScript is executing not339 // the target frame.340 Frame* activeFrame = static_cast<ScriptInterpreter*>( exec->dynamicInterpreter() )->frame();341 if (activeFrame)342 str = activeFrame->document()->completeURL(str);343 344 // We want a new history item if this JS was called via a user gesture345 bool userGesture = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->wasRunByUserGesture();346 frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !userGesture);347 }348 break;349 case BgColor:350 if (bodyElement)351 bodyElement->setBgColor(valueToStringWithNullCheck(exec, value));352 break;353 case FgColor:354 if (bodyElement)355 bodyElement->setText(valueToStringWithNullCheck(exec, value));356 break;357 case AlinkColor:358 if (bodyElement) {359 // this check is a bit silly, but some benchmarks like to set the360 // document's link colors over and over to the same value and we361 // don't want to incur a style update each time.362 String newColor = valueToStringWithNullCheck(exec, value);363 if (bodyElement->aLink() != newColor)364 bodyElement->setALink(newColor);365 }366 break;367 case LinkColor:368 if (bodyElement) {369 // this check is a bit silly, but some benchmarks like to set the370 // document's link colors over and over to the same value and we371 // don't want to incur a style update each time.372 String newColor = valueToStringWithNullCheck(exec, value);373 if (bodyElement->link() != newColor)374 bodyElement->setLink(newColor);375 }376 break;377 case VlinkColor:378 if (bodyElement) {379 // this check is a bit silly, but some benchmarks like to set the380 // document's link colors over and over to the same value and we381 // don't want to incur a style update each time.382 String newColor = valueToStringWithNullCheck(exec, value);383 if (bodyElement->vLink() != newColor)384 bodyElement->setVLink(newColor);385 }386 break;387 case Dir:388 if (body)389 body->setDir(valueToStringWithNullCheck(exec, value));390 break;391 case DesignMode:392 {393 String modeString = valueToStringWithNullCheck(exec, value);394 Document::InheritedBool mode;395 if (equalIgnoringCase(modeString, "on"))396 mode = Document::on;397 else if (equalIgnoringCase(modeString, "off"))398 mode = Document::off;399 else400 mode = Document::inherit;401 doc.setDesignMode(mode);402 break;403 }404 case All:405 // Add "all" to the property map.406 putDirect("all", value);407 break;408 }409 }410 411 // -------------------------------------------------------------------------412 73 413 74 const ClassInfo JSHTMLElement::info = { "HTMLElement", &JSElement::info, &HTMLElementTable, 0 }; -
trunk/WebCore/bindings/js/kjs_html.h
r21651 r21681 37 37 38 38 class JSAbstractEventListener; 39 40 KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(JSHTMLDocumentPrototype, WebCore::JSDocumentPrototype)41 42 class JSHTMLDocument : public WebCore::JSDocument {43 public:44 JSHTMLDocument(ExecState*, WebCore::HTMLDocument*);45 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);46 JSValue* getValueProperty(ExecState*, int token) const;47 virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attr = None);48 void putValueProperty(ExecState*, int token, JSValue*, int /*attr*/);49 virtual const ClassInfo* classInfo() const { return &info; }50 static const ClassInfo info;51 enum { Title, Referrer, Domain, Body, Location, Cookie,52 Images, Applets, Embeds, Links, Forms, Anchors, Scripts, All, Clear, Open, Close,53 Write, WriteLn, GetElementsByName, CaptureEvents, ReleaseEvents,54 BgColor, FgColor, AlinkColor, LinkColor, VlinkColor, LastModified, Height, Width, Dir, DesignMode };55 private:56 static JSValue* namedItemGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);57 };58 39 59 40 // The inheritance chain for JSHTMLElement is a bit different from other -
trunk/WebCore/bindings/objc/DOMPrivate.h
r21655 r21681 43 43 #import <WebCore/DOMHTMLBodyElementPrivate.h> 44 44 #import <WebCore/DOMHTMLButtonElementPrivate.h> 45 #import <WebCore/DOMHTMLDocumentPrivate.h> 45 46 #import <WebCore/DOMHTMLFormElementPrivate.h> 46 47 #import <WebCore/DOMHTMLFrameElementPrivate.h> -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r21624 r21681 4 4 # Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> 5 5 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 6 # Copyright (C) 2006 Apple Computer, Inc.6 # Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 7 7 # 8 8 # This file is part of the KDE project … … 573 573 push(@hashValues, $value); 574 574 575 my $special = "DontDelete"; 576 $special .= "|ReadOnly" if ($attribute->type =~ /readonly/); 575 my @specials = (); 576 push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; 577 push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; 578 my $special = (@specials > 0) ? join("|", @specials) : "0"; 577 579 push(@hashSpecials, $special); 578 580 … … 653 655 push(@hashValues, $value); 654 656 655 my $special = "DontDelete|Function"; 657 my @specials = (); 658 push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"}; 659 push(@specials, "Function"); 660 my $special = (@specials > 0) ? join("|", @specials) : "0"; 656 661 push(@hashSpecials, $special); 657 662 … … 784 789 push(@implContent, " return true;\n"); 785 790 push(@implContent, " }\n"); 786 }787 788 if ($dataNode->extendedAttributes->{"HasNameGetter"} || $dataNode->extendedAttributes->{"HasOverridingNameGetter"}) {789 # if it has a prototype, we need to check that first too790 push(@implContent, " if (prototype()->isObject() && static_cast<JSObject*>(prototype())->hasProperty(exec, propertyName))\n");791 push(@implContent, " return false;\n");792 791 } 793 792 … … 1423 1422 $implIncludes{"kjs_events.h"} = 1; 1424 1423 $implIncludes{"Event.h"} = 1; 1425 } elsif ($type eq "NodeList" or $type eq "NamedNodeMap") {1424 } elsif ($type eq "NodeList") { 1426 1425 $implIncludes{"kjs_dom.h"} = 1; 1426 $implIncludes{"NodeList.h"} = 1; 1427 $implIncludes{"NameNodeList.h"} = 1; 1428 } elsif ($type eq "NamedNodeMap") { 1429 $implIncludes{"kjs_dom.h"} = 1; 1430 $implIncludes{"NamedNodeMap.h"} = 1; 1427 1431 } elsif ($type eq "CSSStyleSheet" or $type eq "StyleSheet" or $type eq "MediaList") { 1428 1432 $implIncludes{"CSSStyleSheet.h"} = 1; -
trunk/WebCore/dom/Document.cpp
r21654 r21681 3330 3330 } 3331 3331 3332 PassRefPtr<HTMLCollection> Document::plugins() 3333 { 3334 // This is an alias for embeds() required for the JS DOM bindings. 3335 return new HTMLCollection(this, HTMLCollection::DocEmbeds); 3336 } 3337 3332 3338 PassRefPtr<HTMLCollection> Document::objects() 3333 3339 { -
trunk/WebCore/dom/Document.h
r21430 r21681 208 208 PassRefPtr<HTMLCollection> images(); 209 209 PassRefPtr<HTMLCollection> embeds(); 210 PassRefPtr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings. 210 211 PassRefPtr<HTMLCollection> applets(); 211 212 PassRefPtr<HTMLCollection> links(); -
trunk/WebCore/html/HTMLDocument.cpp
r21179 r21681 62 62 #include "Frame.h" 63 63 #include "FrameLoader.h" 64 #include "FrameView.h" 65 #include "HTMLBodyElement.h" 64 66 #include "HTMLElement.h" 65 67 #include "HTMLElementFactory.h" … … 115 117 else 116 118 documentElement()->replaceChild(newBody, b, ec); 119 } 120 121 int HTMLDocument::width() const 122 { 123 FrameView* frameView = view(); 124 return frameView ? frameView->contentsWidth() : 0; 125 } 126 127 int HTMLDocument::height() const 128 { 129 FrameView* frameView = view(); 130 return frameView ? frameView->contentsHeight() : 0; 131 } 132 133 String HTMLDocument::dir() 134 { 135 HTMLElement* b = body(); 136 if (!b) 137 return String(); 138 return b->dir(); 139 } 140 141 void HTMLDocument::setDir(const String& value) 142 { 143 HTMLElement* b = body(); 144 if (b) 145 b->setDir(value); 146 } 147 148 String HTMLDocument::designMode() const 149 { 150 return inDesignMode() ? "on" : "off"; 151 } 152 153 void HTMLDocument::setDesignMode(const String& value) 154 { 155 InheritedBool mode; 156 if (equalIgnoringCase(value, "on")) 157 mode = on; 158 else if (equalIgnoringCase(value, "off")) 159 mode = off; 160 else 161 mode = inherit; 162 Document::setDesignMode(mode); 163 } 164 165 String HTMLDocument::bgColor() 166 { 167 HTMLElement* b = body(); 168 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 169 170 if (!bodyElement) 171 return String(); 172 return bodyElement->bgColor(); 173 } 174 175 void HTMLDocument::setBgColor(const String& value) 176 { 177 HTMLElement* b = body(); 178 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 179 180 if (bodyElement) 181 bodyElement->setBgColor(value); 182 } 183 184 String HTMLDocument::fgColor() 185 { 186 HTMLElement* b = body(); 187 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 188 189 if (!bodyElement) 190 return String(); 191 return bodyElement->text(); 192 } 193 194 void HTMLDocument::setFgColor(const String& value) 195 { 196 HTMLElement* b = body(); 197 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 198 199 if (bodyElement) 200 bodyElement->setText(value); 201 } 202 203 String HTMLDocument::alinkColor() 204 { 205 HTMLElement* b = body(); 206 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 207 208 if (!bodyElement) 209 return String(); 210 return bodyElement->aLink(); 211 } 212 213 void HTMLDocument::setAlinkColor(const String& value) 214 { 215 HTMLElement* b = body(); 216 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 217 218 if (bodyElement) { 219 // This check is a bit silly, but some benchmarks like to set the 220 // document's link colors over and over to the same value and we 221 // don't want to incur a style update each time. 222 if (bodyElement->aLink() != value) 223 bodyElement->setALink(value); 224 } 225 } 226 227 String HTMLDocument::linkColor() 228 { 229 HTMLElement* b = body(); 230 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 231 232 if (!bodyElement) 233 return String(); 234 return bodyElement->link(); 235 } 236 237 void HTMLDocument::setLinkColor(const String& value) 238 { 239 HTMLElement* b = body(); 240 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 241 242 if (bodyElement) { 243 // This check is a bit silly, but some benchmarks like to set the 244 // document's link colors over and over to the same value and we 245 // don't want to incur a style update each time. 246 if (bodyElement->link() != value) 247 bodyElement->setLink(value); 248 } 249 } 250 251 String HTMLDocument::vlinkColor() 252 { 253 HTMLElement* b = body(); 254 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 255 256 if (!bodyElement) 257 return String(); 258 return bodyElement->vLink(); 259 } 260 261 void HTMLDocument::setVlinkColor(const String& value) 262 { 263 HTMLElement* b = body(); 264 HTMLBodyElement* bodyElement = (b && b->hasTagName(bodyTag)) ? static_cast<HTMLBodyElement*>(b) : 0; 265 266 if (bodyElement) { 267 // This check is a bit silly, but some benchmarks like to set the 268 // document's link colors over and over to the same value and we 269 // don't want to incur a style update each time. 270 if (bodyElement->vLink() != value) 271 bodyElement->setVLink(value); 272 } 273 } 274 275 void HTMLDocument::captureEvents() 276 { 277 } 278 279 void HTMLDocument::releaseEvents() 280 { 117 281 } 118 282 -
trunk/WebCore/html/HTMLDocument.h
r21179 r21681 45 45 void setBody(HTMLElement*, ExceptionCode&); 46 46 47 int width() const; 48 int height() const; 49 50 String dir(); 51 void setDir(const String&); 52 53 String designMode() const; 54 void setDesignMode(const String&); 55 56 String bgColor(); 57 void setBgColor(const String&); 58 String fgColor(); 59 void setFgColor(const String&); 60 String alinkColor(); 61 void setAlinkColor(const String&); 62 String linkColor(); 63 void setLinkColor(const String&); 64 String vlinkColor(); 65 void setVlinkColor(const String&); 66 67 void captureEvents(); 68 void releaseEvents(); 69 47 70 virtual Tokenizer* createTokenizer(); 48 71 -
trunk/WebCore/html/HTMLDocument.idl
r21470 r21681 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 4 4 * … … 21 21 module html { 22 22 23 interface [LegacyParent=KJS::JSHTMLDocument, GenerateConstructor] HTMLDocument : Document { 24 #if !defined(LANGUAGE_JAVASCRIPT) 23 interface [GenerateConstructor, HasOverridingNameGetter] HTMLDocument : Document { 25 24 attribute [ConvertNullToNullString] DOMString title; 26 25 readonly attribute DOMString referrer; 26 #if defined(LANGUAGE_JAVASCRIPT) 27 attribute DOMString domain; 28 #else 27 29 readonly attribute DOMString domain; 30 #endif 28 31 readonly attribute DOMString URL; 29 32 … … 44 47 /*setter raises (DOMException)*/; 45 48 46 voidopen();47 void 48 voidwrite(in DOMString text);49 voidwriteln(in DOMString text);50 NodeList 49 [Custom] void open(); 50 void close(); 51 [Custom] void write(in DOMString text); 52 [Custom] void writeln(in DOMString text); 53 NodeList getElementsByName(in DOMString elementName); 51 54 52 // non-standard 55 // Extensions 56 Element getElementById(in DOMString elementId); 53 57 54 Element getElementById(in DOMString elementId); 58 readonly attribute HTMLCollection embeds; 59 readonly attribute HTMLCollection plugins; 60 readonly attribute HTMLCollection scripts; 61 62 readonly attribute DOMString lastModified; 63 64 #if defined(LANGUAGE_JAVASCRIPT) 65 // FIXME: These should eventually be available (if they are wanted) for all languages. 66 67 attribute [Custom, Deletable] HTMLCollection all; 68 69 attribute [Custom] Window location; 70 71 [Custom] void clear(); 55 72 #endif 73 74 void captureEvents(); 75 void releaseEvents(); 76 77 readonly attribute long width; 78 readonly attribute long height; 79 attribute [ConvertNullToNullString] DOMString dir; 80 attribute [ConvertNullToNullString] DOMString designMode; 81 82 // Deprecated attributes 83 attribute [ConvertNullToNullString] DOMString bgColor; 84 attribute [ConvertNullToNullString] DOMString fgColor; 85 attribute [ConvertNullToNullString] DOMString alinkColor; 86 attribute [ConvertNullToNullString] DOMString linkColor; 87 attribute [ConvertNullToNullString] DOMString vlinkColor; 56 88 }; 57 89 58 90 } 59 -
trunk/WebKit/ChangeLog
r21678 r21681 1 2007-05-23 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Darin. 4 5 Patch for http://bugs.webkit.org/show_bug.cgi?id=13830 6 Auto-generate JS DOM bindings for HTMLDocument and most of the rest 7 of HTMLElement 8 9 * MigrateHeaders.make: add DOMHTMLDocumentPrivate.h 10 * WebKit.xcodeproj/project.pbxproj: 11 1 12 2007-05-23 Oliver Hunt <oliver@apple.com> 2 13 -
trunk/WebKit/MigrateHeaders.make
r21655 r21681 94 94 $(PUBLIC_HEADERS_DIR)/DOMHTMLDivElement.h \ 95 95 $(PUBLIC_HEADERS_DIR)/DOMHTMLDocument.h \ 96 $(PRIVATE_HEADERS_DIR)/DOMHTMLDocumentPrivate.h \ 96 97 $(PUBLIC_HEADERS_DIR)/DOMHTMLElement.h \ 97 98 $(INTERNAL_HEADERS_DIR)/DOMHTMLElementInternal.h \ -
trunk/WebKit/WebKit.xcodeproj/project.pbxproj
r21618 r21681 1318 1318 isa = PBXProject; 1319 1319 buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */; 1320 compatibilityVersion = "Xcode 2.4";1321 1320 hasScannedForEncodings = 1; 1322 1321 knownRegions = ( … … 1333 1332 projectDirPath = ""; 1334 1333 projectRoot = ""; 1335 shouldCheckCompatibility = 1;1336 1334 targets = ( 1337 1335 9398100A0824BF01008DF038 /* WebKit */,
Note: See TracChangeset
for help on using the changeset viewer.