Title: [128148] trunk
Revision
128148
Author
[email protected]
Date
2012-09-10 22:29:55 -0700 (Mon, 10 Sep 2012)

Log Message

REGRESSION (r127226): Calling DateTimeEditElement::layout() in focus handler should not dispatch blur event
https://bugs.webkit.org/show_bug.cgi?id=96232

Reviewed by Kent Tamura.

Source/WebCore:

This patch makes DateTimeEditElement::layout() not to dispatch blur
event by removing existing fields, one of them can be focused, after
moving focus to newly created field.

This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.

Test: fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html

* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::build): Changed to call resetFields().
(WebCore::DateTimeEditElement::focusedFieldIndex): Changed to use
Document::focusedNode(). When this function is called during handling
focus event, Element::focused() isn't true.
(WebCore::DateTimeEditElement::layout): Changed to remove existing
child nodes after moving focus to newly created field.
(WebCore::DateTimeEditElement::resetFields): Renamed from resetLayout().
This function makes m_fields vector empty.
(WebCore::DateTimeEditElement::resetLayout): Renamed to resetFields().
We moved removing field elements and spin button to layout().
* html/shadow/DateTimeEditElement.h:
(DateTimeEditElement): Renamed resetLayout() to resetFields().

LayoutTests:

This patch adds a new test for checking layout changing of multiple
fields time input UI in focus handler doesn't dispatch blur event.

This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.

* fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (128147 => 128148)


--- trunk/LayoutTests/ChangeLog	2012-09-11 05:17:56 UTC (rev 128147)
+++ trunk/LayoutTests/ChangeLog	2012-09-11 05:29:55 UTC (rev 128148)
@@ -1,3 +1,19 @@
+2012-09-10  Yoshifumi Inoue  <[email protected]>
+
+        REGRESSION (r127226): Calling DateTimeEditElement::layout() in focus handler should not dispatch blur event
+        https://bugs.webkit.org/show_bug.cgi?id=96232
+
+        Reviewed by Kent Tamura.
+
+        This patch adds a new test for checking layout changing of multiple
+        fields time input UI in focus handler doesn't dispatch blur event.
+
+        This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
+        ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.
+
+        * fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur-expected.txt: Added.
+        * fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html: Added.
+
 2012-09-10  Joanmarie Diggs  <[email protected]>
 
         Properly expose <legend> elements to ATs

Added: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur-expected.txt (0 => 128148)


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur-expected.txt	2012-09-11 05:29:55 UTC (rev 128148)
@@ -0,0 +1,14 @@
+Check focus handler not dispatch blur event
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+call focus()
+Entering focus event handler
+Existing focus event handler
+focus() finished
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html (0 => 128148)


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html	2012-09-11 05:29:55 UTC (rev 128148)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('Check focus handler not dispatch blur event');
+testInput = document.createElement('input');
+document.body.appendChild(testInput);
+testInput.type = 'time';
+
+testInput.addEventListener(
+    'blur',
+    function()
+    {
+        debug('Entering blur event handler');
+        testInput.setAttribute('y', 'y');
+        debug('Existing blur event handler');
+    },
+    false);
+
+testInput.addEventListener(
+    'focus',
+    function()
+    {
+        debug('Entering focus event handler');
+        testInput.setAttribute('x', 'x');
+        debug('Existing focus event handler');
+    },
+    false);
+
+debug('call focus()');
+testInput.focus();
+debug('focus() finished');
+debug('');
+
+testInput.parentNode.removeChild(testInput);
+</script>
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (128147 => 128148)


