Changeset 114334 in webkit


Ignore:
Timestamp:
Apr 16, 2012 7:55:40 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Shadow DOM] InsertionPoint should have isActive() member function.
https://bugs.webkit.org/show_bug.cgi?id=82010

Patch by Takashi Sakamoto <tasak@google.com> on 2012-04-16
Reviewed by Hajime Morita.

This patch adds isActive public member function to InsertionPoint and
makes InsertionPoint elements consider whether active or not.
If an InsertionPoint is inactive, the element is not shadow boundary
and is needed to be rendered.
c.f. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-active-insertion-point

Test: update existing tests, i.e.
LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html and
LayoutTests/fast/dom/shadow/shadow-contents-fallback.html

  • html/shadow/InsertionPoint.cpp:

(WebCore::InsertionPoint::isActive):
A new public method for checking whether an insertion point is active or inactive.
If active, returns true. Otherwise, false.
(WebCore::InsertionPoint::isShadowBoundary):
Make the method consider whether an insertin point is active or inactive.
(WebCore::InsertionPoint::rendererIsNeeded):
Changed to return true If an insertion point is inactive.
(WebCore::InsertionPoint::attach):
Changed to call only HTMLElement::attach If an insertion point is inactive.
(WebCore::InsertionPoint::detach):
Changed to call only HTMLElement::detach If an insertion point is inactive.

  • html/shadow/InsertionPoint.h:

(InsertionPoint):
Added isActive public method.

  • dom/NodeRenderingContext.cpp:

