Title: [288447] trunk/Source/WebCore
Revision
288447
Author
[email protected]
Date
2022-01-24 08:21:27 -0800 (Mon, 24 Jan 2022)

Log Message

[GTK][a11y] Only consider links as replaced objects when iterating with EmitsObjectReplacementCharacters
https://bugs.webkit.org/show_bug.cgi?id=235474

Reviewed by Adrian Perez de Castro.

We don't want to consider links replaced objects in other cases.

* editing/TextIterator.cpp:
(WebCore::isRendererReplacedElement): Add TextIteratorBehaviors parameter to check if
EmitsObjectReplacementCharacters is present.
(WebCore::TextIterator::advance): Pass m_behaviors to isRendererReplacedElement().
(WebCore::SimplifiedBackwardsTextIterator::advance): Ditto.
(WebCore::isInsideReplacedElement): Add TextIteratorBehaviors parameter and pass it to isRendererReplacedElement().
(WebCore::resolveCharacterRange): Pass behaviors to isInsideReplacedElement().
* editing/TextIterator.h:
(WebCore::isRendererReplacedElement): Add optional parameter TextIteratorBehaviors.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288446 => 288447)


--- trunk/Source/WebCore/ChangeLog	2022-01-24 16:20:20 UTC (rev 288446)
+++ trunk/Source/WebCore/ChangeLog	2022-01-24 16:21:27 UTC (rev 288447)
@@ -1,5 +1,24 @@
 2022-01-24  Carlos Garcia Campos  <[email protected]>
 
+        [GTK][a11y] Only consider links as replaced objects when iterating with EmitsObjectReplacementCharacters
+        https://bugs.webkit.org/show_bug.cgi?id=235474
+
+        Reviewed by Adrian Perez de Castro.
+
+        We don't want to consider links replaced objects in other cases.
+
+        * editing/TextIterator.cpp:
+        (WebCore::isRendererReplacedElement): Add TextIteratorBehaviors parameter to check if
+        EmitsObjectReplacementCharacters is present.
+        (WebCore::TextIterator::advance): Pass m_behaviors to isRendererReplacedElement().
+        (WebCore::SimplifiedBackwardsTextIterator::advance): Ditto.
+        (WebCore::isInsideReplacedElement): Add TextIteratorBehaviors parameter and pass it to isRendererReplacedElement().
+        (WebCore::resolveCharacterRange): Pass behaviors to isInsideReplacedElement().
+        * editing/TextIterator.h:
+        (WebCore::isRendererReplacedElement): Add optional parameter TextIteratorBehaviors.
+
+2022-01-24  Carlos Garcia Campos  <[email protected]>
+
         [GTK][a11y] Do not use heap allocated timers in AccessibilityAtspi
         https://bugs.webkit.org/show_bug.cgi?id=235473
 

Modified: trunk/Source/WebCore/editing/TextIterator.cpp (288446 => 288447)


--- trunk/Source/WebCore/editing/TextIterator.cpp	2022-01-24 16:20:20 UTC (rev 288446)
+++ trunk/Source/WebCore/editing/TextIterator.cpp	2022-01-24 16:21:27 UTC (rev 288447)
@@ -259,7 +259,7 @@
 
 // FIXME: editingIgnoresContent and isRendererReplacedElement try to do the same job.
 // It's not good to have both of them.
-bool isRendererReplacedElement(RenderObject* renderer)
+bool isRendererReplacedElement(RenderObject* renderer, TextIteratorBehaviors behaviors)
 {
     if (!renderer)
         return false;
@@ -279,8 +279,10 @@
             return true;
 #if USE(ATSPI)
         // Links are also replaced with object replacement character in ATSPI.
-        if (element.isLink())
+        if (behaviors.contains(TextIteratorBehavior::EmitsObjectReplacementCharacters) && element.isLink())
             return true;
+#else
+        UNUSED_PARAM(behaviors);
 #endif
     }
 
@@ -474,7 +476,7 @@
                 // handle current node according to its type
                 if (renderer->isText() && m_node->isTextNode())
                     m_handledNode = handleTextNode();
-                else if (isRendererReplacedElement(renderer))
+                else if (isRendererReplacedElement(renderer, m_behaviors))
                     m_handledNode = handleReplacedElement();
                 else
                     m_handledNode = handleNonTextNode();
@@ -1211,7 +1213,7 @@
             if (renderer && renderer->isText() && m_node->isTextNode()) {
                 if (renderer->style().visibility() == Visibility::Visible && m_offset > 0)
                     m_handledNode = handleTextNode();
-            } else if (isRendererReplacedElement(renderer)) {
+            } else if (isRendererReplacedElement(renderer, m_behaviors)) {
                 if (renderer->style().visibility() == Visibility::Visible && m_offset > 0)
                     m_handledNode = handleReplacedElement();
             } else
@@ -2366,12 +2368,12 @@
     return length;
 }
 
-static inline bool isInsideReplacedElement(TextIterator& iterator)
+static inline bool isInsideReplacedElement(TextIterator& iterator, TextIteratorBehaviors behaviors)
 {
     ASSERT(!iterator.atEnd());
     ASSERT(iterator.text().length() == 1);
     Node* node = iterator.node();
-    return node && isRendererReplacedElement(node->renderer());
+    return node && isRendererReplacedElement(node->renderer(), behaviors);
 }
 
 constexpr uint64_t clampedAdd(uint64_t a, uint64_t b)
@@ -2398,7 +2400,7 @@
         if (foundEnd) {
             // FIXME: This is a workaround for the fact that the end of a run is often at the wrong position for emitted '\n's or if the renderer of the current node is a replaced element.
             // FIXME: consider controlling this with TextIteratorBehavior instead of doing it unconditionally to help us eventually phase it out everywhere.
-            if (length == 1 && (it.text()[0] == '\n' || isInsideReplacedElement(it))) {
+            if (length == 1 && (it.text()[0] == '\n' || isInsideReplacedElement(it, behaviors))) {
                 it.advance();
                 if (!it.atEnd())
                     textRunRange.end = it.range().start;

Modified: trunk/Source/WebCore/editing/TextIterator.h (288446 => 288447)


--- trunk/Source/WebCore/editing/TextIterator.h	2022-01-24 16:20:20 UTC (rev 288446)
+++ trunk/Source/WebCore/editing/TextIterator.h	2022-01-24 16:21:27 UTC (rev 288447)
@@ -56,7 +56,7 @@
 WEBCORE_EXPORT String foldQuoteMarks(const String&);
 
 // FIXME: Move this somewhere else in the editing directory. It doesn't belong in the header with TextIterator.
-bool isRendererReplacedElement(RenderObject*);
+bool isRendererReplacedElement(RenderObject*, TextIteratorBehaviors = { });
 
 // FIXME: Move each iterator class into a separate header file.
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to