Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsGfxScrollFrame.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/* rendering object to wrap rendering objects that should be scrollable */
8
9
#ifndef nsGfxScrollFrame_h___
10
#define nsGfxScrollFrame_h___
11
12
#include "mozilla/Attributes.h"
13
#include "nsContainerFrame.h"
14
#include "nsIAnonymousContentCreator.h"
15
#include "nsBoxFrame.h"
16
#include "nsIScrollableFrame.h"
17
#include "nsIScrollbarMediator.h"
18
#include "nsIStatefulFrame.h"
19
#include "nsThreadUtils.h"
20
#include "nsIReflowCallback.h"
21
#include "nsBoxLayoutState.h"
22
#include "nsQueryFrame.h"
23
#include "nsRefreshDriver.h"
24
#include "nsExpirationTracker.h"
25
#include "TextOverflow.h"
26
#include "ScrollVelocityQueue.h"
27
#include "mozilla/PresState.h"
28
29
class nsPresContext;
30
class nsIPresShell;
31
class nsIContent;
32
class nsAtom;
33
class nsIScrollPositionListener;
34
35
namespace mozilla {
36
struct ScrollReflowInput;
37
namespace layers {
38
class Layer;
39
class LayerManager;
40
} // namespace layers
41
namespace layout {
42
class ScrollbarActivity;
43
} // namespace layout
44
45
class ScrollFrameHelper : public nsIReflowCallback {
46
public:
47
  typedef nsIFrame::Sides Sides;
48
  typedef mozilla::CSSIntPoint CSSIntPoint;
49
  typedef mozilla::layout::ScrollbarActivity ScrollbarActivity;
50
  typedef mozilla::layers::FrameMetrics FrameMetrics;
51
  typedef mozilla::layers::ScrollSnapInfo ScrollSnapInfo;
52
  typedef mozilla::layers::Layer Layer;
53
  typedef mozilla::layers::LayerManager LayerManager;
54
55
  class AsyncScroll;
56
  class AsyncSmoothMSDScroll;
57
58
  ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot);
59
  ~ScrollFrameHelper();
60
61
  mozilla::ScrollStyles GetScrollStylesFromFrame() const;
62
63
  // If a child frame was added or removed on the scrollframe,
64
  // reload our child frame list.
65
  // We need this if a scrollbar frame is recreated.
66
  void ReloadChildFrames();
67
68
  nsresult CreateAnonymousContent(
69
    nsTArray<nsIAnonymousContentCreator::ContentInfo>& aElements);
70
  void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements, uint32_t aFilter);
71
  nsresult FireScrollPortEvent();
72
  void PostScrollEndEvent();
73
  void FireScrollEndEvent();
74
  void PostOverflowEvent();
75
  using PostDestroyData = nsIFrame::PostDestroyData;
76
  void Destroy(PostDestroyData& aPostDestroyData);
77
78
  void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
79
                        const nsDisplayListSet& aLists);
80
81
  void AppendScrollPartsTo(nsDisplayListBuilder*   aBuilder,
82
                           const nsDisplayListSet& aLists,
83
                           bool                    aCreateLayer,
84
                           bool                    aPositioned);
85
86
  bool GetBorderRadii(const nsSize& aFrameSize, const nsSize& aBorderArea,
87
                      Sides aSkipSides, nscoord aRadii[8]) const;
88
89
  // nsIReflowCallback
90
  virtual bool ReflowFinished() override;
91
  virtual void ReflowCallbackCanceled() override;
92
93
  /**
94
   * @note This method might destroy the frame, pres shell and other objects.
95
   * Called when the 'curpos' attribute on one of the scrollbars changes.
96
   */
97
  void CurPosAttributeChanged(nsIContent* aChild, bool aDoScroll = true);
98
99
  void PostScrollEvent();
100
  void FireScrollEvent();
101
  void PostScrolledAreaEvent();
102
  void FireScrolledAreaEvent();
103
104
  bool IsSmoothScrollingEnabled();
105
106
  /**
107
   * This class handles the dispatching of scroll events to content.
108
   *
109
   * Scroll events are posted to the refresh driver via
110
   * nsRefreshDriver::PostScrollEvent(), and they are fired during a refresh
111
   * driver tick, after running requestAnimationFrame callbacks but before
112
   * the style flush. This allows rAF callbacks to perform scrolling and have
113
   * that scrolling be reflected on the same refresh driver tick, while at
114
   * the same time allowing scroll event listeners to make style changes and
115
   * have those style changes be reflected on the same refresh driver tick.
116
   *
117
   * ScrollEvents cannot be refresh observers, because none of the existing
118
   * categories of refresh observers (FlushType::Style, FlushType::Layout,
119
   * and FlushType::Display) are run at the desired time in a refresh driver
120
   * tick. They behave similarly to refresh observers in that their presence
121
   * causes the refresh driver to tick.
122
   *
123
   * ScrollEvents are one-shot runnables; the refresh driver drops them after
124
   * running them.
125
   */
126
  class ScrollEvent : public Runnable {
127
  public:
128
    NS_DECL_NSIRUNNABLE
129
    explicit ScrollEvent(ScrollFrameHelper* aHelper);
130
0
    void Revoke() { mHelper = nullptr; }
131
  private:
132
    ScrollFrameHelper* mHelper;
133
  };
134
135
  class ScrollEndEvent : public Runnable {
136
  public:
137
    NS_DECL_NSIRUNNABLE
138
    explicit ScrollEndEvent(ScrollFrameHelper* aHelper);
139
0
    void Revoke() { mHelper = nullptr; }
140
  private:
141
    ScrollFrameHelper* mHelper;
142
  };
143
144
  class AsyncScrollPortEvent : public Runnable {
145
  public:
146
    NS_DECL_NSIRUNNABLE
147
    explicit AsyncScrollPortEvent(ScrollFrameHelper* helper)
148
      : Runnable("ScrollFrameHelper::AsyncScrollPortEvent")
149
      , mHelper(helper)
150
0
    {
151
0
    }
152
0
    void Revoke() { mHelper = nullptr; }
153
  private:
154
    ScrollFrameHelper *mHelper;
155
  };
156
157
  class ScrolledAreaEvent : public Runnable {
158
  public:
159
    NS_DECL_NSIRUNNABLE
160
    explicit ScrolledAreaEvent(ScrollFrameHelper* helper)
161
      : Runnable("ScrollFrameHelper::ScrolledAreaEvent")
162
      , mHelper(helper)
163
0
    {
164
0
    }
165
0
    void Revoke() { mHelper = nullptr; }
166
  private:
167
    ScrollFrameHelper *mHelper;
168
  };
169
170
  /**
171
   * @note This method might destroy the frame, pres shell and other objects.
172
   */
173
  void FinishReflowForScrollbar(mozilla::dom::Element* aElement,
174
                                nscoord aMinXY, nscoord aMaxXY,
175
                                nscoord aCurPosXY, nscoord aPageIncrement,
176
                                nscoord aIncrement);
177
  /**
178
   * @note This method might destroy the frame, pres shell and other objects.
179
   */
180
  void SetScrollbarEnabled(mozilla::dom::Element* aElement, nscoord aMaxPos);
181
  /**
182
   * @note This method might destroy the frame, pres shell and other objects.
183
   */
184
  void SetCoordAttribute(mozilla::dom::Element* aElement,
185
                         nsAtom* aAtom,
186
                         nscoord aSize);
187
188
  nscoord GetCoordAttribute(nsIFrame* aFrame, nsAtom* aAtom, nscoord aDefaultValue,
189
                            nscoord* aRangeStart, nscoord* aRangeLength);
190
191
  /**
192
   * @note This method might destroy the frame, pres shell and other objects.
193
   * Update scrollbar curpos attributes to reflect current scroll position
194
   */
195
  void UpdateScrollbarPosition();
196
197
0
  nsRect GetScrollPortRect() const { return mScrollPort; }
198
0
  nsPoint GetScrollPosition() const {
199
0
    return mScrollPort.TopLeft() - mScrolledFrame->GetPosition();
200
0
  }
201
  /**
202
   * For LTR frames, the logical scroll position is the offset of the top left
203
   * corner of the frame from the top left corner of the scroll port (same as
204
   * GetScrollPosition).
205
   * For RTL frames, it is the offset of the top right corner of the frame from
206
   * the top right corner of the scroll port
207
   */
208
0
  nsPoint GetLogicalScrollPosition() const {
209
0
    nsPoint pt;
210
0
    pt.x = IsPhysicalLTR() ?
211
0
      mScrollPort.x - mScrolledFrame->GetPosition().x :
212
0
      mScrollPort.XMost() - mScrolledFrame->GetRect().XMost();
213
0
    pt.y = mScrollPort.y - mScrolledFrame->GetPosition().y;
214
0
    return pt;
215
0
  }
216
  nsRect GetScrollRange() const;
217
  // Get the scroll range assuming the viewport has size (aWidth, aHeight).
218
  nsRect GetScrollRange(nscoord aWidth, nscoord aHeight) const;
219
  nsSize GetVisualViewportSize() const;
