Changeset 136575 in webkit


Ignore:
Timestamp:
Dec 4, 2012 2:43:26 PM (11 years ago)
Author:
dpranke@chromium.org
Message:

setIsInTopLayer is not really a setter
https://bugs.webkit.org/show_bug.cgi?id=103912

Patch by Elliott Sprehn <esprehn@chromium.org> on 2012-12-04
Reviewed by Eric Seidel.

Element::setInTopLayer isn't just a setter, it also adds the element
to the top layer vector in the document which changes it's display and
causes a reattach.

To make this more obvious make HTMLDialogElement use the methods on
Document and make those update the state boolean.

There also doesn't seem to be any reason for setInTopLayer
or isInTopLayer to be virtual, it appears it was a typo.

No new tests, just refactoring.

  • dom/Document.cpp:

(WebCore::Document::addToTopLayer):
(WebCore::Document::removeFromTopLayer):

  • dom/Element.cpp:

(WebCore::Element::setIsInTopLayer):

  • dom/Element.h:
  • html/HTMLDialogElement.cpp:

(WebCore::HTMLDialogElement::close):
(WebCore::HTMLDialogElement::showModal):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r136574 r136575  
     12012-12-04  Elliott Sprehn  <esprehn@chromium.org>
     2
     3        setIsInTopLayer is not really a setter
     4        https://bugs.webkit.org/show_bug.cgi?id=103912
     5
     6        Reviewed by Eric Seidel.
     7
     8        Element::setInTopLayer isn't just a setter, it also adds the element
     9        to the top layer vector in the document which changes it's display and
     10        causes a reattach.
     11
     12        To make this more obvious make HTMLDialogElement use the methods on
     13        Document and make those update the state boolean.
     14
     15        There also doesn't seem to be any reason for setInTopLayer
     16        or isInTopLayer to be virtual, it appears it was a typo.
     17
     18        No new tests, just refactoring.
     19
     20        * dom/Document.cpp:
     21        (WebCore::Document::addToTopLayer):
     22        (WebCore::Document::removeFromTopLayer):
     23        * dom/Element.cpp:
     24        (WebCore::Element::setIsInTopLayer):
     25        * dom/Element.h:
     26        * html/HTMLDialogElement.cpp:
     27        (WebCore::HTMLDialogElement::close):
     28        (WebCore::HTMLDialogElement::showModal):
     29
    1302012-12-04  Elliott Sprehn  <esprehn@chromium.org>
    231
  • trunk/Source/WebCore/dom/Document.cpp

    r136574 r136575  
    54265426void Document::addToTopLayer(Element* element)
    54275427{
     5428    if (element->isInTopLayer())
     5429        return;
    54285430    ASSERT(!m_topLayerElements.contains(element));
    54295431    m_topLayerElements.append(element);
     5432    element->setIsInTopLayer(true);
    54305433}
    54315434
    54325435void Document::removeFromTopLayer(Element* element)
    54335436{
     5437    if (!element->isInTopLayer())
     5438        return;
    54345439    size_t position = m_topLayerElements.find(element);
    54355440    ASSERT(position != notFound);
    54365441    m_topLayerElements.remove(position);
     5442    element->setIsInTopLayer(false);
    54375443}
    54385444#endif
  • trunk/Source/WebCore/dom/Element.cpp

    r136574 r136575  
    22312231void Element::setIsInTopLayer(bool inTopLayer)
    22322232{
    2233     if (isInTopLayer() == inTopLayer)
    2234         return;
    2235 
    22362233    ensureElementRareData()->setIsInTopLayer(inTopLayer);
    2237 
    2238     if (inTopLayer)
    2239         document()->addToTopLayer(this);
    2240     else
    2241         document()->removeFromTopLayer(this);
    22422234    setNeedsStyleRecalc(SyntheticStyleChange);
    22432235}
  • trunk/Source/WebCore/dom/Element.h

    r136573 r136575  
    438438
    439439#if ENABLE(DIALOG_ELEMENT)
    440     virtual bool isInTopLayer() const;
    441     virtual void setIsInTopLayer(bool);
     440    bool isInTopLayer() const;
     441    void setIsInTopLayer(bool);
    442442#endif
    443443
  • trunk/Source/WebCore/html/HTMLDialogElement.cpp

    r135242 r136575  
    5454    }
    5555    setBooleanAttribute(openAttr, false);
    56     setIsInTopLayer(false);
     56    document()->removeFromTopLayer(this);
    5757}
    5858
     
    7171    }
    7272    setBooleanAttribute(openAttr, true);
    73     setIsInTopLayer(true);
     73    document()->addToTopLayer(this);
    7474}
    7575
Note: See TracChangeset for help on using the changeset viewer.