Changeset 27369 in webkit


Ignore:
Timestamp:
Nov 1, 2007, 3:58:47 PM (18 years ago)
Author:
justing
Message:

WebCore:

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:]):
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r27367 r27369  
     12007-11-01  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        <rdar://problem/5195056> Huge plain text pastes are slow, time spent in ApplyStyleCommand::doApply
     6
     7        * editing/ReplaceSelectionCommand.cpp:
     8        (WebCore::ReplaceSelectionCommand::doApply): No need to match style when pasting
     9        into a plaintext-only region, since when we build the fragment to insert from
     10        plain text, we don't put any style information on it, so it will automatically
     11        match style with no intervention.
     12        * editing/markup.cpp:
     13        (WebCore::createFragmentFromText): Place paragraphs into clones of the
     14        block being inserted into, instead of default paragraph elements,
     15        so that when inserted content will match the surrounding paragraph style.
     16        This was broken before, but I haven't added a layout test yet because
     17        there currently isn't a way to get only plain text onto the pasteboard
     18        in a layout test.
     19
    1202007-11-01  Sam Weinig  <sam@webkit.org>
    221
  • trunk/WebCore/editing/ReplaceSelectionCommand.cpp

    r27280 r27369  
    518518   
    519519    bool selectionIsPlainText = !selection.isContentRichlyEditable();
    520     if (selectionIsPlainText)
    521         m_matchStyle = true;
    522520   
    523521    Element* currentRoot = selection.rootEditableElement();
  • trunk/WebCore/editing/markup.cpp

    r27293 r27369  
    972972    if (!context)
    973973        return 0;
     974       
     975    Node* block = enclosingBlock(context->startNode());
    974976
    975977    Node* styleNode = context->startNode();
     
    10251027            element->setAttribute(classAttr, AppleInterchangeNewline);           
    10261028        } else {
    1027             element = createDefaultParagraphElement(document);
     1029            element = static_cast<Element *>(block->cloneNode(false).get());
    10281030            fillContainerFromString(element.get(), s);
    10291031        }
  • trunk/WebKit/ChangeLog

    r27332 r27369  
     12007-11-01  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4       
     5        <rdar://problem/5195056> Huge plain text pastes are slow, time spent in ApplyStyleCommand::doApply
     6       
     7        No need to match style when pasting plain text, since the fragment we build for plain text
     8        won't have any style information on it.
     9
     10        * WebView/WebHTMLView.mm:
     11        (-[WebHTMLView _documentFragmentFromPasteboard:inContext:allowPlainText:]): There's no
     12        longer a need to know whether this function chosePlaintext.
     13        (-[WebHTMLView _pasteWithPasteboard:allowPlainText:]):
     14        (-[WebHTMLView _documentFragmentFromPasteboard:]):
     15
    1162007-10-31  Timothy Hatcher  <timothy@apple.com>
    217
  • trunk/WebKit/WebView/WebHTMLView.mm

    r27264 r27369  
    296296@interface WebHTMLView (WebHTMLViewFileInternal)
    297297- (BOOL)_imageExistsAtPaths:(NSArray *)paths;
    298 - (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard inContext:(DOMRange *)context allowPlainText:(BOOL)allowPlainText chosePlainText:(BOOL *)chosePlainText;
     298- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard inContext:(DOMRange *)context allowPlainText:(BOOL)allowPlainText;
    299299- (NSString *)_plainTextFromPasteboard:(NSPasteboard *)pasteboard;
    300300- (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText;
     
    553553                                               inContext:(DOMRange *)context
    554554                                          allowPlainText:(BOOL)allowPlainText
    555                                           chosePlainText:(BOOL *)chosePlainText
    556555{
    557556    NSArray *types = [pasteboard types];
    558     *chosePlainText = NO;
    559557    DOMDocumentFragment *fragment = nil;
    560558
     
    620618                                                inContext:context
    621619                                             subresources:0])) {
    622         *chosePlainText = YES;
    623620        return fragment;
    624621    }
     
    667664{
    668665    DOMRange *range = [self _selectedRange];
    669     BOOL chosePlainText;
    670666    DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard
    671         inContext:range allowPlainText:allowPlainText chosePlainText:&chosePlainText];
     667        inContext:range allowPlainText:allowPlainText];
    672668    WebFrameBridge *bridge = [self _bridge];
    673669    if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:[self _selectedRange] givenAction:WebViewInsertActionPasted]) {
    674         [bridge replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:chosePlainText];
     670        [bridge replaceSelectionWithFragment:fragment selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard] matchStyle:NO];
    675671    }
    676672}
     
    50935089- (DOMDocumentFragment*)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard
    50945090{
    5095     BOOL discard;
    5096     return [self _documentFragmentFromPasteboard:pasteboard inContext:nil allowPlainText:NO chosePlainText:&discard];
     5091    return [self _documentFragmentFromPasteboard:pasteboard inContext:nil allowPlainText:NO];
    50975092}
    50985093
Note: See TracChangeset for help on using the changeset viewer.