220
  void ScrollSnap(nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
221
  void ScrollSnap(const nsPoint &aDestination,
222
                  nsIScrollableFrame::ScrollMode aMode = nsIScrollableFrame::SMOOTH_MSD);
223
224
protected:
225
  nsRect GetScrollRangeForClamping() const;
226
227
public:
228
  static void AsyncScrollCallback(ScrollFrameHelper* aInstance,
229
                                  mozilla::TimeStamp aTime);
230
  static void AsyncSmoothMSDScrollCallback(ScrollFrameHelper* aInstance,
231
                                           mozilla::TimeDuration aDeltaTime);
232
  /**
233
   * @note This method might destroy the frame, pres shell and other objects.
234
   * aRange is the range of allowable scroll positions around the desired
235
   * aScrollPosition. Null means only aScrollPosition is allowed.
236
   * This is a closed-ended range --- aRange.XMost()/aRange.YMost() are allowed.
237
   */
238
  void ScrollTo(nsPoint aScrollPosition, nsIScrollableFrame::ScrollMode aMode,
239
                const nsRect* aRange = nullptr,
240
                nsIScrollbarMediator::ScrollSnapMode aSnap
241
0
                  = nsIScrollbarMediator::DISABLE_SNAP) {
242
0
    ScrollToWithOrigin(aScrollPosition, aMode, nsGkAtoms::other, aRange,
243
0
                       aSnap);
244
0
  }
245
  /**
246
   * @note This method might destroy the frame, pres shell and other objects.
247
   */
248
  void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
249
                         nsIScrollableFrame::ScrollMode aMode
250
                           = nsIScrollableFrame::INSTANT);
251
  /**
252
   * @note This method might destroy the frame, pres shell and other objects.
253
   */
254
  void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
255
                                    nsAtom* aOrigin = nullptr);
256
257
  CSSIntPoint GetScrollPositionCSSPixels();
258
  /**
259
   * @note This method might destroy the frame, pres shell and other objects.
260
   */
261
  void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange, nsAtom* aOrigin = nullptr);
262
  void ScrollVisual();
263
  /**
264
   * @note This method might destroy the frame, pres shell and other objects.
265
   */
266
  void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
267
                nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow,
268
                nsAtom* aOrigin = nullptr,
269
                nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
270
                nsIScrollbarMediator::ScrollSnapMode aSnap
271
                  = nsIScrollbarMediator::DISABLE_SNAP);
272
  /**
273
   * @note This method might destroy the frame, pres shell and other objects.
274
   */
275
  void ScrollToRestoredPosition();
276
277
  enum class LoadingState {
278
    Loading,
279
    Stopped,
280
    Loaded
281
  };
282
283
  LoadingState GetPageLoadingState();
284
285
  /**
286
   * GetSnapPointForDestination determines which point to snap to after
287
   * scrolling. aStartPos gives the position before scrolling and aDestination
288
   * gives the position after scrolling, with no snapping. Behaviour is
289
   * dependent on the value of aUnit.
290
   * Returns true if a suitable snap point could be found and aDestination has
291
   * been updated to a valid snapping position.
292
   */
293
  bool GetSnapPointForDestination(nsIScrollableFrame::ScrollUnit aUnit,
294
                                  nsPoint aStartPos,
295
                                  nsPoint &aDestination);
296
297
  nsSize GetLineScrollAmount() const;
298
  nsSize GetPageScrollAmount() const;
299
300
  mozilla::UniquePtr<mozilla::PresState> SaveState() const;
301
  void RestoreState(mozilla::PresState* aState);
302
303
0
  nsIFrame* GetScrolledFrame() const { return mScrolledFrame; }
304
0
  nsIFrame* GetScrollbarBox(bool aVertical) const {
305
0
    return aVertical ? mVScrollbarBox : mHScrollbarBox;
306
0
  }
307
308
0
  void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
309
0
    mListeners.AppendElement(aListener);
310
0
  }
311
0
  void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
312
0
    mListeners.RemoveElement(aListener);
313
0
  }
314
315
  static void SetScrollbarVisibility(nsIFrame* aScrollbar, bool aVisible);
316
317
  /**
318
   * GetScrolledRect is designed to encapsulate deciding which
319
   * directions of overflow should be reachable by scrolling and which
320
   * should not.  Callers should NOT depend on it having any particular
321
   * behavior (although nsXULScrollFrame currently does).
322
   *
323
   * This should only be called when the scrolled frame has been
324
   * reflowed with the scroll port size given in mScrollPort.
325
   *
326
   * Currently it allows scrolling down and to the right for
327
   * nsHTMLScrollFrames with LTR directionality and for all
328
   * nsXULScrollFrames, and allows scrolling down and to the left for
329
   * nsHTMLScrollFrames with RTL directionality.
330
   */
331
  nsRect GetScrolledRect() const;
332
333
  /**
334
   * GetUnsnappedScrolledRectInternal is designed to encapsulate deciding which
335
   * directions of overflow should be reachable by scrolling and which
336
   * should not.  Callers should NOT depend on it having any particular
337
   * behavior (although nsXULScrollFrame currently does).
338
   *
339
   * Currently it allows scrolling down and to the right for
340
   * nsHTMLScrollFrames with LTR directionality and for all
341
   * nsXULScrollFrames, and allows scrolling down and to the left for
342
   * nsHTMLScrollFrames with RTL directionality.
343
   */
344
  nsRect GetUnsnappedScrolledRectInternal(const nsRect& aScrolledOverflowArea,
345
                                          const nsSize& aScrollPortSize) const;
346
347
0
  uint32_t GetScrollbarVisibility() const {
348
0
    return (mHasVerticalScrollbar ? nsIScrollableFrame::VERTICAL : 0) |
349
0
           (mHasHorizontalScrollbar ? nsIScrollableFrame::HORIZONTAL : 0);
350
0
  }
351
  nsMargin GetActualScrollbarSizes() const;
352
  nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState);
353
  nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState,
354
                                           mozilla::WritingMode aVerticalWM);
355
0
  bool IsPhysicalLTR() const {
356
0
    WritingMode wm = GetFrameForDir()->GetWritingMode();
357
0
    return wm.IsVertical() ? wm.IsVerticalLR() : wm.IsBidiLTR();
358
0
  }
359
0
  bool IsBidiLTR() const {
360
0
    nsIFrame* frame = GetFrameForDir();
361
0
    return frame->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR;
362
0
  }
363
private:
364
  nsIFrame* GetFrameForDir() const; // helper for Is{Physical,Bidi}LTR to find
365
                                    // the frame whose directionality we use
366
367
public:
368
  bool IsScrollbarOnRight() const;
369
  bool IsScrollingActive(nsDisplayListBuilder* aBuilder) const;
370
0
  bool IsMaybeAsynchronouslyScrolled() const {
371
0
    // If this is true, then we'll build an ASR, and that's what we want
372
0
    // to know I think.
373
0
    return mWillBuildScrollableLayer;
374
0
  }
375
  bool IsMaybeScrollingActive() const;
376
0
  bool IsProcessingAsyncScroll() const {
377
0
    return mAsyncScroll != nullptr || mAsyncSmoothMSDScroll != nullptr;
378
0
  }
379
  void ResetScrollPositionForLayerPixelAlignment()
380
0
  {
381
0
    mScrollPosForLayerPixelAlignment = GetScrollPosition();
382
0
  }
383
384
  bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas);
385
386
  void UpdateSticky();
387
388
  void UpdatePrevScrolledRect();
389
390
  bool IsRectNearlyVisible(const nsRect& aRect) const;
391
  nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const;
392
393
  // adjust the scrollbar rectangle aRect to account for any visible resizer.
394
  // aHasResizer specifies if there is a content resizer, however this method
395
  // will also check if a widget resizer is present as well.
396
  void AdjustScrollbarRectForResizer(nsIFrame* aFrame, nsPresContext* aPresContext,
397
                                     nsRect& aRect, bool aHasResizer, bool aVertical);
398
  // returns true if a resizer should be visible
399
0
  bool HasResizer() { return mResizerBox && !mCollapsedResizer; }
400
  void LayoutScrollbars(nsBoxLayoutState& aState,
401
                        const nsRect& aContentArea,
402
                        const nsRect& aOldScrollArea);
403
404
  bool IsIgnoringViewportClipping() const;
405
406
  void MarkScrollbarsDirtyForReflow() const;
407
408
  bool ShouldClampScrollPosition() const;
409
410
  bool IsAlwaysActive() const;
411
  void MarkRecentlyScrolled();
412
  void MarkNotRecentlyScrolled();
413
0
  nsExpirationState* GetExpirationState() { return &mActivityExpirationState; }
414
415
0
  void SetTransformingByAPZ(bool aTransforming) {
416
0
    if (mTransformingByAPZ && !aTransforming) {
417
0
      PostScrollEndEvent();
418
0
    }
419
0
    mTransformingByAPZ = aTransforming;
420
0
    if (!mozilla::css::TextOverflow::HasClippedOverflow(mOuter)) {
421
0
      // If the block has some text-overflow stuff we should kick off a paint
422
0
      // because we have special behaviour for it when APZ scrolling is active.
423
0
      mOuter->SchedulePaint();
424
0
    }
425
0
  }
426
0
  bool IsTransformingByAPZ() const {
427
0
    return mTransformingByAPZ;
428
0
  }
429
  void SetScrollableByAPZ(bool aScrollable);
