|
|
Chromium Code Reviews|
Created:
4 years, 5 months ago by dmazzoni Modified:
4 years, 4 months ago CC:
aboxhall+watch_chromium.org, aboxhall, blink-reviews, chromium-reviews, dmazzoni+watch_chromium.org, dtseng+watch_chromium.org, haraken, je_julie, nektar+watch_chromium.org, yuzo+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionFix visible position calculation in accessible setSelection
The accessible setSelection function is similar to the equivalent APIs to
create a range and set the selection in the DOM, except that offsets are
all visible positions, since the accessibility tree uses visible text
(with whitespace collapsed, for example).
The code that created a VisiblePosition from a text node and offset was
incorrect if the text node had a previous sibling. Fix it so that the
offset of the text node within its container is taken into account.
BUG=626385
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
Committed: https://crrev.com/29605283e274ab1f520a07bce5507b691c117a55
Cr-Commit-Position: refs/heads/master@{#408520}
Patch Set 1 #
Total comments: 1
Patch Set 2 : Return null VisiblePosition #
Total comments: 11
Patch Set 3 : Address some feedback #
Total comments: 1
Patch Set 4 : Revert ChromeVox workaround and update test #
Total comments: 2
Messages
Total messages: 42 (19 generated)
The CQ bit was checked by dmazzoni@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
dmazzoni@chromium.org changed reviewers: + dtseng@chromium.org, ojan@chromium.org
ojan: I need your owners review for EditingUtilities.h If you have time, there might be a better way for us to accomplish what we want. This current fix seems a bit roundabout. Is there a more straightforward way to create a VisiblePosition if I have a text node and the index of a *visible position* in that node?
We already have a function called int AXLayoutObject::indexForVisiblePosition(const VisiblePosition& position) const; Now that blink::indexForVisiblePosition has been introduced, should we remove it? Or, should we update that instead?
Instead of returning bool from toVisiblePosition, could you return a null visible position?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
On 2016/07/20 at 18:58:44, nektar wrote: > We already have a function called > int AXLayoutObject::indexForVisiblePosition(const VisiblePosition& position) const; > Now that blink::indexForVisiblePosition has been introduced, should we remove it? Or, should we update that instead? I didn't introduce it, blink::indexForVisiblePosition was already there and I just exported it. I'd like it if AXLayoutObject::indexForVisiblePosition could call blink::indexForVisiblePosition, but blink::indexForVisiblePosition only takes a ContainerNode, so you can't call it with a Text node directly. I'd like to better understand why.
https://codereview.chromium.org/2164813003/diff/1/third_party/WebKit/LayoutTe... File third_party/WebKit/LayoutTests/accessibility/set-selection-link.html (right): https://codereview.chromium.org/2164813003/diff/1/third_party/WebKit/LayoutTe... third_party/WebKit/LayoutTests/accessibility/set-selection-link.html:22: var range = selection.getRangeAt(0); Can we verify the selection data returned by ax (on the root ax node)?
On 2016/07/20 at 19:04:06, nektar wrote: > Instead of returning bool from toVisiblePosition, could you return a null visible position? Good idea, done.
The CQ bit was checked by dmazzoni@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
ojan@chromium.org changed reviewers: + yoichio@chromium.org, yosin@chromium.org
yosin or yoichio, mind doing this review?
https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Layo... File third_party/WebKit/LayoutTests/accessibility/set-selection-link.html (right): https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/accessibility/set-selection-link.html:14: var axPara = accessibilityController.accessibleElementById("para"); It is better to have assert_not_equals(window.accessibilityController, undefined, 'This test requires accessibilityController'); https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/accessibility/set-selection-link.html:28: <script> You don't need to have hide test sample. Or put |<div id="log"></div>| https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp (right): https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:1994: Please add |DCHECK(node) << obj|. For ease of debugging, it is better to introduce |AXObject* runner| to keep input parameter |obj|. https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:2007: VisiblePosition nodePosition = blink::visiblePositionBeforeNode(*node); I recommend to use |PlainTextRange|, which is used by IME, to map text position to DOM position. If so, this function should return |Position| and rename to |toPosition(AXObject* obj, int offset);
Thanks for the review! I'm having trouble with the PlainTextRange suggestion, below. https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Layo... File third_party/WebKit/LayoutTests/accessibility/set-selection-link.html (right): https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/accessibility/set-selection-link.html:14: var axPara = accessibilityController.accessibleElementById("para"); On 2016/07/27 at 01:31:14, Yosi_UTC9 wrote: > It is better to have > > assert_not_equals(window.accessibilityController, undefined, > 'This test requires accessibilityController'); Done https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/accessibility/set-selection-link.html:28: <script> On 2016/07/27 at 01:31:14, Yosi_UTC9 wrote: > You don't need to have hide test sample. > Or put |<div id="log"></div>| Removed. Is there a way to have multiple ignored sections? This test works fine, but I've had other tests where the HTML snippet used in the test would mess up parsing the test results. https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp (right): https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:1994: On 2016/07/27 at 01:31:14, Yosi_UTC9 wrote: > Please add |DCHECK(node) << obj|. > For ease of debugging, it is better to introduce |AXObject* runner| to keep input parameter |obj|. I changed to using a runner, good idea. Rather than DCHECK, I'll just check for null |node| because I think there are probably obscure cases where that could happen, like if this gets called during teardown. https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:2007: VisiblePosition nodePosition = blink::visiblePositionBeforeNode(*node); On 2016/07/27 at 01:31:14, Yosi_UTC9 wrote: > I recommend to use |PlainTextRange|, which is used by IME, to map text position to DOM position. > If so, this function should return |Position| and rename to |toPosition(AXObject* obj, int offset); I can't figure out how using PlainTextRange will make this easier. Suppose that both the start and end of my selection are in different Text nodes. In order to use PlainTextRange, I still need to pass it a ContainerNode, which means I have to figure out the starting index of this node within its container node. Am I missing something? I think the difference is that IME is always dealing with the plain text of an editable text control. All of the selection offsets are relative to the root editable element. With accessibility we also have the case where the client wants to set a range with an arbitrary start and end position, which can be in arbitrary text nodes in the tree. I don't think PlainTextRange was meant for that. I'm hoping there might be a better way than what I have now, though. Another option would be to use a TextIterator, but that seems more low-level.
https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp (right): https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:2007: VisiblePosition nodePosition = blink::visiblePositionBeforeNode(*node); On 2016/07/27 at 06:45:17, dmazzoni wrote: > On 2016/07/27 at 01:31:14, Yosi_UTC9 wrote: > > I recommend to use |PlainTextRange|, which is used by IME, to map text position to DOM position. > > If so, this function should return |Position| and rename to |toPosition(AXObject* obj, int offset); > > I can't figure out how using PlainTextRange will make this easier. > > Suppose that both the start and end of my selection are in different > Text nodes. In order to use PlainTextRange, I still need to pass it a ContainerNode, which means I have to figure out the starting index of this node within its container node. > > Am I missing something? > > I think the difference is that IME is always dealing with the plain text of an editable text control. All of the selection offsets are relative to the root editable element. > > With accessibility we also have the case where the client wants to set a range with an arbitrary start and end position, which can be in arbitrary text nodes in the tree. I don't think PlainTextRange was meant for that. > > I'm hoping there might be a better way than what I have now, though. > > Another option would be to use a TextIterator, but that seems more low-level. I thinkg following code is identical to this sequence: const PlaintTextRange& textRange(offset); const EphemeralRange& range = range.createRange(parent); return VisbilePosition(range.startPosition()); https://codereview.chromium.org/2164813003/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp (right): https://codereview.chromium.org/2164813003/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:2054: frame->selection().setSelection(VisibleSelection(anchorVisiblePosition, focusVisiblePosition)); Could you pass |Position| instead of |VisiblePositon|? Since |VisiblePosition| constructor attempts to update layout, we would like to avoid to reduce usage of VisaiblePosition.
https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp (right): https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:2007: VisiblePosition nodePosition = blink::visiblePositionBeforeNode(*node); > I thinkg following code is identical to this sequence: > > const PlaintTextRange& textRange(offset); > const EphemeralRange& range = range.createRange(parent); > return VisbilePosition(range.startPosition()); I just tried it, it doesn't work because it assumes |node| is the first child of |parent|. |offset| is an offset into the text of |node|, but |parent| may have multiple children.
lgtm Sorry for confusion. It seems we should use indexForVisiblePosition() and visiblePositionForIndex(). Editing should provide better function than them... https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp (right): https://codereview.chromium.org/2164813003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp:2007: VisiblePosition nodePosition = blink::visiblePositionBeforeNode(*node); On 2016/07/27 at 07:49:22, dmazzoni wrote: > > I thinkg following code is identical to this sequence: > > > > const PlaintTextRange& textRange(offset); > > const EphemeralRange& range = range.createRange(parent); > > return VisbilePosition(range.startPosition()); > > I just tried it, it doesn't work because it assumes |node| > is the first child of |parent|. |offset| is an offset into > the text of |node|, but |parent| may have multiple children. I see, |offset| is visible offset in |node| instead of visible offset in |parent|.
No problem, thanks. If you end up adding new editing APIs in the future that might make this easier, let me know.
The CQ bit was checked by dmazzoni@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by ojan@chromium.org
lgtm
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Description was changed from ========== Fix visible position calculation in accessible setSelection The accessible setSelection function is similar to the equivalent APIs to create a range and set the selection in the DOM, except that offsets are all visible positions, since the accessibility tree uses visible text (with whitespace collapsed, for example). The code that created a VisiblePosition from a text node and offset was incorrect if the text node had a previous sibling. Fix it so that the offset of the text node within its container is taken into account. BUG=626385 ========== to ========== Fix visible position calculation in accessible setSelection The accessible setSelection function is similar to the equivalent APIs to create a range and set the selection in the DOM, except that offsets are all visible positions, since the accessibility tree uses visible text (with whitespace collapsed, for example). The code that created a VisiblePosition from a text node and offset was incorrect if the text node had a previous sibling. Fix it so that the offset of the text node within its container is taken into account. BUG=626385 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ==========
The CQ bit was checked by dmazzoni@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from yosin@chromium.org, ojan@chromium.org Link to the patchset: https://codereview.chromium.org/2164813003/#ps60001 (title: "Revert ChromeVox workaround and update test")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #4 (id:60001)
Message was sent while issue was closed.
Description was changed from ========== Fix visible position calculation in accessible setSelection The accessible setSelection function is similar to the equivalent APIs to create a range and set the selection in the DOM, except that offsets are all visible positions, since the accessibility tree uses visible text (with whitespace collapsed, for example). The code that created a VisiblePosition from a text node and offset was incorrect if the text node had a previous sibling. Fix it so that the offset of the text node within its container is taken into account. BUG=626385 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ========== to ========== Fix visible position calculation in accessible setSelection The accessible setSelection function is similar to the equivalent APIs to create a range and set the selection in the DOM, except that offsets are all visible positions, since the accessibility tree uses visible text (with whitespace collapsed, for example). The code that created a VisiblePosition from a text node and offset was incorrect if the text node had a previous sibling. Fix it so that the offset of the text node within its container is taken into account. BUG=626385 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation Committed: https://crrev.com/29605283e274ab1f520a07bce5507b691c117a55 Cr-Commit-Position: refs/heads/master@{#408520} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/29605283e274ab1f520a07bce5507b691c117a55 Cr-Commit-Position: refs/heads/master@{#408520}
Message was sent while issue was closed.
aboxhall@chromium.org changed reviewers: + aboxhall@chromium.org
Message was sent while issue was closed.
lgtm
Message was sent while issue was closed.
This cl helps, but it still doesn't fix some of the cases that work in the DOM. I've marked two places in the ChromeVox test. Also, indexing into children e.g. selecting a non-leaf text node, doesn't always work. Can we get a mini-spec going? I can write one up if needed, but it should pull directly from the DOM's specification of how selection works. https://codereview.chromium.org/2164813003/diff/60001/chrome/browser/resource... File chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors_test.extjs (right): https://codereview.chromium.org/2164813003/diff/60001/chrome/browser/resource... chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors_test.extjs:400: assertEquals(testNode, root.anchorObject); FYI; this is still wrong. https://codereview.chromium.org/2164813003/diff/60001/chrome/browser/resource... chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors_test.extjs:402: assertEquals(4, root.anchorOffset); As is this. The selection is on the ofSelection node. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
