[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8

simon.fraser at apple.com simon.fraser at apple.com
Wed Feb 10 22:16:59 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 21f050dd4df9f983e401068fee6976e413d96f2f
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 5 19:50:24 2010 +0000

    2010-02-05  Simon Fraser  <simon.fraser at apple.com>
    
            Reviewed by Dan Bernstein.
    
            Changing display type of parent of input on focus causes input field to not receive key events
            https://bugs.webkit.org/show_bug.cgi?id=34620
            <rdar://problem/7584572>
    
            When layout affects a text input, the RenderTextControl gets destroyed and
            recreated, which in turn makes a new innerTextElement. However, if the text field was
            focused, the VisibleSelection is left pointing to the old innerTextElement, so text
            input no longer works.
    
            The fix is to call updateFocusAppearanceSoon() when attaching the input element,
            which will update the selection if necessary.
    
            Test: fast/forms/restore-selection-after-layout.html
    
            * dom/Document.h: Add a paramter to updateFocusAppearanceSoon() and a member variable,
            m_updateFocusAppearanceRestoresSelection, to store its value until the timer fires.
            * dom/Document.cpp:
            (WebCore::Document::Document): Initialize m_updateFocusAppearanceRestoresSelection
            (WebCore::Document::updateFocusAppearanceSoon): New restorePreviousSelection parameter.
            (WebCore::Document::updateFocusAppearanceTimerFired): Pass m_updateFocusAppearanceRestoresSelection down.
            * dom/Element.cpp:
            (WebCore::Element::attach): Call updateFocusAppearanceSoon() with false.
            * dom/Element.h: The updateFocusAppearanceSoonAfterAttach() was undefined.
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::attach): Call document()->updateFocusAppearanceSoon() with true.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54438 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6d99c3f..825cba5 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-02-05  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Changing display type of parent of input on focus causes input field to not receive key events
+        https://bugs.webkit.org/show_bug.cgi?id=34620
+        <rdar://problem/7584572>
+        
+        Testcase that tests input into a text field after changing layout.
+
+        * fast/forms/restore-selection-after-layout-expected.txt: Added.
+        * fast/forms/restore-selection-after-layout.html: Added.
+
 2010-02-05  Csaba Osztrogonác  <ossy at webkit.org>
 
         Reviewed by Dirk Schulze.
diff --git a/LayoutTests/fast/forms/restore-selection-after-layout-expected.txt b/LayoutTests/fast/forms/restore-selection-after-layout-expected.txt
new file mode 100644
index 0000000..a80e8df
--- /dev/null
+++ b/LayoutTests/fast/forms/restore-selection-after-layout-expected.txt
@@ -0,0 +1,4 @@
+This test only works in DRT. You should see 'beforeafter' in the text field.
+
+ 
+beforeafter
diff --git a/LayoutTests/fast/forms/restore-selection-after-layout.html b/LayoutTests/fast/forms/restore-selection-after-layout.html
new file mode 100644
index 0000000..c0028e9
--- /dev/null
+++ b/LayoutTests/fast/forms/restore-selection-after-layout.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+
+    function sendKey(element, key) {
+        if (window.layoutTestController) {
+            key = key.substr(0,1).toLowerCase() + key.substr(1); // lowercase 1st letter for eventSender
+            eventSender.keyDown(key);
+        } else {
+            // Note that initKeyboardEvent is broken:
+            // https://bugs.webkit.org/show_bug.cgi?id=16735
+            var event = document.createEvent("KeyboardEvents");
+            event.initKeyboardEvent("keydown", true, true, document.defaultView, key, 0,
+                                    false, false, false, false, false);
+            element.dispatchEvent(event);
+        }
+    }
+
+    function changeStyle()
+    {
+      var testInput = document.getElementById('input');
+      testInput.focus();
+
+      sendKey(testInput, 'b');
+      sendKey(testInput, 'e');
+      sendKey(testInput, 'f');
+      sendKey(testInput, 'o');
+      sendKey(testInput, 'r');
+      sendKey(testInput, 'e');
+
+      // make a layout happen
+      var containerDiv = document.getElementById('container')
+      containerDiv.style.display = 'inline';
+      
+      window.setTimeout(function() {
+        sendKey(testInput, 'a');
+        sendKey(testInput, 'f');
+        sendKey(testInput, 't');
+        sendKey(testInput, 'e');
+        sendKey(testInput, 'r');
+
+        document.getElementById('result').innerText = testInput.value;
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+      }, 0);
+    }
+    
+    window.addEventListener('load', changeStyle, false);
+  </script>
+</head>
+<body>
+  <p>This test only works in DRT. You should see 'beforeafter' in the text field.</p>
+  <div id="container">
+    <input id="input" type="text" value="">
+  </div>
+
+  <div id="result"></div>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b1f45b9..846c2f1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-02-05  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Changing display type of parent of input on focus causes input field to not receive key events
+        https://bugs.webkit.org/show_bug.cgi?id=34620
+        <rdar://problem/7584572>
+        
+        When layout affects a text input, the RenderTextControl gets destroyed and
+        recreated, which in turn makes a new innerTextElement. However, if the text field was
+        focused, the VisibleSelection is left pointing to the old innerTextElement, so text
+        input no longer works.
+        
+        The fix is to call updateFocusAppearanceSoon() when attaching the input element,
+        which will update the selection if necessary.
+
+        Test: fast/forms/restore-selection-after-layout.html
+
+        * dom/Document.h: Add a paramter to updateFocusAppearanceSoon() and a member variable,
+        m_updateFocusAppearanceRestoresSelection, to store its value until the timer fires.
+        * dom/Document.cpp:
+        (WebCore::Document::Document): Initialize m_updateFocusAppearanceRestoresSelection
+        (WebCore::Document::updateFocusAppearanceSoon): New restorePreviousSelection parameter.
+        (WebCore::Document::updateFocusAppearanceTimerFired): Pass m_updateFocusAppearanceRestoresSelection down.
+        * dom/Element.cpp:
+        (WebCore::Element::attach): Call updateFocusAppearanceSoon() with false.
+        * dom/Element.h: The updateFocusAppearanceSoonAfterAttach() was undefined.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::attach): Call document()->updateFocusAppearanceSoon() with true.
+
 2010-02-05  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 2c76ca5..6cf8665 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -355,6 +355,7 @@ Document::Document(Frame* frame, bool isXHTML, bool isHTML)
     , m_styleRecalcTimer(this, &Document::styleRecalcTimerFired)
     , m_frameElementsShouldIgnoreScrolling(false)
     , m_containsValidityStyleRules(false)
