Can't type in status in facebook.com on iOS Safari because keyboard disappears
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2014 04:06:05 +0000 (04:06 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2014 04:06:05 +0000 (04:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133196

Reviewed by Geoffrey Garen.

Source/WebCore:
Fixed the bug by rolling out r156252.

When the user taps on the status on facebook.com, the page focuses a textarea,
which is then made momentarily invisible by setting display:none.
The page then removes display:none later and expects the textarea to be still focused.

With r156252, the focus is removed after the page sets display:none and the keyboard disappears.
Since the focus is never reset on the textarea, the user can never type in anything.

The specification may need to change here given that this (rather odd) behavior/expectation exists
on one of the most popular websites on the Web.

* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::recalcStyle):
(WebCore::Document::updateLayout):
(WebCore::Document::resetHiddenFocusElementSoon): Deleted.
(WebCore::Document::resetHiddenFocusElementTimer): Deleted.
* dom/Document.h:

LayoutTests:
Removed the test added by r156252.

* fast/dom/HTMLDocument/active-element-gets-unfocusable-expected.txt: Removed.
* fast/dom/HTMLDocument/active-element-gets-unfocusable.html: Removed.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLDocument/active-element-gets-unfocusable-expected.txt [deleted file]
LayoutTests/fast/dom/HTMLDocument/active-element-gets-unfocusable.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h

index 537e985d8358e14478c9cc8f466783230469983d..80e07417dc18e7516a0a9a0404b263c473d4ada6 100644 (file)
@@ -1,3 +1,15 @@
+2014-05-22  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Can't type in status in facebook.com on iOS Safari because keyboard disappears
+        https://bugs.webkit.org/show_bug.cgi?id=133196
+
+        Reviewed by Geoffrey Garen.
+
+        Removed the test added by r156252.
+
+        * fast/dom/HTMLDocument/active-element-gets-unfocusable-expected.txt: Removed.
+        * fast/dom/HTMLDocument/active-element-gets-unfocusable.html: Removed.
+
 2014-05-22  Myles C. Maxfield  <mmaxfield@apple.com>
 
         http/tests/security/xss-DENIED-xsl-document-redirect.xml fails with NetworkProcess
diff --git a/LayoutTests/fast/dom/HTMLDocument/active-element-gets-unfocusable-expected.txt b/LayoutTests/fast/dom/HTMLDocument/active-element-gets-unfocusable-expected.txt
deleted file mode 100644 (file)
index 4e180bf..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Making a focused element invisible should make it blur.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-===> Setting display:none
-Event: blur
-PASS document.activeElement is document.body
-PASS The focusTarget element lost focus.
-
-===> Setting visibility:hidden
-Event: blur
-PASS document.activeElement is document.body
-PASS The focusTarget element lost focus.
-
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/dom/HTMLDocument/active-element-gets-unfocusable.html b/LayoutTests/fast/dom/HTMLDocument/active-element-gets-unfocusable.html
deleted file mode 100644 (file)
index 8c14df0..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE html>
-<body>
-<script src="../../../resources/js-test-pre.js"></script>
-
-<div id="f1">
-  <div tabindex="1" id="div1"></div>
-</div>
-
-<script type="text/javascript">
-description('Making a focused element invisible should make it blur.');
-jsTestIsAsync = true;
-var focusTarget = document.getElementById('div1');
-var testStage = 0;
-var testTimeout = 0;
-
-document.body.onload = function() {
-    focusTarget.focus();
-
-    shouldBe('document.activeElement', 'focusTarget', true);
-    debug('===> Setting display:none');
-    setTimeout("f1.style.display = 'none'",0);
-
-    testTimeout = setTimeout(function() {
-        testFailed('Timeout: Didn\'t loose focus.');
-        finishJSTest();
-    }, 1000);
-};
-
-focusTarget.addEventListener('blur', function() {
-    debug('Event: blur');
-    shouldBe('document.activeElement', 'document.body');
-    testPassed('The focusTarget element lost focus.');
-
-    debug('');
-    if (testStage++ == 0) {
-        f1.style.display = 'block';
-        focusTarget.focus();
-        shouldBe('document.activeElement', 'focusTarget', true);
-        debug('===> Setting visibility:hidden');
-        setTimeout("f1.style.visibility = 'hidden'",0);
-    } else {
-        clearTimeout(testTimeout);
-        finishJSTest();
-    }
-}, false);
-
-</script>
-<script src="../../../resources/js-test-post.js"></script>
-</body>
index 908abd10c0b02e17e162263be3f80f8748419dfb..389e4b433d8868760f1793a1a5d3350d91fa24c7 100644 (file)
@@ -1,3 +1,30 @@
+2014-05-22  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Can't type in status in facebook.com on iOS Safari because keyboard disappears
+        https://bugs.webkit.org/show_bug.cgi?id=133196
+
+        Reviewed by Geoffrey Garen.
+
+        Fixed the bug by rolling out r156252.
+
+        When the user taps on the status on facebook.com, the page focuses a textarea,
+        which is then made momentarily invisible by setting display:none.
+        The page then removes display:none later and expects the textarea to be still focused.
+
+        With r156252, the focus is removed after the page sets display:none and the keyboard disappears.
+        Since the focus is never reset on the textarea, the user can never type in anything.
+
+        The specification may need to change here given that this (rather odd) behavior/expectation exists
+        on one of the most popular websites on the Web.
+
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::recalcStyle):
+        (WebCore::Document::updateLayout):
+        (WebCore::Document::resetHiddenFocusElementSoon): Deleted.
+        (WebCore::Document::resetHiddenFocusElementTimer): Deleted.
+        * dom/Document.h:
+
 2014-05-22  Myles C. Maxfield  <mmaxfield@apple.com>
 
         http/tests/security/xss-DENIED-xsl-document-redirect.xml fails with NetworkProcess
