Changeset 125984 in webkit


Ignore:
Timestamp:
Aug 19, 2012 6:08:05 PM (12 years ago)
Author:
haraken@chromium.org
Message:

Remove RefPtr from SearchInputType::m_resultsButton and SearchInputType::m_cancelButton
https://bugs.webkit.org/show_bug.cgi?id=94339

Reviewed by Kent Tamura.

To avoid reference cycles of RefPtr<Node>s, we want to remove unnecessary
RefPtr<Node>s. The rationale is described in bug 94324.

SearchInputType::m_resultsButton and SearchInputType::m_cancelButton do not
need to be RefPtr<Node>s, because they are guaranteed to point to the shadow
DOM tree of the SearchInputType node, which is guaranteed to exist in the
subtree of the SearchInputType node.

No tests. No change in behavior.

  • html/SearchInputType.cpp:

(WebCore::SearchInputType::SearchInputType):
(WebCore::SearchInputType::createShadowSubtree):
(WebCore::SearchInputType::resultsButtonElement):
(WebCore::SearchInputType::cancelButtonElement):
(WebCore::SearchInputType::destroyShadowSubtree):
(WebCore::SearchInputType::subtreeHasChanged):

  • html/SearchInputType.h:

(SearchInputType):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r125983 r125984  
     12012-08-19  Kentaro Hara  <haraken@chromium.org>
     2
     3        Remove RefPtr from SearchInputType::m_resultsButton and SearchInputType::m_cancelButton
     4        https://bugs.webkit.org/show_bug.cgi?id=94339
     5
     6        Reviewed by Kent Tamura.
     7
     8        To avoid reference cycles of RefPtr<Node>s, we want to remove unnecessary
     9        RefPtr<Node>s. The rationale is described in bug 94324.
     10
     11        SearchInputType::m_resultsButton and SearchInputType::m_cancelButton do not
     12        need to be RefPtr<Node>s, because they are guaranteed to point to the shadow
     13        DOM tree of the SearchInputType node, which is guaranteed to exist in the
     14        subtree of the SearchInputType node.
     15
     16        No tests. No change in behavior.
     17
     18        * html/SearchInputType.cpp:
     19        (WebCore::SearchInputType::SearchInputType):
     20        (WebCore::SearchInputType::createShadowSubtree):
     21        (WebCore::SearchInputType::resultsButtonElement):
     22        (WebCore::SearchInputType::cancelButtonElement):
     23        (WebCore::SearchInputType::destroyShadowSubtree):
     24        (WebCore::SearchInputType::subtreeHasChanged):
     25        * html/SearchInputType.h:
     26        (SearchInputType):
     27
    1282012-08-19  Mike West  <mkwst@chromium.org>
    229
  • trunk/Source/WebCore/html/SearchInputType.cpp

    r120569 r125984  
    4646inline SearchInputType::SearchInputType(HTMLInputElement* element)
    4747    : BaseTextInputType(element)
     48    , m_resultsButton(0)
     49    , m_cancelButton(0)
    4850    , m_searchEventTimer(this, &SearchInputType::searchEventTimerFired)
    4951{
     
    98100
    99101    ExceptionCode ec = 0;
    100     m_resultsButton = SearchFieldResultsButtonElement::create(element()->document());
     102    RefPtr<SearchFieldResultsButtonElement> resultsButton = SearchFieldResultsButtonElement::create(element()->document());
     103    m_resultsButton = resultsButton.get();
    101104    container->insertBefore(m_resultsButton, textWrapper, ec);
    102105
    103     m_cancelButton = SearchFieldCancelButtonElement::create(element()->document());
     106    RefPtr<SearchFieldCancelButtonElement> cancelButton = SearchFieldCancelButtonElement::create(element()->document());
     107    m_cancelButton = cancelButton.get();
    104108    container->insertBefore(m_cancelButton, textWrapper->nextSibling(), ec);
    105109}
     
    107111HTMLElement* SearchInputType::resultsButtonElement() const
    108112{
    109     return m_resultsButton.get();
     113    return m_resultsButton;
    110114}
    111115
    112116HTMLElement* SearchInputType::cancelButtonElement() const
    113117{
    114     return m_cancelButton.get();
     118    return m_cancelButton;
    115119}
    116120
     
    136140{
    137141    TextFieldInputType::destroyShadowSubtree();
    138     m_resultsButton.clear();
    139     m_cancelButton.clear();
     142    m_resultsButton = 0;
     143    m_cancelButton = 0;
    140144}
    141145
     
    173177void SearchInputType::subtreeHasChanged()
    174178{
    175     if (m_cancelButton.get())
     179    if (m_cancelButton)
    176180        toRenderSearchField(element()->renderer())->updateCancelButtonVisibility();
    177181
  • trunk/Source/WebCore/html/SearchInputType.h

    r120569 r125984  
    6565    void startSearchEventTimer();
    6666
    67     RefPtr<HTMLElement> m_resultsButton;
    68     RefPtr<HTMLElement> m_cancelButton;
     67    HTMLElement* m_resultsButton;
     68    HTMLElement* m_cancelButton;
    6969    Timer<SearchInputType> m_searchEventTimer;
    7070};
Note: See TracChangeset for help on using the changeset viewer.