430
  void SetZoomableByAPZ(bool aZoomable);
431
  void SetHasOutOfFlowContentInsideFilter();
432
433
  bool UsesContainerScrolling() const;
434
435
  ScrollSnapInfo GetScrollSnapInfo() const;
436
437
  bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
438
                             nsRect* aVisibleRect,
439
                             nsRect* aDirtyRect,
440
                             bool aSetBase,
441
                             bool* aDirtyRectHasBeenOverriden = nullptr);
442
  void NotifyApproximateFrameVisibilityUpdate(bool aIgnoreDisplayPort);
443
  bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(nsRect* aDisplayPort);
444
445
  bool AllowDisplayPortExpiration();
446
  void TriggerDisplayPortExpiration();
447
  void ResetDisplayPortExpiryTimer();
448
449
  void ScheduleSyntheticMouseMove();
450
  static void ScrollActivityCallback(nsITimer *aTimer, void* anInstance);
451
452
  void HandleScrollbarStyleSwitching();
453
454
0
  nsAtom* LastScrollOrigin() const { return mLastScrollOrigin; }
455
0
  void AllowScrollOriginDowngrade() { mAllowScrollOriginDowngrade = true; }
456
0
  nsAtom* LastSmoothScrollOrigin() const { return mLastSmoothScrollOrigin; }
457
0
  uint32_t CurrentScrollGeneration() const { return mScrollGeneration; }
458
0
  nsPoint LastScrollDestination() const { return mDestination; }
459
0
  void ResetScrollInfoIfGeneration(uint32_t aGeneration) {
460
0
    if (aGeneration == mScrollGeneration) {
461
0
      mLastScrollOrigin = nullptr;
462
0
      mLastSmoothScrollOrigin = nullptr;
463
0
    }
464
0
  }
465
  bool WantAsyncScroll() const;
466
  Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
467
    LayerManager* aLayerManager,
468
    const nsIFrame* aContainerReferenceFrame,
469
    const ContainerLayerParameters& aParameters,
470
    const mozilla::DisplayItemClip* aClip) const;
471
  void ClipLayerToDisplayPort(Layer* aLayer,
472
                              const mozilla::DisplayItemClip* aClip,
473
                              const ContainerLayerParameters& aParameters) const;
474
475
  // nsIScrollbarMediator
476
  void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
477
                    nsIScrollbarMediator::ScrollSnapMode aSnap
478
                      = nsIScrollbarMediator::DISABLE_SNAP);
479
  void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
480
                     nsIScrollbarMediator::ScrollSnapMode aSnap
481
                       = nsIScrollbarMediator::DISABLE_SNAP);
482
  void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
483
                    nsIScrollbarMediator::ScrollSnapMode aSnap
484
                      = nsIScrollbarMediator::DISABLE_SNAP);
485
  void RepeatButtonScroll(nsScrollbarFrame* aScrollbar);
486
  void ThumbMoved(nsScrollbarFrame* aScrollbar,
487
                  nscoord aOldPos,
488
                  nscoord aNewPos);
489
  void ScrollbarReleased(nsScrollbarFrame* aScrollbar);
490
  void ScrollByUnit(nsScrollbarFrame* aScrollbar,
491
                    nsIScrollableFrame::ScrollMode aMode,
492
                    int32_t aDirection,
493
                    nsIScrollableFrame::ScrollUnit aUnit,
494
                    nsIScrollbarMediator::ScrollSnapMode aSnap
495
                      = nsIScrollbarMediator::DISABLE_SNAP);
496
0
  bool ShouldSuppressScrollbarRepaints() const {
497
0
    return mSuppressScrollbarRepaints;
498
0
  }
499
500
  bool DragScroll(WidgetEvent* aEvent);
501
502
  void AsyncScrollbarDragRejected();
503
504
0
  bool IsRootScrollFrameOfDocument() const { return mIsRoot; }
505
506
  // owning references to the nsIAnonymousContentCreator-built content
507
  nsCOMPtr<mozilla::dom::Element> mHScrollbarContent;
508
  nsCOMPtr<mozilla::dom::Element> mVScrollbarContent;
509
  nsCOMPtr<mozilla::dom::Element> mScrollCornerContent;
510
  nsCOMPtr<mozilla::dom::Element> mResizerContent;
511
512
  RefPtr<ScrollEvent> mScrollEvent;
513
  RefPtr<ScrollEndEvent> mScrollEndEvent;
514
  nsRevocableEventPtr<AsyncScrollPortEvent> mAsyncScrollPortEvent;
515
  nsRevocableEventPtr<ScrolledAreaEvent> mScrolledAreaEvent;
516
  nsIFrame* mHScrollbarBox;
517
  nsIFrame* mVScrollbarBox;
518
  nsIFrame* mScrolledFrame;
519
  nsIFrame* mScrollCornerBox;
520
  nsIFrame* mResizerBox;
521
  nsContainerFrame* mOuter;
522
  const nsIFrame* mReferenceFrameDuringPainting;
523
  RefPtr<AsyncScroll> mAsyncScroll;
524
  RefPtr<AsyncSmoothMSDScroll> mAsyncSmoothMSDScroll;
525
  RefPtr<ScrollbarActivity> mScrollbarActivity;
526
  nsTArray<nsIScrollPositionListener*> mListeners;
527
  nsAtom* mLastScrollOrigin;
528
  bool mAllowScrollOriginDowngrade;
529
  nsAtom* mLastSmoothScrollOrigin;
530
  Maybe<nsPoint> mApzSmoothScrollDestination;
531
  uint32_t mScrollGeneration;
532
  nsRect mScrollPort;
533
  // Where we're currently scrolling to, if we're scrolling asynchronously.
534
  // If we're not in the middle of an asynchronous scroll then this is
535
  // just the current scroll position. ScrollBy will choose its
536
  // destination based on this value.
537
  nsPoint mDestination;
538
  nsPoint mScrollPosAtLastPaint;
539
540
  // A goal position to try to scroll to as content loads. As long as mLastPos
541
  // matches the current logical scroll position, we try to scroll to mRestorePos
542
  // after every reflow --- because after each time content is loaded/added to the
543
  // scrollable element, there will be a reflow.
544
  nsPoint mRestorePos;
545
  // The last logical position we scrolled to while trying to restore mRestorePos, or
546
  // 0,0 when this is a new frame. Set to -1,-1 once we've scrolled for any reason
547
  // other than trying to restore mRestorePos.
548
  nsPoint mLastPos;
549
550
  nsExpirationState mActivityExpirationState;
551
552
  nsCOMPtr<nsITimer> mScrollActivityTimer;
553
  nsPoint mScrollPosForLayerPixelAlignment;
554
555
  // The scroll position where we last updated frame visibility.
556
  nsPoint mLastUpdateFramesPos;
557
  bool mHadDisplayPortAtLastFrameUpdate;
558
  nsRect mDisplayPortAtLastFrameUpdate;
559
560
  nsRect mPrevScrolledRect;
561
562
  FrameMetrics::ViewID mScrollParentID;
563
564
  // Timer to remove the displayport some time after scrolling has stopped
565
  nsCOMPtr<nsITimer> mDisplayPortExpiryTimer;
566
567
  bool mNeverHasVerticalScrollbar:1;
568
  bool mNeverHasHorizontalScrollbar:1;
569
  bool mHasVerticalScrollbar:1;
570
  bool mHasHorizontalScrollbar:1;
571
  bool mFrameIsUpdatingScrollbar:1;
572
  bool mDidHistoryRestore:1;
573
  // Is this the scrollframe for the document's viewport?
574
  bool mIsRoot:1;
575
  // True if we should clip all descendants, false if we should only clip
576
  // descendants for which we are the containing block.
577
  bool mClipAllDescendants:1;
578
  // If true, don't try to layout the scrollbars in Reflow().  This can be
579
  // useful if multiple passes are involved, because we don't want to place the
580
  // scrollbars at the wrong size.
581
  bool mSuppressScrollbarUpdate:1;
582
  // If true, we skipped a scrollbar layout due to mSuppressScrollbarUpdate
583
  // being set at some point.  That means we should lay out scrollbars even if
584
  // it might not strictly be needed next time mSuppressScrollbarUpdate is
585
  // false.
586
  bool mSkippedScrollbarLayout:1;
587
588
  bool mHadNonInitialReflow:1;
589
  // State used only by PostScrollEvents so we know
590
  // which overflow states have changed.
591
  bool mHorizontalOverflow:1;
592
  bool mVerticalOverflow:1;
593
  bool mPostedReflowCallback:1;
594
  bool mMayHaveDirtyFixedChildren:1;
595
  // If true, need to actually update our scrollbar attributes in the
596
  // reflow callback.
597
  bool mUpdateScrollbarAttributes:1;
598
  // If true, we should be prepared to scroll using this scrollframe
599
  // by placing descendant content into its own layer(s)
600
  bool mHasBeenScrolledRecently:1;
601
  // If true, the resizer is collapsed and not displayed
602
  bool mCollapsedResizer:1;
603
604
  // If true, the scroll frame should always be active because we always build
605
  // a scrollable layer. Used for asynchronous scrolling.
606
  bool mWillBuildScrollableLayer:1;
607
608
  // If true, the scroll frame is an ancestor of other scrolling frames, so
