Changeset 105387 in webkit


Ignore:
Timestamp:
Jan 18, 2012 11:05:58 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

ShadowContent query should be able to have fallback elements.
https://bugs.webkit.org/show_bug.cgi?id=75306

Patch by Shinya Kawanaka <shinyak@google.com> on 2012-01-18
Reviewed by Hajime Morita.

Source/WebCore:

When no elements are selected by a shadow content element selector query,
light children are selected as a fallback elements.

Test: fast/dom/shadow/shadow-contents-fallback.html

  • dom/NodeRenderingContext.cpp:

(WebCore::NodeRenderingContext::NodeRenderingContext):

Considers fallback phase. When no elements are chosen, the phase is set to 'fallback'.

(WebCore::NodeRenderingContext::nextRenderer):

Takes fallback phase into account.

(WebCore::NodeRenderingContext::previousRenderer): ditto.

  • dom/NodeRenderingContext.h:
  • html/shadow/HTMLContentElement.cpp:

(WebCore::HTMLContentElement::attach):

Calculates inclusions before attaching light children.

  • html/shadow/HTMLContentElement.h:

(WebCore::HTMLContentElement::hasInclusion):

LayoutTests:

  • fast/dom/shadow/shadow-contents-fallback-expected.txt: Added.
  • fast/dom/shadow/shadow-contents-fallback.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r105386 r105387  
     12012-01-18  Shinya Kawanaka  <shinyak@google.com>
     2
     3        ShadowContent query should be able to have fallback elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=75306
     5
     6        Reviewed by Hajime Morita.
     7
     8        * fast/dom/shadow/shadow-contents-fallback-expected.txt: Added.
     9        * fast/dom/shadow/shadow-contents-fallback.html: Added.
     10
    1112012-01-18  Kent Tamura  <tkent@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r105386 r105387  
     12012-01-18  Shinya Kawanaka  <shinyak@google.com>
     2
     3        ShadowContent query should be able to have fallback elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=75306
     5
     6        Reviewed by Hajime Morita.
     7
     8        When no elements are selected by a shadow content element selector query,
     9        light children are selected as a fallback elements.
     10
     11        Test: fast/dom/shadow/shadow-contents-fallback.html
     12
     13        * dom/NodeRenderingContext.cpp:
     14        (WebCore::NodeRenderingContext::NodeRenderingContext):
     15          Considers fallback phase. When no elements are chosen, the phase is set to 'fallback'.
     16        (WebCore::NodeRenderingContext::nextRenderer):
     17          Takes fallback phase into account.
     18        (WebCore::NodeRenderingContext::previousRenderer): ditto.
     19        * dom/NodeRenderingContext.h:
     20        * html/shadow/HTMLContentElement.cpp:
     21        (WebCore::HTMLContentElement::attach):
     22          Calculates inclusions before attaching light children.
     23        * html/shadow/HTMLContentElement.h:
     24        (WebCore::HTMLContentElement::hasInclusion):
     25
    1262012-01-18  Kent Tamura  <tkent@chromium.org>
    227
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r105249 r105387  
    7474                m_parentNodeForRenderingAndStyle = NodeRenderingContext(m_includer).parentNodeForRenderingAndStyle();
    7575                return;
    76             } 
    77                
     76            }
     77
    7878            m_phase = AttachContentLight;
    7979            m_parentNodeForRenderingAndStyle = parent;
    8080            return;
     81        }
     82
     83        if (parent->isContentElement()) {
     84            HTMLContentElement* shadowContentElement = toHTMLContentElement(parent);
     85            if (!shadowContentElement->hasInclusion()) {
     86                m_phase = AttachContentFallback;
     87                m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
     88                return;
     89            }
    8190        }
    8291    }
     
    177186    // Avoid an O(n^2) problem with this function by not checking for
    178187    // nextRenderer() when the parent element hasn't attached yet.
    179     if (m_node->parentOrHostNode() && !m_node->parentOrHostNode()->attached())
     188    if (m_node->parentOrHostNode() && !m_node->parentOrHostNode()->attached() && m_phase != AttachContentFallback)
    180189        return 0;
    181190
     
    192201        }
    193202    }
     203
     204    if (m_phase == AttachContentFallback)
     205        return NodeRenderingContext(m_node->parentNode()).nextRenderer();
    194206
    195207    return 0;
     
    226238    }
    227239
     240    if (m_phase == AttachContentFallback)
     241        return NodeRenderingContext(m_node->parentNode()).previousRenderer();
     242
    228243    return 0;
    229244}
  • trunk/Source/WebCore/dom/NodeRenderingContext.h

    r105249 r105387  
    8080        AttachContentLight,
    8181        AttachContentForwarded,
     82        AttachContentFallback,
    8283    };
    8384
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp

    r105249 r105387  
    5757void HTMLContentElement::attach()
    5858{
    59     ASSERT(!firstChild()); // Currently doesn't support any light child.
    60     HTMLElement::attach();
     59    ShadowRoot* root = toShadowRoot(shadowTreeRootNode());
    6160
    62     if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
     61    // Before calling StyledElement::attach, selector must be calculated.
     62    if (root) {
    6363        ContentInclusionSelector* selector = root->ensureInclusions();
    6464        selector->unselect(m_inclusions.get());
    6565        selector->select(this, m_inclusions.get());
     66    }
     67
     68    HTMLElement::attach();
     69
     70    if (root) {
    6671        for (ShadowInclusion* inclusion = m_inclusions->first(); inclusion; inclusion = inclusion->next())
    6772            inclusion->content()->detach();
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.h

    r105249 r105387  
    3232#define HTMLContentElement_h
    3333
     34#include "ContentInclusionSelector.h"
    3435#include "HTMLElement.h"
    3536#include <wtf/Forward.h>
     
    6061
    6162    const ShadowInclusionList* inclusions() const { return m_inclusions.get(); }
     63    bool hasInclusion() const { return inclusions()->first(); }
    6264
    6365protected:
Note: See TracChangeset for help on using the changeset viewer.