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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192477
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-11-16 Jiewen Tan <jiewen_tan@apple.com>
+
+ Null-pointer dereference in WebCore::firstEditablePositionAfterPositionInRoot
+ https://bugs.webkit.org/show_bug.cgi?id=151288
+ <rdar://problem/23450367>
+
+ Reviewed by Darin Adler.
+
+ * 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.
+
2015-11-16 Ryan Haddad <ryanhaddad@apple.com>
Rebaselining LayoutTest js/dom/global-constructors-attributes on Mac
--- /dev/null
+Pass.
+WebKit didn't Crash.
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body id="webtest3">
+Pass. <summary/>WebKit didn't Crash.<br>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+function editingTest() {
+ document.execCommand("SelectAll");
+ document.designMode = "on";
+ document.execCommand("JustifyRight", false, null);
+ document.execCommand("Indent", false, null);
+}
+editingTest();
+</script>
+</body>
+</html>
--- /dev/null
+Pass. WebKit didn't crash.
+
+
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+Pass. WebKit didn't crash.<ul><br><summary>
+<br><rt/>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+function editingTest() {
+ document.execCommand("SelectAll");
+ document.designMode = "on";
+ document.execCommand("JustifyRight", true, "Arial");
+}
+editingTest();
+</script>
+</body>
+</html>
\ No newline at end of file
+2015-11-16 Jiewen Tan <jiewen_tan@apple.com>
+
+ Null-pointer dereference in WebCore::firstEditablePositionAfterPositionInRoot
+ https://bugs.webkit.org/show_bug.cgi?id=151288
+ <rdar://problem/23450367>
+
+ Reviewed by Darin Adler.
+
+ 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):
+
2015-11-16 Simon Fraser <simon.fraser@apple.com>
Sort the Xcode project files.
return nullptr;
}
} else if (enclosingBlock(upstreamEnd.deprecatedNode()) != upstreamStart.deprecatedNode()) {
- // The visibleEnd. It must be an ancestor of the paragraph start.
- // We can bail as we have a full block to work with.
- ASSERT(upstreamStart.deprecatedNode()->isDescendantOf(enclosingBlock(upstreamEnd.deprecatedNode())));
- return nullptr;
+ // The visibleEnd. If it is an ancestor of the paragraph start, then
+ // we can bail as we have a full block to work with.
+ if (upstreamStart.deprecatedNode()->isDescendantOf(enclosingBlock(upstreamEnd.deprecatedNode())))
+ return nullptr;
} else if (isEndOfEditableOrNonEditableContent(visibleEnd)) {
// At the end of the editable region. We can bail here as well.
return nullptr;
}
}
+ // If upstreamStart is not editable, then we can bail here.
+ if (!isEditablePosition(upstreamStart))
+ return nullptr;
RefPtr<Node> newBlock = insertNewDefaultParagraphElementAt(upstreamStart);
bool endWasBr = visibleParagraphEnd.deepEquivalent().deprecatedNode()->hasTagName(brTag);
afterParagraph = VisiblePosition(afterParagraph.deepEquivalent());
if (beforeParagraph.isNotNull() && !isRenderedTable(beforeParagraph.deepEquivalent().deprecatedNode())
- && ((!isEndOfParagraph(beforeParagraph) && !isStartOfParagraph(beforeParagraph)) || beforeParagraph == afterParagraph)) {
+ && ((!isEndOfParagraph(beforeParagraph) && !isStartOfParagraph(beforeParagraph)) || beforeParagraph == afterParagraph)
+ && isEditablePosition(beforeParagraph.deepEquivalent())) {
// FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
insertNodeAt(createBreakElement(document()), beforeParagraph.deepEquivalent());
}
Position firstEditablePositionAfterPositionInRoot(const Position& position, Node* highestRoot)
{
+ if (!highestRoot)
+ return Position();
+
// position falls before highestRoot.
if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && highestRoot->hasEditableStyle())
return firstPositionInNode(highestRoot);
Position lastEditablePositionBeforePositionInRoot(const Position& position, Node* highestRoot)
{
+ if (!highestRoot)
+ return Position();
+
// When position falls after highestRoot, the result is easy to compute.
if (comparePositions(position, lastPositionInNode(highestRoot)) == 1)
return lastPositionInNode(highestRoot);