Changeset 109096 in webkit


Ignore:
Timestamp:
Feb 28, 2012 3:36:37 AM (12 years ago)
Author:
shinyak@chromium.org
Message:

Element should be able to have multiple shadow roots.
https://bugs.webkit.org/show_bug.cgi?id=77931

Reviewed by Hajime Morita.

.:

  • Source/autotools/symbols.filter:

Source/WebCore:

This patch enables us to add multiple shadow subtrees into elements.
Note that multiple shadow subtrees are enabled
only if RuntimeEnabledFeatures::multipleShadowSubtrees is enabled.

Since we don't have <shadow> element yet, only the youngest shadow tree
will be rendered. This patch includes tests to confirm adding a new shadow
tree dynamically to confirm only the youngest shadow tree is renderered.

Tests: fast/dom/shadow/multiple-shadowroot-rendering.html

fast/dom/shadow/multiple-shadowroot.html

  • WebCore.exp.in:
  • dom/Element.cpp: Uses ShadowRootList interfaces directly instead of ShadowRootList emulation methods.

(WebCore::Element::~Element):
(WebCore::Element::attach):
(WebCore::Element::addShadowRoot):
(WebCore::Element::removeShadowRootList):

  • dom/Element.h:

(Element):

  • dom/NodeRenderingContext.cpp: Makes non-youngest shadow subtrees hidden.

(WebCore::NodeRenderingContext::NodeRenderingContext):
(WebCore::NodeRenderingContext::hostChildrenChanged):

Since non-youngest children may be changed, make sure host children are changed.

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::create):

  • dom/ShadowRoot.h: Utility methods to make code intention clear are added.

(WebCore::ShadowRoot::youngerShadowRoot):
(WebCore::ShadowRoot::olderShadowRoot):
(ShadowRoot):
(WebCore::ShadowRoot::isYoungest):
(WebCore::ShadowRoot::isOldest):

  • dom/ShadowRootList.cpp:

(WebCore::ShadowRootList::popShadowRoot):
(WebCore::ShadowRootList::attach):
(WebCore::ShadowRootList::detach):

Detaches shadow subtrees.

  • testing/Internals.cpp:

(WebCore::Internals::address):
(WebCore):
(WebCore::Internals::youngerShadowRoot):
(WebCore::Internals::olderShadowRoot):
(WebCore::Internals::removeShadowRoot):

  • testing/Internals.h:

(Internals):

  • testing/Internals.idl:

Source/WebKit2:

  • win/WebKit2.def:
  • win/WebKit2CFLite.def:

LayoutTests:

  • fast/dom/resources/shadow-test-driver.js:

(createSpanWithText):
(doneTest):
(doTest):

  • fast/dom/shadow/multiple-shadowroot-expected.txt: Added.
  • fast/dom/shadow/multiple-shadowroot-rendering-expected.txt: Added.
  • fast/dom/shadow/multiple-shadowroot-rendering.html: Added.
  • fast/dom/shadow/multiple-shadowroot.html: Added.
  • platform/efl/Skipped:
  • platform/gtk/Skipped:
  • platform/mac/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:
  • platform/wincairo/Skipped:
  • platform/wk2/Skipped:
