forked from mirrors/gecko-dev
Bug 1896516 Part 9 - Remove nsIScrollableFrame usages under dom/. r=layout-reviewers,emilio
Also, in EventStateManager, convert `ComputeScrollTarget()` and `ComputeScrollTargetAndMayAdjustWheelEvent()` to return `ScrollContainerFrame*` so that we can drop more unnecessarily `do_QueryFrame`. Due to removing `nsIScrollableFrame` forward declaration in DOM headers, we have to add `nsIScrollableFrame` forward declaration temporarily in nsMenuPopupFrame.h to make this patch compile, but we'll remove it once we remove `nsIScrollableFrame` under layout/. Differential Revision: https://phabricator.services.mozilla.com/D211496
This commit is contained in:
parent
8016adbafa
commit
58991f71c0
17 changed files with 131 additions and 137 deletions
|
|
@ -53,7 +53,7 @@ class ElementAnimationData {
|
|||
// This is different from |mScrollTimelines|. We use this to schedule all
|
||||
// scroll-driven animations (which use anonymous/named scroll timelines or
|
||||
// anonymous/name view timelines) for a specific scroll source (which is the
|
||||
// element with nsIScrollableFrame).
|
||||
// element with ScrollContainerFrame).
|
||||
//
|
||||
// TimelineCollection owns and manages the named progress timeline generated
|
||||
// by specifying scroll-timeline-name property and view-timeline-name
|
||||
|
|
|
|||
|
|
@ -353,7 +353,8 @@ static Maybe<nsRect> ComputeTheIntersection(
|
|||
// FIXME(emilio): What about other scroll frames that inherit from
|
||||
// ScrollContainerFrame but have a different type, like nsListControlFrame?
|
||||
// This looks bogus in that case, but different bug.
|
||||
if (nsIScrollableFrame* scrollFrame = do_QueryFrame(containerFrame)) {
|
||||
if (ScrollContainerFrame* scrollContainerFrame =
|
||||
do_QueryFrame(containerFrame)) {
|
||||
if (containerFrame->GetParent() == aRoot && !aRoot->GetParent()) {
|
||||
// This is subtle: if we're computing the intersection against the
|
||||
// viewport (the root frame), and this is its scroll frame, we really
|
||||
|
|
@ -361,7 +362,7 @@ static Maybe<nsRect> ComputeTheIntersection(
|
|||
// root margin, which is already in aRootBounds).
|
||||
break;
|
||||
}
|
||||
nsRect subFrameRect = scrollFrame->GetScrollPortRect();
|
||||
nsRect subFrameRect = scrollContainerFrame->GetScrollPortRect();
|
||||
|
||||
// 3.1 Map intersectionRect to the coordinate space of container.
|
||||
nsRect intersectionRectRelativeToContainer =
|
||||
|
|
@ -543,10 +544,11 @@ IntersectionInput DOMIntersectionObserver::ComputeInput(
|
|||
if (aRoot && aRoot->IsElement()) {
|
||||
if ((rootFrame = aRoot->AsElement()->GetPrimaryFrame())) {
|
||||
nsRect rootRectRelativeToRootFrame;
|
||||
if (nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame)) {
|
||||
if (ScrollContainerFrame* scrollContainerFrame =
|
||||
do_QueryFrame(rootFrame)) {
|
||||
// rootRectRelativeToRootFrame should be the content rect of rootFrame,
|
||||
// not including the scrollbars.
|
||||
rootRectRelativeToRootFrame = scrollFrame->GetScrollPortRect();
|
||||
rootRectRelativeToRootFrame = scrollContainerFrame->GetScrollPortRect();
|
||||
} else {
|
||||
// rootRectRelativeToRootFrame should be the border rect of rootFrame.
|
||||
rootRectRelativeToRootFrame = rootFrame->GetRectRelativeToSelf();
|
||||
|
|
|
|||
|
|
@ -657,8 +657,8 @@ already_AddRefed<nsIHTMLCollection> Element::GetElementsByTagName(
|
|||
return NS_GetContentList(this, kNameSpaceID_Unknown, aLocalName);
|
||||
}
|
||||
|
||||
nsIScrollableFrame* Element::GetScrollFrame(nsIFrame** aFrame,
|
||||
FlushType aFlushType) {
|
||||
ScrollContainerFrame* Element::GetScrollContainerFrame(nsIFrame** aFrame,
|
||||
FlushType aFlushType) {
|
||||
nsIFrame* frame = GetPrimaryFrame(aFlushType);
|
||||
if (aFrame) {
|
||||
*aFrame = frame;
|
||||
|
|
@ -669,11 +669,12 @@ nsIScrollableFrame* Element::GetScrollFrame(nsIFrame** aFrame,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (nsIScrollableFrame* scrollFrame = frame->GetScrollTargetFrame()) {
|
||||
if (ScrollContainerFrame* scrollContainerFrame =
|
||||
frame->GetScrollTargetFrame()) {
|
||||
MOZ_ASSERT(!OwnerDoc()->IsScrollingElement(this),
|
||||
"How can we have a scrollframe if we're the "
|
||||
"How can we have a scroll container frame if we're the "
|
||||
"scrollingElement for our document?");
|
||||
return scrollFrame;
|
||||
return scrollContainerFrame;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -682,13 +683,15 @@ nsIScrollableFrame* Element::GetScrollFrame(nsIFrame** aFrame,
|
|||
// a quirks mode document.
|
||||
const bool isScrollingElement = doc->IsScrollingElement(this);
|
||||
if (isScrollingElement) {
|
||||
// Our scroll info should map to the root scrollable frame if there is one.
|
||||
// Our scroll info should map to the root scroll container frame if there is
|
||||
// one.
|
||||
if (PresShell* presShell = doc->GetPresShell()) {
|
||||
if ((frame = presShell->GetRootScrollContainerFrame())) {
|
||||
if (ScrollContainerFrame* rootScrollContainerFrame =
|
||||
presShell->GetRootScrollContainerFrame()) {
|
||||
if (aFrame) {
|
||||
*aFrame = frame;
|
||||
*aFrame = rootScrollContainerFrame;
|
||||
}
|
||||
return do_QueryFrame(frame);
|
||||
return rootScrollContainerFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -825,7 +828,7 @@ void Element::ScrollTo(const ScrollToOptions& aOptions) {
|
|||
(aOptions.mTop.WasPassed() && aOptions.mTop.Value() != 0.0);
|
||||
|
||||
nsIFrame* frame;
|
||||
nsIScrollableFrame* sf = GetScrollFrame(
|
||||
ScrollContainerFrame* sf = GetScrollContainerFrame(
|
||||
&frame, needsLayoutFlush ? FlushType::Layout : FlushType::Frames);
|
||||
if (!sf) {
|
||||
return;
|
||||
|
|
@ -854,7 +857,7 @@ void Element::ScrollBy(double aXScrollDif, double aYScrollDif) {
|
|||
|
||||
void Element::ScrollBy(const ScrollToOptions& aOptions) {
|
||||
nsIFrame* frame;
|
||||
nsIScrollableFrame* sf = GetScrollFrame(&frame);
|
||||
ScrollContainerFrame* sf = GetScrollContainerFrame(&frame);
|
||||
if (!sf) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -897,14 +900,15 @@ void Element::SetScrollLeft(int32_t aScrollLeft) {
|
|||
}
|
||||
|
||||
void Element::MozScrollSnap() {
|
||||
if (nsIScrollableFrame* sf = GetScrollFrame(nullptr, FlushType::None)) {
|
||||
if (ScrollContainerFrame* sf =
|
||||
GetScrollContainerFrame(nullptr, FlushType::None)) {
|
||||
sf->ScrollSnap();
|
||||
}
|
||||
}
|
||||
|
||||
nsRect Element::GetScrollRange() {
|
||||
nsIFrame* frame;
|
||||
nsIScrollableFrame* sf = GetScrollFrame(&frame);
|
||||
ScrollContainerFrame* sf = GetScrollContainerFrame(&frame);
|
||||
if (!sf) {
|
||||
return nsRect();
|
||||
}
|
||||
|
|
@ -952,7 +956,7 @@ static nsSize GetScrollRectSizeForOverflowVisibleFrame(nsIFrame* aFrame) {
|
|||
nsSize Element::GetScrollSize() {
|
||||
nsIFrame* frame;
|
||||
nsSize size;
|
||||
if (nsIScrollableFrame* sf = GetScrollFrame(&frame)) {
|
||||
if (ScrollContainerFrame* sf = GetScrollContainerFrame(&frame)) {
|
||||
size = sf->GetScrollRange().Size() + sf->GetScrollPortRect().Size();
|
||||
} else {
|
||||
size = GetScrollRectSizeForOverflowVisibleFrame(frame);
|
||||
|
|
@ -965,7 +969,7 @@ nsSize Element::GetScrollSize() {
|
|||
|
||||
nsPoint Element::GetScrollOrigin() {
|
||||
nsIFrame* frame;
|
||||
nsIScrollableFrame* sf = GetScrollFrame(&frame);
|
||||
ScrollContainerFrame* sf = GetScrollContainerFrame(&frame);
|
||||
if (!sf) {
|
||||
return nsPoint();
|
||||
}
|
||||
|
|
@ -1000,17 +1004,16 @@ nsRect Element::GetClientAreaRect() {
|
|||
}
|
||||
|
||||
nsIFrame* frame;
|
||||
if (nsIScrollableFrame* sf = GetScrollFrame(&frame)) {
|
||||
if (ScrollContainerFrame* sf = GetScrollContainerFrame(&frame)) {
|
||||
nsRect scrollPort = sf->GetScrollPortRect();
|
||||
|
||||
if (!sf->IsRootScrollFrameOfDocument()) {
|
||||
MOZ_ASSERT(frame);
|
||||
nsIFrame* scrollableAsFrame = do_QueryFrame(sf);
|
||||
// We want the offset to be relative to `frame`, not `sf`... Except for
|
||||
// the root scroll frame, which is an ancestor of frame rather than a
|
||||
// descendant and thus this wouldn't particularly make sense.
|
||||
if (frame != scrollableAsFrame) {
|
||||
scrollPort.MoveBy(scrollableAsFrame->GetOffsetTo(frame));
|
||||
if (frame != sf) {
|
||||
scrollPort.MoveBy(sf->GetOffsetTo(frame));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1867,7 +1870,7 @@ void Element::GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements) {
|
|||
}
|
||||
|
||||
bool Element::HasVisibleScrollbars() {
|
||||
nsIScrollableFrame* scrollFrame = GetScrollFrame();
|
||||
ScrollContainerFrame* scrollFrame = GetScrollContainerFrame();
|
||||
return scrollFrame && !scrollFrame->GetScrollbarVisibility().isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ class nsIFrame;
|
|||
class nsIHTMLCollection;
|
||||
class nsIPrincipal;
|
||||
class nsIScreen;
|
||||
class nsIScrollableFrame;
|
||||
class nsIURI;
|
||||
class nsObjectLoadingContent;
|
||||
class nsPresContext;
|
||||
|
|
@ -110,6 +109,7 @@ class MappedDeclarationsBuilder;
|
|||
class EditorBase;
|
||||
class ErrorResult;
|
||||
class OOMReporter;
|
||||
class ScrollContainerFrame;
|
||||
class SMILAttr;
|
||||
struct MutationClosureData;
|
||||
class TextEditor;
|
||||
|
|
@ -727,8 +727,8 @@ class Element : public FragmentOrElement {
|
|||
|
||||
public:
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsIScrollableFrame* GetScrollFrame(nsIFrame** aFrame = nullptr,
|
||||
FlushType aFlushType = FlushType::Layout);
|
||||
ScrollContainerFrame* GetScrollContainerFrame(
|
||||
nsIFrame** aFrame = nullptr, FlushType aFlushType = FlushType::Layout);
|
||||
|
||||
private:
|
||||
// Style state computed from element's state and style locks.
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@
|
|||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsView.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "ChildIterator.h"
|
||||
#include "mozilla/dom/NodeListBinding.h"
|
||||
#include "mozilla/dom/MutationObservers.h"
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "mozilla/SVGUtils.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include <limits>
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ static uint32_t GetNodeDepth(nsINode* aNode) {
|
|||
}
|
||||
|
||||
static nsSize GetContentRectSize(const nsIFrame& aFrame) {
|
||||
if (const nsIScrollableFrame* f = do_QueryFrame(&aFrame)) {
|
||||
if (const ScrollContainerFrame* f = do_QueryFrame(&aFrame)) {
|
||||
// We return the scrollport rect for compat with other UAs, see bug 1733042.
|
||||
// But the scrollPort includes padding (but not border!), so remove it.
|
||||
nsRect scrollPort = f->GetScrollPortRect();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsTableWrapperFrame.h"
|
||||
#include "nsTableCellFrame.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsTextFragment.h"
|
||||
|
|
|
|||
|
|
@ -610,7 +610,7 @@ nsDOMWindowUtils::GetScrollbarSizes(Element* aElement,
|
|||
|
||||
CSSIntMargin scrollbarSizes = RoundedToInt(
|
||||
CSSMargin::FromAppUnits(scrollContainerFrame->GetActualScrollbarSizes(
|
||||
nsIScrollableFrame::ScrollbarSizesOptions::
|
||||
ScrollContainerFrame::ScrollbarSizesOptions::
|
||||
INCLUDE_VISUAL_VIEWPORT_SCROLLBARS)));
|
||||
*aOutVerticalScrollbarWidth = scrollbarSizes.LeftRight();
|
||||
*aOutHorizontalScrollbarHeight = scrollbarSizes.TopBottom();
|
||||
|
|
@ -2974,16 +2974,16 @@ nsDOMWindowUtils::DisableApzForElement(Element* aElement) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsTArray<nsIScrollableFrame*> CollectScrollableAncestors(
|
||||
static nsTArray<ScrollContainerFrame*> CollectScrollableAncestors(
|
||||
nsIFrame* aStart) {
|
||||
nsTArray<nsIScrollableFrame*> result;
|
||||
nsTArray<ScrollContainerFrame*> result;
|
||||
nsIFrame* frame = aStart;
|
||||
while (frame) {
|
||||
frame = nsLayoutUtils::GetCrossDocParentFrame(frame);
|
||||
if (!frame) {
|
||||
break;
|
||||
}
|
||||
nsIScrollableFrame* scrollAncestor =
|
||||
ScrollContainerFrame* scrollAncestor =
|
||||
nsLayoutUtils::GetAsyncScrollableAncestorFrame(frame);
|
||||
if (!scrollAncestor) {
|
||||
break;
|
||||
|
|
@ -3104,7 +3104,7 @@ nsDOMWindowUtils::ZoomToFocusedInput() {
|
|||
CSSPoint::FromAppUnits(rootScrollContainerFrame->GetScrollPosition());
|
||||
|
||||
bool waitForRefresh = false;
|
||||
for (nsIScrollableFrame* scrollAncestor :
|
||||
for (ScrollContainerFrame* scrollAncestor :
|
||||
CollectScrollableAncestors(element->GetPrimaryFrame())) {
|
||||
if (scrollAncestor->HasScrollUpdates()) {
|
||||
waitForRefresh = true;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@
|
|||
#include "mozilla/dom/NodeInfo.h"
|
||||
#include "mozilla/dom/NodeInfoInlines.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsView.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
|
|
|
|||
|
|
@ -3145,7 +3145,8 @@ void EventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame,
|
|||
aState.mDefaultPreventedByContent = event.DefaultPreventedByContent();
|
||||
}
|
||||
|
||||
nsIFrame* EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
ScrollContainerFrame*
|
||||
EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
nsIFrame* aTargetFrame, WidgetWheelEvent* aEvent,
|
||||
ComputeScrollTargetOptions aOptions) {
|
||||
return ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
|
|
@ -3155,7 +3156,8 @@ nsIFrame* EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
|
|||
// Overload ComputeScrollTargetAndMayAdjustWheelEvent method to allow passing
|
||||
// "test" dx and dy when looking for which scrollbarmediators to activate when
|
||||
// two finger down on trackpad and before any actual motion
|
||||
nsIFrame* EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
ScrollContainerFrame*
|
||||
EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
nsIFrame* aTargetFrame, double aDirectionX, double aDirectionY,
|
||||
WidgetWheelEvent* aEvent, ComputeScrollTargetOptions aOptions) {
|
||||
bool isAutoDir = false;
|
||||
|
|
@ -3328,19 +3330,20 @@ nsIFrame* EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
|
|||
|
||||
nsSize EventStateManager::GetScrollAmount(
|
||||
nsPresContext* aPresContext, WidgetWheelEvent* aEvent,
|
||||
nsIScrollableFrame* aScrollableFrame) {
|
||||
ScrollContainerFrame* aScrollContainerFrame) {
|
||||
MOZ_ASSERT(aPresContext);
|
||||
MOZ_ASSERT(aEvent);
|
||||
|
||||
const bool isPage = aEvent->mDeltaMode == WheelEvent_Binding::DOM_DELTA_PAGE;
|
||||
if (!aScrollableFrame) {
|
||||
if (!aScrollContainerFrame) {
|
||||
// If there is no scrollable frame, we should use root, see below.
|
||||
aScrollableFrame = aPresContext->PresShell()->GetRootScrollContainerFrame();
|
||||
aScrollContainerFrame =
|
||||
aPresContext->PresShell()->GetRootScrollContainerFrame();
|
||||
}
|
||||
|
||||
if (aScrollableFrame) {
|
||||
return isPage ? aScrollableFrame->GetPageScrollAmount()
|
||||
: aScrollableFrame->GetLineScrollAmount();
|
||||
if (aScrollContainerFrame) {
|
||||
return isPage ? aScrollContainerFrame->GetPageScrollAmount()
|
||||
: aScrollContainerFrame->GetLineScrollAmount();
|
||||
}
|
||||
|
||||
// If there is no scrollable frame and page scrolling, use viewport size.
|
||||
|
|
@ -3364,15 +3367,12 @@ nsSize EventStateManager::GetScrollAmount(
|
|||
return nsSize(fm->AveCharWidth(), fm->MaxHeight());
|
||||
}
|
||||
|
||||
void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
||||
WidgetWheelEvent* aEvent) {
|
||||
MOZ_ASSERT(aScrollableFrame);
|
||||
void EventStateManager::DoScrollText(
|
||||
ScrollContainerFrame* aScrollContainerFrame, WidgetWheelEvent* aEvent) {
|
||||
MOZ_ASSERT(aScrollContainerFrame);
|
||||
MOZ_ASSERT(aEvent);
|
||||
|
||||
nsIFrame* scrollFrame = do_QueryFrame(aScrollableFrame);
|
||||
MOZ_ASSERT(scrollFrame);
|
||||
|
||||
AutoWeakFrame scrollFrameWeak(scrollFrame);
|
||||
AutoWeakFrame scrollFrameWeak(aScrollContainerFrame);
|
||||
AutoWeakFrame eventFrameWeak(mCurrentTarget);
|
||||
if (!WheelTransaction::WillHandleDefaultAction(aEvent, scrollFrameWeak,
|
||||
eventFrameWeak)) {
|
||||
|
|
@ -3381,8 +3381,8 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
|||
|
||||
// Default action's actual scroll amount should be computed from device
|
||||
// pixels.
|
||||
nsPresContext* pc = scrollFrame->PresContext();
|
||||
nsSize scrollAmount = GetScrollAmount(pc, aEvent, aScrollableFrame);
|
||||
nsPresContext* pc = aScrollContainerFrame->PresContext();
|
||||
nsSize scrollAmount = GetScrollAmount(pc, aEvent, aScrollContainerFrame);
|
||||
nsIntSize scrollAmountInDevPixels(
|
||||
pc->AppUnitsToDevPixels(scrollAmount.width),
|
||||
pc->AppUnitsToDevPixels(scrollAmount.height));
|
||||
|
|
@ -3391,7 +3391,7 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
|||
aEvent, scrollAmountInDevPixels);
|
||||
|
||||
// Don't scroll around the axis whose overflow style is hidden.
|
||||
ScrollStyles overflowStyle = aScrollableFrame->GetScrollStyles();
|
||||
ScrollStyles overflowStyle = aScrollContainerFrame->GetScrollStyles();
|
||||
if (overflowStyle.mHorizontal == StyleOverflow::Hidden) {
|
||||
actualDevPixelScrollAmount.x = 0;
|
||||
}
|
||||
|
|
@ -3420,7 +3420,7 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
|||
|
||||
// We shouldn't scroll more one page at once except when over one page scroll
|
||||
// is allowed for the event.
|
||||
nsSize pageSize = aScrollableFrame->GetPageScrollAmount();
|
||||
nsSize pageSize = aScrollContainerFrame->GetPageScrollAmount();
|
||||
nsIntSize devPixelPageSize(pc->AppUnitsToDevPixels(pageSize.width),
|
||||
pc->AppUnitsToDevPixels(pageSize.height));
|
||||
if (!WheelPrefs::GetInstance()->IsOverOnePageScrollAllowedX(aEvent) &&
|
||||
|
|
@ -3466,14 +3466,14 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
|||
MOZ_CRASH("Invalid mScrollType value comes");
|
||||
}
|
||||
|
||||
nsIScrollableFrame::ScrollMomentum momentum =
|
||||
aEvent->mIsMomentum ? nsIScrollableFrame::SYNTHESIZED_MOMENTUM_EVENT
|
||||
: nsIScrollableFrame::NOT_MOMENTUM;
|
||||
ScrollContainerFrame::ScrollMomentum momentum =
|
||||
aEvent->mIsMomentum ? ScrollContainerFrame::SYNTHESIZED_MOMENTUM_EVENT
|
||||
: ScrollContainerFrame::NOT_MOMENTUM;
|
||||
|
||||
nsIntPoint overflow;
|
||||
aScrollableFrame->ScrollBy(actualDevPixelScrollAmount,
|
||||
ScrollUnit::DEVICE_PIXELS, mode, &overflow, origin,
|
||||
momentum, snapFlags);
|
||||
aScrollContainerFrame->ScrollBy(actualDevPixelScrollAmount,
|
||||
ScrollUnit::DEVICE_PIXELS, mode, &overflow,
|
||||
origin, momentum, snapFlags);
|
||||
|
||||
if (!scrollFrameWeak.IsAlive()) {
|
||||
// If the scroll causes changing the layout, we can think that the event
|
||||
|
|
@ -3499,13 +3499,13 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
|||
if (scrollFrameWeak.IsAlive()) {
|
||||
if (aEvent->mDeltaX && overflowStyle.mHorizontal == StyleOverflow::Hidden &&
|
||||
!ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
scrollFrame, aEvent,
|
||||
aScrollContainerFrame, aEvent,
|
||||
COMPUTE_SCROLLABLE_ANCESTOR_ALONG_X_AXIS_WITH_AUTO_DIR)) {
|
||||
aEvent->mOverflowDeltaX = aEvent->mDeltaX;
|
||||
}
|
||||
if (aEvent->mDeltaY && overflowStyle.mVertical == StyleOverflow::Hidden &&
|
||||
!ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
scrollFrame, aEvent,
|
||||
aScrollContainerFrame, aEvent,
|
||||
COMPUTE_SCROLLABLE_ANCESTOR_ALONG_Y_AXIS_WITH_AUTO_DIR)) {
|
||||
aEvent->mOverflowDeltaY = aEvent->mDeltaY;
|
||||
}
|
||||
|
|
@ -3575,9 +3575,9 @@ void EventStateManager::DecideGestureEvent(WidgetGestureNotifyEvent* aEvent,
|
|||
break;
|
||||
}
|
||||
|
||||
if (nsIScrollableFrame* scrollableFrame = do_QueryFrame(current)) {
|
||||
if (ScrollContainerFrame* scrollContainerFrame = do_QueryFrame(current)) {
|
||||
layers::ScrollDirections scrollbarVisibility =
|
||||
scrollableFrame->GetScrollbarVisibility();
|
||||
scrollContainerFrame->GetScrollbarVisibility();
|
||||
|
||||
// Check if we have visible scrollbars
|
||||
if (scrollbarVisibility.contains(layers::ScrollDirection::eVertical)) {
|
||||
|
|
@ -3590,7 +3590,7 @@ void EventStateManager::DecideGestureEvent(WidgetGestureNotifyEvent* aEvent,
|
|||
panDirection = WidgetGestureNotifyEvent::ePanHorizontal;
|
||||
displayPanFeedback = true;
|
||||
}
|
||||
} // scrollableFrame
|
||||
}
|
||||
} // ancestor chain
|
||||
aEvent->mDisplayPanFeedback = displayPanFeedback;
|
||||
aEvent->mPanDirection = panDirection;
|
||||
|
|
@ -4041,10 +4041,10 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
MOZ_ASSERT(aEvent->IsTrusted());
|
||||
ScrollbarsForWheel::MayInactivate();
|
||||
WidgetWheelEvent* wheelEvent = aEvent->AsWheelEvent();
|
||||
nsIScrollableFrame* scrollTarget =
|
||||
do_QueryFrame(ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
ScrollContainerFrame* scrollTarget =
|
||||
ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
mCurrentTarget, wheelEvent,
|
||||
COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR));
|
||||
COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR);
|
||||
// If the wheel event was handled by APZ, APZ will perform the scroll
|
||||
// snap.
|
||||
if (scrollTarget && !WheelTransaction::HandledByApz()) {
|
||||
|
|
@ -4091,9 +4091,10 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
// values is adjusted during its lifetime, the instance will restore the
|
||||
// adjusted delta when it's being destrcuted.
|
||||
ESMAutoDirWheelDeltaRestorer restorer(*wheelEvent);
|
||||
nsIFrame* frameToScroll = ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
mCurrentTarget, wheelEvent,
|
||||
COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR);
|
||||
ScrollContainerFrame* scrollTarget =
|
||||
ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
mCurrentTarget, wheelEvent,
|
||||
COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR);
|
||||
|
||||
switch (action) {
|
||||
case WheelPrefs::ACTION_SCROLL:
|
||||
|
|
@ -4109,18 +4110,13 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
break;
|
||||
}
|
||||
|
||||
nsIScrollableFrame* scrollTarget = do_QueryFrame(frameToScroll);
|
||||
ScrollbarsForWheel::SetActiveScrollTarget(scrollTarget);
|
||||
|
||||
nsIFrame* rootScrollFrame =
|
||||
ScrollContainerFrame* rootScrollContainerFrame =
|
||||
!mCurrentTarget
|
||||
? nullptr
|
||||
: mCurrentTarget->PresShell()->GetRootScrollContainerFrame();
|
||||
nsIScrollableFrame* rootScrollableFrame = nullptr;
|
||||
if (rootScrollFrame) {
|
||||
rootScrollableFrame = do_QueryFrame(rootScrollFrame);
|
||||
}
|
||||
if (!scrollTarget || scrollTarget == rootScrollableFrame) {
|
||||
if (!scrollTarget || scrollTarget == rootScrollContainerFrame) {
|
||||
wheelEvent->mViewPortIsOverscrolled = true;
|
||||
}
|
||||
wheelEvent->mOverflowDeltaX = wheelEvent->mDeltaX;
|
||||
|
|
@ -4160,9 +4156,9 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
bool allDeltaOverflown = false;
|
||||
if (StaticPrefs::dom_event_wheel_event_groups_enabled() &&
|
||||
(wheelEvent->mDeltaX != 0.0 || wheelEvent->mDeltaY != 0.0)) {
|
||||
if (frameToScroll) {
|
||||
if (scrollTarget) {
|
||||
WheelTransaction::WillHandleDefaultAction(
|
||||
wheelEvent, frameToScroll, mCurrentTarget);
|
||||
wheelEvent, scrollTarget, mCurrentTarget);
|
||||
} else {
|
||||
WheelTransaction::EndTransaction();
|
||||
}
|
||||
|
|
@ -4210,7 +4206,7 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
if (mCurrentTarget && aEvent->mMessage == eDragOver) {
|
||||
nsIFrame* checkFrame = mCurrentTarget;
|
||||
while (checkFrame) {
|
||||
nsIScrollableFrame* scrollFrame = do_QueryFrame(checkFrame);
|
||||
ScrollContainerFrame* scrollFrame = do_QueryFrame(checkFrame);
|
||||
// Break out so only the innermost scrollframe is scrolled.
|
||||
if (scrollFrame && scrollFrame->DragScroll(aEvent)) {
|
||||
break;
|
||||
|
|
@ -6911,11 +6907,10 @@ void EventStateManager::DeltaAccumulator::InitLineOrPageDelta(
|
|||
mIsNoLineOrPageDeltaDevice = aEvent->mIsNoLineOrPageDelta;
|
||||
|
||||
{
|
||||
nsIFrame* frame = aESM->ComputeScrollTarget(aTargetFrame, aEvent,
|
||||
COMPUTE_DEFAULT_ACTION_TARGET);
|
||||
nsPresContext* pc =
|
||||
frame ? frame->PresContext() : aTargetFrame->PresContext();
|
||||
nsIScrollableFrame* scrollTarget = do_QueryFrame(frame);
|
||||
ScrollContainerFrame* scrollTarget = aESM->ComputeScrollTarget(
|
||||
aTargetFrame, aEvent, COMPUTE_DEFAULT_ACTION_TARGET);
|
||||
nsPresContext* pc = scrollTarget ? scrollTarget->PresContext()
|
||||
: aTargetFrame->PresContext();
|
||||
aEvent->mScrollAmount = aESM->GetScrollAmount(pc, aEvent, scrollTarget);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class nsIDocShellTreeItem;
|
|||
class nsIFrame;
|
||||
class imgIContainer;
|
||||
class nsIDocumentViewer;
|
||||
class nsIScrollableFrame;
|
||||
class nsITimer;
|
||||
class nsIWidget;
|
||||
class nsPresContext;
|
||||
|
|
@ -44,6 +43,7 @@ class EditorBase;
|
|||
class EnterLeaveDispatcher;
|
||||
class IMEContentObserver;
|
||||
class ScrollbarsForWheel;
|
||||
class ScrollContainerFrame;
|
||||
class TextControlElement;
|
||||
class WheelTransaction;
|
||||
|
||||
|
|
@ -999,26 +999,26 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
|||
// The delta values in the wheel event may be changed if the event is for
|
||||
// auto-dir scrolling. For information on auto-dir,
|
||||
// @see mozilla::WheelDeltaAdjustmentStrategy
|
||||
nsIFrame* ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
ScrollContainerFrame* ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
nsIFrame* aTargetFrame, WidgetWheelEvent* aEvent,
|
||||
ComputeScrollTargetOptions aOptions);
|
||||
|
||||
nsIFrame* ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
ScrollContainerFrame* ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
nsIFrame* aTargetFrame, double aDirectionX, double aDirectionY,
|
||||
WidgetWheelEvent* aEvent, ComputeScrollTargetOptions aOptions);
|
||||
|
||||
nsIFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
|
||||
WidgetWheelEvent* aEvent,
|
||||
ComputeScrollTargetOptions aOptions) {
|
||||
ScrollContainerFrame* ComputeScrollTarget(
|
||||
nsIFrame* aTargetFrame, WidgetWheelEvent* aEvent,
|
||||
ComputeScrollTargetOptions aOptions) {
|
||||
MOZ_ASSERT(!(aOptions & MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
||||
"aEvent may be modified by auto-dir");
|
||||
return ComputeScrollTargetAndMayAdjustWheelEvent(aTargetFrame, aEvent,
|
||||
aOptions);
|
||||
}
|
||||
|
||||
nsIFrame* ComputeScrollTarget(nsIFrame* aTargetFrame, double aDirectionX,
|
||||
double aDirectionY, WidgetWheelEvent* aEvent,
|
||||
ComputeScrollTargetOptions aOptions) {
|
||||
ScrollContainerFrame* ComputeScrollTarget(
|
||||
nsIFrame* aTargetFrame, double aDirectionX, double aDirectionY,
|
||||
WidgetWheelEvent* aEvent, ComputeScrollTargetOptions aOptions) {
|
||||
MOZ_ASSERT(!(aOptions & MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
||||
"aEvent may be modified by auto-dir");
|
||||
return ComputeScrollTargetAndMayAdjustWheelEvent(
|
||||
|
|
@ -1030,21 +1030,22 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
|||
* one page. If the wheel event scrolls a page, returns the page width and
|
||||
* height. Otherwise, returns line height for both its width and height.
|
||||
*
|
||||
* @param aScrollableFrame A frame which will be scrolled by the event.
|
||||
* The result of
|
||||
* ComputeScrollTargetAndMayAdjustWheelEvent() is
|
||||
* expected for this value.
|
||||
* This can be nullptr if there is no scrollable
|
||||
* frame. Then, this method uses root frame's
|
||||
* line height or visible area's width and height.
|
||||
* @param aScrollContainerFrame A frame which will be scrolled by the event.
|
||||
* The result of
|
||||
* ComputeScrollTargetAndMayAdjustWheelEvent() is
|
||||
* expected for this value.
|
||||
* This can be nullptr if there is no scrollable
|
||||
* frame. Then, this method uses root frame's
|
||||
* line height or visible area's width and
|
||||
* height.
|
||||
*/
|
||||
nsSize GetScrollAmount(nsPresContext* aPresContext, WidgetWheelEvent* aEvent,
|
||||
nsIScrollableFrame* aScrollableFrame);
|
||||
ScrollContainerFrame* aScrollContainerFrame);
|
||||
|
||||
/**
|
||||
* DoScrollText() scrolls the scrollable frame for aEvent.
|
||||
* DoScrollText() scrolls the scroll container frame for aEvent.
|
||||
*/
|
||||
void DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
||||
void DoScrollText(ScrollContainerFrame* aScrollContainerFrame,
|
||||
WidgetWheelEvent* aEvent);
|
||||
|
||||
void DoScrollHistory(int32_t direction);
|
||||
|
|
|
|||
|
|
@ -169,9 +169,10 @@ void WheelTransaction::BeginTransaction(nsIFrame* aScrollTargetFrame,
|
|||
/* static */
|
||||
bool WheelTransaction::UpdateTransaction(const WidgetWheelEvent* aEvent) {
|
||||
nsIFrame* scrollToFrame = GetScrollTargetFrame();
|
||||
nsIScrollableFrame* scrollableFrame = scrollToFrame->GetScrollTargetFrame();
|
||||
if (scrollableFrame) {
|
||||
scrollToFrame = do_QueryFrame(scrollableFrame);
|
||||
ScrollContainerFrame* scrollContainerFrame =
|
||||
scrollToFrame->GetScrollTargetFrame();
|
||||
if (scrollContainerFrame) {
|
||||
scrollToFrame = scrollContainerFrame;
|
||||
}
|
||||
|
||||
if (!WheelHandlingUtils::CanScrollOn(scrollToFrame, aEvent->mDeltaX,
|
||||
|
|
@ -485,17 +486,16 @@ void ScrollbarsForWheel::PrepareToScrollText(EventStateManager* aESM,
|
|||
|
||||
/* static */
|
||||
void ScrollbarsForWheel::SetActiveScrollTarget(
|
||||
nsIScrollableFrame* aScrollTarget) {
|
||||
ScrollContainerFrame* aScrollTarget) {
|
||||
if (!sHadWheelStart) {
|
||||
return;
|
||||
}
|
||||
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(aScrollTarget);
|
||||
if (!scrollbarMediator) {
|
||||
if (!aScrollTarget) {
|
||||
return;
|
||||
}
|
||||
sHadWheelStart = false;
|
||||
sActiveOwner = do_QueryFrame(aScrollTarget);
|
||||
scrollbarMediator->ScrollbarActivityStarted();
|
||||
sActiveOwner = aScrollTarget;
|
||||
aScrollTarget->ScrollbarActivityStarted();
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
@ -547,14 +547,12 @@ void ScrollbarsForWheel::TemporarilyActivateAllPossibleScrollTargets(
|
|||
const DeltaValues* dir = &directions[i];
|
||||
AutoWeakFrame* scrollTarget = &sActivatedScrollTargets[i];
|
||||
MOZ_ASSERT(!*scrollTarget, "scroll target still temporarily activated!");
|
||||
nsIScrollableFrame* target = do_QueryFrame(aESM->ComputeScrollTarget(
|
||||
ScrollContainerFrame* target = aESM->ComputeScrollTarget(
|
||||
aTargetFrame, dir->deltaX, dir->deltaY, aEvent,
|
||||
EventStateManager::COMPUTE_DEFAULT_ACTION_TARGET));
|
||||
nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(target);
|
||||
if (scrollbarMediator) {
|
||||
nsIFrame* targetFrame = do_QueryFrame(target);
|
||||
*scrollTarget = targetFrame;
|
||||
scrollbarMediator->ScrollbarActivityStarted();
|
||||
EventStateManager::COMPUTE_DEFAULT_ACTION_TARGET);
|
||||
if (target) {
|
||||
*scrollTarget = target;
|
||||
target->ScrollbarActivityStarted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include "nsPoint.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsIScrollableFrame;
|
||||
class nsITimer;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
@ -84,7 +83,7 @@ class ScrollbarsForWheel {
|
|||
static void PrepareToScrollText(EventStateManager* aESM,
|
||||
nsIFrame* aTargetFrame,
|
||||
WidgetWheelEvent* aEvent);
|
||||
static void SetActiveScrollTarget(nsIScrollableFrame* aScrollTarget);
|
||||
static void SetActiveScrollTarget(ScrollContainerFrame* aScrollTarget);
|
||||
// Hide all scrollbars (both mActiveOwner's and mActivatedScrollTargets')
|
||||
static void MayInactivate();
|
||||
static void Inactivate();
|
||||
|
|
@ -402,7 +401,7 @@ class MOZ_STACK_CLASS ESMAutoDirWheelDeltaAdjuster final
|
|||
virtual bool CanScrollRightwards() const override;
|
||||
virtual bool IsHorizontalContentRightToLeft() const override;
|
||||
|
||||
nsIScrollableFrame* mScrollTargetFrame;
|
||||
ScrollContainerFrame* mScrollTargetFrame;
|
||||
bool mIsHorizontalContentRightToLeft;
|
||||
|
||||
int32_t& mLineOrPageDeltaX;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include "mozilla/dom/UnbindContext.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsView.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "nsChangeHint.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "mozilla/dom/MutationEventBinding.h"
|
||||
#include "mozilla/dom/XULTextElement.h"
|
||||
#include "mozilla/dom/XULTextElementBinding.h"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include "nsContentList.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/DocumentInlines.h"
|
||||
#include "mozilla/dom/HTMLTemplateElement.h"
|
||||
|
|
@ -27,6 +26,7 @@
|
|||
#include "nsRange.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/PresShellInlines.h"
|
||||
#include "mozilla/ScrollContainerFrame.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/dom/CharacterData.h"
|
||||
#include "mozilla/dom/CSSBinding.h"
|
||||
|
|
@ -949,17 +949,17 @@ static void AddOverflowingChildrenOfElement(const nsIFrame* aFrame,
|
|||
already_AddRefed<nsINodeList> InspectorUtils::GetOverflowingChildrenOfElement(
|
||||
GlobalObject& aGlobal, Element& aElement) {
|
||||
auto list = MakeRefPtr<nsSimpleContentList>(&aElement);
|
||||
const nsIScrollableFrame* scrollFrame = aElement.GetScrollFrame();
|
||||
// Element must have a nsIScrollableFrame
|
||||
if (!scrollFrame) {
|
||||
const ScrollContainerFrame* scrollContainerFrame =
|
||||
aElement.GetScrollContainerFrame();
|
||||
// Element must be a ScrollContainerFrame.
|
||||
if (!scrollContainerFrame) {
|
||||
return list.forget();
|
||||
}
|
||||
|
||||
auto scrollPortRect = scrollFrame->GetScrollPortRect();
|
||||
const nsIFrame* outerFrame = do_QueryFrame(scrollFrame);
|
||||
const nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
|
||||
AddOverflowingChildrenOfElement(scrolledFrame, outerFrame, scrollPortRect,
|
||||
*list);
|
||||
auto scrollPortRect = scrollContainerFrame->GetScrollPortRect();
|
||||
const nsIFrame* scrolledFrame = scrollContainerFrame->GetScrolledFrame();
|
||||
AddOverflowingChildrenOfElement(scrolledFrame, scrollContainerFrame,
|
||||
scrollPortRect, *list);
|
||||
return list.forget();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "Units.h"
|
||||
|
||||
class nsIScrollableFrame;
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
|||
Loading…
Reference in a new issue