[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
enrica at apple.com
enrica at apple.com
Thu Feb 4 21:31:44 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 815fc503373de915e761cbfe9b2caf7106b9c065
Author: enrica at apple.com <enrica at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jan 29 02:10:55 2010 +0000
Huge plain text pastes are slow
<rdar://problem/5195056>
https://bugs.webkit.org/show_bug.cgi?id=34237
Reviewed by Maciej Stachowiak.
WebCore:
No new tests. It is a performance improvement.
The performance of the plain text paste is now linear.
We treat as a special case, a fragment that has been
created from plain text. Finding VisiblePositions and
applying style is greatly simplified, given the nature of
the fragment.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply):
* editing/markup.cpp:
(WebCore::isPlainTextMarkup):
* editing/markup.h:
WebKit/mac:
Mail is ignoring the fragment created from plain text or HTML that is
passed to the delegate function, that creates a new one.
This fix avoids creating the fragment twice.
* WebView/WebHTMLView.mm:
(-[WebHTMLView _pasteWithPasteboard:allowPlainText:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b5d6a27..4151743 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-28 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Maciej Stachowiak.
+
+ Huge plain text pastes are slow
+ <rdar://problem/5195056>
+ https://bugs.webkit.org/show_bug.cgi?id=34237
+
+ No new tests. It is a performance improvement.
+
+ The performance of the plain text paste is now linear.
+ We treat as a special case, a fragment that has been
+ created from plain text. Finding VisiblePositions and
+ applying style is greatly simplified, given the nature of
+ the fragment.
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::doApply):
+ * editing/markup.cpp:
+ (WebCore::isPlainTextMarkup):
+ * editing/markup.h:
+
2010-01-28 Jeremy Orlow <jorlow at chromium.org>
Reviewed by Adam Barth.
diff --git a/WebCore/editing/ReplaceSelectionCommand.cpp b/WebCore/editing/ReplaceSelectionCommand.cpp
index b40dab2..85a4471 100644
--- a/WebCore/editing/ReplaceSelectionCommand.cpp
+++ b/WebCore/editing/ReplaceSelectionCommand.cpp
@@ -877,6 +877,8 @@ void ReplaceSelectionCommand::doApply()
if (!refNode->inDocument())
return;
+ bool plainTextFragment = isPlainTextMarkup(refNode.get());
+
while (node) {
Node* next = node->nextSibling();
fragment.removeNode(node);
@@ -887,6 +889,8 @@ void ReplaceSelectionCommand::doApply()
return;
refNode = node;
+ if (node && plainTextFragment)
+ plainTextFragment = isPlainTextMarkup(node.get());
node = next;
}
@@ -913,7 +917,7 @@ void ReplaceSelectionCommand::doApply()
bool interchangeNewlineAtEnd = fragment.hasInterchangeNewlineAtEnd();
- if (shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR))
+ if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR)))
removeNodeAndPruneAncestors(endBR);
// Determine whether or not we should merge the end of inserted content with what's after it before we do
@@ -1020,6 +1024,11 @@ void ReplaceSelectionCommand::doApply()
}
}
+ // If we are dealing with a fragment created from plain text
+ // no style matching is necessary.
+ if (plainTextFragment)
+ m_matchStyle = false;
+
completeHTMLReplacement(lastPositionToSelect);
}
diff --git a/WebCore/editing/markup.cpp b/WebCore/editing/markup.cpp
index 8986cd0..dc6cbc2 100644
--- a/WebCore/editing/markup.cpp
+++ b/WebCore/editing/markup.cpp
@@ -1133,6 +1133,17 @@ static void fillContainerFromString(ContainerNode* paragraph, const String& stri
}
}
+bool isPlainTextMarkup(Node *node)
+{
+ if (!node->isElementNode() || !node->hasTagName(divTag) || static_cast<Element*>(node)->attributes()->length())
+ return false;
+
+ if (node->childNodeCount() == 1 && (node->firstChild()->isTextNode() || (node->firstChild()->firstChild())))
+ return true;
+
+ return (node->childNodeCount() == 2 && isTabSpanTextNode(node->firstChild()->firstChild()) && node->firstChild()->nextSibling()->isTextNode());
+}
+
PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text)
{
if (!context)
diff --git a/WebCore/editing/markup.h b/WebCore/editing/markup.h
index 61dc3dc..5ace04a 100644
--- a/WebCore/editing/markup.h
+++ b/WebCore/editing/markup.h
@@ -45,6 +45,8 @@ namespace WebCore {
PassRefPtr<DocumentFragment> createFragmentFromMarkup(Document*, const String& markup, const String& baseURL, FragmentScriptingPermission = FragmentScriptingAllowed);
PassRefPtr<DocumentFragment> createFragmentFromNodes(Document*, const Vector<Node*>&);
+ bool isPlainTextMarkup(Node *node);
+
String createMarkup(const Range*,
Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false);
String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0);
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 16da703..8b638a0 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,18 @@
+2010-01-28 Enrica Casucci <enrica at apple.com>
+
+ Reviewed by Maciej Stachowiak.
+
+ Huge plain text pastes are slow
+ <rdar://problem/5195056>
+ https://bugs.webkit.org/show_bug.cgi?id=34237
+
+ Mail is ignoring the fragment created from plain text or HTML that is
+ passed to the delegate function, that creates a new one.
+ This fix avoids creating the fragment twice.
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _pasteWithPasteboard:allowPlainText:]):
+
2010-01-25 Anders Carlsson <andersca at apple.com>
Featureless build fixes.
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index 2a20acd..54a177e 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -103,6 +103,7 @@
#import <WebCore/Page.h>
#import <WebCore/PlatformKeyboardEvent.h>
#import <WebCore/Range.h>
+#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/SelectionController.h>
#import <WebCore/SharedBuffer.h>
#import <WebCore/SimpleFontData.h>
@@ -796,10 +797,26 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
[webView _setInsertionPasteboard:pasteboard];
DOMRange *range = [self _selectedRange];
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard inContext:range allowPlainText:allowPlainText];
if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionPasted])
[[self _frame] _replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
-
+#else
+ // Mail is ignoring the frament passed to the delegate and creates a new one.
+ // We want to avoid creating the fragment twice.
+ if (applicationIsAppleMail()) {
+ if ([self _shouldInsertFragment:nil replacingDOMRange:range givenAction:WebViewInsertActionPasted]) {
+ DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard inContext:range allowPlainText:allowPlainText];
+ if (fragment)
+ [[self _frame] _replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
+ }
+ } else {
+ DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard inContext:range allowPlainText:allowPlainText];
+ if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionPasted])
+ [[self _frame] _replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
+ }
+#endif
[webView _setInsertionPasteboard:nil];
[webView release];
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list