⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 121131 in webkit


Ignore:
Timestamp:
Jun 24, 2012, 7:25:43 PM (14 years ago)
Author:
morrita@google.com
Message:

NodeRenderingContext::AttachingPhase is redundant.
https://bugs.webkit.org/show_bug.cgi?id=79220

Reviewed by Dimitri Glazkov.

This change removes NodeRenderingContext::AttachingPhase and
NodeRenderingContext::m_phase respectively. The state originally
represented as m_phase is naturally encoded into other member variables.

NodeRenderingContext::m_visualParentShadow is also replaced, with
a local variable parentScope.

Basically, what NodeRenderingContext wants to know is the parent of
the composed shadow tree and an optional insertion point where the
node is distributed. Once these becomes clear, m_phase is no longer required.
It was rather a historical artifact.

No new tests. No behavioral change.

  • dom/NodeRenderingContext.cpp: Replaced m_phase with implicit states.

(WebCore::NodeRenderingContext::NodeRenderingContext):
(WebCore::NodeRenderingContext::nextRenderer):
(WebCore::NodeRenderingContext::previousRenderer):
(WebCore::NodeRenderingContext::parentRenderer):
(WebCore::NodeRenderingContext::shouldCreateRenderer):
(WebCore::NodeRenderingContext::isOnEncapsulationBoundary):
(WebCore::NodeRenderingContext::isOnUpperEncapsulationBoundary):

  • dom/NodeRenderingContext.h:

(NodeRenderingContext):
(WebCore::NodeRenderingContext::parentNodeForRenderingAndStyle): Removed an assert which checks m_phase.
(WebCore::NodeRenderingContext::resetStyleInheritance): Removed an assert which checks m_phase.

  • html/shadow/InsertionPoint.h:

