Changeset 130532 in webkit


Ignore:
Timestamp:
Oct 5, 2012, 11:26:37 AM (13 years ago)
Author:
rniwa@webkit.org
Message:

Deleting across multiple paragraphs can change the style of surrounding text
https://bugs.webkit.org/show_bug.cgi?id=97266

Reviewed by Levi Weintraub.

Source/WebCore:

Preserve editing styles from CSS rules in wrappingStyleForSerialization as well as inline styles
even when we're not annotating. We don't want to preserve all styles because it's against
the user expectation to keep borders, etc... when merging paragraphs. We also don't want to copy
styles from a mail blockquote because that's not a style the user has applied. See the comment
in EditingStyle::wrappingStyleForSerialization.

Test: editing/deleting/merge-paragraph-with-style-from-rule.html

  • editing/EditingStyle.cpp:

(WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement):
(WebCore::EditingStyle::wrappingStyleForSerialization):

LayoutTests:

Added a regression test and rebaselined tests.

  • editing/deleting/delete-before-block-image-2-expected.txt:
  • editing/deleting/merge-paragraph-from-p-with-style-expected.txt:
  • editing/deleting/merge-paragraph-from-p-with-style.html: We changed the behavior. The editing style of p

is now preserved when merging paragraphs.

  • editing/deleting/merge-paragraph-with-style-from-rule-expected.txt: Added.
  • editing/deleting/merge-paragraph-with-style-from-rule.html: Added.
  • platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt:
  • platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt:
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r130529 r130532  
     12012-10-05  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Deleting across multiple paragraphs can change the style of surrounding text
     4        https://bugs.webkit.org/show_bug.cgi?id=97266
     5
     6        Reviewed by Levi Weintraub.
     7
     8        Added a regression test and rebaselined tests.
     9
     10        * editing/deleting/delete-before-block-image-2-expected.txt:
     11        * editing/deleting/merge-paragraph-from-p-with-style-expected.txt:
     12        * editing/deleting/merge-paragraph-from-p-with-style.html: We changed the behavior. The editing style of p
     13        is now preserved when merging paragraphs.
     14        * editing/deleting/merge-paragraph-with-style-from-rule-expected.txt: Added.
     15        * editing/deleting/merge-paragraph-with-style-from-rule.html: Added.
     16        * platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt:
     17        * platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt:
     18
    1192012-10-05  Julien Chaffraix  <jchaffraix@webkit.org>
    220
  • trunk/LayoutTests/editing/deleting/delete-before-block-image-2-expected.txt

    r50542 r130532  
    1 <img id="img" style="display:block;" src="../resources/abe.png">
     1<img id="img" src="../resources/abe.png" style="display: block;">
    22
    33Selection: [[object HTMLDivElement], 0]
  • trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style-expected.txt

    r126656 r130532  
    99EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
    1010This tests deleting line break before p.
    11 "helloworld" should both be in black text (no p element) and "world" should be italicized.
     11"world" in "helloworld" should be italicized in red.
    1212| "
    1313hello<#selection-caret>"
    1414| <span>
    15 |   style="font-style: italic;"
     15|   style="color: red; font-style: italic;"
    1616|   "world"
    1717| "
  • trunk/LayoutTests/editing/deleting/merge-paragraph-from-p-with-style.html

    r96870 r130532  
    88<body>
    99<p id="description">This tests deleting line break before p.
    10 "helloworld" should both be in black text (no p element) and "world" should be italicized.</p>
     10"world" in "helloworld" should be italicized in red.</p>
    1111<div id="test" contenteditable>
    1212hello
  • trunk/LayoutTests/platform/mac/editing/deleting/delete-block-merge-contents-001-expected.txt

    r96870 r130532  
    1919          RenderText {#text} at (0,0) size 84x28
    2020            text run at (0,0) width 84: "OneTwo"
     21          RenderText {#text} at (0,0) size 0x0
    2122caret: position 4 of child 0 {#text} of child 1 {DIV} of child 1 {DIV} of body
  • trunk/LayoutTests/platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt

    r96870 r130532  
    22EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
    33EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    4 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 16 of #text > DIV > BODY > HTML > #document to 16 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     4EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 17 of #text > DIV > BODY > HTML > #document to 17 of #text > DIV > BODY > HTML > #document toDOMRange:range from 16 of #text > DIV > BODY > HTML > #document to 16 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    66EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    1212EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1313EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    14 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 4 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     14EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 14 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document to 3 of #text > DIV > BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    1515EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1616EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
     
    4242            RenderText {#text} at (0,0) size 49x18
    4343              text run at (0,0) width 49: "barText"
    44 caret: position 4 of child 0 {#text} of child 0 {DIV} of child 1 {BLOCKQUOTE} of child 10 {DIV} of body
     44caret: position 3 of child 0 {#text} of child 0 {DIV} of child 1 {BLOCKQUOTE} of child 10 {DIV} of body
  • trunk/Source/WebCore/ChangeLog

    r130531 r130532  
     12012-10-05  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Deleting across multiple paragraphs can change the style of surrounding text
     4        https://bugs.webkit.org/show_bug.cgi?id=97266
     5
     6        Reviewed by Levi Weintraub.
     7
     8        Preserve editing styles from CSS rules in wrappingStyleForSerialization as well as inline styles
     9        even when we're not annotating. We don't want to preserve all styles because it's against
     10        the user expectation to keep borders, etc... when merging paragraphs. We also don't want to copy
     11        styles from a mail blockquote because that's not a style the user has applied. See the comment
     12        in EditingStyle::wrappingStyleForSerialization.
     13
     14        Test: editing/deleting/merge-paragraph-with-style-from-rule.html
     15
     16        * editing/EditingStyle.cpp:
     17        (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement):
     18        (WebCore::EditingStyle::wrappingStyleForSerialization):
     19
    1202012-10-05  Dan Bernstein  <mitz@apple.com>
    221
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r128572 r130532  
    982982void EditingStyle::mergeInlineAndImplicitStyleOfElement(StyledElement* element, CSSPropertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
    983983{
     984    RefPtr<EditingStyle> styleFromRules = EditingStyle::create();
     985    styleFromRules->mergeStyleFromRulesForSerialization(element);
     986    styleFromRules->removeNonEditingProperties();
     987    mergeStyle(styleFromRules->m_mutableStyle.get(), mode);
     988
    984989    mergeInlineStyleOfElement(element, mode, propertiesToInclude);
    985990
     
    10201025    // When not annotating for interchange, we only preserve inline style declarations.
    10211026    for (Node* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
    1022         if (node->isStyledElement()) {
     1027        if (node->isStyledElement() && !isMailBlockquote(node)) {
    10231028            wrappingStyle->mergeInlineAndImplicitStyleOfElement(static_cast<StyledElement*>(node), EditingStyle::DoNotOverrideValues,
    10241029                EditingStyle::EditingPropertiesInEffect);
Note: See TracChangeset for help on using the changeset viewer.