Bug 1253412 - Add IsScrollFrameWithSnapping to speed up event regions. r=mstange
MozReview-Commit-ID: Gi0y7aH0LNx
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8957,16 +8957,17 @@ nsLayoutUtils::GetSelectionBoundingRect(
/* static */ bool
nsLayoutUtils::IsScrollFrameWithSnapping(nsIFrame* aFrame)
{
nsIScrollableFrame* sf = do_QueryFrame(aFrame);
if (!sf) {
return false;
}
+ return sf->IsScrollFrameWithSnapping();
ScrollbarStyles styles = sf->GetScrollbarStyles();
return styles.mScrollSnapTypeY != NS_STYLE_SCROLL_SNAP_TYPE_NONE ||
styles.mScrollSnapTypeX != NS_STYLE_SCROLL_SNAP_TYPE_NONE;
}
/* static */ nsBlockFrame*
nsLayoutUtils::GetFloatContainingBlock(nsIFrame* aFrame)
{
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -699,17 +699,17 @@ public:
* return the element that we took the overflow from (which should then be
* treated as "overflow: visible"), and we store the overflow style here.
* If the document is in fullscreen, and the fullscreen element is not the
* root, the scrollbar of viewport will be suppressed.
* @return if scroll was propagated from some content node, the content node
* it was propagated from.
*/
nsIContent* UpdateViewportScrollbarStylesOverride();
- ScrollbarStyles GetViewportScrollbarStylesOverride()
+ const ScrollbarStyles& GetViewportScrollbarStylesOverride()
{
return mViewportStyleScrollbar;
}
/**
* Set and get methods for controlling the background drawing
*/
bool GetBackgroundImageDraw() const { return mDrawImageBackground; }
--- a/layout/forms/nsListControlFrame.h
+++ b/layout/forms/nsListControlFrame.h
@@ -103,16 +103,19 @@ public:
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override;
#endif
// nsIFormControlFrame
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) override;
virtual void SetFocus(bool aOn = true, bool aRepaint = false) override;
+ virtual bool IsScrollFrameWithSnapping() const override {
+ return false;
+ }
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override;
virtual bool ShouldPropagateComputedBSizeToScrolledContent() const override;
// for accessibility purposes
#ifdef ACCESSIBILITY
virtual mozilla::a11y::AccType AccessibleType() override;
#endif
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3625,16 +3625,36 @@ static void HandleScrollPref(nsIScrollab
aValue = NS_STYLE_OVERFLOW_HIDDEN;
break;
case nsIScrollable::Scrollbar_Always:
aValue = NS_STYLE_OVERFLOW_SCROLL;
break;
}
}
+bool
+ScrollFrameHelper::IsScrollFrameWithSnapping() const
+{
+ nsPresContext* presContext = mOuter->PresContext();
+ if (!presContext->IsDynamic() &&
+ !(mIsRoot && presContext->HasPaginatedScrolling())) {
+ return false;
+ }
+
+ if (!mIsRoot) {
+ const nsStyleDisplay& display = *mOuter->StyleDisplay();
+ return display.mScrollSnapTypeY != NS_STYLE_SCROLL_SNAP_TYPE_NONE ||
+ display.mScrollSnapTypeX != NS_STYLE_SCROLL_SNAP_TYPE_NONE;
+ } else {
+ const ScrollbarStyles& display = presContext->GetViewportScrollbarStylesOverride();
+ return display.mScrollSnapTypeY != NS_STYLE_SCROLL_SNAP_TYPE_NONE ||
+ display.mScrollSnapTypeX != NS_STYLE_SCROLL_SNAP_TYPE_NONE;
+ }
+}
+
ScrollbarStyles
ScrollFrameHelper::GetScrollbarStylesFromFrame() const
{
nsPresContext* presContext = mOuter->PresContext();
if (!presContext->IsDynamic() &&
!(mIsRoot && presContext->HasPaginatedScrolling())) {
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
}
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -52,16 +52,17 @@ public:
typedef mozilla::layers::Layer Layer;
class AsyncScroll;
class AsyncSmoothMSDScroll;
ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot);
~ScrollFrameHelper();
+ bool IsScrollFrameWithSnapping() const;
mozilla::ScrollbarStyles GetScrollbarStylesFromFrame() const;
// If a child frame was added or removed on the scrollframe,
// reload our child frame list.
// We need this if a scrollbar frame is recreated.
void ReloadChildFrames();
nsresult CreateAnonymousContent(
@@ -744,16 +745,19 @@ public:
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
uint32_t aFilter) override;
// nsIScrollableFrame
virtual nsIFrame* GetScrolledFrame() const override {
return mHelper.GetScrolledFrame();
}
+ virtual bool IsScrollFrameWithSnapping() const override {
+ return mHelper.IsScrollFrameWithSnapping();
+ }
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override {
return mHelper.GetScrollbarStylesFromFrame();
}
virtual uint32_t GetScrollbarVisibility() const override {
return mHelper.GetScrollbarVisibility();
}
virtual nsMargin GetActualScrollbarSizes() const override {
return mHelper.GetActualScrollbarSizes();
@@ -1156,16 +1160,19 @@ public:
static void AdjustReflowStateForPrintPreview(nsBoxLayoutState& aState, bool& aSetBack);
static void AdjustReflowStateBack(nsBoxLayoutState& aState, bool aSetBack);
// nsIScrollableFrame
virtual nsIFrame* GetScrolledFrame() const override {
return mHelper.GetScrolledFrame();
}
+ virtual bool IsScrollFrameWithSnapping() const override {
+ return mHelper.IsScrollFrameWithSnapping();
+ }
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override {
return mHelper.GetScrollbarStylesFromFrame();
}
virtual uint32_t GetScrollbarVisibility() const override {
return mHelper.GetScrollbarVisibility();
}
virtual nsMargin GetActualScrollbarSizes() const override {
return mHelper.GetActualScrollbarSizes();
--- a/layout/generic/nsIScrollableFrame.h
+++ b/layout/generic/nsIScrollableFrame.h
@@ -59,16 +59,18 @@ public:
/**
* Get the styles (NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
* or NS_STYLE_OVERFLOW_AUTO) governing the horizontal and vertical
* scrollbars for this frame.
*/
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const = 0;
+ virtual bool IsScrollFrameWithSnapping() const = 0;
+
enum { HORIZONTAL = 0x01, VERTICAL = 0x02 };
/**
* Return the scrollbars which are visible. It's OK to call this during reflow
* of the scrolled contents, in which case it will reflect the current
* assumptions about scrollbar visibility.
*/
virtual uint32_t GetScrollbarVisibility() const = 0;
/**