--- trunk/Source/WebCore/ChangeLog	2012-09-11 05:17:56 UTC (rev 128147)
+++ trunk/Source/WebCore/ChangeLog	2012-09-11 05:29:55 UTC (rev 128148)
@@ -1,3 +1,33 @@
+2012-09-10  Yoshifumi Inoue  <[email protected]>
+
+        REGRESSION (r127226): Calling DateTimeEditElement::layout() in focus handler should not dispatch blur event
+        https://bugs.webkit.org/show_bug.cgi?id=96232
+
+        Reviewed by Kent Tamura.
+
+        This patch makes DateTimeEditElement::layout() not to dispatch blur
+        event by removing existing fields, one of them can be focused, after
+        moving focus to newly created field.
+
+        This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
+        ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.
+
+        Test: fast/forms/time-multiple-fields/time-multiple-fields-state-change-on-focus-or-blur.html
+
+        * html/shadow/DateTimeEditElement.cpp:
+        (WebCore::DateTimeEditBuilder::build): Changed to call resetFields().
+        (WebCore::DateTimeEditElement::focusedFieldIndex): Changed to use
+        Document::focusedNode(). When this function is called during handling
+        focus event, Element::focused() isn't true.
+        (WebCore::DateTimeEditElement::layout): Changed to remove existing
+        child nodes after moving focus to newly created field.
+        (WebCore::DateTimeEditElement::resetFields): Renamed from resetLayout().
+        This function makes m_fields vector empty.
+        (WebCore::DateTimeEditElement::resetLayout): Renamed to resetFields().
+        We moved removing field elements and spin button to layout().
+        * html/shadow/DateTimeEditElement.h:
+        (DateTimeEditElement): Renamed resetLayout() to resetFields().
+
 2012-09-10  Keishi Hattori  <[email protected]>
 
         Rename NumberLocalizer to Localizer

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp (128147 => 128148)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-09-11 05:17:56 UTC (rev 128147)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-09-11 05:29:55 UTC (rev 128148)
@@ -80,7 +80,7 @@
 
 bool DateTimeEditBuilder::build(const String& formatString)
 {
-    m_editElement.resetLayout();
+    m_editElement.resetFields();
     return DateTimeFormat::parse(formatString, *this);
 }
 
@@ -282,8 +282,9 @@
 
 size_t DateTimeEditElement::focusedFieldIndex() const
 {
+    Node* const focusedFieldNode = document()->focusedNode();
     for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) {
-        if (m_fields[fieldIndex]->focused())
+        if (m_fields[fieldIndex] == focusedFieldNode)
             return fieldIndex;
     }
     return invalidFieldIndex;
@@ -343,13 +344,12 @@
 
     DateTimeEditBuilder builder(*this, stepRange, dateValue);
     const String dateTimeFormat = builder.needSecondField() ? localizedTimeFormatText() : localizedShortTimeFormatText();
-    if (!builder.build(dateTimeFormat) || m_fields.isEmpty())
+    Node* lastChildToBeRemoved = lastChild();
+    if (!builder.build(dateTimeFormat) || m_fields.isEmpty()) {
+        lastChildToBeRemoved = lastChild();
         builder.build(builder.needSecondField() ? "HH:mm:ss" : "HH:mm");
+    }
 
-    RefPtr<SpinButtonElement> spinButton = SpinButtonElement::create(document(), *this);
-    m_spinButton = spinButton.get();
-    appendChild(spinButton);
-
     if (focusedFieldIndex != invalidFieldIndex) {
         for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) {
             if (m_fields[fieldIndex]->shadowPseudoId() == focusedFieldId) {
@@ -360,6 +360,18 @@
         if (DateTimeFieldElement* field = fieldAt(std::min(focusedFieldIndex, m_fields.size() - 1)))
             field->focus();
     }
+
+    if (lastChildToBeRemoved) {
+        for (Node* childNode = firstChild(); childNode; childNode = firstChild()) {
+            removeChild(childNode);
+            if (childNode == lastChildToBeRemoved)
+                break;
+        }
+    }
+
+    RefPtr<SpinButtonElement> spinButton = SpinButtonElement::create(document(), *this);
+    m_spinButton = spinButton.get();
+    appendChild(spinButton);
 }
 
 void DateTimeEditElement::readOnlyStateChanged()
@@ -367,11 +379,9 @@
     updateUIState();
 }
 
-void DateTimeEditElement::resetLayout()
+void DateTimeEditElement::resetFields()
 {
     m_fields.shrink(0);
-    m_spinButton = 0;
-    removeChildren();
 }
 
 void DateTimeEditElement::defaultEventHandler(Event* event)

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.h (128147 => 128148)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.h	2012-09-11 05:17:56 UTC (rev 128147)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.h	2012-09-11 05:29:55 UTC (rev 128148)
@@ -68,7 +68,7 @@
     void focusByOwner();
     void readOnlyStateChanged();
     void removeEditControlOwner() { m_editControlOwner = 0; }
-    void resetLayout();
+    void resetFields();
     void setEmptyValue(const StepRange&, const DateComponents&  dateForReadOnlyField);
     void setValueAsDate(const StepRange&, const DateComponents&);
     double valueAsDouble() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to