Changeset 109864 in webkit


Ignore:
Timestamp:
Mar 5, 2012 10:59:02 PM (12 years ago)
Author:
shinyak@chromium.org
Message:

InsertionPoint::attach should be consistent with Element.
https://bugs.webkit.org/show_bug.cgi?id=80373

Reviewed by Hajime Morita.

This patch is preparation for coming <shadow> patches.

InsertionPoint used to attach fallback elements before attaching distributed elements.
To be consistent with Element::attach behavior, attaching distributed elements first is
natural, because Element attaches a shadow tree first.

Also, this patch extracts a few methods form InsretionPoint::attach() and detach()
to keep code clean. They will become messy without this refactoring when adding
<shadow> patch.

No new tests. Should be covered by existing tests.

  • html/shadow/InsertionPoint.cpp:

(WebCore::InsertionPoint::attach):
(WebCore::InsertionPoint::detach):
(WebCore::InsertionPoint::distributeHostChildren):
(WebCore):
(WebCore::InsertionPoint::clearDistribution):
(WebCore::InsertionPoint::attachDistributedNode):

  • html/shadow/InsertionPoint.h:

(InsertionPoint):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109861 r109864  
     12012-03-05  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        InsertionPoint::attach should be consistent with Element.
     4        https://bugs.webkit.org/show_bug.cgi?id=80373
     5
     6        Reviewed by Hajime Morita.
     7
     8        This patch is preparation for coming <shadow> patches.
     9
     10        InsertionPoint used to attach fallback elements before attaching distributed elements.
     11        To be consistent with Element::attach behavior, attaching distributed elements first is
     12        natural, because Element attaches a shadow tree first.
     13
     14        Also, this patch extracts a few methods form InsretionPoint::attach() and detach()
     15        to keep code clean. They will become messy without this refactoring when adding
     16        <shadow> patch.
     17
     18        No new tests. Should be covered by existing tests.
     19
     20        * html/shadow/InsertionPoint.cpp:
     21        (WebCore::InsertionPoint::attach):
     22        (WebCore::InsertionPoint::detach):
     23        (WebCore::InsertionPoint::distributeHostChildren):
     24        (WebCore):
     25        (WebCore::InsertionPoint::clearDistribution):
     26        (WebCore::InsertionPoint::attachDistributedNode):
     27        * html/shadow/InsertionPoint.h:
     28        (InsertionPoint):
     29
    1302012-03-05  Adam Barth  <abarth@webkit.org>
    231
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r109718 r109864  
    4949void InsertionPoint::attach()
    5050{
    51     ShadowRoot* root = toShadowRoot(shadowTreeRootNode());
    52 
    53     if (root) {
    54         HTMLContentSelector* selector = root->tree()->ensureSelector();
    55         selector->unselect(&m_selections);
    56         selector->select(this, &m_selections);
     51    if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
     52        distributeHostChildren(root->tree());
     53        attachDistributedNode();
    5754    }
    5855
    5956    HTMLElement::attach();
    60 
    61     if (root) {
    62         for (HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next())
    63             selection->node()->attach();
    64     }
    6557}
    6658
     
    6860{
    6961    if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
    70         if (HTMLContentSelector* selector = root->tree()->selector())
    71             selector->unselect(&m_selections);
     62        ShadowTree* tree = root->tree();
     63        clearDistribution(tree);
    7264
    7365        // When shadow element is detached, shadow tree should be recreated to re-calculate selector for
    7466        // other insertion points.
    75         root->tree()->setNeedsReattachHostChildrenAndShadow();
     67        tree->setNeedsReattachHostChildrenAndShadow();
    7668    }
    7769
     
    9284}
    9385
     86inline void InsertionPoint::distributeHostChildren(ShadowTree* tree)
     87{
     88    HTMLContentSelector* selector = tree->ensureSelector();
     89    selector->unselect(&m_selections);
     90    selector->select(this, &m_selections);
     91}
     92
     93inline void InsertionPoint::clearDistribution(ShadowTree* tree)
     94{
     95    if (HTMLContentSelector* selector = tree->selector())
     96        selector->unselect(&m_selections);
     97}
     98
     99inline void InsertionPoint::attachDistributedNode()
     100{
     101    for (HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next())
     102        selection->node()->attach();
     103}
     104
    94105} // namespace WebCore
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r109718 r109864  
    5555    virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;
    5656
     57private:
     58    void distributeHostChildren(ShadowTree*);
     59    void clearDistribution(ShadowTree*);
     60    void attachDistributedNode();
     61
    5762    HTMLContentSelectionList m_selections;
    5863};
Note: See TracChangeset for help on using the changeset viewer.