FrameSelection::textWasReplaced and setSelectedRange shouldn't trigger synchronous...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Feb 2014 22:35:14 +0000 (22:35 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Feb 2014 22:35:14 +0000 (22:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128951

Reviewed by Antti Koivisto.

Cleanup.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::textWasReplaced): Don't call updateLayout. It's totally unnecessarily.
(WebCore::FrameSelection::setSelectedRange): Ditto. Also removed the code to set affinity only when
range is collapsed since VisibleSelection::validate already does this.

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

Source/WebCore/ChangeLog
Source/WebCore/editing/FrameSelection.cpp

index 49855e58e8b955677cfbab8d85a3ab0ba583437d..327f13c13a8c65dc2428560383e5754e49959d0a 100644 (file)
@@ -1,3 +1,17 @@
+2014-02-18  Ryosuke Niwa  <rniwa@webkit.org>
+
+        FrameSelection::textWasReplaced and setSelectedRange shouldn't trigger synchronous layout
+        https://bugs.webkit.org/show_bug.cgi?id=128951
+
+        Reviewed by Antti Koivisto.
+
+        Cleanup.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::textWasReplaced): Don't call updateLayout. It's totally unnecessarily.
+        (WebCore::FrameSelection::setSelectedRange): Ditto. Also removed the code to set affinity only when
+        range is collapsed since VisibleSelection::validate already does this.
+
 2014-02-18  Eric Carlson  <eric.carlson@apple.com>
 
         Do not cache media time until media engine returns a non-zero value
index adc543ff8914036add6387da74f365d04232532b..4575a47058f1fa70e768ad0d51c572b15bc88a78 100644 (file)
@@ -515,7 +515,6 @@ void FrameSelection::textWasReplaced(CharacterData* node, unsigned offset, unsig
         else
             newSelection.setWithoutValidation(start, end);
 
-        m_frame->document()->updateLayout();
         setSelection(newSelection, DoNotSetFocus);
     }
 }
@@ -1700,25 +1699,15 @@ bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool clo
         return false;
     ASSERT(&range->startContainer()->document() == &range->endContainer()->document());
 
-    m_frame->document()->updateLayoutIgnorePendingStylesheets();
-
-    // Non-collapsed ranges are not allowed to start at the end of a line that is wrapped,
-    // they start at the beginning of the next line instead
-    ExceptionCode ec = 0;
-    bool collapsed = range->collapsed(ec);
-    if (ec)
-        return false;
+    VisibleSelection newSelection(range, affinity);
 
-    // FIXME: Can we provide extentAffinity?
-    VisiblePosition visibleStart(range->startPosition(), collapsed ? affinity : DOWNSTREAM);
-    VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY);
 #if PLATFORM(IOS)
-    if (range->startContainer() && visibleStart.isNull())
-        return false;
-    if (range->endContainer() && visibleEnd.isNull())
+    // FIXME: Why do we need this check only in iOS?
+    if (range->startContainer() && range->endContainer() && newSelection.isNull())
         return false;
 #endif
-    setSelection(VisibleSelection(visibleStart, visibleEnd), ClearTypingStyle | (closeTyping ? CloseTyping : 0));
+
+    setSelection(newSelection, ClearTypingStyle | (closeTyping ? CloseTyping : 0));
     return true;
 }