Changeset 89910 in webkit


Ignore:
Timestamp:
Jun 28, 2011 2:20:58 AM (13 years ago)
Author:
tkent@chromium.org
Message:

2011-06-28 Kent Tamura <tkent@chromium.org>

Reviewed by Hajime Morita.

Use RefPtr for the HTMLElement data members of TextFieldInptType
and SearchInputType.
https://bugs.webkit.org/show_bug.cgi?id=63511

No new tests because of no behavior change.

  • html/SearchInputType.cpp: (WebCore::SearchInputType::SearchInputType): No need to initialize the element members explicitly because RefPtr constructor works well. (WebCore::SearchInputType::createShadowSubtree): Substitute an element to a data member, and don't call RefPtr<>::release(). (WebCore::SearchInputType::innerBlockElement): Moved from the header file, and adjustment for RefPtr<>. (WebCore::SearchInputType::resultsButtonElement): ditto. (WebCore::SearchInputType::cancelButtonElement): ditto. (WebCore::SearchInputType::destroyShadowSubtree): Adjustment for RefPtr<>.
  • html/SearchInputType.h:
    • Move accessor functions to the cpp file because they are virtual.
    • Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
  • html/TextFieldInputType.cpp: (WebCore::TextFieldInputType::TextFieldInputType): No need to initialize the element members explicitly because RefPtr constructor works well. (WebCore::TextFieldInputType::~TextFieldInputType): Explicityly defines the destructor in the cpp file to avoid to make it implicitly in the header file. If the destructor was made in the header file, we would need to include HTMLElement.h in the header file. (WebCore::TextFieldInputType::createShadowSubtree):
  • Don't call RenderTheme::themeForPage().
  • Substitute an element to a data member, and don't call RefPtr<>::release(). (WebCore::TextFieldInputType::setInnerTextElement): Moved from the header file to avoid to include HTMLElement.h. (WebCore::TextFieldInputType::setSpeechButtonElement): ditto. (WebCore::TextFieldInputType::innerTextElement): Moved from the header file, and adjustment for RefPtr<>. (WebCore::TextFieldInputType::innerSpinButtonElement): ditto. (WebCore::TextFieldInputType::speechButtonElement): ditto. (WebCore::TextFieldInputType::destroyShadowSubtree): Adjustment for RefPtr<>.
  • html/TextFieldInputType.h:
    • Move accessor functions to the cpp file because they are virtual.
    • Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89907 r89910  
     12011-06-28  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Hajime Morita.
     4
     5        Use RefPtr for the HTMLElement data members of TextFieldInptType
     6        and SearchInputType.
     7        https://bugs.webkit.org/show_bug.cgi?id=63511
     8
     9        No new tests because of no behavior change.
     10
     11        * html/SearchInputType.cpp:
     12        (WebCore::SearchInputType::SearchInputType):
     13        No need to initialize the element members explicitly because
     14        RefPtr constructor works well.
     15        (WebCore::SearchInputType::createShadowSubtree):
     16        Substitute an element to a data member, and don't call RefPtr<>::release().
     17        (WebCore::SearchInputType::innerBlockElement):
     18        Moved from the header file, and adjustment for RefPtr<>.
     19        (WebCore::SearchInputType::resultsButtonElement): ditto.
     20        (WebCore::SearchInputType::cancelButtonElement): ditto.
     21        (WebCore::SearchInputType::destroyShadowSubtree):
     22         Adjustment for RefPtr<>.
     23        * html/SearchInputType.h:
     24         - Move accessor functions to the cpp file because they are virtual.
     25         - Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
     26        * html/TextFieldInputType.cpp:
     27        (WebCore::TextFieldInputType::TextFieldInputType):
     28        No need to initialize the element members explicitly because
     29        RefPtr constructor works well.
     30        (WebCore::TextFieldInputType::~TextFieldInputType):
     31        Explicityly defines the destructor in the cpp file to avoid to
     32        make it implicitly in the header file. If the destructor was made
     33        in the header file, we would need to include HTMLElement.h in the
     34        header file.
     35        (WebCore::TextFieldInputType::createShadowSubtree):
     36        - Don't call RenderTheme::themeForPage().
     37        - Substitute an element to a data member, and don't call RefPtr<>::release().
     38        (WebCore::TextFieldInputType::setInnerTextElement):
     39         Moved from the header file to avoid to include HTMLElement.h.
     40        (WebCore::TextFieldInputType::setSpeechButtonElement): ditto.
     41        (WebCore::TextFieldInputType::innerTextElement):
     42        Moved from the header file, and adjustment for RefPtr<>.
     43        (WebCore::TextFieldInputType::innerSpinButtonElement): ditto.
     44        (WebCore::TextFieldInputType::speechButtonElement): ditto.
     45        (WebCore::TextFieldInputType::destroyShadowSubtree):
     46         Adjustment for RefPtr<>.
     47        * html/TextFieldInputType.h:
     48         - Move accessor functions to the cpp file because they are virtual.
     49         - Change element data member types: HTMLElement* -> RefPtr<HTMLElement>.
     50
    1512011-06-28  Felician Marton  <marton.felician.zoltan@stud.u-szeged.hu>
    252
  • trunk/Source/WebCore/html/SearchInputType.cpp

    r89460 r89910  
    4141inline SearchInputType::SearchInputType(HTMLInputElement* element)
    4242    : BaseTextInputType(element)
    43     , m_innerBlock(0)
    44     , m_resultsButton(0)
    45     , m_cancelButton(0)
    4643{
    4744}
     
    7067{
    7168    ASSERT(!m_innerBlock);
    72     ASSERT(!innerTextElement());
    7369    ASSERT(!m_resultsButton);
    7470    ASSERT(!m_cancelButton);
     
    7672    ExceptionCode ec = 0;
    7773    Document* document = element()->document();
    78     RefPtr<HTMLElement> inner = TextControlInnerElement::create(document);
    79     m_innerBlock = inner.get();
    80     element()->ensureShadowRoot()->appendChild(inner.release(), ec);
     74    m_innerBlock = TextControlInnerElement::create(document);
     75    element()->ensureShadowRoot()->appendChild(m_innerBlock, ec);
    8176
    8277#if ENABLE(INPUT_SPEECH)
    8378    if (element()->isSpeechEnabled()) {
    84         RefPtr<HTMLElement> speech = InputFieldSpeechButtonElement::create(document);
    85         setSpeechButtonElement(speech.get());
    86         element()->ensureShadowRoot()->appendChild(speech.release(), ec);
     79        setSpeechButtonElement(InputFieldSpeechButtonElement::create(document));
     80        element()->ensureShadowRoot()->appendChild(speechButtonElement(), ec);
    8781    }
    8882#endif
    8983
    90     RefPtr<HTMLElement> results = SearchFieldResultsButtonElement::create(document);
    91     m_resultsButton = results.get();
    92     m_innerBlock->appendChild(results.release(), ec);
     84    m_resultsButton = SearchFieldResultsButtonElement::create(document);
     85    m_innerBlock->appendChild(m_resultsButton, ec);
    9386
    94     RefPtr<HTMLElement> innerText = TextControlInnerTextElement::create(document);
    95     setInnerTextElement(innerText.get());
    96     m_innerBlock->appendChild(innerText.release(), ec);
     87    setInnerTextElement(TextControlInnerTextElement::create(document));
     88    m_innerBlock->appendChild(innerTextElement(), ec);
    9789
    98     RefPtr<HTMLElement> cancel = SearchFieldCancelButtonElement::create(element()->document());
    99     m_cancelButton = cancel.get();
    100     m_innerBlock->appendChild(cancel.release(), ec);
     90    m_cancelButton = SearchFieldCancelButtonElement::create(element()->document());
     91    m_innerBlock->appendChild(m_cancelButton, ec);
     92}
     93
     94HTMLElement* SearchInputType::innerBlockElement() const
     95{
     96    return m_innerBlock.get();
     97}
     98
     99HTMLElement* SearchInputType::resultsButtonElement() const
     100{
     101    return m_resultsButton.get();
     102}
     103
     104HTMLElement* SearchInputType::cancelButtonElement() const
     105{
     106    return m_cancelButton.get();
    101107}
    102108
     
    104110{
    105111    TextFieldInputType::destroyShadowSubtree();
    106     m_innerBlock = 0;
    107     m_resultsButton = 0;
    108     m_cancelButton = 0;
     112    m_innerBlock.clear();
     113    m_resultsButton.clear();
     114    m_cancelButton.clear();
    109115}
    110116
  • trunk/Source/WebCore/html/SearchInputType.h

    r89460 r89910  
    5252    virtual bool shouldRespectSpeechAttribute();
    5353    virtual bool isSearchField() const;
    54     virtual HTMLElement* innerBlockElement() const { return m_innerBlock; }
    55     virtual HTMLElement* resultsButtonElement() const { return m_resultsButton; }
    56     virtual HTMLElement* cancelButtonElement() const { return m_cancelButton; }
     54    virtual HTMLElement* innerBlockElement() const;
     55    virtual HTMLElement* resultsButtonElement() const;
     56    virtual HTMLElement* cancelButtonElement() const;
    5757
    58     HTMLElement* m_innerBlock;
    59     HTMLElement* m_resultsButton;
    60     HTMLElement* m_cancelButton;
     58    RefPtr<HTMLElement> m_innerBlock;
     59    RefPtr<HTMLElement> m_resultsButton;
     60    RefPtr<HTMLElement> m_cancelButton;
    6161};
    6262
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r89460 r89910  
    3737#include "HTMLInputElement.h"
    3838#include "KeyboardEvent.h"
     39#include "Page.h"
    3940#include "RenderTextControlSingleLine.h"
    4041#include "RenderTheme.h"
     
    5051TextFieldInputType::TextFieldInputType(HTMLInputElement* element)
    5152    : InputType(element)
    52     , m_innerText(0)
    53     , m_innerSpinButton(0)
    54 #if ENABLE(INPUT_SPEECH)
    55     , m_speechButton(0)
    56 #endif
     53{
     54}
     55
     56TextFieldInputType::~TextFieldInputType()
    5757{
    5858}
     
    135135    ASSERT(!m_innerSpinButton);
    136136
    137     bool shouldHaveSpinButton = RenderTheme::themeForPage(element()->document()->page())->shouldHaveSpinButton(element());
     137    Document* document = element()->document();
     138    RefPtr<RenderTheme> theme = document->page() ? document->page()->theme() : RenderTheme::defaultTheme();
     139    bool shouldHaveSpinButton = theme->shouldHaveSpinButton(element());
    138140    bool hasDecorations = shouldHaveSpinButton;
    139141#if ENABLE(INPUT_SPEECH)
     
    143145
    144146    ExceptionCode ec = 0;
    145     Document* document = element()->document();
    146     RefPtr<HTMLElement> innerText = TextControlInnerTextElement::create(document);
    147     m_innerText = innerText.get();
    148     element()->ensureShadowRoot()->appendChild(innerText.release(), ec);
     147    m_innerText = TextControlInnerTextElement::create(document);
     148    element()->ensureShadowRoot()->appendChild(m_innerText, ec);
    149149    if (!hasDecorations)
    150150        return;
     
    153153    ASSERT(!m_speechButton);
    154154    if (element()->isSpeechEnabled()) {
    155         RefPtr<HTMLElement> speech = InputFieldSpeechButtonElement::create(document);
    156         m_speechButton = speech.get();
    157         element()->ensureShadowRoot()->appendChild(speech.release(), ec);
     155        m_speechButton = InputFieldSpeechButtonElement::create(document);
     156        element()->ensureShadowRoot()->appendChild(m_speechButton, ec);
    158157    }
    159158#endif
    160159
    161160    if (shouldHaveSpinButton) {
    162         RefPtr<HTMLElement> inner = SpinButtonElement::create(document);
    163         m_innerSpinButton = inner.get();
    164         element()->ensureShadowRoot()->appendChild(inner.release(), ec);
    165     }
    166 }
     161        m_innerSpinButton = SpinButtonElement::create(document);
     162        element()->ensureShadowRoot()->appendChild(m_innerSpinButton, ec);
     163    }
     164}
     165
     166void TextFieldInputType::setInnerTextElement(PassRefPtr<HTMLElement> element)
     167{
     168    m_innerText = element;
     169}
     170
     171#if ENABLE(INPUT_SPEECH)
     172void TextFieldInputType::setSpeechButtonElement(PassRefPtr<HTMLElement> element)
     173{
     174    m_speechButton = element;
     175}
     176#endif
     177
     178HTMLElement* TextFieldInputType::innerTextElement() const
     179{
     180    ASSERT(m_innerText);
     181    return m_innerText.get();
     182}
     183
     184HTMLElement* TextFieldInputType::innerSpinButtonElement() const
     185{
     186    return m_innerSpinButton.get();
     187}
     188
     189#if ENABLE(INPUT_SPEECH)
     190HTMLElement* TextFieldInputType::speechButtonElement() const
     191{
     192    return m_speechButton.get();
     193}
     194#endif
    167195
    168196void TextFieldInputType::destroyShadowSubtree()
    169197{
    170198    InputType::destroyShadowSubtree();
    171     m_innerText = 0;
    172 #if ENABLE(INPUT_SPEECH)
    173     m_speechButton = 0;
    174 #endif
    175     m_innerSpinButton = 0;
     199    m_innerText.clear();
     200#if ENABLE(INPUT_SPEECH)
     201    m_speechButton.clear();
     202#endif
     203    m_innerSpinButton.clear();
    176204}
    177205
  • trunk/Source/WebCore/html/TextFieldInputType.h

    r89460 r89910  
    4141protected:
    4242    TextFieldInputType(HTMLInputElement*);
     43    virtual ~TextFieldInputType();
    4344    virtual bool canSetSuggestedValue();
    4445    virtual void handleKeydownEvent(KeyboardEvent*);
     
    4647    void handleWheelEventForSpinButton(WheelEvent*);
    4748
    48     virtual HTMLElement* innerTextElement() const { return m_innerText; }
    49     virtual HTMLElement* innerSpinButtonElement() const { return m_innerSpinButton; }
     49    virtual HTMLElement* innerTextElement() const;
     50    virtual HTMLElement* innerSpinButtonElement() const;
    5051#if ENABLE(INPUT_SPEECH)
    51     virtual HTMLElement* speechButtonElement() const { return m_speechButton; }
     52    virtual HTMLElement* speechButtonElement() const;
    5253#endif
    5354
     
    5556    virtual void createShadowSubtree();
    5657    virtual void destroyShadowSubtree();
    57     void setInnerTextElement(HTMLElement* element) { m_innerText = element; }
     58    void setInnerTextElement(PassRefPtr<HTMLElement>);
    5859#if ENABLE(INPUT_SPEECH)
    59     void setSpeechButtonElement(HTMLElement* element) { m_speechButton = element; }
     60    void setSpeechButtonElement(PassRefPtr<HTMLElement>);
    6061#endif
    6162
     
    7172    virtual bool shouldRespectListAttribute();
    7273
    73     HTMLElement* m_innerText;
    74     HTMLElement* m_innerSpinButton;
     74    RefPtr<HTMLElement> m_innerText;
     75    RefPtr<HTMLElement> m_innerSpinButton;
    7576#if ENABLE(INPUT_SPEECH)
    76     HTMLElement* m_speechButton;
     77    RefPtr<HTMLElement> m_speechButton;
    7778#endif
    7879};
Note: See TracChangeset for help on using the changeset viewer.