Pasting large amounts of plain text in a text area is very slow
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Nov 2010 00:14:52 +0000 (00:14 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Nov 2010 00:14:52 +0000 (00:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=49040
<rdar://problem/7640912>

Reviewed by Adele Peterson.

The optimization consists in skipping the ApplyStyle command when
pasting into a text area or into an element that has -webkit-user-modify: read-write-plaintext-only.
The biggest performance hit comes from iterating through
a large number of paragraph when no style change is needed.
A further step will be to improve the paragraph iteration when it
can't be avoided.

* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply): Check if the selection
is in a text form control or in an element that has -webkit-user-modify: read-write-plaintext-only
and force no style matching.

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

WebCore/ChangeLog
WebCore/editing/ReplaceSelectionCommand.cpp

index 535fd45..bb9b0f7 100644 (file)
@@ -1,3 +1,23 @@
+2010-11-04  Enrica Casucci  <enrica@apple.com>
+
+        Reviewed by Adele Peterson.
+
+        Pasting large amounts of plain text in a text area is very slow
+        https://bugs.webkit.org/show_bug.cgi?id=49040
+        <rdar://problem/7640912>
+        
+        The optimization consists in skipping the ApplyStyle command when
+        pasting into a text area or into an element that has -webkit-user-modify: read-write-plaintext-only.
+        The biggest performance hit comes from iterating through
+        a large number of paragraph when no style change is needed.
+        A further step will be to improve the paragraph iteration when it
+        can't be avoided.
+        
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::doApply): Check if the selection
+        is in a text form control or in an element that has -webkit-user-modify: read-write-plaintext-only
+        and force no style matching.
+
 2010-11-05  Ryosuke Niwa  <rniwa@webkit.org>
 
         Reviewed by David Levin.
index 53ab70f..c9f7aa7 100644 (file)
@@ -799,6 +799,11 @@ void ReplaceSelectionCommand::doApply()
     if (performTrivialReplace(fragment))
         return;
     
+    // We can skip matching the style if the selection is plain text.
+    if ((selection.start().node()->renderer() && selection.start().node()->renderer()->style()->userModify() == READ_WRITE_PLAINTEXT_ONLY) &&
+        (selection.end().node()->renderer() && selection.end().node()->renderer()->style()->userModify() == READ_WRITE_PLAINTEXT_ONLY))
+        m_matchStyle = false;
+    
     if (m_matchStyle)
         m_insertionStyle = ApplyStyleCommand::editingStyleAtPosition(selection.start(), IncludeTypingStyle);