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 /* a presentation of a document, part 2 */ 8 9 #ifndef nsIPresShell_h___ 10 #define nsIPresShell_h___ 11 12 #include "mozilla/ArenaObjectID.h" 13 #include "mozilla/EventForwards.h" 14 #include "mozilla/FlushType.h" 15 #include "mozilla/MemoryReporting.h" 16 #include "mozilla/StaticPtr.h" 17 #include "mozilla/StyleSetHandle.h" 18 #include "mozilla/StyleSheet.h" 19 #include "mozilla/WeakPtr.h" 20 #include "GeckoProfiler.h" 21 #include "gfxPoint.h" 22 #include "nsTHashtable.h" 23 #include "nsHashKeys.h" 24 #include "nsISupports.h" 25 #include "nsIContent.h" 26 #include "nsISelectionController.h" 27 #include "nsQueryFrame.h" 28 #include "nsStringFwd.h" 29 #include "nsCoord.h" 30 #include "nsColor.h" 31 #include "nsFrameManager.h" 32 #include "nsRect.h" 33 #include "nsRegionFwd.h" 34 #include "nsWeakReference.h" 35 #include <stdio.h> // for FILE definition 36 #include "nsChangeHint.h" 37 #include "nsRefPtrHashtable.h" 38 #include "nsClassHashtable.h" 39 #include "nsPresArena.h" 40 #include "nsIImageLoadingContent.h" 41 #include "nsMargin.h" 42 #include "nsFrameState.h" 43 #include "nsStubDocumentObserver.h" 44 #include "Units.h" 45 46 class gfxContext; 47 class nsDocShell; 48 class nsIDocument; 49 class nsIFrame; 50 class nsPresContext; 51 class nsWindowSizes; 52 class nsViewManager; 53 class nsView; 54 class nsIPageSequenceFrame; 55 class nsCanvasFrame; 56 class nsCaret; 57 namespace mozilla { 58 class AccessibleCaretEventHub; 59 class CSSStyleSheet; 60 } // namespace mozilla 61 class nsFrameSelection; 62 class nsFrameManager; 63 class nsILayoutHistoryState; 64 class nsIReflowCallback; 65 class nsIDOMNode; 66 class nsCSSFrameConstructor; 67 class nsISelection; 68 template <class E> 69 class nsCOMArray; 70 class AutoWeakFrame; 71 class WeakFrame; 72 class nsIScrollableFrame; 73 class nsIDOMEvent; 74 class nsDisplayList; 75 class nsDisplayListBuilder; 76 class nsPIDOMWindowOuter; 77 struct nsPoint; 78 class nsINode; 79 struct nsRect; 80 class nsRegion; 81 class nsRefreshDriver; 82 class nsARefreshObserver; 83 class nsAPostRefreshObserver; 84 #ifdef ACCESSIBILITY 85 class nsAccessibilityService; 86 namespace mozilla { 87 namespace a11y { 88 class DocAccessible; 89 } // namespace a11y 90 } // namespace mozilla 91 #endif 92 class nsITimer; 93 94 namespace mozilla { 95 class EventStates; 96 97 namespace dom { 98 class Element; 99 class Touch; 100 class Selection; 101 class ShadowRoot; 102 } // namespace dom 103 104 namespace layers { 105 class LayerManager; 106 } // namespace layers 107 108 namespace gfx { 109 class SourceSurface; 110 } // namespace gfx 111 } // namespace mozilla 112 113 // Flags to pass to SetCapturingContent 114 // 115 // when assigning capture, ignore whether capture is allowed or not 116 #define CAPTURE_IGNOREALLOWED 1 117 // true if events should be targeted at the capturing content or its children 118 #define CAPTURE_RETARGETTOELEMENT 2 119 // true if the current capture wants drags to be prevented 120 #define CAPTURE_PREVENTDRAG 4 121 // true when the mouse is pointer locked, and events are sent to locked element 122 #define CAPTURE_POINTERLOCK 8 123 124 typedef struct CapturingContentInfo { 125 // capture should only be allowed during a mousedown event 126 bool mAllowed; 127 bool mPointerLock; 128 bool mRetargetToElement; 129 bool mPreventDrag; 130 mozilla::StaticRefPtr<nsIContent> mContent; 131 } CapturingContentInfo; 132 133 // b7b89561-4f03-44b3-9afa-b47e7f313ffb 134 #define NS_IPRESSHELL_IID \ 135 { \ 136 0xb7b89561, 0x4f03, 0x44b3, { \ 137 0x9a, 0xfa, 0xb4, 0x7e, 0x7f, 0x31, 0x3f, 0xfb \ 138 } \ 139 } 140 141 // debug VerifyReflow flags 142 #define VERIFY_REFLOW_ON 0x01 143 #define VERIFY_REFLOW_NOISY 0x02 144 #define VERIFY_REFLOW_ALL 0x04 145 #define VERIFY_REFLOW_DUMP_COMMANDS 0x08 146 #define VERIFY_REFLOW_NOISY_RC 0x10 147 #define VERIFY_REFLOW_REALLY_NOISY_RC 0x20 148 #define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x40 149 150 #undef NOISY_INTERRUPTIBLE_REFLOW 151 152 enum nsRectVisibility { 153 nsRectVisibility_kVisible, 154 nsRectVisibility_kAboveViewport, 155 nsRectVisibility_kBelowViewport, 156 nsRectVisibility_kLeftOfViewport, 157 nsRectVisibility_kRightOfViewport 158 }; 159 160 /** 161 * Presentation shell interface. Presentation shells are the 162 * controlling point for managing the presentation of a document. The 163 * presentation shell holds a live reference to the document, the 164 * presentation context, the style manager, the style set and the root 165 * frame. <p> 166 * 167 * When this object is Release'd, it will release the document, the 168 * presentation context, the style manager, the style set and the root 169 * frame. 170 */ 171 172 class nsIPresShell : public nsStubDocumentObserver { 173 public: 174 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID) 175 176 protected: 177 typedef mozilla::layers::LayerManager LayerManager; 178 typedef mozilla::gfx::SourceSurface SourceSurface; 179 180 enum eRenderFlag { 181 STATE_IGNORING_VIEWPORT_SCROLLING = 0x1, 182 STATE_DRAWWINDOW_NOT_FLUSHING = 0x2 183 }; 184 typedef uint8_t RenderFlags; // for storing the above flags 185 186 public: 187 nsIPresShell(); 188 189 /** 190 * All callers are responsible for calling |Destroy| after calling 191 * |EndObservingDocument|. It needs to be separate only because form 192 * controls incorrectly store their data in the frames rather than the 193 * content model and printing calls |EndObservingDocument| multiple 194 * times to make form controls behave nicely when printed. 195 */ 196 virtual void Destroy() = 0; 197 IsDestroying()198 bool IsDestroying() { return mIsDestroying; } 199 200 /** 201 * All frames owned by the shell are allocated from an arena. They 202 * are also recycled using free lists. Separate free lists are 203 * maintained for each frame type (aID), which must always correspond 204 * to the same aSize value. AllocateFrame is infallible and will abort 205 * on out-of-memory. 206 */ AllocateFrame(nsQueryFrame::FrameIID aID,size_t aSize)207 void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) { 208 void* result = mFrameArena.AllocateByFrameID(aID, aSize); 209 RecordAlloc(result); 210 return result; 211 } 212 FreeFrame(nsQueryFrame::FrameIID aID,void * aPtr)213 void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr) { 214 RecordFree(aPtr); 215 if (!mIsDestroying) mFrameArena.FreeByFrameID(aID, aPtr); 216 } 217 218 /** 219 * This is for allocating other types of objects (not frames). Separate free 220 * lists are maintained for each type (aID), which must always correspond to 221 * the same aSize value. AllocateByObjectID is infallible and will abort on 222 * out-of-memory. 223 */ AllocateByObjectID(mozilla::ArenaObjectID aID,size_t aSize)224 void* AllocateByObjectID(mozilla::ArenaObjectID aID, size_t aSize) { 225 void* result = mFrameArena.AllocateByObjectID(aID, aSize); 226 RecordAlloc(result); 227 return result; 228 } 229 FreeByObjectID(mozilla::ArenaObjectID aID,void * aPtr)230 void FreeByObjectID(mozilla::ArenaObjectID aID, void* aPtr) { 231 RecordFree(aPtr); 232 if (!mIsDestroying) mFrameArena.FreeByObjectID(aID, aPtr); 233 } 234 235 template <typename T> RegisterArenaRefPtr(mozilla::ArenaRefPtr<T> * aPtr)236 void RegisterArenaRefPtr(mozilla::ArenaRefPtr<T>* aPtr) { 237 mFrameArena.RegisterArenaRefPtr(aPtr); 238 } 239 240 template <typename T> DeregisterArenaRefPtr(mozilla::ArenaRefPtr<T> * aPtr)241 void DeregisterArenaRefPtr(mozilla::ArenaRefPtr<T>* aPtr) { 242 mFrameArena.DeregisterArenaRefPtr(aPtr); 243 } 244 ClearArenaRefPtrs(mozilla::ArenaObjectID aObjectID)245 void ClearArenaRefPtrs(mozilla::ArenaObjectID aObjectID) { 246 mFrameArena.ClearArenaRefPtrs(aObjectID); 247 } 248 GetDocument()249 nsIDocument* GetDocument() const { return mDocument; } 250 GetPresContext()251 nsPresContext* GetPresContext() const { return mPresContext; } 252 GetViewManager()253 nsViewManager* GetViewManager() const { return mViewManager; } 254 255 nsRefreshDriver* GetRefreshDriver() const; 256 257 #ifdef ACCESSIBILITY 258 /** 259 * Return the document accessible for this pres shell if there is one. 260 */ GetDocAccessible()261 mozilla::a11y::DocAccessible* GetDocAccessible() const { 262 return mDocAccessible; 263 } 264 265 /** 266 * Set the document accessible for this pres shell. 267 */ SetDocAccessible(mozilla::a11y::DocAccessible * aDocAccessible)268 void SetDocAccessible(mozilla::a11y::DocAccessible* aDocAccessible) { 269 mDocAccessible = aDocAccessible; 270 } 271 #endif 272 StyleSet()273 mozilla::StyleSetHandle StyleSet() const { return mStyleSet; } 274 FrameConstructor()275 nsCSSFrameConstructor* FrameConstructor() const { return mFrameConstructor; } 276 277 /* Enable/disable author style level. Disabling author style disables the 278 * entire author level of the cascade, including the HTML preshint level. 279 */ 280 // XXX these could easily be inlined, but there is a circular #include 281 // problem with nsStyleSet. 282 void SetAuthorStyleDisabled(bool aDisabled); 283 bool GetAuthorStyleDisabled() const; 284 285 /* 286 * Called when stylesheets are added/removed/enabled/disabled to 287 * recompute style and clear other cached data as needed. This will 288 * not reconstruct style synchronously; if you need to do that, call 289 * FlushPendingNotifications to flush out style reresolves. 290 * 291 * This handles the the addition and removal of the various types of 292 * style rules that can be in CSS style sheets, such as @font-face 293 * rules and @counter-style rules. 294 * 295 * It requires that StyleSheetAdded, StyleSheetRemoved, 296 * StyleSheetApplicableStateChanged, StyleRuleAdded, StyleRuleRemoved, 297 * or StyleRuleChanged has been called on the style sheets that have 298 * changed. 299 * 300 * // XXXbz why do we have this on the interface anyway? The only consumer 301 * is calling AddOverrideStyleSheet/RemoveOverrideStyleSheet, and I think 302 * those should just handle reconstructing style data... 303 */ 304 void RestyleForCSSRuleChanges(); 305 306 /** 307 * Update the style set somehow to take into account changed prefs which 308 * affect document styling. 309 */ 310 virtual void UpdatePreferenceStyles() = 0; 311 312 /** 313 * FrameSelection will return the Frame based selection API. 314 * You cannot go back and forth anymore with QI between nsIDOM sel and 315 * nsIFrame sel. 316 */ 317 already_AddRefed<nsFrameSelection> FrameSelection(); 318 319 /** 320 * ConstFrameSelection returns an object which methods are safe to use for 321 * example in nsIFrame code. 322 */ ConstFrameSelection()323 const nsFrameSelection* ConstFrameSelection() const { return mSelection; } 324 325 // Start receiving notifications from our document. If called after Destroy, 326 // this will be ignored. 327 void BeginObservingDocument(); 328 329 // Stop receiving notifications from our document. If called after Destroy, 330 // this will be ignored. 331 void EndObservingDocument(); 332 IsObservingDocument()333 bool IsObservingDocument() const { return mIsObservingDocument; } 334 335 /** 336 * Return whether Initialize() was previously called. 337 */ DidInitialize()338 bool DidInitialize() const { return mDidInitialize; } 339 340 /** 341 * Perform initialization. Constructs the frame for the root content 342 * object and then enqueues a reflow of the frame model. 343 * 344 * Callers of this method must hold a reference to this shell that 345 * is guaranteed to survive through arbitrary script execution. 346 * Calling Initialize can execute arbitrary script. 347 */ 348 virtual nsresult Initialize() = 0; 349 350 enum class ResizeReflowOptions : uint32_t { 351 // the resulting BSize should be exactly as given 352 eBSizeExact, 353 // the resulting BSize can be less than the given one, producing 354 // shrink-to-fit sizing in the block dimension 355 eBSizeLimit 356 }; 357 /** 358 * Reflow the frame model into a new width and height. The 359 * coordinates for aWidth and aHeight must be in standard nscoord's. 360 */ 361 virtual nsresult ResizeReflow( 362 nscoord aWidth, nscoord aHeight, nscoord aOldWidth = 0, 363 nscoord aOldHeight = 0, 364 ResizeReflowOptions aOptions = ResizeReflowOptions::eBSizeExact) = 0; 365 /** 366 * Do the same thing as ResizeReflow but even if ResizeReflowOverride was 367 * called previously. 368 */ 369 virtual nsresult ResizeReflowIgnoreOverride( 370 nscoord aWidth, nscoord aHeight, nscoord aOldWidth, nscoord aOldHeight, 371 ResizeReflowOptions aOptions = ResizeReflowOptions::eBSizeExact) = 0; 372 373 /** 374 * Returns true if ResizeReflowOverride has been called. 375 */ 376 virtual bool GetIsViewportOverridden() = 0; 377 378 /** 379 * Return true if the presshell expects layout flush. 380 */ 381 virtual bool IsLayoutFlushObserver() = 0; 382 383 /** 384 * Called when document load completes. 385 */ 386 virtual void LoadComplete() = 0; 387 388 /** 389 * This calls through to the frame manager to get the root frame. 390 */ GetRootFrame()391 nsIFrame* GetRootFrame() const { return mFrameManager->GetRootFrame(); } 392 393 /* 394 * Get root scroll frame from FrameManager()->GetRootFrame(). 395 */ 396 nsIFrame* GetRootScrollFrame() const; 397 398 /* 399 * The same as GetRootScrollFrame, but returns an nsIScrollableFrame 400 */ 401 nsIScrollableFrame* GetRootScrollFrameAsScrollable() const; 402 403 /** 404 * Get the current focused content or DOM selection that should be the 405 * target for scrolling. 406 */ 407 already_AddRefed<nsIContent> GetContentForScrolling() const; 408 409 /** 410 * Get the DOM selection that should be the target for scrolling, if there 411 * is no focused content. 412 */ 413 already_AddRefed<nsIContent> GetSelectedContentForScrolling() const; 414 415 /** 416 * Gets nearest scrollable frame from the specified content node. The frame 417 * is scrollable with overflow:scroll or overflow:auto in some direction when 418 * aDirection is eEither. Otherwise, this returns a nearest frame that is 419 * scrollable in the specified direction. 420 */ 421 enum ScrollDirection { eHorizontal, eVertical, eEither }; 422 nsIScrollableFrame* GetScrollableFrameToScrollForContent( 423 nsIContent* aContent, ScrollDirection aDirection); 424 425 /** 426 * Gets nearest scrollable frame from current focused content or DOM 427 * selection if there is no focused content. The frame is scrollable with 428 * overflow:scroll or overflow:auto in some direction when aDirection is 429 * eEither. Otherwise, this returns a nearest frame that is scrollable in 430 * the specified direction. 431 */ 432 nsIScrollableFrame* GetScrollableFrameToScroll(ScrollDirection aDirection); 433 434 /** 435 * Gets nearest ancestor scrollable frame from aFrame. The frame is 436 * scrollable with overflow:scroll or overflow:auto in some direction when 437 * aDirection is eEither. Otherwise, this returns a nearest frame that is 438 * scrollable in the specified direction. 439 */ 440 nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame, 441 ScrollDirection aDirection); 442 443 /** 444 * Returns the page sequence frame associated with the frame hierarchy. 445 * Returns nullptr if not a paginated view. 446 */ 447 virtual nsIPageSequenceFrame* GetPageSequenceFrame() const = 0; 448 449 /** 450 * Returns the canvas frame associated with the frame hierarchy. 451 * Returns nullptr if is XUL document. 452 */ 453 virtual nsCanvasFrame* GetCanvasFrame() const = 0; 454 455 /** 456 * Tell the pres shell that a frame needs to be marked dirty and needs 457 * Reflow. It's OK if this is an ancestor of the frame needing reflow as 458 * long as the ancestor chain between them doesn't cross a reflow root. 459 * 460 * The bit to add should be NS_FRAME_IS_DIRTY, NS_FRAME_HAS_DIRTY_CHILDREN 461 * or nsFrameState(0); passing 0 means that dirty bits won't be set on the 462 * frame or its ancestors/descendants, but that intrinsic widths will still 463 * be marked dirty. Passing aIntrinsicDirty = eResize and aBitToAdd = 0 464 * would result in no work being done, so don't do that. 465 */ 466 enum IntrinsicDirty { 467 // XXXldb eResize should be renamed 468 eResize, // don't mark any intrinsic widths dirty 469 eTreeChange, // mark intrinsic widths dirty on aFrame and its ancestors 470 eStyleChange // Do eTreeChange, plus all of aFrame's descendants 471 }; 472 enum ReflowRootHandling { 473 ePositionOrSizeChange, // aFrame is changing position or size 474 eNoPositionOrSizeChange, // ... NOT changing ... 475 eInferFromBitToAdd // is changing iff (aBitToAdd == NS_FRAME_IS_DIRTY) 476 477 // Note: With eStyleChange, these can also apply to out-of-flows 478 // in addition to aFrame. 479 }; 480 virtual void FrameNeedsReflow( 481 nsIFrame* aFrame, IntrinsicDirty aIntrinsicDirty, nsFrameState aBitToAdd, 482 ReflowRootHandling aRootHandling = eInferFromBitToAdd) = 0; 483 484 /** 485 * Calls FrameNeedsReflow on all fixed position children of the root frame. 486 */ 487 virtual void MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty); 488 489 /** 490 * Tell the presshell that the given frame's reflow was interrupted. This 491 * will mark as having dirty children a path from the given frame (inclusive) 492 * to the nearest ancestor with a dirty subtree, or to the reflow root 493 * currently being reflowed if no such ancestor exists (inclusive). This is 494 * to be done immediately after reflow of the current reflow root completes. 495 * This method must only be called during reflow, and the frame it's being 496 * called on must be in the process of being reflowed when it's called. This 497 * method doesn't mark any intrinsic widths dirty and doesn't add any bits 498 * other than NS_FRAME_HAS_DIRTY_CHILDREN. 499 */ 500 virtual void FrameNeedsToContinueReflow(nsIFrame* aFrame) = 0; 501 502 virtual void CancelAllPendingReflows() = 0; 503 504 virtual void NotifyCounterStylesAreDirty() = 0; 505 506 /** 507 * Destroy the frames for aElement, and reconstruct them asynchronously if 508 * needed. 509 * 510 * Note that this may destroy frames for an ancestor instead. 511 */ 512 virtual void DestroyFramesForAndRestyle(mozilla::dom::Element* aElement) = 0; 513 514 void PostRecreateFramesFor(mozilla::dom::Element* aElement); 515 void RestyleForAnimation(mozilla::dom::Element* aElement, 516 nsRestyleHint aHint); 517 518 // ShadowRoot has APIs that can change styles. This notifies the shell that 519 // stlyes applicable in the shadow tree have potentially changed. 520 void RecordShadowStyleChange(mozilla::dom::ShadowRoot& aShadowRoot); 521 522 /** 523 * Determine if it is safe to flush all pending notifications. 524 */ 525 bool IsSafeToFlush() const; 526 527 /** 528 * Flush pending notifications of the type specified. This method 529 * will not affect the content model; it'll just affect style and 530 * frames. Callers that actually want up-to-date presentation (other 531 * than the document itself) should probably be calling 532 * nsIDocument::FlushPendingNotifications. 533 * 534 * This method can execute script, which can destroy this presshell object 535 * unless someone is holding a reference to it on the stack. The presshell 536 * itself will ensure it lives up until the method returns, but callers who 537 * plan to use the presshell after this call should hold a strong ref 538 * themselves! 539 * 540 * @param aType the type of notifications to flush 541 */ 542 public: FlushPendingNotifications(mozilla::FlushType aType)543 void FlushPendingNotifications(mozilla::FlushType aType) { 544 if (!NeedFlush(aType)) { 545 return; 546 } 547 548 DoFlushPendingNotifications(aType); 549 } 550 FlushPendingNotifications(mozilla::ChangesToFlush aType)551 void FlushPendingNotifications(mozilla::ChangesToFlush aType) { 552 if (!NeedFlush(aType.mFlushType)) { 553 return; 554 } 555 556 DoFlushPendingNotifications(aType); 557 } 558 559 protected: 560 /** 561 * Implementation methods for FlushPendingNotifications. 562 */ 563 virtual void DoFlushPendingNotifications(mozilla::FlushType aType) = 0; 564 virtual void DoFlushPendingNotifications(mozilla::ChangesToFlush aType) = 0; 565 566 public: 567 /** 568 * Whether we might need a flush for the given flush type. If this 569 * function returns false, we definitely don't need to flush. 570 * 571 * @param aFlushType The flush type to check. This must be 572 * >= FlushType::Style. This also returns true if a throttled 573 * animation flush is required. 574 */ NeedFlush(mozilla::FlushType aType)575 bool NeedFlush(mozilla::FlushType aType) const { 576 // We check mInFlush to handle re-entrant calls to FlushPendingNotifications 577 // by reporting that we always need a flush in that case. Otherwise, 578 // we could end up missing needed flushes, since we clear the mNeedXXXFlush 579 // flags at the top of FlushPendingNotifications. 580 MOZ_ASSERT(aType >= mozilla::FlushType::Style); 581 return mNeedStyleFlush || 582 (mNeedLayoutFlush && 583 aType >= mozilla::FlushType::InterruptibleLayout) || 584 aType >= mozilla::FlushType::Display || 585 mNeedThrottledAnimationFlush || mInFlush; 586 } 587 588 inline void EnsureStyleFlush(); 589 inline void SetNeedStyleFlush(); 590 inline void SetNeedLayoutFlush(); 591 inline void SetNeedThrottledAnimationFlush(); 592 ObservingStyleFlushes()593 bool ObservingStyleFlushes() const { return mObservingStyleFlushes; } ObservingLayoutFlushes()594 bool ObservingLayoutFlushes() const { return mObservingLayoutFlushes; } 595 ObserveStyleFlushes()596 void ObserveStyleFlushes() { 597 if (!ObservingStyleFlushes()) DoObserveStyleFlushes(); 598 } 599 NeedStyleFlush()600 bool NeedStyleFlush() const { return mNeedStyleFlush; } 601 /** 602 * Returns true if we might need to flush layout, even if we haven't scheduled 603 * one yet (as opposed to HasPendingReflow, which returns true if a flush is 604 * scheduled or will soon be scheduled). 605 */ NeedLayoutFlush()606 bool NeedLayoutFlush() const { return mNeedLayoutFlush; } 607 608 /** 609 * Callbacks will be called even if reflow itself fails for 610 * some reason. 611 */ 612 virtual nsresult PostReflowCallback(nsIReflowCallback* aCallback) = 0; 613 virtual void CancelReflowCallback(nsIReflowCallback* aCallback) = 0; 614 615 virtual void ClearFrameRefs(nsIFrame* aFrame) = 0; 616 617 /** 618 * Get a reference rendering context. This is a context that should not 619 * be rendered to, but is suitable for measuring text and performing 620 * other non-rendering operations. Guaranteed to return non-null. 621 */ 622 virtual already_AddRefed<gfxContext> CreateReferenceRenderingContext() = 0; 623 624 /** 625 * Informs the pres shell that the document is now at the anchor with 626 * the given name. If |aScroll| is true, scrolls the view of the 627 * document so that the anchor with the specified name is displayed at 628 * the top of the window. If |aAnchorName| is empty, then this informs 629 * the pres shell that there is no current target, and |aScroll| must 630 * be false. If |aAdditionalScrollFlags| is nsIPresShell::SCROLL_SMOOTH_AUTO 631 * and |aScroll| is true, the scrolling may be performed with an animation. 632 */ 633 virtual nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll, 634 uint32_t aAdditionalScrollFlags = 0) = 0; 635 636 /** 637 * Tells the presshell to scroll again to the last anchor scrolled to by 638 * GoToAnchor, if any. This scroll only happens if the scroll 639 * position has not changed since the last GoToAnchor. This is called 640 * by nsDocumentViewer::LoadComplete. This clears the last anchor 641 * scrolled to by GoToAnchor (we don't want to keep it alive if it's 642 * removed from the DOM), so don't call this more than once. 643 */ 644 virtual nsresult ScrollToAnchor() = 0; 645 646 enum { 647 SCROLL_TOP = 0, 648 SCROLL_BOTTOM = 100, 649 SCROLL_LEFT = 0, 650 SCROLL_RIGHT = 100, 651 SCROLL_CENTER = 50, 652 SCROLL_MINIMUM = -1 653 }; 654 655 enum WhenToScroll { 656 SCROLL_ALWAYS, 657 SCROLL_IF_NOT_VISIBLE, 658 SCROLL_IF_NOT_FULLY_VISIBLE 659 }; 660 typedef struct ScrollAxis { 661 int16_t mWhereToScroll; 662 WhenToScroll mWhenToScroll : 8; 663 bool mOnlyIfPerceivedScrollableDirection : 1; 664 /** 665 * @param aWhere: Either a percentage or a special value. 666 * nsIPresShell defines: 667 * * (Default) SCROLL_MINIMUM = -1: The visible area is 668 * scrolled the minimum amount to show as much as possible of the frame. 669 * This won't hide any initially visible part of the frame. 670 * * SCROLL_TOP = 0: The frame's upper edge is aligned with 671 * the top edge of the visible area. 672 * * SCROLL_BOTTOM = 100: The frame's bottom edge is aligned 673 * with the bottom edge of the visible area. 674 * * SCROLL_LEFT = 0: The frame's left edge is aligned with 675 * the left edge of the visible area. 676 * * SCROLL_RIGHT = 100: The frame's right edge is aligned 677 * with the right edge of the visible area. 678 * * SCROLL_CENTER = 50: The frame is centered along the axis 679 * the ScrollAxis is used for. 680 * 681 * Other values are treated as a percentage, and the point 682 * "percent" down the frame is placed at the point "percent" 683 * down the visible area. 684 * @param aWhen: 685 * * (Default) SCROLL_IF_NOT_FULLY_VISIBLE: Move the frame 686 * only if it is not fully visible (including if it's not visible at all). 687 * Note that in this case if the frame is too large to fit in 688 * view, it will only be scrolled if more of it can fit than 689 * is already in view. 690 * * SCROLL_IF_NOT_VISIBLE: Move the frame only if none of it 691 * is visible. 692 * * SCROLL_ALWAYS: Move the frame regardless of its current 693 * visibility. 694 * @param aOnlyIfPerceivedScrollableDirection: 695 * If the direction is not a perceived scrollable direction 696 * (i.e. no scrollbar showing and less than one device pixel of scrollable 697 * distance), don't scroll. Defaults to false. 698 */ 699 explicit ScrollAxis(int16_t aWhere = SCROLL_MINIMUM, 700 WhenToScroll aWhen = SCROLL_IF_NOT_FULLY_VISIBLE, 701 bool aOnlyIfPerceivedScrollableDirection = false) mWhereToScrollScrollAxis702 : mWhereToScroll(aWhere), 703 mWhenToScroll(aWhen), 704 mOnlyIfPerceivedScrollableDirection( 705 aOnlyIfPerceivedScrollableDirection) {} 706 } ScrollAxis; 707 /** 708 * Scrolls the view of the document so that the primary frame of the content 709 * is displayed in the window. Layout is flushed before scrolling. 710 * 711 * @param aContent The content object of which primary frame should be 712 * scrolled into view. 713 * @param aVertical How to align the frame vertically and when to do so. 714 * This is a ScrollAxis of Where and When. 715 * @param aHorizontal How to align the frame horizontally and when to do so. 716 * This is a ScrollAxis of Where and When. 717 * @param aFlags If SCROLL_FIRST_ANCESTOR_ONLY is set, only the nearest 718 * scrollable ancestor is scrolled, otherwise all 719 * scrollable ancestors may be scrolled if necessary. 720 * If SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a 721 * direction even if overflow:hidden is specified in that 722 * direction; otherwise we will not scroll in that direction 723 * when overflow:hidden is set for that direction. 724 * If SCROLL_NO_PARENT_FRAMES is set then we only scroll 725 * nodes in this document, not in any parent documents which 726 * contain this document in a iframe or the like. 727 * If SCROLL_SMOOTH is set and CSSOM-VIEW scroll-behavior 728 * is enabled, we will scroll smoothly using 729 * nsIScrollableFrame::ScrollMode::SMOOTH_MSD; otherwise, 730 * nsIScrollableFrame::ScrollMode::INSTANT will be used. 731 * If SCROLL_SMOOTH_AUTO is set, the CSSOM-View 732 * scroll-behavior attribute is set to 'smooth' on the 733 * scroll frame, and CSSOM-VIEW scroll-behavior is enabled, 734 * we will scroll smoothly using 735 * nsIScrollableFrame::ScrollMode::SMOOTH_MSD; otherwise, 736 * nsIScrollableFrame::ScrollMode::INSTANT will be used. 737 */ 738 virtual nsresult ScrollContentIntoView(nsIContent* aContent, 739 ScrollAxis aVertical, 740 ScrollAxis aHorizontal, 741 uint32_t aFlags) = 0; 742 743 enum { 744 SCROLL_FIRST_ANCESTOR_ONLY = 0x01, 745 SCROLL_OVERFLOW_HIDDEN = 0x02, 746 SCROLL_NO_PARENT_FRAMES = 0x04, 747 SCROLL_SMOOTH = 0x08, 748 SCROLL_SMOOTH_AUTO = 0x10 749 }; 750 /** 751 * Scrolls the view of the document so that the given area of a frame 752 * is visible, if possible. Layout is not flushed before scrolling. 753 * 754 * @param aRect relative to aFrame 755 * @param aVertical see ScrollContentIntoView and ScrollAxis 756 * @param aHorizontal see ScrollContentIntoView and ScrollAxis 757 * @param aFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the 758 * nearest scrollable ancestor is scrolled, otherwise all 759 * scrollable ancestors may be scrolled if necessary 760 * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction 761 * even if overflow:hidden is specified in that direction; otherwise 762 * we will not scroll in that direction when overflow:hidden is 763 * set for that direction 764 * If SCROLL_NO_PARENT_FRAMES is set then we only scroll 765 * nodes in this document, not in any parent documents which 766 * contain this document in a iframe or the like. 767 * @return true if any scrolling happened, false if no scrolling happened 768 */ 769 virtual bool ScrollFrameRectIntoView(nsIFrame* aFrame, const nsRect& aRect, 770 ScrollAxis aVertical, 771 ScrollAxis aHorizontal, 772 uint32_t aFlags) = 0; 773 774 /** 775 * Determine if a rectangle specified in the frame's coordinate system 776 * intersects the viewport "enough" to be considered visible. 777 * @param aFrame frame that aRect coordinates are specified relative to 778 * @param aRect rectangle in twips to test for visibility 779 * @param aMinTwips is the minimum distance in from the edge of the viewport 780 * that an object must be to be counted visible 781 * @return nsRectVisibility_kVisible if the rect is visible 782 * nsRectVisibility_kAboveViewport 783 * nsRectVisibility_kBelowViewport 784 * nsRectVisibility_kLeftOfViewport 785 * nsRectVisibility_kRightOfViewport rectangle is outside the viewport 786 * in the specified direction 787 */ 788 virtual nsRectVisibility GetRectVisibility(nsIFrame* aFrame, 789 const nsRect& aRect, 790 nscoord aMinTwips) const = 0; 791 792 /** 793 * Suppress notification of the frame manager that frames are 794 * being destroyed. 795 */ 796 virtual void SetIgnoreFrameDestruction(bool aIgnore) = 0; 797 798 /** 799 * Notification sent by a frame informing the pres shell that it is about to 800 * be destroyed. 801 * This allows any outstanding references to the frame to be cleaned up 802 */ 803 virtual void NotifyDestroyingFrame(nsIFrame* aFrame) = 0; 804 805 /** 806 * Get the AccessibleCaretEventHub, if it exists. AddRefs it. 807 */ 808 virtual already_AddRefed<mozilla::AccessibleCaretEventHub> 809 GetAccessibleCaretEventHub() const = 0; 810 811 /** 812 * Get the caret, if it exists. AddRefs it. 813 */ 814 virtual already_AddRefed<nsCaret> GetCaret() const = 0; 815 816 /** 817 * Set the current caret to a new caret. To undo this, call RestoreCaret. 818 */ 819 virtual void SetCaret(nsCaret* aNewCaret) = 0; 820 821 /** 822 * Restore the caret to the original caret that this pres shell was created 823 * with. 824 */ 825 virtual void RestoreCaret() = 0; 826 827 /** 828 * Should the images have borders etc. Actual visual effects are determined 829 * by the frames. Visual effects may not effect layout, only display. 830 * Takes effect on next repaint, does not force a repaint itself. 831 * 832 * @param aInEnable if true, visual selection effects are enabled 833 * if false visual selection effects are disabled 834 */ 835 NS_IMETHOD SetSelectionFlags(int16_t aInEnable) = 0; 836 837 /** 838 * Gets the current state of non text selection effects 839 * @return current state of non text selection, 840 * as set by SetDisplayNonTextSelection 841 */ GetSelectionFlags()842 int16_t GetSelectionFlags() const { return mSelectionFlags; } 843 844 virtual mozilla::dom::Selection* GetCurrentSelection( 845 mozilla::SelectionType aSelectionType) = 0; 846 847 /** 848 * Gets a selection controller for the focused content in the DOM window 849 * for mDocument. 850 * 851 * @param aFocusedContent If there is focused content in the DOM window, 852 * the focused content will be returned. This may 853 * be nullptr if it's not necessary. 854 * @return A selection controller for focused content. 855 * E.g., if an <input> element has focus, returns 856 * the independent selection controller of it. 857 * If the DOM window does not have focused content 858 * (similar to Document.activeElement), returns 859 * nullptr. 860 */ 861 virtual already_AddRefed<nsISelectionController> 862 GetSelectionControllerForFocusedContent( 863 nsIContent** aFocusedContent = nullptr) = 0; 864 865 /** 866 * Interface to dispatch events via the presshell 867 * @note The caller must have a strong reference to the PresShell. 868 */ 869 virtual nsresult HandleEventWithTarget( 870 mozilla::WidgetEvent* aEvent, nsIFrame* aFrame, nsIContent* aContent, 871 nsEventStatus* aStatus, bool aIsHandlingNativeEvent = false, 872 nsIContent** aTargetContent = nullptr, 873 nsIContent* aOverrideClickTarget = nullptr) = 0; 874 875 /** 876 * Dispatch event to content only (NOT full processing) 877 * @note The caller must have a strong reference to the PresShell. 878 */ 879 virtual nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent, 880 mozilla::WidgetEvent* aEvent, 881 nsEventStatus* aStatus) = 0; 882 883 /** 884 * Dispatch event to content only (NOT full processing) 885 * @note The caller must have a strong reference to the PresShell. 886 */ 887 virtual nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent, 888 nsIDOMEvent* aEvent, 889 nsEventStatus* aStatus) = 0; 890 891 /** 892 * Return whether or not the event is valid to be dispatched 893 */ 894 virtual bool CanDispatchEvent( 895 const mozilla::WidgetGUIEvent* aEvent = nullptr) const = 0; 896 897 /** 898 * Gets the current target event frame from the PresShell 899 */ 900 virtual nsIFrame* GetEventTargetFrame() = 0; 901 902 /** 903 * Gets the current target event frame from the PresShell 904 */ 905 virtual already_AddRefed<nsIContent> GetEventTargetContent( 906 mozilla::WidgetEvent* aEvent) = 0; 907 908 /** 909 * Get and set the history state for the current document 910 */ 911 912 virtual nsresult CaptureHistoryState( 913 nsILayoutHistoryState** aLayoutHistoryState) = 0; 914 915 /** 916 * Determine if reflow is currently locked 917 * returns true if reflow is locked, false otherwise 918 */ IsReflowLocked()919 bool IsReflowLocked() const { return mIsReflowing; } 920 921 /** 922 * Called to find out if painting is suppressed for this presshell. If it is 923 * suppressd, we don't allow the painting of any layer but the background, and 924 * we don't recur into our children. 925 */ IsPaintingSuppressed()926 bool IsPaintingSuppressed() const { return mPaintingSuppressed; } 927 928 /** 929 * Pause painting by freezing the refresh driver of this and all parent 930 * presentations. This may not have the desired effect if this pres shell 931 * has its own refresh driver. 932 */ 933 virtual void PausePainting() = 0; 934 935 /** 936 * Resume painting by thawing the refresh driver of this and all parent 937 * presentations. This may not have the desired effect if this pres shell 938 * has its own refresh driver. 939 */ 940 virtual void ResumePainting() = 0; 941 942 /** 943 * Unsuppress painting. 944 */ 945 virtual void UnsuppressPainting() = 0; 946 947 /** 948 * Get the set of agent style sheets for this presentation 949 */ 950 virtual nsresult GetAgentStyleSheets( 951 nsTArray<RefPtr<mozilla::StyleSheet>>& aSheets) = 0; 952 953 /** 954 * Replace the set of agent style sheets 955 */ 956 virtual nsresult SetAgentStyleSheets( 957 const nsTArray<RefPtr<mozilla::StyleSheet>>& aSheets) = 0; 958 959 /** 960 * Add an override style sheet for this presentation 961 */ 962 virtual nsresult AddOverrideStyleSheet(mozilla::StyleSheet* aSheet) = 0; 963 964 /** 965 * Remove an override style sheet 966 */ 967 virtual nsresult RemoveOverrideStyleSheet(mozilla::StyleSheet* aSheet) = 0; 968 969 /** 970 * Reconstruct frames for all elements in the document 971 */ 972 virtual void ReconstructFrames() = 0; 973 974 /** 975 * Notify that a content node's state has changed 976 */ 977 virtual void ContentStateChanged( 978 nsIDocument* aDocument, nsIContent* aContent, 979 mozilla::EventStates aStateMask) override = 0; 980 981 /** 982 * See if reflow verification is enabled. To enable reflow verification add 983 * "verifyreflow:1" to your MOZ_LOG environment variable (any non-zero 984 * debug level will work). Or, call SetVerifyReflowEnable with true. 985 */ 986 static bool GetVerifyReflowEnable(); 987 988 /** 989 * Set the verify-reflow enable flag. 990 */ 991 static void SetVerifyReflowEnable(bool aEnabled); 992 993 virtual nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame); 994 995 #ifdef MOZ_REFLOW_PERF 996 virtual void DumpReflows() = 0; 997 virtual void CountReflows(const char* aName, nsIFrame* aFrame) = 0; 998 virtual void PaintCount(const char* aName, gfxContext* aRenderingContext, 999 nsPresContext* aPresContext, nsIFrame* aFrame, 1000 const nsPoint& aOffset, uint32_t aColor) = 0; 1001 virtual void SetPaintFrameCount(bool aOn) = 0; 1002 virtual bool IsPaintingFrameCounts() = 0; 1003 #endif 1004 1005 #ifdef DEBUG 1006 // Debugging hooks 1007 virtual void ListStyleContexts(FILE* out, int32_t aIndent = 0) = 0; 1008 1009 virtual void ListStyleSheets(FILE* out, int32_t aIndent = 0) = 0; 1010 virtual void VerifyStyleTree() = 0; 1011 #endif 1012 1013 #ifdef ACCESSIBILITY 1014 /** 1015 * Return true if accessibility is active. 1016 */ 1017 static bool IsAccessibilityActive(); 1018 1019 /** 1020 * Return accessibility service if accessibility is active. 1021 */ 1022 static nsAccessibilityService* AccService(); 1023 #endif 1024 1025 /** 1026 * Stop all active elements (plugins and the caret) in this presentation and 1027 * in the presentations of subdocuments. Resets painting to a suppressed 1028 * state. 1029 * XXX this should include image animations 1030 */ 1031 virtual void Freeze() = 0; IsFrozen()1032 bool IsFrozen() { return mFrozen; } 1033 1034 /** 1035 * Restarts active elements (plugins) in this presentation and in the 1036 * presentations of subdocuments, then do a full invalidate of the content 1037 * area. 1038 */ 1039 virtual void Thaw() = 0; 1040 1041 virtual void FireOrClearDelayedEvents(bool aFireEvents) = 0; 1042 1043 /** 1044 * When this shell is disconnected from its containing docshell, we 1045 * lose our container pointer. However, we'd still like to be able to target 1046 * user events at the docshell's parent. This pointer allows us to do that. 1047 * It should not be used for any other purpose. 1048 */ 1049 void SetForwardingContainer(const mozilla::WeakPtr<nsDocShell>& aContainer); 1050 1051 /** 1052 * Render the document into an arbitrary gfxContext 1053 * Designed for getting a picture of a document or a piece of a document 1054 * Note that callers will generally want to call FlushPendingNotifications 1055 * to get an up-to-date view of the document 1056 * @param aRect is the region to capture into the offscreen buffer, in the 1057 * root frame's coordinate system (if aIgnoreViewportScrolling is false) 1058 * or in the root scrolled frame's coordinate system 1059 * (if aIgnoreViewportScrolling is true). The coordinates are in appunits. 1060 * @param aFlags see below; 1061 * set RENDER_IS_UNTRUSTED if the contents may be passed to malicious 1062 * agents. E.g. we might choose not to paint the contents of sensitive widgets 1063 * such as the file name in a file upload widget, and we might choose not 1064 * to paint themes. 1065 * set RENDER_IGNORE_VIEWPORT_SCROLLING to ignore 1066 * clipping and scrollbar painting due to scrolling in the viewport 1067 * set RENDER_CARET to draw the caret if one would be visible 1068 * (by default the caret is never drawn) 1069 * set RENDER_USE_LAYER_MANAGER to force rendering to go through 1070 * the layer manager for the window. This may be unexpectedly slow 1071 * (if the layer manager must read back data from the GPU) or low-quality 1072 * (if the layer manager reads back pixel data and scales it 1073 * instead of rendering using the appropriate scaling). It may also 1074 * slow everything down if the area rendered does not correspond to the 1075 * normal visible area of the window. 1076 * set RENDER_ASYNC_DECODE_IMAGES to avoid having images synchronously 1077 * decoded during rendering. 1078 * (by default images decode synchronously with RenderDocument) 1079 * set RENDER_DOCUMENT_RELATIVE to render the document as if there has been 1080 * no scrolling and interpret |aRect| relative to the document instead of the 1081 * CSS viewport. Only considered if RENDER_IGNORE_VIEWPORT_SCROLLING is set 1082 * or the document is in ignore viewport scrolling mode 1083 * (nsIPresShell::SetIgnoreViewportScrolling/IgnoringViewportScrolling). 1084 * @param aBackgroundColor a background color to render onto 1085 * @param aRenderedContext the gfxContext to render to. We render so that 1086 * one CSS pixel in the source document is rendered to one unit in the current 1087 * transform. 1088 */ 1089 enum { 1090 RENDER_IS_UNTRUSTED = 0x01, 1091 RENDER_IGNORE_VIEWPORT_SCROLLING = 0x02, 1092 RENDER_CARET = 0x04, 1093 RENDER_USE_WIDGET_LAYERS = 0x08, 1094 RENDER_ASYNC_DECODE_IMAGES = 0x10, 1095 RENDER_DOCUMENT_RELATIVE = 0x20, 1096 RENDER_DRAWWINDOW_NOT_FLUSHING = 0x40 1097 }; 1098 virtual nsresult RenderDocument(const nsRect& aRect, uint32_t aFlags, 1099 nscolor aBackgroundColor, 1100 gfxContext* aRenderedContext) = 0; 1101 1102 enum { RENDER_IS_IMAGE = 0x100, RENDER_AUTO_SCALE = 0x80 }; 1103 1104 /** 1105 * Renders a node aNode to a surface and returns it. The aRegion may be used 1106 * to clip the rendering. This region is measured in CSS pixels from the 1107 * edge of the presshell area. The aPoint, aScreenRect and aFlags arguments 1108 * function in a similar manner as RenderSelection. 1109 */ 1110 virtual already_AddRefed<mozilla::gfx::SourceSurface> RenderNode( 1111 nsIDOMNode* aNode, nsIntRegion* aRegion, 1112 const mozilla::LayoutDeviceIntPoint aPoint, 1113 mozilla::LayoutDeviceIntRect* aScreenRect, uint32_t aFlags) = 0; 1114 1115 /** 1116 * Renders a selection to a surface and returns it. This method is primarily 1117 * intended to create the drag feedback when dragging a selection. 1118 * 1119 * aScreenRect will be filled in with the bounding rectangle of the 1120 * selection area on screen. 1121 * 1122 * If the area of the selection is large and the RENDER_AUTO_SCALE flag is 1123 * set, the image will be scaled down. The argument aPoint is used in this 1124 * case as a reference point when determining the new screen rectangle after 1125 * scaling. Typically, this will be the mouse position, so that the screen 1126 * rectangle is positioned such that the mouse is over the same point in the 1127 * scaled image as in the original. When scaling does not occur, the mouse 1128 * point isn't used because the position can be determined from the displayed 1129 * frames. 1130 */ 1131 virtual already_AddRefed<mozilla::gfx::SourceSurface> RenderSelection( 1132 nsISelection* aSelection, const mozilla::LayoutDeviceIntPoint aPoint, 1133 mozilla::LayoutDeviceIntRect* aScreenRect, uint32_t aFlags) = 0; 1134 1135 void AddAutoWeakFrame(AutoWeakFrame* aWeakFrame); 1136 void AddWeakFrame(WeakFrame* aWeakFrame); 1137 1138 void RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame); 1139 void RemoveWeakFrame(WeakFrame* aWeakFrame); 1140 1141 #ifdef DEBUG GetDrawEventTargetFrame()1142 nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; } 1143 #endif 1144 1145 /** 1146 * Stop or restart non synthetic test mouse event handling on *all* 1147 * presShells. 1148 * 1149 * @param aDisable If true, disable all non synthetic test mouse 1150 * events on all presShells. Otherwise, enable them. 1151 */ 1152 virtual void DisableNonTestMouseEvents(bool aDisable) = 0; 1153 1154 /** 1155 * Record the background color of the most recently drawn canvas. This color 1156 * is composited on top of the user's default background color and then used 1157 * to draw the background color of the canvas. See PresShell::Paint, 1158 * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer; 1159 * bug 488242, bug 476557 and other bugs mentioned there. 1160 */ SetCanvasBackground(nscolor aColor)1161 void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; } GetCanvasBackground()1162 nscolor GetCanvasBackground() { return mCanvasBackgroundColor; } 1163 1164 /** 1165 * Use the current frame tree (if it exists) to update the background 1166 * color of the most recently drawn canvas. 1167 */ 1168 virtual void UpdateCanvasBackground() = 0; 1169 1170 /** 1171 * Add a solid color item to the bottom of aList with frame aFrame and bounds 1172 * aBounds. Checks first if this needs to be done by checking if aFrame is a 1173 * canvas frame (if the FORCE_DRAW flag is passed then this check is skipped). 1174 * aBackstopColor is composed behind the background color of the canvas, it is 1175 * transparent by default. 1176 * We attempt to make the background color part of the scrolled canvas (to 1177 * reduce transparent layers), and if async scrolling is enabled (and the 1178 * background is opaque) then we add a second, unscrolled item to handle the 1179 * checkerboarding case. ADD_FOR_SUBDOC shoud be specified when calling this 1180 * for a subdocument, and LayoutUseContainersForRootFrame might cause the 1181 * whole list to be scrolled. In that case the second unscrolled item will be 1182 * elided. APPEND_UNSCROLLED_ONLY only attempts to add the unscrolled item, so 1183 * that we can add it manually after LayoutUseContainersForRootFrame has built 1184 * the scrolling ContainerLayer. 1185 */ 1186 enum { 1187 FORCE_DRAW = 0x01, 1188 ADD_FOR_SUBDOC = 0x02, 1189 APPEND_UNSCROLLED_ONLY = 0x04, 1190 }; 1191 virtual void AddCanvasBackgroundColorItem( 1192 nsDisplayListBuilder& aBuilder, nsDisplayList& aList, nsIFrame* aFrame, 1193 const nsRect& aBounds, nscolor aBackstopColor = NS_RGBA(0, 0, 0, 0), 1194 uint32_t aFlags = 0) = 0; 1195 1196 /** 1197 * Add a solid color item to the bottom of aList with frame aFrame and 1198 * bounds aBounds representing the dark grey background behind the page of a 1199 * print preview presentation. 1200 */ 1201 virtual void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder, 1202 nsDisplayList& aList, 1203 nsIFrame* aFrame, 1204 const nsRect& aBounds) = 0; 1205 1206 /** 1207 * Computes the backstop color for the view: transparent if in a transparent 1208 * widget, otherwise the PresContext default background color. This color is 1209 * only visible if the contents of the view as a whole are translucent. 1210 */ 1211 virtual nscolor ComputeBackstopColor(nsView* aDisplayRoot) = 0; 1212 ObserveNativeAnonMutationsForPrint(bool aObserve)1213 void ObserveNativeAnonMutationsForPrint(bool aObserve) { 1214 mObservesMutationsForPrint = aObserve; 1215 } ObservesNativeAnonMutationsForPrint()1216 bool ObservesNativeAnonMutationsForPrint() { 1217 return mObservesMutationsForPrint; 1218 } 1219 1220 virtual nsresult SetIsActive(bool aIsActive) = 0; 1221 IsActive()1222 bool IsActive() { return mIsActive; } 1223 1224 // mouse capturing 1225 static CapturingContentInfo gCaptureInfo; 1226 1227 /** 1228 * When capturing content is set, it traps all mouse events and retargets 1229 * them at this content node. If capturing is not allowed 1230 * (gCaptureInfo.mAllowed is false), then capturing is not set. However, if 1231 * the CAPTURE_IGNOREALLOWED flag is set, the allowed state is ignored and 1232 * capturing is set regardless. To disable capture, pass null for the value 1233 * of aContent. 1234 * 1235 * If CAPTURE_RETARGETTOELEMENT is set, all mouse events are targeted at 1236 * aContent only. Otherwise, mouse events are targeted at aContent or its 1237 * descendants. That is, descendants of aContent receive mouse events as 1238 * they normally would, but mouse events outside of aContent are retargeted 1239 * to aContent. 1240 * 1241 * If CAPTURE_PREVENTDRAG is set then drags are prevented from starting while 1242 * this capture is active. 1243 * 1244 * If CAPTURE_POINTERLOCK is set, similar to CAPTURE_RETARGETTOELEMENT, then 1245 * events are targeted at aContent, but capturing is held more strongly (i.e., 1246 * calls to SetCapturingContent won't unlock unless CAPTURE_POINTERLOCK is 1247 * set again). 1248 */ 1249 static void SetCapturingContent(nsIContent* aContent, uint8_t aFlags); 1250 1251 /** 1252 * Return the active content currently capturing the mouse if any. 1253 */ GetCapturingContent()1254 static nsIContent* GetCapturingContent() { return gCaptureInfo.mContent; } 1255 1256 /** 1257 * Allow or disallow mouse capturing. 1258 */ AllowMouseCapture(bool aAllowed)1259 static void AllowMouseCapture(bool aAllowed) { 1260 gCaptureInfo.mAllowed = aAllowed; 1261 } 1262 1263 /** 1264 * Returns true if there is an active mouse capture that wants to prevent 1265 * drags. 1266 */ IsMouseCapturePreventingDrag()1267 static bool IsMouseCapturePreventingDrag() { 1268 return gCaptureInfo.mPreventDrag && gCaptureInfo.mContent; 1269 } 1270 1271 /** 1272 * Keep track of how many times this presshell has been rendered to 1273 * a window. 1274 */ GetPaintCount()1275 uint64_t GetPaintCount() { return mPaintCount; } IncrementPaintCount()1276 void IncrementPaintCount() { ++mPaintCount; } 1277 1278 /** 1279 * Get the root DOM window of this presShell. 1280 */ 1281 virtual already_AddRefed<nsPIDOMWindowOuter> GetRootWindow() = 0; 1282 1283 /** 1284 * This returns the focused DOM window under our top level window. 1285 * I.e., when we are deactive, this returns the *last* focused DOM window. 1286 */ 1287 virtual already_AddRefed<nsPIDOMWindowOuter> 1288 GetFocusedDOMWindowInOurWindow() = 0; 1289 1290 /** 1291 * Get the focused content under this window. 1292 */ 1293 already_AddRefed<nsIContent> GetFocusedContentInOurWindow() const; 1294 1295 /** 1296 * Get the layer manager for the widget of the root view, if it has 1297 * one. 1298 */ 1299 virtual LayerManager* GetLayerManager() = 0; 1300 1301 /** 1302 * Return true iff there is a widget rendering this presShell and that 1303 * widget is APZ-enabled. 1304 */ 1305 virtual bool AsyncPanZoomEnabled() = 0; 1306 1307 /** 1308 * Track whether we're ignoring viewport scrolling for the purposes 1309 * of painting. If we are ignoring, then layers aren't clipped to 1310 * the CSS viewport and scrollbars aren't drawn. 1311 */ 1312 virtual void SetIgnoreViewportScrolling(bool aIgnore) = 0; IgnoringViewportScrolling()1313 bool IgnoringViewportScrolling() const { 1314 return mRenderFlags & STATE_IGNORING_VIEWPORT_SCROLLING; 1315 } 1316 1317 /** 1318 * Set a "resolution" for the document, which if not 1.0 will 1319 * allocate more or fewer pixels for rescalable content by a factor 1320 * of |resolution| in both dimensions. Return NS_OK iff the 1321 * resolution bounds are sane, and the resolution of this was 1322 * actually updated. 1323 * 1324 * The resolution defaults to 1.0. 1325 */ 1326 virtual nsresult SetResolution(float aResolution) = 0; GetResolution()1327 float GetResolution() const { return mResolution.valueOr(1.0); } 1328 virtual float GetCumulativeResolution() = 0; 1329 1330 /** 1331 * Calculate the cumulative scale resolution from this document up to 1332 * but not including the root document. 1333 */ 1334 virtual float GetCumulativeNonRootScaleResolution() = 0; 1335 1336 /** 1337 * Was the current resolution set by the user or just default initialized? 1338 */ IsResolutionSet()1339 bool IsResolutionSet() { return mResolution.isSome(); } 1340 1341 /** 1342 * Similar to SetResolution() but also increases the scale of the content 1343 * by the same amount. 1344 */ 1345 virtual nsresult SetResolutionAndScaleTo(float aResolution) = 0; 1346 1347 /** 1348 * Return whether we are scaling to the set resolution. 1349 * This is initially false; it's set to true by a call to 1350 * SetResolutionAndScaleTo(), and set to false by a call to SetResolution(). 1351 */ 1352 virtual bool ScaleToResolution() const = 0; 1353 1354 /** 1355 * Used by session restore code to restore a resolution before the first 1356 * paint. 1357 */ 1358 virtual void SetRestoreResolution( 1359 float aResolution, mozilla::LayoutDeviceIntSize aDisplaySize) = 0; 1360 1361 /** 1362 * Returns whether we are in a DrawWindow() call that used the 1363 * DRAWWINDOW_DO_NOT_FLUSH flag. 1364 */ InDrawWindowNotFlushing()1365 bool InDrawWindowNotFlushing() const { 1366 return mRenderFlags & STATE_DRAWWINDOW_NOT_FLUSHING; 1367 } 1368 1369 /** 1370 * Set the isFirstPaint flag. 1371 */ SetIsFirstPaint(bool aIsFirstPaint)1372 void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; } 1373 1374 /** 1375 * Get the isFirstPaint flag. 1376 */ GetIsFirstPaint()1377 bool GetIsFirstPaint() const { return mIsFirstPaint; } 1378 GetPresShellId()1379 uint32_t GetPresShellId() { return mPresShellId; } 1380 1381 /** 1382 * Dispatch a mouse move event based on the most recent mouse position if 1383 * this PresShell is visible. This is used when the contents of the page 1384 * moved (aFromScroll is false) or scrolled (aFromScroll is true). 1385 */ 1386 virtual void SynthesizeMouseMove(bool aFromScroll) = 0; 1387 1388 enum PaintFlags { 1389 /* Update the layer tree and paint PaintedLayers. If this is not specified, 1390 * we may still have to do it if the layer tree lost PaintedLayer contents 1391 * we need for compositing. */ 1392 PAINT_LAYERS = 0x01, 1393 /* Composite layers to the window. */ 1394 PAINT_COMPOSITE = 0x02, 1395 /* Sync-decode images. */ 1396 PAINT_SYNC_DECODE_IMAGES = 0x04 1397 }; 1398 virtual void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, 1399 uint32_t aFlags) = 0; 1400 virtual nsresult HandleEvent(nsIFrame* aFrame, 1401 mozilla::WidgetGUIEvent* aEvent, 1402 bool aDontRetargetEvents, 1403 nsEventStatus* aEventStatus) = 0; 1404 virtual bool ShouldIgnoreInvalidation() = 0; 1405 /** 1406 * Notify that we're going to call Paint with PAINT_LAYERS 1407 * on the pres shell for a widget (which might not be this one, since 1408 * WillPaint is called on all presshells in the same toplevel window as the 1409 * painted widget). This is issued at a time when it's safe to modify 1410 * widget geometry. 1411 */ 1412 virtual void WillPaint() = 0; 1413 /** 1414 * Notify that we're going to call Paint with PAINT_COMPOSITE. 1415 * Fires on the presshell for the painted widget. 1416 * This is issued at a time when it's safe to modify widget geometry. 1417 */ 1418 virtual void WillPaintWindow() = 0; 1419 /** 1420 * Notify that we called Paint with PAINT_COMPOSITE. 1421 * Fires on the presshell for the painted widget. 1422 * This is issued at a time when it's safe to modify widget geometry. 1423 */ 1424 virtual void DidPaintWindow() = 0; 1425 1426 /** 1427 * Ensures that the refresh driver is running, and schedules a view 1428 * manager flush on the next tick. 1429 * 1430 * @param aType PAINT_DELAYED_COMPRESS : Schedule a paint to be executed after 1431 * a delay, and put FrameLayerBuilder in 'compressed' mode that avoids short 1432 * cut optimizations. 1433 */ 1434 enum PaintType { PAINT_DEFAULT, PAINT_DELAYED_COMPRESS }; 1435 virtual void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) = 0; 1436 virtual void ClearMouseCaptureOnView(nsView* aView) = 0; 1437 virtual bool IsVisible() = 0; 1438 virtual void DispatchSynthMouseMove(mozilla::WidgetGUIEvent* aEvent, 1439 bool aFlushOnHoverChange) = 0; 1440 1441 virtual void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const = 0; 1442 1443 /** 1444 * Methods that retrieve the cached font inflation preferences. 1445 */ FontSizeInflationEmPerLine()1446 uint32_t FontSizeInflationEmPerLine() const { 1447 return mFontSizeInflationEmPerLine; 1448 } 1449 FontSizeInflationMinTwips()1450 uint32_t FontSizeInflationMinTwips() const { 1451 return mFontSizeInflationMinTwips; 1452 } 1453 FontSizeInflationLineThreshold()1454 uint32_t FontSizeInflationLineThreshold() const { 1455 return mFontSizeInflationLineThreshold; 1456 } 1457 FontSizeInflationForceEnabled()1458 bool FontSizeInflationForceEnabled() const { 1459 return mFontSizeInflationForceEnabled; 1460 } 1461 FontSizeInflationDisabledInMasterProcess()1462 bool FontSizeInflationDisabledInMasterProcess() const { 1463 return mFontSizeInflationDisabledInMasterProcess; 1464 } 1465 FontSizeInflationEnabled()1466 bool FontSizeInflationEnabled() const { return mFontSizeInflationEnabled; } 1467 1468 /** 1469 * Recomputes whether font-size inflation is enabled. 1470 */ 1471 void RecomputeFontSizeInflationEnabled(); 1472 1473 /** 1474 * Return true if the most recent interruptible reflow was interrupted. 1475 */ IsReflowInterrupted()1476 bool IsReflowInterrupted() const { return mWasLastReflowInterrupted; } 1477 1478 /** 1479 * Return true if the the interruptible reflows have to be suppressed. 1480 * This may happen only if if the most recent reflow was interrupted. 1481 */ SuppressInterruptibleReflows()1482 bool SuppressInterruptibleReflows() const { 1483 return mWasLastReflowInterrupted; 1484 } 1485 1486 ////////////////////////////////////////////////////////////////////////////// 1487 // Approximate frame visibility tracking public API. 1488 ////////////////////////////////////////////////////////////////////////////// 1489 1490 /// Schedule an update of the list of approximately visible frames "soon". 1491 /// This lets the refresh driver know that we want a visibility update in the 1492 /// near future. The refresh driver applies its own heuristics and throttling 1493 /// to decide when to actually perform the visibility update. 1494 virtual void ScheduleApproximateFrameVisibilityUpdateSoon() = 0; 1495 1496 /// Schedule an update of the list of approximately visible frames "now". The 1497 /// update runs asynchronously, but it will be posted to the event loop 1498 /// immediately. Prefer the "soon" variation of this method when possible, as 1499 /// this variation ignores the refresh driver's heuristics. 1500 virtual void ScheduleApproximateFrameVisibilityUpdateNow() = 0; 1501 1502 /// Clears the current list of approximately visible frames on this pres shell 1503 /// and replaces it with frames that are in the display list @aList. 1504 virtual void RebuildApproximateFrameVisibilityDisplayList( 1505 const nsDisplayList& aList) = 0; 1506 virtual void RebuildApproximateFrameVisibility(nsRect* aRect = nullptr, 1507 bool aRemoveOnly = false) = 0; 1508 1509 /// Ensures @aFrame is in the list of approximately visible frames. 1510 virtual void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame) = 0; 1511 1512 /// Removes @aFrame from the list of approximately visible frames if present. 1513 virtual void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame) = 0; 1514 1515 /// Whether we should assume all frames are visible. 1516 virtual bool AssumeAllFramesVisible() = 0; 1517 1518 /** 1519 * Returns whether the document's style set's rule processor for the 1520 * specified level of the cascade is shared by multiple style sets. 1521 * 1522 * @param aSheetType One of the nsIStyleSheetService.*_SHEET constants. 1523 */ 1524 nsresult HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType, 1525 bool* aRetVal); 1526 1527 /** 1528 * Returns whether or not the document has ever handled user input 1529 */ 1530 virtual bool HasHandledUserInput() const = 0; 1531 1532 virtual void FireResizeEvent() = 0; 1533 1534 protected: 1535 /** 1536 * Refresh observer management. 1537 */ 1538 void DoObserveStyleFlushes(); 1539 void DoObserveLayoutFlushes(); 1540 1541 /** 1542 * Does the actual work of figuring out the current state of font size 1543 * inflation. 1544 */ 1545 bool DetermineFontSizeInflationState(); 1546 RecordAlloc(void * aPtr)1547 void RecordAlloc(void* aPtr) { 1548 #ifdef DEBUG 1549 MOZ_ASSERT(!mAllocatedPointers.Contains(aPtr)); 1550 mAllocatedPointers.PutEntry(aPtr); 1551 #endif 1552 } 1553 RecordFree(void * aPtr)1554 void RecordFree(void* aPtr) { 1555 #ifdef DEBUG 1556 MOZ_ASSERT(mAllocatedPointers.Contains(aPtr)); 1557 mAllocatedPointers.RemoveEntry(aPtr); 1558 #endif 1559 } 1560 1561 public: 1562 bool AddRefreshObserver(nsARefreshObserver* aObserver, 1563 mozilla::FlushType aFlushType); 1564 bool RemoveRefreshObserver(nsARefreshObserver* aObserver, 1565 mozilla::FlushType aFlushType); 1566 1567 virtual bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver); 1568 virtual bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver); 1569 1570 // If a frame in the subtree rooted at aFrame is capturing the mouse then 1571 // clears that capture. 1572 static void ClearMouseCapture(nsIFrame* aFrame); 1573 1574 void SetScrollPositionClampingScrollPortSize(nscoord aWidth, nscoord aHeight); IsScrollPositionClampingScrollPortSizeSet()1575 bool IsScrollPositionClampingScrollPortSizeSet() { 1576 return mScrollPositionClampingScrollPortSizeSet; 1577 } GetScrollPositionClampingScrollPortSize()1578 nsSize GetScrollPositionClampingScrollPortSize() { 1579 NS_ASSERTION(mScrollPositionClampingScrollPortSizeSet, 1580 "asking for scroll port when its not set?"); 1581 return mScrollPositionClampingScrollPortSize; 1582 } 1583 1584 virtual void WindowSizeMoveDone() = 0; 1585 virtual void SysColorChanged() = 0; 1586 virtual void ThemeChanged() = 0; 1587 virtual void BackingScaleFactorChanged() = 0; 1588 1589 /** 1590 * Documents belonging to an invisible DocShell must not be painted ever. 1591 */ IsNeverPainting()1592 bool IsNeverPainting() { return mIsNeverPainting; } 1593 SetNeverPainting(bool aNeverPainting)1594 void SetNeverPainting(bool aNeverPainting) { 1595 mIsNeverPainting = aNeverPainting; 1596 } 1597 1598 /** 1599 * True if a reflow event has been scheduled, or is going to be scheduled 1600 * to run in the future. 1601 */ HasPendingReflow()1602 bool HasPendingReflow() const { 1603 return mObservingLayoutFlushes || mReflowContinueTimer; 1604 } 1605 1606 void SyncWindowProperties(nsView* aView); 1607 1608 virtual nsIDocument* GetPrimaryContentDocument() = 0; 1609 1610 // aSheetType is one of the nsIStyleSheetService *_SHEET constants. 1611 virtual void NotifyStyleSheetServiceSheetAdded(mozilla::StyleSheet* aSheet, 1612 uint32_t aSheetType) = 0; 1613 virtual void NotifyStyleSheetServiceSheetRemoved(mozilla::StyleSheet* aSheet, 1614 uint32_t aSheetType) = 0; 1615 1616 protected: 1617 friend class nsRefreshDriver; 1618 1619 // IMPORTANT: The ownership implicit in the following member variables 1620 // has been explicitly checked. If you add any members to this class, 1621 // please make the ownership explicit (pinkerton, scc). 1622 1623 // These are the same Document and PresContext owned by the DocViewer. 1624 // we must share ownership. 1625 nsCOMPtr<nsIDocument> mDocument; 1626 RefPtr<nsPresContext> mPresContext; 1627 mozilla::StyleSetHandle mStyleSet; // [OWNS] 1628 nsCSSFrameConstructor* mFrameConstructor; // [OWNS] 1629 nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to 1630 nsPresArena mFrameArena; 1631 RefPtr<nsFrameSelection> mSelection; 1632 // Pointer into mFrameConstructor - this is purely so that GetRootFrame() can 1633 // be inlined: 1634 nsFrameManager* mFrameManager; 1635 mozilla::WeakPtr<nsDocShell> mForwardingContainer; 1636 #ifdef ACCESSIBILITY 1637 mozilla::a11y::DocAccessible* mDocAccessible; 1638 #endif 1639 1640 // At least on Win32 and Mac after interupting a reflow we need to post 1641 // the resume reflow event off a timer to avoid event starvation because 1642 // posted messages are processed before other messages when the modal 1643 // moving/sizing loop is running, see bug 491700 for details. 1644 nsCOMPtr<nsITimer> mReflowContinueTimer; 1645 1646 #ifdef DEBUG 1647 nsIFrame* mDrawEventTargetFrame; 1648 1649 // We track allocated pointers in a debug-only hashtable to assert against 1650 // missing/double frees. 1651 nsTHashtable<nsPtrHashKey<void>> mAllocatedPointers; 1652 #endif 1653 1654 // Count of the number of times this presshell has been painted to a window. 1655 uint64_t mPaintCount; 1656 1657 nsSize mScrollPositionClampingScrollPortSize; 1658 1659 // A list of stack weak frames. This is a pointer to the last item in the 1660 // list. 1661 AutoWeakFrame* mAutoWeakFrames; 1662 1663 // A hash table of heap allocated weak frames. 1664 nsTHashtable<nsPtrHashKey<WeakFrame>> mWeakFrames; 1665 1666 #ifdef MOZ_GECKO_PROFILER 1667 // These two fields capture call stacks of any changes that require a restyle 1668 // or a reflow. Only the first change per restyle / reflow is recorded (the 1669 // one that caused a call to SetNeedStyleFlush() / SetNeedLayoutFlush()). 1670 UniqueProfilerBacktrace mStyleCause; 1671 UniqueProfilerBacktrace mReflowCause; 1672 #endif 1673 1674 // Most recent canvas background color. 1675 nscolor mCanvasBackgroundColor; 1676 1677 // Used to force allocation and rendering of proportionally more or 1678 // less pixels in both dimensions. 1679 mozilla::Maybe<float> mResolution; 1680 1681 int16_t mSelectionFlags; 1682 1683 // This is used to protect ourselves from triggering reflow while in the 1684 // middle of frame construction and the like... it really shouldn't be 1685 // needed, one hopes, but it is for now. 1686 uint16_t mChangeNestCount; 1687 1688 // Flags controlling how our document is rendered. These persist 1689 // between paints and so are tied with retained layer pixels. 1690 // PresShell flushes retained layers when the rendering state 1691 // changes in a way that prevents us from being able to (usefully) 1692 // re-use old pixels. 1693 RenderFlags mRenderFlags; 1694 bool mDidInitialize : 1; 1695 bool mIsDestroying : 1; 1696 bool mIsReflowing : 1; 1697 bool mIsObservingDocument : 1; 1698 1699 // We've been disconnected from the document. We will refuse to paint the 1700 // document until either our timer fires or all frames are constructed. 1701 bool mIsDocumentGone : 1; 1702 1703 // For all documents we initially lock down painting. 1704 bool mPaintingSuppressed : 1; 1705 1706 bool mIsActive : 1; 1707 bool mFrozen : 1; 1708 bool mIsFirstPaint : 1; 1709 bool mObservesMutationsForPrint : 1; 1710 1711 // Whether the most recent interruptible reflow was actually interrupted: 1712 bool mWasLastReflowInterrupted : 1; 1713 bool mScrollPositionClampingScrollPortSizeSet : 1; 1714 1715 // True if a layout flush might not be a no-op 1716 bool mNeedLayoutFlush : 1; 1717 1718 // True if a style flush might not be a no-op 1719 bool mNeedStyleFlush : 1; 1720 1721 // True if we're observing the refresh driver for style flushes. 1722 bool mObservingStyleFlushes : 1; 1723 1724 // True if we're observing the refresh driver for layout flushes, that is, if 1725 // we have a reflow scheduled. 1726 // 1727 // Guaranteed to be false if mReflowContinueTimer is non-null. 1728 bool mObservingLayoutFlushes : 1; 1729 1730 // True if there are throttled animations that would be processed when 1731 // performing a flush with mFlushAnimations == true. 1732 bool mNeedThrottledAnimationFlush : 1; 1733 1734 uint32_t mPresShellId; 1735 1736 static nsIContent* gKeyDownTarget; 1737 1738 // Cached font inflation values. This is done to prevent changing of font 1739 // inflation until a page is reloaded. 1740 uint32_t mFontSizeInflationEmPerLine; 1741 uint32_t mFontSizeInflationMinTwips; 1742 uint32_t mFontSizeInflationLineThreshold; 1743 bool mFontSizeInflationForceEnabled; 1744 bool mFontSizeInflationDisabledInMasterProcess; 1745 bool mFontSizeInflationEnabled; 1746 1747 // Dirty bit indicating that mFontSizeInflationEnabled needs to be recomputed. 1748 bool mFontSizeInflationEnabledIsDirty; 1749 1750 bool mPaintingIsFrozen; 1751 1752 // If a document belongs to an invisible DocShell, this flag must be set 1753 // to true, so we can avoid any paint calls for widget related to this 1754 // presshell. 1755 bool mIsNeverPainting; 1756 1757 // Whether we're currently under a FlushPendingNotifications. 1758 // This is used to handle flush reentry correctly. 1759 bool mInFlush; 1760 }; 1761 1762 NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell, NS_IPRESSHELL_IID) 1763 1764 #endif /* nsIPresShell_h___ */ 1765