Changeset 112109 in webkit


Ignore:
Timestamp:
Mar 26, 2012 9:19:02 AM (12 years ago)
Author:
tkent@chromium.org
Message:

Add a notification function for detaching to TextFieldDecorator
https://bugs.webkit.org/show_bug.cgi?id=82142

Reviewed by Dimitri Glazkov.

Add willDetach() functio to TextFieldDecorator. This will be
needed if a decorator opens a popup UI on handleClick(), and the
popup UI should be closed when the attaching text field is
detached.

No new tests because of no behavior changes in any platforms.

  • html/shadow/TextFieldDecorationElement.cpp:

(WebCore::TextFieldDecorationElement::hostInput):
Added. A utilify function to get an HTMLInputElement*.
(WebCore::TextFieldDecorationElement::updateImage): Use hostInput().
(WebCore::TextFieldDecorationElement::customStyleForRenderer): ditto.
(WebCore::TextFieldDecorationElement::detach): Added. Calls TextFieldDecorator::willDetach().
(WebCore::TextFieldDecorationElement::defaultEventHandler): Use hostInput().

  • html/shadow/TextFieldDecorationElement.h:

(TextFieldDecorator):
(TextFieldDecorationElement):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112108 r112109  
     12012-03-26  Kent Tamura  <tkent@chromium.org>
     2
     3        Add a notification function for detaching to TextFieldDecorator
     4        https://bugs.webkit.org/show_bug.cgi?id=82142
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Add willDetach() functio to TextFieldDecorator. This will be
     9        needed if a decorator opens a popup UI on handleClick(), and the
     10        popup UI should be closed when the attaching text field is
     11        detached.
     12
     13        No new tests because of no behavior changes in any platforms.
     14
     15        * html/shadow/TextFieldDecorationElement.cpp:
     16        (WebCore::TextFieldDecorationElement::hostInput):
     17        Added. A utilify function to get an HTMLInputElement*.
     18        (WebCore::TextFieldDecorationElement::updateImage): Use hostInput().
     19        (WebCore::TextFieldDecorationElement::customStyleForRenderer): ditto.
     20        (WebCore::TextFieldDecorationElement::detach): Added. Calls TextFieldDecorator::willDetach().
     21        (WebCore::TextFieldDecorationElement::defaultEventHandler): Use hostInput().
     22        * html/shadow/TextFieldDecorationElement.h:
     23        (TextFieldDecorator):
     24        (TextFieldDecorationElement):
     25
    1262012-03-26  Dan Bernstein  <mitz@apple.com>
    227
  • trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp

    r112016 r112109  
    3939namespace WebCore {
    4040
     41using namespace HTMLNames;
     42
    4143// TextFieldDecorator ----------------------------------------------------------------
    4244
     
    6062}
    6163
     64inline HTMLInputElement* TextFieldDecorationElement::hostInput()
     65{
     66    ASSERT(shadowAncestorNode());
     67    ASSERT(shadowAncestorNode()->hasTagName(inputTag));
     68    return static_cast<HTMLInputElement*>(shadowAncestorNode());
     69}
     70
    6271bool TextFieldDecorationElement::isTextFieldDecoration() const
    6372{
     
    7079        return;
    7180    RenderImageResource* resource = toRenderImage(renderer())->imageResource();
    72     HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
    7381    CachedImage* image;
    74     if (input->disabled())
     82    if (hostInput()->disabled())
    7583        image = m_textFieldDecorator->imageForDisabledState();
    76     else if (input->readOnly())
     84    else if (hostInput()->readOnly())
    7785        image = m_textFieldDecorator->imageForReadonlyState();
    7886    else
     
    8593{
    8694    RefPtr<RenderStyle> style = RenderStyle::create();
    87     RenderStyle* inputStyle = shadowAncestorNode()->renderStyle();
     95    RenderStyle* inputStyle = hostInput()->renderStyle();
    8896    ASSERT(inputStyle);
    8997    style->setWidth(Length(inputStyle->fontSize(), Fixed));
     
    106114}
    107115
     116void TextFieldDecorationElement::detach()
     117{
     118    m_textFieldDecorator->willDetach(hostInput());
     119    HTMLDivElement::detach();
     120}
     121
    108122bool TextFieldDecorationElement::isMouseFocusable() const
    109123{
     
    113127void TextFieldDecorationElement::defaultEventHandler(Event* event)
    114128{
    115     RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode()));
     129    RefPtr<HTMLInputElement> input(hostInput());
    116130    if (input->disabled() || input->readOnly() || !event->isMouseEvent()) {
    117131        if (!event->defaultHandled())
  • trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h

    r111930 r112109  
    5353
    5454    virtual void handleClick(HTMLInputElement*) = 0;
     55    virtual void willDetach(HTMLInputElement*) = 0;
    5556
    5657    virtual ~TextFieldDecorator();
     
    7071    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;
    7172    virtual void attach() OVERRIDE;
     73    virtual void detach() OVERRIDE;
    7274    virtual bool isMouseFocusable() const OVERRIDE;
    7375    virtual void defaultEventHandler(Event*) OVERRIDE;
    7476
     77    HTMLInputElement* hostInput();
    7578    void updateImage();
    7679
Note: See TracChangeset for help on using the changeset viewer.