<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201667] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201667">201667</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-03 16:01:49 -0700 (Fri, 03 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Crash under VisibleSelection::firstRange()
https://bugs.webkit.org/show_bug.cgi?id=158241

Reviewed by Enrica Casucci.

Source/WebCore:

The crash was commonly caused by parentAnchoredEquivalent returning null when the anchored node was a shadow root.
Fixed it by returning a shadow root in parentAnchoredEquivalent.

Also guard against other kinds of crashes by adding a null check in VisibleSelection::firstRange() since we've seen
a crash in the same code path outside of a shadow tree.

This patch also fixes other Position methods to stop using nonShadowBoundaryParentNode in place of parentNode as
that would cause a similar crash and/or a bug elsewhere.

Test: fast/shadow-dom/selection-at-shadow-root-crash.html

* accessibility/AXObjectCache.cpp:
(AXObjectCache::startCharacterOffsetOfParagraph): Fixed a bug uncovered by the assertion fix in Position::Position.
This code was sometimes creating a position inside a BR, which is wrong.
(AXObjectCache::endCharacterOffsetOfParagraph): Ditto.
* dom/Position.cpp:
(WebCore::Position::Position): Fixed an assertion which was checking that this constructor wasn't being called
with m_anchorNode set to an element editing ignores content of. ||ing it with isShadowRoot() made this assertion
useless because it's true whenever m_anchorNode is not a shadow root.
(WebCore::Position::containerNode): Use parentNode() instead of findParent() which calls nonShadowBoundaryParentNode
since Position should
(WebCore::Position::parentAnchoredEquivalent): Fixed the bug by letting this function return a shadow root.
(WebCore::Position::previous): Use parentNode() instead of findParent().
(WebCore::Position::next): Ditto.
(WebCore::Position::atStartOfTree): Ditto.
(WebCore::Position::atEndOfTree): Ditto.
(WebCore::Position::findParent): Deleted.
* dom/Position.h:
* editing/VisibleSelection.cpp:
(VisibleSelection::firstRange): Added a null check.

LayoutTests:

Added a regression test.

