REGRESSION(r180867): Tabbing to login field on iCloud.com doesn't have highlight...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jun 2015 00:57:30 +0000 (00:57 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jun 2015 00:57:30 +0000 (00:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145830

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by setSelection not updating RenderView when there is a style recalc scheduled
that doesn't trigger a layout. Fixed the bug by explicitly updating the selection in
Document::recalcStyle in that case.

Test: editing/selection/update-selection-by-style-change.html

* dom/Document.cpp:
(WebCore::Document::recalcStyle):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::updateAppearanceAfterLayout): Renamed from didLayout.
* editing/FrameSelection.h:
* page/FrameView.cpp:
(WebCore::FrameView::performPostLayoutTasks):

LayoutTests:

Added a regression test.

* editing/selection/update-selection-by-style-change-expected.html: Added.
* editing/selection/update-selection-by-style-change.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/selection/update-selection-by-style-change-expected.html [new file with mode: 0644]
LayoutTests/editing/selection/update-selection-by-style-change.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/FrameSelection.h
Source/WebCore/page/FrameView.cpp

index 27b035c..27e8fdf 100644 (file)
@@ -1,3 +1,15 @@
+2015-06-09  Ryosuke Niwa  <rniwa@webkit.org>
+
+        REGRESSION(r180867): Tabbing to login field on iCloud.com doesn't have highlight for text
+        https://bugs.webkit.org/show_bug.cgi?id=145830
+
+        Reviewed by Darin Adler.
+
+        Added a regression test.
+
+        * editing/selection/update-selection-by-style-change-expected.html: Added.
+        * editing/selection/update-selection-by-style-change.html: Added.
+
 2015-06-09  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         SVG Fragment is not rendered if it is the css background image of an HTML element
diff --git a/LayoutTests/editing/selection/update-selection-by-style-change-expected.html b/LayoutTests/editing/selection/update-selection-by-style-change-expected.html
new file mode 100644 (file)
index 0000000..7dc57c6
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>\r
+<html>\r
+<body>\r
+<p>This tests modifying selection after triggering a style change. Selection should be updated immediately.\r
+You should see the "hello" selected below as "world" turns red.</p>\r
+<input type="text" value="hello" autofocus/>\r
+<input type="text" value="world" style="color: red" />\r
+<style> * {outline: none} </style>\r
+<script>\r
+document.querySelector('input').select();\r
+</script>\r
+</body>\r
+</html>\r
diff --git a/LayoutTests/editing/selection/update-selection-by-style-change.html b/LayoutTests/editing/selection/update-selection-by-style-change.html
new file mode 100644 (file)
index 0000000..83bc273
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>\r
+<html>\r
+<body>\r
+<p>This tests modifying selection after triggering a style change. Selection should be updated immediately.\r
+You should see the "hello" selected below as "world" turns red.</p>\r
+<input type="text" value="hello"/>\r
+<input type="text" value="world"/>\r
+<style> * {outline: none} </style>\r
+<script>\r
+\r
+if (window.testRunner)\r
+    testRunner.waitUntilDone();\r
+\r
+var inputs = document.querySelectorAll('input');\r
+inputs[0].focus();\r
+inputs[0].setSelectionRange(0, 0);\r
+setTimeout(function () {\r
+    inputs[1].style.color = 'red';\r
+    inputs[0].select();\r
+\r
+    if (window.testRunner)\r
+        testRunner.notifyDone();\r
+}, 50);\r
+\r
+</script>\r
+</body>\r
+</html>\r
index 4274d52..452736a 100644 (file)
@@ -1,3 +1,24 @@
+2015-06-09  Ryosuke Niwa  <rniwa@webkit.org>
+
+        REGRESSION(r180867): Tabbing to login field on iCloud.com doesn't have highlight for text
+        https://bugs.webkit.org/show_bug.cgi?id=145830
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by setSelection not updating RenderView when there is a style recalc scheduled
+        that doesn't trigger a layout. Fixed the bug by explicitly updating the selection in
+        Document::recalcStyle in that case.
+
+        Test: editing/selection/update-selection-by-style-change.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::recalcStyle):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::updateAppearanceAfterLayout): Renamed from didLayout.
+        * editing/FrameSelection.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::performPostLayoutTasks):
+
 2015-06-09  Dean Jackson  <dino@apple.com>
 
         MediaControls: Reenable resize of controls on pinch zoom
index 349f2a3..ba817bf 100644 (file)
@@ -1811,6 +1811,9 @@ void Document::recalcStyle(Style::Change change)
     if (updatedCompositingLayers && !frameView.needsLayout())
         frameView.viewportContentsChanged();
 
+    if (!frameView.needsLayout())
+        frameView.frame().selection().updateAppearanceAfterLayout();
+
     // As a result of the style recalculation, the currently hovered element might have been
     // detached (for example, by setting display:none in the :hover style), schedule another mouseMove event
     // to check if any other elements ended up under the mouse pointer due to re-layout.
index 02264d5..9ee00f2 100644 (file)
@@ -2222,7 +2222,7 @@ void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor)
     updateAppearance();
 }
 
-void FrameSelection::didLayout()
+void FrameSelection::updateAppearanceAfterLayout()
 {
     setCaretRectNeedsUpdate();
     updateAndRevealSelection(AXTextStateChangeIntent());
index db7d667..7783b6a 100644 (file)
@@ -151,7 +151,7 @@ public:
     WEBCORE_EXPORT void clear();
     void prepareForDestruction();
 
-    void didLayout();
+    void updateAppearanceAfterLayout();
     void setNeedsSelectionUpdate();
 
     bool contains(const LayoutPoint&);
index 081304b..32afa44 100644 (file)
@@ -2983,7 +2983,7 @@ void FrameView::performPostLayoutTasks()
 
     m_postLayoutTasksTimer.stop();
 
-    frame().selection().didLayout();
+    frame().selection().updateAppearanceAfterLayout();
 
     if (m_nestedLayoutCount <= 1 && frame().document()->documentElement())
         fireLayoutRelatedMilestonesIfNeeded();