Changeset 154327 in webkit


Ignore:
Timestamp:
Aug 20, 2013 8:27:41 AM (11 years ago)
Author:
Antti Koivisto
Message:

<https://webkit.org/b/120017> Remove NodeRenderingTraversal::ParentDetails

Reviewed by Andreas Kling.

Remove this oddly factored type that is used to optionally collect some data during ComposedShadowTreeWalker parent traversal.

Also removed support for reset-style-inheritance attribute in InsertionPoint. We don't use or expose it.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::State::initForStyleResolve):
(WebCore::StyleResolver::styleForElement):

  • css/StyleResolver.h:

(WebCore::StyleResolver::State::State):
(WebCore::StyleResolver::State::elementLinkState):

Remove m_distributedToInsertionPoint State field. We never hit the cases where it was used.

  • dom/ComposedShadowTreeWalker.cpp:

(WebCore::ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint):
(WebCore::ComposedShadowTreeWalker::traverseNodeEscapingFallbackContents):
(WebCore::ComposedShadowTreeWalker::traverseParent):

Return null instead of setting childWasOutOfComposition to details object. That's what would happen anyway in the caller.

(WebCore::ComposedShadowTreeWalker::traverseParentInCurrentTree):
(WebCore::ComposedShadowTreeWalker::traverseParentBackToShadowRootOrHost):

  • dom/ComposedShadowTreeWalker.h:
  • dom/Node.cpp:

(WebCore::Node::insertionParentForBinding):

  • dom/NodeRenderingContext.cpp:

(WebCore::NodeRenderingContext::NodeRenderingContext):
(WebCore::NodeRenderingContext::isOnEncapsulationBoundary):

Make this look up InsertionPoint directly intead of relying it being populated in m_parentDetails. The function is used only in
a few non-performance critical places.

(WebCore::NodeRenderingContext::resetStyleInheritance):

Return parent ShadowRoots resetStyleInheritance() flag instead of using m_parentDetails.

  • dom/NodeRenderingContext.h:
  • dom/NodeRenderingTraversal.cpp:

(WebCore::NodeRenderingTraversal::parentSlow):

  • dom/NodeRenderingTraversal.h:

(WebCore::NodeRenderingTraversal::parent):

Remove ParentDetails.

  • html/HTMLAttributeNames.in:
  • html/shadow/InsertionPoint.cpp:


Remove unused resetStyleInheritance attribute.

(WebCore::InsertionPoint::removedFrom):
(WebCore::findInsertionPointOf):

Renamed for clarity.

  • html/shadow/InsertionPoint.h:
  • testing/Internals.cpp:

