Changeset 192477 in webkit


Ignore:
Timestamp:
Nov 16, 2015 11:04:02 AM (8 years ago)
Author:
jiewen_tan@apple.com
Message:

Null-pointer dereference in WebCore::firstEditablePositionAfterPositionInRoot
https://bugs.webkit.org/show_bug.cgi?id=151288
<rdar://problem/23450367>

Reviewed by Darin Adler.

Source/WebCore:

Some problematic organization of body element could cause problems to JustifyRight
and Indent commnads.

Tests: editing/execCommand/justify-right-then-indent-with-problematic-body.html

editing/execCommand/justify-right-with-problematic-body.html

  • editing/CompositeEditCommand.cpp:

(WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
Assertion at l1017 is not held anymore with the testcase:
editing/execCommand/justify-right-with-problematic-body.html.
Therefore, change it to an if statement.
Also, add a guardance before calling insertNewDefaultParagraphElementAt()
as insertNodeAt() requires an editable position.
(WebCore::CompositeEditCommand::moveParagraphWithClones):
Add a guardance before calling insertNodeAt() as it requires an editable position.

  • editing/htmlediting.cpp:

(WebCore::firstEditablePositionAfterPositionInRoot):
(WebCore::lastEditablePositionBeforePositionInRoot):

LayoutTests:

  • editing/execCommand/justify-right-then-indent-with-problematic-body-expected.txt: Added.
  • editing/execCommand/justify-right-then-indent-with-problematic-body.html: Added.
  • editing/execCommand/justify-right-with-problematic-body-expected.txt: Added.
  • editing/execCommand/justify-right-with-problematic-body.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r192473 r192477  
     12015-11-16  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Null-pointer dereference in WebCore::firstEditablePositionAfterPositionInRoot
     4        https://bugs.webkit.org/show_bug.cgi?id=151288
     5        <rdar://problem/23450367>
     6
     7        Reviewed by Darin Adler.
     8
     9        * editing/execCommand/justify-right-then-indent-with-problematic-body-expected.txt: Added.
     10        * editing/execCommand/justify-right-then-indent-with-problematic-body.html: Added.
     11        * editing/execCommand/justify-right-with-problematic-body-expected.txt: Added.
     12        * editing/execCommand/justify-right-with-problematic-body.html: Added.
     13
    1142015-11-16  Ryan Haddad  <ryanhaddad@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r192476 r192477  
     12015-11-16  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Null-pointer dereference in WebCore::firstEditablePositionAfterPositionInRoot
     4        https://bugs.webkit.org/show_bug.cgi?id=151288
     5        <rdar://problem/23450367>
     6
     7        Reviewed by Darin Adler.
     8
     9        Some problematic organization of body element could cause problems to JustifyRight
     10        and Indent commnads.
     11
     12        Tests: editing/execCommand/justify-right-then-indent-with-problematic-body.html
     13               editing/execCommand/justify-right-with-problematic-body.html
     14
     15        * editing/CompositeEditCommand.cpp:
     16        (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
     17        Assertion at l1017 is not held anymore with the testcase:
     18        editing/execCommand/justify-right-with-problematic-body.html.
     19        Therefore, change it to an if statement.
     20        Also, add a guardance before calling insertNewDefaultParagraphElementAt()
     21        as insertNodeAt() requires an editable position.
     22        (WebCore::CompositeEditCommand::moveParagraphWithClones):
     23        Add a guardance before calling insertNodeAt() as it requires an editable position.
     24        * editing/htmlediting.cpp:
     25        (WebCore::firstEditablePositionAfterPositionInRoot):
     26        (WebCore::lastEditablePositionBeforePositionInRoot):
     27
    1282015-11-16  Simon Fraser  <simon.fraser@apple.com>
    229
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r192170 r192477  
    10131013            }
    10141014        } else if (enclosingBlock(upstreamEnd.deprecatedNode()) != upstreamStart.deprecatedNode()) {
    1015             // The visibleEnd.  It must be an ancestor of the paragraph start.
    1016             // We can bail as we have a full block to work with.
    1017             ASSERT(upstreamStart.deprecatedNode()->isDescendantOf(enclosingBlock(upstreamEnd.deprecatedNode())));
    1018             return nullptr;
     1015            // The visibleEnd. If it is an ancestor of the paragraph start, then
     1016            // we can bail as we have a full block to work with.
     1017            if (upstreamStart.deprecatedNode()->isDescendantOf(enclosingBlock(upstreamEnd.deprecatedNode())))
     1018                return nullptr;
    10191019        } else if (isEndOfEditableOrNonEditableContent(visibleEnd)) {
    10201020            // At the end of the editable region. We can bail here as well.
     
    10231023    }
    10241024
     1025    // If upstreamStart is not editable, then we can bail here.
     1026    if (!isEditablePosition(upstreamStart))
     1027        return nullptr;
    10251028    RefPtr<Node> newBlock = insertNewDefaultParagraphElementAt(upstreamStart);
    10261029
     
    11981201
    11991202    if (beforeParagraph.isNotNull() && !isRenderedTable(beforeParagraph.deepEquivalent().deprecatedNode())
    1200         && ((!isEndOfParagraph(beforeParagraph) && !isStartOfParagraph(beforeParagraph)) || beforeParagraph == afterParagraph)) {
     1203        && ((!isEndOfParagraph(beforeParagraph) && !isStartOfParagraph(beforeParagraph)) || beforeParagraph == afterParagraph)
     1204        && isEditablePosition(beforeParagraph.deepEquivalent())) {
    12011205        // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
    12021206        insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquivalent());
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r192043 r192477  
    288288Position firstEditablePositionAfterPositionInRoot(const Position& position, Node* highestRoot)
    289289{
     290    if (!highestRoot)
     291        return Position();
     292
    290293    // position falls before highestRoot.
    291294    if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && highestRoot->hasEditableStyle())
     
    313316Position lastEditablePositionBeforePositionInRoot(const Position& position, Node* highestRoot)
    314317{
     318    if (!highestRoot)
     319        return Position();
     320
    315321    // When position falls after highestRoot, the result is easy to compute.
    316322    if (comparePositions(position, lastPositionInNode(highestRoot)) == 1)
Note: See TracChangeset for help on using the changeset viewer.