Reviewed by Oliver Hunt.
<rdar://problem/
5195056> Huge plain text pastes are slow, time spent in ApplyStyleCommand::doApply
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply): No need to match style when pasting
into a plaintext-only region, since when we build the fragment to insert from
plain text, we don't put any style information on it, so it will automatically
match style with no intervention.
* editing/markup.cpp:
(WebCore::createFragmentFromText): Place paragraphs into clones of the
block being inserted into, instead of default paragraph elements,
so that when inserted content will match the surrounding paragraph style.
This was broken before, but I haven't added a layout test yet because
there currently isn't a way to get only plain text onto the pasteboard
in a layout test.
WebKit:
Reviewed by Oliver Hunt.
<rdar://problem/
5195056> Huge plain text pastes are slow, time spent in ApplyStyleCommand::doApply
No need to match style when pasting plain text, since the fragment we build for plain text
won't have any style information on it.
* WebView/WebHTMLView.mm:
(-[WebHTMLView _documentFragmentFromPasteboard:inContext:allowPlainText:]): There's no
longer a need to know whether this function chosePlaintext.
(-[WebHTMLView _pasteWithPasteboard:allowPlainText:]):
(-[WebHTMLView _documentFragmentFromPasteboard:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27369
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-11-01 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ <rdar://problem/5195056> Huge plain text pastes are slow, time spent in ApplyStyleCommand::doApply
+
+ * editing/ReplaceSelectionCommand.cpp:
+ (WebCore::ReplaceSelectionCommand::doApply): No need to match style when pasting
+ into a plaintext-only region, since when we build the fragment to insert from
+ plain text, we don't put any style information on it, so it will automatically
+ match style with no intervention.
+ * editing/markup.cpp:
+ (WebCore::createFragmentFromText): Place paragraphs into clones of the
+ block being inserted into, instead of default paragraph elements,
+ so that when inserted content will match the surrounding paragraph style.
+ This was broken before, but I haven't added a layout test yet because
+ there currently isn't a way to get only plain text onto the pasteboard
+ in a layout test.
+
2007-11-01 Sam Weinig <sam@webkit.org>
Reviewed by Adam Roben.
return;
bool selectionIsPlainText = !selection.isContentRichlyEditable();
- if (selectionIsPlainText)
- m_matchStyle = true;
Element* currentRoot = selection.rootEditableElement();
ReplacementFragment fragment(document(), m_documentFragment.get(), m_matchStyle, selection);
{
if (!context)
return 0;
+
+ Node* block = enclosingBlock(context->startNode());
Node* styleNode = context->startNode();
if (!styleNode) {
ASSERT(ec == 0);
element->setAttribute(classAttr, AppleInterchangeNewline);
} else {
- element = createDefaultParagraphElement(document);
+ element = static_cast<Element *>(block->cloneNode(false).get());
fillContainerFromString(element.get(), s);
}
fragment->appendChild(element.release(), ec);
+2007-11-01 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ <rdar://problem/5195056> Huge plain text pastes are slow, time spent in ApplyStyleCommand::doApply
+
+ No need to match style when pasting plain text, since the fragment we build for plain text
+ won't have any style information on it.
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _documentFragmentFromPasteboard:inContext:allowPlainText:]): There's no
+ longer a need to know whether this function chosePlaintext.
+ (-[WebHTMLView _pasteWithPasteboard:allowPlainText:]):
+ (-[WebHTMLView _documentFragmentFromPasteboard:]):
+
2007-10-31 Timothy Hatcher <timothy@apple.com>
Reviewed by John Sullivan.
@interface WebHTMLView (WebHTMLViewFileInternal)
- (BOOL)_imageExistsAtPaths:(NSArray *)paths;
-- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard inContext:(DOMRange *)context allowPlainText:(BOOL)allowPlainText chosePlainText:(BOOL *)chosePlainText;
+- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard inContext:(DOMRange *)context allowPlainText:(BOOL)allowPlainText;
- (NSString *)_plainTextFromPasteboard:(NSPasteboard *)pasteboard;
- (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText;
- (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard;
- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard
inContext:(DOMRange *)context
allowPlainText:(BOOL)allowPlainText
- chosePlainText:(BOOL *)chosePlainText
{
NSArray *types = [pasteboard types];
- *chosePlainText = NO;
DOMDocumentFragment *fragment = nil;
if ([types containsObject:WebArchivePboardType] &&
forType:NSStringPboardType
inContext:context
subresources:0])) {
- *chosePlainText = YES;
return fragment;
}
- (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText
{
DOMRange *range = [self _selectedRange];
- BOOL chosePlainText;
DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard
- inContext:range allowPlainText:allowPlainText chosePlainText:&chosePlainText];
+ inContext:range allowPlainText:allowPlainText];
WebFrameBridge *bridge = [self _bridge];
if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:[self _selectedRange] givenAction:WebViewInsertActionPasted]) {
- [bridge replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:chosePlainText];
+ [bridge replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
}
}
- (DOMDocumentFragment*)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard
{
- BOOL discard;
- return [self _documentFragmentFromPasteboard:pasteboard inContext:nil allowPlainText:NO chosePlainText:&discard];
+ return [self _documentFragmentFromPasteboard:pasteboard inContext:nil allowPlainText:NO];
}
#ifndef BUILDING_ON_TIGER