Changeset 64083 in webkit


Ignore:
Timestamp:
Jul 26, 2010 3:47:21 PM (14 years ago)
Author:
rniwa@webkit.org
Message:

Applying inline style to a text node whose parent is an inline editable root causes crash
https://bugs.webkit.org/show_bug.cgi?id=39989

Reviewed by Darin Adler.

WebCore:

The crash was caused by splitTextElementAtStart and splitTextElementAtEnd assuming that the parent
and the grandparent of the specified text node is editable.

Modified splitTextElementAtStart and splitTextElementAtEnd so that they call splitTextAtStart
and splitTextAtEnd respectively when the grandparent is not editable.

Also modified SplitTextNodeContainingElement to exit early if the grandparent of m_text is not editable.

Test: editing/style/style-text-node-without-editable-parent.html

  • editing/ApplyStyleCommand.cpp:

(WebCore::ApplyStyleCommand::splitTextElementAtStart):
(WebCore::ApplyStyleCommand::splitTextElementAtEnd):

  • editing/SplitTextNodeContainingElementCommand.cpp:

(WebCore::SplitTextNodeContainingElementCommand::doApply):

LayoutTests:

Added a test to apply inline styles to a text node which is a editable root's child.
The test should not crash.

Two tests require rebaseline for the editing delegates. However, the final selection is kept same.

  • editing/execCommand/hilitecolor-expected.txt:
  • editing/style/remove-underline-from-stylesheet-expected.txt:
  • editing/style/style-text-node-without-editable-parent-expected.txt: Added.
  • editing/style/style-text-node-without-editable-parent.html: Added.
  • resources/dump-as-markup.js:
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r64082 r64083  
     12010-07-26  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Applying inline style to a text node whose parent is an inline editable root causes crash
     6        https://bugs.webkit.org/show_bug.cgi?id=39989
     7
     8        Added a test to apply inline styles to a text node which is a editable root's child.
     9        The test should not crash.
     10
     11        Two tests require rebaseline for the editing delegates. However, the final selection is kept same.
     12
     13        * editing/execCommand/hilitecolor-expected.txt:
     14        * editing/style/remove-underline-from-stylesheet-expected.txt:
     15        * editing/style/style-text-node-without-editable-parent-expected.txt: Added.
     16        * editing/style/style-text-node-without-editable-parent.html: Added.
     17        * resources/dump-as-markup.js:
     18
    1192010-07-26  Martin Robinson  <mrobinson@igalia.com>
    220
  • trunk/LayoutTests/editing/execCommand/hilitecolor-expected.txt

    r64013 r64083  
    55EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    66EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    7 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    8 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 6 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     7EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 10 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 6 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    98EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    109EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt

    r64013 r64083  
    6565EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    6666EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    67 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    68 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     67EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    6968EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    7069EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/resources/dump-as-markup.js

    r63918 r64083  
    162162
    163163// FIXME: Is there a better way to do this than a hard coded list?
    164 Markup._DUMP_AS_MARKUP_PROPERTIES = ['src', 'type', 'href', 'style', 'class', 'id', 'contentEditable'];
     164Markup._DUMP_AS_MARKUP_PROPERTIES = ['src', 'type', 'href', 'style', 'class', 'id', 'color', 'bgcolor', 'contentEditable'];
    165165
    166166Markup._getAttributes = function(node)
  • trunk/WebCore/ChangeLog

    r64078 r64083  
     12010-07-26  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Applying inline style to a text node whose parent is an inline editable root causes crash
     6        https://bugs.webkit.org/show_bug.cgi?id=39989
     7
     8        The crash was caused by splitTextElementAtStart and splitTextElementAtEnd assuming that the parent
     9        and the grandparent of the specified text node is editable.
     10
     11        Modified splitTextElementAtStart and splitTextElementAtEnd so that they call splitTextAtStart
     12        and splitTextAtEnd respectively when the grandparent is not editable.
     13
     14        Also modified SplitTextNodeContainingElement to exit early if the grandparent of m_text is not editable.
     15
     16        Test: editing/style/style-text-node-without-editable-parent.html
     17
     18        * editing/ApplyStyleCommand.cpp:
     19        (WebCore::ApplyStyleCommand::splitTextElementAtStart):
     20        (WebCore::ApplyStyleCommand::splitTextElementAtEnd):
     21        * editing/SplitTextNodeContainingElementCommand.cpp:
     22        (WebCore::SplitTextNodeContainingElementCommand::doApply):
     23
    1242010-07-26  Simon Fraser  <simon.fraser@apple.com>
    225
  • trunk/WebCore/editing/ApplyStyleCommand.cpp

    r64028 r64083  
    15551555void ApplyStyleCommand::splitTextElementAtStart(const Position& start, const Position& end)
    15561556{
     1557    Node* parent = start.node()->parentNode();
     1558    if (!parent || !parent->parentElement() || !parent->parentElement()->isContentEditable())
     1559        return splitTextAtStart(start, end);
     1560
    15571561    int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
    15581562    Text* text = static_cast<Text*>(start.node());
     
    15631567void ApplyStyleCommand::splitTextElementAtEnd(const Position& start, const Position& end)
    15641568{
     1569    Node* parent = end.node()->parentNode();
     1570    if (!parent || !parent->parentElement() || !parent->parentElement()->isContentEditable())
     1571        return splitTextAtEnd(start, end);
     1572
    15651573    Text* text = static_cast<Text*>(end.node());
    15661574    splitTextNodeContainingElement(text, end.deprecatedEditingOffset());
  • trunk/WebCore/editing/SplitTextNodeContainingElementCommand.cpp

    r39456 r64083  
    4949
    5050    Element* parent = m_text->parentElement();
    51     if (!parent)
     51    if (!parent || !parent->parentElement() || !parent->parentElement()->isContentEditable())
    5252        return;
    5353
Note: See TracChangeset for help on using the changeset viewer.