1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/nsGfxScrollFrame.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1058 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* rendering object to wrap rendering objects that should be scrollable */ 1.10 + 1.11 +#ifndef nsGfxScrollFrame_h___ 1.12 +#define nsGfxScrollFrame_h___ 1.13 + 1.14 +#include "mozilla/Attributes.h" 1.15 +#include "nsContainerFrame.h" 1.16 +#include "nsIAnonymousContentCreator.h" 1.17 +#include "nsBoxFrame.h" 1.18 +#include "nsIScrollableFrame.h" 1.19 +#include "nsIStatefulFrame.h" 1.20 +#include "nsThreadUtils.h" 1.21 +#include "nsIReflowCallback.h" 1.22 +#include "nsBoxLayoutState.h" 1.23 +#include "nsQueryFrame.h" 1.24 +#include "nsExpirationTracker.h" 1.25 + 1.26 +class nsPresContext; 1.27 +class nsIPresShell; 1.28 +class nsIContent; 1.29 +class nsIAtom; 1.30 +class nsIScrollFrameInternal; 1.31 +class nsPresState; 1.32 +class nsIScrollPositionListener; 1.33 +struct ScrollReflowState; 1.34 + 1.35 +namespace mozilla { 1.36 +namespace layout { 1.37 +class ScrollbarActivity; 1.38 +} 1.39 +} 1.40 + 1.41 +namespace mozilla { 1.42 + 1.43 +class ScrollFrameHelper : public nsIReflowCallback { 1.44 +public: 1.45 + typedef mozilla::CSSIntPoint CSSIntPoint; 1.46 + typedef mozilla::layout::ScrollbarActivity ScrollbarActivity; 1.47 + 1.48 + class AsyncScroll; 1.49 + 1.50 + ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot); 1.51 + ~ScrollFrameHelper(); 1.52 + 1.53 + mozilla::ScrollbarStyles GetScrollbarStylesFromFrame() const; 1.54 + 1.55 + // If a child frame was added or removed on the scrollframe, 1.56 + // reload our child frame list. 1.57 + // We need this if a scrollbar frame is recreated. 1.58 + void ReloadChildFrames(); 1.59 + 1.60 + nsresult CreateAnonymousContent( 1.61 + nsTArray<nsIAnonymousContentCreator::ContentInfo>& aElements); 1.62 + void AppendAnonymousContentTo(nsBaseContentList& aElements, uint32_t aFilter); 1.63 + nsresult FireScrollPortEvent(); 1.64 + void PostOverflowEvent(); 1.65 + void Destroy(); 1.66 + 1.67 + void BuildDisplayList(nsDisplayListBuilder* aBuilder, 1.68 + const nsRect& aDirtyRect, 1.69 + const nsDisplayListSet& aLists); 1.70 + 1.71 + void AppendScrollPartsTo(nsDisplayListBuilder* aBuilder, 1.72 + const nsRect& aDirtyRect, 1.73 + const nsDisplayListSet& aLists, 1.74 + bool& aCreateLayer, 1.75 + bool aPositioned); 1.76 + 1.77 + bool GetBorderRadii(nscoord aRadii[8]) const; 1.78 + 1.79 + // nsIReflowCallback 1.80 + virtual bool ReflowFinished() MOZ_OVERRIDE; 1.81 + virtual void ReflowCallbackCanceled() MOZ_OVERRIDE; 1.82 + 1.83 + /** 1.84 + * @note This method might destroy the frame, pres shell and other objects. 1.85 + * Called when the 'curpos' attribute on one of the scrollbars changes. 1.86 + */ 1.87 + void CurPosAttributeChanged(nsIContent* aChild); 1.88 + 1.89 + void PostScrollEvent(); 1.90 + void FireScrollEvent(); 1.91 + void PostScrolledAreaEvent(); 1.92 + void FireScrolledAreaEvent(); 1.93 + 1.94 + class ScrollEvent : public nsRunnable { 1.95 + public: 1.96 + NS_DECL_NSIRUNNABLE 1.97 + ScrollEvent(ScrollFrameHelper *helper) : mHelper(helper) {} 1.98 + void Revoke() { mHelper = nullptr; } 1.99 + private: 1.100 + ScrollFrameHelper *mHelper; 1.101 + }; 1.102 + 1.103 + class AsyncScrollPortEvent : public nsRunnable { 1.104 + public: 1.105 + NS_DECL_NSIRUNNABLE 1.106 + AsyncScrollPortEvent(ScrollFrameHelper *helper) : mHelper(helper) {} 1.107 + void Revoke() { mHelper = nullptr; } 1.108 + private: 1.109 + ScrollFrameHelper *mHelper; 1.110 + }; 1.111 + 1.112 + class ScrolledAreaEvent : public nsRunnable { 1.113 + public: 1.114 + NS_DECL_NSIRUNNABLE 1.115 + ScrolledAreaEvent(ScrollFrameHelper *helper) : mHelper(helper) {} 1.116 + void Revoke() { mHelper = nullptr; } 1.117 + private: 1.118 + ScrollFrameHelper *mHelper; 1.119 + }; 1.120 + 1.121 + /** 1.122 + * @note This method might destroy the frame, pres shell and other objects. 1.123 + */ 1.124 + void FinishReflowForScrollbar(nsIContent* aContent, nscoord aMinXY, 1.125 + nscoord aMaxXY, nscoord aCurPosXY, 1.126 + nscoord aPageIncrement, 1.127 + nscoord aIncrement); 1.128 + /** 1.129 + * @note This method might destroy the frame, pres shell and other objects. 1.130 + */ 1.131 + void SetScrollbarEnabled(nsIContent* aContent, nscoord aMaxPos); 1.132 + /** 1.133 + * @note This method might destroy the frame, pres shell and other objects. 1.134 + */ 1.135 + void SetCoordAttribute(nsIContent* aContent, nsIAtom* aAtom, nscoord aSize); 1.136 + 1.137 + nscoord GetCoordAttribute(nsIFrame* aFrame, nsIAtom* aAtom, nscoord aDefaultValue, 1.138 + nscoord* aRangeStart, nscoord* aRangeLength); 1.139 + 1.140 + /** 1.141 + * @note This method might destroy the frame, pres shell and other objects. 1.142 + * Update scrollbar curpos attributes to reflect current scroll position 1.143 + */ 1.144 + void UpdateScrollbarPosition(); 1.145 + 1.146 + nsRect GetScrollPortRect() const { return mScrollPort; } 1.147 + nsPoint GetScrollPosition() const { 1.148 + return mScrollPort.TopLeft() - mScrolledFrame->GetPosition(); 1.149 + } 1.150 + /** 1.151 + * For LTR frames, the logical scroll position is the offset of the top left 1.152 + * corner of the frame from the top left corner of the scroll port (same as 1.153 + * GetScrollPosition). 1.154 + * For RTL frames, it is the offset of the top right corner of the frame from 1.155 + * the top right corner of the scroll port 1.156 + */ 1.157 + nsPoint GetLogicalScrollPosition() const { 1.158 + nsPoint pt; 1.159 + pt.x = IsLTR() ? 1.160 + mScrollPort.x - mScrolledFrame->GetPosition().x : 1.161 + mScrollPort.XMost() - mScrolledFrame->GetRect().XMost(); 1.162 + pt.y = mScrollPort.y - mScrolledFrame->GetPosition().y; 1.163 + return pt; 1.164 + } 1.165 + nsRect GetScrollRange() const; 1.166 + // Get the scroll range assuming the scrollport has size (aWidth, aHeight). 1.167 + nsRect GetScrollRange(nscoord aWidth, nscoord aHeight) const; 1.168 + nsSize GetScrollPositionClampingScrollPortSize() const; 1.169 + gfxSize GetResolution() const; 1.170 + void SetResolution(const gfxSize& aResolution); 1.171 + 1.172 +protected: 1.173 + nsRect GetScrollRangeForClamping() const; 1.174 + 1.175 +public: 1.176 + static void AsyncScrollCallback(void* anInstance, mozilla::TimeStamp aTime); 1.177 + /** 1.178 + * @note This method might destroy the frame, pres shell and other objects. 1.179 + * aRange is the range of allowable scroll positions around the desired 1.180 + * aScrollPosition. Null means only aScrollPosition is allowed. 1.181 + * This is a closed-ended range --- aRange.XMost()/aRange.YMost() are allowed. 1.182 + */ 1.183 + void ScrollTo(nsPoint aScrollPosition, nsIScrollableFrame::ScrollMode aMode, 1.184 + const nsRect* aRange = nullptr) { 1.185 + ScrollToWithOrigin(aScrollPosition, aMode, nsGkAtoms::other, aRange); 1.186 + } 1.187 + /** 1.188 + * @note This method might destroy the frame, pres shell and other objects. 1.189 + */ 1.190 + void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition); 1.191 + /** 1.192 + * @note This method might destroy the frame, pres shell and other objects. 1.193 + */ 1.194 + void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition, 1.195 + nsIAtom* aOrigin = nullptr); 1.196 + 1.197 + CSSIntPoint GetScrollPositionCSSPixels(); 1.198 + /** 1.199 + * @note This method might destroy the frame, pres shell and other objects. 1.200 + */ 1.201 + void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange, nsIAtom* aOrigin = nullptr); 1.202 + void ScrollVisual(nsPoint aOldScrolledFramePosition); 1.203 + /** 1.204 + * @note This method might destroy the frame, pres shell and other objects. 1.205 + */ 1.206 + void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit, 1.207 + nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow, nsIAtom *aOrigin = nullptr); 1.208 + /** 1.209 + * @note This method might destroy the frame, pres shell and other objects. 1.210 + */ 1.211 + void ScrollToRestoredPosition(); 1.212 + 1.213 + nsSize GetLineScrollAmount() const; 1.214 + nsSize GetPageScrollAmount() const; 1.215 + 1.216 + nsPresState* SaveState() const; 1.217 + void RestoreState(nsPresState* aState); 1.218 + 1.219 + nsIFrame* GetScrolledFrame() const { return mScrolledFrame; } 1.220 + nsIFrame* GetScrollbarBox(bool aVertical) const { 1.221 + return aVertical ? mVScrollbarBox : mHScrollbarBox; 1.222 + } 1.223 + 1.224 + void AddScrollPositionListener(nsIScrollPositionListener* aListener) { 1.225 + mListeners.AppendElement(aListener); 1.226 + } 1.227 + void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) { 1.228 + mListeners.RemoveElement(aListener); 1.229 + } 1.230 + 1.231 + static void SetScrollbarVisibility(nsIFrame* aScrollbar, bool aVisible); 1.232 + 1.233 + /** 1.234 + * GetScrolledRect is designed to encapsulate deciding which 1.235 + * directions of overflow should be reachable by scrolling and which 1.236 + * should not. Callers should NOT depend on it having any particular 1.237 + * behavior (although nsXULScrollFrame currently does). 1.238 + * 1.239 + * This should only be called when the scrolled frame has been 1.240 + * reflowed with the scroll port size given in mScrollPort. 1.241 + * 1.242 + * Currently it allows scrolling down and to the right for 1.243 + * nsHTMLScrollFrames with LTR directionality and for all 1.244 + * nsXULScrollFrames, and allows scrolling down and to the left for 1.245 + * nsHTMLScrollFrames with RTL directionality. 1.246 + */ 1.247 + nsRect GetScrolledRect() const; 1.248 + 1.249 + /** 1.250 + * GetScrolledRectInternal is designed to encapsulate deciding which 1.251 + * directions of overflow should be reachable by scrolling and which 1.252 + * should not. Callers should NOT depend on it having any particular 1.253 + * behavior (although nsXULScrollFrame currently does). 1.254 + * 1.255 + * Currently it allows scrolling down and to the right for 1.256 + * nsHTMLScrollFrames with LTR directionality and for all 1.257 + * nsXULScrollFrames, and allows scrolling down and to the left for 1.258 + * nsHTMLScrollFrames with RTL directionality. 1.259 + */ 1.260 + nsRect GetScrolledRectInternal(const nsRect& aScrolledOverflowArea, 1.261 + const nsSize& aScrollPortSize) const; 1.262 + 1.263 + uint32_t GetScrollbarVisibility() const { 1.264 + return (mHasVerticalScrollbar ? nsIScrollableFrame::VERTICAL : 0) | 1.265 + (mHasHorizontalScrollbar ? nsIScrollableFrame::HORIZONTAL : 0); 1.266 + } 1.267 + nsMargin GetActualScrollbarSizes() const; 1.268 + nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState); 1.269 + nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState); 1.270 + bool IsLTR() const; 1.271 + bool IsScrollbarOnRight() const; 1.272 + bool IsScrollingActive() const { return mScrollingActive || mShouldBuildScrollableLayer; } 1.273 + bool IsProcessingAsyncScroll() const { return mAsyncScroll != nullptr; } 1.274 + void ResetScrollPositionForLayerPixelAlignment() 1.275 + { 1.276 + mScrollPosForLayerPixelAlignment = GetScrollPosition(); 1.277 + } 1.278 + 1.279 + bool UpdateOverflow(); 1.280 + 1.281 + void UpdateSticky(); 1.282 + 1.283 + bool IsRectNearlyVisible(const nsRect& aRect) const; 1.284 + 1.285 + // adjust the scrollbar rectangle aRect to account for any visible resizer. 1.286 + // aHasResizer specifies if there is a content resizer, however this method 1.287 + // will also check if a widget resizer is present as well. 1.288 + void AdjustScrollbarRectForResizer(nsIFrame* aFrame, nsPresContext* aPresContext, 1.289 + nsRect& aRect, bool aHasResizer, bool aVertical); 1.290 + // returns true if a resizer should be visible 1.291 + bool HasResizer() { return mResizerBox && !mCollapsedResizer; } 1.292 + void LayoutScrollbars(nsBoxLayoutState& aState, 1.293 + const nsRect& aContentArea, 1.294 + const nsRect& aOldScrollArea); 1.295 + 1.296 + bool IsIgnoringViewportClipping() const; 1.297 + 1.298 + bool ShouldClampScrollPosition() const; 1.299 + 1.300 + bool IsAlwaysActive() const; 1.301 + void MarkActive(); 1.302 + void MarkInactive(); 1.303 + nsExpirationState* GetExpirationState() { return &mActivityExpirationState; } 1.304 + 1.305 + void ScheduleSyntheticMouseMove(); 1.306 + static void ScrollActivityCallback(nsITimer *aTimer, void* anInstance); 1.307 + 1.308 + void HandleScrollbarStyleSwitching(); 1.309 + 1.310 + nsIAtom* OriginOfLastScroll() const { return mOriginOfLastScroll; } 1.311 + uint32_t CurrentScrollGeneration() const { return mScrollGeneration; } 1.312 + void ResetOriginIfScrollAtGeneration(uint32_t aGeneration) { 1.313 + if (aGeneration == mScrollGeneration) { 1.314 + mOriginOfLastScroll = nullptr; 1.315 + } 1.316 + } 1.317 + bool WantAsyncScroll() const; 1.318 + 1.319 + // owning references to the nsIAnonymousContentCreator-built content 1.320 + nsCOMPtr<nsIContent> mHScrollbarContent; 1.321 + nsCOMPtr<nsIContent> mVScrollbarContent; 1.322 + nsCOMPtr<nsIContent> mScrollCornerContent; 1.323 + nsCOMPtr<nsIContent> mResizerContent; 1.324 + 1.325 + nsRevocableEventPtr<ScrollEvent> mScrollEvent; 1.326 + nsRevocableEventPtr<AsyncScrollPortEvent> mAsyncScrollPortEvent; 1.327 + nsRevocableEventPtr<ScrolledAreaEvent> mScrolledAreaEvent; 1.328 + nsIFrame* mHScrollbarBox; 1.329 + nsIFrame* mVScrollbarBox; 1.330 + nsIFrame* mScrolledFrame; 1.331 + nsIFrame* mScrollCornerBox; 1.332 + nsIFrame* mResizerBox; 1.333 + nsContainerFrame* mOuter; 1.334 + nsRefPtr<AsyncScroll> mAsyncScroll; 1.335 + nsRefPtr<ScrollbarActivity> mScrollbarActivity; 1.336 + nsTArray<nsIScrollPositionListener*> mListeners; 1.337 + nsIAtom* mOriginOfLastScroll; 1.338 + uint32_t mScrollGeneration; 1.339 + nsRect mScrollPort; 1.340 + // Where we're currently scrolling to, if we're scrolling asynchronously. 1.341 + // If we're not in the middle of an asynchronous scroll then this is 1.342 + // just the current scroll position. ScrollBy will choose its 1.343 + // destination based on this value. 1.344 + nsPoint mDestination; 1.345 + nsPoint mScrollPosAtLastPaint; 1.346 + 1.347 + // A goal position to try to scroll to as content loads. As long as mLastPos 1.348 + // matches the current logical scroll position, we try to scroll to mRestorePos 1.349 + // after every reflow --- because after each time content is loaded/added to the 1.350 + // scrollable element, there will be a reflow. 1.351 + nsPoint mRestorePos; 1.352 + // The last logical position we scrolled to while trying to restore mRestorePos, or 1.353 + // 0,0 when this is a new frame. Set to -1,-1 once we've scrolled for any reason 1.354 + // other than trying to restore mRestorePos. 1.355 + nsPoint mLastPos; 1.356 + 1.357 + // The current resolution derived from the zoom level and device pixel ratio. 1.358 + gfxSize mResolution; 1.359 + 1.360 + nsExpirationState mActivityExpirationState; 1.361 + 1.362 + nsCOMPtr<nsITimer> mScrollActivityTimer; 1.363 + nsPoint mScrollPosForLayerPixelAlignment; 1.364 + 1.365 + // The scroll position where we last updated image visibility. 1.366 + nsPoint mLastUpdateImagesPos; 1.367 + 1.368 + bool mNeverHasVerticalScrollbar:1; 1.369 + bool mNeverHasHorizontalScrollbar:1; 1.370 + bool mHasVerticalScrollbar:1; 1.371 + bool mHasHorizontalScrollbar:1; 1.372 + bool mFrameIsUpdatingScrollbar:1; 1.373 + bool mDidHistoryRestore:1; 1.374 + // Is this the scrollframe for the document's viewport? 1.375 + bool mIsRoot:1; 1.376 + // True if we should clip all descendants, false if we should only clip 1.377 + // descendants for which we are the containing block. 1.378 + bool mClipAllDescendants:1; 1.379 + // If true, don't try to layout the scrollbars in Reflow(). This can be 1.380 + // useful if multiple passes are involved, because we don't want to place the 1.381 + // scrollbars at the wrong size. 1.382 + bool mSupppressScrollbarUpdate:1; 1.383 + // If true, we skipped a scrollbar layout due to mSupppressScrollbarUpdate 1.384 + // being set at some point. That means we should lay out scrollbars even if 1.385 + // it might not strictly be needed next time mSupppressScrollbarUpdate is 1.386 + // false. 1.387 + bool mSkippedScrollbarLayout:1; 1.388 + 1.389 + bool mHadNonInitialReflow:1; 1.390 + // State used only by PostScrollEvents so we know 1.391 + // which overflow states have changed. 1.392 + bool mHorizontalOverflow:1; 1.393 + bool mVerticalOverflow:1; 1.394 + bool mPostedReflowCallback:1; 1.395 + bool mMayHaveDirtyFixedChildren:1; 1.396 + // If true, need to actually update our scrollbar attributes in the 1.397 + // reflow callback. 1.398 + bool mUpdateScrollbarAttributes:1; 1.399 + // If true, we should be prepared to scroll using this scrollframe 1.400 + // by placing descendant content into its own layer(s) 1.401 + bool mScrollingActive:1; 1.402 + // If true, the resizer is collapsed and not displayed 1.403 + bool mCollapsedResizer:1; 1.404 + 1.405 + // If true, the layer should always be active because we always build a 1.406 + // scrollable layer. Used for asynchronous scrolling. 1.407 + bool mShouldBuildScrollableLayer:1; 1.408 + 1.409 + // True if this frame has been scrolled at least once 1.410 + bool mHasBeenScrolled:1; 1.411 + 1.412 + // True if the frame's resolution has been set via SetResolution or restored 1.413 + // via RestoreState. 1.414 + bool mIsResolutionSet:1; 1.415 + 1.416 +protected: 1.417 + /** 1.418 + * @note This method might destroy the frame, pres shell and other objects. 1.419 + */ 1.420 + void ScrollToWithOrigin(nsPoint aScrollPosition, 1.421 + nsIScrollableFrame::ScrollMode aMode, 1.422 + nsIAtom *aOrigin, // nullptr indicates "other" origin 1.423 + const nsRect* aRange); 1.424 + 1.425 + nsRect ExpandRect(const nsRect& aRect) const; 1.426 + static void EnsureImageVisPrefsCached(); 1.427 + static bool sImageVisPrefsCached; 1.428 + // The number of scrollports wide/high to expand when looking for images. 1.429 + static uint32_t sHorzExpandScrollPort; 1.430 + static uint32_t sVertExpandScrollPort; 1.431 + // The fraction of the scrollport we allow to scroll by before we schedule 1.432 + // an update of image visibility. 1.433 + static int32_t sHorzScrollFraction; 1.434 + static int32_t sVertScrollFraction; 1.435 +}; 1.436 + 1.437 +} 1.438 + 1.439 +/** 1.440 + * The scroll frame creates and manages the scrolling view 1.441 + * 1.442 + * It only supports having a single child frame that typically is an area 1.443 + * frame, but doesn't have to be. The child frame must have a view, though 1.444 + * 1.445 + * Scroll frames don't support incremental changes, i.e. you can't replace 1.446 + * or remove the scrolled frame 1.447 + */ 1.448 +class nsHTMLScrollFrame : public nsContainerFrame, 1.449 + public nsIScrollableFrame, 1.450 + public nsIAnonymousContentCreator, 1.451 + public nsIStatefulFrame { 1.452 +public: 1.453 + typedef mozilla::ScrollFrameHelper ScrollFrameHelper; 1.454 + typedef mozilla::CSSIntPoint CSSIntPoint; 1.455 + friend nsIFrame* NS_NewHTMLScrollFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot); 1.456 + 1.457 + NS_DECL_QUERYFRAME 1.458 + NS_DECL_FRAMEARENA_HELPERS 1.459 + 1.460 + // Called to set the child frames. We typically have three: the scroll area, 1.461 + // the vertical scrollbar, and the horizontal scrollbar. 1.462 + virtual nsresult SetInitialChildList(ChildListID aListID, 1.463 + nsFrameList& aChildList) MOZ_OVERRIDE; 1.464 + 1.465 + virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, 1.466 + const nsRect& aDirtyRect, 1.467 + const nsDisplayListSet& aLists) MOZ_OVERRIDE { 1.468 + mHelper.BuildDisplayList(aBuilder, aDirtyRect, aLists); 1.469 + } 1.470 + 1.471 + bool TryLayout(ScrollReflowState* aState, 1.472 + nsHTMLReflowMetrics* aKidMetrics, 1.473 + bool aAssumeVScroll, bool aAssumeHScroll, 1.474 + bool aForce, nsresult* aResult); 1.475 + bool ScrolledContentDependsOnHeight(ScrollReflowState* aState); 1.476 + nsresult ReflowScrolledFrame(ScrollReflowState* aState, 1.477 + bool aAssumeHScroll, 1.478 + bool aAssumeVScroll, 1.479 + nsHTMLReflowMetrics* aMetrics, 1.480 + bool aFirstPass); 1.481 + nsresult ReflowContents(ScrollReflowState* aState, 1.482 + const nsHTMLReflowMetrics& aDesiredSize); 1.483 + void PlaceScrollArea(const ScrollReflowState& aState, 1.484 + const nsPoint& aScrollPosition); 1.485 + nscoord GetIntrinsicVScrollbarWidth(nsRenderingContext *aRenderingContext); 1.486 + 1.487 + virtual bool GetBorderRadii(nscoord aRadii[8]) const MOZ_OVERRIDE { 1.488 + return mHelper.GetBorderRadii(aRadii); 1.489 + } 1.490 + 1.491 + virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; 1.492 + virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; 1.493 + virtual nsresult GetPadding(nsMargin& aPadding) MOZ_OVERRIDE; 1.494 + virtual bool IsCollapsed() MOZ_OVERRIDE; 1.495 + 1.496 + virtual nsresult Reflow(nsPresContext* aPresContext, 1.497 + nsHTMLReflowMetrics& aDesiredSize, 1.498 + const nsHTMLReflowState& aReflowState, 1.499 + nsReflowStatus& aStatus) MOZ_OVERRIDE; 1.500 + 1.501 + virtual bool UpdateOverflow() MOZ_OVERRIDE { 1.502 + return mHelper.UpdateOverflow(); 1.503 + } 1.504 + 1.505 + // Because there can be only one child frame, these two function return 1.506 + // NS_ERROR_FAILURE 1.507 + virtual nsresult AppendFrames(ChildListID aListID, 1.508 + nsFrameList& aFrameList) MOZ_OVERRIDE; 1.509 + virtual nsresult InsertFrames(ChildListID aListID, 1.510 + nsIFrame* aPrevFrame, 1.511 + nsFrameList& aFrameList) MOZ_OVERRIDE; 1.512 + 1.513 + virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; 1.514 + 1.515 + 1.516 + virtual nsresult RemoveFrame(ChildListID aListID, 1.517 + nsIFrame* aOldFrame) MOZ_OVERRIDE; 1.518 + 1.519 + virtual nsIScrollableFrame* GetScrollTargetFrame() MOZ_OVERRIDE { 1.520 + return this; 1.521 + } 1.522 + 1.523 + virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE { 1.524 + return mHelper.GetScrolledFrame()->GetContentInsertionFrame(); 1.525 + } 1.526 + 1.527 + virtual bool DoesClipChildren() MOZ_OVERRIDE { return true; } 1.528 + virtual nsSplittableType GetSplittableType() const MOZ_OVERRIDE; 1.529 + 1.530 + virtual nsPoint GetPositionOfChildIgnoringScrolling(nsIFrame* aChild) MOZ_OVERRIDE 1.531 + { nsPoint pt = aChild->GetPosition(); 1.532 + if (aChild == mHelper.GetScrolledFrame()) pt += GetScrollPosition(); 1.533 + return pt; 1.534 + } 1.535 + 1.536 + // nsIAnonymousContentCreator 1.537 + virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE; 1.538 + virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, 1.539 + uint32_t aFilter) MOZ_OVERRIDE; 1.540 + 1.541 + // nsIScrollbarOwner 1.542 + virtual nsIFrame* GetScrollbarBox(bool aVertical) MOZ_OVERRIDE { 1.543 + return mHelper.GetScrollbarBox(aVertical); 1.544 + } 1.545 + 1.546 + virtual void ScrollbarActivityStarted() const MOZ_OVERRIDE; 1.547 + virtual void ScrollbarActivityStopped() const MOZ_OVERRIDE; 1.548 + 1.549 + // nsIScrollableFrame 1.550 + virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE { 1.551 + return mHelper.GetScrolledFrame(); 1.552 + } 1.553 + virtual mozilla::ScrollbarStyles GetScrollbarStyles() const MOZ_OVERRIDE { 1.554 + return mHelper.GetScrollbarStylesFromFrame(); 1.555 + } 1.556 + virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE { 1.557 + return mHelper.GetScrollbarVisibility(); 1.558 + } 1.559 + virtual nsMargin GetActualScrollbarSizes() const MOZ_OVERRIDE { 1.560 + return mHelper.GetActualScrollbarSizes(); 1.561 + } 1.562 + virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) MOZ_OVERRIDE { 1.563 + return mHelper.GetDesiredScrollbarSizes(aState); 1.564 + } 1.565 + virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext, 1.566 + nsRenderingContext* aRC) MOZ_OVERRIDE { 1.567 + nsBoxLayoutState bls(aPresContext, aRC, 0); 1.568 + return GetDesiredScrollbarSizes(&bls); 1.569 + } 1.570 + virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext, 1.571 + nsRenderingContext* aRC) MOZ_OVERRIDE { 1.572 + nsBoxLayoutState bls(aPresContext, aRC, 0); 1.573 + return mHelper.GetNondisappearingScrollbarWidth(&bls); 1.574 + } 1.575 + virtual nsRect GetScrolledRect() const MOZ_OVERRIDE { 1.576 + return mHelper.GetScrolledRect(); 1.577 + } 1.578 + virtual nsRect GetScrollPortRect() const MOZ_OVERRIDE { 1.579 + return mHelper.GetScrollPortRect(); 1.580 + } 1.581 + virtual nsPoint GetScrollPosition() const MOZ_OVERRIDE { 1.582 + return mHelper.GetScrollPosition(); 1.583 + } 1.584 + virtual nsPoint GetLogicalScrollPosition() const MOZ_OVERRIDE { 1.585 + return mHelper.GetLogicalScrollPosition(); 1.586 + } 1.587 + virtual nsRect GetScrollRange() const MOZ_OVERRIDE { 1.588 + return mHelper.GetScrollRange(); 1.589 + } 1.590 + virtual nsSize GetScrollPositionClampingScrollPortSize() const MOZ_OVERRIDE { 1.591 + return mHelper.GetScrollPositionClampingScrollPortSize(); 1.592 + } 1.593 + virtual gfxSize GetResolution() const MOZ_OVERRIDE { 1.594 + return mHelper.GetResolution(); 1.595 + } 1.596 + virtual void SetResolution(const gfxSize& aResolution) MOZ_OVERRIDE { 1.597 + return mHelper.SetResolution(aResolution); 1.598 + } 1.599 + virtual nsSize GetLineScrollAmount() const MOZ_OVERRIDE { 1.600 + return mHelper.GetLineScrollAmount(); 1.601 + } 1.602 + virtual nsSize GetPageScrollAmount() const MOZ_OVERRIDE { 1.603 + return mHelper.GetPageScrollAmount(); 1.604 + } 1.605 + /** 1.606 + * @note This method might destroy the frame, pres shell and other objects. 1.607 + */ 1.608 + virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode, 1.609 + const nsRect* aRange = nullptr) MOZ_OVERRIDE { 1.610 + mHelper.ScrollTo(aScrollPosition, aMode, aRange); 1.611 + } 1.612 + /** 1.613 + * @note This method might destroy the frame, pres shell and other objects. 1.614 + */ 1.615 + virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition) MOZ_OVERRIDE { 1.616 + mHelper.ScrollToCSSPixels(aScrollPosition); 1.617 + } 1.618 + virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition, 1.619 + nsIAtom* aOrigin = nullptr) MOZ_OVERRIDE { 1.620 + mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin); 1.621 + } 1.622 + /** 1.623 + * @note This method might destroy the frame, pres shell and other objects. 1.624 + */ 1.625 + virtual CSSIntPoint GetScrollPositionCSSPixels() MOZ_OVERRIDE { 1.626 + return mHelper.GetScrollPositionCSSPixels(); 1.627 + } 1.628 + /** 1.629 + * @note This method might destroy the frame, pres shell and other objects. 1.630 + */ 1.631 + virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode, 1.632 + nsIntPoint* aOverflow, nsIAtom *aOrigin = nullptr) MOZ_OVERRIDE { 1.633 + mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin); 1.634 + } 1.635 + /** 1.636 + * @note This method might destroy the frame, pres shell and other objects. 1.637 + */ 1.638 + virtual void ScrollToRestoredPosition() MOZ_OVERRIDE { 1.639 + mHelper.ScrollToRestoredPosition(); 1.640 + } 1.641 + virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) MOZ_OVERRIDE { 1.642 + mHelper.AddScrollPositionListener(aListener); 1.643 + } 1.644 + virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) MOZ_OVERRIDE { 1.645 + mHelper.RemoveScrollPositionListener(aListener); 1.646 + } 1.647 + /** 1.648 + * @note This method might destroy the frame, pres shell and other objects. 1.649 + */ 1.650 + virtual void CurPosAttributeChanged(nsIContent* aChild) MOZ_OVERRIDE { 1.651 + mHelper.CurPosAttributeChanged(aChild); 1.652 + } 1.653 + NS_IMETHOD PostScrolledAreaEventForCurrentArea() MOZ_OVERRIDE { 1.654 + mHelper.PostScrolledAreaEvent(); 1.655 + return NS_OK; 1.656 + } 1.657 + virtual bool IsScrollingActive() MOZ_OVERRIDE { 1.658 + return mHelper.IsScrollingActive(); 1.659 + } 1.660 + virtual bool IsProcessingAsyncScroll() MOZ_OVERRIDE { 1.661 + return mHelper.IsProcessingAsyncScroll(); 1.662 + } 1.663 + virtual void ResetScrollPositionForLayerPixelAlignment() MOZ_OVERRIDE { 1.664 + mHelper.ResetScrollPositionForLayerPixelAlignment(); 1.665 + } 1.666 + virtual bool IsResolutionSet() const MOZ_OVERRIDE { 1.667 + return mHelper.mIsResolutionSet; 1.668 + } 1.669 + virtual bool DidHistoryRestore() const MOZ_OVERRIDE { 1.670 + return mHelper.mDidHistoryRestore; 1.671 + } 1.672 + virtual void ClearDidHistoryRestore() MOZ_OVERRIDE { 1.673 + mHelper.mDidHistoryRestore = false; 1.674 + } 1.675 + virtual bool IsRectNearlyVisible(const nsRect& aRect) MOZ_OVERRIDE { 1.676 + return mHelper.IsRectNearlyVisible(aRect); 1.677 + } 1.678 + virtual nsIAtom* OriginOfLastScroll() MOZ_OVERRIDE { 1.679 + return mHelper.OriginOfLastScroll(); 1.680 + } 1.681 + virtual uint32_t CurrentScrollGeneration() MOZ_OVERRIDE { 1.682 + return mHelper.CurrentScrollGeneration(); 1.683 + } 1.684 + virtual void ResetOriginIfScrollAtGeneration(uint32_t aGeneration) MOZ_OVERRIDE { 1.685 + mHelper.ResetOriginIfScrollAtGeneration(aGeneration); 1.686 + } 1.687 + virtual bool WantAsyncScroll() const MOZ_OVERRIDE { 1.688 + return mHelper.WantAsyncScroll(); 1.689 + } 1.690 + 1.691 + // nsIStatefulFrame 1.692 + NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE { 1.693 + NS_ENSURE_ARG_POINTER(aState); 1.694 + *aState = mHelper.SaveState(); 1.695 + return NS_OK; 1.696 + } 1.697 + NS_IMETHOD RestoreState(nsPresState* aState) MOZ_OVERRIDE { 1.698 + NS_ENSURE_ARG_POINTER(aState); 1.699 + mHelper.RestoreState(aState); 1.700 + return NS_OK; 1.701 + } 1.702 + 1.703 + /** 1.704 + * Get the "type" of the frame 1.705 + * 1.706 + * @see nsGkAtoms::scrollFrame 1.707 + */ 1.708 + virtual nsIAtom* GetType() const MOZ_OVERRIDE; 1.709 + 1.710 +#ifdef DEBUG_FRAME_DUMP 1.711 + virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; 1.712 +#endif 1.713 + 1.714 +#ifdef ACCESSIBILITY 1.715 + virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; 1.716 +#endif 1.717 + 1.718 +protected: 1.719 + nsHTMLScrollFrame(nsIPresShell* aShell, nsStyleContext* aContext, bool aIsRoot); 1.720 + void SetSuppressScrollbarUpdate(bool aSuppress) { 1.721 + mHelper.mSupppressScrollbarUpdate = aSuppress; 1.722 + } 1.723 + bool GuessHScrollbarNeeded(const ScrollReflowState& aState); 1.724 + bool GuessVScrollbarNeeded(const ScrollReflowState& aState); 1.725 + 1.726 + bool IsScrollbarUpdateSuppressed() const { 1.727 + return mHelper.mSupppressScrollbarUpdate; 1.728 + } 1.729 + 1.730 + // Return whether we're in an "initial" reflow. Some reflows with 1.731 + // NS_FRAME_FIRST_REFLOW set are NOT "initial" as far as we're concerned. 1.732 + bool InInitialReflow() const; 1.733 + 1.734 + /** 1.735 + * Override this to return false if computed height/min-height/max-height 1.736 + * should NOT be propagated to child content. 1.737 + * nsListControlFrame uses this. 1.738 + */ 1.739 + virtual bool ShouldPropagateComputedHeightToScrolledContent() const { return true; } 1.740 + 1.741 +private: 1.742 + friend class mozilla::ScrollFrameHelper; 1.743 + ScrollFrameHelper mHelper; 1.744 +}; 1.745 + 1.746 +/** 1.747 + * The scroll frame creates and manages the scrolling view 1.748 + * 1.749 + * It only supports having a single child frame that typically is an area 1.750 + * frame, but doesn't have to be. The child frame must have a view, though 1.751 + * 1.752 + * Scroll frames don't support incremental changes, i.e. you can't replace 1.753 + * or remove the scrolled frame 1.754 + */ 1.755 +class nsXULScrollFrame : public nsBoxFrame, 1.756 + public nsIScrollableFrame, 1.757 + public nsIAnonymousContentCreator, 1.758 + public nsIStatefulFrame { 1.759 +public: 1.760 + typedef mozilla::ScrollFrameHelper ScrollFrameHelper; 1.761 + typedef mozilla::CSSIntPoint CSSIntPoint; 1.762 + 1.763 + NS_DECL_QUERYFRAME 1.764 + NS_DECL_FRAMEARENA_HELPERS 1.765 + 1.766 + friend nsIFrame* NS_NewXULScrollFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, 1.767 + bool aIsRoot, bool aClipAllDescendants); 1.768 + 1.769 + // Called to set the child frames. We typically have three: the scroll area, 1.770 + // the vertical scrollbar, and the horizontal scrollbar. 1.771 + virtual nsresult SetInitialChildList(ChildListID aListID, 1.772 + nsFrameList& aChildList) MOZ_OVERRIDE; 1.773 + 1.774 + virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, 1.775 + const nsRect& aDirtyRect, 1.776 + const nsDisplayListSet& aLists) MOZ_OVERRIDE { 1.777 + mHelper.BuildDisplayList(aBuilder, aDirtyRect, aLists); 1.778 + } 1.779 + 1.780 + // XXXldb Is this actually used? 1.781 +#if 0 1.782 + virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; 1.783 +#endif 1.784 + 1.785 + virtual bool UpdateOverflow() MOZ_OVERRIDE { 1.786 + return mHelper.UpdateOverflow(); 1.787 + } 1.788 + 1.789 + // Because there can be only one child frame, these two function return 1.790 + // NS_ERROR_FAILURE 1.791 + virtual nsresult AppendFrames(ChildListID aListID, 1.792 + nsFrameList& aFrameList) MOZ_OVERRIDE; 1.793 + virtual nsresult InsertFrames(ChildListID aListID, 1.794 + nsIFrame* aPrevFrame, 1.795 + nsFrameList& aFrameList) MOZ_OVERRIDE; 1.796 + 1.797 + virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; 1.798 + 1.799 + virtual nsresult RemoveFrame(ChildListID aListID, 1.800 + nsIFrame* aOldFrame) MOZ_OVERRIDE; 1.801 + 1.802 + virtual nsIScrollableFrame* GetScrollTargetFrame() MOZ_OVERRIDE { 1.803 + return this; 1.804 + } 1.805 + 1.806 + virtual nsIFrame* GetContentInsertionFrame() MOZ_OVERRIDE { 1.807 + return mHelper.GetScrolledFrame()->GetContentInsertionFrame(); 1.808 + } 1.809 + 1.810 + virtual bool DoesClipChildren() MOZ_OVERRIDE { return true; } 1.811 + virtual nsSplittableType GetSplittableType() const MOZ_OVERRIDE; 1.812 + 1.813 + virtual nsPoint GetPositionOfChildIgnoringScrolling(nsIFrame* aChild) MOZ_OVERRIDE 1.814 + { nsPoint pt = aChild->GetPosition(); 1.815 + if (aChild == mHelper.GetScrolledFrame()) 1.816 + pt += mHelper.GetLogicalScrollPosition(); 1.817 + return pt; 1.818 + } 1.819 + 1.820 + // nsIAnonymousContentCreator 1.821 + virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE; 1.822 + virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, 1.823 + uint32_t aFilter) MOZ_OVERRIDE; 1.824 + 1.825 + virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.826 + virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.827 + virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.828 + virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.829 + 1.830 + NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.831 + virtual nsresult GetPadding(nsMargin& aPadding) MOZ_OVERRIDE; 1.832 + 1.833 + virtual bool GetBorderRadii(nscoord aRadii[8]) const MOZ_OVERRIDE { 1.834 + return mHelper.GetBorderRadii(aRadii); 1.835 + } 1.836 + 1.837 + nsresult Layout(nsBoxLayoutState& aState); 1.838 + void LayoutScrollArea(nsBoxLayoutState& aState, const nsPoint& aScrollPosition); 1.839 + 1.840 + static bool AddRemoveScrollbar(bool& aHasScrollbar, 1.841 + nscoord& aXY, 1.842 + nscoord& aSize, 1.843 + nscoord aSbSize, 1.844 + bool aOnRightOrBottom, 1.845 + bool aAdd); 1.846 + 1.847 + bool AddRemoveScrollbar(nsBoxLayoutState& aState, 1.848 + bool aOnRightOrBottom, 1.849 + bool aHorizontal, 1.850 + bool aAdd); 1.851 + 1.852 + bool AddHorizontalScrollbar (nsBoxLayoutState& aState, bool aOnBottom); 1.853 + bool AddVerticalScrollbar (nsBoxLayoutState& aState, bool aOnRight); 1.854 + void RemoveHorizontalScrollbar(nsBoxLayoutState& aState, bool aOnBottom); 1.855 + void RemoveVerticalScrollbar (nsBoxLayoutState& aState, bool aOnRight); 1.856 + 1.857 + static void AdjustReflowStateForPrintPreview(nsBoxLayoutState& aState, bool& aSetBack); 1.858 + static void AdjustReflowStateBack(nsBoxLayoutState& aState, bool aSetBack); 1.859 + 1.860 + // nsIScrollbarOwner 1.861 + virtual nsIFrame* GetScrollbarBox(bool aVertical) MOZ_OVERRIDE { 1.862 + return mHelper.GetScrollbarBox(aVertical); 1.863 + } 1.864 + 1.865 + virtual void ScrollbarActivityStarted() const MOZ_OVERRIDE; 1.866 + virtual void ScrollbarActivityStopped() const MOZ_OVERRIDE; 1.867 + 1.868 + // nsIScrollableFrame 1.869 + virtual nsIFrame* GetScrolledFrame() const MOZ_OVERRIDE { 1.870 + return mHelper.GetScrolledFrame(); 1.871 + } 1.872 + virtual mozilla::ScrollbarStyles GetScrollbarStyles() const MOZ_OVERRIDE { 1.873 + return mHelper.GetScrollbarStylesFromFrame(); 1.874 + } 1.875 + virtual uint32_t GetScrollbarVisibility() const MOZ_OVERRIDE { 1.876 + return mHelper.GetScrollbarVisibility(); 1.877 + } 1.878 + virtual nsMargin GetActualScrollbarSizes() const MOZ_OVERRIDE { 1.879 + return mHelper.GetActualScrollbarSizes(); 1.880 + } 1.881 + virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) MOZ_OVERRIDE { 1.882 + return mHelper.GetDesiredScrollbarSizes(aState); 1.883 + } 1.884 + virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext, 1.885 + nsRenderingContext* aRC) MOZ_OVERRIDE { 1.886 + nsBoxLayoutState bls(aPresContext, aRC, 0); 1.887 + return GetDesiredScrollbarSizes(&bls); 1.888 + } 1.889 + virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext, 1.890 + nsRenderingContext* aRC) MOZ_OVERRIDE { 1.891 + nsBoxLayoutState bls(aPresContext, aRC, 0); 1.892 + return mHelper.GetNondisappearingScrollbarWidth(&bls); 1.893 + } 1.894 + virtual nsRect GetScrolledRect() const MOZ_OVERRIDE { 1.895 + return mHelper.GetScrolledRect(); 1.896 + } 1.897 + virtual nsRect GetScrollPortRect() const MOZ_OVERRIDE { 1.898 + return mHelper.GetScrollPortRect(); 1.899 + } 1.900 + virtual nsPoint GetScrollPosition() const MOZ_OVERRIDE { 1.901 + return mHelper.GetScrollPosition(); 1.902 + } 1.903 + virtual nsPoint GetLogicalScrollPosition() const MOZ_OVERRIDE { 1.904 + return mHelper.GetLogicalScrollPosition(); 1.905 + } 1.906 + virtual nsRect GetScrollRange() const MOZ_OVERRIDE { 1.907 + return mHelper.GetScrollRange(); 1.908 + } 1.909 + virtual nsSize GetScrollPositionClampingScrollPortSize() const MOZ_OVERRIDE { 1.910 + return mHelper.GetScrollPositionClampingScrollPortSize(); 1.911 + } 1.912 + virtual gfxSize GetResolution() const MOZ_OVERRIDE { 1.913 + return mHelper.GetResolution(); 1.914 + } 1.915 + virtual void SetResolution(const gfxSize& aResolution) MOZ_OVERRIDE { 1.916 + return mHelper.SetResolution(aResolution); 1.917 + } 1.918 + virtual nsSize GetLineScrollAmount() const MOZ_OVERRIDE { 1.919 + return mHelper.GetLineScrollAmount(); 1.920 + } 1.921 + virtual nsSize GetPageScrollAmount() const MOZ_OVERRIDE { 1.922 + return mHelper.GetPageScrollAmount(); 1.923 + } 1.924 + /** 1.925 + * @note This method might destroy the frame, pres shell and other objects. 1.926 + */ 1.927 + virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode, 1.928 + const nsRect* aRange = nullptr) MOZ_OVERRIDE { 1.929 + mHelper.ScrollTo(aScrollPosition, aMode, aRange); 1.930 + } 1.931 + /** 1.932 + * @note This method might destroy the frame, pres shell and other objects. 1.933 + */ 1.934 + virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition) MOZ_OVERRIDE { 1.935 + mHelper.ScrollToCSSPixels(aScrollPosition); 1.936 + } 1.937 + virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition, 1.938 + nsIAtom* aOrigin = nullptr) MOZ_OVERRIDE { 1.939 + mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin); 1.940 + } 1.941 + virtual CSSIntPoint GetScrollPositionCSSPixels() MOZ_OVERRIDE { 1.942 + return mHelper.GetScrollPositionCSSPixels(); 1.943 + } 1.944 + /** 1.945 + * @note This method might destroy the frame, pres shell and other objects. 1.946 + */ 1.947 + virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode, 1.948 + nsIntPoint* aOverflow, nsIAtom* aOrigin = nullptr) MOZ_OVERRIDE { 1.949 + mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin); 1.950 + } 1.951 + /** 1.952 + * @note This method might destroy the frame, pres shell and other objects. 1.953 + */ 1.954 + virtual void ScrollToRestoredPosition() MOZ_OVERRIDE { 1.955 + mHelper.ScrollToRestoredPosition(); 1.956 + } 1.957 + virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) MOZ_OVERRIDE { 1.958 + mHelper.AddScrollPositionListener(aListener); 1.959 + } 1.960 + virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) MOZ_OVERRIDE { 1.961 + mHelper.RemoveScrollPositionListener(aListener); 1.962 + } 1.963 + /** 1.964 + * @note This method might destroy the frame, pres shell and other objects. 1.965 + */ 1.966 + virtual void CurPosAttributeChanged(nsIContent* aChild) MOZ_OVERRIDE { 1.967 + mHelper.CurPosAttributeChanged(aChild); 1.968 + } 1.969 + NS_IMETHOD PostScrolledAreaEventForCurrentArea() MOZ_OVERRIDE { 1.970 + mHelper.PostScrolledAreaEvent(); 1.971 + return NS_OK; 1.972 + } 1.973 + virtual bool IsScrollingActive() MOZ_OVERRIDE { 1.974 + return mHelper.IsScrollingActive(); 1.975 + } 1.976 + virtual bool IsProcessingAsyncScroll() MOZ_OVERRIDE { 1.977 + return mHelper.IsProcessingAsyncScroll(); 1.978 + } 1.979 + virtual void ResetScrollPositionForLayerPixelAlignment() MOZ_OVERRIDE { 1.980 + mHelper.ResetScrollPositionForLayerPixelAlignment(); 1.981 + } 1.982 + virtual bool IsResolutionSet() const MOZ_OVERRIDE { 1.983 + return mHelper.mIsResolutionSet; 1.984 + } 1.985 + virtual bool DidHistoryRestore() const MOZ_OVERRIDE { 1.986 + return mHelper.mDidHistoryRestore; 1.987 + } 1.988 + virtual void ClearDidHistoryRestore() MOZ_OVERRIDE { 1.989 + mHelper.mDidHistoryRestore = false; 1.990 + } 1.991 + virtual bool IsRectNearlyVisible(const nsRect& aRect) MOZ_OVERRIDE { 1.992 + return mHelper.IsRectNearlyVisible(aRect); 1.993 + } 1.994 + virtual nsIAtom* OriginOfLastScroll() MOZ_OVERRIDE { 1.995 + return mHelper.OriginOfLastScroll(); 1.996 + } 1.997 + virtual uint32_t CurrentScrollGeneration() MOZ_OVERRIDE { 1.998 + return mHelper.CurrentScrollGeneration(); 1.999 + } 1.1000 + virtual void ResetOriginIfScrollAtGeneration(uint32_t aGeneration) MOZ_OVERRIDE { 1.1001 + mHelper.ResetOriginIfScrollAtGeneration(aGeneration); 1.1002 + } 1.1003 + virtual bool WantAsyncScroll() const MOZ_OVERRIDE { 1.1004 + return mHelper.WantAsyncScroll(); 1.1005 + } 1.1006 + 1.1007 + // nsIStatefulFrame 1.1008 + NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE { 1.1009 + NS_ENSURE_ARG_POINTER(aState); 1.1010 + *aState = mHelper.SaveState(); 1.1011 + return NS_OK; 1.1012 + } 1.1013 + NS_IMETHOD RestoreState(nsPresState* aState) MOZ_OVERRIDE { 1.1014 + NS_ENSURE_ARG_POINTER(aState); 1.1015 + mHelper.RestoreState(aState); 1.1016 + return NS_OK; 1.1017 + } 1.1018 + 1.1019 + /** 1.1020 + * Get the "type" of the frame 1.1021 + * 1.1022 + * @see nsGkAtoms::scrollFrame 1.1023 + */ 1.1024 + virtual nsIAtom* GetType() const MOZ_OVERRIDE; 1.1025 + 1.1026 + virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE 1.1027 + { 1.1028 + // Override bogus IsFrameOfType in nsBoxFrame. 1.1029 + if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced)) 1.1030 + return false; 1.1031 + return nsBoxFrame::IsFrameOfType(aFlags); 1.1032 + } 1.1033 + 1.1034 +#ifdef DEBUG_FRAME_DUMP 1.1035 + virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; 1.1036 +#endif 1.1037 + 1.1038 +protected: 1.1039 + nsXULScrollFrame(nsIPresShell* aShell, nsStyleContext* aContext, bool aIsRoot, 1.1040 + bool aClipAllDescendants); 1.1041 + 1.1042 + void ClampAndSetBounds(nsBoxLayoutState& aState, 1.1043 + nsRect& aRect, 1.1044 + nsPoint aScrollPosition, 1.1045 + bool aRemoveOverflowAreas = false) { 1.1046 + /* 1.1047 + * For RTL frames, restore the original scrolled position of the right 1.1048 + * edge, then subtract the current width to find the physical position. 1.1049 + */ 1.1050 + if (!mHelper.IsLTR()) { 1.1051 + aRect.x = mHelper.mScrollPort.XMost() - aScrollPosition.x - aRect.width; 1.1052 + } 1.1053 + mHelper.mScrolledFrame->SetBounds(aState, aRect, aRemoveOverflowAreas); 1.1054 + } 1.1055 + 1.1056 +private: 1.1057 + friend class mozilla::ScrollFrameHelper; 1.1058 + ScrollFrameHelper mHelper; 1.1059 +}; 1.1060 + 1.1061 +#endif /* nsGfxScrollFrame_h___ */