Changeset 24182 in webkit
- Timestamp:
- Jul 10, 2007 10:10:24 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r24181 r24182 1 2007-07-10 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Oliver. 4 5 * fast/dom/Window/get-set-properties-expected.txt: Added. 6 * fast/dom/Window/get-set-properties.html: Added. 7 1 8 2007-07-10 Sam Weinig <sam@webkit.org> 2 9 -
trunk/WebCore/ChangeLog
r24181 r24182 1 2007-07-10 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Oliver. 4 5 Move more attributes from the pure JS bindings in KJS::Window 6 to the implementation in DOMWindow and autogenerate the new bindings 7 8 Test: fast/dom/Window/get-set-properties.html 9 10 * bindings/js/JSDOMWindowCustom.cpp: 11 (WebCore::JSDOMWindow::customGetOwnPropertySlot): Change to use propHashTable in 12 JSDOMWindow instead of KJS::Window 13 * bindings/js/kjs_window.cpp: 14 (KJS::Window::getValueProperty): 15 (KJS::Window::put): 16 * bindings/js/kjs_window.h: 17 (KJS::Window::): 18 * bindings/scripts/CodeGeneratorJS.pm: Cleanup getValueProperty and put generation 19 to reduce code duplication. 20 * page/DOMWindow.cpp: 21 (WebCore::DOMWindow::closed): 22 (WebCore::DOMWindow::length): 23 (WebCore::DOMWindow::name): 24 (WebCore::DOMWindow::setName): 25 (WebCore::DOMWindow::status): 26 (WebCore::DOMWindow::setStatus): 27 (WebCore::DOMWindow::defaultStatus): 28 (WebCore::DOMWindow::setDefaultStatus): 29 * page/DOMWindow.h: 30 (WebCore::DOMWindow::defaultstatus): 31 (WebCore::DOMWindow::setDefaultstatus): 32 * page/DOMWindow.idl: 33 1 34 2007-07-10 Sam Weinig <sam@webkit.org> 2 35 -
trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp
r24028 r24182 30 30 if (!frame()) { 31 31 if (propertyName == "closed") { 32 const KJS::HashEntry* entry = KJS::Lookup::findEntry( KJS::Window::classInfo()->propHashTable, propertyName);32 const KJS::HashEntry* entry = KJS::Lookup::findEntry(classInfo()->propHashTable, propertyName); 33 33 ASSERT(entry); 34 34 if (entry) { 35 slot.setStaticEntry(this, entry, KJS::staticValueGetter< KJS::Window>);35 slot.setStaticEntry(this, entry, KJS::staticValueGetter<JSDOMWindow>); 36 36 return true; 37 37 } -
trunk/WebCore/bindings/js/kjs_window.cpp
r24181 r24182 175 175 stop Window::Stop DontDelete|Function 0 176 176 # -- Attributes -- 177 closed Window::Closed DontDelete|ReadOnly178 177 crypto Window::Crypto DontDelete|ReadOnly 179 defaultStatus Window::DefaultStatus DontDelete180 defaultstatus Window::DefaultStatus DontDelete181 status Window::Status DontDelete182 178 frames Window::Frames DontDelete|ReadOnly 183 179 event Window::Event_ DontDelete 184 length Window::Length DontDelete|ReadOnly185 180 location Window::Location_ DontDelete 186 name Window::Name DontDelete187 181 navigator Window::Navigator_ DontDelete|ReadOnly 188 182 clientInformation Window::ClientInformation DontDelete|ReadOnly … … 518 512 JSValue *Window::getValueProperty(ExecState *exec, int token) const 519 513 { 520 ASSERT( token == Closed ||m_frame);514 ASSERT(m_frame); 521 515 522 516 switch (token) { 523 case Closed:524 return jsBoolean(!m_frame);525 517 case Crypto: 526 518 if (!isSafeScript(exec)) 527 519 return jsUndefined(); 528 520 return jsUndefined(); // FIXME: implement this 529 case DefaultStatus:530 if (!isSafeScript(exec))531 return jsUndefined();532 return jsString(UString(m_frame->jsDefaultStatusBarText()));533 521 case DOMException: 534 522 if (!isSafeScript(exec)) 535 523 return jsUndefined(); 536 524 return getDOMExceptionConstructor(exec); 537 case Status:538 if (!isSafeScript(exec))539 return jsUndefined();540 return jsString(UString(m_frame->jsStatusBarText()));541 525 case Frames: 542 526 return retrieve(m_frame); … … 547 531 return jsUndefined(); 548 532 return toJS(exec, d->m_evt); 549 case Length:550 return jsNumber(m_frame->tree()->childCount());551 533 case Location_: 552 534 return location(); 553 case Name:554 if (!isSafeScript(exec))555 return jsUndefined();556 return jsString(m_frame->tree()->name());557 535 case Navigator_: 558 536 case ClientInformation: { … … 762 740 763 741 switch (entry->value) { 764 case Status:765 if (isSafeScript(exec))766 m_frame->setJSStatusBarText(value->toString(exec));767 return;768 case DefaultStatus:769 if (isSafeScript(exec))770 m_frame->setJSDefaultStatusBarText(value->toString(exec));771 return;772 742 case Location_: { 773 743 Frame* p = Window::retrieveActive(exec)->m_frame; … … 881 851 if (isSafeScript(exec)) 882 852 setListener(exec, unloadEvent, value); 883 return;884 case Name:885 if (isSafeScript(exec))886 m_frame->tree()->setName(value->toString(exec));887 853 return; 888 854 default: -
trunk/WebCore/bindings/js/kjs_window.h
r24176 r24182 157 157 158 158 // Attributes 159 Closed, Crypto, DefaultStatus, Status, 160 Frames, Event_, Length, Location_, 161 Name, Navigator_, ClientInformation, Opener, 159 Crypto, Frames, Event_, Location_, 160 Navigator_, ClientInformation, Opener, 162 161 Parent, Self, Window_, Top, 163 162 FrameElement, -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r24165 r24182 879 879 } 880 880 881 if ($attribute->signature->type =~ /Constructor$/) { 882 push(@implContent, " case " . $name . "ConstructorAttrNum: {\n"); 883 } else { 884 push(@implContent, " case " . WK_ucfirst($name) . "AttrNum: {\n"); 885 } 886 887 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { 888 push(@implContent, " if (!isSafeScript(exec))\n"); 889 push(@implContent, " return jsUndefined();\n"); 890 } 891 881 892 if ($attribute->signature->extendedAttributes->{"Custom"}) { 882 push(@implContent, " case " . WK_ucfirst($name) . "AttrNum:\n");883 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {884 push(@implContent, " if (!isSafeScript(exec))\n");885 push(@implContent, " return jsUndefined();");886 }887 893 push(@implContent, " return $name(exec);\n"); 888 894 } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { 889 push(@implContent, " case " . WK_ucfirst($name) . "AttrNum:\n");890 push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, $implClassNameForValueConversion, "imp->$name()") . " : jsUndefined();\n");891 895 $implIncludes{"Document.h"} = 1; 892 896 $implIncludes{"kjs_dom.h"} = 1; 897 push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, $implClassNameForValueConversion, "imp->$name()") . " : jsUndefined();\n"); 893 898 } elsif ($attribute->signature->type =~ /Constructor$/) { 894 899 my $constructorType = $codeGenerator->StripModule($attribute->signature->type); 895 900 $constructorType =~ s/Constructor$//; 896 897 push(@implContent, " case " . $name . "ConstructorAttrNum:\n");898 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {899 push(@implContent, " if (!isSafeScript(exec))\n");900 push(@implContent, " return jsUndefined();\n");901 }902 901 push(@implContent, " return JS" . $constructorType . "::getConstructor(exec);\n"); 903 902 } elsif (!@{$attribute->getterExceptions}) { 904 push(@implContent, " case " . WK_ucfirst($name) . "AttrNum:\n");905 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {906 push(@implContent, " if (!isSafeScript(exec))\n");907 push(@implContent, " return jsUndefined();\n");908 }909 910 903 if ($podType) { 911 904 if ($podType eq "double") { # Special case for JSSVGNumber … … 919 912 920 913 if ($codeGenerator->IsSVGAnimatedType($type)) { 921 push(@implContent, " {\n");922 914 push(@implContent, " ASSERT(exec && exec->dynamicInterpreter());\n\n"); 923 915 push(@implContent, " RefPtr<$type> obj = $jsType;\n"); … … 933 925 push(@implContent, " }\n\n"); 934 926 push(@implContent, " return toJS(exec, obj.get());\n"); 935 push(@implContent, " }\n");936 927 } elsif ($attribute->signature->extendedAttributes->{"NullCheck"}) { 937 928 push(@implContent, " return imp->$name() ? $jsType : jsUndefined();\n"); … … 941 932 } 942 933 } else { 943 push(@implContent, " case " . WK_ucfirst($name) . "AttrNum: {\n");944 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {945 push(@implContent, " if (!isSafeScript(exec))\n");946 push(@implContent, " return jsUndefined();\n");947 }948 934 push(@implContent, " ExceptionCode ec = 0;\n"); 949 935 … … 958 944 push(@implContent, " setDOMException(exec, ec);\n"); 959 945 push(@implContent, " return result;\n"); 960 push(@implContent, " }\n");961 946 } 947 push(@implContent, " }\n"); 962 948 } 963 949 … … 967 953 } 968 954 969 push(@implContent, " }\n return 0;\n}\n\n"); 955 push(@implContent, " }\n"); 956 push(@implContent, " return 0;\n}\n\n"); 970 957 971 958 # Check if we have any writable attributes … … 1008 995 my $name = $attribute->signature->name; 1009 996 997 if ($attribute->signature->type =~ /Constructor$/) { 998 push(@implContent, " case " . $name ."ConstructorAttrNum: {\n"); 999 } else { 1000 push(@implContent, " case " . WK_ucfirst($name) . "AttrNum: {\n"); 1001 } 1002 1003 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { 1004 push(@implContent, " if (!isSafeScript(exec))\n"); 1005 push(@implContent, " return;\n"); 1006 } 1007 1010 1008 if ($attribute->signature->extendedAttributes->{"Custom"}) { 1011 push(@implContent, " case " . WK_ucfirst($name) . "AttrNum: {\n");1012 1009 push(@implContent, " set" . WK_ucfirst($name) . "(exec, value);\n"); 1013 1010 } elsif ($attribute->signature->type =~ /Constructor$/) { 1014 1011 my $constructorType = $attribute->signature->type; 1015 1012 $constructorType =~ s/Constructor$//; 1016 1017 1013 $implIncludes{"JS" . $constructorType . ".h"} = 1; 1018 push(@implContent, " case " . $name ."ConstructorAttrNum: {\n");1019 1014 push(@implContent, " // Shadowing a built-in constructor\n"); 1020 1021 # FIXME: We need to provide scalable hooks/attributes for this kind of extension 1022 push(@implContent, " if (isSafeScript(exec))\n"); 1023 push(@implContent, " JSObject::put(exec, \"$name\", value);\n"); 1015 push(@implContent, " JSObject::put(exec, \"$name\", value);\n"); 1024 1016 } else { 1025 push(@implContent, " case " . WK_ucfirst($name) ."AttrNum: {\n");1026 1017 if ($podType) { 1027 1018 if ($podType eq "double") { # Special case for JSSVGNumber … … 1046 1037 1047 1038 my $contextInterfaceName = CreateSVGContextInterfaceName($interfaceName); 1048 if ($interfaceName eq "DOMWindow") { 1049 push(@implContent, " // FIXME: Hack to prevent unused variable warning -- remove once DOMWindow includes a settable property\n"); 1050 push(@implContent, " (void)imp;\n"); 1051 } elsif ($contextInterfaceName ne "") { 1039 if ($contextInterfaceName ne "") { 1052 1040 push(@implContent, " ASSERT(exec && exec->dynamicInterpreter());\n"); 1053 1041 push(@implContent, " Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame();\n"); -
trunk/WebCore/page/DOMWindow.cpp
r24178 r24182 36 36 #include "Frame.h" 37 37 #include "FrameLoader.h" 38 #include "FrameTree.h" 38 39 #include "FrameView.h" 39 40 #include "History.h" 40 41 #include "Page.h" 41 42 #include "PlatformScreen.h" 43 #include "PlatformString.h" 42 44 #include "Screen.h" 43 45 #include "cssstyleselector.h" … … 281 283 } 282 284 285 bool DOMWindow::closed() const 286 { 287 return !m_frame; 288 } 289 290 unsigned DOMWindow::length() const 291 { 292 if (!m_frame) 293 return 0; 294 295 return m_frame->tree()->childCount(); 296 } 297 298 String DOMWindow::name() const 299 { 300 if (!m_frame) 301 return String(); 302 303 return m_frame->tree()->name(); 304 } 305 306 void DOMWindow::setName(const String& string) 307 { 308 if (!m_frame) 309 return; 310 311 m_frame->tree()->setName(string); 312 } 313 314 String DOMWindow::status() const 315 { 316 if (!m_frame) 317 return String(); 318 319 return m_frame->jsStatusBarText(); 320 } 321 322 void DOMWindow::setStatus(const String& string) 323 { 324 if (!m_frame) 325 return; 326 327 m_frame->setJSStatusBarText(string); 328 } 329 330 String DOMWindow::defaultStatus() const 331 { 332 if (!m_frame) 333 return String(); 334 335 return m_frame->jsDefaultStatusBarText(); 336 } 337 338 void DOMWindow::setDefaultStatus(const String& string) 339 { 340 if (!m_frame) 341 return; 342 343 m_frame->setJSDefaultStatusBarText(string); 344 } 345 283 346 Document* DOMWindow::document() const 284 347 { -
trunk/WebCore/page/DOMWindow.h
r24176 r24182 27 27 #define DOMWindow_h 28 28 29 #include "PlatformString.h" 29 30 #include "Shared.h" 30 31 #include <wtf/Forward.h> … … 42 43 class History; 43 44 class Screen; 44 class String;45 45 46 46 class DOMWindow : public Shared<DOMWindow> { … … 83 83 int pageYOffset() const { return scrollY(); } 84 84 85 bool closed() const; 86 87 unsigned length() const; 88 89 String name() const; 90 void setName(const String&); 91 92 String status() const; 93 void setStatus(const String&); 94 String defaultStatus() const; 95 void setDefaultStatus(const String&); 96 // This attribute is an alias of defaultStatus and is necessary for legacy uses. 97 String defaultstatus() const { return defaultStatus(); } 98 void setDefaultstatus(const String& string) { setDefaultStatus(string); } 99 85 100 // DOM Level 2 AbstractView Interface 86 101 Document* document() const; -
trunk/WebCore/page/DOMWindow.idl
r24176 r24182 57 57 readonly attribute long pageXOffset; 58 58 readonly attribute long pageYOffset; 59 60 readonly attribute [DoNotCheckDomainSecurity] boolean closed; 61 62 readonly attribute [DoNotCheckDomainSecurity] unsigned long length; 63 64 attribute DOMString name; 65 66 attribute DOMString status; 67 attribute DOMString defaultStatus; 68 #if defined(LANGUAGE_JAVASCRIPT) 69 // This attribute is an alias of defaultStatus and is necessary for legacy uses. 70 attribute DOMString defaultstatus; 71 #endif 59 72 60 73 // DOM Level 2 AbstractView Interface
Note: See TracChangeset
for help on using the changeset viewer.