mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 945584: Part 2 - Add CSS scroll snapping attributes to ScrollbarStyles (v10 Patch),r=mstange
- ScrollbarStyles now carries additional variables to support new CSS scroll snapping attributes: - scroll-snap-type / scroll-snap-type-x / scroll-snap-type-y - scroll-snap-points-x / scroll-snap-points-y - scroll-snap-destination - (scroll-snap-coordinate does not apply to the scroll container) - Simplified the constructor and operator== for ScrollbarStyles.
This commit is contained in:
parent
16eb36e28b
commit
22098428f9
32
layout/base/ScrollbarStyles.cpp
Normal file
32
layout/base/ScrollbarStyles.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ScrollbarStyles.h"
|
||||
#include "nsStyleStruct.h" // for nsStyleDisplay and nsStyleBackground::Position
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
ScrollbarStyles::ScrollbarStyles(uint8_t aH, uint8_t aV,
|
||||
const nsStyleDisplay* aDisplay)
|
||||
: mHorizontal(aH), mVertical(aV),
|
||||
mScrollBehavior(aDisplay->mScrollBehavior),
|
||||
mScrollSnapTypeX(aDisplay->mScrollSnapTypeX),
|
||||
mScrollSnapTypeY(aDisplay->mScrollSnapTypeY),
|
||||
mScrollSnapPointsX(aDisplay->mScrollSnapPointsX),
|
||||
mScrollSnapPointsY(aDisplay->mScrollSnapPointsY),
|
||||
mScrollSnapDestinationX(aDisplay->mScrollSnapDestination.mXPosition),
|
||||
mScrollSnapDestinationY(aDisplay->mScrollSnapDestination.mYPosition) {}
|
||||
|
||||
ScrollbarStyles::ScrollbarStyles(const nsStyleDisplay* aDisplay)
|
||||
: mHorizontal(aDisplay->mOverflowX), mVertical(aDisplay->mOverflowY),
|
||||
mScrollBehavior(aDisplay->mScrollBehavior),
|
||||
mScrollSnapTypeX(aDisplay->mScrollSnapTypeX),
|
||||
mScrollSnapTypeY(aDisplay->mScrollSnapTypeY),
|
||||
mScrollSnapPointsX(aDisplay->mScrollSnapPointsX),
|
||||
mScrollSnapPointsY(aDisplay->mScrollSnapPointsY),
|
||||
mScrollSnapDestinationX(aDisplay->mScrollSnapDestination.mXPosition),
|
||||
mScrollSnapDestinationY(aDisplay->mScrollSnapDestination.mYPosition) {}
|
||||
|
||||
}
|
@ -7,9 +7,13 @@
|
||||
#define ScrollbarStyles_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsStyleConsts.h" // for NS_STYLE_SCROLL_SNAP_*
|
||||
#include "nsStyleCoord.h" // for nsStyleCoord
|
||||
#include "mozilla/dom/WindowBinding.h"
|
||||
|
||||
// Forward declarations
|
||||
struct nsStyleDisplay;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct ScrollbarStyles
|
||||
@ -21,17 +25,46 @@ struct ScrollbarStyles
|
||||
// Always one of NS_STYLE_SCROLL_BEHAVIOR_AUTO or
|
||||
// NS_STYLE_SCROLL_BEHAVIOR_SMOOTH
|
||||
uint8_t mScrollBehavior;
|
||||
ScrollbarStyles(uint8_t aH, uint8_t aV, uint8_t aB) : mHorizontal(aH),
|
||||
mVertical(aV),
|
||||
mScrollBehavior(aB) {}
|
||||
// Always one of NS_STYLE_SCROLL_SNAP_NONE, NS_STYLE_SCROLL_SNAP_MANDATORY,
|
||||
// or NS_STYLE_SCROLL_SNAP_PROXIMITY.
|
||||
uint8_t mScrollSnapTypeX;
|
||||
uint8_t mScrollSnapTypeY;
|
||||
nsStyleCoord mScrollSnapPointsX;
|
||||
nsStyleCoord mScrollSnapPointsY;
|
||||
nsStyleCoord::CalcValue mScrollSnapDestinationX;
|
||||
nsStyleCoord::CalcValue mScrollSnapDestinationY;
|
||||
|
||||
ScrollbarStyles(uint8_t aH, uint8_t aV)
|
||||
: mHorizontal(aH), mVertical(aV),
|
||||
mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO),
|
||||
mScrollSnapTypeX(NS_STYLE_SCROLL_SNAP_TYPE_NONE),
|
||||
mScrollSnapTypeY(NS_STYLE_SCROLL_SNAP_TYPE_NONE),
|
||||
mScrollSnapPointsX(nsStyleCoord(eStyleUnit_None)),
|
||||
mScrollSnapPointsY(nsStyleCoord(eStyleUnit_None)) {
|
||||
|
||||
mScrollSnapDestinationX.mPercent = 0;
|
||||
mScrollSnapDestinationX.mLength = nscoord(0.0f);
|
||||
mScrollSnapDestinationX.mHasPercent = false;
|
||||
mScrollSnapDestinationY.mPercent = 0;
|
||||
mScrollSnapDestinationY.mLength = nscoord(0.0f);
|
||||
mScrollSnapDestinationY.mHasPercent = false;
|
||||
}
|
||||
|
||||
explicit ScrollbarStyles(const nsStyleDisplay* aDisplay);
|
||||
ScrollbarStyles(uint8_t aH, uint8_t aV, const nsStyleDisplay* aDisplay);
|
||||
ScrollbarStyles() {}
|
||||
bool operator==(const ScrollbarStyles& aStyles) const {
|
||||
return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical &&
|
||||
aStyles.mScrollBehavior == mScrollBehavior;
|
||||
aStyles.mScrollBehavior == mScrollBehavior &&
|
||||
aStyles.mScrollSnapTypeX == mScrollSnapTypeX &&
|
||||
aStyles.mScrollSnapTypeY == mScrollSnapTypeY &&
|
||||
aStyles.mScrollSnapPointsX == mScrollSnapPointsX &&
|
||||
aStyles.mScrollSnapPointsY == mScrollSnapPointsY &&
|
||||
aStyles.mScrollSnapDestinationX == mScrollSnapDestinationX &&
|
||||
aStyles.mScrollSnapDestinationY == mScrollSnapDestinationY;
|
||||
}
|
||||
bool operator!=(const ScrollbarStyles& aStyles) const {
|
||||
return aStyles.mHorizontal != mHorizontal || aStyles.mVertical != mVertical ||
|
||||
aStyles.mScrollBehavior != mScrollBehavior;
|
||||
return !(*this == aStyles);
|
||||
}
|
||||
bool IsHiddenInBothDirections() const {
|
||||
return mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
|
||||
|
@ -132,6 +132,7 @@ UNIFIED_SOURCES += [
|
||||
'PositionedEventTargeting.cpp',
|
||||
'RestyleManager.cpp',
|
||||
'RestyleTracker.cpp',
|
||||
'ScrollbarStyles.cpp',
|
||||
'SelectionCarets.cpp',
|
||||
'StackArena.cpp',
|
||||
'TouchCaret.cpp',
|
||||
|
@ -2301,7 +2301,15 @@ static bool CheckOverflow(nsPresContext* aPresContext,
|
||||
const nsStyleDisplay* aDisplay)
|
||||
{
|
||||
if (aDisplay->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE &&
|
||||
aDisplay->mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_AUTO) {
|
||||
aDisplay->mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_AUTO &&
|
||||
aDisplay->mScrollSnapTypeX == NS_STYLE_SCROLL_SNAP_TYPE_NONE &&
|
||||
aDisplay->mScrollSnapTypeY == NS_STYLE_SCROLL_SNAP_TYPE_NONE &&
|
||||
aDisplay->mScrollSnapPointsX == nsStyleCoord(eStyleUnit_None) &&
|
||||
aDisplay->mScrollSnapPointsY == nsStyleCoord(eStyleUnit_None) &&
|
||||
!aDisplay->mScrollSnapDestination.mXPosition.mHasPercent &&
|
||||
!aDisplay->mScrollSnapDestination.mYPosition.mHasPercent &&
|
||||
aDisplay->mScrollSnapDestination.mXPosition.mLength == 0 &&
|
||||
aDisplay->mScrollSnapDestination.mYPosition.mLength == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2309,12 +2317,10 @@ static bool CheckOverflow(nsPresContext* aPresContext,
|
||||
aPresContext->SetViewportScrollbarStylesOverride(
|
||||
ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN,
|
||||
NS_STYLE_OVERFLOW_HIDDEN,
|
||||
aDisplay->mScrollBehavior));
|
||||
aDisplay));
|
||||
} else {
|
||||
aPresContext->SetViewportScrollbarStylesOverride(
|
||||
ScrollbarStyles(aDisplay->mOverflowX,
|
||||
aDisplay->mOverflowY,
|
||||
aDisplay->mScrollBehavior));
|
||||
ScrollbarStyles(aDisplay));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -2334,8 +2340,7 @@ nsCSSFrameConstructor::PropagateScrollToViewport()
|
||||
nsPresContext* presContext = mPresShell->GetPresContext();
|
||||
presContext->SetViewportScrollbarStylesOverride(
|
||||
ScrollbarStyles(NS_STYLE_OVERFLOW_AUTO,
|
||||
NS_STYLE_OVERFLOW_AUTO,
|
||||
NS_STYLE_SCROLL_BEHAVIOR_AUTO));
|
||||
NS_STYLE_OVERFLOW_AUTO));
|
||||
|
||||
// We never mess with the viewport scroll state
|
||||
// when printing or in print preview
|
||||
|
@ -106,7 +106,7 @@
|
||||
#include "nsAnimationManager.h"
|
||||
#include "nsTransitionManager.h"
|
||||
#include "RestyleManager.h"
|
||||
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -192,9 +192,7 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
|
||||
: mType(aType), mDocument(aDocument), mBaseMinFontSize(0),
|
||||
mTextZoom(1.0), mFullZoom(1.0), mLastFontInflationScreenWidth(-1.0),
|
||||
mPageSize(-1, -1), mPPScale(1.0f),
|
||||
mViewportStyleScrollbar(NS_STYLE_OVERFLOW_AUTO,
|
||||
NS_STYLE_OVERFLOW_AUTO,
|
||||
NS_STYLE_SCROLL_BEHAVIOR_AUTO),
|
||||
mViewportStyleScrollbar(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO),
|
||||
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
|
||||
mAllInvalidated(false),
|
||||
mPaintFlashing(false), mPaintFlashingInitialized(false)
|
||||
|
@ -588,8 +588,7 @@ nsListControlFrame::GetScrollbarStyles() const
|
||||
// and GetScrollbarStyles can be devirtualized
|
||||
int32_t verticalStyle = IsInDropDownMode() ? NS_STYLE_OVERFLOW_AUTO
|
||||
: NS_STYLE_OVERFLOW_SCROLL;
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, verticalStyle,
|
||||
NS_STYLE_SCROLL_BEHAVIOR_AUTO);
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, verticalStyle);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -3207,14 +3207,12 @@ ScrollFrameHelper::GetScrollbarStylesFromFrame() const
|
||||
nsPresContext* presContext = mOuter->PresContext();
|
||||
if (!presContext->IsDynamic() &&
|
||||
!(mIsRoot && presContext->HasPaginatedScrolling())) {
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN,
|
||||
NS_STYLE_SCROLL_BEHAVIOR_AUTO);
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
}
|
||||
|
||||
if (!mIsRoot) {
|
||||
const nsStyleDisplay* disp = mOuter->StyleDisplay();
|
||||
return ScrollbarStyles(disp->mOverflowX, disp->mOverflowY,
|
||||
disp->mScrollBehavior);
|
||||
return ScrollbarStyles(disp);
|
||||
}
|
||||
|
||||
ScrollbarStyles result = presContext->GetViewportScrollbarStylesOverride();
|
||||
|
Loading…
Reference in New Issue
Block a user