diff --git a/accessible/base/SelectionManager.cpp b/accessible/base/SelectionManager.cpp index 9edd5e628b82e..2665d01b67fae 100644 --- a/accessible/base/SelectionManager.cpp +++ b/accessible/base/SelectionManager.cpp @@ -1228,17 +1228,6 @@ mCaretOffset 1 ) { -TextLeafPoint -caret -= -TextLeafPoint -: -: -GetCaret -( -caretCntr -) -; RefPtr < AccCaretMoveEvent @@ -1256,9 +1245,12 @@ selection IsCollapsed ( ) -caret -. -mIsEndOfLineInsertionPoint +caretCntr +- +> +IsCaretAtEndOfLine +( +) event - > diff --git a/accessible/base/TextLeafRange.cpp b/accessible/base/TextLeafRange.cpp index ba2924f0bafc2..180610a1fad27 100644 --- a/accessible/base/TextLeafRange.cpp +++ b/accessible/base/TextLeafRange.cpp @@ -7285,6 +7285,16 @@ Accessible aAcc ) { +HyperTextAccessibleBase +* +ht +; +int32_t +htOffset +; +bool +isEndOfLine +; if ( LocalAccessible @@ -7337,8 +7347,6 @@ caret events ) . -HyperTextAccessible -* ht = HyperTextFor @@ -7358,7 +7366,6 @@ TextLeafPoint ) ; } -int32_t htOffset = ht @@ -7383,198 +7390,55 @@ TextLeafPoint ) ; } -TextLeafPoint -point -= -ht -- -> -ToTextLeafPoint -( -htOffset -) -; -nsIFrame -* -frame -= -ht -- -> -GetFrame -( -) -; -RefPtr -< -nsFrameSelection -> -sel -= -frame -? -frame -- -> -GetFrameSelection -( -) -: -nullptr -; -if -( -sel -& -& -sel -- -> -GetHint -( -) -= -= -CaretAssociationHint -: -: -Before -) -{ / / -CaretAssociationHint +Use +HyperTextAccessible : : -Before -can -mean -that -the -caret -is -at -the -end -of +IsCaretAtEndOfLine +. +Eventually +we +' +ll +want +to / / -a -line -. -However -it -can -also -mean +move that -the -caret -is -before -the -start +code +into +TextLeafPoint +but +existing +code +depends +on +it +living / / -of -a -node in -the -middle -of -a -line -. -This -happens -when -moving -the -cursor -/ -/ -forward -to -a -new -node -. -if +HyperTextAccessible ( -point -. -mOffset -= -= -0 -) -{ -/ -/ -The -caret -is -before -the -start -of -a -node -. -The +including caret -is -at -the -end -of -a -/ -/ -line -if -the -node -is -at -the -start -of -a -line -but -not -at -the -start -of -a -/ -/ -paragraph -. -point +events +) . -mIsEndOfLineInsertionPoint +isEndOfLine = -IsLocalAccAtLineStart -( -point -. -mAcc +localAcc - > -AsLocal +AsHyperText ( ) -) -& -& -! -point -. -IsParagraphStart +- +> +IsCaretAtEndOfLine ( ) ; @@ -7583,40 +7447,6 @@ else { / / -This -isn -' -t -the -start -of -a -node -so -we -must -be -at -the -end -of -a -line -. -point -. -mIsEndOfLineInsertionPoint -= -true -; -} -} -return -point -; -} -/ -/ Ideally we ' @@ -7655,11 +7485,14 @@ Document ( ) ; -auto -[ +std +: +: +tie +( ht htOffset -] +) = remoteDoc - @@ -7680,6 +7513,16 @@ TextLeafPoint ) ; } +isEndOfLine += +remoteDoc +- +> +IsCaretAtEndOfLine +( +) +; +} TextLeafPoint point = @@ -7695,12 +7538,7 @@ point . mIsEndOfLineInsertionPoint = -remoteDoc -- -> -IsCaretAtEndOfLine -( -) +isEndOfLine ; return point diff --git a/accessible/generic/HyperTextAccessible-inl.h b/accessible/generic/HyperTextAccessible-inl.h index d4df6cc5c8dfb..0f38914047d3e 100644 --- a/accessible/generic/HyperTextAccessible-inl.h +++ b/accessible/generic/HyperTextAccessible-inl.h @@ -208,6 +208,44 @@ aOffset ; } inline +bool +HyperTextAccessible +: +: +IsCaretAtEndOfLine +( +) +const +{ +RefPtr +< +nsFrameSelection +> +frameSelection += +FrameSelection +( +) +; +return +frameSelection +& +& +frameSelection +- +> +GetHint +( +) += += +CaretAssociationHint +: +: +Before +; +} +inline already_AddRefed < nsFrameSelection diff --git a/accessible/generic/HyperTextAccessible.h b/accessible/generic/HyperTextAccessible.h index 1375d6d45da24..7560b84a04074 100644 --- a/accessible/generic/HyperTextAccessible.h +++ b/accessible/generic/HyperTextAccessible.h @@ -1220,6 +1220,28 @@ nsIWidget aWidget ) ; +/ +* +* +* +Return +true +if +caret +is +at +end +of +line +. +* +/ +bool +IsCaretAtEndOfLine +( +) +const +; virtual int32_t SelectionCount diff --git a/accessible/tests/browser/text/browser_text_caret.js b/accessible/tests/browser/text/browser_text_caret.js index 6caa2e9bb639f..fa5c0ee8fd7b4 100644 --- a/accessible/tests/browser/text/browser_text_caret.js +++ b/accessible/tests/browser/text/browser_text_caret.js @@ -150,28 +150,6 @@ empty / textarea > -< -div -id -= -" -contentEditable -" -contenteditable -> -a -< -span -> -b -< -/ -span -> -< -/ -div -> async function ( @@ -1260,172 +1238,6 @@ line " ) ; -const -contentEditable -= -findAccessibleChildByID -( -docAcc -" -contentEditable -" -[ -nsIAccessibleText -] -) -; -caretMoved -= -waitForEvent -( -EVENT_TEXT_CARET_MOVED -contentEditable -) -; -contentEditable -. -takeFocus -( -) -; -evt -= -await -caretMoved -; -is -( -contentEditable -. -caretOffset -0 -" -Initial -caret -offset -in -contentEditable -is -0 -" -) -; -evt -. -QueryInterface -( -nsIAccessibleCaretMoveEvent -) -; -ok -( -! -evt -. -isAtEndOfLine -" -Caret -is -not -at -end -of -line -" -) -; -testTextAtOffset -( -kCaretOffset -BOUNDARY_CHAR -" -a -" -0 -1 -contentEditable -kOk -kOk -kOk -) -; -caretMoved -= -waitForEvent -( -EVENT_TEXT_CARET_MOVED -contentEditable -) -; -EventUtils -. -synthesizeKey -( -" -KEY_ArrowRight -" -) -; -evt -= -await -caretMoved -; -is -( -contentEditable -. -caretOffset -1 -" -Caret -offset -is -1 -after -ArrowRight -" -) -; -evt -. -QueryInterface -( -nsIAccessibleCaretMoveEvent -) -; -ok -( -! -evt -. -isAtEndOfLine -" -Caret -is -not -at -end -of -line -" -) -; -testTextAtOffset -( -kCaretOffset -BOUNDARY_CHAR -" -b -" -1 -2 -contentEditable -kOk -kOk -kOk -) -; } { chrome