609
  // we shouldn't expire the displayport on this scrollframe unless those
610
  // descendant scrollframes also have their displayports removed.
611
  bool mIsScrollParent:1;
612
613
  // Whether we are the root scroll frame that is used for containerful
614
  // scrolling with a display port. If true, the scrollable frame
615
  // shouldn't attach frame metrics to its layers because the container
616
  // will already have the necessary frame metrics.
617
  bool mIsScrollableLayerInRootContainer:1;
618
619
  // If true, add clipping in ScrollFrameHelper::ClipLayerToDisplayPort.
620
  bool mAddClipRectToLayer:1;
621
622
  // True if this frame has been scrolled at least once
623
  bool mHasBeenScrolled:1;
624
625
  // True if the events synthesized by OSX to produce momentum scrolling should
626
  // be ignored.  Reset when the next real, non-synthesized scroll event occurs.
627
  bool mIgnoreMomentumScroll:1;
628
629
  // True if the APZ is in the process of async-transforming this scrollframe,
630
  // (as best as we can tell on the main thread, anyway).
631
  bool mTransformingByAPZ:1;
632
633
  // True if APZ can scroll this frame asynchronously (i.e. it has an APZC
634
  // set up for this frame and it's not a scrollinfo layer).
635
  bool mScrollableByAPZ:1;
636
637
  // True if the APZ is allowed to zoom this scrollframe.
638
  bool mZoomableByAPZ:1;
639
640
  // True if the scroll frame contains out-of-flow content and is inside
641
  // a CSS filter.
642
  bool mHasOutOfFlowContentInsideFilter:1;
643
644
  // True if we don't want the scrollbar to repaint itself right now.
645
  bool mSuppressScrollbarRepaints:1;
646
647
  mozilla::layout::ScrollVelocityQueue mVelocityQueue;
648
649
protected:
650
  class AutoScrollbarRepaintSuppression;
651
  friend class AutoScrollbarRepaintSuppression;
652
  class AutoScrollbarRepaintSuppression {
653
  public:
654
    AutoScrollbarRepaintSuppression(ScrollFrameHelper* aHelper, bool aSuppress)
655
      : mHelper(aHelper)
656
      , mOldSuppressValue(aHelper->mSuppressScrollbarRepaints)
657
0
    {
658
0
      mHelper->mSuppressScrollbarRepaints = aSuppress;
659
0
    }
660
661
    ~AutoScrollbarRepaintSuppression()
662
0
    {
663
0
      mHelper->mSuppressScrollbarRepaints = mOldSuppressValue;
664
0
    }
665
666
  private:
667
    ScrollFrameHelper* mHelper;
668
    bool mOldSuppressValue;
669
  };
670
671
  /**
672
   * @note This method might destroy the frame, pres shell and other objects.
673
   */
674
  void ScrollToWithOrigin(nsPoint aScrollPosition,
675
                          nsIScrollableFrame::ScrollMode aMode,
676
                          nsAtom *aOrigin, // nullptr indicates "other" origin
677
                          const nsRect* aRange,
678
                          nsIScrollbarMediator::ScrollSnapMode aSnap
679
                            = nsIScrollbarMediator::DISABLE_SNAP);
680
681
  void CompleteAsyncScroll(const nsRect &aRange, nsAtom* aOrigin = nullptr);
682
683
  bool HasPluginFrames();
684
0
  bool HasPerspective() const {
685
0
    return mOuter->ChildrenHavePerspective();
686
0
  }
687
  bool HasBgAttachmentLocal() const;
688
  uint8_t GetScrolledFrameDir() const;
689
690
  bool IsForTextControlWithNoScrollbars() const;
691
692
  static void EnsureFrameVisPrefsCached();
693
  static bool sFrameVisPrefsCached;
694
  // The number of scrollports wide/high to expand when tracking frame visibility.
695
  static uint32_t sHorzExpandScrollPort;
696
  static uint32_t sVertExpandScrollPort;
697
  // The fraction of the scrollport we allow to scroll by before we schedule
698
  // an update of frame visibility.
699
  static int32_t sHorzScrollFraction;
700
  static int32_t sVertScrollFraction;
701
};
702
703
} // namespace mozilla
704
705
/**
706
 * The scroll frame creates and manages the scrolling view
707
 *
708
 * It only supports having a single child frame that typically is an area
709
 * frame, but doesn't have to be. The child frame must have a view, though
710
 *
711
 * Scroll frames don't support incremental changes, i.e. you can't replace
712
 * or remove the scrolled frame
713
 */
714
class nsHTMLScrollFrame : public nsContainerFrame,
715
                          public nsIScrollableFrame,
716
                          public nsIAnonymousContentCreator,
717
                          public nsIStatefulFrame {
718
public:
719
  typedef mozilla::ScrollFrameHelper ScrollFrameHelper;
720
  typedef mozilla::CSSIntPoint CSSIntPoint;
721
  typedef mozilla::ScrollReflowInput ScrollReflowInput;
722
  friend nsHTMLScrollFrame* NS_NewHTMLScrollFrame(nsIPresShell* aPresShell,
723
                                                  ComputedStyle* aStyle,
724
                                                  bool aIsRoot);
725
726
  NS_DECL_QUERYFRAME
727
  NS_DECL_FRAMEARENA_HELPERS(nsHTMLScrollFrame)
728
729
  virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
730
0
                                const nsDisplayListSet& aLists) override {
731
0
    mHelper.BuildDisplayList(aBuilder, aLists);
732
0
  }
733
734
  bool TryLayout(ScrollReflowInput* aState,
735
                   ReflowOutput* aKidMetrics,
736
                   bool aAssumeVScroll, bool aAssumeHScroll,
737
                   bool aForce);
738
  bool ScrolledContentDependsOnHeight(ScrollReflowInput* aState);
739
  void ReflowScrolledFrame(ScrollReflowInput* aState,
740
                           bool aAssumeHScroll,
741
                           bool aAssumeVScroll,
742
                           ReflowOutput* aMetrics,
743
                           bool aFirstPass);
744
  void ReflowContents(ScrollReflowInput* aState,
745
                      const ReflowOutput& aDesiredSize);
746
  void PlaceScrollArea(ScrollReflowInput& aState,
747
                       const nsPoint& aScrollPosition);
748
  nscoord GetIntrinsicVScrollbarWidth(gfxContext *aRenderingContext);
749
750
  virtual bool GetBorderRadii(const nsSize& aFrameSize, const nsSize& aBorderArea,
751
0
                              Sides aSkipSides, nscoord aRadii[8]) const override {
752
0
    return mHelper.GetBorderRadii(aFrameSize, aBorderArea, aSkipSides, aRadii);
753
0
  }
754
755
  virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
756
  virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
757
  virtual nsresult GetXULPadding(nsMargin& aPadding) override;
758
  virtual bool IsXULCollapsed() override;
759
760
  virtual void Reflow(nsPresContext*           aPresContext,
761
                      ReflowOutput&     aDesiredSize,
762
                      const ReflowInput& aReflowInput,
763
                      nsReflowStatus&          aStatus) override;
764
765
0
  virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
766
0
    return mHelper.ComputeCustomOverflow(aOverflowAreas);
767
0
  }
768
769
  bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
770
0
                                nscoord* aBaseline) const override {
771
0
    *aBaseline = GetLogicalBaseline(aWM);
772
0
    return true;
773
0
  }
774
775
  // Recomputes the scrollable overflow area we store in the helper to take children
776
  // that are affected by perpsective set on the outer frame and scroll at different
777
  // rates.
778
  void AdjustForPerspective(nsRect& aScrollableOverflow);
779
780
  // Called to set the child frames. We typically have three: the scroll area,
781
  // the vertical scrollbar, and the horizontal scrollbar.
782
  virtual void SetInitialChildList(ChildListID     aListID,
783
                                   nsFrameList&    aChildList) override;
784
  virtual void AppendFrames(ChildListID     aListID,
785
                            nsFrameList&    aFrameList) override;
786
  virtual void InsertFrames(ChildListID     aListID,
787
                            nsIFrame*       aPrevFrame,
788
                            nsFrameList&    aFrameList) override;
789
  virtual void RemoveFrame(ChildListID     aListID,
790
                           nsIFrame*       aOldFrame) override;
791
792
  virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
793
794
0
  virtual nsIScrollableFrame* GetScrollTargetFrame() override {
795
0
    return this;
796
0
  }
797
798
0
  virtual nsContainerFrame* GetContentInsertionFrame() override {
799
0
    return mHelper.GetScrolledFrame()->GetContentInsertionFrame();
800
0
  }
801
802
0
  virtual bool DoesClipChildren() override { return true; }
803
  virtual nsSplittableType GetSplittableType() const override;
804
805
  nsPoint GetPositionOfChildIgnoringScrolling(const nsIFrame* aChild) override
806
0
  { nsPoint pt = aChild->GetPosition();
807
0
    if (aChild == mHelper.GetScrolledFrame()) pt += GetScrollPosition();
808
0
    return pt;
809
0
  }
810
811
  // nsIAnonymousContentCreator
812
  virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
813
  virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
814
                                        uint32_t aFilter) override;
815
816
  // nsIScrollableFrame
