Avoid synchronous style recalc when mutating a Node inside FrameSelection.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 16:22:40 +0000 (16:22 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 16:22:40 +0000 (16:22 +0000)
<https://webkit.org/b/138791>

Reviewed by Antti Koivisto.

Source/WebCore:

We can safely clear the RenderView's selection without doing a synchronous
style recalc first.

This is a small progression on Speedometer locally.

* editing/FrameSelection.cpp:
(WebCore::DragCaretController::nodeWillBeRemoved):
(WebCore::FrameSelection::respondToNodeModification):
(WebCore::clearRenderViewSelection): Deleted.

    Merged clearRenderViewSelection() into the call sites and removed
    the now-unnecessary protection of the Document.

LayoutTests:

Rebaseline fast/dynamic/move-node-with-selection.html.
This is a progression, we avoid littering the render tree with some empty
text renderers due to deferring the style recalc in selection clearing.

* platform/efl/fast/dynamic/move-node-with-selection-expected.txt:
* platform/gtk/fast/dynamic/move-node-with-selection-expected.txt:
* platform/ios-sim-deprecated/fast/dynamic/move-node-with-selection-expected.txt:
* platform/ios-simulator/fast/dynamic/move-node-with-selection-expected.txt:
* platform/mac/fast/dynamic/move-node-with-selection-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/platform/efl/fast/dynamic/move-node-with-selection-expected.txt
LayoutTests/platform/gtk/fast/dynamic/move-node-with-selection-expected.txt
LayoutTests/platform/ios-sim-deprecated/fast/dynamic/move-node-with-selection-expected.txt
LayoutTests/platform/ios-simulator/fast/dynamic/move-node-with-selection-expected.txt
LayoutTests/platform/mac/fast/dynamic/move-node-with-selection-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/editing/FrameSelection.cpp

index 86fed5e..190c78d 100644 (file)
@@ -1,3 +1,20 @@
+2014-11-16  Andreas Kling  <akling@apple.com>
+
+        Avoid synchronous style recalc when mutating a Node inside FrameSelection.
+        <https://webkit.org/b/138791>
+
+        Reviewed by Antti Koivisto.
+
+        Rebaseline fast/dynamic/move-node-with-selection.html.
+        This is a progression, we avoid littering the render tree with some empty
+        text renderers due to deferring the style recalc in selection clearing.
+
+        * platform/efl/fast/dynamic/move-node-with-selection-expected.txt:
+        * platform/gtk/fast/dynamic/move-node-with-selection-expected.txt:
+        * platform/ios-sim-deprecated/fast/dynamic/move-node-with-selection-expected.txt:
+        * platform/ios-simulator/fast/dynamic/move-node-with-selection-expected.txt:
+        * platform/mac/fast/dynamic/move-node-with-selection-expected.txt:
+
 2014-11-17  Tibor Meszaros  <tmeszaros.u-szeged@partner.samsung.com>
 
         [EFL] Skip timeouting editing tests
index d199981..34e4bf7 100644 (file)
@@ -7,7 +7,4 @@ layer at (0,0) size 800x600
         RenderInline {DIV} at (0,0) size 84x17
           RenderText {#text} at (0,0) size 84x17
             text run at (0,0) width 84: "Lorem ipsum"
-      RenderBlock (anonymous) at (0,18) size 784x0
-        RenderText {#text} at (0,0) size 0x0
-        RenderText {#text} at (0,0) size 0x0
 caret: position 2 of body
index e10991b..29a0182 100644 (file)
@@ -7,7 +7,4 @@ layer at (0,0) size 800x600
         RenderInline {DIV} at (0,0) size 84x17
           RenderText {#text} at (0,0) size 84x17
             text run at (0,0) width 84: "Lorem ipsum"
-      RenderBlock (anonymous) at (0,17) size 784x0
-        RenderText {#text} at (0,0) size 0x0
-        RenderText {#text} at (0,0) size 0x0
 caret: position 2 of body
index e1447d4..39fd193 100644 (file)
@@ -7,7 +7,4 @@ layer at (0,0) size 800x600
         RenderInline {DIV} at (0,0) size 86x19
           RenderText {#text} at (0,0) size 86x19
             text run at (0,0) width 86: "Lorem ipsum"
-      RenderBlock (anonymous) at (0,20) size 784x0
-        RenderText {#text} at (0,0) size 0x0
-        RenderText {#text} at (0,0) size 0x0
 caret: position 2 of body
index e1447d4..39fd193 100644 (file)
@@ -7,7 +7,4 @@ layer at (0,0) size 800x600
         RenderInline {DIV} at (0,0) size 86x19
           RenderText {#text} at (0,0) size 86x19
             text run at (0,0) width 86: "Lorem ipsum"
-      RenderBlock (anonymous) at (0,20) size 784x0
-        RenderText {#text} at (0,0) size 0x0
-        RenderText {#text} at (0,0) size 0x0
 caret: position 2 of body
index 497d6c8..4c429e4 100644 (file)
@@ -7,7 +7,4 @@ layer at (0,0) size 800x600
         RenderInline {DIV} at (0,0) size 84x18
           RenderText {#text} at (0,0) size 84x18
             text run at (0,0) width 84: "Lorem ipsum"
-      RenderBlock (anonymous) at (0,18) size 784x0
-        RenderText {#text} at (0,0) size 0x0
-        RenderText {#text} at (0,0) size 0x0
 caret: position 2 of body
index 3bf0675..14ee2cc 100644 (file)
@@ -1,3 +1,23 @@
+2014-11-16  Andreas Kling  <akling@apple.com>
+
+        Avoid synchronous style recalc when mutating a Node inside FrameSelection.
+        <https://webkit.org/b/138791>
+
+        Reviewed by Antti Koivisto.
+
+        We can safely clear the RenderView's selection without doing a synchronous
+        style recalc first.
+
+        This is a small progression on Speedometer locally.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::DragCaretController::nodeWillBeRemoved):
+        (WebCore::FrameSelection::respondToNodeModification):
+        (WebCore::clearRenderViewSelection): Deleted.
+
+            Merged clearRenderViewSelection() into the call sites and removed
+            the now-unnecessary protection of the Document.
+
 2014-11-17  Eric Carlson  <eric.carlson@apple.com>
 
         [iOS] allow host application to opt-out of alternate fullscreen
index 8df98db..46b2de4 100644 (file)
@@ -404,14 +404,6 @@ static bool removingNodeRemovesPosition(Node& node, const Position& position)
     return downcast<Element>(node).containsIncludingShadowDOM(position.anchorNode());
 }
 
-static void clearRenderViewSelection(Node& node)
-{
-    Ref<Document> document(node.document());
-    document->updateStyleIfNeeded();
-    if (RenderView* view = document->renderView())
-        view->clearSelection();
-}
-
 void DragCaretController::nodeWillBeRemoved(Node& node)
 {
     if (!hasCaret() || !node.inDocument())
@@ -420,7 +412,9 @@ void DragCaretController::nodeWillBeRemoved(Node& node)
     if (!removingNodeRemovesPosition(node, m_position.deepEquivalent()))
         return;
 
-    clearRenderViewSelection(node);
+    if (RenderView* view = node.document().renderView())
+        view->clearSelection();
+
     clear();
 }
 
@@ -479,10 +473,10 @@ void FrameSelection::respondToNodeModification(Node& node, bool baseRemoved, boo
     }
 
     if (clearRenderTreeSelection) {
-        clearRenderViewSelection(node);
-
-        // Trigger a selection update so the selection will be set again.
         if (auto* renderView = node.document().renderView()) {
+            renderView->clearSelection();
+
+            // Trigger a selection update so the selection will be set again.
             m_pendingSelectionUpdate = true;
             renderView->setNeedsLayout();
         }