(WebCore::Internals::includerFor):

Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154326 r154327  
     12013-08-20  Antti Koivisto  <antti@apple.com>
     2
     3        <https://webkit.org/b/120017> Remove NodeRenderingTraversal::ParentDetails
     4
     5        Reviewed by Andreas Kling.
     6
     7        Remove this oddly factored type that is used to optionally collect some data during ComposedShadowTreeWalker parent traversal.
     8       
     9        Also removed support for reset-style-inheritance attribute in InsertionPoint. We don't use or expose it.
     10
     11        * css/StyleResolver.cpp:
     12        (WebCore::StyleResolver::State::initForStyleResolve):
     13        (WebCore::StyleResolver::styleForElement):
     14        * css/StyleResolver.h:
     15        (WebCore::StyleResolver::State::State):
     16        (WebCore::StyleResolver::State::elementLinkState):
     17       
     18            Remove m_distributedToInsertionPoint State field. We never hit the cases where it was used.
     19
     20        * dom/ComposedShadowTreeWalker.cpp:
     21        (WebCore::ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint):
     22        (WebCore::ComposedShadowTreeWalker::traverseNodeEscapingFallbackContents):
     23        (WebCore::ComposedShadowTreeWalker::traverseParent):
     24       
     25            Return null instead of setting childWasOutOfComposition to details object. That's what would happen anyway in the caller.
     26
     27        (WebCore::ComposedShadowTreeWalker::traverseParentInCurrentTree):
     28        (WebCore::ComposedShadowTreeWalker::traverseParentBackToShadowRootOrHost):
     29        * dom/ComposedShadowTreeWalker.h:
     30        * dom/Node.cpp:
     31        (WebCore::Node::insertionParentForBinding):
     32        * dom/NodeRenderingContext.cpp:
     33        (WebCore::NodeRenderingContext::NodeRenderingContext):
     34        (WebCore::NodeRenderingContext::isOnEncapsulationBoundary):
     35       
     36            Make this look up InsertionPoint directly intead of relying it being populated in m_parentDetails. The function is used only in
     37            a few non-performance critical places.
     38
     39        (WebCore::NodeRenderingContext::resetStyleInheritance):
     40       
     41            Return parent ShadowRoots resetStyleInheritance() flag instead of using m_parentDetails.
     42
     43        * dom/NodeRenderingContext.h:
     44        * dom/NodeRenderingTraversal.cpp:
     45        (WebCore::NodeRenderingTraversal::parentSlow):
     46        * dom/NodeRenderingTraversal.h:
     47        (WebCore::NodeRenderingTraversal::parent):
     48       
     49            Remove ParentDetails.
     50
     51        * html/HTMLAttributeNames.in:
     52        * html/shadow/InsertionPoint.cpp:
     53       
     54            Remove unused resetStyleInheritance attribute.
     55
     56        (WebCore::InsertionPoint::removedFrom):
     57        (WebCore::findInsertionPointOf):
     58       
     59            Renamed for clarity.
     60
     61        * html/shadow/InsertionPoint.h:
     62        * testing/Internals.cpp:
     63        (WebCore::Internals::includerFor):
     64
    1652013-08-20  Antti Koivisto  <antti@apple.com>
    266
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r154299 r154327  
    434434            parentStyle ? parentStyle :
    435435            m_parentNode ? m_parentNode->renderStyle() : 0;
    436         m_distributedToInsertionPoint = context.insertionPoint();
    437436    } else {
    438437        m_parentNode = 0;
    439438        m_parentStyle = parentStyle;
    440         m_distributedToInsertionPoint = false;
    441439    }
    442440
     
    810808    initElement(element);
    811809    state.initForStyleResolve(document(), element, defaultParent, regionForStyling);
    812     if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint()) {
     810    if (sharingBehavior == AllowStyleSharing) {
    813811        RenderStyle* sharedStyle = locateSharedStyle();
    814812        if (sharedStyle) {
     
    824822        state.setStyle(defaultStyleForElement());
    825823        state.setParentStyle(RenderStyle::clone(state.style()));
    826     }
    827     // contenteditable attribute (implemented by -webkit-user-modify) should
    828     // be propagated from shadow host to distributed node.
    829     if (state.distributedToInsertionPoint()) {
    830         if (Element* parent = element->parentElement()) {
    831             if (RenderStyle* styleOfShadowHost = parent->renderStyle())
    832                 state.style()->setUserModify(styleOfShadowHost->userModify());
    833         }
    834824    }
    835825
  • trunk/Source/WebCore/css/StyleResolver.h

    r154133 r154327  
    416416        , m_regionForStyling(0)
    417417        , m_elementLinkState(NotInsideLink)
    418         , m_distributedToInsertionPoint(false)
    419418        , m_elementAffectedByClassRules(false)
    420419        , m_applyPropertyToRegularStyle(true)
     
    447446        const RenderRegion* regionForStyling() const { return m_regionForStyling; }
    448447        EInsideLink elementLinkState() const { return m_elementLinkState; }
    449         bool distributedToInsertionPoint() const { return m_distributedToInsertionPoint; }
    450448        void setElementAffectedByClassRules(bool isAffected) { m_elementAffectedByClassRules = isAffected; }
    451449        bool elementAffectedByClassRules() const { return m_elementAffectedByClassRules; }
     
    500498       
    501499        EInsideLink m_elementLinkState;
    502 
    503         bool m_distributedToInsertionPoint;
    504500
    505501        bool m_elementAffectedByClassRules;
  • trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp

    r154232 r154327  
    154154        return traverseSiblingInCurrentTree(node, direction);
    155155
    156     InsertionPoint* insertionPoint = resolveReprojection(node);
     156    InsertionPoint* insertionPoint = findInsertionPointOf(node);
    157157    if (!insertionPoint)
    158158        return traverseSiblingInCurrentTree(node, direction);
     
    179179}
    180180
    181 inline Node* ComposedShadowTreeWalker::traverseNodeEscapingFallbackContents(const Node* node, ParentTraversalDetails* details) const
     181inline Node* ComposedShadowTreeWalker::traverseNodeEscapingFallbackContents(const Node* node) const
    182182{
    183183    ASSERT(node);
     
    186186    const InsertionPoint* insertionPoint = toInsertionPoint(node);
    187187    return insertionPoint->hasDistribution() ? 0 :
    188         insertionPoint->isActive() ? traverseParent(node, details) : const_cast<Node*>(node);
     188        insertionPoint->isActive() ? traverseParent(node) : const_cast<Node*>(node);
    189189}
    190190
     
    198198// FIXME: Use an iterative algorithm so that it can be inlined.
    199199// https://bugs.webkit.org/show_bug.cgi?id=90415
    200 Node* ComposedShadowTreeWalker::traverseParent(const Node* node, ParentTraversalDetails* details) const
     200Node* ComposedShadowTreeWalker::traverseParent(const Node* node) const
    201201{
    202202    if (node->isPseudoElement())
     
    207207
    208208    if (nodeCanBeDistributed(node)) {
    209         if (InsertionPoint* insertionPoint = resolveReprojection(node)) {
    210             if (details)
    211                 details->didTraverseInsertionPoint(insertionPoint);
    212             return traverseParent(insertionPoint, details);
    213         }
    214 
    215         // The node is a non-distributed light child or older shadow's child.
    216         if (details)
    217             details->childWasOutOfComposition();
    218     }
    219     return traverseParentInCurrentTree(node, details);
    220 }
    221 
    222 inline Node* ComposedShadowTreeWalker::traverseParentInCurrentTree(const Node* node, ParentTraversalDetails* details) const
     209        if (InsertionPoint* insertionPoint = findInsertionPointOf(node))
     210            return traverseParent(insertionPoint);
     211        return 0;
     212    }
     213    return traverseParentInCurrentTree(node);
     214}
     215
     216inline Node* ComposedShadowTreeWalker::traverseParentInCurrentTree(const Node* node) const
    223217{
    224218    if (Node* parent = node->parentNode())
    225         return parent->isShadowRoot() ? traverseParentBackToShadowRootOrHost(toShadowRoot(parent), details) : traverseNodeEscapingFallbackContents(parent, details);
    226     return 0;
    227 }
    228 
    229 Node* ComposedShadowTreeWalker::traverseParentBackToShadowRootOrHost(const ShadowRoot* shadowRoot, ParentTraversalDetails* details) const
     219        return parent->isShadowRoot() ? traverseParentBackToShadowRootOrHost(toShadowRoot(parent)) : traverseNodeEscapingFallbackContents(parent);
     220    return 0;
     221}
     222
     223Node* ComposedShadowTreeWalker::traverseParentBackToShadowRootOrHost(const ShadowRoot* shadowRoot) const
    230224{
    231225    ASSERT(shadowRoot);
    232226
    233     if (canCrossUpperBoundary()) {
    234         if (details)
    235             details->didTraverseShadowRoot(shadowRoot);
     227    if (canCrossUpperBoundary())
    236228        return shadowRoot->hostElement();
    237     }
    238229
    239230    return const_cast<ShadowRoot*>(shadowRoot);
  • trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h

    r149549 r154327  
    4141class ComposedShadowTreeWalker {
    4242public:
    43     typedef NodeRenderingTraversal::ParentDetails ParentTraversalDetails;
    44 
    4543    enum Policy {
    4644        CrossUpperBoundary,
     
    7270    void previous();
    7371
    74     Node* traverseParent(const Node*, ParentTraversalDetails* = 0) const;
     72    Node* traverseParent(const Node*) const;
    7573
    7674private:
    77     ComposedShadowTreeWalker(const Node*, ParentTraversalDetails*);
    78 
    7975    enum TraversalDirection {
    8076        TraversalDirectionForward,
     
    120116    static Node* escapeFallbackContentElement(const Node*, TraversalDirection);
    121117
    122     Node* traverseNodeEscapingFallbackContents(const Node*, ParentTraversalDetails* = 0) const;
    123     Node* traverseParentInCurrentTree(const Node*, ParentTraversalDetails* = 0) const;
    124     Node* traverseParentBackToShadowRootOrHost(const ShadowRoot*, ParentTraversalDetails* = 0) const;
     118    Node* traverseNodeEscapingFallbackContents(const Node*) const;
     119    Node* traverseParentInCurrentTree(const Node*) const;
     120    Node* traverseParentBackToShadowRootOrHost(const ShadowRoot*) const;
    125121
    126122    const Node* m_node;
  • trunk/Source/WebCore/dom/Node.cpp

    r154239 r154327  
    10401040Node* Node::insertionParentForBinding() const
    10411041{
    1042     return resolveReprojection(this);
     1042    return findInsertionPointOf(this);
    10431043}
    10441044
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r154257 r154327  
    5757    , m_parentFlowRenderer(0)
    5858{
    59     m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetails);
     59    m_renderingParent = NodeRenderingTraversal::parent(node);
    6060}
    6161
     
    7373    , m_parentFlowRenderer(0)
    7474{
    75     m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetails);
     75    m_renderingParent = NodeRenderingTraversal::parent(node);
    7676}
    7777
     
    238238bool NodeRenderingContext::isOnEncapsulationBoundary() const
    239239{
    240     return isOnUpperEncapsulationBoundary() || isLowerEncapsulationBoundary(m_parentDetails.insertionPoint()) || isLowerEncapsulationBoundary(m_node->parentNode());
     240    return isOnUpperEncapsulationBoundary()
     241        || isLowerEncapsulationBoundary(findInsertionPointOf(m_node))
     242        || isLowerEncapsulationBoundary(m_node->parentNode());
    241243}
    242244
     
    335337}
    336338
    337 }
     339bool NodeRenderingContext::resetStyleInheritance() const
     340{
     341    ContainerNode* parent = m_node->parentNode();
     342    return parent && parent->isShadowRoot() && toShadowRoot(parent)->resetStyleInheritance();
     343}
     344
     345}
  • trunk/Source/WebCore/dom/NodeRenderingContext.h

    r154257 r154327  
    6060    RenderObject* nextRenderer() const;
    6161    RenderObject* previousRenderer() const;
    62     InsertionPoint* insertionPoint() const;
    6362
    6463    const RenderStyle* style() const;
     
    7473    Node* m_node;
    7574    ContainerNode* m_renderingParent;
    76     NodeRenderingTraversal::ParentDetails m_parentDetails;
    7775    RefPtr<RenderStyle> m_style;
    7876    RenderNamedFlowThread* m_parentFlowRenderer;
     
    8987}
    9088
    91 inline bool NodeRenderingContext::resetStyleInheritance() const
    92 {
    93     return m_parentDetails.resetStyleInheritance();
    94 }
    95 
    9689inline const RenderStyle* NodeRenderingContext::style() const
    9790{
     
    9992}
    10093
    101 inline InsertionPoint* NodeRenderingContext::insertionPoint() const
    102 {
    103     return m_parentDetails.insertionPoint();
    104 }
    105 
    10694} // namespace WebCore
    10795
  • trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp

    r139325 r154327  
    3535namespace NodeRenderingTraversal {
    3636
    37 void ParentDetails::didTraverseInsertionPoint(InsertionPoint* insertionPoint)
    38 {
    39     if (!m_insertionPoint) {
    40         m_insertionPoint = insertionPoint;
    41         m_resetStyleInheritance  = m_resetStyleInheritance || insertionPoint->resetStyleInheritance();
    42     }
    43 }
    44 
    45 void ParentDetails::didTraverseShadowRoot(const ShadowRoot* root)
    46 {
    47     m_resetStyleInheritance  = m_resetStyleInheritance || root->resetStyleInheritance();
    48 }
    49 
    50 ContainerNode* parentSlow(const Node* node, ParentDetails* details)
     37ContainerNode* parentSlow(const Node* node)
    5138{
    5239    ComposedShadowTreeWalker walker(node, ComposedShadowTreeWalker::CrossUpperBoundary, ComposedShadowTreeWalker::CanStartFromShadowBoundary);
    53     ContainerNode* found = toContainerNode(walker.traverseParent(walker.get(), details));
    54     return details->outOfComposition() ? 0 : found;
     40    return toContainerNode(walker.traverseParent(walker.get()));
    5541}
    5642
  • trunk/Source/WebCore/dom/NodeRenderingTraversal.h

    r139325 r154327  
    3636namespace NodeRenderingTraversal {
    3737
    38 class ParentDetails {
    39 public:
    40     ParentDetails()
    41         : m_insertionPoint(0)
    42         , m_resetStyleInheritance(false)
    43         , m_outOfComposition(false)
    44     { }
    45 
    46     InsertionPoint* insertionPoint() const { return m_insertionPoint; }
    47     bool resetStyleInheritance() const { return m_resetStyleInheritance; }
    48     bool outOfComposition() const { return m_outOfComposition; }
    49 
    50     void didTraverseInsertionPoint(InsertionPoint*);
    51     void didTraverseShadowRoot(const ShadowRoot*);
    52     void childWasOutOfComposition() { m_outOfComposition = true; }
    53 
    54     bool operator==(const ParentDetails& other)
    55     {
    56         return m_insertionPoint == other.m_insertionPoint
    57             && m_resetStyleInheritance == other.m_resetStyleInheritance
    58             && m_outOfComposition == other.m_outOfComposition;
    59     }
    60 
    61 private:
    62     InsertionPoint* m_insertionPoint;
    63     bool m_resetStyleInheritance;
    64     bool m_outOfComposition;
    65 };
    66 
    67 ContainerNode* parent(const Node*, ParentDetails*);
    68 ContainerNode* parentSlow(const Node*, ParentDetails*);
     38ContainerNode* parent(const Node*);
     39ContainerNode* parentSlow(const Node*);
    6940Node* nextSibling(const Node*);
    7041Node* nextSiblingSlow(const Node*);
     
    7748Node* lastChildInScope(const Node*);
    7849
    79 inline ContainerNode* parent(const Node* node, ParentDetails* details)
     50inline ContainerNode* parent(const Node* node)
    8051{
    8152    if (!node->needsShadowTreeWalker()) {
    8253#ifndef NDEBUG
    83         ParentDetails slowDetails;
    84         ASSERT(node->parentNode() == parentSlow(node, &slowDetails));
    85         ASSERT(slowDetails == *details);
     54        ASSERT(node->parentNode() == parentSlow(node));
    8655#endif
    8756        return node->parentNodeGuaranteedHostFree();
    8857    }
    8958
    90     return parentSlow(node, details);
     59    return parentSlow(node);
    9160}
    9261
  • trunk/Source/WebCore/html/HTMLAttributeNames.in

    r153624 r154327  
    284284rel
    285285required
    286 reset-style-inheritance
    287286results
    288287rev
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r154257 r154327  
    148148    HTMLElement::removedFrom(insertionPoint);
    149149}
    150 
    151 void InsertionPoint::parseAttribute(const QualifiedName& name, const AtomicString& value)
    152 {
    153     if (name == reset_style_inheritanceAttr) {
    154         if (!inDocument() || !attached() || !isActive())
    155             return;
    156         containingShadowRoot()->hostElement()->setNeedsStyleRecalc();
    157     } else
    158         HTMLElement::parseAttribute(name, value);
    159 }
    160 
    161 bool InsertionPoint::resetStyleInheritance() const
    162 {
    163     return fastHasAttribute(reset_style_inheritanceAttr);
    164 }
    165 
    166 void InsertionPoint::setResetStyleInheritance(bool value)
    167 {
    168     setBooleanAttribute(reset_style_inheritanceAttr, value);
    169 }
    170150   
    171151Node* InsertionPoint::firstDistributed() const
     
    209189}
    210190
    211 InsertionPoint* resolveReprojection(const Node* projectedNode)
     191InsertionPoint* findInsertionPointOf(const Node* projectedNode)
    212192{
    213193    if (ShadowRoot* shadowRoot = shadowRootOfParentForDistribution(projectedNode)) {
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r154254 r154327  
    6363    virtual Type insertionPointType() const { return InternalType; }
    6464
    65     bool resetStyleInheritance() const;
    66     void setResetStyleInheritance(bool);
    67 
    6865    virtual void willAttachRenderers() OVERRIDE;
    6966    virtual void willDetachRenderers() OVERRIDE;
     
    8279    virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
    8380    virtual void removedFrom(ContainerNode*) OVERRIDE;
    84     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
    8581    virtual bool isInsertionPointNode() const OVERRIDE { return true; }
    8682
     
    146142}
    147143
    148 InsertionPoint* resolveReprojection(const Node*);
     144InsertionPoint* findInsertionPointOf(const Node*);
    149145
    150146} // namespace WebCore
  • trunk/Source/WebCore/testing/Internals.cpp

    r154286 r154327  
    669669}
    670670
    671 Element* Internals::includerFor(Node* node, ExceptionCode& ec)
    672 {
    673     if (!node) {
    674         ec = INVALID_ACCESS_ERR;
    675         return 0;
    676     }
    677 
    678     return NodeRenderingContext(node).insertionPoint();
     671Element* Internals::includerFor(Node*, ExceptionCode& ec)
     672{
     673    ec = INVALID_ACCESS_ERR;
     674    return 0;
    679675}
    680676
Note: See TracChangeset for help on using the changeset viewer.