index 1ddbbbd8a4ac4d8e802f05efcae261825fdd47ca..c7ae5fe01fff4be7c542524ee1c9985e66d39e36 100644 (file)
@@ -442,7 +442,6 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     , m_titleSetExplicitly(false)
     , m_markers(std::make_unique<DocumentMarkerController>())
     , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired)
-    , m_resetHiddenFocusElementTimer(this, &Document::resetHiddenFocusElementTimer)
     , m_cssTarget(nullptr)
     , m_processingLoadEvent(false)
     , m_loadEventFinished(false)
@@ -1774,9 +1773,6 @@ void Document::recalcStyle(Style::Change change)
     // to check if any other elements ended up under the mouse pointer due to re-layout.
     if (m_hoveredElement && !m_hoveredElement->renderer())
         frameView.frame().mainFrame().eventHandler().dispatchFakeMouseMoveEventSoon();
-
-    // Style change may reset the focus, e.g. display: none, visibility: hidden.
-    resetHiddenFocusElementSoon();
 }
 
 void Document::updateStyleIfNeeded()
@@ -1820,9 +1816,6 @@ void Document::updateLayout()
     // Only do a layout if changes have occurred that make it necessary.      
     if (frameView && renderView() && (frameView->layoutPending() || renderView()->needsLayout()))
         frameView->layout();
-
-    // Active focus element's isFocusable() state may change after Layout. e.g. width: 0px or height: 0px.
-    resetHiddenFocusElementSoon();
 }
 
 // FIXME: This is a bad idea and needs to be removed eventually.
@@ -4729,12 +4722,6 @@ void Document::cancelFocusAppearanceUpdate()
     m_updateFocusAppearanceTimer.stop();
 }
 
-void Document::resetHiddenFocusElementSoon()
-{
-    if (!m_resetHiddenFocusElementTimer.isActive() && m_focusedElement)
-        m_resetHiddenFocusElementTimer.startOneShot(0);
-}
-
 void Document::updateFocusAppearanceTimerFired(Timer<Document>&)
 {
     Element* element = focusedElement();
@@ -4746,15 +4733,6 @@ void Document::updateFocusAppearanceTimerFired(Timer<Document>&)
         element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
 }
 
-void Document::resetHiddenFocusElementTimer(Timer<Document>&)
-{
-    if (view() && view()->needsLayout())
-        return;
-
-    if (m_focusedElement && !m_focusedElement->isFocusable())
-        setFocusedElement(nullptr);
-}
-
 void Document::attachRange(Range* range)
 {
     ASSERT(!m_ranges.contains(range));
index afc2aa9de31c3494df85d1a6ae62d13f4c0bfe8d..b07b501b5419694e99c4bafa0099d5c8ae66676f 100644 (file)
@@ -993,8 +993,6 @@ public:
     void updateFocusAppearanceSoon(bool restorePreviousSelection);
     void cancelFocusAppearanceUpdate();
 
-    void resetHiddenFocusElementSoon();
-
     // Extension for manipulating canvas drawing contexts for use in CSS
     CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
     HTMLCanvasElement* getCSSCanvasElement(const String& name);
@@ -1321,8 +1319,6 @@ private:
     void updateFocusAppearanceTimerFired(Timer<Document>&);
     void updateBaseURL();
 
-    void resetHiddenFocusElementTimer(Timer<Document>&);
-
     void buildAccessKeyMap(TreeScope* root);
 
     void createStyleResolver();
@@ -1468,7 +1464,6 @@ private:
     const std::unique_ptr<DocumentMarkerController> m_markers;
     
     Timer<Document> m_updateFocusAppearanceTimer;
-    Timer<Document> m_resetHiddenFocusElementTimer;
 
     Element* m_cssTarget;