Changeset 24182 in webkit


Ignore:
Timestamp:
Jul 10, 2007 10:10:24 PM (17 years ago)
Author:
weinig
Message:

LayoutTests:

Reviewed by Oliver.

  • fast/dom/Window/get-set-properties-expected.txt: Added.
  • fast/dom/Window/get-set-properties.html: Added.

WebCore:

Reviewed by Oliver.

Move more attributes from the pure JS bindings in KJS::Window
to the implementation in DOMWindow and autogenerate the new bindings

Test: fast/dom/Window/get-set-properties.html

  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::customGetOwnPropertySlot): Change to use propHashTable in JSDOMWindow instead of KJS::Window
  • bindings/js/kjs_window.cpp: (KJS::Window::getValueProperty): (KJS::Window::put):
  • bindings/js/kjs_window.h: (KJS::Window::):
  • bindings/scripts/CodeGeneratorJS.pm: Cleanup getValueProperty and put generation to reduce code duplication.
  • page/DOMWindow.cpp: (WebCore::DOMWindow::closed): (WebCore::DOMWindow::length): (WebCore::DOMWindow::name): (WebCore::DOMWindow::setName): (WebCore::DOMWindow::status): (WebCore::DOMWindow::setStatus): (WebCore::DOMWindow::defaultStatus): (WebCore::DOMWindow::setDefaultStatus):
  • page/DOMWindow.h: (WebCore::DOMWindow::defaultstatus): (WebCore::DOMWindow::setDefaultstatus):
  • page/DOMWindow.idl:
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r24181 r24182  
     12007-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
    182007-07-10  Sam Weinig  <sam@webkit.org>
    29
  • trunk/WebCore/ChangeLog

    r24181 r24182  
     12007-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
    1342007-07-10  Sam Weinig  <sam@webkit.org>
    235
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r24028 r24182  
    3030    if (!frame()) {
    3131        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);
    3333            ASSERT(entry);
    3434            if (entry) {
    35                 slot.setStaticEntry(this, entry, KJS::staticValueGetter<KJS::Window>);
     35                slot.setStaticEntry(this, entry, KJS::staticValueGetter<JSDOMWindow>);
    3636                return true;
    3737            }
  • trunk/WebCore/bindings/js/kjs_window.cpp

    r24181 r24182  
    175175  stop                  Window::Stop                DontDelete|Function 0
    176176# -- Attributes --
    177   closed                Window::Closed              DontDelete|ReadOnly
    178177  crypto                Window::Crypto              DontDelete|ReadOnly
    179   defaultStatus         Window::DefaultStatus       DontDelete
    180   defaultstatus         Window::DefaultStatus       DontDelete
    181   status                Window::Status              DontDelete
    182178  frames                Window::Frames              DontDelete|ReadOnly
    183179  event                 Window::Event_              DontDelete
    184   length                Window::Length              DontDelete|ReadOnly
    185180  location              Window::Location_           DontDelete
    186   name                  Window::Name                DontDelete
    187181  navigator             Window::Navigator_          DontDelete|ReadOnly
    188182  clientInformation     Window::ClientInformation   DontDelete|ReadOnly
     
    518512JSValue *Window::getValueProperty(ExecState *exec, int token) const
    519513{
    520    ASSERT(token == Closed || m_frame);
     514   ASSERT(m_frame);
    521515
    522516   switch (token) {
    523    case Closed:
    524       return jsBoolean(!m_frame);
    525517   case Crypto:
    526518      if (!isSafeScript(exec))
    527519        return jsUndefined();
    528520      return jsUndefined(); // FIXME: implement this
    529    case DefaultStatus:
    530       if (!isSafeScript(exec))
    531         return jsUndefined();
    532       return jsString(UString(m_frame->jsDefaultStatusBarText()));
    533521   case DOMException:
    534522      if (!isSafeScript(exec))
    535523        return jsUndefined();
    536524      return getDOMExceptionConstructor(exec);
    537    case Status:
    538       if (!isSafeScript(exec))
    539         return jsUndefined();
    540       return jsString(UString(m_frame->jsStatusBarText()));
    541525    case Frames:
    542526      return retrieve(m_frame);
     
    547531        return jsUndefined();
    548532      return toJS(exec, d->m_evt);
    549     case Length:
    550       return jsNumber(m_frame->tree()->childCount());
    551533    case Location_:
    552534      return location();
    553     case Name:
    554       if (!isSafeScript(exec))
    555         return jsUndefined();
    556       return jsString(m_frame->tree()->name());
    557535    case Navigator_:
    558536    case ClientInformation: {
     
    762740
    763741    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;
    772742    case Location_: {
    773743      Frame* p = Window::retrieveActive(exec)->m_frame;
     
    881851      if (isSafeScript(exec))
    882852        setListener(exec, unloadEvent, value);
    883       return;
    884     case Name:
    885       if (isSafeScript(exec))
    886         m_frame->tree()->setName(value->toString(exec));
    887853      return;
    888854    default:
  • trunk/WebCore/bindings/js/kjs_window.h

    r24176 r24182  
    157157
    158158        // 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,
    162161        Parent, Self, Window_, Top,
    163162        FrameElement,
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r24165 r24182  
    879879            }
    880880
     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
    881892            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                 }
    887893                push(@implContent, "        return $name(exec);\n");
    888894            } 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");
    891895                $implIncludes{"Document.h"} = 1;
    892896                $implIncludes{"kjs_dom.h"} = 1;
     897                push(@implContent, "        return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature,  $implClassNameForValueConversion, "imp->$name()") . " : jsUndefined();\n");
    893898            } elsif ($attribute->signature->type =~ /Constructor$/) {
    894899                my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
    895900                $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                 }
    902901                push(@implContent, "        return JS" . $constructorType . "::getConstructor(exec);\n");
    903902            } 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        
    910903                if ($podType) {
    911904                    if ($podType eq "double") { # Special case for JSSVGNumber
     
    919912
    920913                    if ($codeGenerator->IsSVGAnimatedType($type)) {
    921                         push(@implContent, "    {\n");   
    922914                        push(@implContent, "        ASSERT(exec && exec->dynamicInterpreter());\n\n");
    923915                        push(@implContent, "        RefPtr<$type> obj = $jsType;\n");
     
    933925                        push(@implContent, "        }\n\n");
    934926                        push(@implContent, "        return toJS(exec, obj.get());\n");
    935                         push(@implContent, "    }\n");
    936927                    } elsif ($attribute->signature->extendedAttributes->{"NullCheck"}) {
    937928                        push(@implContent, "        return imp->$name() ? $jsType : jsUndefined();\n");
     
    941932                }
    942933            } 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                 }
    948934                push(@implContent, "        ExceptionCode ec = 0;\n");
    949935       
     
    958944                push(@implContent, "        setDOMException(exec, ec);\n");
    959945                push(@implContent, "        return result;\n");
    960                 push(@implContent, "    }\n");
    961946            }
     947            push(@implContent, "    }\n");
    962948        }
    963949
     
    967953        }
    968954
    969         push(@implContent, "    }\n    return 0;\n}\n\n");
     955        push(@implContent, "    }\n");
     956        push(@implContent, "    return 0;\n}\n\n");
    970957
    971958        # Check if we have any writable attributes
     
    1008995                    my $name = $attribute->signature->name;
    1009996
     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
    10101008                    if ($attribute->signature->extendedAttributes->{"Custom"}) {
    1011                         push(@implContent, "    case " . WK_ucfirst($name) . "AttrNum: {\n");
    10121009                        push(@implContent, "        set" . WK_ucfirst($name) . "(exec, value);\n");
    10131010                    } elsif ($attribute->signature->type =~ /Constructor$/) {
    10141011                        my $constructorType = $attribute->signature->type;
    10151012                        $constructorType =~ s/Constructor$//;
    1016 
    10171013                        $implIncludes{"JS" . $constructorType . ".h"} = 1;
    1018                         push(@implContent, "    case " . $name ."ConstructorAttrNum: {\n");
    10191014                        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");
    10241016                    } else {
    1025                         push(@implContent, "    case " . WK_ucfirst($name) ."AttrNum: {\n");
    10261017                        if ($podType) {
    10271018                            if ($podType eq "double") { # Special case for JSSVGNumber
     
    10461037
    10471038            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 "") {
    10521040                push(@implContent, "    ASSERT(exec && exec->dynamicInterpreter());\n");
    10531041                push(@implContent, "    Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame();\n");
  • trunk/WebCore/page/DOMWindow.cpp

    r24178 r24182  
    3636#include "Frame.h"
    3737#include "FrameLoader.h"
     38#include "FrameTree.h"
    3839#include "FrameView.h"
    3940#include "History.h"
    4041#include "Page.h"
    4142#include "PlatformScreen.h"
     43#include "PlatformString.h"
    4244#include "Screen.h"
    4345#include "cssstyleselector.h"
     
    281283}
    282284
     285bool DOMWindow::closed() const
     286{
     287    return !m_frame;
     288}
     289
     290unsigned DOMWindow::length() const
     291{
     292    if (!m_frame)
     293        return 0;
     294
     295    return m_frame->tree()->childCount();
     296}
     297
     298String DOMWindow::name() const
     299{
     300    if (!m_frame)
     301        return String();
     302
     303    return m_frame->tree()->name();
     304}
     305
     306void DOMWindow::setName(const String& string)
     307{
     308    if (!m_frame)
     309        return;
     310
     311    m_frame->tree()->setName(string);
     312}
     313
     314String DOMWindow::status() const
     315{
     316    if (!m_frame)
     317        return String();
     318
     319    return m_frame->jsStatusBarText();
     320}
     321
     322void DOMWindow::setStatus(const String& string)
     323{
     324    if (!m_frame)
     325        return;
     326
     327    m_frame->setJSStatusBarText(string);
     328}
     329
     330String DOMWindow::defaultStatus() const
     331{
     332    if (!m_frame)
     333        return String();
     334
     335    return m_frame->jsDefaultStatusBarText();
     336}
     337
     338void DOMWindow::setDefaultStatus(const String& string)
     339{
     340    if (!m_frame)
     341        return;
     342
     343    m_frame->setJSDefaultStatusBarText(string);
     344}
     345
    283346Document* DOMWindow::document() const
    284347{
  • trunk/WebCore/page/DOMWindow.h

    r24176 r24182  
    2727#define DOMWindow_h
    2828
     29#include "PlatformString.h"
    2930#include "Shared.h"
    3031#include <wtf/Forward.h>
     
    4243    class History;
    4344    class Screen;
    44     class String;
    4545   
    4646    class DOMWindow : public Shared<DOMWindow> {
     
    8383        int pageYOffset() const { return scrollY(); }
    8484
     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
    85100        // DOM Level 2 AbstractView Interface
    86101        Document* document() const;
  • trunk/WebCore/page/DOMWindow.idl

    r24176 r24182  
    5757        readonly attribute long pageXOffset;
    5858        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
    5972
    6073        // DOM Level 2 AbstractView Interface
Note: See TracChangeset for help on using the changeset viewer.