- Revision
- 268494
- Author
- andresg...@apple.com
- Date
- 2020-10-14 15:47:26 -0700 (Wed, 14 Oct 2020)
Log Message
Support AXCoreObject::elementPath for text elements.
https://bugs.webkit.org/show_bug.cgi?id=215206
Reviewed by Chris Fleizach.
Source/WebCore:
Test: accessibility/text-element-path.html
Text elements now support returning a Path in those cases where the
element consists of the last part of a line and the beginning of the
next line. Heuristics were added to avoid to compute the element Path for those cases in which the bounding rectangle is suitable.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::supportsPath const):
(WebCore::AccessibilityRenderObject::elementPath const):
LayoutTests:
* accessibility/mac/bounds-for-range-expected.txt:
Since elementPath is now supported for text elements,
AccessibilityUIEelement::attributesOfLinkedUIElements also returns the
element path description.
* accessibility/mac/internal-link-anchors-expected.txt: Ditto.
* accessibility/text-element-path-expected.txt: Added.
* accessibility/text-element-path.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (268493 => 268494)
--- trunk/LayoutTests/ChangeLog 2020-10-14 22:25:44 UTC (rev 268493)
+++ trunk/LayoutTests/ChangeLog 2020-10-14 22:47:26 UTC (rev 268494)
@@ -1,3 +1,18 @@
+2020-10-14 Andres Gonzalez <andresg...@apple.com>
+
+ Support AXCoreObject::elementPath for text elements.
+ https://bugs.webkit.org/show_bug.cgi?id=215206
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/mac/bounds-for-range-expected.txt:
+ Since elementPath is now supported for text elements,
+ AccessibilityUIEelement::attributesOfLinkedUIElements also returns the
+ element path description.
+ * accessibility/mac/internal-link-anchors-expected.txt: Ditto.
+ * accessibility/text-element-path-expected.txt: Added.
+ * accessibility/text-element-path.html: Added.
+
2020-10-14 Hector Lopez <hector_i_lo...@apple.com>
Rebaseline editing/editable-region/iframe.html result
Modified: trunk/LayoutTests/accessibility/mac/bounds-for-range-expected.txt (268493 => 268494)
--- trunk/LayoutTests/accessibility/mac/bounds-for-range-expected.txt 2020-10-14 22:25:44 UTC (rev 268493)
+++ trunk/LayoutTests/accessibility/mac/bounds-for-range-expected.txt 2020-10-14 22:47:26 UTC (rev 268494)
@@ -27,6 +27,7 @@
AXEditableAncestor: (null)
AXHighestEditableAncestor: (null)
AXElementBusy: 0
+AXPath: (null)
----------------------
AXUIElementForTextMarker
Modified: trunk/LayoutTests/accessibility/mac/internal-link-anchors-expected.txt (268493 => 268494)
--- trunk/LayoutTests/accessibility/mac/internal-link-anchors-expected.txt 2020-10-14 22:25:44 UTC (rev 268493)
+++ trunk/LayoutTests/accessibility/mac/internal-link-anchors-expected.txt 2020-10-14 22:47:26 UTC (rev 268494)
@@ -28,6 +28,7 @@
AXEditableAncestor: (null)
AXHighestEditableAncestor: (null)
AXElementBusy: 0
+AXPath: (null)
------------
Added: trunk/LayoutTests/accessibility/text-element-path-expected.txt (0 => 268494)
--- trunk/LayoutTests/accessibility/text-element-path-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/text-element-path-expected.txt 2020-10-14 22:47:26 UTC (rev 268494)
@@ -0,0 +1,67 @@
+Add or delete a table in Numbers on iPhone
+
+When you add a table, you choose from a number of predesigned styles that match your template. After you add a table, you can customize it however you like. You can add as many tables as you want to a sheet.
+
+This tests that text elements properly support paths.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+AXRole: AXStaticText
+AXValue: Add or delete a table in Numbers on iPhone
+
+Start Path
+
+AXRole: AXStaticText
+AXValue: When you add a table, you choose from a number of predesigned styles that match your
+
+Start Path
+
+AXRole: AXLink
+AXValue:
+
+Start Path
+
+AXRole: AXStaticText
+AXValue: . After you add a table, you can customize it however you like. You can add as many tables as you want to a
+
+Start Path
+ Move to point
+ Line to
+ Line to
+ Line to
+ Line to
+ Line to
+ Line to
+ Line to
+ Close
+ Move to point
+ Line to
+ Line to
+ Line to
+ Line to
+ Line to
+ Line to
+ Line to
+ Close
+ Move to point
+
+AXRole: AXLink
+AXValue:
+
+Start Path
+
+AXRole: AXStaticText
+AXValue: .
+
+Start Path
+
+AXRole: AXStaticText
+AXValue: template
+
+Start Path
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/accessibility/text-element-path.html (0 => 268494)
--- trunk/LayoutTests/accessibility/text-element-path.html (rev 0)
+++ trunk/LayoutTests/accessibility/text-element-path.html 2020-10-14 22:47:26 UTC (rev 268494)
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<head>
+<script src=""
+</head>
+<body>
+
+<h1 id="h1">Add or delete a table in Numbers on iPhone</h1>
+<p id="p1">When you add a table, you choose from a number of predesigned styles that match your <a href="" id="link1">template</a>. After you add a table, you can customize it however you like. You can add as many tables as you want to a <a href="" id="link2">sheet</a>.</p>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+ description("This tests that text elements properly support paths.");
+
+ function logChildrenPath(accessibleElement) {
+ for (i = 0; i < accessibleElement.childrenCount; ++i) {
+ child = accessibleElement.childAtIndex(i);
+ debug(child.role);
+ debug(child.stringValue);
+ debug(child.pathDescription);
+ }
+ }
+
+ if (window.accessibilityController) {
+ logChildrenPath(accessibilityController.accessibleElementById("h1"));
+ logChildrenPath(accessibilityController.accessibleElementById("p1"));
+ logChildrenPath(accessibilityController.accessibleElementById("link1"));
+ }
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/platform/win/TestExpectations (268493 => 268494)
--- trunk/LayoutTests/platform/win/TestExpectations 2020-10-14 22:25:44 UTC (rev 268493)
+++ trunk/LayoutTests/platform/win/TestExpectations 2020-10-14 22:47:26 UTC (rev 268494)
@@ -1616,6 +1616,7 @@
[ Debug ] accessibility/heading-title-includes-links.html [ Skip ]
webkit.org/b/140867 [ Debug ] accessibility/spinbutton-value.html [ Skip ]
accessibility/url-test.html [ Skip ]
+accessibility/text-element-path.html [ Skip ]
# Missing support for scrollTo* methods.
accessibility/scroll-to-global-point-iframe-nested.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (268493 => 268494)
--- trunk/Source/WebCore/ChangeLog 2020-10-14 22:25:44 UTC (rev 268493)
+++ trunk/Source/WebCore/ChangeLog 2020-10-14 22:47:26 UTC (rev 268494)
@@ -1,3 +1,20 @@
+2020-10-14 Andres Gonzalez <andresg...@apple.com>
+
+ Support AXCoreObject::elementPath for text elements.
+ https://bugs.webkit.org/show_bug.cgi?id=215206
+
+ Reviewed by Chris Fleizach.
+
+ Test: accessibility/text-element-path.html
+
+ Text elements now support returning a Path in those cases where the
+ element consists of the last part of a line and the beginning of the
+ next line. Heuristics were added to avoid to compute the element Path for those cases in which the bounding rectangle is suitable.
+
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::supportsPath const):
+ (WebCore::AccessibilityRenderObject::elementPath const):
+
2020-10-14 Alexey Shvayka <shvaikal...@gmail.com>
Use @putByValDirect instead of Array.prototype.@push in built-ins
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (268493 => 268494)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2020-10-14 22:25:44 UTC (rev 268493)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2020-10-14 22:47:26 UTC (rev 268494)
@@ -73,6 +73,7 @@
#include "LocalizedStrings.h"
#include "NodeList.h"
#include "Page.h"
+#include "PathUtilities.h"
#include "ProgressTracker.h"
#include "Range.h"
#include "RenderButton.h"
@@ -887,26 +888,64 @@
return boundingBoxRect();
}
-
+
bool AccessibilityRenderObject::supportsPath() const
{
- return is<RenderSVGShape>(renderer());
+ return is<RenderText>(renderer()) || is<RenderSVGShape>(renderer());
}
Path AccessibilityRenderObject::elementPath() const
{
+ if (is<RenderText>(renderer())) {
+ Vector<IntRect> rects;
+ downcast<RenderText>(*m_renderer).absoluteRects(rects, flooredLayoutPoint(m_renderer->localToAbsolute()));
+ // If only 1 rect, don't compute path since the bounding rect will be good enough.
+ if (rects.size() < 2)
+ return Path();
+
+ // Compute the path only if this is the last part of a line followed by the beginning of the next line.
+ const auto& style = m_renderer->style();
+ bool rightToLeftText = style.direction() == TextDirection::RTL;
+ static const int xTolerance = 5;
+ static const int yTolerance = 5;
+ bool needsPath = false;
+ IntRect unionRect = rects[0];
+ for (size_t i = 1; i < rects.size(); ++i) {
+ needsPath = abs(rects[i].y() - unionRect.maxY()) < yTolerance // This rect is in a new line.
+ && (rightToLeftText ? rects[i].x() - unionRect.x() > xTolerance
+ : unionRect.x() - rects[i].x() > xTolerance); // And this rect is to right/left of all previous rects.
+
+ if (needsPath)
+ break;
+
+ unionRect.unite(rects[i]);
+ }
+ if (!needsPath)
+ return Path();
+
+ float outlineOffset = style.outlineOffset();
+ float deviceScaleFactor = m_renderer->document().deviceScaleFactor();
+ Vector<FloatRect> pixelSnappedRects;
+ for (auto rect : rects) {
+ rect.inflate(outlineOffset);
+ pixelSnappedRects.append(snapRectToDevicePixels(rect, deviceScaleFactor));
+ }
+
+ return PathUtilities::pathWithShrinkWrappedRects(pixelSnappedRects, 0);
+ }
+
if (is<RenderSVGShape>(renderer()) && downcast<RenderSVGShape>(*m_renderer).hasPath()) {
Path path = downcast<RenderSVGShape>(*m_renderer).path();
-
+
// The SVG path is in terms of the parent's bounding box. The path needs to be offset to frame coordinates.
if (auto svgRoot = ancestorsOfType<RenderSVGRoot>(*m_renderer).first()) {
LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location();
path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y()));
}
-
+
return path;
}
-
+
return Path();
}