(WebCore::NodeRenderingContext::NodeRenderingContext):
Changed to take into account an insertion point's activeness when parent is an insertion point.
(WebCore::NodeRenderingContext::firstRendererOf):
(WebCore::NodeRenderingContext::lastRendererOf):
Changed to take into account an insertion point's activeness.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html

    r108480 r114334  
    343343function testContentInContent(callIfDone) {
    344344    document.getElementById('expect-container').innerHTML =
    345         "<div>{SHADOW: <span>S1</span><span>S2</span>}</div>";
     345        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
    346346
    347347    var target = document.createElement('div');
     
    374374function testContentInContentFallback(callIfDone) {
    375375    document.getElementById('expect-container').innerHTML =
    376         "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
     376        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
    377377
    378378    var target = document.createElement('div');
     
    405405function testContentInContentFallbackDirect(callIfDone) {
    406406    document.getElementById('expect-container').innerHTML =
    407         "<div><span>CONTENT 2 FALLBACK</span></div>";
     407        "<div><content><span>CONTENT 2 FALLBACK</span></content></div>";
    408408
    409409    var target = document.createElement('div');
  • trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback.html

    r108480 r114334  
    268268    document.getElementById('actual-container').appendChild(target);
    269269    document.getElementById('expect-container').innerHTML =
    270         "<div>{SHADOW: <span>S1</span><span>S2</span>}</div>";
     270        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
    271271}
    272272
     
    291291    document.getElementById('actual-container').appendChild(target);
    292292    document.getElementById('expect-container').innerHTML =
    293         "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
     293        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
    294294}
    295295
     
    317317    document.getElementById('actual-container').appendChild(target);
    318318    document.getElementById('expect-container').innerHTML =
    319         "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
     319        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
    320320}
    321321
     
    338338    document.getElementById('actual-container').appendChild(target);
    339339    document.getElementById('expect-container').innerHTML =
    340         "<div><span>CONTENT 2 FALLBACK</span></div>";
     340        "<div><content><span>CONTENT 2 FALLBACK</span></content></div>";
    341341}
    342342
  • trunk/Source/WebCore/ChangeLog

    r114333 r114334  
     12012-04-16  Takashi Sakamoto  <tasak@google.com>
     2
     3        [Shadow DOM] InsertionPoint should have isActive() member function.
     4        https://bugs.webkit.org/show_bug.cgi?id=82010
     5
     6        Reviewed by Hajime Morita.
     7
     8        This patch adds isActive public member function to InsertionPoint and
     9        makes InsertionPoint elements consider whether active or not.
     10        If an InsertionPoint is inactive, the element is not shadow boundary
     11        and is needed to be rendered.
     12        c.f. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-active-insertion-point
     13
     14        Test: update existing tests, i.e.
     15        LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html and
     16        LayoutTests/fast/dom/shadow/shadow-contents-fallback.html
     17
     18        * html/shadow/InsertionPoint.cpp:
     19        (WebCore::InsertionPoint::isActive):
     20        A new public method for checking whether an insertion point is active or inactive.
     21        If active, returns true. Otherwise, false.
     22        (WebCore::InsertionPoint::isShadowBoundary):
     23        Make the method consider whether an insertin point is active or inactive.
     24        (WebCore::InsertionPoint::rendererIsNeeded):
     25        Changed to return true If an insertion point is inactive.
     26        (WebCore::InsertionPoint::attach):
     27        Changed to call only HTMLElement::attach If an insertion point is inactive.
     28        (WebCore::InsertionPoint::detach):
     29        Changed to call only HTMLElement::detach If an insertion point is inactive.
     30        * html/shadow/InsertionPoint.h:
     31        (InsertionPoint):
     32        Added isActive public method.
     33        * dom/NodeRenderingContext.cpp:
     34        (WebCore::NodeRenderingContext::NodeRenderingContext):
     35        Changed to take into account an insertion point's activeness when parent is an insertion point.
     36        (WebCore::NodeRenderingContext::firstRendererOf):
     37        (WebCore::NodeRenderingContext::lastRendererOf):
     38        Changed to take into account an insertion point's activeness.
     39
    1402012-04-16  MORITA Hajime  <morrita@google.com>
    241
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r114189 r114334  
    102102            else
    103103                m_phase = AttachingFallbacked;
    104             m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
     104
     105            if (toInsertionPoint(parent)->isActive())
     106                m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
     107            else
     108                m_parentNodeForRenderingAndStyle = parent;
    105109            return;
    106110        }
     
    203207        }
    204208
    205         if (isInsertionPoint(node)) {
     209        if (isInsertionPoint(node) && toInsertionPoint(node)->isActive()) {
    206210            if (RenderObject* first = firstRendererOfInsertionPoint(toInsertionPoint(node)))
    207211                return first;
     
    221225            return node->renderer();
    222226        }
    223         if (isInsertionPoint(node)) {
     227        if (isInsertionPoint(node) && toInsertionPoint(node)->isActive()) {
    224228            if (RenderObject* last = lastRendererOfInsertionPoint(toInsertionPoint(node)))
    225229                return last;
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r112978 r114334  
    4949void InsertionPoint::attach()
    5050{
    51     TreeScope* scope = treeScope();
    52     if (scope->rootNode()->isShadowRoot()) {
    53         ShadowRoot* root = toShadowRoot(scope->rootNode());
     51    if (isShadowBoundary()) {
     52        ShadowRoot* root = toShadowRoot(treeScope()->rootNode());
    5453        if (doesSelectFromHostChildren()) {
    5554            distributeHostChildren(root->tree());
     
    6766void InsertionPoint::detach()
    6867{
    69     if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
     68    ShadowRoot* root = toShadowRoot(shadowTreeRootNode());
     69    if (root && isActive()) {
    7070        ShadowTree* tree = root->tree();
    7171
     
    9898bool InsertionPoint::isShadowBoundary() const
    9999{
    100     return treeScope()->rootNode()->isShadowRoot();
     100    return treeScope()->rootNode()->isShadowRoot() && isActive();
     101}
     102
     103bool InsertionPoint::isActive() const
     104{
     105    const Node* node = parentNode();
     106    while (node) {
     107        if (WebCore::isInsertionPoint(node))
     108            return false;
     109
     110        node = node->parentNode();
     111    }
     112    return true;
    101113}
    102114
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r112055 r114334  
    4646    bool hasSelection() const { return m_selections.first(); }
    4747    bool isShadowBoundary() const;
     48    bool isActive() const;
    4849
    4950    virtual const AtomicString& select() const = 0;
Note: See TracChangeset for help on using the changeset viewer.