Location:
trunk
Files:
4 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r109084 r109096  
     12012-02-28  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        Element should be able to have multiple shadow roots.
     4        https://bugs.webkit.org/show_bug.cgi?id=77931
     5
     6        Reviewed by Hajime Morita.
     7
     8        * Source/autotools/symbols.filter:
     9
    1102012-02-27  Shinya Kawanaka  <shinyak@chromium.org>
    211
  • trunk/LayoutTests/ChangeLog

    r109093 r109096  
     12012-02-28  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        Element should be able to have multiple shadow roots.
     4        https://bugs.webkit.org/show_bug.cgi?id=77931
     5
     6        Reviewed by Hajime Morita.
     7
     8        * fast/dom/resources/shadow-test-driver.js:
     9        (createSpanWithText):
     10        (doneTest):
     11        (doTest):
     12        * fast/dom/shadow/multiple-shadowroot-expected.txt: Added.
     13        * fast/dom/shadow/multiple-shadowroot-rendering-expected.txt: Added.
     14        * fast/dom/shadow/multiple-shadowroot-rendering.html: Added.
     15        * fast/dom/shadow/multiple-shadowroot.html: Added.
     16        * platform/efl/Skipped:
     17        * platform/gtk/Skipped:
     18        * platform/mac/Skipped:
     19        * platform/qt/Skipped:
     20        * platform/win/Skipped:
     21        * platform/wincairo/Skipped:
     22        * platform/wk2/Skipped:
     23
    1242012-02-28  Yoshifumi Inoue  <yosin@chromium.org>
    225
  • trunk/LayoutTests/fast/dom/resources/shadow-test-driver.js

    r106619 r109096  
    5454}
    5555
    56 function createSpanWithText(text) {
     56function createSpanWithText(text, className) {
    5757    var span = document.createElement('span');
    5858    span.appendChild(document.createTextNode(text));
     59    if (className)
     60        span.className = className;
    5961    return span;
    6062}
     
    119121function doneTest() {
    120122    log("TEST COMPLETED");
     123    if (window.tearDownOnce)
     124        window.tearDownOnce();
    121125    layoutTestController.notifyDone();
    122126}
     
    124128// A test driver. Call this body.onload.
    125129function doTest(tests) {
     130    if (window.setUpOnce)
     131        window.setUpOnce();
     132
    126133    if (window.layoutTestController) {
    127134        layoutTestController.waitUntilDone();
  • trunk/LayoutTests/platform/efl/Skipped

    r109039 r109096  
    20922092fast/dom/shadow/shadow-root-attached.html
    20932093fast/dom/shadow/shadow-root-new.html
     2094fast/dom/shadow/multiple-shadowroot.html
     2095fast/dom/shadow/multiple-shadowroot-rendering.html
    20942096
    20952097# CSS Filters support not yet enabled (needs ENABLE_CSS_FILTERS).
  • trunk/LayoutTests/platform/mac/Skipped

    r108980 r109096  
    431431fast/dom/shadow/shadow-root-new.html
    432432fast/dom/shadow/shadow-ul-li.html
     433fast/dom/shadow/multiple-shadowroot.html
     434fast/dom/shadow/multiple-shadowroot-rendering.html
    433435
    434436# JSC does not support setIsolatedWorldSecurityOrigin (http://webkit.org/b/61540)
  • trunk/LayoutTests/platform/qt/Skipped

    r109079 r109096  
    169169fast/dom/shadow/shadow-root-new.html
    170170fast/dom/shadow/shadow-ul-li.html
     171fast/dom/shadow/multiple-shadowroot.html
     172fast/dom/shadow/multiple-shadowroot-rendering.html
    171173
    172174# CSS Regions support not yet enabled. http://webkit.org/b/57312
  • trunk/LayoutTests/platform/win/Skipped

    r108980 r109096  
    14601460fast/dom/shadow/shadow-root-new.html
    14611461fast/dom/shadow/shadow-ul-li.html
     1462fast/dom/shadow/multiple-shadowroot.html
     1463fast/dom/shadow/multiple-shadowroot-rendering.html
    14621464
    14631465# CSS Regions support not yet enabled. http://webkit.org/b/57312
  • trunk/LayoutTests/platform/wincairo/Skipped

    r108272 r109096  
    19701970fast/dom/shadow/shadow-root-attached.html
    19711971fast/dom/shadow/shadow-root-new.html
     1972fast/dom/shadow/multiple-shadowroot.html
     1973fast/dom/shadow/multiple-shadowroot-rendering.html
    19721974
    19731975# CSS Regions support not yet enabled. http://webkit.org/b/57312
  • trunk/LayoutTests/platform/wk2/Skipped

    r109055 r109096  
    10711071fast/dom/shadow/shadow-root-new.html
    10721072fast/dom/shadow/shadow-ul-li.html
     1073fast/dom/shadow/multiple-shadowroot.html
     1074fast/dom/shadow/multiple-shadowroot-rendering.html
    10731075
    10741076# WTR needs an implementation for eventSender.continuousMouseScrollBy
  • trunk/Source/WebCore/ChangeLog

    r109091 r109096  
     12012-02-28  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        Element should be able to have multiple shadow roots.
     4        https://bugs.webkit.org/show_bug.cgi?id=77931
     5
     6        Reviewed by Hajime Morita.
     7
     8        This patch enables us to add multiple shadow subtrees into elements.
     9        Note that multiple shadow subtrees are enabled
     10        only if RuntimeEnabledFeatures::multipleShadowSubtrees is enabled.
     11
     12        Since we don't have <shadow> element yet, only the youngest shadow tree
     13        will be rendered. This patch includes tests to confirm adding a new shadow
     14        tree dynamically to confirm only the youngest shadow tree is renderered.
     15
     16        Tests: fast/dom/shadow/multiple-shadowroot-rendering.html
     17               fast/dom/shadow/multiple-shadowroot.html
     18
     19        * WebCore.exp.in:
     20        * dom/Element.cpp:
     21          Uses ShadowRootList interfaces directly instead of ShadowRootList emulation methods.
     22        (WebCore::Element::~Element):
     23        (WebCore::Element::attach):
     24        (WebCore::Element::addShadowRoot):
     25        (WebCore::Element::removeShadowRootList):
     26        * dom/Element.h:
     27        (Element):
     28        * dom/NodeRenderingContext.cpp:
     29          Makes non-youngest shadow subtrees hidden.
     30        (WebCore::NodeRenderingContext::NodeRenderingContext):
     31        (WebCore::NodeRenderingContext::hostChildrenChanged):
     32          Since non-youngest children may be changed, make sure host children are changed.
     33        * dom/ShadowRoot.cpp:
     34        (WebCore::ShadowRoot::create):
     35        * dom/ShadowRoot.h:
     36          Utility methods to make code intention clear are added.
     37        (WebCore::ShadowRoot::youngerShadowRoot):
     38        (WebCore::ShadowRoot::olderShadowRoot):
     39        (ShadowRoot):
     40        (WebCore::ShadowRoot::isYoungest):
     41        (WebCore::ShadowRoot::isOldest):
     42        * dom/ShadowRootList.cpp:
     43        (WebCore::ShadowRootList::popShadowRoot):
     44        (WebCore::ShadowRootList::attach):
     45        (WebCore::ShadowRootList::detach):
     46          Detaches shadow subtrees.
     47        * testing/Internals.cpp:
     48        (WebCore::Internals::address):
     49        (WebCore):
     50        (WebCore::Internals::youngerShadowRoot):
     51        (WebCore::Internals::olderShadowRoot):
     52        (WebCore::Internals::removeShadowRoot):
     53        * testing/Internals.h:
     54        (Internals):
     55        * testing/Internals.idl:
     56
    1572012-02-28  Antti Koivisto  <antti@apple.com>
    258
  • trunk/Source/WebCore/dom/Element.cpp

    r109084 r109096  
    6161#include "RenderView.h"
    6262#include "RenderWidget.h"
     63#include "RuntimeEnabledFeatures.h"
    6364#include "Settings.h"
    6465#include "ShadowRoot.h"
     
    932933        shadowTree()->attach();
    933934
    934         // In a shadow tree, some of light children may be attached by 'content' element.
     935        // In a shadow tree, some of light children may be attached by <content> or <shadow>.
    935936        // However, when there is no content element or content element does not select
    936937        // all light children, we have to attach the rest of light children here.
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r108959 r109096  
    5858
    5959    if (parent->isShadowRoot()) {
    60         m_phase = AttachingShadowChild;
     60        // FIXME: We don't support <shadow> yet, so the non-youngest shadow won't be rendered.
     61        // https://bugs.webkit.org/shod_bugs.cgi?id=78596
     62        if (toShadowRoot(parent)->isYoungest())
     63            m_phase = AttachingShadowChild;
     64        else
     65            m_phase = AttachingNotDistributed;
    6166        m_parentNodeForRenderingAndStyle = parent->shadowHost();
    6267        return;
     
    6873            if ((m_insertionPoint = m_visualParentShadowTree->insertionPointFor(m_node))
    6974                && m_visualParentShadowTree->isSelectorActive()) {
    70                 m_phase = AttachingDistributed;
    71                 m_parentNodeForRenderingAndStyle = NodeRenderingContext(m_insertionPoint).parentNodeForRenderingAndStyle();
    72                 return;
     75
     76                // FIXME: We don't support <shadow> yet, so the non-youngest shadow won't be rendered.
     77                // https://bugs.webkit.org/show_bugs.cgi?id=78596
     78                if (toShadowRoot(m_insertionPoint->shadowTreeRootNode())->isYoungest()) {
     79                    m_phase = AttachingDistributed;
     80                    m_parentNodeForRenderingAndStyle = NodeRenderingContext(m_insertionPoint).parentNodeForRenderingAndStyle();
     81                    return;
     82                }
    7383            }
    7484
     
    261271void NodeRenderingContext::hostChildrenChanged()
    262272{
    263     if (m_phase == AttachingNotDistributed)
     273    if (m_phase == AttachingNotDistributed && m_visualParentShadowTree)
    264274        m_visualParentShadowTree->hostChildrenChanged();
    265275}
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r109084 r109096  
    185185}
    186186
    187 void ShadowRoot::attach()
    188 {
    189     // Children of m_selector is populated lazily in
    190     // ensureSelector(), and here we just ensure that
    191     // it is in clean state.
    192     // FIXME: This assertion breaks if multiple shadow roots are being attached.
    193     // ShadowTree should have responsibility of side effect of selector in attaching/detaching.
    194     ASSERT(!tree()->selector() || !tree()->selector()->hasCandidates());
    195     DocumentFragment::attach();
    196     if (HTMLContentSelector* selector = tree()->selector())
    197         selector->didSelect();
    198187}
    199 
    200 }
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r108959 r109096  
    6565    void hostChildrenChanged();
    6666
    67     virtual void attach();
    68 
    6967    virtual bool applyAuthorSheets() const;
    7068    void setApplyAuthorSheets(bool);
     
    7573    ShadowRoot* youngerShadowRoot() const { return prev(); }
    7674    ShadowRoot* olderShadowRoot() const { return next(); }
     75
     76    bool isYoungest() const { return !youngerShadowRoot(); }
     77    bool isOldest() const { return !olderShadowRoot(); }
    7778
    7879    bool hasContentElement() const;
  • trunk/Source/WebCore/dom/ShadowTree.cpp

    r109084 r109096  
    110110
    111111        oldRoot->setShadowHost(0);
     112        oldRoot->setPrev(0);
     113        oldRoot->setNext(0);
    112114        shadowHost->document()->adoptIfNeeded(oldRoot.get());
    113115        if (oldRoot->inDocument())
     
    157159void ShadowTree::attach()
    158160{
    159     // FIXME: Currently we only support the case that the shadow root list has at most one shadow root.
    160     // See also https://bugs.webkit.org/show_bug.cgi?id=77503 and its dependent bugs.
    161     ASSERT(m_shadowRoots.size() <= 1);
     161    // Children of m_selector is populated lazily in
     162    // ensureSelector(), and here we just ensure that it is in clean state.
     163    ASSERT(!selector() || !selector()->hasCandidates());
    162164
    163165    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
     
    165167            root->attach();
    166168    }
     169
     170    if (HTMLContentSelector* contentSelector = selector())
     171        contentSelector->didSelect();
    167172}
    168173
    169174void ShadowTree::detach()
    170175{
    171     // FIXME: Currently we only support the case that the shadow root list has at most one shadow root.
    172     // See also https://bugs.webkit.org/show_bug.cgi?id=77503 and its dependent bugs.
    173     ASSERT(m_shadowRoots.size() <= 1);
    174 
    175176    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
    176177        if (root->attached())
  • trunk/Source/WebCore/testing/Internals.cpp

    r109084 r109096  
    120120}
    121121
     122String Internals::address(Node* node)
     123{
     124    char buf[32];
     125    sprintf(buf, "%p", node);
     126
     127    return String(buf);
     128}
     129
    122130bool Internals::isPreloaded(Document* document, const String& url)
    123131{
     
    240248
    241249    return host->shadowTree()->oldestShadowRoot();
     250}
     251
     252Internals::ShadowRootIfShadowDOMEnabledOrNode* Internals::youngerShadowRoot(Node* shadow, ExceptionCode& ec)
     253{
     254    if (!shadow || !shadow->isShadowRoot()) {
     255        ec = INVALID_ACCESS_ERR;
     256        return 0;
     257    }
     258
     259    return toShadowRoot(shadow)->youngerShadowRoot();
     260}
     261
     262Internals::ShadowRootIfShadowDOMEnabledOrNode* Internals::olderShadowRoot(Node* shadow, ExceptionCode& ec)
     263{
     264    if (!shadow || !shadow->isShadowRoot()) {
     265        ec = INVALID_ACCESS_ERR;
     266        return 0;
     267    }
     268
     269    return toShadowRoot(shadow)->olderShadowRoot();
    242270}
    243271
  • trunk/Source/WebCore/testing/Internals.h

    r108831 r109096  
    5656    String elementRenderTreeAsText(Element*, ExceptionCode&);
    5757
     58    String address(Node*);
     59
    5860    bool isPreloaded(Document*, const String& url);
    5961
     
    6971    ShadowRootIfShadowDOMEnabledOrNode* youngestShadowRoot(Element* host, ExceptionCode&);
    7072    ShadowRootIfShadowDOMEnabledOrNode* oldestShadowRoot(Element* host, ExceptionCode&);
     73    ShadowRootIfShadowDOMEnabledOrNode* youngerShadowRoot(Node* shadow, ExceptionCode&);
     74    ShadowRootIfShadowDOMEnabledOrNode* olderShadowRoot(Node* shadow, ExceptionCode&);
    7175    void removeShadowRoot(Element* host, ExceptionCode&);
    7276    void setMultipleShadowSubtreesEnabled(bool);
  • trunk/Source/WebCore/testing/Internals.idl

    r108831 r109096  
    2828        OmitConstructor
    2929    ] Internals {
     30        DOMString address(in Node node);
     31
    3032        DOMString elementRenderTreeAsText(in Element element) raises(DOMException);
    3133        boolean isPreloaded(in Document document, in DOMString url);
     
    3840        ShadowRoot youngestShadowRoot(in Element host) raises (DOMException);
    3941        ShadowRoot oldestShadowRoot(in Element host) raises (DOMException);
     42        ShadowRoot youngerShadowRoot(in Node root) raises (DOMException);
     43        ShadowRoot olderShadowRoot(in Node root) raises (DOMException);
    4044#else
    4145        Node ensureShadowRoot(in Element host) raises (DOMException);
     
    4347        Node youngestShadowRoot(in Element host) raises (DOMException);
    4448        Node oldestShadowRoot(in Element host) raises (DOMException);
     49        Node youngerShadowRoot(in Node root) raises (DOMException);
     50        Node youngerShadowRoot(in Node root) raises (DOMException);
    4551#endif
    4652        void setMultipleShadowSubtreesEnabled(in boolean enabled);
  • trunk/Source/WebKit2/ChangeLog

    r109094 r109096  
     12012-02-28  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        Element should be able to have multiple shadow roots.
     4        https://bugs.webkit.org/show_bug.cgi?id=77931
     5
     6        Reviewed by Hajime Morita.
     7
     8        * win/WebKit2.def:
     9        * win/WebKit2CFLite.def:
     10
    1112012-02-28  Hugo Parente Lima  <hugo.lima@openbossa.org>
    212
  • trunk/Source/WebKit2/win/WebKit2.def

    r109084 r109096  
    178178        ?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVElement@2@HH_N@Z
    179179        ?removeAllShadowRoots@ShadowTree@WebCore@@QAEXXZ
     180        ?s_info@JSNode@WebCore@@2UClassInfo@JSC@@B
    180181        ?scriptExecutionContext@JSDOMGlobalObject@WebCore@@QBEPAVScriptExecutionContext@2@XZ
    181182        ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z
  • trunk/Source/WebKit2/win/WebKit2CFLite.def

    r109084 r109096  
    170170        ?paintControlTints@FrameView@WebCore@@AAEXXZ
    171171        ?rangeFromLocationAndLength@TextIterator@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@PAVElement@2@HH_N@Z
    172         ?removeAllShadowRoots@ShadowTree@WebCore@@QAEXXZ
     172        ?removeShadowRootList@Element@WebCore@@QAEXXZ
     173        ?s_info@JSNode@WebCore@@2UClassInfo@JSC@@B
    173174        ?scriptExecutionContext@JSDOMGlobalObject@WebCore@@QBEPAVScriptExecutionContext@2@XZ
    174175        ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z
  • trunk/Source/autotools/symbols.filter

    r109084 r109096  
    6868_ZN7WebCore6JSNode6s_infoE;
    6969_ZN7WebCore6toNodeEN3JSC7JSValueE;
     70_ZN7WebCore7Element20removeShadowRootListEv;
    7071_ZN7WebCore7toRangeEN3JSC7JSValueE;
    7172_ZN7WebCore9JSElement10putVirtualEPN3JSC9ExecStateERKNS1_10IdentifierENS1_7JSValueERNS1_15PutPropertySlotE;
Note: See TracChangeset for help on using the changeset viewer.