Title: [112109] trunk/Source/WebCore
- Revision
- 112109
- Author
- [email protected]
- Date
- 2012-03-26 09:19:02 -0700 (Mon, 26 Mar 2012)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (112108 => 112109)
--- trunk/Source/WebCore/ChangeLog 2012-03-26 16:16:32 UTC (rev 112108)
+++ trunk/Source/WebCore/ChangeLog 2012-03-26 16:19:02 UTC (rev 112109)
@@ -1,3 +1,28 @@
+2012-03-26 Kent Tamura <[email protected]>
+
+ 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):
+
2012-03-26 Dan Bernstein <[email protected]>
Tried to fix the 32-bit build after r112021.
Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp (112108 => 112109)
--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-03-26 16:16:32 UTC (rev 112108)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.cpp 2012-03-26 16:19:02 UTC (rev 112109)
@@ -38,6 +38,8 @@
namespace WebCore {
+using namespace HTMLNames;
+
// TextFieldDecorator ----------------------------------------------------------------
TextFieldDecorator::~TextFieldDecorator()
@@ -59,6 +61,13 @@
return adoptRef(new TextFieldDecorationElement(document, decorator));
}
+inline HTMLInputElement* TextFieldDecorationElement::hostInput()
+{
+ ASSERT(shadowAncestorNode());
+ ASSERT(shadowAncestorNode()->hasTagName(inputTag));
+ return static_cast<HTMLInputElement*>(shadowAncestorNode());
+}
+
bool TextFieldDecorationElement::isTextFieldDecoration() const
{
return true;
@@ -69,11 +78,10 @@
if (!renderer() || !renderer()->isImage())
return;
RenderImageResource* resource = toRenderImage(renderer())->imageResource();
- HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
CachedImage* image;
- if (input->disabled())
+ if (hostInput()->disabled())
image = m_textFieldDecorator->imageForDisabledState();
- else if (input->readOnly())
+ else if (hostInput()->readOnly())
image = m_textFieldDecorator->imageForReadonlyState();
else
image = m_textFieldDecorator->imageForNormalState();
@@ -84,7 +92,7 @@
PassRefPtr<RenderStyle> TextFieldDecorationElement::customStyleForRenderer()
{
RefPtr<RenderStyle> style = RenderStyle::create();
- RenderStyle* inputStyle = shadowAncestorNode()->renderStyle();
+ RenderStyle* inputStyle = hostInput()->renderStyle();
ASSERT(inputStyle);
style->setWidth(Length(inputStyle->fontSize(), Fixed));
style->setHeight(Length(inputStyle->fontSize(), Fixed));
@@ -105,6 +113,12 @@
updateImage();
}
+void TextFieldDecorationElement::detach()
+{
+ m_textFieldDecorator->willDetach(hostInput());
+ HTMLDivElement::detach();
+}
+
bool TextFieldDecorationElement::isMouseFocusable() const
{
return false;
@@ -112,7 +126,7 @@
void TextFieldDecorationElement::defaultEventHandler(Event* event)
{
- RefPtr<HTMLInputElement> input(static_cast<HTMLInputElement*>(shadowAncestorNode()));
+ RefPtr<HTMLInputElement> input(hostInput());
if (input->disabled() || input->readOnly() || !event->isMouseEvent()) {
if (!event->defaultHandled())
HTMLDivElement::defaultEventHandler(event);
Modified: trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h (112108 => 112109)
--- trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h 2012-03-26 16:16:32 UTC (rev 112108)
+++ trunk/Source/WebCore/html/shadow/TextFieldDecorationElement.h 2012-03-26 16:19:02 UTC (rev 112109)
@@ -52,6 +52,7 @@
virtual CachedImage* imageForReadonlyState() = 0;
virtual void handleClick(HTMLInputElement*) = 0;
+ virtual void willDetach(HTMLInputElement*) = 0;
virtual ~TextFieldDecorator();
};
@@ -69,9 +70,11 @@
virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;
virtual void attach() OVERRIDE;
+ virtual void detach() OVERRIDE;
virtual bool isMouseFocusable() const OVERRIDE;
virtual void defaultEventHandler(Event*) OVERRIDE;
+ HTMLInputElement* hostInput();
void updateImage();
TextFieldDecorator* m_textFieldDecorator;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes