Bug 232622 - [GTK][a11y] Embedded objects are not correctly handled by text interface with ATSPI
Summary: [GTK][a11y] Embedded objects are not correctly handled by text interface with...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks: ATSPI 232707 232708
  Show dependency treegraph
 
Reported: 2021-11-02 07:11 PDT by Carlos Garcia Campos
Modified: 2021-11-05 01:22 PDT (History)
11 users (show)

See Also:


Attachments
Patch (12.34 KB, patch)
2021-11-02 07:17 PDT, Carlos Garcia Campos
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (12.34 KB, patch)
2021-11-02 07:39 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (13.39 KB, patch)
2021-11-04 07:10 PDT, Carlos Garcia Campos
andresg_22: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2021-11-02 07:11:36 PDT
We are not correctly handling embedded objects (replaced elements) when converting text offsets to/from visible position.
Comment 1 Carlos Garcia Campos 2021-11-02 07:17:06 PDT
Created attachment 443086 [details]
Patch
Comment 2 Carlos Garcia Campos 2021-11-02 07:39:31 PDT
Created attachment 443088 [details]
Patch
Comment 3 Andres Gonzalez 2021-11-04 06:37:34 PDT
(In reply to Carlos Garcia Campos from comment #2)
> Created attachment 443088 [details]
> Patch

--- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
+++ a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
@@ -2145,7 +2145,12 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForIndex(int index) co
     if (!node)
         return VisiblePosition();

+#if USE(ATSPI)
+    // We need to consider replaced elements for GTK, as they will be presented with the 'object replacement character' (0xFFFC).
+    return { makeDeprecatedLegacyPosition(resolveCharacterLocation(makeRangeSelectingNodeContents(*node), index, TextIteratorBehavior::EmitsObjectReplacementCharacters)) };

Can we use 

VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope)

in editing.cpp adding a TextIteratorBehaviors parameter to it?
Comment 4 Carlos Garcia Campos 2021-11-04 06:42:47 PDT
(In reply to Andres Gonzalez from comment #3)
> (In reply to Carlos Garcia Campos from comment #2)
> > Created attachment 443088 [details]
> > Patch
> 
> --- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
> +++ a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
> @@ -2145,7 +2145,12 @@ VisiblePosition
> AccessibilityRenderObject::visiblePositionForIndex(int index) co
>      if (!node)
>          return VisiblePosition();
> 
> +#if USE(ATSPI)
> +    // We need to consider replaced elements for GTK, as they will be
> presented with the 'object replacement character' (0xFFFC).
> +    return {
> makeDeprecatedLegacyPosition(resolveCharacterLocation(makeRangeSelectingNodeC
> ontents(*node), index,
> TextIteratorBehavior::EmitsObjectReplacementCharacters)) };
> 
> Can we use 
> 
> VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope)
> 
> in editing.cpp adding a TextIteratorBehaviors parameter to it?

That was my initial idea, but it expects ContainerNode while we have just a Node and I'm not sure it's ok to change visiblePositionForIndex to receive a Node.
Comment 5 Andres Gonzalez 2021-11-04 06:50:51 PDT
(In reply to Carlos Garcia Campos from comment #4)
> (In reply to Andres Gonzalez from comment #3)
> > (In reply to Carlos Garcia Campos from comment #2)
> > > Created attachment 443088 [details]
> > > Patch
> > 
> > --- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
> > +++ a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
> > @@ -2145,7 +2145,12 @@ VisiblePosition
> > AccessibilityRenderObject::visiblePositionForIndex(int index) co
> >      if (!node)
> >          return VisiblePosition();
> > 
> > +#if USE(ATSPI)
> > +    // We need to consider replaced elements for GTK, as they will be
> > presented with the 'object replacement character' (0xFFFC).
> > +    return {
> > makeDeprecatedLegacyPosition(resolveCharacterLocation(makeRangeSelectingNodeC
> > ontents(*node), index,
> > TextIteratorBehavior::EmitsObjectReplacementCharacters)) };
> > 
> > Can we use 
> > 
> > VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope)
> > 
> > in editing.cpp adding a TextIteratorBehaviors parameter to it?
> 
> That was my initial idea, but it expects ContainerNode while we have just a
> Node and I'm not sure it's ok to change visiblePositionForIndex to receive a
> Node.

It should be ok since it is only used for

SimpleRange makeRangeSelectingNodeContents(Node& node)
Comment 6 Carlos Garcia Campos 2021-11-04 06:53:54 PDT
(In reply to Andres Gonzalez from comment #5)
> (In reply to Carlos Garcia Campos from comment #4)
> > (In reply to Andres Gonzalez from comment #3)
> > > (In reply to Carlos Garcia Campos from comment #2)
> > > > Created attachment 443088 [details]
> > > > Patch
> > > 
> > > --- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
> > > +++ a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
> > > @@ -2145,7 +2145,12 @@ VisiblePosition
> > > AccessibilityRenderObject::visiblePositionForIndex(int index) co
> > >      if (!node)
> > >          return VisiblePosition();
> > > 
> > > +#if USE(ATSPI)
> > > +    // We need to consider replaced elements for GTK, as they will be
> > > presented with the 'object replacement character' (0xFFFC).
> > > +    return {
> > > makeDeprecatedLegacyPosition(resolveCharacterLocation(makeRangeSelectingNodeC
> > > ontents(*node), index,
> > > TextIteratorBehavior::EmitsObjectReplacementCharacters)) };
> > > 
> > > Can we use 
> > > 
> > > VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope)
> > > 
> > > in editing.cpp adding a TextIteratorBehaviors parameter to it?
> > 
> > That was my initial idea, but it expects ContainerNode while we have just a
> > Node and I'm not sure it's ok to change visiblePositionForIndex to receive a
> > Node.
> 
> It should be ok since it is only used for
> 
> SimpleRange makeRangeSelectingNodeContents(Node& node)

Ok! I'll do it
Comment 7 Andres Gonzalez 2021-11-04 06:57:35 PDT
Why the TextIteratorBehaviors need to be different for ATSPI vx. ATK or Mac? This should all be platform independent. Not saying that you should make it platform-independent, but just want to understand the differences.
Comment 8 Carlos Garcia Campos 2021-11-04 07:10:33 PDT
Created attachment 443302 [details]
Patch
Comment 9 Carlos Garcia Campos 2021-11-04 07:13:50 PDT
(In reply to Andres Gonzalez from comment #7)
> Why the TextIteratorBehaviors need to be different for ATSPI vx. ATK or Mac?
> This should all be platform independent. Not saying that you should make it
> platform-independent, but just want to understand the differences.

I don't know how it's expected to behave in mac, it should be the same for ATK and ATSPI, but I don't want to change the ATK behavior in this patch. The handling of replaced objects is already broken in ATK and fixing it would require more changes not included in this patch. The new ATSPI implementation will replace the ATK one, so I don't plan to fix ATK at this point.
Comment 10 Carlos Garcia Campos 2021-11-05 01:22:50 PDT
Committed r285339 (243900@main): <https://commits.webkit.org/243900@main>