Move focus/blur handling code of HTMLInputElement to InputType
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jan 2012 23:56:30 +0000 (23:56 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jan 2012 23:56:30 +0000 (23:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76984

Reviewed by Dimitri Glazkov.

No new tests. Just a refactoring.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::handleFocusEvent):
Move the code to PasswordInputType::handleFocusEvent().
(WebCore::HTMLInputElement::handleBlurEvent):
Move the code to TextFieldInputType::handleBlurEvent() and
PasswordInputType::handleBlurEvent().
* html/InputType.cpp:
(WebCore::InputType::handleFocusEvent):
* html/InputType.h:
(InputType): Add handleFocusEvent().
* html/PasswordInputType.cpp:
(WebCore::PasswordInputType::handleFocusEvent):
Move the code for type=password from HTMLInputElement::handleFocusEvent().
(WebCore::PasswordInputType::handleBlurEvent):
Move the code for tyep=password from HTMLInputElement::handleBlurEvent().
* html/PasswordInputType.h:
(PasswordInputType): Add handleFocusEvent() and handleBlurEvent().
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleBlurEvent):
Move the code for text field types from HTMLInputElement::handleBlurEvent().
* html/TextFieldInputType.h:
(TextFieldInputType): Add handleBlurEvent().

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105937 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/PasswordInputType.cpp
Source/WebCore/html/PasswordInputType.h
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/TextFieldInputType.h

index 2687662..f54a6c5 100644 (file)
@@ -1,3 +1,35 @@
+2012-01-25  Kent Tamura  <tkent@chromium.org>
+
+        Move focus/blur handling code of HTMLInputElement to InputType
+        https://bugs.webkit.org/show_bug.cgi?id=76984
+
+        Reviewed by Dimitri Glazkov.
+
+        No new tests. Just a refactoring.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::handleFocusEvent):
+        Move the code to PasswordInputType::handleFocusEvent().
+        (WebCore::HTMLInputElement::handleBlurEvent):
+        Move the code to TextFieldInputType::handleBlurEvent() and
+        PasswordInputType::handleBlurEvent().
+        * html/InputType.cpp:
+        (WebCore::InputType::handleFocusEvent):
+        * html/InputType.h:
+        (InputType): Add handleFocusEvent().
+        * html/PasswordInputType.cpp:
+        (WebCore::PasswordInputType::handleFocusEvent):
+        Move the code for type=password from HTMLInputElement::handleFocusEvent().
+        (WebCore::PasswordInputType::handleBlurEvent):
+        Move the code for tyep=password from HTMLInputElement::handleBlurEvent().
+        * html/PasswordInputType.h:
+        (PasswordInputType): Add handleFocusEvent() and handleBlurEvent().
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::handleBlurEvent):
+        Move the code for text field types from HTMLInputElement::handleBlurEvent().
+        * html/TextFieldInputType.h:
+        (TextFieldInputType): Add handleBlurEvent().
+
 2012-01-25  Adam Barth  <abarth@webkit.org>
 
         Node.cpp shouldn't duplicate QualifiedName parsing logic
index ecde0b7..413c127 100644 (file)
@@ -472,23 +472,12 @@ bool HTMLInputElement::shouldUseInputMethod()
 
 void HTMLInputElement::handleFocusEvent()
 {
-    if (!isTextField())
-        return;
-    if (isPasswordField() && document()->frame())
-        document()->setUseSecureKeyboardEntryWhenActive(true);
+    m_inputType->handleFocusEvent();
 }
 
 void HTMLInputElement::handleBlurEvent()
 {
     m_inputType->handleBlurEvent();
-    if (!isTextField())
-        return;
-    Frame* frame = document()->frame();
-    if (!frame)
-        return;
-    if (isPasswordField())
-        document()->setUseSecureKeyboardEntryWhenActive(false);
-    frame->editor()->textFieldDidEndEditing(this);
 }
 
 void HTMLInputElement::setType(const String& type)
index 5102392..551f095 100644 (file)
@@ -436,6 +436,10 @@ bool InputType::shouldUseInputMethod() const
     return false;
 }
 
+void InputType::handleFocusEvent()
+{
+}
+
 void InputType::handleBlurEvent()
 {
 }
index c13fa08..93e600e 100644 (file)
@@ -183,6 +183,7 @@ public:
     virtual PassRefPtr<HTMLFormElement> formForSubmission() const;
     virtual bool isKeyboardFocusable() const;
     virtual bool shouldUseInputMethod() const;
+    virtual void handleFocusEvent();
     virtual void handleBlurEvent();
     virtual void accessKeyAction(bool sendMouseEvents);
     virtual bool canBeSuccessfulSubmitButton();
index 2a9ad02..c11d3c6 100644 (file)
@@ -32,6 +32,7 @@
 #include "config.h"
 #include "PasswordInputType.h"
 
+#include "HTMLInputElement.h"
 #include <wtf/Assertions.h>
 #include <wtf/PassOwnPtr.h>
 
@@ -86,4 +87,18 @@ bool PasswordInputType::isPasswordField() const
     return true;
 }
 
+void PasswordInputType::handleFocusEvent()
+{
+    BaseTextInputType::handleFocusEvent();
+    if (element()->document()->frame())
+        element()->document()->setUseSecureKeyboardEntryWhenActive(true);
+}
+
+void PasswordInputType::handleBlurEvent()
+{
+    if (element()->document()->frame())
+        element()->document()->setUseSecureKeyboardEntryWhenActive(false);
+    BaseTextInputType::handleBlurEvent();
+}
+
 } // namespace WebCore
index e9ca18e..10680ac 100644 (file)
@@ -49,6 +49,8 @@ private:
     virtual bool shouldRespectListAttribute() OVERRIDE;
     virtual bool shouldRespectSpeechAttribute() OVERRIDE;
     virtual bool isPasswordField() const OVERRIDE;
+    virtual void handleFocusEvent() OVERRIDE;
+    virtual void handleBlurEvent() OVERRIDE;
 };
 
 } // namespace WebCore
index 37e0b9f..3ec15bc 100644 (file)
@@ -161,6 +161,13 @@ void TextFieldInputType::forwardEvent(Event* event)
     }
 }
 
+void TextFieldInputType::handleBlurEvent()
+{
+    InputType::handleBlurEvent();
+    if (Frame* frame = element()->document()->frame())
+        frame->editor()->textFieldDidEndEditing(element());
+}
+
 bool TextFieldInputType::shouldSubmitImplicitly(Event* event)
 {
     return (event->type() == eventNames().textInputEvent && event->hasInterface(eventNames().interfaceForTextEvent) && static_cast<TextEvent*>(event)->data() == "\n") || InputType::shouldSubmitImplicitly(event);
index 161884d..f94018b 100644 (file)
@@ -63,6 +63,7 @@ protected:
     virtual void destroyShadowSubtree() OVERRIDE;
     virtual void disabledAttributeChanged() OVERRIDE;
     virtual void readonlyAttributeChanged() OVERRIDE;
+    virtual void handleBlurEvent() OVERRIDE;
 
 private:
     virtual bool isTextField() const OVERRIDE;