Changeset 87123 in webkit


Ignore:
Timestamp:
May 23, 2011 8:31:34 PM (13 years ago)
Author:
morrita@google.com
Message:

2011-05-20 MORITA Hajime <morrita@google.com>

Reviewed by Dimitri Glazkov.

[Refactoring] attach() following detach() should be replaced with Node::reattach()
https://bugs.webkit.org/show_bug.cgi?id=61011

  • Renamed forceReattach() to reattach()
  • Introduced reattachIfAttached() as a variant.

No new tests. No behavior change.

  • dom/CharacterData.cpp: (WebCore::CharacterData::updateRenderer):
  • dom/Element.cpp: (WebCore::Element::recalcStyle):
  • dom/Node.h: (WebCore::Node::reattach): (WebCore::Node::reattachIfAttached):
  • dom/Text.cpp: (WebCore::Text::recalcStyle):
  • html/HTMLDetailsElement.cpp: (WebCore::HTMLDetailsElement::refreshMainSummary): (WebCore::HTMLDetailsElement::parseMappedAttribute):
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::parseMappedAttribute):
  • html/HTMLObjectElement.cpp: (WebCore::HTMLObjectElement::renderFallbackContent):
  • html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::recalcStyle):
  • html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::parseMappedAttribute):
Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87122 r87123  
     12011-05-20  MORITA Hajime  <morrita@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4       
     5        [Refactoring] attach() following detach() should be replaced with Node::reattach()
     6        https://bugs.webkit.org/show_bug.cgi?id=61011
     7
     8        - Renamed forceReattach() to reattach()
     9        - Introduced reattachIfAttached() as a variant.
     10       
     11        No new tests. No behavior change.
     12
     13        * dom/CharacterData.cpp:
     14        (WebCore::CharacterData::updateRenderer):
     15        * dom/Element.cpp:
     16        (WebCore::Element::recalcStyle):
     17        * dom/Node.h:
     18        (WebCore::Node::reattach):
     19        (WebCore::Node::reattachIfAttached):
     20        * dom/Text.cpp:
     21        (WebCore::Text::recalcStyle):
     22        * html/HTMLDetailsElement.cpp:
     23        (WebCore::HTMLDetailsElement::refreshMainSummary):
     24        (WebCore::HTMLDetailsElement::parseMappedAttribute):
     25        * html/HTMLInputElement.cpp:
     26        (WebCore::HTMLInputElement::parseMappedAttribute):
     27        * html/HTMLObjectElement.cpp:
     28        (WebCore::HTMLObjectElement::renderFallbackContent):
     29        * html/HTMLPlugInImageElement.cpp:
     30        (WebCore::HTMLPlugInImageElement::recalcStyle):
     31        * html/HTMLSelectElement.cpp:
     32        (WebCore::HTMLSelectElement::parseMappedAttribute):
     33
    1342011-05-23  Mark Rowe  <mrowe@apple.com>
    235
  • trunk/Source/WebCore/dom/CharacterData.cpp

    r85030 r87123  
    183183{
    184184    if ((!renderer() || !rendererIsNeeded(renderer()->style())) && attached()) {
    185         detach();
    186         attach();
     185        reattach();
    187186    } else if (renderer())
    188187        toRenderText(renderer())->setTextWithOffset(m_data, offsetOfReplacedData, lengthOfReplacedData);
  • trunk/Source/WebCore/dom/Element.cpp

    r87067 r87123  
    10871087        StyleChange ch = diff(currentStyle.get(), newStyle.get());
    10881088        if (ch == Detach || !currentStyle) {
    1089             if (attached())
    1090                 detach();
    1091             attach(); // FIXME: The style gets computed twice by calling attach. We could do better if we passed the style along.
     1089            // FIXME: The style gets computed twice by calling attach. We could do better if we passed the style along.
     1090            reattach();
    10921091            // attach recalulates the style for all children. No need to do it twice.
    10931092            clearNeedsStyleRecalc();
  • trunk/Source/WebCore/dom/Node.h

    r87079 r87123  
    452452    virtual void detach();
    453453
    454     void forceReattach();
     454    void reattach();
     455    void reattachIfAttached();
    455456
    456457    virtual void willRemove();
     
    740741}
    741742
    742 inline void Node::forceReattach()
     743inline void Node::reattach()
    743744{
    744     if (!attached())
    745         return;
    746     detach();
     745    if (attached())
     746        detach();
    747747    attach();
     748}
     749
     750inline void Node::reattachIfAttached()
     751{
     752    if (attached())
     753        reattach();
    748754}
    749755
  • trunk/Source/WebCore/dom/ShadowContentSelector.cpp

    r86726 r87123  
    6363            continue;
    6464
    65         child->forceReattach();
     65        child->reattach();
    6666        m_children[i] = 0;
    6767    }
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r86726 r87123  
    8585{
    8686    if (hasContentElement())
    87         forceReattach();
     87        reattach();
    8888    else {
    8989        for (Node* n = firstChild(); n; n = n->nextSibling())
  • trunk/Source/WebCore/dom/Text.cpp

    r85256 r87123  
    266266            if (renderer()->isText())
    267267                toRenderText(renderer())->setText(dataImpl());
    268         } else {
    269             if (attached())
    270                 detach();
    271             attach();
    272         }
     268        } else
     269            reattach();
    273270    }
    274271    clearNeedsStyleRecalc();
  • trunk/Source/WebCore/html/HTMLDetailsElement.cpp

    r86726 r87123  
    147147        return;
    148148
    149     if (oldSummary && oldSummary->parentNodeForRenderingAndStyle()) {
    150         oldSummary->detach();
    151         oldSummary->attach();
    152     }
    153        
    154     if (m_mainSummary && refreshRenderer == RefreshRendererAllowed) {
    155         m_mainSummary->detach();
    156         m_mainSummary->attach();
    157     }
     149    if (oldSummary && oldSummary->parentNodeForRenderingAndStyle())
     150        oldSummary->reattach();
     151    if (m_mainSummary && refreshRenderer == RefreshRendererAllowed)
     152        m_mainSummary->reattach();
    158153}
    159154
     
    197192        bool oldValue = m_isOpen;
    198193        m_isOpen =  !attr->value().isNull();
    199         if (attached() && oldValue != m_isOpen) {
    200             detach();
    201             attach();
    202         }
     194        if (oldValue != m_isOpen)
     195            reattachIfAttached();
    203196    } else
    204197        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r87067 r87123  
    722722        // FIXME: Detaching just for maxResults change is not ideal.  We should figure out the right
    723723        // time to relayout for this change.
    724         if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0) && attached()) {
    725             detach();
    726             attach();
    727         }
     724        if (m_maxResults != oldResults && (m_maxResults <= 0 || oldResults <= 0))
     725            reattachIfAttached();
    728726        setNeedsStyleRecalc();
    729727    } else if (attr->name() == autosaveAttr || attr->name() == incrementalAttr)
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r87115 r87123  
    379379        if (!isImageType()) {
    380380            // If we don't think we have an image type anymore, then clear the image from the loader.
    381             m_imageLoader->setImage(0);       
    382             detach();
    383             attach();
     381            m_imageLoader->setImage(0);
     382            reattach();
    384383            return;
    385384        }
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r82001 r87123  
    125125{
    126126    // FIXME: Why is this necessary?  Manual re-attach is almost always wrong.
    127     if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType()) {
    128         detach();
    129         attach();
    130     }
     127    if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType())
     128        reattach();
    131129    HTMLPlugInElement::recalcStyle(ch);
    132130}
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r86827 r87123  
    265265        setNeedsValidityCheck();
    266266        if ((oldUsesMenuList != m_data.usesMenuList() || (!oldUsesMenuList && m_data.size() != oldSize)) && attached()) {
    267             detach();
    268             attach();
     267            reattach();
    269268            setRecalcListItems();
    270269        }
Note: See TracChangeset for help on using the changeset viewer.