mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 14:56:07 +00:00
Bug 908724 - Avoid #including nsPresContext.h in nsIScrollableFrame.h; r=mats
nsPresContext.h pulls in a large number of headers which should not be needed in nsIScrollableFrame, if we just move ScrollbarStyles to its own header
This commit is contained in:
parent
4c5f4ab84f
commit
0e024fd271
@ -2596,7 +2596,7 @@ nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
|
||||
return frameToScroll;
|
||||
}
|
||||
|
||||
nsPresContext::ScrollbarStyles ss = frameToScroll->GetScrollbarStyles();
|
||||
ScrollbarStyles ss = frameToScroll->GetScrollbarStyles();
|
||||
bool hiddenForV = (NS_STYLE_OVERFLOW_HIDDEN == ss.mVertical);
|
||||
bool hiddenForH = (NS_STYLE_OVERFLOW_HIDDEN == ss.mHorizontal);
|
||||
if ((hiddenForV && hiddenForH) ||
|
||||
@ -2705,8 +2705,7 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
||||
ComputeScrollAmountForDefaultAction(aEvent, scrollAmountInDevPixels);
|
||||
|
||||
// Don't scroll around the axis whose overflow style is hidden.
|
||||
nsPresContext::ScrollbarStyles overflowStyle =
|
||||
aScrollableFrame->GetScrollbarStyles();
|
||||
ScrollbarStyles overflowStyle = aScrollableFrame->GetScrollbarStyles();
|
||||
if (overflowStyle.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
|
||||
actualDevPixelScrollAmount.x = 0;
|
||||
}
|
||||
|
31
layout/base/ScrollbarStyles.h
Normal file
31
layout/base/ScrollbarStyles.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef ScrollbarStyles_h
|
||||
#define ScrollbarStyles_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct ScrollbarStyles
|
||||
{
|
||||
// Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
|
||||
// or NS_STYLE_OVERFLOW_AUTO.
|
||||
uint8_t mHorizontal;
|
||||
uint8_t mVertical;
|
||||
ScrollbarStyles(uint8_t h, uint8_t v) : mHorizontal(h), mVertical(v) {}
|
||||
ScrollbarStyles() {}
|
||||
bool operator==(const ScrollbarStyles& aStyles) const {
|
||||
return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical;
|
||||
}
|
||||
bool operator!=(const ScrollbarStyles& aStyles) const {
|
||||
return aStyles.mHorizontal != mHorizontal || aStyles.mVertical != mVertical;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -30,6 +30,7 @@ EXPORTS += [
|
||||
'DisplayListClipState.h',
|
||||
'FrameLayerBuilder.h',
|
||||
'FramePropertyTable.h',
|
||||
'ScrollbarStyles.h',
|
||||
'StackArena.h',
|
||||
'Units.h',
|
||||
'nsArenaMemoryStats.h',
|
||||
|
@ -1144,7 +1144,7 @@ nsLayoutUtils::GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
|
||||
for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
|
||||
nsIScrollableFrame* scrollableFrame = do_QueryFrame(f);
|
||||
if (scrollableFrame) {
|
||||
nsPresContext::ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
|
||||
ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
|
||||
uint32_t directions = scrollableFrame->GetPerceivedScrollingDirections();
|
||||
if (aDirection == eVertical ?
|
||||
(ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN &&
|
||||
@ -1166,7 +1166,7 @@ nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame, uint32_t aFlags)
|
||||
f->GetParent() : nsLayoutUtils::GetCrossDocParentFrame(f)) {
|
||||
nsIScrollableFrame* scrollableFrame = do_QueryFrame(f);
|
||||
if (scrollableFrame) {
|
||||
nsPresContext::ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
|
||||
ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
|
||||
if ((aFlags & SCROLLABLE_INCLUDE_HIDDEN) ||
|
||||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN ||
|
||||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN)
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "prclist.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "ScrollbarStyles.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
@ -628,25 +629,12 @@ public:
|
||||
nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const
|
||||
{ return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); }
|
||||
|
||||
struct ScrollbarStyles {
|
||||
// Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
|
||||
// or NS_STYLE_OVERFLOW_AUTO.
|
||||
uint8_t mHorizontal, mVertical;
|
||||
ScrollbarStyles(uint8_t h, uint8_t v) : mHorizontal(h), mVertical(v) {}
|
||||
ScrollbarStyles() {}
|
||||
bool operator==(const ScrollbarStyles& aStyles) const {
|
||||
return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical;
|
||||
}
|
||||
bool operator!=(const ScrollbarStyles& aStyles) const {
|
||||
return aStyles.mHorizontal != mHorizontal || aStyles.mVertical != mVertical;
|
||||
}
|
||||
};
|
||||
void SetViewportOverflowOverride(uint8_t aX, uint8_t aY)
|
||||
{
|
||||
mViewportStyleOverflow.mHorizontal = aX;
|
||||
mViewportStyleOverflow.mVertical = aY;
|
||||
}
|
||||
ScrollbarStyles GetViewportOverflowOverride()
|
||||
mozilla::ScrollbarStyles GetViewportOverflowOverride()
|
||||
{
|
||||
return mViewportStyleOverflow;
|
||||
}
|
||||
@ -1223,7 +1211,7 @@ protected:
|
||||
|
||||
nscolor mBodyTextColor;
|
||||
|
||||
ScrollbarStyles mViewportStyleOverflow;
|
||||
mozilla::ScrollbarStyles mViewportStyleOverflow;
|
||||
uint8_t mFocusRingWidth;
|
||||
|
||||
bool mExistThrottledUpdates;
|
||||
|
@ -3107,7 +3107,7 @@ static void ScrollToShowRect(nsIFrame* aFrame,
|
||||
aHorizontal.mWhenToScroll == nsIPresShell::SCROLL_IF_NOT_VISIBLE) {
|
||||
lineSize = aFrameAsScrollable->GetLineScrollAmount();
|
||||
}
|
||||
nsPresContext::ScrollbarStyles ss = aFrameAsScrollable->GetScrollbarStyles();
|
||||
ScrollbarStyles ss = aFrameAsScrollable->GetScrollbarStyles();
|
||||
nsRect allowedRange(scrollPt, nsSize(0, 0));
|
||||
bool needToScroll = false;
|
||||
uint32_t directions = aFrameAsScrollable->GetPerceivedScrollingDirections();
|
||||
|
@ -594,15 +594,14 @@ nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext,
|
||||
return nsHTMLScrollFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
|
||||
}
|
||||
|
||||
nsGfxScrollFrameInner::ScrollbarStyles
|
||||
ScrollbarStyles
|
||||
nsListControlFrame::GetScrollbarStyles() const
|
||||
{
|
||||
// We can't express this in the style system yet; when we can, this can go away
|
||||
// and GetScrollbarStyles can be devirtualized
|
||||
int32_t verticalStyle = IsInDropDownMode() ? NS_STYLE_OVERFLOW_AUTO
|
||||
: NS_STYLE_OVERFLOW_SCROLL;
|
||||
return nsGfxScrollFrameInner::ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN,
|
||||
verticalStyle);
|
||||
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, verticalStyle);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE;
|
||||
virtual void SetFocus(bool aOn = true, bool aRepaint = false) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const MOZ_OVERRIDE;
|
||||
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const MOZ_OVERRIDE;
|
||||
virtual bool ShouldPropagateComputedHeightToScrolledContent() const MOZ_OVERRIDE;
|
||||
|
||||
// for accessibility purposes
|
||||
|
@ -7332,7 +7332,7 @@ nsIFrame::IsFocusable(int32_t *aTabIndex, bool aWithMouse)
|
||||
// will be enough to make them keyboard scrollable.
|
||||
nsIScrollableFrame *scrollFrame = do_QueryFrame(this);
|
||||
if (scrollFrame &&
|
||||
scrollFrame->GetScrollbarStyles() != nsIScrollableFrame::ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN) &&
|
||||
scrollFrame->GetScrollbarStyles() != ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN) &&
|
||||
!scrollFrame->GetScrollRange().IsEqualEdges(nsRect(0, 0, 0, 0))) {
|
||||
// Scroll bars will be used for overflow
|
||||
isFocusable = true;
|
||||
|
@ -159,7 +159,7 @@ nsHTMLScrollFrame::GetType() const
|
||||
struct MOZ_STACK_CLASS ScrollReflowState {
|
||||
const nsHTMLReflowState& mReflowState;
|
||||
nsBoxLayoutState mBoxState;
|
||||
nsGfxScrollFrameInner::ScrollbarStyles mStyles;
|
||||
ScrollbarStyles mStyles;
|
||||
nsMargin mComputedBorder;
|
||||
|
||||
// === Filled in by ReflowScrolledFrame ===
|
||||
@ -652,7 +652,7 @@ nsHTMLScrollFrame::PlaceScrollArea(const ScrollReflowState& aState,
|
||||
nscoord
|
||||
nsHTMLScrollFrame::GetIntrinsicVScrollbarWidth(nsRenderingContext *aRenderingContext)
|
||||
{
|
||||
nsGfxScrollFrameInner::ScrollbarStyles ss = GetScrollbarStyles();
|
||||
ScrollbarStyles ss = GetScrollbarStyles();
|
||||
if (ss.mVertical != NS_STYLE_OVERFLOW_SCROLL || !mInner.mVScrollbarBox)
|
||||
return 0;
|
||||
|
||||
@ -861,7 +861,7 @@ nsHTMLScrollFrame::AccessibleType()
|
||||
// Create an accessible regardless of focusable state because the state can be
|
||||
// changed during frame life cycle without any notifications to accessibility.
|
||||
if (mContent->IsRootOfNativeAnonymousSubtree() ||
|
||||
GetScrollbarStyles() == nsIScrollableFrame::
|
||||
GetScrollbarStyles() ==
|
||||
ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN) ) {
|
||||
return a11y::eNoType;
|
||||
}
|
||||
@ -1080,7 +1080,7 @@ nsXULScrollFrame::GetPrefSize(nsBoxLayoutState& aState)
|
||||
|
||||
nsSize pref = mInner.mScrolledFrame->GetPrefSize(aState);
|
||||
|
||||
nsGfxScrollFrameInner::ScrollbarStyles styles = GetScrollbarStyles();
|
||||
ScrollbarStyles styles = GetScrollbarStyles();
|
||||
|
||||
// scrolled frames don't have their own margins
|
||||
|
||||
@ -1113,7 +1113,7 @@ nsXULScrollFrame::GetMinSize(nsBoxLayoutState& aState)
|
||||
|
||||
nsSize min = mInner.mScrolledFrame->GetMinSizeForScrollArea(aState);
|
||||
|
||||
nsGfxScrollFrameInner::ScrollbarStyles styles = GetScrollbarStyles();
|
||||
ScrollbarStyles styles = GetScrollbarStyles();
|
||||
|
||||
if (mInner.mVScrollbarBox &&
|
||||
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
||||
@ -2342,7 +2342,7 @@ static void HandleScrollPref(nsIScrollable *aScrollable, int32_t aOrientation,
|
||||
}
|
||||
}
|
||||
|
||||
nsGfxScrollFrameInner::ScrollbarStyles
|
||||
ScrollbarStyles
|
||||
nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const
|
||||
{
|
||||
nsPresContext* presContext = mOuter->PresContext();
|
||||
|
@ -51,8 +51,7 @@ public:
|
||||
nsGfxScrollFrameInner(nsContainerFrame* aOuter, bool aIsRoot);
|
||||
~nsGfxScrollFrameInner();
|
||||
|
||||
typedef nsIScrollableFrame::ScrollbarStyles ScrollbarStyles;
|
||||
ScrollbarStyles GetScrollbarStylesFromFrame() const;
|
||||
mozilla::ScrollbarStyles GetScrollbarStylesFromFrame() const;
|
||||
|
||||
// If a child frame was added or removed on the scrollframe,
|
||||
// reload our child frame list.
|
||||
@ -510,7 +509,7 @@ public:
|
||||
virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE {
|
||||
return mInner.GetScrolledFrame();
|
||||
}
|
||||
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const {
|
||||
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const {
|
||||
return mInner.GetScrollbarStylesFromFrame();
|
||||
}
|
||||
virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE {
|
||||
@ -797,7 +796,7 @@ public:
|
||||
virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE {
|
||||
return mInner.GetScrolledFrame();
|
||||
}
|
||||
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const {
|
||||
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const {
|
||||
return mInner.GetScrollbarStylesFromFrame();
|
||||
}
|
||||
virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE {
|
||||
|
@ -10,9 +10,8 @@
|
||||
#ifndef nsIScrollFrame_h___
|
||||
#define nsIScrollFrame_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "ScrollbarStyles.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "nsIScrollbarOwner.h"
|
||||
#include "Units.h"
|
||||
@ -23,6 +22,8 @@
|
||||
class nsBoxLayoutState;
|
||||
class nsIScrollPositionListener;
|
||||
class nsIFrame;
|
||||
class nsPresContext;
|
||||
class nsIContent;
|
||||
|
||||
/**
|
||||
* Interface for frames that are scrollable. This interface exposes
|
||||
@ -41,13 +42,12 @@ public:
|
||||
*/
|
||||
virtual nsIFrame* GetScrolledFrame() const = 0;
|
||||
|
||||
typedef nsPresContext::ScrollbarStyles ScrollbarStyles;
|
||||
/**
|
||||
* 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 ScrollbarStyles GetScrollbarStyles() const = 0;
|
||||
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const = 0;
|
||||
|
||||
enum { HORIZONTAL = 0x01, VERTICAL = 0x02 };
|
||||
/**
|
||||
|
@ -338,7 +338,7 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime)
|
||||
return true;
|
||||
}
|
||||
|
||||
nsPresContext::ScrollbarStyles ss = scrollable->GetScrollbarStyles();
|
||||
ScrollbarStyles ss = scrollable->GetScrollbarStyles();
|
||||
if (ss.mVertical == NS_STYLE_OVERFLOW_HIDDEN &&
|
||||
ss.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
|
||||
scrollable->GetLogicalScrollPosition() == nsPoint(0, 0)) {
|
||||
|
@ -246,7 +246,7 @@ static nsSize CalcViewportUnitsScale(nsPresContext* aPresContext)
|
||||
nsIScrollableFrame* scrollFrame =
|
||||
aPresContext->PresShell()->GetRootScrollFrameAsScrollable();
|
||||
if (scrollFrame) {
|
||||
nsPresContext::ScrollbarStyles styles(scrollFrame->GetScrollbarStyles());
|
||||
ScrollbarStyles styles(scrollFrame->GetScrollbarStyles());
|
||||
|
||||
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL ||
|
||||
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user