From c67ce672032e73348b8e9be345244a86f405450f Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Wed, 27 Jan 2021 09:43:00 +0000 Subject: [PATCH] Bug 1688832: part 8) Add `AccessibleCaretManager::Carets::GetSecond`. r=TYLin Differential Revision: https://phabricator.services.mozilla.com/D102924 --- layout/base/AccessibleCaretManager.cpp | 38 +++++++++++++++++----------------- layout/base/AccessibleCaretManager.h | 2 ++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/layout/base/AccessibleCaretManager.cpp b/layout/base/AccessibleCaretManager.cpp index 6618837432a9..0b3a3a3fd684 100644 --- a/layout/base/AccessibleCaretManager.cpp +++ b/layout/base/AccessibleCaretManager.cpp @@ -176,7 +176,7 @@ void AccessibleCaretManager::HideCaretsAndDispatchCaretStateChangedEvent() { if (mCarets.AreLogicallyVisible()) { AC_LOG("%s", __FUNCTION__); mCarets.GetFirst()->SetAppearance(Appearance::None); - mCarets.mSecond->SetAppearance(Appearance::None); + mCarets.GetSecond()->SetAppearance(Appearance::None); mIsCaretPositionChanged = false; DispatchCaretStateChangedEvent(CaretChangedReason::Visibilitychange); } @@ -298,7 +298,7 @@ void AccessibleCaretManager::UpdateCaretsForCursorMode( break; } - mCarets.mSecond->SetAppearance(Appearance::None); + mCarets.GetSecond()->SetAppearance(Appearance::None); mIsCaretPositionChanged = (result == PositionChangedResult::Position); @@ -348,7 +348,7 @@ void AccessibleCaretManager::UpdateCaretsForSelectionMode( PositionChangedResult firstCaretResult = updateSingleCaret(mCarets.GetFirst(), startFrame, startOffset); PositionChangedResult secondCaretResult = - updateSingleCaret(mCarets.mSecond.get(), endFrame, endOffset); + updateSingleCaret(mCarets.GetSecond(), endFrame, endOffset); mIsCaretPositionChanged = firstCaretResult == PositionChangedResult::Position || @@ -412,8 +412,8 @@ void AccessibleCaretManager::DesiredAsyncPanZoomState::Update( ((aAccessibleCaretManager.mCarets.GetFirst()->IsVisuallyVisible() && aAccessibleCaretManager.mCarets.GetFirst() ->IsInPositionFixedSubtree()) || - (aAccessibleCaretManager.mCarets.mSecond->IsVisuallyVisible() && - aAccessibleCaretManager.mCarets.mSecond + (aAccessibleCaretManager.mCarets.GetSecond()->IsVisuallyVisible() && + aAccessibleCaretManager.mCarets.GetSecond() ->IsInPositionFixedSubtree())) ? Value::Disabled : Value::Enabled; @@ -426,19 +426,19 @@ bool AccessibleCaretManager::UpdateCaretsForOverlappingTilt() { return false; } - if (!mCarets.GetFirst()->Intersects(*mCarets.mSecond)) { + if (!mCarets.GetFirst()->Intersects(*mCarets.GetSecond())) { mCarets.GetFirst()->SetAppearance(Appearance::Normal); - mCarets.mSecond->SetAppearance(Appearance::Normal); + mCarets.GetSecond()->SetAppearance(Appearance::Normal); return false; } if (mCarets.GetFirst()->LogicalPosition().x <= - mCarets.mSecond->LogicalPosition().x) { + mCarets.GetSecond()->LogicalPosition().x) { mCarets.GetFirst()->SetAppearance(Appearance::Left); - mCarets.mSecond->SetAppearance(Appearance::Right); + mCarets.GetSecond()->SetAppearance(Appearance::Right); } else { mCarets.GetFirst()->SetAppearance(Appearance::Right); - mCarets.mSecond->SetAppearance(Appearance::Left); + mCarets.GetSecond()->SetAppearance(Appearance::Left); } return true; @@ -458,9 +458,9 @@ void AccessibleCaretManager::UpdateCaretsForAlwaysTilt( ? Appearance::Left : Appearance::Right); } - if (mCarets.mSecond->IsVisuallyVisible()) { + if (mCarets.GetSecond()->IsVisuallyVisible()) { auto endFrameWritingMode = aEndFrame->GetWritingMode(); - mCarets.mSecond->SetAppearance( + mCarets.GetSecond()->SetAppearance( endFrameWritingMode.IsBidiLTR() ? Appearance::Right : Appearance::Left); } } @@ -487,8 +487,8 @@ nsresult AccessibleCaretManager::PressCaret(const nsPoint& aPoint, if (mCarets.GetFirst()->Contains(aPoint, touchArea)) { mActiveCaret = mCarets.GetFirst(); SetSelectionDirection(eDirPrevious); - } else if (mCarets.mSecond->Contains(aPoint, touchArea)) { - mActiveCaret = mCarets.mSecond.get(); + } else if (mCarets.GetSecond()->Contains(aPoint, touchArea)) { + mActiveCaret = mCarets.GetSecond(); SetSelectionDirection(eDirNext); } @@ -789,7 +789,7 @@ void AccessibleCaretManager::OnKeyboardEvent() { void AccessibleCaretManager::OnFrameReconstruction() { mCarets.GetFirst()->EnsureApzAware(); - mCarets.mSecond->EnsureApzAware(); + mCarets.GetSecond()->EnsureApzAware(); } void AccessibleCaretManager::SetLastInputSource(uint16_t aInputSource) { @@ -1209,7 +1209,7 @@ bool AccessibleCaretManager::RestrictCaretDraggingOffsets( if (!StaticPrefs:: layout_accessiblecaret_allow_dragging_across_other_caret()) { if ((mActiveCaret == mCarets.GetFirst() && *cmpToLimit == 1) || - (mActiveCaret == mCarets.mSecond.get() && *cmpToLimit == -1)) { + (mActiveCaret == mCarets.GetSecond() && *cmpToLimit == -1)) { // The active caret's position is past the limit, which we don't allow // here. So set it to the limit, resulting in one character being // selected. @@ -1227,11 +1227,11 @@ bool AccessibleCaretManager::RestrictCaretDraggingOffsets( if (mActiveCaret == mCarets.GetFirst()) { // First caret was moved across the second caret. After making change // to the selection, the user will drag the second caret. - mActiveCaret = mCarets.mSecond.get(); + mActiveCaret = mCarets.GetSecond(); } break; case -1: - if (mActiveCaret == mCarets.mSecond.get()) { + if (mActiveCaret == mCarets.GetSecond()) { // Second caret was moved across the first caret. After making change // to the selection, the user will drag the first caret. mActiveCaret = mCarets.GetFirst(); @@ -1382,7 +1382,7 @@ nsPoint AccessibleCaretManager::AdjustDragBoundary( // (upper bound) of its Y-coordinate is the logical position of the second // caret. if (mActiveCaret == mCarets.GetFirst()) { - nscoord dragDownBoundaryY = mCarets.mSecond->LogicalPosition().y; + nscoord dragDownBoundaryY = mCarets.GetSecond()->LogicalPosition().y; if (dragDownBoundaryY > 0 && adjustedPoint.y > dragDownBoundaryY) { adjustedPoint.y = dragDownBoundaryY; } diff --git a/layout/base/AccessibleCaretManager.h b/layout/base/AccessibleCaretManager.h index 1b61429e77bc..4874dc5ffb51 100644 --- a/layout/base/AccessibleCaretManager.h +++ b/layout/base/AccessibleCaretManager.h @@ -364,6 +364,8 @@ class AccessibleCaretManager { AccessibleCaret* GetFirst() const { return mFirst.get(); } + AccessibleCaret* GetSecond() const { return mSecond.get(); } + // First caret is attached to nsCaret in cursor mode, and is attached to // selection highlight as the left caret in selection mode. UniquePtr mFirst; -- 2.11.4.GIT