<!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>[277286] 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/277286">277286</a></dd>
<dt>Author</dt> <dd>andresg_22@apple.com</dd>
<dt>Date</dt> <dd>2021-05-10 12:50:19 -0700 (Mon, 10 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix for assert crash in AXObjectCache::visiblePositionForTextMarkerData.
https://bugs.webkit.org/show_bug.cgi?id=225303
<rdar://problem/77453921>

Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/mac/pseudo-element-text-markers.html

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::visiblePositionForTextMarkerData):
Added check for Node::isPseudoElement to avoid hitting the assertion during the creation of a Position.

LayoutTests:

* accessibility/mac/pseudo-element-text-markers-expected.txt: Added.
* accessibility/mac/pseudo-element-text-markers.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAXObjectCachecpp">trunk/Source/WebCore/accessibility/AXObjectCache.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsaccessibilitymacpseudoelementtextmarkersexpectedtxt">trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt</a></li>
<li><a href="#trunkLayoutTestsaccessibilitymacpseudoelementtextmarkershtml">trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (277285 => 277286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-05-10 19:49:33 UTC (rev 277285)
+++ trunk/LayoutTests/ChangeLog 2021-05-10 19:50:19 UTC (rev 277286)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-05-10  Andres Gonzalez  <andresg_22@apple.com>
+
+        Fix for assert crash in AXObjectCache::visiblePositionForTextMarkerData.
+        https://bugs.webkit.org/show_bug.cgi?id=225303
+        <rdar://problem/77453921>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/pseudo-element-text-markers-expected.txt: Added.
+        * accessibility/mac/pseudo-element-text-markers.html: Added.
+
</ins><span class="cx"> 2021-05-10  Ryan Haddad  <ryanhaddad@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] imported/w3c/web-platform-tests/css/css-flexbox/flex-item-compressible-001.html is failing after WPT re-sync
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacpseudoelementtextmarkersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt (0 => 277286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt                             (rev 0)
+++ trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers-expected.txt        2021-05-10 19:50:19 UTC (rev 277286)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pseudoElement.role is 'AXRole: AXStaticText'
+PASS pseudoElement.stringValue is 'AXValue: Hello'
+PASS pseudoElement.textMarkerRangeLength(range) is 0
+PASS pseudoElement.stringForTextMarkerRange(range) is null
+PASS pseudoElement.accessibilityElementForTextMarker(start) is null
+PASS pseudoElement.accessibilityElementForTextMarker(next) is null
+PASS pseudoElement.accessibilityElementForTextMarker(prev) is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+AXRole: AXScrollArea AXValue:
+AXRole: AXWebArea AXValue:
+AXRole: AXGroup AXValue:
+AXRole: AXStaticText AXValue: Hello
+AXRole: AXGroup AXValue:
+AXRole: AXStaticText AXValue: This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.
+AXRole: AXGroup AXValue:
+AXRole: AXStaticText AXValue: On success, you will see a series of "
+AXRole: AXStaticText AXValue: PASS
+AXRole: AXStaticText AXValue: " messages, followed by "
+AXRole: AXStaticText AXValue: TEST COMPLETE
+AXRole: AXStaticText AXValue: ".
+AXRole: AXGroup AXValue:
+AXRole: AXStaticText AXValue: AXRole: AXScrollArea AXValue:
+AXRole: AXWebArea AXValue:
+AXRole: AXGroup AXValue:
+AXRole: AXStaticText AXValue: Hello
+AXRole: AXGroup AXValue:
+AXRole: AXStaticText AXValue: This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.
+AXRole: AXGroup AXValue:
+AXRole: AXStaticText AXValue: On success, you will see a series of "
+AXRole: AXStaticText AXValue: PASS
+AXRole: AXStaticText AXValue: " messages, followed by "
+AXRole: AXStaticText AXValue: TEST COMPLETE
+AXRole: AXStaticText AXValue: ".
+AXRole: AXGroup AXValue:
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacpseudoelementtextmarkershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers.html (0 => 277286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers.html                             (rev 0)
+++ trunk/LayoutTests/accessibility/mac/pseudo-element-text-markers.html        2021-05-10 19:50:19 UTC (rev 277286)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../../resources/accessibility-helper.js"></script>
+
+<style>
+    body:before {
+        content: "Hello";
+        position: fixed;
+    }
+</style>
+</head>
+<body>
+
+<pre id="tree"></pre>
+
+<script>
+    description("This tests that the pseudo element style:body:before is accessible via the accessibility tree but not via TextMarkers.");
+
+    if (window.accessibilityController) {
+        let root = accessibilityController.rootElement;
+        dumpAccessibilityTree(root);
+
+        var pseudoElement = root.childAtIndex(0).childAtIndex(0).childAtIndex(0);
+        shouldBe("pseudoElement.role", "'AXRole: AXStaticText'");
+        shouldBe("pseudoElement.stringValue", "'AXValue: Hello'");
+
+        var range = pseudoElement.textMarkerRangeForElement(pseudoElement);
+        shouldBe("pseudoElement.textMarkerRangeLength(range)", "0");
+        shouldBe("pseudoElement.stringForTextMarkerRange(range)", "null");
+
+        var start = pseudoElement.startTextMarkerForTextMarkerRange(range);
+        shouldBe("pseudoElement.accessibilityElementForTextMarker(start)", "null");
+        var next = pseudoElement.nextTextMarker(start);
+        shouldBe("pseudoElement.accessibilityElementForTextMarker(next)", "null");
+        var prev = pseudoElement.previousTextMarker(start);
+        shouldBe("pseudoElement.accessibilityElementForTextMarker(prev)", "null");
+    }
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (277285 => 277286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations      2021-05-10 19:49:33 UTC (rev 277285)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2021-05-10 19:50:19 UTC (rev 277286)
</span><span class="lines">@@ -981,6 +981,7 @@
</span><span class="cx"> accessibility/aria-sort.html [ Skip ]
</span><span class="cx"> accessibility/mac/aria-details.html [ Skip ]
</span><span class="cx"> accessibility/mac/aria-errormessage.html [ Skip ]
</span><ins>+accessibility/mac/pseudo-element-text-markers.html [ Skip ]
</ins><span class="cx"> accessibility/nested-textareas-value-changed-notifications.html [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> # <rdar://problem/61066929> [ Stress GC ] flaky JSC::ExceptionScope::assertNoException crash under WebCore::ReadableStreamDefaultController
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (277285 => 277286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-05-10 19:49:33 UTC (rev 277285)
+++ trunk/Source/WebCore/ChangeLog      2021-05-10 19:50:19 UTC (rev 277286)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-05-10  Andres Gonzalez  <andresg_22@apple.com>
+
+        Fix for assert crash in AXObjectCache::visiblePositionForTextMarkerData.
+        https://bugs.webkit.org/show_bug.cgi?id=225303
+        <rdar://problem/77453921>
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/mac/pseudo-element-text-markers.html
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::visiblePositionForTextMarkerData):
+        Added check for Node::isPseudoElement to avoid hitting the assertion during the creation of a Position.
+
</ins><span class="cx"> 2021-05-10  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Use HashSet<RefPtr<Node>> instead of HashSet<Node*>
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAXObjectCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (277285 => 277286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp     2021-05-10 19:49:33 UTC (rev 277285)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp        2021-05-10 19:50:19 UTC (rev 277286)
</span><span class="lines">@@ -1863,23 +1863,24 @@
</span><span class="cx"> 
</span><span class="cx"> VisiblePosition AXObjectCache::visiblePositionForTextMarkerData(TextMarkerData& textMarkerData)
</span><span class="cx"> {
</span><del>-    if (!isNodeInUse(textMarkerData.node))
-        return VisiblePosition();
-    
-    VisiblePosition visiblePos = VisiblePosition(makeContainerOffsetPosition(textMarkerData.node, textMarkerData.offset), textMarkerData.affinity);
-    Position deepPos = visiblePos.deepEquivalent();
-    if (deepPos.isNull())
-        return VisiblePosition();
-    
-    RenderObject* renderer = deepPos.deprecatedNode()->renderer();
</del><ins>+    if (!isNodeInUse(textMarkerData.node)
+        || textMarkerData.node->isPseudoElement())
+        return { };
+
+    auto visiblePosition = VisiblePosition(makeContainerOffsetPosition(textMarkerData.node, textMarkerData.offset), textMarkerData.affinity);
+    auto deepPosition = visiblePosition.deepEquivalent();
+    if (deepPosition.isNull())
+        return { };
+
+    auto* renderer = deepPosition.deprecatedNode()->renderer();
</ins><span class="cx">     if (!renderer)
</span><del>-        return VisiblePosition();
-    
-    AXObjectCache* cache = renderer->document().axObjectCache();
</del><ins>+        return { };
+
+    auto* cache = renderer->document().axObjectCache();
</ins><span class="cx">     if (cache && !cache->m_idsInUse.contains(textMarkerData.axID))
</span><del>-        return VisiblePosition();
</del><ins>+        return { };
</ins><span class="cx"> 
</span><del>-    return visiblePos;
</del><ins>+    return visiblePosition;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CharacterOffset AXObjectCache::characterOffsetForTextMarkerData(TextMarkerData& textMarkerData)
</span></span></pre>
</div>
</div>

</body>
</html>