Changeset 95645 in webkit


Ignore:
Timestamp:
Sep 21, 2011, 10:06:53 AM (14 years ago)
Author:
rniwa@webkit.org
Message:

Span element gets produced using backspace/delete to merge header with paragraph
https://bugs.webkit.org/show_bug.cgi?id=68413

Reviewed by Darin Adler.

Source/WebCore:

Add p element to the list of elements to retain appearance. Also modified removeStyleFromNode
(and renamed to removeStyleFromRules) not to remove inline style declarations because
inline styles need to stay on copy.

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

  • editing/DeleteSelectionCommand.cpp:

(WebCore::DeleteSelectionCommand::saveTypingStyleState):

  • editing/EditingStyle.cpp:

(WebCore::EditingStyle::removeStyleFromRules): Renamed from removeStyleFromNode.

  • editing/EditingStyle.h:
  • editing/markup.cpp:

(WebCore::isBlockNodeToRetainAppearance):
(WebCore::StyledMarkupAccumulator::serializeNodes):

LayoutTests:

Add a test to remove the line break before a p element. WebKit should not preserve
the font color from the style rule but should preserve the font style from inline style declaration.

Also fix merge-paragraph-from-h6* to actually h6 instead of h1.

  • editing/deleting/merge-paragraph-from-h6-expected.txt:
  • editing/deleting/merge-paragraph-from-h6-with-style-expected.txt:
  • editing/deleting/merge-paragraph-from-h6-with-style.html:
  • editing/deleting/merge-paragraph-from-h6.html:
  • editing/deleting/merge-paragraph-from-p-with-style-expected.txt: Added.
  • editing/deleting/merge-paragraph-from-p-with-style.html: Added.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95644 r95645  
     12011-09-20  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Span element gets produced using backspace/delete to merge header with paragraph
     4        https://bugs.webkit.org/show_bug.cgi?id=68413
     5
     6        Reviewed by Darin Adler.
     7
     8        Add a test to remove the line break before a p element. WebKit should not preserve
     9        the font color from the style rule but should preserve the font style from inline style declaration.
     10
     11        Also fix merge-paragraph-from-h6* to actually h6 instead of h1.
     12
     13        * editing/deleting/merge-paragraph-from-h6-expected.txt:
     14        * editing/deleting/merge-paragraph-from-h6-with-style-expected.txt:
     15        * editing/deleting/merge-paragraph-from-h6-with-style.html:
     16        * editing/deleting/merge-paragraph-from-h6.html:
     17        * editing/deleting/merge-paragraph-from-p-with-style-expected.txt: Added.
     18        * editing/deleting/merge-paragraph-from-p-with-style.html: Added.
     19
    1202011-09-21  Ojan Vafai  <ojan@chromium.org>
    221
  • trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-expected.txt

    r95335 r95645  
    33EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    44EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    5 EDITING DELEGATE: shouldDeleteDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 0 of H1 > DIV > BODY > HTML > #document
     5EDITING DELEGATE: shouldDeleteDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 0 of H6 > DIV > BODY > HTML > #document
    66EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    77EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
  • trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style-expected.txt

    r95335 r95645  
    33EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    44EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    5 EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 0 of H1 > DIV > BODY > HTML > #document
     5EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 0 of H6 > DIV > BODY > HTML > #document
    66EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    77EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 5 of #text > EM > DIV > BODY > HTML > #document to 5 of #text > EM > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
  • trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6-with-style.html

    r95335 r95645  
    66<div id="test" contenteditable>
    77<em>hello</em>
    8 <h1><font color="red">world</font></h1>
     8<h6><font color="red">world</font></h6>
    99</div>
    1010</div>
  • trunk/LayoutTests/editing/deleting/merge-paragraph-from-h6.html

    r95335 r95645  
    66<div id="test" contenteditable>
    77hello
    8 <h1>world</h1>
     8<h6>world</h6>
    99</div>
    1010</div>
  • trunk/Source/WebCore/ChangeLog

    r95641 r95645  
     12011-09-20  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Span element gets produced using backspace/delete to merge header with paragraph
     4        https://bugs.webkit.org/show_bug.cgi?id=68413
     5
     6        Reviewed by Darin Adler.
     7
     8        Add p element to the list of elements to retain appearance. Also modified removeStyleFromNode
     9        (and renamed to removeStyleFromRules) not to remove inline style declarations because
     10        inline styles need to stay on copy.
     11
     12        Test: editing/deleting/merge-paragraph-from-p-with-style.html
     13
     14        * editing/DeleteSelectionCommand.cpp:
     15        (WebCore::DeleteSelectionCommand::saveTypingStyleState):
     16        * editing/EditingStyle.cpp:
     17        (WebCore::EditingStyle::removeStyleFromRules): Renamed from removeStyleFromNode.
     18        * editing/EditingStyle.h:
     19        * editing/markup.cpp:
     20        (WebCore::isBlockNodeToRetainAppearance):
     21        (WebCore::StyledMarkupAccumulator::serializeNodes):
     22
    1232011-09-21  Alice Boxhall  <aboxhall@chromium.org>
    224
  • trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp

    r94898 r95645  
    284284    // Figure out the typing style in effect before the delete is done.
    285285    m_typingStyle = EditingStyle::create(m_selectionToDelete.start());
    286     m_typingStyle->removeStyleAddedByNode(enclosingAnchorElement(m_selectionToDelete.start()));
     286    m_typingStyle->removeStyleFromRules(enclosingAnchorElement(m_selectionToDelete.start()));
    287287
    288288    // If we're deleting into a Mail blockquote, save the style at end() instead of start()
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r93001 r95645  
    520520}
    521521
    522 void EditingStyle::removeStyleAddedByNode(Node* node)
    523 {
     522void EditingStyle::removeStyleFromRules(Node* node)
     523{
     524    // FIXME: This should share code with removeStyleFromRulesAndContext
     525    // but it's hard to do until we figure out how to compare font-size property without computed style.
    524526    if (!node || !node->parentNode())
    525527        return;
     
    527529    RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node));
    528530    parentStyle->diff(nodeStyle.get());
     531    if (node->isStyledElement() && static_cast<StyledElement*>(node)->inlineStyleDecl())
     532        nodeStyle = getPropertiesNotIn(nodeStyle.get(), static_cast<StyledElement*>(node)->inlineStyleDecl());
    529533    nodeStyle->diff(m_mutableStyle.get());
    530534}
  • trunk/Source/WebCore/editing/EditingStyle.h

    r92823 r95645  
    103103    PassRefPtr<EditingStyle> extractAndRemoveTextDirection();
    104104    void removeBlockProperties();
    105     void removeStyleAddedByNode(Node*);
     105    void removeStyleFromRules(Node*);
    106106    void removeStyleConflictingWithStyleOfNode(Node*);
    107107    void removeNonEditingProperties();
  • trunk/Source/WebCore/editing/markup.cpp

    r95335 r95645  
    350350        names.add(h6Tag.impl());
    351351        names.add(listingTag.impl());
     352        names.add(pTag.impl());
    352353        names.add(preTag.impl());
    353354    }
     
    369370        // to help us differentiate those styles from ones that the user has applied.
    370371        // This helps us get the color of content pasted into blockquotes right.
    371         m_wrappingStyle->removeStyleAddedByNode(enclosingNodeOfType(firstPositionInOrBeforeNode(parentOfHighestNode), isBlockNodeToRetainAppearance, CanCrossEditingBoundary));
     372        m_wrappingStyle->removeStyleFromRules(enclosingNodeOfType(firstPositionInOrBeforeNode(parentOfHighestNode), isBlockNodeToRetainAppearance, CanCrossEditingBoundary));
    372373
    373374        // Call collapseTextDecorationProperties first or otherwise it'll copy the value over from in-effect to text-decorations.
Note: See TracChangeset for help on using the changeset viewer.