817
0
  virtual nsIFrame* GetScrolledFrame() const override {
818
0
    return mHelper.GetScrolledFrame();
819
0
  }
820
0
  virtual mozilla::ScrollStyles GetScrollStyles() const override {
821
0
    return mHelper.GetScrollStylesFromFrame();
822
0
  }
823
0
  virtual uint32_t GetScrollbarVisibility() const override {
824
0
    return mHelper.GetScrollbarVisibility();
825
0
  }
826
0
  virtual nsMargin GetActualScrollbarSizes() const override {
827
0
    return mHelper.GetActualScrollbarSizes();
828
0
  }
829
0
  virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) override {
830
0
    return mHelper.GetDesiredScrollbarSizes(aState);
831
0
  }
832
  virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
833
0
          gfxContext* aRC) override {
834
0
    nsBoxLayoutState bls(aPresContext, aRC, 0);
835
0
    return GetDesiredScrollbarSizes(&bls);
836
0
  }
837
  virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
838
0
          gfxContext* aRC, mozilla::WritingMode aWM) override {
839
0
    nsBoxLayoutState bls(aPresContext, aRC, 0);
840
0
    return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
841
0
  }
842
0
  virtual nsRect GetScrolledRect() const override {
843
0
    return mHelper.GetScrolledRect();
844
0
  }
845
0
  virtual nsRect GetScrollPortRect() const override {
846
0
    return mHelper.GetScrollPortRect();
847
0
  }
848
0
  virtual nsPoint GetScrollPosition() const override {
849
0
    return mHelper.GetScrollPosition();
850
0
  }
851
0
  virtual nsPoint GetLogicalScrollPosition() const override {
852
0
    return mHelper.GetLogicalScrollPosition();
853
0
  }
854
0
  virtual nsRect GetScrollRange() const override {
855
0
    return mHelper.GetScrollRange();
856
0
  }
857
0
  virtual nsSize GetVisualViewportSize() const override {
858
0
    return mHelper.GetVisualViewportSize();
859
0
  }
860
0
  virtual nsSize GetLineScrollAmount() const override {
861
0
    return mHelper.GetLineScrollAmount();
862
0
  }
863
0
  virtual nsSize GetPageScrollAmount() const override {
864
0
    return mHelper.GetPageScrollAmount();
865
0
  }
866
  /**
867
   * @note This method might destroy the frame, pres shell and other objects.
868
   */
869
  virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
870
                        const nsRect* aRange = nullptr,
871
                        nsIScrollbarMediator::ScrollSnapMode aSnap
872
                          = nsIScrollbarMediator::DISABLE_SNAP)
873
0
                        override {
874
0
    mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
875
0
  }
876
  /**
877
   * @note This method might destroy the frame, pres shell and other objects.
878
   */
879
  virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
880
                                 nsIScrollableFrame::ScrollMode aMode
881
0
                                   = nsIScrollableFrame::INSTANT) override {
882
0
    mHelper.ScrollToCSSPixels(aScrollPosition, aMode);
883
0
  }
884
  virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
885
0
                                            nsAtom* aOrigin = nullptr) override {
886
0
    mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin);
887
0
  }
888
  /**
889
   * @note This method might destroy the frame, pres shell and other objects.
890
   */
891
0
  virtual CSSIntPoint GetScrollPositionCSSPixels() override {
892
0
    return mHelper.GetScrollPositionCSSPixels();
893
0
  }
894
  /**
895
   * @note This method might destroy the frame, pres shell and other objects.
896
   */
897
  virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
898
                        nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
899
                        nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
900
                        nsIScrollbarMediator::ScrollSnapMode aSnap
901
                          = nsIScrollbarMediator::DISABLE_SNAP)
902
0
                        override {
903
0
    mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
904
0
  }
905
0
  virtual void ScrollSnap() override {
906
0
    mHelper.ScrollSnap();
907
0
  }
908
  /**
909
   * @note This method might destroy the frame, pres shell and other objects.
910
   */
911
0
  virtual void ScrollToRestoredPosition() override {
912
0
    mHelper.ScrollToRestoredPosition();
913
0
  }
914
0
  virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) override {
915
0
    mHelper.AddScrollPositionListener(aListener);
916
0
  }
917
0
  virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) override {
918
0
    mHelper.RemoveScrollPositionListener(aListener);
919
0
  }
920
  /**
921
   * @note This method might destroy the frame, pres shell and other objects.
922
   */
923
0
  virtual void CurPosAttributeChanged(nsIContent* aChild) override {
924
0
    mHelper.CurPosAttributeChanged(aChild);
925
0
  }
926
0
  NS_IMETHOD PostScrolledAreaEventForCurrentArea() override {
927
0
    mHelper.PostScrolledAreaEvent();
928
0
    return NS_OK;
929
0
  }
930
0
  virtual bool IsScrollingActive(nsDisplayListBuilder* aBuilder) override {
931
0
    return mHelper.IsScrollingActive(aBuilder);
932
0
  }
933
0
  virtual bool IsMaybeScrollingActive() const override {
934
0
    return mHelper.IsMaybeScrollingActive();
935
0
  }
936
0
  virtual bool IsMaybeAsynchronouslyScrolled() override {
937
0
    return mHelper.IsMaybeAsynchronouslyScrolled();
938
0
  }
939
0
  virtual bool IsProcessingAsyncScroll() override {
940
0
    return mHelper.IsProcessingAsyncScroll();
941
0
  }
942
0
  virtual void ResetScrollPositionForLayerPixelAlignment() override {
943
0
    mHelper.ResetScrollPositionForLayerPixelAlignment();
944
0
  }
945
0
  virtual bool DidHistoryRestore() const override {
946
0
    return mHelper.mDidHistoryRestore;
947
0
  }
948
0
  virtual void ClearDidHistoryRestore() override {
949
0
    mHelper.mDidHistoryRestore = false;
950
0
  }
951
0
  virtual bool IsRectNearlyVisible(const nsRect& aRect) override {
952
0
    return mHelper.IsRectNearlyVisible(aRect);
953
0
  }
954
0
  virtual nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const override {
955
0
    return mHelper.ExpandRectToNearlyVisible(aRect);
956
0
  }
957
0
  virtual nsAtom* LastScrollOrigin() override {
958
0
    return mHelper.LastScrollOrigin();
959
0
  }
960
0
  virtual void AllowScrollOriginDowngrade() override {
961
0
    mHelper.AllowScrollOriginDowngrade();
962
0
  }
963
0
  virtual nsAtom* LastSmoothScrollOrigin() override {
964
0
    return mHelper.LastSmoothScrollOrigin();
965
0
  }
966
0
  virtual uint32_t CurrentScrollGeneration() override {
967
0
    return mHelper.CurrentScrollGeneration();
968
0
  }
969
0
  virtual nsPoint LastScrollDestination() override {
970
0
    return mHelper.LastScrollDestination();
971
0
  }
972
0
  virtual void ResetScrollInfoIfGeneration(uint32_t aGeneration) override {
973
0
    mHelper.ResetScrollInfoIfGeneration(aGeneration);
974
0
  }
975
0
  virtual bool WantAsyncScroll() const override {
976
0
    return mHelper.WantAsyncScroll();
977
0
  }
978
  virtual mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
979
    LayerManager* aLayerManager,
980
    const nsIFrame* aContainerReferenceFrame,
981
    const ContainerLayerParameters& aParameters,
982
    const mozilla::DisplayItemClip* aClip) const override
983
0
  {
984
0
    return mHelper.ComputeScrollMetadata(aLayerManager, aContainerReferenceFrame, aParameters, aClip);
985
0
  }
986
  virtual void ClipLayerToDisplayPort(Layer* aLayer,
987
                                      const mozilla::DisplayItemClip* aClip,
988
                                      const ContainerLayerParameters& aParameters) const override
989
0
  {
990
0
    mHelper.ClipLayerToDisplayPort(aLayer, aClip, aParameters);
991
0
  }
992
0
  virtual bool IsIgnoringViewportClipping() const override {
993
0
    return mHelper.IsIgnoringViewportClipping();
994
0
  }
995
0
  virtual void MarkScrollbarsDirtyForReflow() const override {
996
0
    mHelper.MarkScrollbarsDirtyForReflow();
997
0
  }
998
0
  virtual bool UsesContainerScrolling() const override {
999
0
    return mHelper.UsesContainerScrolling();
1000
0
  }
1001
  virtual bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
1002
                                     nsRect* aVisibleRect,
1003
                                     nsRect* aDirtyRect,
1004
0
                                     bool aSetBase) override {
1005
0
    return mHelper.DecideScrollableLayer(aBuilder, aVisibleRect, aDirtyRect, aSetBase);
1006
0
  }
1007
0
  virtual void NotifyApproximateFrameVisibilityUpdate(bool aIgnoreDisplayPort) override {
1008
0
    mHelper.NotifyApproximateFrameVisibilityUpdate(aIgnoreDisplayPort);
1009
0
  }
1010
0
  virtual bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(nsRect* aDisplayPort) override {
1011
0
    return mHelper.GetDisplayPortAtLastApproximateFrameVisibilityUpdate(aDisplayPort);
1012
0
  }
1013
0
  void TriggerDisplayPortExpiration() override {
1014
0
    mHelper.TriggerDisplayPortExpiration();
1015
0
  }
