mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1688832: part 4) Add AccessibleCaretManager::Carets::GetFirst
. r=smaug
Will help to hide the `UniquePtr`s. Depends on D103310 Differential Revision: https://phabricator.services.mozilla.com/D103311
This commit is contained in:
parent
6cc1ec1655
commit
b0ddf0f1e6
@ -173,7 +173,7 @@ nsresult AccessibleCaretManager::OnSelectionChanged(Document* aDoc,
|
||||
void AccessibleCaretManager::HideCaretsAndDispatchCaretStateChangedEvent() {
|
||||
if (mCarets.HasLogicallyVisibleCaret()) {
|
||||
AC_LOG("%s", __FUNCTION__);
|
||||
mCarets.mFirst->SetAppearance(Appearance::None);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::None);
|
||||
mCarets.mSecond->SetAppearance(Appearance::None);
|
||||
mIsCaretPositionChanged = false;
|
||||
DispatchCaretStateChangedEvent(CaretChangedReason::Visibilitychange);
|
||||
@ -258,7 +258,7 @@ void AccessibleCaretManager::UpdateCaretsForCursorMode(
|
||||
return;
|
||||
}
|
||||
|
||||
PositionChangedResult result = mCarets.mFirst->SetPosition(frame, offset);
|
||||
PositionChangedResult result = mCarets.GetFirst()->SetPosition(frame, offset);
|
||||
|
||||
switch (result) {
|
||||
case PositionChangedResult::NotChanged:
|
||||
@ -266,15 +266,15 @@ void AccessibleCaretManager::UpdateCaretsForCursorMode(
|
||||
case PositionChangedResult::Zoom:
|
||||
if (!aHints.contains(UpdateCaretsHint::RespectOldAppearance)) {
|
||||
if (HasNonEmptyTextContent(GetEditingHostForFrame(frame))) {
|
||||
mCarets.mFirst->SetAppearance(Appearance::Normal);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::Normal);
|
||||
} else if (
|
||||
StaticPrefs::
|
||||
layout_accessiblecaret_caret_shown_when_long_tapping_on_empty_content()) {
|
||||
if (mCarets.mFirst->IsLogicallyVisible()) {
|
||||
if (mCarets.GetFirst()->IsLogicallyVisible()) {
|
||||
// Possible cases are: 1) SelectWordOrShortcut() sets the
|
||||
// appearance to Normal. 2) When the caret is out of viewport and
|
||||
// now scrolling into viewport, it has appearance NormalNotShown.
|
||||
mCarets.mFirst->SetAppearance(Appearance::Normal);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::Normal);
|
||||
} else {
|
||||
// Possible cases are: a) Single tap on current empty content;
|
||||
// OnSelectionChanged() sets the appearance to None due to
|
||||
@ -286,13 +286,13 @@ void AccessibleCaretManager::UpdateCaretsForCursorMode(
|
||||
// to NormalNotShown here like the default update behavior.
|
||||
}
|
||||
} else {
|
||||
mCarets.mFirst->SetAppearance(Appearance::NormalNotShown);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::NormalNotShown);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PositionChangedResult::Invisible:
|
||||
mCarets.mFirst->SetAppearance(Appearance::NormalNotShown);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::NormalNotShown);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ void AccessibleCaretManager::UpdateCaretsForSelectionMode(
|
||||
};
|
||||
|
||||
PositionChangedResult firstCaretResult =
|
||||
updateSingleCaret(mCarets.mFirst.get(), startFrame, startOffset);
|
||||
updateSingleCaret(mCarets.GetFirst(), startFrame, startOffset);
|
||||
PositionChangedResult secondCaretResult =
|
||||
updateSingleCaret(mCarets.mSecond.get(), endFrame, endOffset);
|
||||
|
||||
@ -399,42 +399,44 @@ void AccessibleCaretManager::DesiredAsyncPanZoomState::Update(
|
||||
break;
|
||||
case CaretMode::Cursor:
|
||||
mValue =
|
||||
(aAccessibleCaretManager.mCarets.mFirst->IsVisuallyVisible() &&
|
||||
aAccessibleCaretManager.mCarets.mFirst->IsInPositionFixedSubtree())
|
||||
(aAccessibleCaretManager.mCarets.GetFirst()->IsVisuallyVisible() &&
|
||||
aAccessibleCaretManager.mCarets.GetFirst()
|
||||
->IsInPositionFixedSubtree())
|
||||
? Value::Disabled
|
||||
: Value::Enabled;
|
||||
break;
|
||||
case CaretMode::Selection:
|
||||
mValue = ((aAccessibleCaretManager.mCarets.mFirst->IsVisuallyVisible() &&
|
||||
aAccessibleCaretManager.mCarets.mFirst
|
||||
->IsInPositionFixedSubtree()) ||
|
||||
(aAccessibleCaretManager.mCarets.mSecond->IsVisuallyVisible() &&
|
||||
aAccessibleCaretManager.mCarets.mSecond
|
||||
->IsInPositionFixedSubtree()))
|
||||
? Value::Disabled
|
||||
: Value::Enabled;
|
||||
mValue =
|
||||
((aAccessibleCaretManager.mCarets.GetFirst()->IsVisuallyVisible() &&
|
||||
aAccessibleCaretManager.mCarets.GetFirst()
|
||||
->IsInPositionFixedSubtree()) ||
|
||||
(aAccessibleCaretManager.mCarets.mSecond->IsVisuallyVisible() &&
|
||||
aAccessibleCaretManager.mCarets.mSecond
|
||||
->IsInPositionFixedSubtree()))
|
||||
? Value::Disabled
|
||||
: Value::Enabled;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool AccessibleCaretManager::UpdateCaretsForOverlappingTilt() {
|
||||
if (!mCarets.mFirst->IsVisuallyVisible() ||
|
||||
if (!mCarets.GetFirst()->IsVisuallyVisible() ||
|
||||
!mCarets.mSecond->IsVisuallyVisible()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mCarets.mFirst->Intersects(*mCarets.mSecond)) {
|
||||
mCarets.mFirst->SetAppearance(Appearance::Normal);
|
||||
if (!mCarets.GetFirst()->Intersects(*mCarets.mSecond)) {
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::Normal);
|
||||
mCarets.mSecond->SetAppearance(Appearance::Normal);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mCarets.mFirst->LogicalPosition().x <=
|
||||
if (mCarets.GetFirst()->LogicalPosition().x <=
|
||||
mCarets.mSecond->LogicalPosition().x) {
|
||||
mCarets.mFirst->SetAppearance(Appearance::Left);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::Left);
|
||||
mCarets.mSecond->SetAppearance(Appearance::Right);
|
||||
} else {
|
||||
mCarets.mFirst->SetAppearance(Appearance::Right);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::Right);
|
||||
mCarets.mSecond->SetAppearance(Appearance::Left);
|
||||
}
|
||||
|
||||
@ -449,11 +451,11 @@ void AccessibleCaretManager::UpdateCaretsForAlwaysTilt(
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCarets.mFirst->IsVisuallyVisible()) {
|
||||
if (mCarets.GetFirst()->IsVisuallyVisible()) {
|
||||
auto startFrameWritingMode = aStartFrame->GetWritingMode();
|
||||
mCarets.mFirst->SetAppearance(startFrameWritingMode.IsBidiLTR()
|
||||
? Appearance::Left
|
||||
: Appearance::Right);
|
||||
mCarets.GetFirst()->SetAppearance(startFrameWritingMode.IsBidiLTR()
|
||||
? Appearance::Left
|
||||
: Appearance::Right);
|
||||
}
|
||||
if (mCarets.mSecond->IsVisuallyVisible()) {
|
||||
auto endFrameWritingMode = aEndFrame->GetWritingMode();
|
||||
@ -481,8 +483,8 @@ nsresult AccessibleCaretManager::PressCaret(const nsPoint& aPoint,
|
||||
TouchArea touchArea =
|
||||
aEventClass == eMouseEventClass ? TouchArea::CaretImage : TouchArea::Full;
|
||||
|
||||
if (mCarets.mFirst->Contains(aPoint, touchArea)) {
|
||||
mActiveCaret = mCarets.mFirst.get();
|
||||
if (mCarets.GetFirst()->Contains(aPoint, touchArea)) {
|
||||
mActiveCaret = mCarets.GetFirst();
|
||||
SetSelectionDirection(eDirPrevious);
|
||||
} else if (mCarets.mSecond->Contains(aPoint, touchArea)) {
|
||||
mActiveCaret = mCarets.mSecond.get();
|
||||
@ -601,7 +603,7 @@ nsresult AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint) {
|
||||
|
||||
if (StaticPrefs::
|
||||
layout_accessiblecaret_caret_shown_when_long_tapping_on_empty_content()) {
|
||||
mCarets.mFirst->SetAppearance(Appearance::Normal);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::Normal);
|
||||
}
|
||||
// We need to update carets to get correct information before dispatching
|
||||
// CaretStateChangedEvent.
|
||||
@ -661,7 +663,7 @@ nsresult AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint) {
|
||||
|
||||
if (StaticPrefs::
|
||||
layout_accessiblecaret_caret_shown_when_long_tapping_on_empty_content()) {
|
||||
mCarets.mFirst->SetAppearance(Appearance::Normal);
|
||||
mCarets.GetFirst()->SetAppearance(Appearance::Normal);
|
||||
}
|
||||
|
||||
UpdateCarets();
|
||||
@ -714,7 +716,7 @@ void AccessibleCaretManager::OnScrollEnd() {
|
||||
mIsScrollStarted = false;
|
||||
|
||||
if (GetCaretMode() == CaretMode::Cursor) {
|
||||
if (!mCarets.mFirst->IsLogicallyVisible()) {
|
||||
if (!mCarets.GetFirst()->IsLogicallyVisible()) {
|
||||
// If the caret is hidden (Appearance::None) due to blur, no
|
||||
// need to update it.
|
||||
return;
|
||||
@ -785,7 +787,7 @@ void AccessibleCaretManager::OnKeyboardEvent() {
|
||||
}
|
||||
|
||||
void AccessibleCaretManager::OnFrameReconstruction() {
|
||||
mCarets.mFirst->EnsureApzAware();
|
||||
mCarets.GetFirst()->EnsureApzAware();
|
||||
mCarets.mSecond->EnsureApzAware();
|
||||
}
|
||||
|
||||
@ -1136,7 +1138,7 @@ bool AccessibleCaretManager::RestrictCaretDraggingOffsets(
|
||||
MOZ_ASSERT(GetCaretMode() == CaretMode::Selection);
|
||||
|
||||
nsDirection dir =
|
||||
mActiveCaret == mCarets.mFirst.get() ? eDirPrevious : eDirNext;
|
||||
mActiveCaret == mCarets.GetFirst() ? eDirPrevious : eDirNext;
|
||||
int32_t offset = 0;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
int32_t contentOffset = 0;
|
||||
@ -1187,7 +1189,7 @@ bool AccessibleCaretManager::RestrictCaretDraggingOffsets(
|
||||
|
||||
if (!StaticPrefs::
|
||||
layout_accessiblecaret_allow_dragging_across_other_caret()) {
|
||||
if ((mActiveCaret == mCarets.mFirst.get() && *cmpToLimit == 1) ||
|
||||
if ((mActiveCaret == mCarets.GetFirst() && *cmpToLimit == 1) ||
|
||||
(mActiveCaret == mCarets.mSecond.get() && *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
|
||||
@ -1203,7 +1205,7 @@ bool AccessibleCaretManager::RestrictCaretDraggingOffsets(
|
||||
SetOffsetsToLimit();
|
||||
break;
|
||||
case 1:
|
||||
if (mActiveCaret == mCarets.mFirst.get()) {
|
||||
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();
|
||||
@ -1213,7 +1215,7 @@ bool AccessibleCaretManager::RestrictCaretDraggingOffsets(
|
||||
if (mActiveCaret == mCarets.mSecond.get()) {
|
||||
// Second caret was moved across the first caret. After making change
|
||||
// to the selection, the user will drag the first caret.
|
||||
mActiveCaret = mCarets.mFirst.get();
|
||||
mActiveCaret = mCarets.GetFirst();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1360,13 +1362,13 @@ nsPoint AccessibleCaretManager::AdjustDragBoundary(
|
||||
// caret. Likewise, when dragging the first caret, the horizontal boundary
|
||||
// (upper bound) of its Y-coordinate is the logical position of the second
|
||||
// caret.
|
||||
if (mActiveCaret == mCarets.mFirst.get()) {
|
||||
if (mActiveCaret == mCarets.GetFirst()) {
|
||||
nscoord dragDownBoundaryY = mCarets.mSecond->LogicalPosition().y;
|
||||
if (dragDownBoundaryY > 0 && adjustedPoint.y > dragDownBoundaryY) {
|
||||
adjustedPoint.y = dragDownBoundaryY;
|
||||
}
|
||||
} else {
|
||||
nscoord dragUpBoundaryY = mCarets.mFirst->LogicalPosition().y;
|
||||
nscoord dragUpBoundaryY = mCarets.GetFirst()->LogicalPosition().y;
|
||||
if (adjustedPoint.y < dragUpBoundaryY) {
|
||||
adjustedPoint.y = dragUpBoundaryY;
|
||||
}
|
||||
|
@ -315,6 +315,8 @@ class AccessibleCaretManager {
|
||||
PresShell* MOZ_NON_OWNING_REF mPresShell = nullptr;
|
||||
|
||||
struct Carets {
|
||||
AccessibleCaret* GetFirst() const { return mFirst.get(); }
|
||||
|
||||
bool HasLogicallyVisibleCaret() const {
|
||||
return mFirst->IsLogicallyVisible() || mSecond->IsLogicallyVisible();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user