Changeset 92537 in webkit


Ignore:
Timestamp:
Aug 5, 2011 6:47:07 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r92330.
http://trac.webkit.org/changeset/92330
https://bugs.webkit.org/show_bug.cgi?id=65804

caused various regressions in paste (Requested by rniwa on
#webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2011-08-05

Source/WebCore:

  • editing/ReplaceSelectionCommand.cpp:

(WebCore::isInlineNodeWithStyle):
(WebCore::ReplaceSelectionCommand::doApply):

  • editing/markup.cpp:

(WebCore::ancestorToRetainStructureAndAppearance):

  • editing/markup.h:

LayoutTests:

  • editing/pasteboard/5065605-expected.txt:
  • editing/pasteboard/copy-paste-text-in-h1-expected.txt: Removed.
  • editing/pasteboard/copy-paste-text-in-h1.html: Removed.
  • editing/pasteboard/display-block-on-spans-expected.txt:
  • editing/pasteboard/paste-pre-001-expected.txt:
  • editing/pasteboard/paste-pre-002-expected.txt:
  • editing/pasteboard/paste-text-011-expected.txt:
Location:
trunk
Files:
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r92531 r92537  
     12011-08-05  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r92330.
     4        http://trac.webkit.org/changeset/92330
     5        https://bugs.webkit.org/show_bug.cgi?id=65804
     6
     7        caused various regressions in paste (Requested by rniwa on
     8        #webkit).
     9
     10        * editing/pasteboard/5065605-expected.txt:
     11        * editing/pasteboard/copy-paste-text-in-h1-expected.txt: Removed.
     12        * editing/pasteboard/copy-paste-text-in-h1.html: Removed.
     13        * editing/pasteboard/display-block-on-spans-expected.txt:
     14        * editing/pasteboard/paste-pre-001-expected.txt:
     15        * editing/pasteboard/paste-pre-002-expected.txt:
     16        * editing/pasteboard/paste-text-011-expected.txt:
     17
    1182011-08-05  Ryosuke Niwa  <rniwa@webkit.org>
    219
  • trunk/LayoutTests/editing/pasteboard/5065605-expected.txt

    r92330 r92537  
    2222EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    2323EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    24 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 24 of #text > FONT > DIV > DIV > BODY > HTML > #document to 24 of #text > FONT > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     24EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 24 of #text > FONT > DIV > SPAN > FONT > DIV > DIV > BODY > HTML > #document to 24 of #text > FONT > DIV > SPAN > FONT > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2525EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2626EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3737|     color="#ff0000"
    3838|     "This text should be red."
    39 | <font>
    40 |   class="Apple-style-span"
    41 |   color="#ff0000"
    42 |   "This text should be red."
    4339| <div>
    4440|   <font>
    4541|     class="Apple-style-span"
    4642|     color="#ff0000"
    47 |     "This text should be red.<#selection-caret>"
     43|     <span>
     44|       class="Apple-style-span"
     45|       style="color: rgb(0, 0, 0); "
     46|       <font>
     47|         class="Apple-style-span"
     48|         color="#ff0000"
     49|         "This text should be red."
     50|       <div>
     51|         <font>
     52|           class="Apple-style-span"
     53|           color="#ff0000"
     54|           "This text should be red.<#selection-caret>"
  • trunk/LayoutTests/editing/pasteboard/display-block-on-spans-expected.txt

    r92330 r92537  
    3030|   style="display:block"
    3131|   <b>
    32 |     <span>
    33 |       class="Apple-style-span"
    34 |       style="font-weight: normal; "
    35 |       <b>
    36 |         "This<#selection-caret>"
     32|     "This<#selection-caret>"
     33|   <b>
    3734|     " is another paragraph."
    3835|   <br>
  • trunk/LayoutTests/editing/pasteboard/paste-pre-001-expected.txt

    r92330 r92537  
    88bar
    99execCutCommand: <div id="test" class="editing"> <pre><br></pre> </div>
    10 execPasteCommand: <div id="test" class="editing"> <pre>foo bar</pre> </div>
     10execPasteCommand: <div id="test" class="editing"> <pre><span class="Apple-style-span" style="font-family: Times; white-space: normal; "><pre>foo bar</pre></span></pre> </div>
  • trunk/LayoutTests/editing/pasteboard/paste-pre-002-expected.txt

    r92330 r92537  
    33bar
    44execCopyCommand: <div id="test" class="editing"> <pre>foo bar</pre> </div>
    5 execPasteCommand: <div id="test" class="editing"> <pre>foo bar</pre> </div>
     5execPasteCommand: <div id="test" class="editing"> <pre><span class="Apple-style-span" style="font-family: Times; white-space: normal; "><pre>foo bar</pre></span></pre> </div>
  • trunk/LayoutTests/editing/pasteboard/paste-text-011-expected.txt

    r92330 r92537  
    77EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of P > BODY > HTML > #document to 0 of P > BODY > HTML > #document givenAction:WebViewInsertActionPasted
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    9 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > B > FONT > P > BODY > HTML > #document to 5 of #text > B > FONT > P > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     9EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > B > FONT > P > SPAN > B > FONT > P > BODY > HTML > #document to 5 of #text > B > FONT > P > SPAN > B > FONT > P > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1010EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1111EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    3131|     face="Monaco"
    3232|     <b>
    33 |       "hello"
    34 | <p>
    35 |   <font>
    36 |     face="Monaco"
    37 |     <b>
    38 |       "there<#selection-caret>"
     33|       <span>
     34|         class="Apple-style-span"
     35|         style="font-family: Times; font-weight: normal; "
     36|         <p>
     37|           <font>
     38|             face="Monaco"
     39|             <b>
     40|               "hello"
     41|         <p>
     42|           <font>
     43|             face="Monaco"
     44|             <b>
     45|               "there<#selection-caret>"
    3946| "
    4047
  • trunk/Source/WebCore/ChangeLog

    r92533 r92537  
     12011-08-05  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r92330.
     4        http://trac.webkit.org/changeset/92330
     5        https://bugs.webkit.org/show_bug.cgi?id=65804
     6
     7        caused various regressions in paste (Requested by rniwa on
     8        #webkit).
     9
     10        * editing/ReplaceSelectionCommand.cpp:
     11        (WebCore::isInlineNodeWithStyle):
     12        (WebCore::ReplaceSelectionCommand::doApply):
     13        * editing/markup.cpp:
     14        (WebCore::ancestorToRetainStructureAndAppearance):
     15        * editing/markup.h:
     16
    1172011-08-05  Kent Tamura  <tkent@chromium.org>
    218
  • trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp

    r92330 r92537  
    761761}
    762762
    763 static bool nodeHasAttributesToPreserve(const HTMLElement* element)
    764 {
    765     const NamedNodeMap* attributeMap = element->attributeMap();
    766     return attributeMap && !attributeMap->isEmpty() && (attributeMap->length() > 1 || !element->hasAttribute(styleAttr));
    767 }
    768 
    769763static bool isInlineNodeWithStyle(const Node* node)
    770764{
     
    788782    // We can skip inline elements that don't have attributes or whose only
    789783    // attribute is the style attribute.
    790     return !nodeHasAttributesToPreserve(static_cast<const HTMLElement*>(node));
     784    const NamedNodeMap* attributeMap = element->attributeMap();
     785    if (!attributeMap || attributeMap->isEmpty() || (attributeMap->length() == 1 && element->hasAttribute(styleAttr)))
     786        return true;
     787
     788    return false;
    791789}
    792790   
     
    940938    // our style spans and for positions inside list items
    941939    // since insertAsListItems already does the right thing.
    942     if (!m_matchStyle && !enclosingList(insertionPos.containerNode()) && isStyleSpan(fragment.firstChild())
    943         && VisiblePosition(firstPositionInNode(insertionPos.containerNode())) == VisiblePosition(lastPositionInNode(insertionPos.containerNode()))) {
     940    if (!m_matchStyle && !enclosingList(insertionPos.containerNode()) && isStyleSpan(fragment.firstChild())) {
    944941        if (insertionPos.containerNode()->isTextNode() && insertionPos.offsetInContainerNode() && !insertionPos.atLastEditingPositionForNode()) {
    945942            splitTextNodeContainingElement(insertionPos.containerText(), insertionPos.offsetInContainerNode());
     
    947944        }
    948945
    949         RefPtr<Node> nodeToSplitTo = highestEnclosingNodeOfType(insertionPos, isInlineNodeWithStyle);
    950         if (HTMLElement* ancestor = ancestorToRetainStructureAndAppearance(nodeToSplitTo ? nodeToSplitTo.get() : insertionPos.containerNode(), IncludeParagraphSeparators)) {
    951             if (ancestor->parentNode() && unsplittableElementForPosition(insertionPos)->contains(ancestor->parentNode()) && !nodeHasAttributesToPreserve(ancestor))
    952                 nodeToSplitTo = ancestor;
    953         }
    954         if (nodeToSplitTo) {
    955             if (insertionPos.containerNode() != nodeToSplitTo->parentNode()) {
    956                 nodeToSplitTo = splitTreeToNode(insertionPos.anchorNode(), nodeToSplitTo->parentNode()).get();
     946        // FIXME: isInlineNodeWithStyle does not check editability.
     947        if (RefPtr<Node> nodeToSplitTo = highestEnclosingNodeOfType(insertionPos, isInlineNodeWithStyle)) {
     948            if (insertionPos.containerNode() != nodeToSplitTo) {
     949                nodeToSplitTo = splitTreeToNode(insertionPos.anchorNode(), nodeToSplitTo.get(), true).get();
    957950                insertionPos = positionInParentBeforeNode(nodeToSplitTo.get());
    958951            }
  • trunk/Source/WebCore/editing/markup.cpp

    r92330 r92537  
    351351}
    352352
    353 HTMLElement* ancestorToRetainStructureAndAppearance(Node* commonAncestor, ShouldIncludeParagraphSeparators shouldIncludeParagraphSeparators)
     353static Node* ancestorToRetainStructureAndAppearance(Node* commonAncestor)
    354354{
    355355    Node* commonAncestorBlock = enclosingBlock(commonAncestor);
     
    363363            table = table->parentNode();
    364364
    365         return toHTMLElement(table);
     365        return table;
    366366    }
    367367
     
    377377        || commonAncestorBlock->hasTagName(h4Tag)
    378378        || commonAncestorBlock->hasTagName(h5Tag))
    379         return toHTMLElement(commonAncestorBlock);
    380 
    381     if (shouldIncludeParagraphSeparators == IncludeParagraphSeparators
    382         && (commonAncestorBlock->hasTagName(pTag) || commonAncestorBlock->hasTagName(divTag)))
    383         return toHTMLElement(commonAncestorBlock);
     379        return commonAncestorBlock;
    384380
    385381    return 0;
  • trunk/Source/WebCore/editing/markup.h

    r92330 r92537  
    3434namespace WebCore {
    3535
    36 class Document;
    37 class DocumentFragment;
    38 class Element;
    39 class HTMLElement;
    40 class KURL;
    41 class Node;
    42 class Range;
     36    class Document;
     37    class DocumentFragment;
     38    class Element;
     39    class KURL;
     40    class Node;
     41    class Range;
    4342
    44 enum EChildrenOnly { IncludeNode, ChildrenOnly };
    45 enum EAbsoluteURLs { DoNotResolveURLs, AbsoluteURLs };
     43    enum EChildrenOnly { IncludeNode, ChildrenOnly };
     44    enum EAbsoluteURLs { DoNotResolveURLs, AbsoluteURLs };
    4645
    47 PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text);
    48 PassRefPtr<DocumentFragment> createFragmentFromMarkup(Document*, const String& markup, const String& baseURL, FragmentScriptingPermission = FragmentScriptingAllowed);
    49 PassRefPtr<DocumentFragment> createFragmentFromNodes(Document*, const Vector<Node*>&);
     46    PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text);
     47    PassRefPtr<DocumentFragment> createFragmentFromMarkup(Document*, const String& markup, const String& baseURL, FragmentScriptingPermission = FragmentScriptingAllowed);
     48    PassRefPtr<DocumentFragment> createFragmentFromNodes(Document*, const Vector<Node*>&);
    5049
    51 bool isPlainTextMarkup(Node*);
     50    bool isPlainTextMarkup(Node *node);
    5251
    53 String createMarkup(const Range*, Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
    54 String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs);
     52    String createMarkup(const Range*,
     53        Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
     54    String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs);
     55   
     56    String createFullMarkup(const Node*);
     57    String createFullMarkup(const Range*);
    5558
    56 String createFullMarkup(const Node*);
    57 String createFullMarkup(const Range*);
    58 
    59 String urlToMarkup(const KURL&, const String& title);
    60 String imageToMarkup(const KURL&, Element*);
    61 
    62 enum ShouldIncludeParagraphSeparators { DoNotIncludeParagraphSeparators, IncludeParagraphSeparators };
    63 HTMLElement* ancestorToRetainStructureAndAppearance(Node*, ShouldIncludeParagraphSeparators = DoNotIncludeParagraphSeparators);
    64 
     59    String urlToMarkup(const KURL&, const String& title);
     60    String imageToMarkup(const KURL&, Element*);
    6561}
    6662
Note: See TracChangeset for help on using the changeset viewer.