1016
1017
  // nsIStatefulFrame
1018
0
  mozilla::UniquePtr<mozilla::PresState> SaveState() override {
1019
0
    return mHelper.SaveState();
1020
0
  }
1021
0
  NS_IMETHOD RestoreState(mozilla::PresState* aState) override {
1022
0
    NS_ENSURE_ARG_POINTER(aState);
1023
0
    mHelper.RestoreState(aState);
1024
0
    return NS_OK;
1025
0
  }
1026
1027
  // nsIScrollbarMediator
1028
  virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
1029
                            nsIScrollbarMediator::ScrollSnapMode aSnap
1030
0
                              = nsIScrollbarMediator::DISABLE_SNAP) override {
1031
0
    mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
1032
0
  }
1033
  virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
1034
                             nsIScrollbarMediator::ScrollSnapMode aSnap
1035
0
                               = nsIScrollbarMediator::DISABLE_SNAP) override {
1036
0
    mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
1037
0
  }
1038
  virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
1039
                            nsIScrollbarMediator::ScrollSnapMode aSnap
1040
0
                              = nsIScrollbarMediator::DISABLE_SNAP) override {
1041
0
    mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
1042
0
  }
1043
0
  virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
1044
0
    mHelper.RepeatButtonScroll(aScrollbar);
1045
0
  }
1046
  virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
1047
                          nscoord aOldPos,
1048
0
                          nscoord aNewPos) override {
1049
0
    mHelper.ThumbMoved(aScrollbar, aOldPos, aNewPos);
1050
0
  }
1051
0
  virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {
1052
0
    mHelper.ScrollbarReleased(aScrollbar);
1053
0
  }
1054
0
  virtual void VisibilityChanged(bool aVisible) override {}
1055
0
  virtual nsIFrame* GetScrollbarBox(bool aVertical) override {
1056
0
    return mHelper.GetScrollbarBox(aVertical);
1057
0
  }
1058
  virtual void ScrollbarActivityStarted() const override;
1059
  virtual void ScrollbarActivityStopped() const override;
1060
1061
0
  virtual bool IsScrollbarOnRight() const override {
1062
0
    return mHelper.IsScrollbarOnRight();
1063
0
  }
1064
1065
0
  virtual bool ShouldSuppressScrollbarRepaints() const override {
1066
0
    return mHelper.ShouldSuppressScrollbarRepaints();
1067
0
  }
1068
1069
0
  virtual void SetTransformingByAPZ(bool aTransforming) override {
1070
0
    mHelper.SetTransformingByAPZ(aTransforming);
1071
0
  }
1072
0
  bool IsTransformingByAPZ() const override {
1073
0
    return mHelper.IsTransformingByAPZ();
1074
0
  }
1075
0
  void SetScrollableByAPZ(bool aScrollable) override {
1076
0
    mHelper.SetScrollableByAPZ(aScrollable);
1077
0
  }
1078
0
  void SetZoomableByAPZ(bool aZoomable) override {
1079
0
    mHelper.SetZoomableByAPZ(aZoomable);
1080
0
  }
1081
0
  void SetHasOutOfFlowContentInsideFilter() override {
1082
0
    mHelper.SetHasOutOfFlowContentInsideFilter();
1083
0
  }
1084
1085
0
  ScrollSnapInfo GetScrollSnapInfo() const override {
1086
0
    return mHelper.GetScrollSnapInfo();
1087
0
  }
1088
1089
0
  virtual bool DragScroll(mozilla::WidgetEvent* aEvent) override {
1090
0
    return mHelper.DragScroll(aEvent);
1091
0
  }
1092
1093
0
  virtual void AsyncScrollbarDragRejected() override {
1094
0
    return mHelper.AsyncScrollbarDragRejected();
1095
0
  }
1096
1097
0
  virtual bool IsRootScrollFrameOfDocument() const override {
1098
0
    return mHelper.IsRootScrollFrameOfDocument();
1099
0
  }
1100
1101
  // Return the scrolled frame.
1102
0
  void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override {
1103
0
    aResult.AppendElement(OwnedAnonBox(mHelper.GetScrolledFrame()));
1104
0
  }
1105
1106
#ifdef DEBUG_FRAME_DUMP
1107
  virtual nsresult GetFrameName(nsAString& aResult) const override;
1108
#endif
1109
1110
#ifdef ACCESSIBILITY
1111
  virtual mozilla::a11y::AccType AccessibleType() override;
1112
#endif
1113
1114
protected:
1115
  nsHTMLScrollFrame(ComputedStyle* aStyle, bool aIsRoot)
1116
    : nsHTMLScrollFrame(aStyle, kClassID, aIsRoot)
1117
0
  {}
1118
1119
  nsHTMLScrollFrame(ComputedStyle* aStyle,
1120
                    nsIFrame::ClassID aID,
1121
                    bool aIsRoot);
1122
0
  void SetSuppressScrollbarUpdate(bool aSuppress) {
1123
0
    mHelper.mSuppressScrollbarUpdate = aSuppress;
1124
0
  }
1125
  bool GuessHScrollbarNeeded(const ScrollReflowInput& aState);
1126
  bool GuessVScrollbarNeeded(const ScrollReflowInput& aState);
1127
1128
0
  bool IsScrollbarUpdateSuppressed() const {
1129
0
    return mHelper.mSuppressScrollbarUpdate;
1130
0
  }
1131
1132
  // Return whether we're in an "initial" reflow.  Some reflows with
1133
  // NS_FRAME_FIRST_REFLOW set are NOT "initial" as far as we're concerned.
1134
  bool InInitialReflow() const;
1135
1136
  /**
1137
   * Override this to return false if computed bsize/min-bsize/max-bsize
1138
   * should NOT be propagated to child content.
1139
   * nsListControlFrame uses this.
1140
   */
1141
0
  virtual bool ShouldPropagateComputedBSizeToScrolledContent() const { return true; }
1142
1143
private:
1144
  friend class mozilla::ScrollFrameHelper;
1145
  ScrollFrameHelper mHelper;
1146
};
1147
1148
/**
1149
 * The scroll frame creates and manages the scrolling view
1150
 *
1151
 * It only supports having a single child frame that typically is an area
1152
 * frame, but doesn't have to be. The child frame must have a view, though
1153
 *
1154
 * Scroll frames don't support incremental changes, i.e. you can't replace
1155
 * or remove the scrolled frame
1156
 */
1157
class nsXULScrollFrame final : public nsBoxFrame,
1158
                               public nsIScrollableFrame,
1159
                               public nsIAnonymousContentCreator,
1160
                               public nsIStatefulFrame
1161
{
1162
public:
1163
  typedef mozilla::ScrollFrameHelper ScrollFrameHelper;
1164
  typedef mozilla::CSSIntPoint CSSIntPoint;
1165
1166
  NS_DECL_QUERYFRAME
1167
  NS_DECL_FRAMEARENA_HELPERS(nsXULScrollFrame)
1168
1169
  friend nsXULScrollFrame* NS_NewXULScrollFrame(nsIPresShell* aPresShell,
1170
                                                ComputedStyle* aStyle,
1171
                                                bool aIsRoot,
1172
                                                bool aClipAllDescendants);
1173
1174
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
1175
0
                                const nsDisplayListSet& aLists) override {
1176
0
    mHelper.BuildDisplayList(aBuilder, aLists);
1177
0
  }
1178
1179
  // XXXldb Is this actually used?
1180
#if 0
1181
  virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
1182
#endif
1183
1184
0
  virtual bool ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) override {
1185
0
    return mHelper.ComputeCustomOverflow(aOverflowAreas);
1186
0
  }
1187
1188
  bool GetVerticalAlignBaseline(mozilla::WritingMode aWM,
1189
0
                                nscoord* aBaseline) const override {
1190
0
    *aBaseline = GetLogicalBaseline(aWM);
1191
0
    return true;
1192
0
  }
1193
1194
  // Called to set the child frames. We typically have three: the scroll area,
1195
  // the vertical scrollbar, and the horizontal scrollbar.
1196
  virtual void SetInitialChildList(ChildListID     aListID,
1197
                                   nsFrameList&    aChildList) override;
1198
  virtual void AppendFrames(ChildListID     aListID,
1199
                            nsFrameList&    aFrameList) override;
1200
  virtual void InsertFrames(ChildListID     aListID,
1201
                            nsIFrame*       aPrevFrame,
1202
                            nsFrameList&    aFrameList) override;
1203
  virtual void RemoveFrame(ChildListID     aListID,
1204
                           nsIFrame*       aOldFrame) override;
1205
1206
  virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
1207
1208
1209
0
  virtual nsIScrollableFrame* GetScrollTargetFrame() override {
1210
0
    return this;
1211
0
  }
1212
1213
0
  virtual nsContainerFrame* GetContentInsertionFrame() override {
1214
0
    return mHelper.GetScrolledFrame()->GetContentInsertionFrame();
1215
0
  }
1216
1217
0
  virtual bool DoesClipChildren() override { return true; }
1218
  virtual nsSplittableType GetSplittableType() const override;
1219
1220
  nsPoint GetPositionOfChildIgnoringScrolling(const nsIFrame* aChild) override
