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:
Ehsan Akhgari 2013-08-23 16:20:07 -04:00
parent 214420a48a
commit 2faab8bc9e
14 changed files with 59 additions and 42 deletions

View File

@ -2596,7 +2596,7 @@ nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
return frameToScroll; return frameToScroll;
} }
nsPresContext::ScrollbarStyles ss = frameToScroll->GetScrollbarStyles(); ScrollbarStyles ss = frameToScroll->GetScrollbarStyles();
bool hiddenForV = (NS_STYLE_OVERFLOW_HIDDEN == ss.mVertical); bool hiddenForV = (NS_STYLE_OVERFLOW_HIDDEN == ss.mVertical);
bool hiddenForH = (NS_STYLE_OVERFLOW_HIDDEN == ss.mHorizontal); bool hiddenForH = (NS_STYLE_OVERFLOW_HIDDEN == ss.mHorizontal);
if ((hiddenForV && hiddenForH) || if ((hiddenForV && hiddenForH) ||
@ -2705,8 +2705,7 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
ComputeScrollAmountForDefaultAction(aEvent, scrollAmountInDevPixels); ComputeScrollAmountForDefaultAction(aEvent, scrollAmountInDevPixels);
// Don't scroll around the axis whose overflow style is hidden. // Don't scroll around the axis whose overflow style is hidden.
nsPresContext::ScrollbarStyles overflowStyle = ScrollbarStyles overflowStyle = aScrollableFrame->GetScrollbarStyles();
aScrollableFrame->GetScrollbarStyles();
if (overflowStyle.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) { if (overflowStyle.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
actualDevPixelScrollAmount.x = 0; actualDevPixelScrollAmount.x = 0;
} }

View 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

View File

@ -30,6 +30,7 @@ EXPORTS += [
'DisplayListClipState.h', 'DisplayListClipState.h',
'FrameLayerBuilder.h', 'FrameLayerBuilder.h',
'FramePropertyTable.h', 'FramePropertyTable.h',
'ScrollbarStyles.h',
'StackArena.h', 'StackArena.h',
'Units.h', 'Units.h',
'nsArenaMemoryStats.h', 'nsArenaMemoryStats.h',

View File

@ -1144,7 +1144,7 @@ nsLayoutUtils::GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) { for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
nsIScrollableFrame* scrollableFrame = do_QueryFrame(f); nsIScrollableFrame* scrollableFrame = do_QueryFrame(f);
if (scrollableFrame) { if (scrollableFrame) {
nsPresContext::ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles(); ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
uint32_t directions = scrollableFrame->GetPerceivedScrollingDirections(); uint32_t directions = scrollableFrame->GetPerceivedScrollingDirections();
if (aDirection == eVertical ? if (aDirection == eVertical ?
(ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN && (ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN &&
@ -1166,7 +1166,7 @@ nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame, uint32_t aFlags)
f->GetParent() : nsLayoutUtils::GetCrossDocParentFrame(f)) { f->GetParent() : nsLayoutUtils::GetCrossDocParentFrame(f)) {
nsIScrollableFrame* scrollableFrame = do_QueryFrame(f); nsIScrollableFrame* scrollableFrame = do_QueryFrame(f);
if (scrollableFrame) { if (scrollableFrame) {
nsPresContext::ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles(); ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
if ((aFlags & SCROLLABLE_INCLUDE_HIDDEN) || if ((aFlags & SCROLLABLE_INCLUDE_HIDDEN) ||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN || ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN ||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN)

View File

@ -33,6 +33,7 @@
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "prclist.h" #include "prclist.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "ScrollbarStyles.h"
#ifdef IBMBIDI #ifdef IBMBIDI
class nsBidiPresUtils; class nsBidiPresUtils;
@ -628,25 +629,12 @@ public:
nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const
{ return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); } { 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) void SetViewportOverflowOverride(uint8_t aX, uint8_t aY)
{ {
mViewportStyleOverflow.mHorizontal = aX; mViewportStyleOverflow.mHorizontal = aX;
mViewportStyleOverflow.mVertical = aY; mViewportStyleOverflow.mVertical = aY;
} }
ScrollbarStyles GetViewportOverflowOverride() mozilla::ScrollbarStyles GetViewportOverflowOverride()
{ {
return mViewportStyleOverflow; return mViewportStyleOverflow;
} }
@ -1223,7 +1211,7 @@ protected:
nscolor mBodyTextColor; nscolor mBodyTextColor;
ScrollbarStyles mViewportStyleOverflow; mozilla::ScrollbarStyles mViewportStyleOverflow;
uint8_t mFocusRingWidth; uint8_t mFocusRingWidth;
bool mExistThrottledUpdates; bool mExistThrottledUpdates;

View File

@ -3107,7 +3107,7 @@ static void ScrollToShowRect(nsIFrame* aFrame,
aHorizontal.mWhenToScroll == nsIPresShell::SCROLL_IF_NOT_VISIBLE) { aHorizontal.mWhenToScroll == nsIPresShell::SCROLL_IF_NOT_VISIBLE) {
lineSize = aFrameAsScrollable->GetLineScrollAmount(); lineSize = aFrameAsScrollable->GetLineScrollAmount();
} }
nsPresContext::ScrollbarStyles ss = aFrameAsScrollable->GetScrollbarStyles(); ScrollbarStyles ss = aFrameAsScrollable->GetScrollbarStyles();
nsRect allowedRange(scrollPt, nsSize(0, 0)); nsRect allowedRange(scrollPt, nsSize(0, 0));
bool needToScroll = false; bool needToScroll = false;
uint32_t directions = aFrameAsScrollable->GetPerceivedScrollingDirections(); uint32_t directions = aFrameAsScrollable->GetPerceivedScrollingDirections();

View File

@ -594,15 +594,14 @@ nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext,
return nsHTMLScrollFrame::Reflow(aPresContext, aDesiredSize, state, aStatus); return nsHTMLScrollFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
} }
nsGfxScrollFrameInner::ScrollbarStyles ScrollbarStyles
nsListControlFrame::GetScrollbarStyles() const nsListControlFrame::GetScrollbarStyles() const
{ {
// We can't express this in the style system yet; when we can, this can go away // We can't express this in the style system yet; when we can, this can go away
// and GetScrollbarStyles can be devirtualized // and GetScrollbarStyles can be devirtualized
int32_t verticalStyle = IsInDropDownMode() ? NS_STYLE_OVERFLOW_AUTO int32_t verticalStyle = IsInDropDownMode() ? NS_STYLE_OVERFLOW_AUTO
: NS_STYLE_OVERFLOW_SCROLL; : NS_STYLE_OVERFLOW_SCROLL;
return nsGfxScrollFrameInner::ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, verticalStyle);
verticalStyle);
} }
bool bool

View File

@ -107,7 +107,7 @@ public:
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE; virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE;
virtual void SetFocus(bool aOn = true, bool aRepaint = false) 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; virtual bool ShouldPropagateComputedHeightToScrolledContent() const MOZ_OVERRIDE;
// for accessibility purposes // for accessibility purposes

View File

@ -7332,7 +7332,7 @@ nsIFrame::IsFocusable(int32_t *aTabIndex, bool aWithMouse)
// will be enough to make them keyboard scrollable. // will be enough to make them keyboard scrollable.
nsIScrollableFrame *scrollFrame = do_QueryFrame(this); nsIScrollableFrame *scrollFrame = do_QueryFrame(this);
if (scrollFrame && 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))) { !scrollFrame->GetScrollRange().IsEqualEdges(nsRect(0, 0, 0, 0))) {
// Scroll bars will be used for overflow // Scroll bars will be used for overflow
isFocusable = true; isFocusable = true;

View File

@ -159,7 +159,7 @@ nsHTMLScrollFrame::GetType() const
struct MOZ_STACK_CLASS ScrollReflowState { struct MOZ_STACK_CLASS ScrollReflowState {
const nsHTMLReflowState& mReflowState; const nsHTMLReflowState& mReflowState;
nsBoxLayoutState mBoxState; nsBoxLayoutState mBoxState;
nsGfxScrollFrameInner::ScrollbarStyles mStyles; ScrollbarStyles mStyles;
nsMargin mComputedBorder; nsMargin mComputedBorder;
// === Filled in by ReflowScrolledFrame === // === Filled in by ReflowScrolledFrame ===
@ -652,7 +652,7 @@ nsHTMLScrollFrame::PlaceScrollArea(const ScrollReflowState& aState,
nscoord nscoord
nsHTMLScrollFrame::GetIntrinsicVScrollbarWidth(nsRenderingContext *aRenderingContext) nsHTMLScrollFrame::GetIntrinsicVScrollbarWidth(nsRenderingContext *aRenderingContext)
{ {
nsGfxScrollFrameInner::ScrollbarStyles ss = GetScrollbarStyles(); ScrollbarStyles ss = GetScrollbarStyles();
if (ss.mVertical != NS_STYLE_OVERFLOW_SCROLL || !mInner.mVScrollbarBox) if (ss.mVertical != NS_STYLE_OVERFLOW_SCROLL || !mInner.mVScrollbarBox)
return 0; return 0;
@ -861,7 +861,7 @@ nsHTMLScrollFrame::AccessibleType()
// Create an accessible regardless of focusable state because the state can be // Create an accessible regardless of focusable state because the state can be
// changed during frame life cycle without any notifications to accessibility. // changed during frame life cycle without any notifications to accessibility.
if (mContent->IsRootOfNativeAnonymousSubtree() || if (mContent->IsRootOfNativeAnonymousSubtree() ||
GetScrollbarStyles() == nsIScrollableFrame:: GetScrollbarStyles() ==
ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN) ) { ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN) ) {
return a11y::eNoType; return a11y::eNoType;
} }
@ -1080,7 +1080,7 @@ nsXULScrollFrame::GetPrefSize(nsBoxLayoutState& aState)
nsSize pref = mInner.mScrolledFrame->GetPrefSize(aState); nsSize pref = mInner.mScrolledFrame->GetPrefSize(aState);
nsGfxScrollFrameInner::ScrollbarStyles styles = GetScrollbarStyles(); ScrollbarStyles styles = GetScrollbarStyles();
// scrolled frames don't have their own margins // scrolled frames don't have their own margins
@ -1113,7 +1113,7 @@ nsXULScrollFrame::GetMinSize(nsBoxLayoutState& aState)
nsSize min = mInner.mScrolledFrame->GetMinSizeForScrollArea(aState); nsSize min = mInner.mScrolledFrame->GetMinSizeForScrollArea(aState);
nsGfxScrollFrameInner::ScrollbarStyles styles = GetScrollbarStyles(); ScrollbarStyles styles = GetScrollbarStyles();
if (mInner.mVScrollbarBox && if (mInner.mVScrollbarBox &&
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) { styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
@ -2342,7 +2342,7 @@ static void HandleScrollPref(nsIScrollable *aScrollable, int32_t aOrientation,
} }
} }
nsGfxScrollFrameInner::ScrollbarStyles ScrollbarStyles
nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const
{ {
nsPresContext* presContext = mOuter->PresContext(); nsPresContext* presContext = mOuter->PresContext();

View File

@ -51,8 +51,7 @@ public:
nsGfxScrollFrameInner(nsContainerFrame* aOuter, bool aIsRoot); nsGfxScrollFrameInner(nsContainerFrame* aOuter, bool aIsRoot);
~nsGfxScrollFrameInner(); ~nsGfxScrollFrameInner();
typedef nsIScrollableFrame::ScrollbarStyles ScrollbarStyles; mozilla::ScrollbarStyles GetScrollbarStylesFromFrame() const;
ScrollbarStyles GetScrollbarStylesFromFrame() const;
// If a child frame was added or removed on the scrollframe, // If a child frame was added or removed on the scrollframe,
// reload our child frame list. // reload our child frame list.
@ -510,7 +509,7 @@ public:
virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE { virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE {
return mInner.GetScrolledFrame(); return mInner.GetScrolledFrame();
} }
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const { virtual mozilla::ScrollbarStyles GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame(); return mInner.GetScrollbarStylesFromFrame();
} }
virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE { virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE {
@ -797,7 +796,7 @@ public:
virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE { virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE {
return mInner.GetScrolledFrame(); return mInner.GetScrolledFrame();
} }
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const { virtual mozilla::ScrollbarStyles GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame(); return mInner.GetScrollbarStylesFromFrame();
} }
virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE { virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE {

View File

@ -10,9 +10,8 @@
#ifndef nsIScrollFrame_h___ #ifndef nsIScrollFrame_h___
#define nsIScrollFrame_h___ #define nsIScrollFrame_h___
#include "nsISupports.h"
#include "nsCoord.h" #include "nsCoord.h"
#include "nsPresContext.h" #include "ScrollbarStyles.h"
#include "mozilla/gfx/Point.h" #include "mozilla/gfx/Point.h"
#include "nsIScrollbarOwner.h" #include "nsIScrollbarOwner.h"
#include "Units.h" #include "Units.h"
@ -23,6 +22,8 @@
class nsBoxLayoutState; class nsBoxLayoutState;
class nsIScrollPositionListener; class nsIScrollPositionListener;
class nsIFrame; class nsIFrame;
class nsPresContext;
class nsIContent;
/** /**
* Interface for frames that are scrollable. This interface exposes * Interface for frames that are scrollable. This interface exposes
@ -41,13 +42,12 @@ public:
*/ */
virtual nsIFrame* GetScrolledFrame() const = 0; virtual nsIFrame* GetScrolledFrame() const = 0;
typedef nsPresContext::ScrollbarStyles ScrollbarStyles;
/** /**
* Get the styles (NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN, * Get the styles (NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
* or NS_STYLE_OVERFLOW_AUTO) governing the horizontal and vertical * or NS_STYLE_OVERFLOW_AUTO) governing the horizontal and vertical
* scrollbars for this frame. * scrollbars for this frame.
*/ */
virtual ScrollbarStyles GetScrollbarStyles() const = 0; virtual mozilla::ScrollbarStyles GetScrollbarStyles() const = 0;
enum { HORIZONTAL = 0x01, VERTICAL = 0x02 }; enum { HORIZONTAL = 0x01, VERTICAL = 0x02 };
/** /**

View File

@ -338,7 +338,7 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime)
return true; return true;
} }
nsPresContext::ScrollbarStyles ss = scrollable->GetScrollbarStyles(); ScrollbarStyles ss = scrollable->GetScrollbarStyles();
if (ss.mVertical == NS_STYLE_OVERFLOW_HIDDEN && if (ss.mVertical == NS_STYLE_OVERFLOW_HIDDEN &&
ss.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN && ss.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
scrollable->GetLogicalScrollPosition() == nsPoint(0, 0)) { scrollable->GetLogicalScrollPosition() == nsPoint(0, 0)) {

View File

@ -246,7 +246,7 @@ static nsSize CalcViewportUnitsScale(nsPresContext* aPresContext)
nsIScrollableFrame* scrollFrame = nsIScrollableFrame* scrollFrame =
aPresContext->PresShell()->GetRootScrollFrameAsScrollable(); aPresContext->PresShell()->GetRootScrollFrameAsScrollable();
if (scrollFrame) { if (scrollFrame) {
nsPresContext::ScrollbarStyles styles(scrollFrame->GetScrollbarStyles()); ScrollbarStyles styles(scrollFrame->GetScrollbarStyles());
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL || if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL ||
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) { styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {