From 8016adbafa603f029d075bd7c60d053b9c94fad2 Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Thu, 30 May 2024 06:32:20 +0000 Subject: [PATCH] Bug 1896516 Part 8 - Remove nsIScrollableFrame usages under accessible/. r=layout-reviewers,emilio Differential Revision: https://phabricator.services.mozilla.com/D211495 --- accessible/android/DocAccessibleWrap.cpp | 1 - accessible/base/nsCoreUtils.cpp | 15 +++++++++------ accessible/base/nsCoreUtils.h | 5 +++-- accessible/generic/DocAccessible-inl.h | 1 - accessible/generic/HyperTextAccessible.cpp | 5 ++--- accessible/generic/LocalAccessible.cpp | 11 ++++++----- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/accessible/android/DocAccessibleWrap.cpp b/accessible/android/DocAccessibleWrap.cpp index 0e46b5664946..b511a0c7f697 100644 --- a/accessible/android/DocAccessibleWrap.cpp +++ b/accessible/android/DocAccessibleWrap.cpp @@ -9,7 +9,6 @@ #include "DocAccessibleChild.h" #include "DocAccessibleWrap.h" #include "nsIDocShell.h" -#include "nsIScrollableFrame.h" #include "nsLayoutUtils.h" #include "nsAccessibilityService.h" #include "nsAccUtils.h" diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index 3e66fa9c2323..adf3dce65256 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -15,7 +15,6 @@ #include "nsIDocShell.h" #include "nsIObserverService.h" #include "nsPresContext.h" -#include "nsIScrollableFrame.h" #include "nsISelectionController.h" #include "nsISimpleEnumerator.h" #include "mozilla/dom/TouchEvent.h" @@ -24,6 +23,7 @@ #include "mozilla/EventStateManager.h" #include "mozilla/MouseEvents.h" #include "mozilla/PresShell.h" +#include "mozilla/ScrollContainerFrame.h" #include "mozilla/TouchEvents.h" #include "nsView.h" #include "nsGkAtoms.h" @@ -253,21 +253,24 @@ nsresult nsCoreUtils::ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange, return NS_OK; } -void nsCoreUtils::ScrollFrameToPoint(nsIFrame* aScrollableFrame, +void nsCoreUtils::ScrollFrameToPoint(nsIFrame* aScrollContainerFrame, nsIFrame* aFrame, const LayoutDeviceIntPoint& aPoint) { - nsIScrollableFrame* scrollableFrame = do_QueryFrame(aScrollableFrame); - if (!scrollableFrame) return; + ScrollContainerFrame* scrollContainerFrame = + do_QueryFrame(aScrollContainerFrame); + if (!scrollContainerFrame) { + return; + } nsPoint point = LayoutDeviceIntPoint::ToAppUnits( aPoint, aFrame->PresContext()->AppUnitsPerDevPixel()); nsRect frameRect = aFrame->GetScreenRectInAppUnits(); nsPoint deltaPoint = point - frameRect.TopLeft(); - nsPoint scrollPoint = scrollableFrame->GetScrollPosition(); + nsPoint scrollPoint = scrollContainerFrame->GetScrollPosition(); scrollPoint -= deltaPoint; - scrollableFrame->ScrollTo(scrollPoint, ScrollMode::Instant); + scrollContainerFrame->ScrollTo(scrollPoint, ScrollMode::Instant); } void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType, diff --git a/accessible/base/nsCoreUtils.h b/accessible/base/nsCoreUtils.h index 28ead982af66..fe46bf4fdf7d 100644 --- a/accessible/base/nsCoreUtils.h +++ b/accessible/base/nsCoreUtils.h @@ -172,11 +172,12 @@ class nsCoreUtils { * Scrolls the given frame to the point, used for implememntation of * nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint. * - * @param aScrollableFrame the scrollable frame + * @param aScrollContainerFrame the scroll container frame * @param aFrame the frame to scroll * @param aPoint the point scroll to (in dev pixels) */ - static void ScrollFrameToPoint(nsIFrame* aScrollableFrame, nsIFrame* aFrame, + static void ScrollFrameToPoint(nsIFrame* aScrollContainerFrame, + nsIFrame* aFrame, const mozilla::LayoutDeviceIntPoint& aPoint); /** diff --git a/accessible/generic/DocAccessible-inl.h b/accessible/generic/DocAccessible-inl.h index 2e358724cd66..6e4798902516 100644 --- a/accessible/generic/DocAccessible-inl.h +++ b/accessible/generic/DocAccessible-inl.h @@ -12,7 +12,6 @@ #include "nsAccessibilityService.h" #include "NotificationController.h" #include "States.h" -#include "nsIScrollableFrame.h" #include "mozilla/dom/DocumentInlines.h" #ifdef A11Y_LOG diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index eaeba0ccf9d0..d4a441f66739 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -26,7 +26,6 @@ #include "nsContainerFrame.h" #include "nsFrameSelection.h" #include "nsILineIterator.h" -#include "nsIScrollableFrame.h" #include "nsIMathMLFrame.h" #include "nsLayoutUtils.h" #include "nsRange.h" @@ -35,6 +34,7 @@ #include "mozilla/HTMLEditor.h" #include "mozilla/IntegerRange.h" #include "mozilla/PresShell.h" +#include "mozilla/ScrollContainerFrame.h" #include "mozilla/SelectionMovementUtils.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLBRElement.h" @@ -894,8 +894,7 @@ void HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset, bool initialScrolled = false; nsIFrame* parentFrame = frame; while ((parentFrame = parentFrame->GetParent())) { - nsIScrollableFrame* scrollableFrame = do_QueryFrame(parentFrame); - if (scrollableFrame) { + if (parentFrame->IsScrollContainerOrSubclass()) { if (!initialScrolled) { // Scroll substring to the given point. Turn the point into percents // relative scrollable area to use nsCoreUtils::ScrollSubstringTo. diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp index 32d4816ef236..969d09feb56d 100644 --- a/accessible/generic/LocalAccessible.cpp +++ b/accessible/generic/LocalAccessible.cpp @@ -320,10 +320,10 @@ uint64_t LocalAccessible::VisibilityState() const { nsIFrame* parentFrame = curFrame->GetParent(); // If contained by scrollable frame then check that at least 12 pixels // around the object is visible, otherwise the object is offscreen. - nsIScrollableFrame* scrollableFrame = do_QueryFrame(parentFrame); const nscoord kMinPixels = nsPresContext::CSSPixelsToAppUnits(12); - if (scrollableFrame) { - nsRect scrollPortRect = scrollableFrame->GetScrollPortRect(); + if (ScrollContainerFrame* scrollContainerFrame = + do_QueryFrame(parentFrame)) { + nsRect scrollPortRect = scrollContainerFrame->GetScrollPortRect(); nsRect frameRect = nsLayoutUtils::TransformFrameRectToAncestor( frame, frame->GetRectRelativeToSelf(), parentFrame); if (!scrollPortRect.Contains(frameRect)) { @@ -2259,8 +2259,9 @@ Relation LocalAccessible::RelationByType(RelationType aType) const { if (frame) { nsView* view = frame->GetView(); if (view) { - nsIScrollableFrame* scrollFrame = do_QueryFrame(frame); - if (scrollFrame || view->GetWidget() || !frame->GetParent()) { + ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(frame); + if (scrollContainerFrame || view->GetWidget() || + !frame->GetParent()) { rel.AppendTarget(LocalParent()); } }