1221
0
  { nsPoint pt = aChild->GetPosition();
1222
0
    if (aChild == mHelper.GetScrolledFrame())
1223
0
      pt += mHelper.GetLogicalScrollPosition();
1224
0
    return pt;
1225
0
  }
1226
1227
  // nsIAnonymousContentCreator
1228
  virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
1229
  virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
1230
                                        uint32_t aFilter) override;
1231
1232
  virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
1233
  virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
1234
  virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
1235
  virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
1236
1237
  NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
1238
  virtual nsresult GetXULPadding(nsMargin& aPadding) override;
1239
1240
  virtual bool GetBorderRadii(const nsSize& aFrameSize, const nsSize& aBorderArea,
1241
0
                              Sides aSkipSides, nscoord aRadii[8]) const override {
1242
0
    return mHelper.GetBorderRadii(aFrameSize, aBorderArea, aSkipSides, aRadii);
1243
0
  }
1244
1245
  nsresult XULLayout(nsBoxLayoutState& aState);
1246
  void LayoutScrollArea(nsBoxLayoutState& aState, const nsPoint& aScrollPosition);
1247
1248
  static bool AddRemoveScrollbar(bool& aHasScrollbar,
1249
                                   nscoord& aXY,
1250
                                   nscoord& aSize,
1251
                                   nscoord aSbSize,
1252
                                   bool aOnRightOrBottom,
1253
                                   bool aAdd);
1254
1255
  bool AddRemoveScrollbar(nsBoxLayoutState& aState,
1256
                            bool aOnRightOrBottom,
1257
                            bool aHorizontal,
1258
                            bool aAdd);
1259
1260
  bool AddHorizontalScrollbar (nsBoxLayoutState& aState, bool aOnBottom);
1261
  bool AddVerticalScrollbar   (nsBoxLayoutState& aState, bool aOnRight);
1262
  void RemoveHorizontalScrollbar(nsBoxLayoutState& aState, bool aOnBottom);
1263
  void RemoveVerticalScrollbar  (nsBoxLayoutState& aState, bool aOnRight);
1264
1265
  static void AdjustReflowInputForPrintPreview(nsBoxLayoutState& aState, bool& aSetBack);
1266
  static void AdjustReflowInputBack(nsBoxLayoutState& aState, bool aSetBack);
1267
1268
  // nsIScrollableFrame
1269
0
  virtual nsIFrame* GetScrolledFrame() const override {
1270
0
    return mHelper.GetScrolledFrame();
1271
0
  }
1272
0
  virtual mozilla::ScrollStyles GetScrollStyles() const override {
1273
0
    return mHelper.GetScrollStylesFromFrame();
1274
0
  }
1275
0
  virtual uint32_t GetScrollbarVisibility() const override {
1276
0
    return mHelper.GetScrollbarVisibility();
1277
0
  }
1278
0
  virtual nsMargin GetActualScrollbarSizes() const override {
1279
0
    return mHelper.GetActualScrollbarSizes();
1280
0
  }
1281
0
  virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) override {
1282
0
    return mHelper.GetDesiredScrollbarSizes(aState);
1283
0
  }
1284
  virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
1285
0
          gfxContext* aRC) override {
1286
0
    nsBoxLayoutState bls(aPresContext, aRC, 0);
1287
0
    return GetDesiredScrollbarSizes(&bls);
1288
0
  }
1289
  virtual nscoord GetNondisappearingScrollbarWidth(nsPresContext* aPresContext,
1290
0
          gfxContext* aRC, mozilla::WritingMode aWM) override {
1291
0
    nsBoxLayoutState bls(aPresContext, aRC, 0);
1292
0
    return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
1293
0
  }
1294
0
  virtual nsRect GetScrolledRect() const override {
1295
0
    return mHelper.GetScrolledRect();
1296
0
  }
1297
0
  virtual nsRect GetScrollPortRect() const override {
1298
0
    return mHelper.GetScrollPortRect();
1299
0
  }
1300
0
  virtual nsPoint GetScrollPosition() const override {
1301
0
    return mHelper.GetScrollPosition();
1302
0
  }
1303
0
  virtual nsPoint GetLogicalScrollPosition() const override {
1304
0
    return mHelper.GetLogicalScrollPosition();
1305
0
  }
1306
0
  virtual nsRect GetScrollRange() const override {
1307
0
    return mHelper.GetScrollRange();
1308
0
  }
1309
0
  virtual nsSize GetVisualViewportSize() const override {
1310
0
    return mHelper.GetVisualViewportSize();
1311
0
  }
1312
0
  virtual nsSize GetLineScrollAmount() const override {
1313
0
    return mHelper.GetLineScrollAmount();
1314
0
  }
1315
0
  virtual nsSize GetPageScrollAmount() const override {
1316
0
    return mHelper.GetPageScrollAmount();
1317
0
  }
1318
  /**
1319
   * @note This method might destroy the frame, pres shell and other objects.
1320
   */
1321
  virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
1322
                        const nsRect* aRange = nullptr,
1323
                        ScrollSnapMode aSnap = nsIScrollbarMediator::DISABLE_SNAP)
1324
0
                        override {
1325
0
    mHelper.ScrollTo(aScrollPosition, aMode, aRange, aSnap);
1326
0
  }
1327
  /**
1328
   * @note This method might destroy the frame, pres shell and other objects.
1329
   */
1330
  virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
1331
                                 nsIScrollableFrame::ScrollMode aMode
1332
0
                                   = nsIScrollableFrame::INSTANT) override {
1333
0
    mHelper.ScrollToCSSPixels(aScrollPosition, aMode);
1334
0
  }
1335
  virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition,
1336
0
                                            nsAtom* aOrigin = nullptr) override {
1337
0
    mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin);
1338
0
  }
1339
0
  virtual CSSIntPoint GetScrollPositionCSSPixels() override {
1340
0
    return mHelper.GetScrollPositionCSSPixels();
1341
0
  }
1342
  /**
1343
   * @note This method might destroy the frame, pres shell and other objects.
1344
   */
1345
  virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
1346
                        nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
1347
                        nsIScrollableFrame::ScrollMomentum aMomentum = nsIScrollableFrame::NOT_MOMENTUM,
1348
                        nsIScrollbarMediator::ScrollSnapMode aSnap
1349
                          = nsIScrollbarMediator::DISABLE_SNAP)
1350
0
                        override {
1351
0
    mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum, aSnap);
1352
0
  }
1353
0
  virtual void ScrollSnap() override {
1354
0
    mHelper.ScrollSnap();
1355
0
  }
1356
  /**
1357
   * @note This method might destroy the frame, pres shell and other objects.
1358
   */
1359
0
  virtual void ScrollToRestoredPosition() override {
1360
0
    mHelper.ScrollToRestoredPosition();
1361
0
  }
1362
0
  virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) override {
1363
0
    mHelper.AddScrollPositionListener(aListener);
1364
0
  }
1365
0
  virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) override {
1366
0
    mHelper.RemoveScrollPositionListener(aListener);
1367
0
  }
1368
  /**
1369
   * @note This method might destroy the frame, pres shell and other objects.
1370
   */
1371
0
  virtual void CurPosAttributeChanged(nsIContent* aChild) override {
1372
0
    mHelper.CurPosAttributeChanged(aChild);
1373
0
  }
1374
0
  NS_IMETHOD PostScrolledAreaEventForCurrentArea() override {
1375
0
    mHelper.PostScrolledAreaEvent();
1376
0
    return NS_OK;
1377
0
  }
1378
0
  virtual bool IsScrollingActive(nsDisplayListBuilder* aBuilder) override {
1379
0
    return mHelper.IsScrollingActive(aBuilder);
1380
0
  }
1381
0
  virtual bool IsMaybeScrollingActive() const override {
1382
0
    return mHelper.IsMaybeScrollingActive();
1383
0
  }
1384
0
  virtual bool IsMaybeAsynchronouslyScrolled() override {
1385
0
    return mHelper.IsMaybeAsynchronouslyScrolled();
1386
0
  }
1387
0
  virtual bool IsProcessingAsyncScroll() override {
1388
0
    return mHelper.IsProcessingAsyncScroll();
1389
0
  }
1390
0
  virtual void ResetScrollPositionForLayerPixelAlignment() override {
1391
0
    mHelper.ResetScrollPositionForLayerPixelAlignment();
1392
0
  }
1393
0
  virtual bool DidHistoryRestore() const override {
1394
0
    return mHelper.mDidHistoryRestore;
1395
0
  }
1396
0
  virtual void ClearDidHistoryRestore() override {
1397
0
    mHelper.mDidHistoryRestore = false;
1398
0
  }
1399
0
  virtual bool IsRectNearlyVisible(const nsRect& aRect) override {
1400
0
    return mHelper.IsRectNearlyVisible(aRect);
1401
0
  }
1402
0
  virtual nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const override {
1403
0
    return mHelper.ExpandRectToNearlyVisible(aRect);
1404
0
  }
1405
0
  virtual nsAtom* LastScrollOrigin() override {
1406
0
    return mHelper.LastScrollOrigin();
1407
0
  }
1408
0
  virtual void AllowScrollOriginDowngrade() override {
1409
0
    mHelper.AllowScrollOriginDowngrade();
1410
0
  }
