Changeset 109718 in webkit


Ignore:
Timestamp:
Mar 5, 2012 12:22:33 AM (12 years ago)
Author:
shinyak@chromium.org
Message:

Refactoring: Move HTMLContentElement::attach to InsertionPoint::attach.
https://bugs.webkit.org/show_bug.cgi?id=80243

Reviewed by Hajime Morita.

Since the current code in HTMLContentElement::attach() will be used for coming <shadow>
elements, it is natural that InsertionPoint::attach() has such code.

No new tests, no change in behavior.

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

(HTMLContentElement):

  • html/shadow/InsertionPoint.cpp:

(WebCore::InsertionPoint::attach):
(WebCore):
(WebCore::InsertionPoint::detach):

  • html/shadow/InsertionPoint.h:

(InsertionPoint):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109716 r109718  
     12012-03-05  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        Refactoring: Move HTMLContentElement::attach to InsertionPoint::attach.
     4        https://bugs.webkit.org/show_bug.cgi?id=80243
     5
     6        Reviewed by Hajime Morita.
     7
     8        Since the current code in HTMLContentElement::attach() will be used for coming <shadow>
     9        elements, it is natural that InsertionPoint::attach() has such code.
     10
     11        No new tests, no change in behavior.
     12
     13        * html/shadow/HTMLContentElement.cpp:
     14        * html/shadow/HTMLContentElement.h:
     15        (HTMLContentElement):
     16        * html/shadow/InsertionPoint.cpp:
     17        (WebCore::InsertionPoint::attach):
     18        (WebCore):
     19        (WebCore::InsertionPoint::detach):
     20        * html/shadow/InsertionPoint.h:
     21        (InsertionPoint):
     22
    1232012-03-05  Adam Barth  <abarth@webkit.org>
    224
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp

    r109313 r109718  
    6969}
    7070
    71 void HTMLContentElement::attach()
    72 {
    73     ShadowRoot* root = toShadowRoot(shadowTreeRootNode());
    74 
    75     // Before calling StyledElement::attach, selector must be calculated.
    76     if (root) {
    77         HTMLContentSelector* selector = root->tree()->ensureSelector();
    78         selector->unselect(&m_selections);
    79         selector->select(this, &m_selections);
    80     }
    81 
    82     InsertionPoint::attach();
    83 
    84     if (root) {
    85         for (HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next())
    86             selection->node()->attach();
    87     }
    88 }
    89 
    90 void HTMLContentElement::detach()
    91 {
    92     if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
    93         if (HTMLContentSelector* selector = root->tree()->selector())
    94             selector->unselect(&m_selections);
    95 
    96         // When content element is detached, shadow tree should be recreated to re-calculate selector for
    97         // other insertion points.
    98         root->tree()->setNeedsReattachHostChildrenAndShadow();
    99     }
    100 
    101     ASSERT(m_selections.isEmpty());
    102     InsertionPoint::detach();
    103 }
    104 
    10571const AtomicString& HTMLContentElement::select() const
    10672{
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.h

    r109313 r109718  
    4545
    4646    virtual ~HTMLContentElement();
    47     virtual void attach();
    48     virtual void detach();
    4947
    5048    const AtomicString& select() const;
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r109179 r109718  
    3333
    3434#include "ShadowRoot.h"
     35#include "ShadowTree.h"
    3536
    3637namespace WebCore {
     
    4445InsertionPoint::~InsertionPoint()
    4546{
     47}
     48
     49void InsertionPoint::attach()
     50{
     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);
     57    }
     58
     59    HTMLElement::attach();
     60
     61    if (root) {
     62        for (HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next())
     63            selection->node()->attach();
     64    }
     65}
     66
     67void InsertionPoint::detach()
     68{
     69    if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
     70        if (HTMLContentSelector* selector = root->tree()->selector())
     71            selector->unselect(&m_selections);
     72
     73        // When shadow element is detached, shadow tree should be recreated to re-calculate selector for
     74        // other insertion points.
     75        root->tree()->setNeedsReattachHostChildrenAndShadow();
     76    }
     77
     78    ASSERT(m_selections.isEmpty());
     79    HTMLElement::detach();
    4680}
    4781
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r109313 r109718  
    4848    virtual const AtomicString& select() const = 0;
    4949
     50    virtual void attach();
     51    virtual void detach();
     52
    5053protected:
    5154    InsertionPoint(const QualifiedName&, Document*);
Note: See TracChangeset for help on using the changeset viewer.