* fast/shadow-dom/selection-at-shadow-root-crash-expected.txt: Added.
* fast/shadow-dom/selection-at-shadow-root-crash.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAXObjectCachecpp">trunk/Source/WebCore/accessibility/AXObjectCache.cpp</a></li>
<li><a href="#trunkSourceWebCoredomPositioncpp">trunk/Source/WebCore/dom/Position.cpp</a></li>
<li><a href="#trunkSourceWebCoredomPositionh">trunk/Source/WebCore/dom/Position.h</a></li>
<li><a href="#trunkSourceWebCoreeditingVisiblePositioncpp">trunk/Source/WebCore/editing/VisiblePosition.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleSelectioncpp">trunk/Source/WebCore/editing/VisibleSelection.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdomselectionatshadowrootcrashexpectedtxt">trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomselectionatshadowrootcrashhtml">trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201666 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-03 22:47:17 UTC (rev 201666)
+++ trunk/LayoutTests/ChangeLog        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-06-03  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Crash under VisibleSelection::firstRange()
+        https://bugs.webkit.org/show_bug.cgi?id=158241
+
+        Reviewed by Enrica Casucci.
+
+        Added a regression test.
+
+        * fast/shadow-dom/selection-at-shadow-root-crash-expected.txt: Added.
+        * fast/shadow-dom/selection-at-shadow-root-crash.html: Added.
+
</ins><span class="cx"> 2016-06-03  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Incorrect rendering on boostmobile FAQ page
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomselectionatshadowrootcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash-expected.txt (0 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash-expected.txt        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+This tests copying an image which is a direct child of a shadow root. To manually test, copy the image by pressing command / control + c. WebKit should not crash or hit an assertion.
+
+PASS - WebKit did not crash
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomselectionatshadowrootcrashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash.html (0 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/selection-at-shadow-root-crash.html        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;body&gt;
+&lt;p&gt;This tests copying an image which is a direct child of a shadow root.
+To manually test, copy the image by pressing command / control + c. WebKit should not crash or hit an assertion.
+&lt;/p&gt;
+&lt;pre id=&quot;result&quot;&gt;&lt;/pre&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+var host = document.createElement('div');
+var root = host.attachShadow({mode: 'closed'});
+root.innerHTML = '&lt;img src=&quot;../../editing/resources/abe.png&quot; onload=&quot;runTest()&quot;&gt;';
+
+document.body.appendChild(host);
+
+function runTest() {
+    window.getSelection().selectAllChildren(root);
+    document.execCommand('copy', null, false);
+    document.getElementById('result').textContent = 'PASS - WebKit did not crash';
+
+    if (testRunner)
+        testRunner.notifyDone();
+}
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201666 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-03 22:47:17 UTC (rev 201666)
+++ trunk/Source/WebCore/ChangeLog        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2016-06-03  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Crash under VisibleSelection::firstRange()
+        https://bugs.webkit.org/show_bug.cgi?id=158241
+
+        Reviewed by Enrica Casucci.
+
+        The crash was commonly caused by parentAnchoredEquivalent returning null when the anchored node was a shadow root.
+        Fixed it by returning a shadow root in parentAnchoredEquivalent.
+
+        Also guard against other kinds of crashes by adding a null check in VisibleSelection::firstRange() since we've seen
+        a crash in the same code path outside of a shadow tree.
+
+        This patch also fixes other Position methods to stop using nonShadowBoundaryParentNode in place of parentNode as
+        that would cause a similar crash and/or a bug elsewhere.
+
+        Test: fast/shadow-dom/selection-at-shadow-root-crash.html
+
+        * accessibility/AXObjectCache.cpp:
+        (AXObjectCache::startCharacterOffsetOfParagraph): Fixed a bug uncovered by the assertion fix in Position::Position.
+        This code was sometimes creating a position inside a BR, which is wrong.
+        (AXObjectCache::endCharacterOffsetOfParagraph): Ditto.
+        * dom/Position.cpp:
+        (WebCore::Position::Position): Fixed an assertion which was checking that this constructor wasn't being called
+        with m_anchorNode set to an element editing ignores content of. ||ing it with isShadowRoot() made this assertion
+        useless because it's true whenever m_anchorNode is not a shadow root.
+        (WebCore::Position::containerNode): Use parentNode() instead of findParent() which calls nonShadowBoundaryParentNode
+        since Position should
+        (WebCore::Position::parentAnchoredEquivalent): Fixed the bug by letting this function return a shadow root.
+        (WebCore::Position::previous): Use parentNode() instead of findParent().
+        (WebCore::Position::next): Ditto.
+        (WebCore::Position::atStartOfTree): Ditto.
+        (WebCore::Position::atEndOfTree): Ditto.
+        (WebCore::Position::findParent): Deleted.
+        * dom/Position.h:
+        * editing/VisibleSelection.cpp:
+        (VisibleSelection::firstRange): Added a null check. 
+
</ins><span class="cx"> 2016-06-03  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Incorrect rendering on boostmobile FAQ page
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAXObjectCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (201666 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp        2016-06-03 22:47:17 UTC (rev 201666)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -2329,8 +2329,7 @@
</span><span class="cx">     
</span><span class="cx">     auto* startBlock = enclosingBlock(startNode);
</span><span class="cx">     int offset = characterOffset.startIndex + characterOffset.offset;
</span><del>-    Position p(startNode, offset, Position::PositionIsOffsetInAnchor);
-    auto* highestRoot = highestEditableRoot(p);
</del><ins>+    auto* highestRoot = highestEditableRoot(firstPositionInOrBeforeNode(startNode));
</ins><span class="cx">     Position::AnchorType type = Position::PositionIsOffsetInAnchor;
</span><span class="cx">     
</span><span class="cx">     auto* node = findStartOfParagraph(startNode, highestRoot, startBlock, offset, type, boundaryCrossingRule);
</span><span class="lines">@@ -2352,8 +2351,7 @@
</span><span class="cx">     
</span><span class="cx">     Node* stayInsideBlock = enclosingBlock(startNode);
</span><span class="cx">     int offset = characterOffset.startIndex + characterOffset.offset;
</span><del>-    Position p(startNode, offset, Position::PositionIsOffsetInAnchor);
-    Node* highestRoot = highestEditableRoot(p);
</del><ins>+    Node* highestRoot = highestEditableRoot(firstPositionInOrBeforeNode(startNode));
</ins><span class="cx">     Position::AnchorType type = Position::PositionIsOffsetInAnchor;
</span><span class="cx">     
</span><span class="cx">     Node* node = findEndOfParagraph(startNode, highestRoot, stayInsideBlock, offset, type, boundaryCrossingRule);
</span></span></pre></div>
<a id="trunkSourceWebCoredomPositioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Position.cpp (201666 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Position.cpp        2016-06-03 22:47:17 UTC (rev 201666)
+++ trunk/Source/WebCore/dom/Position.cpp        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx">     , m_anchorType(anchorType)
</span><span class="cx">     , m_isLegacyEditingPosition(false)
</span><span class="cx"> {
</span><del>-    ASSERT(!m_anchorNode || !editingIgnoresContent(*m_anchorNode) || !m_anchorNode-&gt;isShadowRoot());
</del><ins>+    ASSERT(!m_anchorNode || !editingIgnoresContent(*m_anchorNode));
</ins><span class="cx">     ASSERT(!m_anchorNode || !m_anchorNode-&gt;isPseudoElement());
</span><span class="cx">     ASSERT(anchorType == PositionIsOffsetInAnchor);
</span><span class="cx"> }
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx">         return m_anchorNode.get();
</span><span class="cx">     case PositionIsBeforeAnchor:
</span><span class="cx">     case PositionIsAfterAnchor:
</span><del>-        return findParent(*m_anchorNode);
</del><ins>+        return m_anchorNode-&gt;parentNode();
</ins><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx">     return nullptr;
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx">     
</span><span class="cx">     // FIXME: This should only be necessary for legacy positions, but is also needed for positions before and after Tables
</span><span class="cx">     if (m_offset &lt;= 0 &amp;&amp; (m_anchorType != PositionIsAfterAnchor &amp;&amp; m_anchorType != PositionIsAfterChildren)) {
</span><del>-        if (findParent(*m_anchorNode) &amp;&amp; (editingIgnoresContent(*m_anchorNode) || isRenderedTable(m_anchorNode.get())))
</del><ins>+        if (m_anchorNode-&gt;parentNode() &amp;&amp; (editingIgnoresContent(*m_anchorNode) || isRenderedTable(m_anchorNode.get())))
</ins><span class="cx">             return positionInParentBeforeNode(m_anchorNode.get());
</span><span class="cx">         return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor);
</span><span class="cx">     }
</span><span class="lines">@@ -344,7 +344,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ContainerNode* parent = findParent(*node);
</del><ins>+    ContainerNode* parent = node-&gt;parentNode();
</ins><span class="cx">     if (!parent)
</span><span class="cx">         return *this;
</span><span class="cx"> 
</span><span class="lines">@@ -391,7 +391,7 @@
</span><span class="cx">         return createLegacyEditingPosition(node, (moveType == Character) ? uncheckedNextOffset(node, offset) : offset + 1);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ContainerNode* parent = findParent(*node);
</del><ins>+    ContainerNode* parent = node-&gt;parentNode();
</ins><span class="cx">     if (!parent)
</span><span class="cx">         return *this;
</span><span class="cx"> 
</span><span class="lines">@@ -493,7 +493,7 @@
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     Node* container = containerNode();
</span><del>-    if (container &amp;&amp; findParent(*container))
</del><ins>+    if (container &amp;&amp; container-&gt;parentNode())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     switch (m_anchorType) {
</span><span class="lines">@@ -518,7 +518,7 @@
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     Node* container = containerNode();
</span><del>-    if (container &amp;&amp; findParent(*container))
</del><ins>+    if (container &amp;&amp; container-&gt;parentNode())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     switch (m_anchorType) {
</span><span class="lines">@@ -953,11 +953,6 @@
</span><span class="cx">     return node &amp;&amp; node-&gt;renderer() &amp;&amp; node-&gt;renderer()-&gt;style().userSelect() == SELECT_NONE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ContainerNode* Position::findParent(const Node&amp; node)
-{
-    return node.nonShadowBoundaryParentNode();
-}
-
</del><span class="cx"> #if ENABLE(USERSELECT_ALL)
</span><span class="cx"> bool Position::nodeIsUserSelectAll(const Node* node)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoredomPositionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Position.h (201666 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Position.h        2016-06-03 22:47:17 UTC (rev 201666)
+++ trunk/Source/WebCore/dom/Position.h        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -199,8 +199,7 @@
</span><span class="cx">     static bool nodeIsUserSelectAll(const Node*) { return false; }
</span><span class="cx">     static Node* rootUserSelectAllForNode(Node*) { return 0; }
</span><span class="cx"> #endif
</span><del>-    static ContainerNode* findParent(const Node&amp;);
-    
</del><ins>+
</ins><span class="cx">     void debugPosition(const char* msg = &quot;&quot;) const;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(TREE_DEBUGGING)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisiblePositioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisiblePosition.cpp (201666 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisiblePosition.cpp        2016-06-03 22:47:17 UTC (rev 201666)
+++ trunk/Source/WebCore/editing/VisiblePosition.cpp        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -587,7 +587,7 @@
</span><span class="cx">         
</span><span class="cx">     // If the html element is editable, descending into its body will look like a descent 
</span><span class="cx">     // from non-editable to editable content since rootEditableElement() always stops at the body.
</span><del>-    if ((editingRoot &amp;&amp; editingRoot-&gt;hasTagName(htmlTag)) || position.deprecatedNode()-&gt;isDocumentNode())
</del><ins>+    if ((editingRoot &amp;&amp; editingRoot-&gt;hasTagName(htmlTag)) || (node &amp;&amp; (node-&gt;isDocumentNode() || node-&gt;isShadowRoot())))
</ins><span class="cx">         return next.isNotNull() ? next : prev;
</span><span class="cx">         
</span><span class="cx">     bool prevIsInSameEditableElement = prevNode &amp;&amp; editableRootForPosition(prev) == editingRoot;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleSelection.cpp (201666 => 201667)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleSelection.cpp        2016-06-03 22:47:17 UTC (rev 201666)
+++ trunk/Source/WebCore/editing/VisibleSelection.cpp        2016-06-03 23:01:49 UTC (rev 201667)
</span><span class="lines">@@ -129,6 +129,8 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     Position start = m_start.parentAnchoredEquivalent();
</span><span class="cx">     Position end = m_end.parentAnchoredEquivalent();
</span><ins>+    if (start.isNull() || end.isNull())
+        return nullptr;
</ins><span class="cx">     return Range::create(start.anchorNode()-&gt;document(), start, end);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>