Bug 1896516 Part 8 - Remove nsIScrollableFrame usages under accessible/. r=layout-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D211495
This commit is contained in:
Ting-Yu Lin 2024-05-30 06:32:20 +00:00
parent 6306934820
commit 8016adbafa
6 changed files with 20 additions and 18 deletions

View file

@ -9,7 +9,6 @@
#include "DocAccessibleChild.h" #include "DocAccessibleChild.h"
#include "DocAccessibleWrap.h" #include "DocAccessibleWrap.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIScrollableFrame.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"

View file

@ -15,7 +15,6 @@
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsIScrollableFrame.h"
#include "nsISelectionController.h" #include "nsISelectionController.h"
#include "nsISimpleEnumerator.h" #include "nsISimpleEnumerator.h"
#include "mozilla/dom/TouchEvent.h" #include "mozilla/dom/TouchEvent.h"
@ -24,6 +23,7 @@
#include "mozilla/EventStateManager.h" #include "mozilla/EventStateManager.h"
#include "mozilla/MouseEvents.h" #include "mozilla/MouseEvents.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/TouchEvents.h" #include "mozilla/TouchEvents.h"
#include "nsView.h" #include "nsView.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
@ -253,21 +253,24 @@ nsresult nsCoreUtils::ScrollSubstringTo(nsIFrame* aFrame, nsRange* aRange,
return NS_OK; return NS_OK;
} }
void nsCoreUtils::ScrollFrameToPoint(nsIFrame* aScrollableFrame, void nsCoreUtils::ScrollFrameToPoint(nsIFrame* aScrollContainerFrame,
nsIFrame* aFrame, nsIFrame* aFrame,
const LayoutDeviceIntPoint& aPoint) { const LayoutDeviceIntPoint& aPoint) {
nsIScrollableFrame* scrollableFrame = do_QueryFrame(aScrollableFrame); ScrollContainerFrame* scrollContainerFrame =
if (!scrollableFrame) return; do_QueryFrame(aScrollContainerFrame);
if (!scrollContainerFrame) {
return;
}
nsPoint point = LayoutDeviceIntPoint::ToAppUnits( nsPoint point = LayoutDeviceIntPoint::ToAppUnits(
aPoint, aFrame->PresContext()->AppUnitsPerDevPixel()); aPoint, aFrame->PresContext()->AppUnitsPerDevPixel());
nsRect frameRect = aFrame->GetScreenRectInAppUnits(); nsRect frameRect = aFrame->GetScreenRectInAppUnits();
nsPoint deltaPoint = point - frameRect.TopLeft(); nsPoint deltaPoint = point - frameRect.TopLeft();
nsPoint scrollPoint = scrollableFrame->GetScrollPosition(); nsPoint scrollPoint = scrollContainerFrame->GetScrollPosition();
scrollPoint -= deltaPoint; scrollPoint -= deltaPoint;
scrollableFrame->ScrollTo(scrollPoint, ScrollMode::Instant); scrollContainerFrame->ScrollTo(scrollPoint, ScrollMode::Instant);
} }
void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType, void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType,

View file

@ -172,11 +172,12 @@ class nsCoreUtils {
* Scrolls the given frame to the point, used for implememntation of * Scrolls the given frame to the point, used for implememntation of
* nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint. * nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint.
* *
* @param aScrollableFrame the scrollable frame * @param aScrollContainerFrame the scroll container frame
* @param aFrame the frame to scroll * @param aFrame the frame to scroll
* @param aPoint the point scroll to (in dev pixels) * @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); const mozilla::LayoutDeviceIntPoint& aPoint);
/** /**

View file

@ -12,7 +12,6 @@
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#include "NotificationController.h" #include "NotificationController.h"
#include "States.h" #include "States.h"
#include "nsIScrollableFrame.h"
#include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/DocumentInlines.h"
#ifdef A11Y_LOG #ifdef A11Y_LOG

View file

@ -26,7 +26,6 @@
#include "nsContainerFrame.h" #include "nsContainerFrame.h"
#include "nsFrameSelection.h" #include "nsFrameSelection.h"
#include "nsILineIterator.h" #include "nsILineIterator.h"
#include "nsIScrollableFrame.h"
#include "nsIMathMLFrame.h" #include "nsIMathMLFrame.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsRange.h" #include "nsRange.h"
@ -35,6 +34,7 @@
#include "mozilla/HTMLEditor.h" #include "mozilla/HTMLEditor.h"
#include "mozilla/IntegerRange.h" #include "mozilla/IntegerRange.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
#include "mozilla/ScrollContainerFrame.h"
#include "mozilla/SelectionMovementUtils.h" #include "mozilla/SelectionMovementUtils.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLBRElement.h" #include "mozilla/dom/HTMLBRElement.h"
@ -894,8 +894,7 @@ void HyperTextAccessible::ScrollSubstringToPoint(int32_t aStartOffset,
bool initialScrolled = false; bool initialScrolled = false;
nsIFrame* parentFrame = frame; nsIFrame* parentFrame = frame;
while ((parentFrame = parentFrame->GetParent())) { while ((parentFrame = parentFrame->GetParent())) {
nsIScrollableFrame* scrollableFrame = do_QueryFrame(parentFrame); if (parentFrame->IsScrollContainerOrSubclass()) {
if (scrollableFrame) {
if (!initialScrolled) { if (!initialScrolled) {
// Scroll substring to the given point. Turn the point into percents // Scroll substring to the given point. Turn the point into percents
// relative scrollable area to use nsCoreUtils::ScrollSubstringTo. // relative scrollable area to use nsCoreUtils::ScrollSubstringTo.

View file

@ -320,10 +320,10 @@ uint64_t LocalAccessible::VisibilityState() const {
nsIFrame* parentFrame = curFrame->GetParent(); nsIFrame* parentFrame = curFrame->GetParent();
// If contained by scrollable frame then check that at least 12 pixels // If contained by scrollable frame then check that at least 12 pixels
// around the object is visible, otherwise the object is offscreen. // around the object is visible, otherwise the object is offscreen.
nsIScrollableFrame* scrollableFrame = do_QueryFrame(parentFrame);
const nscoord kMinPixels = nsPresContext::CSSPixelsToAppUnits(12); const nscoord kMinPixels = nsPresContext::CSSPixelsToAppUnits(12);
if (scrollableFrame) { if (ScrollContainerFrame* scrollContainerFrame =
nsRect scrollPortRect = scrollableFrame->GetScrollPortRect(); do_QueryFrame(parentFrame)) {
nsRect scrollPortRect = scrollContainerFrame->GetScrollPortRect();
nsRect frameRect = nsLayoutUtils::TransformFrameRectToAncestor( nsRect frameRect = nsLayoutUtils::TransformFrameRectToAncestor(
frame, frame->GetRectRelativeToSelf(), parentFrame); frame, frame->GetRectRelativeToSelf(), parentFrame);
if (!scrollPortRect.Contains(frameRect)) { if (!scrollPortRect.Contains(frameRect)) {
@ -2259,8 +2259,9 @@ Relation LocalAccessible::RelationByType(RelationType aType) const {
if (frame) { if (frame) {
nsView* view = frame->GetView(); nsView* view = frame->GetView();
if (view) { if (view) {
nsIScrollableFrame* scrollFrame = do_QueryFrame(frame); ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(frame);
if (scrollFrame || view->GetWidget() || !frame->GetParent()) { if (scrollContainerFrame || view->GetWidget() ||
!frame->GetParent()) {
rel.AppendTarget(LocalParent()); rel.AppendTarget(LocalParent());
} }
} }