+    , m_updateFocusAppearanceRestoresSelection(false)
     , m_title("")
     , m_rawTitle("")
     , m_titleSetExplicitly(false)
@@ -4497,8 +4498,9 @@ void Document::updateSandboxFlags()
         securityOrigin()->setSandboxFlags(m_frame->loader()->sandboxFlags());
 }
 
-void Document::updateFocusAppearanceSoon()
+void Document::updateFocusAppearanceSoon(bool restorePreviousSelection)
 {
+    m_updateFocusAppearanceRestoresSelection = restorePreviousSelection;
     if (!m_updateFocusAppearanceTimer.isActive())
         m_updateFocusAppearanceTimer.startOneShot(0);
 }
@@ -4520,7 +4522,7 @@ void Document::updateFocusAppearanceTimerFired(Timer<Document>*)
 
     Element* element = static_cast<Element*>(node);
     if (element->isFocusable())
-        element->updateFocusAppearance(false);
+        element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
 }
 
 void Document::executeScriptSoonTimerFired(Timer<Document>* timer)
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 4798e05..9038f22 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -830,7 +830,7 @@ public:
     void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; }
     bool hasNodeListCaches() const { return m_numNodeListCaches; }
 
-    void updateFocusAppearanceSoon();
+    void updateFocusAppearanceSoon(bool restorePreviousSelection);
     void cancelFocusAppearanceUpdate();
         
     // FF method for accessing the selection added for compatibility.
@@ -1079,6 +1079,7 @@ private:
     bool m_haveExplicitlyDisabledDNSPrefetch;
     bool m_frameElementsShouldIgnoreScrolling;
     bool m_containsValidityStyleRules;
+    bool m_updateFocusAppearanceRestoresSelection;
 
     String m_title;
     String m_rawTitle;
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index cc8f9ef..0a1bc75 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -785,7 +785,7 @@ void Element::attach()
         ElementRareData* data = rareData();
         if (data->needsFocusAppearanceUpdateSoonAfterAttach()) {
             if (isFocusable() && document()->focusedNode() == this)
-                document()->updateFocusAppearanceSoon();
+                document()->updateFocusAppearanceSoon(false /* don't restore selection */);
             data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
         }
     }
diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h
index 15032d7..a5c4e96 100644
--- a/WebCore/dom/Element.h
+++ b/WebCore/dom/Element.h
@@ -304,7 +304,6 @@ private:
     virtual void updateAnimatedSVGAttribute(const QualifiedName&) const { }
 #endif
 
-    void updateFocusAppearanceSoonAfterAttach();
     void cancelFocusAppearanceUpdate();
 
     virtual const AtomicString& virtualPrefix() const { return prefix(); }
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index ef2d627..1cdea12 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -1139,6 +1139,9 @@ void HTMLInputElement::attach()
                 imageObj->setImageSizeForAltText();
         }
     }
+
+    if (document()->focusedNode() == this)
+        document()->updateFocusAppearanceSoon(true /* restore selection */);
 }
 
 void HTMLInputElement::detach()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list