1411
0
  virtual nsAtom* LastSmoothScrollOrigin() override {
1412
0
    return mHelper.LastSmoothScrollOrigin();
1413
0
  }
1414
0
  virtual uint32_t CurrentScrollGeneration() override {
1415
0
    return mHelper.CurrentScrollGeneration();
1416
0
  }
1417
0
  virtual nsPoint LastScrollDestination() override {
1418
0
    return mHelper.LastScrollDestination();
1419
0
  }
1420
0
  virtual void ResetScrollInfoIfGeneration(uint32_t aGeneration) override {
1421
0
    mHelper.ResetScrollInfoIfGeneration(aGeneration);
1422
0
  }
1423
0
  virtual bool WantAsyncScroll() const override {
1424
0
    return mHelper.WantAsyncScroll();
1425
0
  }
1426
  virtual mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
1427
    LayerManager* aLayerManager,
1428
    const nsIFrame* aContainerReferenceFrame,
1429
    const ContainerLayerParameters& aParameters,
1430
    const mozilla::DisplayItemClip* aClip) const override
1431
0
  {
1432
0
    return mHelper.ComputeScrollMetadata(aLayerManager, aContainerReferenceFrame, aParameters, aClip);
1433
0
  }
1434
  virtual void ClipLayerToDisplayPort(Layer* aLayer,
1435
                                      const mozilla::DisplayItemClip* aClip,
1436
0
                                      const ContainerLayerParameters& aParameters) const override {
1437
0
    mHelper.ClipLayerToDisplayPort(aLayer, aClip, aParameters);
1438
0
  }
1439
0
  virtual bool IsIgnoringViewportClipping() const override {
1440
0
    return mHelper.IsIgnoringViewportClipping();
1441
0
  }
1442
0
  virtual void MarkScrollbarsDirtyForReflow() const override {
1443
0
    mHelper.MarkScrollbarsDirtyForReflow();
1444
0
  }
1445
1446
  // nsIStatefulFrame
1447
0
  mozilla::UniquePtr<mozilla::PresState> SaveState() override {
1448
0
    return mHelper.SaveState();
1449
0
  }
1450
0
  NS_IMETHOD RestoreState(mozilla::PresState* aState) override {
1451
0
    NS_ENSURE_ARG_POINTER(aState);
1452
0
    mHelper.RestoreState(aState);
1453
0
    return NS_OK;
1454
0
  }
1455
1456
  virtual bool IsFrameOfType(uint32_t aFlags) const override
1457
0
  {
1458
0
    // Override bogus IsFrameOfType in nsBoxFrame.
1459
0
    if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
1460
0
      return false;
1461
0
    return nsBoxFrame::IsFrameOfType(aFlags);
1462
0
  }
1463
1464
  virtual void ScrollByPage(nsScrollbarFrame* aScrollbar, int32_t aDirection,
1465
                            nsIScrollbarMediator::ScrollSnapMode aSnap
1466
0
                              = nsIScrollbarMediator::DISABLE_SNAP) override {
1467
0
    mHelper.ScrollByPage(aScrollbar, aDirection, aSnap);
1468
0
  }
1469
  virtual void ScrollByWhole(nsScrollbarFrame* aScrollbar, int32_t aDirection,
1470
                             nsIScrollbarMediator::ScrollSnapMode aSnap
1471
0
                               = nsIScrollbarMediator::DISABLE_SNAP) override {
1472
0
    mHelper.ScrollByWhole(aScrollbar, aDirection, aSnap);
1473
0
  }
1474
  virtual void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
1475
                            nsIScrollbarMediator::ScrollSnapMode aSnap
1476
0
                              = nsIScrollbarMediator::DISABLE_SNAP) override {
1477
0
    mHelper.ScrollByLine(aScrollbar, aDirection, aSnap);
1478
0
  }
1479
0
  virtual void RepeatButtonScroll(nsScrollbarFrame* aScrollbar) override {
1480
0
    mHelper.RepeatButtonScroll(aScrollbar);
1481
0
  }
1482
  virtual void ThumbMoved(nsScrollbarFrame* aScrollbar,
1483
                          nscoord aOldPos,
1484
0
                          nscoord aNewPos) override {
1485
0
    mHelper.ThumbMoved(aScrollbar, aOldPos, aNewPos);
1486
0
  }
1487
0
  virtual void ScrollbarReleased(nsScrollbarFrame* aScrollbar) override {
1488
0
    mHelper.ScrollbarReleased(aScrollbar);
1489
0
  }
1490
0
  virtual void VisibilityChanged(bool aVisible) override {}
1491
0
  virtual nsIFrame* GetScrollbarBox(bool aVertical) override {
1492
0
    return mHelper.GetScrollbarBox(aVertical);
1493
0
  }
1494
1495
  virtual void ScrollbarActivityStarted() const override;
1496
  virtual void ScrollbarActivityStopped() const override;
1497
1498
0
  virtual bool IsScrollbarOnRight() const override {
1499
0
    return mHelper.IsScrollbarOnRight();
1500
0
  }
1501
1502
0
  virtual bool ShouldSuppressScrollbarRepaints() const override {
1503
0
    return mHelper.ShouldSuppressScrollbarRepaints();
1504
0
  }
1505
1506
0
  virtual void SetTransformingByAPZ(bool aTransforming) override {
1507
0
    mHelper.SetTransformingByAPZ(aTransforming);
1508
0
  }
1509
0
  virtual bool UsesContainerScrolling() const override {
1510
0
    return mHelper.UsesContainerScrolling();
1511
0
  }
1512
0
  bool IsTransformingByAPZ() const override {
1513
0
    return mHelper.IsTransformingByAPZ();
1514
0
  }
1515
0
  void SetScrollableByAPZ(bool aScrollable) override {
1516
0
    mHelper.SetScrollableByAPZ(aScrollable);
1517
0
  }
1518
0
  void SetZoomableByAPZ(bool aZoomable) override {
1519
0
    mHelper.SetZoomableByAPZ(aZoomable);
1520
0
  }
1521
0
  void SetHasOutOfFlowContentInsideFilter() override {
1522
0
    mHelper.SetHasOutOfFlowContentInsideFilter();
1523
0
  }
1524
  virtual bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
1525
                                     nsRect* aVisibleRect,
1526
                                     nsRect* aDirtyRect,
1527
0
                                     bool aSetBase) override {
1528
0
    return mHelper.DecideScrollableLayer(aBuilder, aVisibleRect, aDirtyRect, aSetBase);
1529
0
  }
1530
0
  virtual void NotifyApproximateFrameVisibilityUpdate(bool aIgnoreDisplayPort) override {
1531
0
    mHelper.NotifyApproximateFrameVisibilityUpdate(aIgnoreDisplayPort);
1532
0
  }
1533
0
  virtual bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(nsRect* aDisplayPort) override {
1534
0
    return mHelper.GetDisplayPortAtLastApproximateFrameVisibilityUpdate(aDisplayPort);
1535
0
  }
1536
0
  void TriggerDisplayPortExpiration() override {
1537
0
    mHelper.TriggerDisplayPortExpiration();
1538
0
  }
1539
1540
0
  ScrollSnapInfo GetScrollSnapInfo() const override {
1541
0
    return mHelper.GetScrollSnapInfo();
1542
0
  }
1543
1544
0
  virtual bool DragScroll(mozilla::WidgetEvent* aEvent) override {
1545
0
    return mHelper.DragScroll(aEvent);
1546
0
  }
1547
1548
0
  virtual void AsyncScrollbarDragRejected() override {
1549
0
    return mHelper.AsyncScrollbarDragRejected();
1550
0
  }
1551
1552
0
  virtual bool IsRootScrollFrameOfDocument() const override {
1553
0
    return mHelper.IsRootScrollFrameOfDocument();
1554
0
  }
1555
1556
  // Return the scrolled frame.
1557
0
  void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override {
1558
0
    aResult.AppendElement(OwnedAnonBox(mHelper.GetScrolledFrame()));
1559
0
  }
1560
1561
#ifdef DEBUG_FRAME_DUMP
1562
  virtual nsresult GetFrameName(nsAString& aResult) const override;
1563
#endif
1564
1565
protected:
1566
  nsXULScrollFrame(ComputedStyle* aStyle, bool aIsRoot,
1567
                   bool aClipAllDescendants);
1568
1569
  void ClampAndSetBounds(nsBoxLayoutState& aState,
1570
                         nsRect& aRect,
1571
                         nsPoint aScrollPosition,
1572
0
                         bool aRemoveOverflowAreas = false) {
1573
0
    /*
1574
0
     * For RTL frames, restore the original scrolled position of the right
1575
0
     * edge, then subtract the current width to find the physical position.
1576
0
     */
1577
0
    if (!mHelper.IsPhysicalLTR()) {
1578
0
      aRect.x = mHelper.mScrollPort.XMost() - aScrollPosition.x - aRect.width;
1579
0
    }
1580
0
    mHelper.mScrolledFrame->SetXULBounds(aState, aRect, aRemoveOverflowAreas);
1581
0
  }
1582
1583
private:
1584
  friend class mozilla::ScrollFrameHelper;
1585
  ScrollFrameHelper mHelper;
1586
};
1587
1588
#endif /* nsGfxScrollFrame_h___ */