Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: set ts=2 sw=2 et tw=78: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 6 | * |
michael@0 | 7 | * This Original Code has been modified by IBM Corporation. |
michael@0 | 8 | * Modifications made by IBM described herein are |
michael@0 | 9 | * Copyright (c) International Business Machines |
michael@0 | 10 | * Corporation, 2000 |
michael@0 | 11 | * |
michael@0 | 12 | * Modifications to Mozilla code or documentation |
michael@0 | 13 | * identified per MPL Section 3.3 |
michael@0 | 14 | * |
michael@0 | 15 | * Date Modified by Description of modification |
michael@0 | 16 | * 05/03/2000 IBM Corp. Observer events for reflow states |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | /* a presentation of a document, part 2 */ |
michael@0 | 20 | |
michael@0 | 21 | #ifndef nsPresShell_h_ |
michael@0 | 22 | #define nsPresShell_h_ |
michael@0 | 23 | |
michael@0 | 24 | #include "nsIPresShell.h" |
michael@0 | 25 | #include "nsStubDocumentObserver.h" |
michael@0 | 26 | #include "nsISelectionController.h" |
michael@0 | 27 | #include "nsIObserver.h" |
michael@0 | 28 | #include "nsWeakReference.h" |
michael@0 | 29 | #include "nsCRT.h" |
michael@0 | 30 | #include "nsAutoPtr.h" |
michael@0 | 31 | #include "nsIWidget.h" |
michael@0 | 32 | #include "nsStyleSet.h" |
michael@0 | 33 | #include "nsFrameSelection.h" |
michael@0 | 34 | #include "nsContentUtils.h" // For AddScriptBlocker(). |
michael@0 | 35 | #include "nsRefreshDriver.h" |
michael@0 | 36 | #include "mozilla/Attributes.h" |
michael@0 | 37 | #include "mozilla/EventForwards.h" |
michael@0 | 38 | #include "mozilla/MemoryReporting.h" |
michael@0 | 39 | |
michael@0 | 40 | class nsRange; |
michael@0 | 41 | class nsIDragService; |
michael@0 | 42 | class nsCSSStyleSheet; |
michael@0 | 43 | |
michael@0 | 44 | struct RangePaintInfo; |
michael@0 | 45 | struct nsCallbackEventRequest; |
michael@0 | 46 | #ifdef MOZ_REFLOW_PERF |
michael@0 | 47 | class ReflowCountMgr; |
michael@0 | 48 | #endif |
michael@0 | 49 | |
michael@0 | 50 | class nsPresShellEventCB; |
michael@0 | 51 | class nsAutoCauseReflowNotifier; |
michael@0 | 52 | |
michael@0 | 53 | // 250ms. This is actually pref-controlled, but we use this value if we fail |
michael@0 | 54 | // to get the pref for any reason. |
michael@0 | 55 | #define PAINTLOCK_EVENT_DELAY 250 |
michael@0 | 56 | |
michael@0 | 57 | class PresShell : public nsIPresShell, |
michael@0 | 58 | public nsStubDocumentObserver, |
michael@0 | 59 | public nsISelectionController, public nsIObserver, |
michael@0 | 60 | public nsSupportsWeakReference |
michael@0 | 61 | { |
michael@0 | 62 | public: |
michael@0 | 63 | PresShell(); |
michael@0 | 64 | |
michael@0 | 65 | NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW |
michael@0 | 66 | |
michael@0 | 67 | // nsISupports |
michael@0 | 68 | NS_DECL_ISUPPORTS |
michael@0 | 69 | |
michael@0 | 70 | void Init(nsIDocument* aDocument, nsPresContext* aPresContext, |
michael@0 | 71 | nsViewManager* aViewManager, nsStyleSet* aStyleSet, |
michael@0 | 72 | nsCompatibility aCompatMode); |
michael@0 | 73 | virtual NS_HIDDEN_(void) Destroy() MOZ_OVERRIDE; |
michael@0 | 74 | virtual NS_HIDDEN_(void) MakeZombie() MOZ_OVERRIDE; |
michael@0 | 75 | |
michael@0 | 76 | virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(bool aForceReflow) MOZ_OVERRIDE; |
michael@0 | 77 | |
michael@0 | 78 | NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection); |
michael@0 | 79 | virtual mozilla::dom::Selection* GetCurrentSelection(SelectionType aType) MOZ_OVERRIDE; |
michael@0 | 80 | |
michael@0 | 81 | NS_IMETHOD SetDisplaySelection(int16_t aToggle) MOZ_OVERRIDE; |
michael@0 | 82 | NS_IMETHOD GetDisplaySelection(int16_t *aToggle) MOZ_OVERRIDE; |
michael@0 | 83 | NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion, |
michael@0 | 84 | int16_t aFlags) MOZ_OVERRIDE; |
michael@0 | 85 | NS_IMETHOD RepaintSelection(SelectionType aType) MOZ_OVERRIDE; |
michael@0 | 86 | |
michael@0 | 87 | virtual NS_HIDDEN_(void) BeginObservingDocument() MOZ_OVERRIDE; |
michael@0 | 88 | virtual NS_HIDDEN_(void) EndObservingDocument() MOZ_OVERRIDE; |
michael@0 | 89 | virtual NS_HIDDEN_(nsresult) Initialize(nscoord aWidth, nscoord aHeight) MOZ_OVERRIDE; |
michael@0 | 90 | virtual NS_HIDDEN_(nsresult) ResizeReflow(nscoord aWidth, nscoord aHeight) MOZ_OVERRIDE; |
michael@0 | 91 | virtual NS_HIDDEN_(nsresult) ResizeReflowOverride(nscoord aWidth, nscoord aHeight) MOZ_OVERRIDE; |
michael@0 | 92 | virtual NS_HIDDEN_(nsIPageSequenceFrame*) GetPageSequenceFrame() const MOZ_OVERRIDE; |
michael@0 | 93 | virtual NS_HIDDEN_(nsIFrame*) GetRealPrimaryFrameFor(nsIContent* aContent) const MOZ_OVERRIDE; |
michael@0 | 94 | |
michael@0 | 95 | virtual NS_HIDDEN_(nsIFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame) const MOZ_OVERRIDE; |
michael@0 | 96 | virtual NS_HIDDEN_(void) FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty, |
michael@0 | 97 | nsFrameState aBitToAdd) MOZ_OVERRIDE; |
michael@0 | 98 | virtual NS_HIDDEN_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame) MOZ_OVERRIDE; |
michael@0 | 99 | virtual NS_HIDDEN_(void) CancelAllPendingReflows() MOZ_OVERRIDE; |
michael@0 | 100 | virtual NS_HIDDEN_(bool) IsSafeToFlush() const MOZ_OVERRIDE; |
michael@0 | 101 | virtual NS_HIDDEN_(void) FlushPendingNotifications(mozFlushType aType) MOZ_OVERRIDE; |
michael@0 | 102 | virtual NS_HIDDEN_(void) FlushPendingNotifications(mozilla::ChangesToFlush aType) MOZ_OVERRIDE; |
michael@0 | 103 | |
michael@0 | 104 | /** |
michael@0 | 105 | * Recreates the frames for a node |
michael@0 | 106 | */ |
michael@0 | 107 | virtual NS_HIDDEN_(nsresult) RecreateFramesFor(nsIContent* aContent) MOZ_OVERRIDE; |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | * Post a callback that should be handled after reflow has finished. |
michael@0 | 111 | */ |
michael@0 | 112 | virtual NS_HIDDEN_(nsresult) PostReflowCallback(nsIReflowCallback* aCallback) MOZ_OVERRIDE; |
michael@0 | 113 | virtual NS_HIDDEN_(void) CancelReflowCallback(nsIReflowCallback* aCallback) MOZ_OVERRIDE; |
michael@0 | 114 | |
michael@0 | 115 | virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame) MOZ_OVERRIDE; |
michael@0 | 116 | virtual NS_HIDDEN_(already_AddRefed<nsRenderingContext>) CreateReferenceRenderingContext(); |
michael@0 | 117 | virtual NS_HIDDEN_(nsresult) GoToAnchor(const nsAString& aAnchorName, bool aScroll) MOZ_OVERRIDE; |
michael@0 | 118 | virtual NS_HIDDEN_(nsresult) ScrollToAnchor() MOZ_OVERRIDE; |
michael@0 | 119 | |
michael@0 | 120 | virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent, |
michael@0 | 121 | ScrollAxis aVertical, |
michael@0 | 122 | ScrollAxis aHorizontal, |
michael@0 | 123 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 124 | virtual bool ScrollFrameRectIntoView(nsIFrame* aFrame, |
michael@0 | 125 | const nsRect& aRect, |
michael@0 | 126 | ScrollAxis aVertical, |
michael@0 | 127 | ScrollAxis aHorizontal, |
michael@0 | 128 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 129 | virtual nsRectVisibility GetRectVisibility(nsIFrame *aFrame, |
michael@0 | 130 | const nsRect &aRect, |
michael@0 | 131 | nscoord aMinTwips) const MOZ_OVERRIDE; |
michael@0 | 132 | |
michael@0 | 133 | virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(bool aIgnore) MOZ_OVERRIDE; |
michael@0 | 134 | virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame) MOZ_OVERRIDE; |
michael@0 | 135 | |
michael@0 | 136 | virtual NS_HIDDEN_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState) MOZ_OVERRIDE; |
michael@0 | 137 | |
michael@0 | 138 | virtual NS_HIDDEN_(void) UnsuppressPainting() MOZ_OVERRIDE; |
michael@0 | 139 | |
michael@0 | 140 | virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) MOZ_OVERRIDE; |
michael@0 | 141 | virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) MOZ_OVERRIDE; |
michael@0 | 142 | |
michael@0 | 143 | virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) MOZ_OVERRIDE; |
michael@0 | 144 | virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) MOZ_OVERRIDE; |
michael@0 | 145 | |
michael@0 | 146 | virtual NS_HIDDEN_(nsresult) HandleEventWithTarget( |
michael@0 | 147 | mozilla::WidgetEvent* aEvent, |
michael@0 | 148 | nsIFrame* aFrame, |
michael@0 | 149 | nsIContent* aContent, |
michael@0 | 150 | nsEventStatus* aStatus) MOZ_OVERRIDE; |
michael@0 | 151 | virtual NS_HIDDEN_(nsIFrame*) GetEventTargetFrame() MOZ_OVERRIDE; |
michael@0 | 152 | virtual NS_HIDDEN_(already_AddRefed<nsIContent>) GetEventTargetContent( |
michael@0 | 153 | mozilla::WidgetEvent* aEvent) MOZ_OVERRIDE; |
michael@0 | 154 | |
michael@0 | 155 | |
michael@0 | 156 | virtual nsresult ReconstructFrames(void) MOZ_OVERRIDE; |
michael@0 | 157 | virtual void Freeze() MOZ_OVERRIDE; |
michael@0 | 158 | virtual void Thaw() MOZ_OVERRIDE; |
michael@0 | 159 | virtual void FireOrClearDelayedEvents(bool aFireEvents) MOZ_OVERRIDE; |
michael@0 | 160 | |
michael@0 | 161 | virtual NS_HIDDEN_(nsresult) RenderDocument(const nsRect& aRect, uint32_t aFlags, |
michael@0 | 162 | nscolor aBackgroundColor, |
michael@0 | 163 | gfxContext* aThebesContext) MOZ_OVERRIDE; |
michael@0 | 164 | |
michael@0 | 165 | virtual mozilla::TemporaryRef<SourceSurface> |
michael@0 | 166 | RenderNode(nsIDOMNode* aNode, |
michael@0 | 167 | nsIntRegion* aRegion, |
michael@0 | 168 | nsIntPoint& aPoint, |
michael@0 | 169 | nsIntRect* aScreenRect) MOZ_OVERRIDE; |
michael@0 | 170 | |
michael@0 | 171 | virtual mozilla::TemporaryRef<SourceSurface> |
michael@0 | 172 | RenderSelection(nsISelection* aSelection, |
michael@0 | 173 | nsIntPoint& aPoint, |
michael@0 | 174 | nsIntRect* aScreenRect) MOZ_OVERRIDE; |
michael@0 | 175 | |
michael@0 | 176 | virtual already_AddRefed<nsPIDOMWindow> GetRootWindow() MOZ_OVERRIDE; |
michael@0 | 177 | |
michael@0 | 178 | virtual LayerManager* GetLayerManager() MOZ_OVERRIDE; |
michael@0 | 179 | |
michael@0 | 180 | virtual void SetIgnoreViewportScrolling(bool aIgnore) MOZ_OVERRIDE; |
michael@0 | 181 | |
michael@0 | 182 | virtual nsresult SetResolution(float aXResolution, float aYResolution) MOZ_OVERRIDE; |
michael@0 | 183 | virtual gfxSize GetCumulativeResolution() MOZ_OVERRIDE; |
michael@0 | 184 | |
michael@0 | 185 | //nsIViewObserver interface |
michael@0 | 186 | |
michael@0 | 187 | virtual void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, |
michael@0 | 188 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 189 | virtual nsresult HandleEvent(nsIFrame* aFrame, |
michael@0 | 190 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 191 | bool aDontRetargetEvents, |
michael@0 | 192 | nsEventStatus* aEventStatus) MOZ_OVERRIDE; |
michael@0 | 193 | virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget( |
michael@0 | 194 | nsIContent* aTargetContent, |
michael@0 | 195 | mozilla::WidgetEvent* aEvent, |
michael@0 | 196 | nsEventStatus* aStatus) MOZ_OVERRIDE; |
michael@0 | 197 | virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent, |
michael@0 | 198 | nsIDOMEvent* aEvent, |
michael@0 | 199 | nsEventStatus* aStatus) MOZ_OVERRIDE; |
michael@0 | 200 | virtual bool ShouldIgnoreInvalidation() MOZ_OVERRIDE; |
michael@0 | 201 | virtual void WillPaint() MOZ_OVERRIDE; |
michael@0 | 202 | virtual void WillPaintWindow() MOZ_OVERRIDE; |
michael@0 | 203 | virtual void DidPaintWindow() MOZ_OVERRIDE; |
michael@0 | 204 | virtual void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) MOZ_OVERRIDE; |
michael@0 | 205 | virtual void DispatchSynthMouseMove(mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 206 | bool aFlushOnHoverChange) MOZ_OVERRIDE; |
michael@0 | 207 | virtual void ClearMouseCaptureOnView(nsView* aView) MOZ_OVERRIDE; |
michael@0 | 208 | virtual bool IsVisible() MOZ_OVERRIDE; |
michael@0 | 209 | |
michael@0 | 210 | // caret handling |
michael@0 | 211 | virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret() const MOZ_OVERRIDE; |
michael@0 | 212 | virtual NS_HIDDEN_(void) MaybeInvalidateCaretPosition() MOZ_OVERRIDE; |
michael@0 | 213 | NS_IMETHOD SetCaretEnabled(bool aInEnable) MOZ_OVERRIDE; |
michael@0 | 214 | NS_IMETHOD SetCaretReadOnly(bool aReadOnly) MOZ_OVERRIDE; |
michael@0 | 215 | NS_IMETHOD GetCaretEnabled(bool *aOutEnabled) MOZ_OVERRIDE; |
michael@0 | 216 | NS_IMETHOD SetCaretVisibilityDuringSelection(bool aVisibility) MOZ_OVERRIDE; |
michael@0 | 217 | NS_IMETHOD GetCaretVisible(bool *_retval) MOZ_OVERRIDE; |
michael@0 | 218 | virtual void SetCaret(nsCaret *aNewCaret) MOZ_OVERRIDE; |
michael@0 | 219 | virtual void RestoreCaret() MOZ_OVERRIDE; |
michael@0 | 220 | |
michael@0 | 221 | NS_IMETHOD SetSelectionFlags(int16_t aInEnable) MOZ_OVERRIDE; |
michael@0 | 222 | NS_IMETHOD GetSelectionFlags(int16_t *aOutEnable) MOZ_OVERRIDE; |
michael@0 | 223 | |
michael@0 | 224 | // nsISelectionController |
michael@0 | 225 | |
michael@0 | 226 | NS_IMETHOD CharacterMove(bool aForward, bool aExtend) MOZ_OVERRIDE; |
michael@0 | 227 | NS_IMETHOD CharacterExtendForDelete() MOZ_OVERRIDE; |
michael@0 | 228 | NS_IMETHOD CharacterExtendForBackspace() MOZ_OVERRIDE; |
michael@0 | 229 | NS_IMETHOD WordMove(bool aForward, bool aExtend) MOZ_OVERRIDE; |
michael@0 | 230 | NS_IMETHOD WordExtendForDelete(bool aForward) MOZ_OVERRIDE; |
michael@0 | 231 | NS_IMETHOD LineMove(bool aForward, bool aExtend) MOZ_OVERRIDE; |
michael@0 | 232 | NS_IMETHOD IntraLineMove(bool aForward, bool aExtend) MOZ_OVERRIDE; |
michael@0 | 233 | NS_IMETHOD PageMove(bool aForward, bool aExtend) MOZ_OVERRIDE; |
michael@0 | 234 | NS_IMETHOD ScrollPage(bool aForward) MOZ_OVERRIDE; |
michael@0 | 235 | NS_IMETHOD ScrollLine(bool aForward) MOZ_OVERRIDE; |
michael@0 | 236 | NS_IMETHOD ScrollCharacter(bool aRight) MOZ_OVERRIDE; |
michael@0 | 237 | NS_IMETHOD CompleteScroll(bool aForward) MOZ_OVERRIDE; |
michael@0 | 238 | NS_IMETHOD CompleteMove(bool aForward, bool aExtend) MOZ_OVERRIDE; |
michael@0 | 239 | NS_IMETHOD SelectAll() MOZ_OVERRIDE; |
michael@0 | 240 | NS_IMETHOD CheckVisibility(nsIDOMNode *node, int16_t startOffset, int16_t EndOffset, bool *_retval) MOZ_OVERRIDE; |
michael@0 | 241 | virtual nsresult CheckVisibilityContent(nsIContent* aNode, int16_t aStartOffset, |
michael@0 | 242 | int16_t aEndOffset, bool* aRetval) MOZ_OVERRIDE; |
michael@0 | 243 | |
michael@0 | 244 | // nsIDocumentObserver |
michael@0 | 245 | NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE |
michael@0 | 246 | NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE |
michael@0 | 247 | NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD |
michael@0 | 248 | NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD |
michael@0 | 249 | NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED |
michael@0 | 250 | NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED |
michael@0 | 251 | NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED |
michael@0 | 252 | NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED |
michael@0 | 253 | NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED |
michael@0 | 254 | NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED |
michael@0 | 255 | NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED |
michael@0 | 256 | NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED |
michael@0 | 257 | |
michael@0 | 258 | // nsIMutationObserver |
michael@0 | 259 | NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATAWILLCHANGE |
michael@0 | 260 | NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED |
michael@0 | 261 | NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE |
michael@0 | 262 | NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED |
michael@0 | 263 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED |
michael@0 | 264 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED |
michael@0 | 265 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED |
michael@0 | 266 | |
michael@0 | 267 | NS_DECL_NSIOBSERVER |
michael@0 | 268 | |
michael@0 | 269 | #ifdef MOZ_REFLOW_PERF |
michael@0 | 270 | virtual NS_HIDDEN_(void) DumpReflows() MOZ_OVERRIDE; |
michael@0 | 271 | virtual NS_HIDDEN_(void) CountReflows(const char * aName, nsIFrame * aFrame) MOZ_OVERRIDE; |
michael@0 | 272 | virtual NS_HIDDEN_(void) PaintCount(const char * aName, |
michael@0 | 273 | nsRenderingContext* aRenderingContext, |
michael@0 | 274 | nsPresContext* aPresContext, |
michael@0 | 275 | nsIFrame * aFrame, |
michael@0 | 276 | const nsPoint& aOffset, |
michael@0 | 277 | uint32_t aColor) MOZ_OVERRIDE; |
michael@0 | 278 | virtual NS_HIDDEN_(void) SetPaintFrameCount(bool aOn) MOZ_OVERRIDE; |
michael@0 | 279 | virtual bool IsPaintingFrameCounts() MOZ_OVERRIDE; |
michael@0 | 280 | #endif |
michael@0 | 281 | |
michael@0 | 282 | #ifdef DEBUG |
michael@0 | 283 | virtual void ListStyleContexts(nsIFrame *aRootFrame, FILE *out, |
michael@0 | 284 | int32_t aIndent = 0) MOZ_OVERRIDE; |
michael@0 | 285 | |
michael@0 | 286 | virtual void ListStyleSheets(FILE *out, int32_t aIndent = 0) MOZ_OVERRIDE; |
michael@0 | 287 | virtual void VerifyStyleTree() MOZ_OVERRIDE; |
michael@0 | 288 | #endif |
michael@0 | 289 | |
michael@0 | 290 | #ifdef PR_LOGGING |
michael@0 | 291 | static PRLogModuleInfo* gLog; |
michael@0 | 292 | #endif |
michael@0 | 293 | |
michael@0 | 294 | virtual NS_HIDDEN_(void) DisableNonTestMouseEvents(bool aDisable) MOZ_OVERRIDE; |
michael@0 | 295 | |
michael@0 | 296 | virtual void UpdateCanvasBackground() MOZ_OVERRIDE; |
michael@0 | 297 | |
michael@0 | 298 | virtual void AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder, |
michael@0 | 299 | nsDisplayList& aList, |
michael@0 | 300 | nsIFrame* aFrame, |
michael@0 | 301 | const nsRect& aBounds, |
michael@0 | 302 | nscolor aBackstopColor, |
michael@0 | 303 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 304 | |
michael@0 | 305 | virtual void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder, |
michael@0 | 306 | nsDisplayList& aList, |
michael@0 | 307 | nsIFrame* aFrame, |
michael@0 | 308 | const nsRect& aBounds) MOZ_OVERRIDE; |
michael@0 | 309 | |
michael@0 | 310 | virtual nscolor ComputeBackstopColor(nsView* aDisplayRoot) MOZ_OVERRIDE; |
michael@0 | 311 | |
michael@0 | 312 | virtual NS_HIDDEN_(nsresult) SetIsActive(bool aIsActive) MOZ_OVERRIDE; |
michael@0 | 313 | |
michael@0 | 314 | virtual bool GetIsViewportOverridden() MOZ_OVERRIDE { return mViewportOverridden; } |
michael@0 | 315 | |
michael@0 | 316 | virtual bool IsLayoutFlushObserver() MOZ_OVERRIDE |
michael@0 | 317 | { |
michael@0 | 318 | return GetPresContext()->RefreshDriver()-> |
michael@0 | 319 | IsLayoutFlushObserver(this); |
michael@0 | 320 | } |
michael@0 | 321 | |
michael@0 | 322 | virtual void LoadComplete() MOZ_OVERRIDE; |
michael@0 | 323 | |
michael@0 | 324 | void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, |
michael@0 | 325 | nsArenaMemoryStats *aArenaObjectsSize, |
michael@0 | 326 | size_t *aPresShellSize, |
michael@0 | 327 | size_t *aStyleSetsSize, |
michael@0 | 328 | size_t *aTextRunsSize, |
michael@0 | 329 | size_t *aPresContextSize) MOZ_OVERRIDE; |
michael@0 | 330 | size_t SizeOfTextRuns(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 331 | |
michael@0 | 332 | virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver) MOZ_OVERRIDE; |
michael@0 | 333 | |
michael@0 | 334 | // This data is stored as a content property (nsGkAtoms::scrolling) on |
michael@0 | 335 | // mContentToScrollTo when we have a pending ScrollIntoView. |
michael@0 | 336 | struct ScrollIntoViewData { |
michael@0 | 337 | ScrollAxis mContentScrollVAxis; |
michael@0 | 338 | ScrollAxis mContentScrollHAxis; |
michael@0 | 339 | uint32_t mContentToScrollToFlags; |
michael@0 | 340 | }; |
michael@0 | 341 | |
michael@0 | 342 | virtual void ScheduleImageVisibilityUpdate() MOZ_OVERRIDE; |
michael@0 | 343 | |
michael@0 | 344 | virtual void RebuildImageVisibility(const nsDisplayList& aList) MOZ_OVERRIDE; |
michael@0 | 345 | |
michael@0 | 346 | virtual void EnsureImageInVisibleList(nsIImageLoadingContent* aImage) MOZ_OVERRIDE; |
michael@0 | 347 | |
michael@0 | 348 | virtual void RemoveImageFromVisibleList(nsIImageLoadingContent* aImage) MOZ_OVERRIDE; |
michael@0 | 349 | |
michael@0 | 350 | virtual bool AssumeAllImagesVisible() MOZ_OVERRIDE; |
michael@0 | 351 | |
michael@0 | 352 | virtual void RestyleShadowRoot(mozilla::dom::ShadowRoot* aShadowRoot); |
michael@0 | 353 | |
michael@0 | 354 | void SetNextPaintCompressed() { mNextPaintCompressed = true; } |
michael@0 | 355 | |
michael@0 | 356 | protected: |
michael@0 | 357 | virtual ~PresShell(); |
michael@0 | 358 | |
michael@0 | 359 | void HandlePostedReflowCallbacks(bool aInterruptible); |
michael@0 | 360 | void CancelPostedReflowCallbacks(); |
michael@0 | 361 | |
michael@0 | 362 | void UnsuppressAndInvalidate(); |
michael@0 | 363 | |
michael@0 | 364 | void WillCauseReflow() { |
michael@0 | 365 | nsContentUtils::AddScriptBlocker(); |
michael@0 | 366 | ++mChangeNestCount; |
michael@0 | 367 | } |
michael@0 | 368 | nsresult DidCauseReflow(); |
michael@0 | 369 | friend class nsAutoCauseReflowNotifier; |
michael@0 | 370 | |
michael@0 | 371 | void DispatchTouchEvent(mozilla::WidgetEvent* aEvent, |
michael@0 | 372 | nsEventStatus* aStatus, |
michael@0 | 373 | nsPresShellEventCB* aEventCB, |
michael@0 | 374 | bool aTouchIsNew); |
michael@0 | 375 | |
michael@0 | 376 | void WillDoReflow(); |
michael@0 | 377 | |
michael@0 | 378 | /** |
michael@0 | 379 | * Callback handler for whether reflow happened. |
michael@0 | 380 | * |
michael@0 | 381 | * @param aInterruptible Whether or not reflow interruption is allowed. |
michael@0 | 382 | * @param aWasInterrupted Whether or not the reflow was interrupted earlier. |
michael@0 | 383 | * |
michael@0 | 384 | */ |
michael@0 | 385 | void DidDoReflow(bool aInterruptible, bool aWasInterrupted); |
michael@0 | 386 | // ProcessReflowCommands returns whether we processed all our dirty roots |
michael@0 | 387 | // without interruptions. |
michael@0 | 388 | bool ProcessReflowCommands(bool aInterruptible); |
michael@0 | 389 | // MaybeScheduleReflow checks if posting a reflow is needed, then checks if |
michael@0 | 390 | // the last reflow was interrupted. In the interrupted case ScheduleReflow is |
michael@0 | 391 | // called off a timer, otherwise it is called directly. |
michael@0 | 392 | void MaybeScheduleReflow(); |
michael@0 | 393 | // Actually schedules a reflow. This should only be called by |
michael@0 | 394 | // MaybeScheduleReflow and the reflow timer ScheduleReflowOffTimer |
michael@0 | 395 | // sets up. |
michael@0 | 396 | void ScheduleReflow(); |
michael@0 | 397 | |
michael@0 | 398 | // Reflow regardless of whether the override bit has been set. |
michael@0 | 399 | nsresult ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight); |
michael@0 | 400 | |
michael@0 | 401 | // DoReflow returns whether the reflow finished without interruption |
michael@0 | 402 | bool DoReflow(nsIFrame* aFrame, bool aInterruptible); |
michael@0 | 403 | #ifdef DEBUG |
michael@0 | 404 | void DoVerifyReflow(); |
michael@0 | 405 | void VerifyHasDirtyRootAncestor(nsIFrame* aFrame); |
michael@0 | 406 | #endif |
michael@0 | 407 | |
michael@0 | 408 | // Helper for ScrollContentIntoView |
michael@0 | 409 | void DoScrollContentIntoView(); |
michael@0 | 410 | |
michael@0 | 411 | /** |
michael@0 | 412 | * Initialize cached font inflation preference values and do an initial |
michael@0 | 413 | * computation to determine if font inflation is enabled. |
michael@0 | 414 | * |
michael@0 | 415 | * @see nsLayoutUtils::sFontSizeInflationEmPerLine |
michael@0 | 416 | * @see nsLayoutUtils::sFontSizeInflationMinTwips |
michael@0 | 417 | * @see nsLayoutUtils::sFontSizeInflationLineThreshold |
michael@0 | 418 | */ |
michael@0 | 419 | void SetupFontInflation(); |
michael@0 | 420 | |
michael@0 | 421 | friend struct AutoRenderingStateSaveRestore; |
michael@0 | 422 | friend struct RenderingState; |
michael@0 | 423 | |
michael@0 | 424 | struct RenderingState { |
michael@0 | 425 | RenderingState(PresShell* aPresShell) |
michael@0 | 426 | : mXResolution(aPresShell->mXResolution) |
michael@0 | 427 | , mYResolution(aPresShell->mYResolution) |
michael@0 | 428 | , mRenderFlags(aPresShell->mRenderFlags) |
michael@0 | 429 | { } |
michael@0 | 430 | float mXResolution; |
michael@0 | 431 | float mYResolution; |
michael@0 | 432 | RenderFlags mRenderFlags; |
michael@0 | 433 | }; |
michael@0 | 434 | |
michael@0 | 435 | struct AutoSaveRestoreRenderingState { |
michael@0 | 436 | AutoSaveRestoreRenderingState(PresShell* aPresShell) |
michael@0 | 437 | : mPresShell(aPresShell) |
michael@0 | 438 | , mOldState(aPresShell) |
michael@0 | 439 | {} |
michael@0 | 440 | |
michael@0 | 441 | ~AutoSaveRestoreRenderingState() |
michael@0 | 442 | { |
michael@0 | 443 | mPresShell->mRenderFlags = mOldState.mRenderFlags; |
michael@0 | 444 | mPresShell->mXResolution = mOldState.mXResolution; |
michael@0 | 445 | mPresShell->mYResolution = mOldState.mYResolution; |
michael@0 | 446 | } |
michael@0 | 447 | |
michael@0 | 448 | PresShell* mPresShell; |
michael@0 | 449 | RenderingState mOldState; |
michael@0 | 450 | }; |
michael@0 | 451 | static RenderFlags ChangeFlag(RenderFlags aFlags, bool aOnOff, |
michael@0 | 452 | eRenderFlag aFlag) |
michael@0 | 453 | { |
michael@0 | 454 | return aOnOff ? (aFlags | aFlag) : (aFlag & ~aFlag); |
michael@0 | 455 | } |
michael@0 | 456 | |
michael@0 | 457 | |
michael@0 | 458 | void SetRenderingState(const RenderingState& aState); |
michael@0 | 459 | |
michael@0 | 460 | friend class nsPresShellEventCB; |
michael@0 | 461 | |
michael@0 | 462 | bool mCaretEnabled; |
michael@0 | 463 | #ifdef DEBUG |
michael@0 | 464 | nsStyleSet* CloneStyleSet(nsStyleSet* aSet); |
michael@0 | 465 | bool VerifyIncrementalReflow(); |
michael@0 | 466 | bool mInVerifyReflow; |
michael@0 | 467 | void ShowEventTargetDebug(); |
michael@0 | 468 | #endif |
michael@0 | 469 | |
michael@0 | 470 | void RecordStyleSheetChange(nsIStyleSheet* aStyleSheet); |
michael@0 | 471 | |
michael@0 | 472 | /** |
michael@0 | 473 | * methods that manage rules that are used to implement the associated preferences |
michael@0 | 474 | * - initially created for bugs 31816, 20760, 22963 |
michael@0 | 475 | */ |
michael@0 | 476 | nsresult ClearPreferenceStyleRules(void); |
michael@0 | 477 | nsresult CreatePreferenceStyleSheet(void); |
michael@0 | 478 | nsresult SetPrefLinkRules(void); |
michael@0 | 479 | nsresult SetPrefFocusRules(void); |
michael@0 | 480 | nsresult SetPrefNoScriptRule(); |
michael@0 | 481 | nsresult SetPrefNoFramesRule(void); |
michael@0 | 482 | |
michael@0 | 483 | // methods for painting a range to an offscreen buffer |
michael@0 | 484 | |
michael@0 | 485 | // given a display list, clip the items within the list to |
michael@0 | 486 | // the range |
michael@0 | 487 | nsRect ClipListToRange(nsDisplayListBuilder *aBuilder, |
michael@0 | 488 | nsDisplayList* aList, |
michael@0 | 489 | nsRange* aRange); |
michael@0 | 490 | |
michael@0 | 491 | // create a RangePaintInfo for the range aRange containing the |
michael@0 | 492 | // display list needed to paint the range to a surface |
michael@0 | 493 | RangePaintInfo* CreateRangePaintInfo(nsIDOMRange* aRange, |
michael@0 | 494 | nsRect& aSurfaceRect, |
michael@0 | 495 | bool aForPrimarySelection); |
michael@0 | 496 | |
michael@0 | 497 | /* |
michael@0 | 498 | * Paint the items to a new surface and return it. |
michael@0 | 499 | * |
michael@0 | 500 | * aSelection - selection being painted, if any |
michael@0 | 501 | * aRegion - clip region, if any |
michael@0 | 502 | * aArea - area that the surface occupies, relative to the root frame |
michael@0 | 503 | * aPoint - reference point, typically the mouse position |
michael@0 | 504 | * aScreenRect - [out] set to the area of the screen the painted area should |
michael@0 | 505 | * be displayed at |
michael@0 | 506 | */ |
michael@0 | 507 | mozilla::TemporaryRef<SourceSurface> |
michael@0 | 508 | PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems, |
michael@0 | 509 | nsISelection* aSelection, |
michael@0 | 510 | nsIntRegion* aRegion, |
michael@0 | 511 | nsRect aArea, |
michael@0 | 512 | nsIntPoint& aPoint, |
michael@0 | 513 | nsIntRect* aScreenRect); |
michael@0 | 514 | |
michael@0 | 515 | /** |
michael@0 | 516 | * Methods to handle changes to user and UA sheet lists that we get |
michael@0 | 517 | * notified about. |
michael@0 | 518 | */ |
michael@0 | 519 | void AddUserSheet(nsISupports* aSheet); |
michael@0 | 520 | void AddAgentSheet(nsISupports* aSheet); |
michael@0 | 521 | void AddAuthorSheet(nsISupports* aSheet); |
michael@0 | 522 | void RemoveSheet(nsStyleSet::sheetType aType, nsISupports* aSheet); |
michael@0 | 523 | |
michael@0 | 524 | // Hide a view if it is a popup |
michael@0 | 525 | void HideViewIfPopup(nsView* aView); |
michael@0 | 526 | |
michael@0 | 527 | // Utility method to restore the root scrollframe state |
michael@0 | 528 | void RestoreRootScrollPosition(); |
michael@0 | 529 | |
michael@0 | 530 | void MaybeReleaseCapturingContent() |
michael@0 | 531 | { |
michael@0 | 532 | nsRefPtr<nsFrameSelection> frameSelection = FrameSelection(); |
michael@0 | 533 | if (frameSelection) { |
michael@0 | 534 | frameSelection->SetMouseDownState(false); |
michael@0 | 535 | } |
michael@0 | 536 | if (gCaptureInfo.mContent && |
michael@0 | 537 | gCaptureInfo.mContent->OwnerDoc() == mDocument) { |
michael@0 | 538 | SetCapturingContent(nullptr, 0); |
michael@0 | 539 | } |
michael@0 | 540 | } |
michael@0 | 541 | |
michael@0 | 542 | nsresult HandleRetargetedEvent(mozilla::WidgetEvent* aEvent, |
michael@0 | 543 | nsEventStatus* aStatus, |
michael@0 | 544 | nsIContent* aTarget) |
michael@0 | 545 | { |
michael@0 | 546 | PushCurrentEventInfo(nullptr, nullptr); |
michael@0 | 547 | mCurrentEventContent = aTarget; |
michael@0 | 548 | nsresult rv = NS_OK; |
michael@0 | 549 | if (GetCurrentEventFrame()) { |
michael@0 | 550 | rv = HandleEventInternal(aEvent, aStatus); |
michael@0 | 551 | } |
michael@0 | 552 | PopCurrentEventInfo(); |
michael@0 | 553 | return rv; |
michael@0 | 554 | } |
michael@0 | 555 | |
michael@0 | 556 | class DelayedEvent |
michael@0 | 557 | { |
michael@0 | 558 | public: |
michael@0 | 559 | virtual ~DelayedEvent() { } |
michael@0 | 560 | virtual void Dispatch() { } |
michael@0 | 561 | }; |
michael@0 | 562 | |
michael@0 | 563 | class DelayedInputEvent : public DelayedEvent |
michael@0 | 564 | { |
michael@0 | 565 | public: |
michael@0 | 566 | virtual void Dispatch() MOZ_OVERRIDE; |
michael@0 | 567 | |
michael@0 | 568 | protected: |
michael@0 | 569 | DelayedInputEvent(); |
michael@0 | 570 | virtual ~DelayedInputEvent(); |
michael@0 | 571 | |
michael@0 | 572 | mozilla::WidgetInputEvent* mEvent; |
michael@0 | 573 | }; |
michael@0 | 574 | |
michael@0 | 575 | class DelayedMouseEvent : public DelayedInputEvent |
michael@0 | 576 | { |
michael@0 | 577 | public: |
michael@0 | 578 | DelayedMouseEvent(mozilla::WidgetMouseEvent* aEvent); |
michael@0 | 579 | }; |
michael@0 | 580 | |
michael@0 | 581 | class DelayedKeyEvent : public DelayedInputEvent |
michael@0 | 582 | { |
michael@0 | 583 | public: |
michael@0 | 584 | DelayedKeyEvent(mozilla::WidgetKeyboardEvent* aEvent); |
michael@0 | 585 | }; |
michael@0 | 586 | |
michael@0 | 587 | // Check if aEvent is a mouse event and record the mouse location for later |
michael@0 | 588 | // synth mouse moves. |
michael@0 | 589 | void RecordMouseLocation(mozilla::WidgetGUIEvent* aEvent); |
michael@0 | 590 | class nsSynthMouseMoveEvent MOZ_FINAL : public nsARefreshObserver { |
michael@0 | 591 | public: |
michael@0 | 592 | nsSynthMouseMoveEvent(PresShell* aPresShell, bool aFromScroll) |
michael@0 | 593 | : mPresShell(aPresShell), mFromScroll(aFromScroll) { |
michael@0 | 594 | NS_ASSERTION(mPresShell, "null parameter"); |
michael@0 | 595 | } |
michael@0 | 596 | |
michael@0 | 597 | private: |
michael@0 | 598 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 599 | ~nsSynthMouseMoveEvent() { |
michael@0 | 600 | Revoke(); |
michael@0 | 601 | } |
michael@0 | 602 | |
michael@0 | 603 | public: |
michael@0 | 604 | NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent) |
michael@0 | 605 | |
michael@0 | 606 | void Revoke() { |
michael@0 | 607 | if (mPresShell) { |
michael@0 | 608 | mPresShell->GetPresContext()->RefreshDriver()-> |
michael@0 | 609 | RemoveRefreshObserver(this, Flush_Display); |
michael@0 | 610 | mPresShell = nullptr; |
michael@0 | 611 | } |
michael@0 | 612 | } |
michael@0 | 613 | virtual void WillRefresh(mozilla::TimeStamp aTime) MOZ_OVERRIDE { |
michael@0 | 614 | if (mPresShell) { |
michael@0 | 615 | nsRefPtr<PresShell> shell = mPresShell; |
michael@0 | 616 | shell->ProcessSynthMouseMoveEvent(mFromScroll); |
michael@0 | 617 | } |
michael@0 | 618 | } |
michael@0 | 619 | private: |
michael@0 | 620 | PresShell* mPresShell; |
michael@0 | 621 | bool mFromScroll; |
michael@0 | 622 | }; |
michael@0 | 623 | void ProcessSynthMouseMoveEvent(bool aFromScroll); |
michael@0 | 624 | |
michael@0 | 625 | void QueryIsActive(); |
michael@0 | 626 | nsresult UpdateImageLockingState(); |
michael@0 | 627 | |
michael@0 | 628 | #ifdef ANDROID |
michael@0 | 629 | nsIDocument* GetTouchEventTargetDocument(); |
michael@0 | 630 | #endif |
michael@0 | 631 | bool InZombieDocument(nsIContent *aContent); |
michael@0 | 632 | already_AddRefed<nsIPresShell> GetParentPresShellForEventHandling(); |
michael@0 | 633 | nsIContent* GetCurrentEventContent(); |
michael@0 | 634 | nsIFrame* GetCurrentEventFrame(); |
michael@0 | 635 | nsresult RetargetEventToParent(mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 636 | nsEventStatus* aEventStatus); |
michael@0 | 637 | void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent); |
michael@0 | 638 | void PopCurrentEventInfo(); |
michael@0 | 639 | nsresult HandleEventInternal(mozilla::WidgetEvent* aEvent, |
michael@0 | 640 | nsEventStatus* aStatus); |
michael@0 | 641 | nsresult HandlePositionedEvent(nsIFrame* aTargetFrame, |
michael@0 | 642 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 643 | nsEventStatus* aEventStatus); |
michael@0 | 644 | // This returns the focused DOM window under our top level window. |
michael@0 | 645 | // I.e., when we are deactive, this returns the *last* focused DOM window. |
michael@0 | 646 | already_AddRefed<nsPIDOMWindow> GetFocusedDOMWindowInOurWindow(); |
michael@0 | 647 | |
michael@0 | 648 | /* |
michael@0 | 649 | * This and the next two helper methods are used to target and position the |
michael@0 | 650 | * context menu when the keyboard shortcut is used to open it. |
michael@0 | 651 | * |
michael@0 | 652 | * If another menu is open, the context menu is opened relative to the |
michael@0 | 653 | * active menuitem within the menu, or the menu itself if no item is active. |
michael@0 | 654 | * Otherwise, if the caret is visible, the menu is opened near the caret. |
michael@0 | 655 | * Otherwise, if a selectable list such as a listbox is focused, the |
michael@0 | 656 | * current item within the menu is opened relative to this item. |
michael@0 | 657 | * Otherwise, the context menu is opened at the topleft corner of the |
michael@0 | 658 | * view. |
michael@0 | 659 | * |
michael@0 | 660 | * Returns true if the context menu event should fire and false if it should |
michael@0 | 661 | * not. |
michael@0 | 662 | */ |
michael@0 | 663 | bool AdjustContextMenuKeyEvent(mozilla::WidgetMouseEvent* aEvent); |
michael@0 | 664 | |
michael@0 | 665 | // |
michael@0 | 666 | bool PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTargetPt); |
michael@0 | 667 | |
michael@0 | 668 | // Get the selected item and coordinates in device pixels relative to root |
michael@0 | 669 | // document's root view for element, first ensuring the element is onscreen |
michael@0 | 670 | void GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl, |
michael@0 | 671 | nsIContent **aTargetToUse, |
michael@0 | 672 | mozilla::LayoutDeviceIntPoint& aTargetPt, |
michael@0 | 673 | nsIWidget *aRootWidget); |
michael@0 | 674 | |
michael@0 | 675 | void FireResizeEvent(); |
michael@0 | 676 | static void AsyncResizeEventCallback(nsITimer* aTimer, void* aPresShell); |
michael@0 | 677 | |
michael@0 | 678 | virtual void SynthesizeMouseMove(bool aFromScroll) MOZ_OVERRIDE; |
michael@0 | 679 | |
michael@0 | 680 | PresShell* GetRootPresShell(); |
michael@0 | 681 | |
michael@0 | 682 | nscolor GetDefaultBackgroundColorToDraw(); |
michael@0 | 683 | |
michael@0 | 684 | DOMHighResTimeStamp GetPerformanceNow(); |
michael@0 | 685 | |
michael@0 | 686 | // The callback for the mPaintSuppressionTimer timer. |
michael@0 | 687 | static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell); |
michael@0 | 688 | |
michael@0 | 689 | // The callback for the mReflowContinueTimer timer. |
michael@0 | 690 | static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell); |
michael@0 | 691 | bool ScheduleReflowOffTimer(); |
michael@0 | 692 | |
michael@0 | 693 | // Widget notificiations |
michael@0 | 694 | virtual void WindowSizeMoveDone() MOZ_OVERRIDE; |
michael@0 | 695 | virtual void SysColorChanged() MOZ_OVERRIDE { mPresContext->SysColorChanged(); } |
michael@0 | 696 | virtual void ThemeChanged() MOZ_OVERRIDE { mPresContext->ThemeChanged(); } |
michael@0 | 697 | virtual void BackingScaleFactorChanged() MOZ_OVERRIDE { mPresContext->UIResolutionChanged(); } |
michael@0 | 698 | |
michael@0 | 699 | virtual void PausePainting() MOZ_OVERRIDE; |
michael@0 | 700 | virtual void ResumePainting() MOZ_OVERRIDE; |
michael@0 | 701 | |
michael@0 | 702 | void UpdateImageVisibility(); |
michael@0 | 703 | void UpdateActivePointerState(mozilla::WidgetGUIEvent* aEvent); |
michael@0 | 704 | |
michael@0 | 705 | nsRevocableEventPtr<nsRunnableMethod<PresShell> > mUpdateImageVisibilityEvent; |
michael@0 | 706 | |
michael@0 | 707 | void ClearVisibleImagesList(); |
michael@0 | 708 | static void ClearImageVisibilityVisited(nsView* aView, bool aClear); |
michael@0 | 709 | static void MarkImagesInListVisible(const nsDisplayList& aList); |
michael@0 | 710 | |
michael@0 | 711 | void EvictTouches(); |
michael@0 | 712 | |
michael@0 | 713 | // A list of images that are visible or almost visible. |
michael@0 | 714 | nsTHashtable< nsRefPtrHashKey<nsIImageLoadingContent> > mVisibleImages; |
michael@0 | 715 | |
michael@0 | 716 | #ifdef DEBUG |
michael@0 | 717 | // The reflow root under which we're currently reflowing. Null when |
michael@0 | 718 | // not in reflow. |
michael@0 | 719 | nsIFrame* mCurrentReflowRoot; |
michael@0 | 720 | uint32_t mUpdateCount; |
michael@0 | 721 | #endif |
michael@0 | 722 | |
michael@0 | 723 | #ifdef MOZ_REFLOW_PERF |
michael@0 | 724 | ReflowCountMgr* mReflowCountMgr; |
michael@0 | 725 | #endif |
michael@0 | 726 | |
michael@0 | 727 | // This is used for synthetic mouse events that are sent when what is under |
michael@0 | 728 | // the mouse pointer may have changed without the mouse moving (eg scrolling, |
michael@0 | 729 | // change to the document contents). |
michael@0 | 730 | // It is set only on a presshell for a root document, this value represents |
michael@0 | 731 | // the last observed location of the mouse relative to that root document. It |
michael@0 | 732 | // is set to (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if the mouse isn't |
michael@0 | 733 | // over our window or there is no last observed mouse location for some |
michael@0 | 734 | // reason. |
michael@0 | 735 | nsPoint mMouseLocation; |
michael@0 | 736 | |
michael@0 | 737 | // mStyleSet owns it but we maintain a ref, may be null |
michael@0 | 738 | nsRefPtr<nsCSSStyleSheet> mPrefStyleSheet; |
michael@0 | 739 | |
michael@0 | 740 | // Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after |
michael@0 | 741 | // we finish reflowing mCurrentReflowRoot. |
michael@0 | 742 | nsTHashtable<nsPtrHashKey<nsIFrame> > mFramesToDirty; |
michael@0 | 743 | |
michael@0 | 744 | // Reflow roots that need to be reflowed. |
michael@0 | 745 | nsTArray<nsIFrame*> mDirtyRoots; |
michael@0 | 746 | |
michael@0 | 747 | nsTArray<nsAutoPtr<DelayedEvent> > mDelayedEvents; |
michael@0 | 748 | nsRevocableEventPtr<nsRunnableMethod<PresShell> > mResizeEvent; |
michael@0 | 749 | nsCOMPtr<nsITimer> mAsyncResizeEventTimer; |
michael@0 | 750 | private: |
michael@0 | 751 | nsIFrame* mCurrentEventFrame; |
michael@0 | 752 | nsCOMPtr<nsIContent> mCurrentEventContent; |
michael@0 | 753 | nsTArray<nsIFrame*> mCurrentEventFrameStack; |
michael@0 | 754 | nsCOMArray<nsIContent> mCurrentEventContentStack; |
michael@0 | 755 | protected: |
michael@0 | 756 | nsRevocableEventPtr<nsSynthMouseMoveEvent> mSynthMouseMoveEvent; |
michael@0 | 757 | nsCOMPtr<nsIContent> mLastAnchorScrolledTo; |
michael@0 | 758 | nsRefPtr<nsCaret> mCaret; |
michael@0 | 759 | nsRefPtr<nsCaret> mOriginalCaret; |
michael@0 | 760 | nsCallbackEventRequest* mFirstCallbackEventRequest; |
michael@0 | 761 | nsCallbackEventRequest* mLastCallbackEventRequest; |
michael@0 | 762 | |
michael@0 | 763 | // This timer controls painting suppression. Until it fires |
michael@0 | 764 | // or all frames are constructed, we won't paint anything but |
michael@0 | 765 | // our <body> background and scrollbars. |
michael@0 | 766 | nsCOMPtr<nsITimer> mPaintSuppressionTimer; |
michael@0 | 767 | |
michael@0 | 768 | // At least on Win32 and Mac after interupting a reflow we need to post |
michael@0 | 769 | // the resume reflow event off a timer to avoid event starvation because |
michael@0 | 770 | // posted messages are processed before other messages when the modal |
michael@0 | 771 | // moving/sizing loop is running, see bug 491700 for details. |
michael@0 | 772 | nsCOMPtr<nsITimer> mReflowContinueTimer; |
michael@0 | 773 | |
michael@0 | 774 | nsCOMPtr<nsITimer> mDelayedPaintTimer; |
michael@0 | 775 | |
michael@0 | 776 | // The `performance.now()` value when we last started to process reflows. |
michael@0 | 777 | DOMHighResTimeStamp mLastReflowStart; |
michael@0 | 778 | |
michael@0 | 779 | mozilla::TimeStamp mLoadBegin; // used to time loads |
michael@0 | 780 | |
michael@0 | 781 | // Information needed to properly handle scrolling content into view if the |
michael@0 | 782 | // pre-scroll reflow flush can be interrupted. mContentToScrollTo is |
michael@0 | 783 | // non-null between the initial scroll attempt and the first time we finish |
michael@0 | 784 | // processing all our dirty roots. mContentToScrollTo has a content property |
michael@0 | 785 | // storing the details for the scroll operation, see ScrollIntoViewData above. |
michael@0 | 786 | nsCOMPtr<nsIContent> mContentToScrollTo; |
michael@0 | 787 | |
michael@0 | 788 | nscoord mLastAnchorScrollPositionY; |
michael@0 | 789 | |
michael@0 | 790 | // This is used to protect ourselves from triggering reflow while in the |
michael@0 | 791 | // middle of frame construction and the like... it really shouldn't be |
michael@0 | 792 | // needed, one hopes, but it is for now. |
michael@0 | 793 | uint16_t mChangeNestCount; |
michael@0 | 794 | |
michael@0 | 795 | bool mDocumentLoading : 1; |
michael@0 | 796 | bool mIgnoreFrameDestruction : 1; |
michael@0 | 797 | bool mHaveShutDown : 1; |
michael@0 | 798 | bool mViewportOverridden : 1; |
michael@0 | 799 | bool mLastRootReflowHadUnconstrainedHeight : 1; |
michael@0 | 800 | bool mNoDelayedMouseEvents : 1; |
michael@0 | 801 | bool mNoDelayedKeyEvents : 1; |
michael@0 | 802 | |
michael@0 | 803 | // We've been disconnected from the document. We will refuse to paint the |
michael@0 | 804 | // document until either our timer fires or all frames are constructed. |
michael@0 | 805 | bool mIsDocumentGone : 1; |
michael@0 | 806 | |
michael@0 | 807 | // Indicates that it is safe to unlock painting once all pending reflows |
michael@0 | 808 | // have been processed. |
michael@0 | 809 | bool mShouldUnsuppressPainting : 1; |
michael@0 | 810 | |
michael@0 | 811 | bool mAsyncResizeTimerIsActive : 1; |
michael@0 | 812 | bool mInResize : 1; |
michael@0 | 813 | |
michael@0 | 814 | bool mImageVisibilityVisited : 1; |
michael@0 | 815 | |
michael@0 | 816 | bool mNextPaintCompressed : 1; |
michael@0 | 817 | |
michael@0 | 818 | static bool sDisableNonTestMouseEvents; |
michael@0 | 819 | }; |
michael@0 | 820 | |
michael@0 | 821 | #endif /* !defined(nsPresShell_h_) */ |