(WebCore::isInsertionPoint): Fix null case check.
(WebCore::isLowerEncapsulationBoundary): Renamed from isShadowBoundary()

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121130 r121131  
     12012-06-24  MORITA Hajime  <morrita@google.com>
     2
     3        NodeRenderingContext::AttachingPhase is redundant.
     4        https://bugs.webkit.org/show_bug.cgi?id=79220
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        This change removes NodeRenderingContext::AttachingPhase and
     9        NodeRenderingContext::m_phase respectively. The state originally
     10        represented as m_phase is naturally encoded into other member variables.
     11
     12        NodeRenderingContext::m_visualParentShadow is also replaced, with
     13        a local variable parentScope.
     14
     15        Basically, what NodeRenderingContext wants to know is the parent of
     16        the composed shadow tree and an optional insertion point where the
     17        node is distributed. Once these becomes clear, m_phase is no longer required.
     18        It was rather a historical artifact.
     19
     20        No new tests. No behavioral change.
     21
     22        * dom/NodeRenderingContext.cpp: Replaced m_phase with implicit states.
     23        (WebCore::NodeRenderingContext::NodeRenderingContext):
     24        (WebCore::NodeRenderingContext::nextRenderer):
     25        (WebCore::NodeRenderingContext::previousRenderer):
     26        (WebCore::NodeRenderingContext::parentRenderer):
     27        (WebCore::NodeRenderingContext::shouldCreateRenderer):
     28        (WebCore::NodeRenderingContext::isOnEncapsulationBoundary):
     29        (WebCore::NodeRenderingContext::isOnUpperEncapsulationBoundary):
     30        * dom/NodeRenderingContext.h:
     31        (NodeRenderingContext):
     32        (WebCore::NodeRenderingContext::parentNodeForRenderingAndStyle): Removed an assert which checks m_phase.
     33        (WebCore::NodeRenderingContext::resetStyleInheritance): Removed an assert which checks m_phase.
     34        * html/shadow/InsertionPoint.h:
     35        (WebCore::isInsertionPoint): Fix null case check.
     36        (WebCore::isLowerEncapsulationBoundary): Renamed from isShadowBoundary()
     37
    1382012-06-24  Antti Koivisto  <antti@apple.com>
    239
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r119799 r121131  
    5353
    5454NodeRenderingContext::NodeRenderingContext(Node* node)
    55     : m_phase(AttachingNotInTree)
    56     , m_node(node)
     55    : m_node(node)
    5756    , m_parentNodeForRenderingAndStyle(0)
    5857    , m_resetStyleInheritance(false)
    59     , m_visualParentShadow(0)
    6058    , m_insertionPoint(0)
    6159    , m_style(0)
     
    6765
    6866    if (parent->isShadowRoot() && toShadowRoot(parent)->isYoungest()) {
    69         m_phase = AttachingShadowChild;
    7067        m_parentNodeForRenderingAndStyle = toShadowRoot(parent)->host();
    7168        m_resetStyleInheritance = toShadowRoot(parent)->resetStyleInheritance();
     
    7471
    7572    if (parent->isElementNode() || parent->isShadowRoot()) {
     73        ElementShadow* parentShadow = 0;
     74
    7675        if (parent->isElementNode())
    77             m_visualParentShadow = toElement(parent)->shadow();
     76            parentShadow = toElement(parent)->shadow();
    7877        else if (parent->isShadowRoot())
    79             m_visualParentShadow = toShadowRoot(parent)->owner();
    80 
    81         if (m_visualParentShadow) {
    82             m_visualParentShadow->ensureDistribution();
    83 
    84             if ((m_insertionPoint = m_visualParentShadow->insertionPointFor(m_node))) {
    85                 if (m_insertionPoint->shadowRoot()->isUsedForRendering()) {
    86                     m_phase = AttachingDistributed;
    87                     NodeRenderingContext insertionPointContext(m_insertionPoint);
     78            parentShadow = toShadowRoot(parent)->owner();
     79
     80        if (parentShadow) {
     81            parentShadow->ensureDistribution();
     82
     83            if (InsertionPoint* insertionPoint = parentShadow->insertionPointFor(m_node)) {
     84                if (insertionPoint->shadowRoot()->isUsedForRendering()) {
     85                    NodeRenderingContext insertionPointContext(insertionPoint);
    8886                    m_parentNodeForRenderingAndStyle = insertionPointContext.parentNodeForRenderingAndStyle();
    8987                    m_resetStyleInheritance = insertionPointContext.resetStyleInheritance();
     88                    m_insertionPoint = insertionPoint;
    9089                    return;
    9190                }
    9291            }
    9392
    94             m_phase = AttachingNotDistributed;
    95             m_parentNodeForRenderingAndStyle = parent;
    9693            return;
    9794        }
    9895
    99         if (isShadowBoundary(parent)) {
    100             ShadowRoot* parentShadowRoot = parent->shadowRoot();
    101             parentShadowRoot->owner()->ensureDistribution();
    102 
    103             if (!parentShadowRoot->isUsedForRendering()) {
    104                 m_phase = AttachingNotDistributed;
    105                 m_parentNodeForRenderingAndStyle = parent;
     96        if (isLowerEncapsulationBoundary(parent)) {
     97            ShadowRoot* parentScope = parent->shadowRoot();
     98            parentScope->owner()->ensureDistribution();
     99
     100            // The shadow tree isn't part of composed tree.
     101            if (!parentScope->isUsedForRendering())
    106102                return;
    107             }
    108 
     103
     104            // the parent insertion point doesn't need any fallback content.
    109105            if (toInsertionPoint(parent)->hasDistribution())
    110                 m_phase = AttachingNotFallbacked;
    111             else
    112                 m_phase = AttachingFallbacked;
     106                return;
    113107
    114108            if (toInsertionPoint(parent)->isActive()) {
     109                // Uses m_node as a fallback node of the insertion point.
    115110                NodeRenderingContext parentContext(parent);
    116111                m_parentNodeForRenderingAndStyle = parentContext.parentNodeForRenderingAndStyle();
    117112                m_resetStyleInheritance = parentContext.resetStyleInheritance();
    118             } else
    119                 m_parentNodeForRenderingAndStyle = parent;
     113                return;
     114            }
     115
     116            // The insertion point isn't active thus behaves as a plain old element.
     117            m_parentNodeForRenderingAndStyle = parent;
    120118            return;
    121119        }
    122120    }
    123121
    124     m_phase = AttachingStraight;
    125122    m_parentNodeForRenderingAndStyle = parent;
    126123}
    127124
    128125NodeRenderingContext::NodeRenderingContext(Node* node, RenderStyle* style)
    129     : m_phase(Calculating)
    130     , m_node(node)
     126    : m_node(node)
    131127    , m_parentNodeForRenderingAndStyle(0)
    132128    , m_resetStyleInheritance(false)
    133     , m_visualParentShadow(0)
    134129    , m_insertionPoint(0)
    135130    , m_style(style)
     
    242237RenderObject* NodeRenderingContext::nextRenderer() const
    243238{
    244     ASSERT(m_node->renderer() || m_phase != Calculating);
    245239    if (RenderObject* renderer = m_node->renderer())
    246240        return renderer->nextSibling();
     
    249243        return m_parentFlowRenderer->nextRendererForNode(m_node);
    250244
    251     if (m_phase == AttachingDistributed) {
     245    if (m_insertionPoint) {
    252246        if (RenderObject* found = nextRendererOfInsertionPoint(m_insertionPoint, m_node))
    253247            return found;
     
    265259RenderObject* NodeRenderingContext::previousRenderer() const
    266260{
    267     ASSERT(m_node->renderer() || m_phase != Calculating);
    268 
    269261    if (RenderObject* renderer = m_node->renderer())
    270262        return renderer->previousSibling();
     
    273265        return m_parentFlowRenderer->previousRendererForNode(m_node);
    274266
    275     if (m_phase == AttachingDistributed) {
     267    if (m_insertionPoint) {
    276268        if (RenderObject* found = previousRendererOfInsertionPoint(m_insertionPoint, m_node))
    277269            return found;
     
    286278RenderObject* NodeRenderingContext::parentRenderer() const
    287279{
    288     if (RenderObject* renderer = m_node->renderer()) {
    289         ASSERT(m_phase == Calculating);
     280    if (RenderObject* renderer = m_node->renderer())
    290281        return renderer->parent();
    291     }
    292 
    293282    if (m_parentFlowRenderer)
    294283        return m_parentFlowRenderer;
    295284
    296     ASSERT(m_phase != Calculating);
    297285    return m_parentNodeForRenderingAndStyle ? m_parentNodeForRenderingAndStyle->renderer() : 0;
    298286}
     
    300288bool NodeRenderingContext::shouldCreateRenderer() const
    301289{
    302     ASSERT(m_phase != Calculating);
    303     ASSERT(parentNodeForRenderingAndStyle());
    304 
    305     if (m_phase == AttachingNotInTree || m_phase == AttachingNotDistributed || m_phase == AttachingNotFallbacked)
     290    if (!m_parentNodeForRenderingAndStyle)
    306291        return false;
    307292    RenderObject* parentRenderer = this->parentRenderer();
     
    341326}
    342327
     328bool NodeRenderingContext::isOnEncapsulationBoundary() const
     329{
     330    return isOnUpperEncapsulationBoundary() || isLowerEncapsulationBoundary(m_insertionPoint) || isLowerEncapsulationBoundary(m_node->parentNode());
     331}
     332
     333bool NodeRenderingContext::isOnUpperEncapsulationBoundary() const
     334{
     335    return m_node->parentNode() && m_node->parentNode()->isShadowRoot();
     336}
     337
    343338NodeRendererFactory::NodeRendererFactory(Node* node)
    344339    : m_context(node)
  • trunk/Source/WebCore/dom/NodeRenderingContext.h

    r119799 r121131  
    6969
    7070private:
    71     enum AttachingPhase {
    72         Calculating,
    73         AttachingStraight,
    74         AttachingNotInTree,
    75         AttachingDistributed,
    76         AttachingNotDistributed,
    77         AttachingFallbacked,
    78         AttachingNotFallbacked,
    79         AttachingShadowChild,
    80     };
    81 
    82     AttachingPhase m_phase;
    8371    Node* m_node;
    8472    ContainerNode* m_parentNodeForRenderingAndStyle;
    8573    bool m_resetStyleInheritance;
    86     ElementShadow* m_visualParentShadow;
    8774    InsertionPoint* m_insertionPoint;
    8875    RefPtr<RenderStyle> m_style;
     
    9885inline ContainerNode* NodeRenderingContext::parentNodeForRenderingAndStyle() const
    9986{
    100     ASSERT(m_phase != Calculating);
    10187    return m_parentNodeForRenderingAndStyle;
    10288}
     
    10490inline bool NodeRenderingContext::resetStyleInheritance() const
    10591{
    106     ASSERT(m_phase != Calculating);
    10792    return m_resetStyleInheritance;
    10893}
     
    116101{
    117102    return m_insertionPoint;
    118 }
    119 
    120 inline bool NodeRenderingContext::isOnEncapsulationBoundary() const
    121 {
    122     return (m_phase == AttachingDistributed
    123             || m_phase == AttachingShadowChild
    124             || m_phase == AttachingFallbacked);
    125 }
    126 
    127 inline bool NodeRenderingContext::isOnUpperEncapsulationBoundary() const
    128 {
    129     return m_phase == AttachingShadowChild;
    130103}
    131104
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r121079 r121131  
    8181{
    8282    if (!node)
    83         return true;
     83        return false;
    8484
    8585    if (node->isHTMLElement() && toHTMLElement(node)->isInsertionPoint())
     
    106106}
    107107
    108 inline bool isShadowBoundary(Node* node)
     108inline bool isLowerEncapsulationBoundary(Node* node)
    109109{
    110110    if (!isInsertionPoint(node))
Note: See TracChangeset for help on using the changeset viewer.