Changeset 106208 in webkit


Ignore:
Timestamp:
Jan 29, 2012 7:47:32 PM (12 years ago)
Author:
hayato@chromium.org
Message:

Add a ShadowRoot constructor as 'WebKitShadowRootConstructor', enabled by SHADOW_DOM flag.
https://bugs.webkit.org/show_bug.cgi?id=76354

Reviewed by Hajime Morita.

We use vendor-prefixed name, 'WebKitShadowRoot', instead of 'ShadowRoot'
since this is a feature under development.

Source/WebCore:

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::create):
(WebCore):

  • dom/ShadowRoot.h:

(WebCore):
(ShadowRoot):

  • dom/ShadowRoot.idl:
  • page/DOMWindow.idl:

LayoutTests:

  • fast/dom/shadow/shadow-root-js-api.html:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106206 r106208  
     12012-01-29  Hayato Ito  <hayato@chromium.org>
     2
     3        Add a ShadowRoot constructor as 'WebKitShadowRootConstructor', enabled by SHADOW_DOM flag.
     4        https://bugs.webkit.org/show_bug.cgi?id=76354
     5
     6        Reviewed by Hajime Morita.
     7
     8        We use vendor-prefixed name, 'WebKitShadowRoot', instead of 'ShadowRoot'
     9        since this is a feature under development.
     10
     11        * fast/dom/shadow/shadow-root-js-api.html:
     12
    1132012-01-29  Yuzo Fujishima  <yuzo@google.com>
    214
  • trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt

    r105500 r106208  
    44
    55
     6PASS new WebKitShadowRoot() threw exception TypeError: Not enough arguments.
     7PASS new WebKitShadowRoot(undefined) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
     8PASS new WebKitShadowRoot(null) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
     9PASS new WebKitShadowRoot(1) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
     10PASS shadowHost is shadowRoot.host
     11PASS new WebKitShadowRoot(shadowHost) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
     12The previous test should not have side effects.
    613PASS shadowHost is shadowRoot.host
    714PASS successfullyParsed is true
  • trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html

    r105500 r106208  
    1111if (window.layoutTestController)
    1212    layoutTestController.dumpAsText();
     13shouldThrow("new WebKitShadowRoot()");
     14shouldThrow("new WebKitShadowRoot(undefined)");
     15shouldThrow("new WebKitShadowRoot(null)");
     16shouldThrow("new WebKitShadowRoot(1)");
    1317var shadowHost = document.createElement('div');
    14 internals.ensureShadowRoot(shadowHost);
    15 var shadowRoot = internals.shadowRoot(shadowHost);
     18var shadowRoot = new WebKitShadowRoot(shadowHost);
     19shouldBe("shadowHost", "shadowRoot.host");
     20shouldThrow("new WebKitShadowRoot(shadowHost)");
     21debug('The previous test should not have side effects.');
    1622shouldBe("shadowHost", "shadowRoot.host");
    1723
  • trunk/Source/WebCore/ChangeLog

    r106203 r106208  
     12012-01-29  Hayato Ito  <hayato@chromium.org>
     2
     3        Add a ShadowRoot constructor as 'WebKitShadowRootConstructor', enabled by SHADOW_DOM flag.
     4        https://bugs.webkit.org/show_bug.cgi?id=76354
     5
     6        Reviewed by Hajime Morita.
     7
     8        We use vendor-prefixed name, 'WebKitShadowRoot', instead of 'ShadowRoot'
     9        since this is a feature under development.
     10
     11        * dom/ShadowRoot.cpp:
     12        (WebCore::ShadowRoot::create):
     13        (WebCore):
     14        * dom/ShadowRoot.h:
     15        (WebCore):
     16        (ShadowRoot):
     17        * dom/ShadowRoot.idl:
     18        * page/DOMWindow.idl:
     19
    1202012-01-29  Noel Gordon  <noel.gordon@gmail.com>
    221
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r105249 r106208  
    5252ShadowRoot::~ShadowRoot()
    5353{
     54}
     55
     56PassRefPtr<ShadowRoot> ShadowRoot::create(Element* element, ExceptionCode& ec)
     57{
     58    if (!element || element->shadowRoot()) {
     59        ec = HIERARCHY_REQUEST_ERR;
     60        return 0;
     61    }
     62    RefPtr<ShadowRoot> shadowRoot = create(element->document());
     63    element->setShadowRoot(shadowRoot, ec);
     64    if (ec)
     65        return 0;
     66    return shadowRoot.release();
    5467}
    5568
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r105500 r106208  
    2828#define ShadowRoot_h
    2929
     30#include "ExceptionCode.h"
    3031#include "TreeScope.h"
    3132
    3233namespace WebCore {
    3334
     35class ContentInclusionSelector;
    3436class Document;
    3537class HTMLContentElement;
    36 class ContentInclusionSelector;
    3738
    3839class ShadowRoot : public TreeScope {
    3940public:
    4041    static PassRefPtr<ShadowRoot> create(Document*);
     42    static PassRefPtr<ShadowRoot> create(Element*, ExceptionCode&);
    4143
    4244    void recalcShadowTreeStyle(StyleChange);
  • trunk/Source/WebCore/dom/ShadowRoot.idl

    r105500 r106208  
    2929    interface [
    3030        Conditional=SHADOW_DOM,
    31         EnabledAtRuntime=shadowDOM
     31        EnabledAtRuntime=shadowDOM,
     32        Constructor(in Element host),
     33        ConstructorRaisesException
    3234    ] ShadowRoot : Node {
    3335        readonly attribute Element host;
  • trunk/Source/WebCore/page/DOMWindow.idl

    r106087 r106208  
    399399        attribute EntityReferenceConstructor EntityReference;
    400400        attribute ProcessingInstructionConstructor ProcessingInstruction;
     401        attribute [Conditional=SHADOW_DOM, EnabledAtRuntime=shadowDOM] ShadowRootConstructor WebKitShadowRoot;
    401402
    402403        attribute HTMLDocumentConstructor HTMLDocument;
Note: See TracChangeset for help on using the changeset viewer.