Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 5 | * |
michael@0 | 6 | * This Original Code has been modified by IBM Corporation. |
michael@0 | 7 | * Modifications made by IBM described herein are |
michael@0 | 8 | * Copyright (c) International Business Machines |
michael@0 | 9 | * Corporation, 2000 |
michael@0 | 10 | * |
michael@0 | 11 | * Modifications to Mozilla code or documentation |
michael@0 | 12 | * identified per MPL Section 3.3 |
michael@0 | 13 | * |
michael@0 | 14 | * Date Modified by Description of modification |
michael@0 | 15 | * 05/03/2000 IBM Corp. Observer related defines for reflow |
michael@0 | 16 | */ |
michael@0 | 17 | |
michael@0 | 18 | /* a presentation of a document, part 2 */ |
michael@0 | 19 | |
michael@0 | 20 | #ifndef nsIPresShell_h___ |
michael@0 | 21 | #define nsIPresShell_h___ |
michael@0 | 22 | |
michael@0 | 23 | #include "mozilla/EventForwards.h" |
michael@0 | 24 | #include "mozilla/MemoryReporting.h" |
michael@0 | 25 | #include "mozilla/WeakPtr.h" |
michael@0 | 26 | #include "gfxPoint.h" |
michael@0 | 27 | #include "nsTHashtable.h" |
michael@0 | 28 | #include "nsHashKeys.h" |
michael@0 | 29 | #include "nsISupports.h" |
michael@0 | 30 | #include "nsQueryFrame.h" |
michael@0 | 31 | #include "nsCoord.h" |
michael@0 | 32 | #include "nsColor.h" |
michael@0 | 33 | #include "nsCompatibility.h" |
michael@0 | 34 | #include "nsFrameManagerBase.h" |
michael@0 | 35 | #include "mozFlushType.h" |
michael@0 | 36 | #include "nsWeakReference.h" |
michael@0 | 37 | #include <stdio.h> // for FILE definition |
michael@0 | 38 | #include "nsChangeHint.h" |
michael@0 | 39 | #include "nsRefPtrHashtable.h" |
michael@0 | 40 | #include "nsClassHashtable.h" |
michael@0 | 41 | #include "nsPresArena.h" |
michael@0 | 42 | #include "nsIImageLoadingContent.h" |
michael@0 | 43 | #include "nsMargin.h" |
michael@0 | 44 | #include "nsFrameState.h" |
michael@0 | 45 | |
michael@0 | 46 | class nsIContent; |
michael@0 | 47 | class nsDocShell; |
michael@0 | 48 | class nsIDocument; |
michael@0 | 49 | class nsIFrame; |
michael@0 | 50 | class nsPresContext; |
michael@0 | 51 | class nsStyleSet; |
michael@0 | 52 | class nsViewManager; |
michael@0 | 53 | class nsView; |
michael@0 | 54 | class nsRenderingContext; |
michael@0 | 55 | class nsIPageSequenceFrame; |
michael@0 | 56 | class nsAString; |
michael@0 | 57 | class nsCaret; |
michael@0 | 58 | class nsFrameSelection; |
michael@0 | 59 | class nsFrameManager; |
michael@0 | 60 | class nsILayoutHistoryState; |
michael@0 | 61 | class nsIReflowCallback; |
michael@0 | 62 | class nsIDOMNode; |
michael@0 | 63 | class nsIntRegion; |
michael@0 | 64 | class nsIStyleSheet; |
michael@0 | 65 | class nsCSSFrameConstructor; |
michael@0 | 66 | class nsISelection; |
michael@0 | 67 | template<class E> class nsCOMArray; |
michael@0 | 68 | class nsWeakFrame; |
michael@0 | 69 | class nsIScrollableFrame; |
michael@0 | 70 | class gfxContext; |
michael@0 | 71 | class nsIDOMEvent; |
michael@0 | 72 | class nsDisplayList; |
michael@0 | 73 | class nsDisplayListBuilder; |
michael@0 | 74 | class nsPIDOMWindow; |
michael@0 | 75 | struct nsPoint; |
michael@0 | 76 | struct nsIntPoint; |
michael@0 | 77 | struct nsIntRect; |
michael@0 | 78 | struct nsRect; |
michael@0 | 79 | class nsRegion; |
michael@0 | 80 | class nsRefreshDriver; |
michael@0 | 81 | class nsARefreshObserver; |
michael@0 | 82 | class nsAPostRefreshObserver; |
michael@0 | 83 | #ifdef ACCESSIBILITY |
michael@0 | 84 | class nsAccessibilityService; |
michael@0 | 85 | namespace mozilla { |
michael@0 | 86 | namespace a11y { |
michael@0 | 87 | class DocAccessible; |
michael@0 | 88 | } // namespace a11y |
michael@0 | 89 | } // namespace mozilla |
michael@0 | 90 | #endif |
michael@0 | 91 | class nsIWidget; |
michael@0 | 92 | struct nsArenaMemoryStats; |
michael@0 | 93 | |
michael@0 | 94 | typedef short SelectionType; |
michael@0 | 95 | |
michael@0 | 96 | namespace mozilla { |
michael@0 | 97 | class EventStates; |
michael@0 | 98 | |
michael@0 | 99 | namespace dom { |
michael@0 | 100 | class Element; |
michael@0 | 101 | class Touch; |
michael@0 | 102 | class Selection; |
michael@0 | 103 | class ShadowRoot; |
michael@0 | 104 | } // namespace dom |
michael@0 | 105 | |
michael@0 | 106 | namespace layers { |
michael@0 | 107 | class LayerManager; |
michael@0 | 108 | } // namespace layers |
michael@0 | 109 | |
michael@0 | 110 | namespace gfx { |
michael@0 | 111 | class SourceSurface; |
michael@0 | 112 | } // namespace gfx |
michael@0 | 113 | } // namespace mozilla |
michael@0 | 114 | |
michael@0 | 115 | // Flags to pass to SetCapturingContent |
michael@0 | 116 | // |
michael@0 | 117 | // when assigning capture, ignore whether capture is allowed or not |
michael@0 | 118 | #define CAPTURE_IGNOREALLOWED 1 |
michael@0 | 119 | // true if events should be targeted at the capturing content or its children |
michael@0 | 120 | #define CAPTURE_RETARGETTOELEMENT 2 |
michael@0 | 121 | // true if the current capture wants drags to be prevented |
michael@0 | 122 | #define CAPTURE_PREVENTDRAG 4 |
michael@0 | 123 | // true when the mouse is pointer locked, and events are sent to locked element |
michael@0 | 124 | #define CAPTURE_POINTERLOCK 8 |
michael@0 | 125 | |
michael@0 | 126 | typedef struct CapturingContentInfo { |
michael@0 | 127 | // capture should only be allowed during a mousedown event |
michael@0 | 128 | bool mAllowed; |
michael@0 | 129 | bool mPointerLock; |
michael@0 | 130 | bool mRetargetToElement; |
michael@0 | 131 | bool mPreventDrag; |
michael@0 | 132 | nsIContent* mContent; |
michael@0 | 133 | } CapturingContentInfo; |
michael@0 | 134 | |
michael@0 | 135 | //61e60df7-128a-4cdd-a684-5f0bd2ceb61f |
michael@0 | 136 | #define NS_IPRESSHELL_IID \ |
michael@0 | 137 | { 0x61e60df7, 0x128a, 0x4cdd, \ |
michael@0 | 138 | {0xa6, 0x84, 0x5f, 0x0b, 0xd2, 0xce, 0xb6, 0x1f}} |
michael@0 | 139 | |
michael@0 | 140 | // debug VerifyReflow flags |
michael@0 | 141 | #define VERIFY_REFLOW_ON 0x01 |
michael@0 | 142 | #define VERIFY_REFLOW_NOISY 0x02 |
michael@0 | 143 | #define VERIFY_REFLOW_ALL 0x04 |
michael@0 | 144 | #define VERIFY_REFLOW_DUMP_COMMANDS 0x08 |
michael@0 | 145 | #define VERIFY_REFLOW_NOISY_RC 0x10 |
michael@0 | 146 | #define VERIFY_REFLOW_REALLY_NOISY_RC 0x20 |
michael@0 | 147 | #define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x40 |
michael@0 | 148 | |
michael@0 | 149 | #undef NOISY_INTERRUPTIBLE_REFLOW |
michael@0 | 150 | |
michael@0 | 151 | enum nsRectVisibility { |
michael@0 | 152 | nsRectVisibility_kVisible, |
michael@0 | 153 | nsRectVisibility_kAboveViewport, |
michael@0 | 154 | nsRectVisibility_kBelowViewport, |
michael@0 | 155 | nsRectVisibility_kLeftOfViewport, |
michael@0 | 156 | nsRectVisibility_kRightOfViewport |
michael@0 | 157 | }; |
michael@0 | 158 | |
michael@0 | 159 | /** |
michael@0 | 160 | * Presentation shell interface. Presentation shells are the |
michael@0 | 161 | * controlling point for managing the presentation of a document. The |
michael@0 | 162 | * presentation shell holds a live reference to the document, the |
michael@0 | 163 | * presentation context, the style manager, the style set and the root |
michael@0 | 164 | * frame. <p> |
michael@0 | 165 | * |
michael@0 | 166 | * When this object is Release'd, it will release the document, the |
michael@0 | 167 | * presentation context, the style manager, the style set and the root |
michael@0 | 168 | * frame. |
michael@0 | 169 | */ |
michael@0 | 170 | |
michael@0 | 171 | class nsIPresShell : public nsISupports |
michael@0 | 172 | { |
michael@0 | 173 | public: |
michael@0 | 174 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID) |
michael@0 | 175 | |
michael@0 | 176 | protected: |
michael@0 | 177 | typedef mozilla::layers::LayerManager LayerManager; |
michael@0 | 178 | typedef mozilla::gfx::SourceSurface SourceSurface; |
michael@0 | 179 | |
michael@0 | 180 | enum eRenderFlag { |
michael@0 | 181 | STATE_IGNORING_VIEWPORT_SCROLLING = 0x1, |
michael@0 | 182 | STATE_DRAWWINDOW_NOT_FLUSHING = 0x2 |
michael@0 | 183 | }; |
michael@0 | 184 | typedef uint8_t RenderFlags; // for storing the above flags |
michael@0 | 185 | |
michael@0 | 186 | public: |
michael@0 | 187 | /** |
michael@0 | 188 | * All callers are responsible for calling |Destroy| after calling |
michael@0 | 189 | * |EndObservingDocument|. It needs to be separate only because form |
michael@0 | 190 | * controls incorrectly store their data in the frames rather than the |
michael@0 | 191 | * content model and printing calls |EndObservingDocument| multiple |
michael@0 | 192 | * times to make form controls behave nicely when printed. |
michael@0 | 193 | */ |
michael@0 | 194 | virtual NS_HIDDEN_(void) Destroy() = 0; |
michael@0 | 195 | |
michael@0 | 196 | bool IsDestroying() { return mIsDestroying; } |
michael@0 | 197 | |
michael@0 | 198 | /** |
michael@0 | 199 | * Make a one-way transition into a "zombie" state. In this state, |
michael@0 | 200 | * no reflow is done, no painting is done, and no refresh driver |
michael@0 | 201 | * ticks are processed. This is a dangerous state: it can leave |
michael@0 | 202 | * areas of the composition target unpainted if callers aren't |
michael@0 | 203 | * careful. (Don't let your zombie presshell out of the shed.) |
michael@0 | 204 | * |
michael@0 | 205 | * This is used in cases where a presshell is created for reasons |
michael@0 | 206 | * other than reflow/painting. |
michael@0 | 207 | */ |
michael@0 | 208 | virtual NS_HIDDEN_(void) MakeZombie() = 0; |
michael@0 | 209 | |
michael@0 | 210 | /** |
michael@0 | 211 | * All frames owned by the shell are allocated from an arena. They |
michael@0 | 212 | * are also recycled using free lists. Separate free lists are |
michael@0 | 213 | * maintained for each frame type (aID), which must always correspond |
michael@0 | 214 | * to the same aSize value. AllocateFrame returns zero-filled memory. |
michael@0 | 215 | * AllocateFrame is infallible and will abort on out-of-memory. |
michael@0 | 216 | */ |
michael@0 | 217 | void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize) |
michael@0 | 218 | { |
michael@0 | 219 | #ifdef DEBUG |
michael@0 | 220 | mPresArenaAllocCount++; |
michael@0 | 221 | #endif |
michael@0 | 222 | void* result = mFrameArena.AllocateByFrameID(aID, aSize); |
michael@0 | 223 | memset(result, 0, aSize); |
michael@0 | 224 | return result; |
michael@0 | 225 | } |
michael@0 | 226 | |
michael@0 | 227 | void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr) |
michael@0 | 228 | { |
michael@0 | 229 | #ifdef DEBUG |
michael@0 | 230 | mPresArenaAllocCount--; |
michael@0 | 231 | #endif |
michael@0 | 232 | if (!mIsDestroying) |
michael@0 | 233 | mFrameArena.FreeByFrameID(aID, aPtr); |
michael@0 | 234 | } |
michael@0 | 235 | |
michael@0 | 236 | /** |
michael@0 | 237 | * This is for allocating other types of objects (not frames). Separate free |
michael@0 | 238 | * lists are maintained for each type (aID), which must always correspond to |
michael@0 | 239 | * the same aSize value. AllocateByObjectID returns zero-filled memory. |
michael@0 | 240 | * AllocateByObjectID is infallible and will abort on out-of-memory. |
michael@0 | 241 | */ |
michael@0 | 242 | void* AllocateByObjectID(nsPresArena::ObjectID aID, size_t aSize) |
michael@0 | 243 | { |
michael@0 | 244 | #ifdef DEBUG |
michael@0 | 245 | mPresArenaAllocCount++; |
michael@0 | 246 | #endif |
michael@0 | 247 | void* result = mFrameArena.AllocateByObjectID(aID, aSize); |
michael@0 | 248 | memset(result, 0, aSize); |
michael@0 | 249 | return result; |
michael@0 | 250 | } |
michael@0 | 251 | |
michael@0 | 252 | void FreeByObjectID(nsPresArena::ObjectID aID, void* aPtr) |
michael@0 | 253 | { |
michael@0 | 254 | #ifdef DEBUG |
michael@0 | 255 | mPresArenaAllocCount--; |
michael@0 | 256 | #endif |
michael@0 | 257 | if (!mIsDestroying) |
michael@0 | 258 | mFrameArena.FreeByObjectID(aID, aPtr); |
michael@0 | 259 | } |
michael@0 | 260 | |
michael@0 | 261 | /** |
michael@0 | 262 | * Other objects closely related to the frame tree that are allocated |
michael@0 | 263 | * from a separate set of per-size free lists. Note that different types |
michael@0 | 264 | * of objects that has the same size are allocated from the same list. |
michael@0 | 265 | * AllocateMisc does *not* clear the memory that it returns. |
michael@0 | 266 | * AllocateMisc is infallible and will abort on out-of-memory. |
michael@0 | 267 | * |
michael@0 | 268 | * @deprecated use AllocateByObjectID/FreeByObjectID instead |
michael@0 | 269 | */ |
michael@0 | 270 | void* AllocateMisc(size_t aSize) |
michael@0 | 271 | { |
michael@0 | 272 | #ifdef DEBUG |
michael@0 | 273 | mPresArenaAllocCount++; |
michael@0 | 274 | #endif |
michael@0 | 275 | return mFrameArena.AllocateBySize(aSize); |
michael@0 | 276 | } |
michael@0 | 277 | |
michael@0 | 278 | void FreeMisc(size_t aSize, void* aPtr) |
michael@0 | 279 | { |
michael@0 | 280 | #ifdef DEBUG |
michael@0 | 281 | mPresArenaAllocCount--; |
michael@0 | 282 | #endif |
michael@0 | 283 | if (!mIsDestroying) |
michael@0 | 284 | mFrameArena.FreeBySize(aSize, aPtr); |
michael@0 | 285 | } |
michael@0 | 286 | |
michael@0 | 287 | nsIDocument* GetDocument() const { return mDocument; } |
michael@0 | 288 | |
michael@0 | 289 | nsPresContext* GetPresContext() const { return mPresContext; } |
michael@0 | 290 | |
michael@0 | 291 | nsViewManager* GetViewManager() const { return mViewManager; } |
michael@0 | 292 | |
michael@0 | 293 | #ifdef ACCESSIBILITY |
michael@0 | 294 | /** |
michael@0 | 295 | * Return the document accessible for this pres shell if there is one. |
michael@0 | 296 | */ |
michael@0 | 297 | mozilla::a11y::DocAccessible* GetDocAccessible() const |
michael@0 | 298 | { |
michael@0 | 299 | return mDocAccessible; |
michael@0 | 300 | } |
michael@0 | 301 | |
michael@0 | 302 | /** |
michael@0 | 303 | * Set the document accessible for this pres shell. |
michael@0 | 304 | */ |
michael@0 | 305 | void SetDocAccessible(mozilla::a11y::DocAccessible* aDocAccessible) |
michael@0 | 306 | { |
michael@0 | 307 | mDocAccessible = aDocAccessible; |
michael@0 | 308 | } |
michael@0 | 309 | #endif |
michael@0 | 310 | |
michael@0 | 311 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 312 | nsStyleSet* StyleSet() const { return mStyleSet; } |
michael@0 | 313 | |
michael@0 | 314 | nsCSSFrameConstructor* FrameConstructor() const { return mFrameConstructor; } |
michael@0 | 315 | |
michael@0 | 316 | nsFrameManager* FrameManager() const { |
michael@0 | 317 | // reinterpret_cast is valid since nsFrameManager does not add |
michael@0 | 318 | // any members over nsFrameManagerBase. |
michael@0 | 319 | return reinterpret_cast<nsFrameManager*> |
michael@0 | 320 | (const_cast<nsIPresShell*>(this)->mFrameManager); |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | #endif |
michael@0 | 324 | |
michael@0 | 325 | /* Enable/disable author style level. Disabling author style disables the entire |
michael@0 | 326 | * author level of the cascade, including the HTML preshint level. |
michael@0 | 327 | */ |
michael@0 | 328 | // XXX these could easily be inlined, but there is a circular #include |
michael@0 | 329 | // problem with nsStyleSet. |
michael@0 | 330 | NS_HIDDEN_(void) SetAuthorStyleDisabled(bool aDisabled); |
michael@0 | 331 | NS_HIDDEN_(bool) GetAuthorStyleDisabled() const; |
michael@0 | 332 | |
michael@0 | 333 | /* |
michael@0 | 334 | * Called when stylesheets are added/removed/enabled/disabled to rebuild |
michael@0 | 335 | * all style data for a given pres shell without necessarily reconstructing |
michael@0 | 336 | * all of the frames. This will not reconstruct style synchronously; if |
michael@0 | 337 | * you need to do that, call FlushPendingNotifications to flush out style |
michael@0 | 338 | * reresolves. |
michael@0 | 339 | * // XXXbz why do we have this on the interface anyway? The only consumer |
michael@0 | 340 | * is calling AddOverrideStyleSheet/RemoveOverrideStyleSheet, and I think |
michael@0 | 341 | * those should just handle reconstructing style data... |
michael@0 | 342 | */ |
michael@0 | 343 | virtual NS_HIDDEN_(void) ReconstructStyleDataExternal(); |
michael@0 | 344 | NS_HIDDEN_(void) ReconstructStyleDataInternal(); |
michael@0 | 345 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 346 | void ReconstructStyleData() { ReconstructStyleDataInternal(); } |
michael@0 | 347 | #else |
michael@0 | 348 | void ReconstructStyleData() { ReconstructStyleDataExternal(); } |
michael@0 | 349 | #endif |
michael@0 | 350 | |
michael@0 | 351 | /** Setup all style rules required to implement preferences |
michael@0 | 352 | * - used for background/text/link colors and link underlining |
michael@0 | 353 | * may be extended for any prefs that are implemented via style rules |
michael@0 | 354 | * - aForceReflow argument is used to force a full reframe to make the rules show |
michael@0 | 355 | * (only used when the current page needs to reflect changed pref rules) |
michael@0 | 356 | * |
michael@0 | 357 | * - initially created for bugs 31816, 20760, 22963 |
michael@0 | 358 | */ |
michael@0 | 359 | virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(bool aForceReflow) = 0; |
michael@0 | 360 | |
michael@0 | 361 | /** |
michael@0 | 362 | * FrameSelection will return the Frame based selection API. |
michael@0 | 363 | * You cannot go back and forth anymore with QI between nsIDOM sel and |
michael@0 | 364 | * nsIFrame sel. |
michael@0 | 365 | */ |
michael@0 | 366 | already_AddRefed<nsFrameSelection> FrameSelection(); |
michael@0 | 367 | |
michael@0 | 368 | /** |
michael@0 | 369 | * ConstFrameSelection returns an object which methods are safe to use for |
michael@0 | 370 | * example in nsIFrame code. |
michael@0 | 371 | */ |
michael@0 | 372 | const nsFrameSelection* ConstFrameSelection() const { return mSelection; } |
michael@0 | 373 | |
michael@0 | 374 | // Make shell be a document observer. If called after Destroy() has |
michael@0 | 375 | // been called on the shell, this will be ignored. |
michael@0 | 376 | virtual NS_HIDDEN_(void) BeginObservingDocument() = 0; |
michael@0 | 377 | |
michael@0 | 378 | // Make shell stop being a document observer |
michael@0 | 379 | virtual NS_HIDDEN_(void) EndObservingDocument() = 0; |
michael@0 | 380 | |
michael@0 | 381 | /** |
michael@0 | 382 | * Return whether Initialize() was previously called. |
michael@0 | 383 | */ |
michael@0 | 384 | bool DidInitialize() const { return mDidInitialize; } |
michael@0 | 385 | |
michael@0 | 386 | /** |
michael@0 | 387 | * Perform initialization. Constructs the frame for the root content |
michael@0 | 388 | * object and then enqueues a reflow of the frame model into the |
michael@0 | 389 | * specified width and height. |
michael@0 | 390 | * |
michael@0 | 391 | * The coordinates for aWidth and aHeight must be in standard nscoords. |
michael@0 | 392 | * |
michael@0 | 393 | * Callers of this method must hold a reference to this shell that |
michael@0 | 394 | * is guaranteed to survive through arbitrary script execution. |
michael@0 | 395 | * Calling Initialize can execute arbitrary script. |
michael@0 | 396 | */ |
michael@0 | 397 | virtual NS_HIDDEN_(nsresult) Initialize(nscoord aWidth, nscoord aHeight) = 0; |
michael@0 | 398 | |
michael@0 | 399 | /** |
michael@0 | 400 | * Reflow the frame model into a new width and height. The |
michael@0 | 401 | * coordinates for aWidth and aHeight must be in standard nscoord's. |
michael@0 | 402 | */ |
michael@0 | 403 | virtual NS_HIDDEN_(nsresult) ResizeReflow(nscoord aWidth, nscoord aHeight) = 0; |
michael@0 | 404 | /** |
michael@0 | 405 | * Reflow, and also change presshell state so as to only permit |
michael@0 | 406 | * reflowing off calls to ResizeReflowOverride() in the future. |
michael@0 | 407 | * ResizeReflow() calls are ignored after ResizeReflowOverride(). |
michael@0 | 408 | */ |
michael@0 | 409 | virtual NS_HIDDEN_(nsresult) ResizeReflowOverride(nscoord aWidth, nscoord aHeight) = 0; |
michael@0 | 410 | |
michael@0 | 411 | /** |
michael@0 | 412 | * Returns true if ResizeReflowOverride has been called. |
michael@0 | 413 | */ |
michael@0 | 414 | virtual bool GetIsViewportOverridden() = 0; |
michael@0 | 415 | |
michael@0 | 416 | /** |
michael@0 | 417 | * Return true if the presshell expects layout flush. |
michael@0 | 418 | */ |
michael@0 | 419 | virtual bool IsLayoutFlushObserver() = 0; |
michael@0 | 420 | |
michael@0 | 421 | /** |
michael@0 | 422 | * Called when document load completes. |
michael@0 | 423 | */ |
michael@0 | 424 | virtual NS_HIDDEN_(void) LoadComplete() = 0; |
michael@0 | 425 | |
michael@0 | 426 | /** |
michael@0 | 427 | * This calls through to the frame manager to get the root frame. |
michael@0 | 428 | */ |
michael@0 | 429 | virtual NS_HIDDEN_(nsIFrame*) GetRootFrameExternal() const; |
michael@0 | 430 | nsIFrame* GetRootFrame() const { |
michael@0 | 431 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 432 | return mFrameManager->GetRootFrame(); |
michael@0 | 433 | #else |
michael@0 | 434 | return GetRootFrameExternal(); |
michael@0 | 435 | #endif |
michael@0 | 436 | } |
michael@0 | 437 | |
michael@0 | 438 | /* |
michael@0 | 439 | * Get root scroll frame from FrameManager()->GetRootFrame(). |
michael@0 | 440 | */ |
michael@0 | 441 | nsIFrame* GetRootScrollFrame() const; |
michael@0 | 442 | |
michael@0 | 443 | /* |
michael@0 | 444 | * The same as GetRootScrollFrame, but returns an nsIScrollableFrame |
michael@0 | 445 | */ |
michael@0 | 446 | nsIScrollableFrame* GetRootScrollFrameAsScrollable() const; |
michael@0 | 447 | |
michael@0 | 448 | /* |
michael@0 | 449 | * The same as GetRootScrollFrame, but returns an nsIScrollableFrame. |
michael@0 | 450 | * Can be called by code not linked into gklayout. |
michael@0 | 451 | */ |
michael@0 | 452 | virtual nsIScrollableFrame* GetRootScrollFrameAsScrollableExternal() const; |
michael@0 | 453 | |
michael@0 | 454 | /* |
michael@0 | 455 | * Gets nearest scrollable frame from current focused content or DOM |
michael@0 | 456 | * selection if there is no focused content. The frame is scrollable with |
michael@0 | 457 | * overflow:scroll or overflow:auto in some direction when aDirection is |
michael@0 | 458 | * eEither. Otherwise, this returns a nearest frame that is scrollable in |
michael@0 | 459 | * the specified direction. |
michael@0 | 460 | */ |
michael@0 | 461 | enum ScrollDirection { eHorizontal, eVertical, eEither }; |
michael@0 | 462 | nsIScrollableFrame* GetFrameToScrollAsScrollable(ScrollDirection aDirection); |
michael@0 | 463 | |
michael@0 | 464 | /** |
michael@0 | 465 | * Returns the page sequence frame associated with the frame hierarchy. |
michael@0 | 466 | * Returns nullptr if not a paginated view. |
michael@0 | 467 | */ |
michael@0 | 468 | virtual NS_HIDDEN_(nsIPageSequenceFrame*) GetPageSequenceFrame() const = 0; |
michael@0 | 469 | |
michael@0 | 470 | /** |
michael@0 | 471 | * Gets the real primary frame associated with the content object. |
michael@0 | 472 | * |
michael@0 | 473 | * In the case of absolutely positioned elements and floated elements, |
michael@0 | 474 | * the real primary frame is the frame that is out of the flow and not the |
michael@0 | 475 | * placeholder frame. |
michael@0 | 476 | */ |
michael@0 | 477 | virtual NS_HIDDEN_(nsIFrame*) GetRealPrimaryFrameFor(nsIContent* aContent) const = 0; |
michael@0 | 478 | |
michael@0 | 479 | /** |
michael@0 | 480 | * Gets the placeholder frame associated with the specified frame. This is |
michael@0 | 481 | * a helper frame that forwards the request to the frame manager. |
michael@0 | 482 | */ |
michael@0 | 483 | virtual NS_HIDDEN_(nsIFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame) const = 0; |
michael@0 | 484 | |
michael@0 | 485 | /** |
michael@0 | 486 | * Tell the pres shell that a frame needs to be marked dirty and needs |
michael@0 | 487 | * Reflow. It's OK if this is an ancestor of the frame needing reflow as |
michael@0 | 488 | * long as the ancestor chain between them doesn't cross a reflow root. |
michael@0 | 489 | * |
michael@0 | 490 | * The bit to add should be NS_FRAME_IS_DIRTY, NS_FRAME_HAS_DIRTY_CHILDREN |
michael@0 | 491 | * or nsFrameState(0); passing 0 means that dirty bits won't be set on the |
michael@0 | 492 | * frame or its ancestors/descendants, but that intrinsic widths will still |
michael@0 | 493 | * be marked dirty. Passing aIntrinsicDirty = eResize and aBitToAdd = 0 |
michael@0 | 494 | * would result in no work being done, so don't do that. |
michael@0 | 495 | */ |
michael@0 | 496 | enum IntrinsicDirty { |
michael@0 | 497 | // XXXldb eResize should be renamed |
michael@0 | 498 | eResize, // don't mark any intrinsic widths dirty |
michael@0 | 499 | eTreeChange, // mark intrinsic widths dirty on aFrame and its ancestors |
michael@0 | 500 | eStyleChange // Do eTreeChange, plus all of aFrame's descendants |
michael@0 | 501 | }; |
michael@0 | 502 | virtual NS_HIDDEN_(void) FrameNeedsReflow(nsIFrame *aFrame, |
michael@0 | 503 | IntrinsicDirty aIntrinsicDirty, |
michael@0 | 504 | nsFrameState aBitToAdd) = 0; |
michael@0 | 505 | |
michael@0 | 506 | /** |
michael@0 | 507 | * Calls FrameNeedsReflow on all fixed position children of the root frame. |
michael@0 | 508 | */ |
michael@0 | 509 | virtual void MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty); |
michael@0 | 510 | |
michael@0 | 511 | /** |
michael@0 | 512 | * Tell the presshell that the given frame's reflow was interrupted. This |
michael@0 | 513 | * will mark as having dirty children a path from the given frame (inclusive) |
michael@0 | 514 | * to the nearest ancestor with a dirty subtree, or to the reflow root |
michael@0 | 515 | * currently being reflowed if no such ancestor exists (inclusive). This is |
michael@0 | 516 | * to be done immediately after reflow of the current reflow root completes. |
michael@0 | 517 | * This method must only be called during reflow, and the frame it's being |
michael@0 | 518 | * called on must be in the process of being reflowed when it's called. This |
michael@0 | 519 | * method doesn't mark any intrinsic widths dirty and doesn't add any bits |
michael@0 | 520 | * other than NS_FRAME_HAS_DIRTY_CHILDREN. |
michael@0 | 521 | */ |
michael@0 | 522 | virtual NS_HIDDEN_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame) = 0; |
michael@0 | 523 | |
michael@0 | 524 | virtual NS_HIDDEN_(void) CancelAllPendingReflows() = 0; |
michael@0 | 525 | |
michael@0 | 526 | /** |
michael@0 | 527 | * Recreates the frames for a node |
michael@0 | 528 | */ |
michael@0 | 529 | virtual NS_HIDDEN_(nsresult) RecreateFramesFor(nsIContent* aContent) = 0; |
michael@0 | 530 | |
michael@0 | 531 | void PostRecreateFramesFor(mozilla::dom::Element* aElement); |
michael@0 | 532 | void RestyleForAnimation(mozilla::dom::Element* aElement, |
michael@0 | 533 | nsRestyleHint aHint); |
michael@0 | 534 | |
michael@0 | 535 | // ShadowRoot has APIs that can change styles so we only |
michael@0 | 536 | // want to restyle elements in the ShadowRoot and not the whole |
michael@0 | 537 | // document. |
michael@0 | 538 | virtual void RestyleShadowRoot(mozilla::dom::ShadowRoot* aShadowRoot) = 0; |
michael@0 | 539 | |
michael@0 | 540 | /** |
michael@0 | 541 | * Determine if it is safe to flush all pending notifications |
michael@0 | 542 | * @param aIsSafeToFlush true if it is safe, false otherwise. |
michael@0 | 543 | * |
michael@0 | 544 | */ |
michael@0 | 545 | virtual NS_HIDDEN_(bool) IsSafeToFlush() const = 0; |
michael@0 | 546 | |
michael@0 | 547 | /** |
michael@0 | 548 | * Flush pending notifications of the type specified. This method |
michael@0 | 549 | * will not affect the content model; it'll just affect style and |
michael@0 | 550 | * frames. Callers that actually want up-to-date presentation (other |
michael@0 | 551 | * than the document itself) should probably be calling |
michael@0 | 552 | * nsIDocument::FlushPendingNotifications. |
michael@0 | 553 | * |
michael@0 | 554 | * @param aType the type of notifications to flush |
michael@0 | 555 | */ |
michael@0 | 556 | virtual NS_HIDDEN_(void) FlushPendingNotifications(mozFlushType aType) = 0; |
michael@0 | 557 | virtual NS_HIDDEN_(void) FlushPendingNotifications(mozilla::ChangesToFlush aType) = 0; |
michael@0 | 558 | |
michael@0 | 559 | /** |
michael@0 | 560 | * Callbacks will be called even if reflow itself fails for |
michael@0 | 561 | * some reason. |
michael@0 | 562 | */ |
michael@0 | 563 | virtual NS_HIDDEN_(nsresult) PostReflowCallback(nsIReflowCallback* aCallback) = 0; |
michael@0 | 564 | virtual NS_HIDDEN_(void) CancelReflowCallback(nsIReflowCallback* aCallback) = 0; |
michael@0 | 565 | |
michael@0 | 566 | virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame) = 0; |
michael@0 | 567 | |
michael@0 | 568 | /** |
michael@0 | 569 | * Get a reference rendering context. This is a context that should not |
michael@0 | 570 | * be rendered to, but is suitable for measuring text and performing |
michael@0 | 571 | * other non-rendering operations. Guaranteed to return non-null. |
michael@0 | 572 | */ |
michael@0 | 573 | virtual already_AddRefed<nsRenderingContext> CreateReferenceRenderingContext() = 0; |
michael@0 | 574 | |
michael@0 | 575 | /** |
michael@0 | 576 | * Informs the pres shell that the document is now at the anchor with |
michael@0 | 577 | * the given name. If |aScroll| is true, scrolls the view of the |
michael@0 | 578 | * document so that the anchor with the specified name is displayed at |
michael@0 | 579 | * the top of the window. If |aAnchorName| is empty, then this informs |
michael@0 | 580 | * the pres shell that there is no current target, and |aScroll| must |
michael@0 | 581 | * be false. |
michael@0 | 582 | */ |
michael@0 | 583 | virtual NS_HIDDEN_(nsresult) GoToAnchor(const nsAString& aAnchorName, bool aScroll) = 0; |
michael@0 | 584 | |
michael@0 | 585 | /** |
michael@0 | 586 | * Tells the presshell to scroll again to the last anchor scrolled to by |
michael@0 | 587 | * GoToAnchor, if any. This scroll only happens if the scroll |
michael@0 | 588 | * position has not changed since the last GoToAnchor. This is called |
michael@0 | 589 | * by nsDocumentViewer::LoadComplete. This clears the last anchor |
michael@0 | 590 | * scrolled to by GoToAnchor (we don't want to keep it alive if it's |
michael@0 | 591 | * removed from the DOM), so don't call this more than once. |
michael@0 | 592 | */ |
michael@0 | 593 | virtual NS_HIDDEN_(nsresult) ScrollToAnchor() = 0; |
michael@0 | 594 | |
michael@0 | 595 | enum { |
michael@0 | 596 | SCROLL_TOP = 0, |
michael@0 | 597 | SCROLL_BOTTOM = 100, |
michael@0 | 598 | SCROLL_LEFT = 0, |
michael@0 | 599 | SCROLL_RIGHT = 100, |
michael@0 | 600 | SCROLL_CENTER = 50, |
michael@0 | 601 | SCROLL_MINIMUM = -1 |
michael@0 | 602 | }; |
michael@0 | 603 | |
michael@0 | 604 | enum WhenToScroll { |
michael@0 | 605 | SCROLL_ALWAYS, |
michael@0 | 606 | SCROLL_IF_NOT_VISIBLE, |
michael@0 | 607 | SCROLL_IF_NOT_FULLY_VISIBLE |
michael@0 | 608 | }; |
michael@0 | 609 | typedef struct ScrollAxis { |
michael@0 | 610 | int16_t mWhereToScroll; |
michael@0 | 611 | WhenToScroll mWhenToScroll : 8; |
michael@0 | 612 | bool mOnlyIfPerceivedScrollableDirection : 1; |
michael@0 | 613 | /** |
michael@0 | 614 | * @param aWhere: Either a percentage or a special value. |
michael@0 | 615 | * nsIPresShell defines: |
michael@0 | 616 | * * (Default) SCROLL_MINIMUM = -1: The visible area is |
michael@0 | 617 | * scrolled to show the entire frame. If the frame is too |
michael@0 | 618 | * large, the top and left edges are given precedence. |
michael@0 | 619 | * * SCROLL_TOP = 0: The frame's upper edge is aligned with the |
michael@0 | 620 | * top edge of the visible area. |
michael@0 | 621 | * * SCROLL_BOTTOM = 100: The frame's bottom edge is aligned |
michael@0 | 622 | * with the bottom edge of the visible area. |
michael@0 | 623 | * * SCROLL_LEFT = 0: The frame's left edge is aligned with the |
michael@0 | 624 | * left edge of the visible area. |
michael@0 | 625 | * * SCROLL_RIGHT = 100: The frame's right edge is aligned with |
michael@0 | 626 | * the right edge of the visible area. |
michael@0 | 627 | * * SCROLL_CENTER = 50: The frame is centered along the axis |
michael@0 | 628 | * the ScrollAxis is used for. |
michael@0 | 629 | * |
michael@0 | 630 | * Other values are treated as a percentage, and the point |
michael@0 | 631 | * "percent" down the frame is placed at the point "percent" |
michael@0 | 632 | * down the visible area. |
michael@0 | 633 | * @param aWhen: |
michael@0 | 634 | * * (Default) SCROLL_IF_NOT_FULLY_VISIBLE: Move the frame only |
michael@0 | 635 | * if it is not fully visible (including if it's not visible |
michael@0 | 636 | * at all). Note that in this case if the frame is too large to |
michael@0 | 637 | * fit in view, it will only be scrolled if more of it can fit |
michael@0 | 638 | * than is already in view. |
michael@0 | 639 | * * SCROLL_IF_NOT_VISIBLE: Move the frame only if none of it |
michael@0 | 640 | * is visible. |
michael@0 | 641 | * * SCROLL_ALWAYS: Move the frame regardless of its current |
michael@0 | 642 | * visibility. |
michael@0 | 643 | * @param aOnlyIfPerceivedScrollableDirection: |
michael@0 | 644 | * If the direction is not a perceived scrollable direction (i.e. |
michael@0 | 645 | * no scrollbar showing and less than one device pixel of |
michael@0 | 646 | * scrollable distance), don't scroll. Defaults to false. |
michael@0 | 647 | */ |
michael@0 | 648 | ScrollAxis(int16_t aWhere = SCROLL_MINIMUM, |
michael@0 | 649 | WhenToScroll aWhen = SCROLL_IF_NOT_FULLY_VISIBLE, |
michael@0 | 650 | bool aOnlyIfPerceivedScrollableDirection = false) : |
michael@0 | 651 | mWhereToScroll(aWhere), mWhenToScroll(aWhen), |
michael@0 | 652 | mOnlyIfPerceivedScrollableDirection(aOnlyIfPerceivedScrollableDirection) |
michael@0 | 653 | {} |
michael@0 | 654 | } ScrollAxis; |
michael@0 | 655 | /** |
michael@0 | 656 | * Scrolls the view of the document so that the primary frame of the content |
michael@0 | 657 | * is displayed in the window. Layout is flushed before scrolling. |
michael@0 | 658 | * |
michael@0 | 659 | * @param aContent The content object of which primary frame should be |
michael@0 | 660 | * scrolled into view. |
michael@0 | 661 | * @param aVertical How to align the frame vertically and when to do so. |
michael@0 | 662 | * This is a ScrollAxis of Where and When. |
michael@0 | 663 | * @param aHorizontal How to align the frame horizontally and when to do so. |
michael@0 | 664 | * This is a ScrollAxis of Where and When. |
michael@0 | 665 | * @param aFlags If SCROLL_FIRST_ANCESTOR_ONLY is set, only the nearest |
michael@0 | 666 | * scrollable ancestor is scrolled, otherwise all |
michael@0 | 667 | * scrollable ancestors may be scrolled if necessary. |
michael@0 | 668 | * If SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a |
michael@0 | 669 | * direction even if overflow:hidden is specified in that |
michael@0 | 670 | * direction; otherwise we will not scroll in that direction |
michael@0 | 671 | * when overflow:hidden is set for that direction. |
michael@0 | 672 | * If SCROLL_NO_PARENT_FRAMES is set then we only scroll |
michael@0 | 673 | * nodes in this document, not in any parent documents which |
michael@0 | 674 | * contain this document in a iframe or the like. |
michael@0 | 675 | */ |
michael@0 | 676 | virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent, |
michael@0 | 677 | ScrollAxis aVertical, |
michael@0 | 678 | ScrollAxis aHorizontal, |
michael@0 | 679 | uint32_t aFlags) = 0; |
michael@0 | 680 | |
michael@0 | 681 | enum { |
michael@0 | 682 | SCROLL_FIRST_ANCESTOR_ONLY = 0x01, |
michael@0 | 683 | SCROLL_OVERFLOW_HIDDEN = 0x02, |
michael@0 | 684 | SCROLL_NO_PARENT_FRAMES = 0x04 |
michael@0 | 685 | }; |
michael@0 | 686 | /** |
michael@0 | 687 | * Scrolls the view of the document so that the given area of a frame |
michael@0 | 688 | * is visible, if possible. Layout is not flushed before scrolling. |
michael@0 | 689 | * |
michael@0 | 690 | * @param aRect relative to aFrame |
michael@0 | 691 | * @param aVertical see ScrollContentIntoView and ScrollAxis |
michael@0 | 692 | * @param aHorizontal see ScrollContentIntoView and ScrollAxis |
michael@0 | 693 | * @param aFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the |
michael@0 | 694 | * nearest scrollable ancestor is scrolled, otherwise all |
michael@0 | 695 | * scrollable ancestors may be scrolled if necessary |
michael@0 | 696 | * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction |
michael@0 | 697 | * even if overflow:hidden is specified in that direction; otherwise |
michael@0 | 698 | * we will not scroll in that direction when overflow:hidden is |
michael@0 | 699 | * set for that direction |
michael@0 | 700 | * If SCROLL_NO_PARENT_FRAMES is set then we only scroll |
michael@0 | 701 | * nodes in this document, not in any parent documents which |
michael@0 | 702 | * contain this document in a iframe or the like. |
michael@0 | 703 | * @return true if any scrolling happened, false if no scrolling happened |
michael@0 | 704 | */ |
michael@0 | 705 | virtual bool ScrollFrameRectIntoView(nsIFrame* aFrame, |
michael@0 | 706 | const nsRect& aRect, |
michael@0 | 707 | ScrollAxis aVertical, |
michael@0 | 708 | ScrollAxis aHorizontal, |
michael@0 | 709 | uint32_t aFlags) = 0; |
michael@0 | 710 | |
michael@0 | 711 | /** |
michael@0 | 712 | * Determine if a rectangle specified in the frame's coordinate system |
michael@0 | 713 | * intersects the viewport "enough" to be considered visible. |
michael@0 | 714 | * @param aFrame frame that aRect coordinates are specified relative to |
michael@0 | 715 | * @param aRect rectangle in twips to test for visibility |
michael@0 | 716 | * @param aMinTwips is the minimum distance in from the edge of the viewport |
michael@0 | 717 | * that an object must be to be counted visible |
michael@0 | 718 | * @return nsRectVisibility_kVisible if the rect is visible |
michael@0 | 719 | * nsRectVisibility_kAboveViewport |
michael@0 | 720 | * nsRectVisibility_kBelowViewport |
michael@0 | 721 | * nsRectVisibility_kLeftOfViewport |
michael@0 | 722 | * nsRectVisibility_kRightOfViewport rectangle is outside the viewport |
michael@0 | 723 | * in the specified direction |
michael@0 | 724 | */ |
michael@0 | 725 | virtual nsRectVisibility GetRectVisibility(nsIFrame *aFrame, |
michael@0 | 726 | const nsRect &aRect, |
michael@0 | 727 | nscoord aMinTwips) const = 0; |
michael@0 | 728 | |
michael@0 | 729 | /** |
michael@0 | 730 | * Suppress notification of the frame manager that frames are |
michael@0 | 731 | * being destroyed. |
michael@0 | 732 | */ |
michael@0 | 733 | virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(bool aIgnore) = 0; |
michael@0 | 734 | |
michael@0 | 735 | /** |
michael@0 | 736 | * Notification sent by a frame informing the pres shell that it is about to |
michael@0 | 737 | * be destroyed. |
michael@0 | 738 | * This allows any outstanding references to the frame to be cleaned up |
michael@0 | 739 | */ |
michael@0 | 740 | virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame) = 0; |
michael@0 | 741 | |
michael@0 | 742 | /** |
michael@0 | 743 | * Get the caret, if it exists. AddRefs it. |
michael@0 | 744 | */ |
michael@0 | 745 | virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret() const = 0; |
michael@0 | 746 | |
michael@0 | 747 | /** |
michael@0 | 748 | * Invalidate the caret's current position if it's outside of its frame's |
michael@0 | 749 | * boundaries. This function is useful if you're batching selection |
michael@0 | 750 | * notifications and might remove the caret's frame out from under it. |
michael@0 | 751 | */ |
michael@0 | 752 | virtual NS_HIDDEN_(void) MaybeInvalidateCaretPosition() = 0; |
michael@0 | 753 | |
michael@0 | 754 | /** |
michael@0 | 755 | * Set the current caret to a new caret. To undo this, call RestoreCaret. |
michael@0 | 756 | */ |
michael@0 | 757 | virtual void SetCaret(nsCaret *aNewCaret) = 0; |
michael@0 | 758 | |
michael@0 | 759 | /** |
michael@0 | 760 | * Restore the caret to the original caret that this pres shell was created |
michael@0 | 761 | * with. |
michael@0 | 762 | */ |
michael@0 | 763 | virtual void RestoreCaret() = 0; |
michael@0 | 764 | |
michael@0 | 765 | /** |
michael@0 | 766 | * Should the images have borders etc. Actual visual effects are determined |
michael@0 | 767 | * by the frames. Visual effects may not effect layout, only display. |
michael@0 | 768 | * Takes effect on next repaint, does not force a repaint itself. |
michael@0 | 769 | * |
michael@0 | 770 | * @param aInEnable if true, visual selection effects are enabled |
michael@0 | 771 | * if false visual selection effects are disabled |
michael@0 | 772 | */ |
michael@0 | 773 | NS_IMETHOD SetSelectionFlags(int16_t aInEnable) = 0; |
michael@0 | 774 | |
michael@0 | 775 | /** |
michael@0 | 776 | * Gets the current state of non text selection effects |
michael@0 | 777 | * @return current state of non text selection, |
michael@0 | 778 | * as set by SetDisplayNonTextSelection |
michael@0 | 779 | */ |
michael@0 | 780 | int16_t GetSelectionFlags() const { return mSelectionFlags; } |
michael@0 | 781 | |
michael@0 | 782 | virtual mozilla::dom::Selection* GetCurrentSelection(SelectionType aType) = 0; |
michael@0 | 783 | |
michael@0 | 784 | /** |
michael@0 | 785 | * Interface to dispatch events via the presshell |
michael@0 | 786 | * @note The caller must have a strong reference to the PresShell. |
michael@0 | 787 | */ |
michael@0 | 788 | virtual NS_HIDDEN_(nsresult) HandleEventWithTarget( |
michael@0 | 789 | mozilla::WidgetEvent* aEvent, |
michael@0 | 790 | nsIFrame* aFrame, |
michael@0 | 791 | nsIContent* aContent, |
michael@0 | 792 | nsEventStatus* aStatus) = 0; |
michael@0 | 793 | |
michael@0 | 794 | /** |
michael@0 | 795 | * Dispatch event to content only (NOT full processing) |
michael@0 | 796 | * @note The caller must have a strong reference to the PresShell. |
michael@0 | 797 | */ |
michael@0 | 798 | virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget( |
michael@0 | 799 | nsIContent* aTargetContent, |
michael@0 | 800 | mozilla::WidgetEvent* aEvent, |
michael@0 | 801 | nsEventStatus* aStatus) = 0; |
michael@0 | 802 | |
michael@0 | 803 | /** |
michael@0 | 804 | * Dispatch event to content only (NOT full processing) |
michael@0 | 805 | * @note The caller must have a strong reference to the PresShell. |
michael@0 | 806 | */ |
michael@0 | 807 | virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent, |
michael@0 | 808 | nsIDOMEvent* aEvent, |
michael@0 | 809 | nsEventStatus* aStatus) = 0; |
michael@0 | 810 | |
michael@0 | 811 | /** |
michael@0 | 812 | * Gets the current target event frame from the PresShell |
michael@0 | 813 | */ |
michael@0 | 814 | virtual NS_HIDDEN_(nsIFrame*) GetEventTargetFrame() = 0; |
michael@0 | 815 | |
michael@0 | 816 | /** |
michael@0 | 817 | * Gets the current target event frame from the PresShell |
michael@0 | 818 | */ |
michael@0 | 819 | virtual NS_HIDDEN_(already_AddRefed<nsIContent>) GetEventTargetContent( |
michael@0 | 820 | mozilla::WidgetEvent* aEvent) = 0; |
michael@0 | 821 | |
michael@0 | 822 | /** |
michael@0 | 823 | * Get and set the history state for the current document |
michael@0 | 824 | */ |
michael@0 | 825 | |
michael@0 | 826 | virtual NS_HIDDEN_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState) = 0; |
michael@0 | 827 | |
michael@0 | 828 | /** |
michael@0 | 829 | * Determine if reflow is currently locked |
michael@0 | 830 | * returns true if reflow is locked, false otherwise |
michael@0 | 831 | */ |
michael@0 | 832 | bool IsReflowLocked() const { return mIsReflowing; } |
michael@0 | 833 | |
michael@0 | 834 | /** |
michael@0 | 835 | * Called to find out if painting is suppressed for this presshell. If it is suppressd, |
michael@0 | 836 | * we don't allow the painting of any layer but the background, and we don't |
michael@0 | 837 | * recur into our children. |
michael@0 | 838 | */ |
michael@0 | 839 | bool IsPaintingSuppressed() const { return mPaintingSuppressed; } |
michael@0 | 840 | |
michael@0 | 841 | /** |
michael@0 | 842 | * Pause painting by freezing the refresh driver of this and all parent |
michael@0 | 843 | * presentations. This may not have the desired effect if this pres shell |
michael@0 | 844 | * has its own refresh driver. |
michael@0 | 845 | */ |
michael@0 | 846 | virtual void PausePainting() = 0; |
michael@0 | 847 | |
michael@0 | 848 | /** |
michael@0 | 849 | * Resume painting by thawing the refresh driver of this and all parent |
michael@0 | 850 | * presentations. This may not have the desired effect if this pres shell |
michael@0 | 851 | * has its own refresh driver. |
michael@0 | 852 | */ |
michael@0 | 853 | virtual void ResumePainting() = 0; |
michael@0 | 854 | |
michael@0 | 855 | /** |
michael@0 | 856 | * Unsuppress painting. |
michael@0 | 857 | */ |
michael@0 | 858 | virtual NS_HIDDEN_(void) UnsuppressPainting() = 0; |
michael@0 | 859 | |
michael@0 | 860 | /** |
michael@0 | 861 | * Called to disable nsITheme support in a specific presshell. |
michael@0 | 862 | */ |
michael@0 | 863 | void DisableThemeSupport() |
michael@0 | 864 | { |
michael@0 | 865 | // Doesn't have to be dynamic. Just set the bool. |
michael@0 | 866 | mIsThemeSupportDisabled = true; |
michael@0 | 867 | } |
michael@0 | 868 | |
michael@0 | 869 | /** |
michael@0 | 870 | * Indicates whether theme support is enabled. |
michael@0 | 871 | */ |
michael@0 | 872 | bool IsThemeSupportEnabled() const { return !mIsThemeSupportDisabled; } |
michael@0 | 873 | |
michael@0 | 874 | /** |
michael@0 | 875 | * Get the set of agent style sheets for this presentation |
michael@0 | 876 | */ |
michael@0 | 877 | virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) = 0; |
michael@0 | 878 | |
michael@0 | 879 | /** |
michael@0 | 880 | * Replace the set of agent style sheets |
michael@0 | 881 | */ |
michael@0 | 882 | virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) = 0; |
michael@0 | 883 | |
michael@0 | 884 | /** |
michael@0 | 885 | * Add an override style sheet for this presentation |
michael@0 | 886 | */ |
michael@0 | 887 | virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) = 0; |
michael@0 | 888 | |
michael@0 | 889 | /** |
michael@0 | 890 | * Remove an override style sheet |
michael@0 | 891 | */ |
michael@0 | 892 | virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) = 0; |
michael@0 | 893 | |
michael@0 | 894 | /** |
michael@0 | 895 | * Reconstruct frames for all elements in the document |
michael@0 | 896 | */ |
michael@0 | 897 | virtual nsresult ReconstructFrames() = 0; |
michael@0 | 898 | |
michael@0 | 899 | /** |
michael@0 | 900 | * Notify that a content node's state has changed |
michael@0 | 901 | */ |
michael@0 | 902 | virtual void ContentStateChanged(nsIDocument* aDocument, |
michael@0 | 903 | nsIContent* aContent, |
michael@0 | 904 | mozilla::EventStates aStateMask) = 0; |
michael@0 | 905 | |
michael@0 | 906 | /** |
michael@0 | 907 | * See if reflow verification is enabled. To enable reflow verification add |
michael@0 | 908 | * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable |
michael@0 | 909 | * (any non-zero debug level will work). Or, call SetVerifyReflowEnable |
michael@0 | 910 | * with true. |
michael@0 | 911 | */ |
michael@0 | 912 | static bool GetVerifyReflowEnable(); |
michael@0 | 913 | |
michael@0 | 914 | /** |
michael@0 | 915 | * Set the verify-reflow enable flag. |
michael@0 | 916 | */ |
michael@0 | 917 | static void SetVerifyReflowEnable(bool aEnabled); |
michael@0 | 918 | |
michael@0 | 919 | virtual nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame); |
michael@0 | 920 | |
michael@0 | 921 | #ifdef MOZ_REFLOW_PERF |
michael@0 | 922 | virtual NS_HIDDEN_(void) DumpReflows() = 0; |
michael@0 | 923 | virtual NS_HIDDEN_(void) CountReflows(const char * aName, nsIFrame * aFrame) = 0; |
michael@0 | 924 | virtual NS_HIDDEN_(void) PaintCount(const char * aName, |
michael@0 | 925 | nsRenderingContext* aRenderingContext, |
michael@0 | 926 | nsPresContext * aPresContext, |
michael@0 | 927 | nsIFrame * aFrame, |
michael@0 | 928 | const nsPoint& aOffset, |
michael@0 | 929 | uint32_t aColor) = 0; |
michael@0 | 930 | virtual NS_HIDDEN_(void) SetPaintFrameCount(bool aOn) = 0; |
michael@0 | 931 | virtual bool IsPaintingFrameCounts() = 0; |
michael@0 | 932 | #endif |
michael@0 | 933 | |
michael@0 | 934 | #ifdef DEBUG |
michael@0 | 935 | // Debugging hooks |
michael@0 | 936 | virtual void ListStyleContexts(nsIFrame *aRootFrame, FILE *out, |
michael@0 | 937 | int32_t aIndent = 0) = 0; |
michael@0 | 938 | |
michael@0 | 939 | virtual void ListStyleSheets(FILE *out, int32_t aIndent = 0) = 0; |
michael@0 | 940 | virtual void VerifyStyleTree() = 0; |
michael@0 | 941 | #endif |
michael@0 | 942 | |
michael@0 | 943 | #ifdef ACCESSIBILITY |
michael@0 | 944 | /** |
michael@0 | 945 | * Return true if accessibility is active. |
michael@0 | 946 | */ |
michael@0 | 947 | static bool IsAccessibilityActive(); |
michael@0 | 948 | |
michael@0 | 949 | /** |
michael@0 | 950 | * Return accessibility service if accessibility is active. |
michael@0 | 951 | */ |
michael@0 | 952 | static nsAccessibilityService* AccService(); |
michael@0 | 953 | #endif |
michael@0 | 954 | |
michael@0 | 955 | /** |
michael@0 | 956 | * Stop all active elements (plugins and the caret) in this presentation and |
michael@0 | 957 | * in the presentations of subdocuments. Resets painting to a suppressed state. |
michael@0 | 958 | * XXX this should include image animations |
michael@0 | 959 | */ |
michael@0 | 960 | virtual void Freeze() = 0; |
michael@0 | 961 | bool IsFrozen() { return mFrozen; } |
michael@0 | 962 | |
michael@0 | 963 | /** |
michael@0 | 964 | * Restarts active elements (plugins) in this presentation and in the |
michael@0 | 965 | * presentations of subdocuments, then do a full invalidate of the content area. |
michael@0 | 966 | */ |
michael@0 | 967 | virtual void Thaw() = 0; |
michael@0 | 968 | |
michael@0 | 969 | virtual void FireOrClearDelayedEvents(bool aFireEvents) = 0; |
michael@0 | 970 | |
michael@0 | 971 | /** |
michael@0 | 972 | * When this shell is disconnected from its containing docshell, we |
michael@0 | 973 | * lose our container pointer. However, we'd still like to be able to target |
michael@0 | 974 | * user events at the docshell's parent. This pointer allows us to do that. |
michael@0 | 975 | * It should not be used for any other purpose. |
michael@0 | 976 | */ |
michael@0 | 977 | void SetForwardingContainer(const mozilla::WeakPtr<nsDocShell> &aContainer); |
michael@0 | 978 | |
michael@0 | 979 | /** |
michael@0 | 980 | * Render the document into an arbitrary gfxContext |
michael@0 | 981 | * Designed for getting a picture of a document or a piece of a document |
michael@0 | 982 | * Note that callers will generally want to call FlushPendingNotifications |
michael@0 | 983 | * to get an up-to-date view of the document |
michael@0 | 984 | * @param aRect is the region to capture into the offscreen buffer, in the |
michael@0 | 985 | * root frame's coordinate system (if aIgnoreViewportScrolling is false) |
michael@0 | 986 | * or in the root scrolled frame's coordinate system |
michael@0 | 987 | * (if aIgnoreViewportScrolling is true). The coordinates are in appunits. |
michael@0 | 988 | * @param aFlags see below; |
michael@0 | 989 | * set RENDER_IS_UNTRUSTED if the contents may be passed to malicious |
michael@0 | 990 | * agents. E.g. we might choose not to paint the contents of sensitive widgets |
michael@0 | 991 | * such as the file name in a file upload widget, and we might choose not |
michael@0 | 992 | * to paint themes. |
michael@0 | 993 | * set RENDER_IGNORE_VIEWPORT_SCROLLING to ignore |
michael@0 | 994 | * clipping/scrolling/scrollbar painting due to scrolling in the viewport |
michael@0 | 995 | * set RENDER_CARET to draw the caret if one would be visible |
michael@0 | 996 | * (by default the caret is never drawn) |
michael@0 | 997 | * set RENDER_USE_LAYER_MANAGER to force rendering to go through |
michael@0 | 998 | * the layer manager for the window. This may be unexpectedly slow |
michael@0 | 999 | * (if the layer manager must read back data from the GPU) or low-quality |
michael@0 | 1000 | * (if the layer manager reads back pixel data and scales it |
michael@0 | 1001 | * instead of rendering using the appropriate scaling). It may also |
michael@0 | 1002 | * slow everything down if the area rendered does not correspond to the |
michael@0 | 1003 | * normal visible area of the window. |
michael@0 | 1004 | * set RENDER_ASYNC_DECODE_IMAGES to avoid having images synchronously |
michael@0 | 1005 | * decoded during rendering. |
michael@0 | 1006 | * (by default images decode synchronously with RenderDocument) |
michael@0 | 1007 | * set RENDER_DOCUMENT_RELATIVE to interpret |aRect| relative to the |
michael@0 | 1008 | * document instead of the CSS viewport |
michael@0 | 1009 | * @param aBackgroundColor a background color to render onto |
michael@0 | 1010 | * @param aRenderedContext the gfxContext to render to. We render so that |
michael@0 | 1011 | * one CSS pixel in the source document is rendered to one unit in the current |
michael@0 | 1012 | * transform. |
michael@0 | 1013 | */ |
michael@0 | 1014 | enum { |
michael@0 | 1015 | RENDER_IS_UNTRUSTED = 0x01, |
michael@0 | 1016 | RENDER_IGNORE_VIEWPORT_SCROLLING = 0x02, |
michael@0 | 1017 | RENDER_CARET = 0x04, |
michael@0 | 1018 | RENDER_USE_WIDGET_LAYERS = 0x08, |
michael@0 | 1019 | RENDER_ASYNC_DECODE_IMAGES = 0x10, |
michael@0 | 1020 | RENDER_DOCUMENT_RELATIVE = 0x20, |
michael@0 | 1021 | RENDER_DRAWWINDOW_NOT_FLUSHING = 0x40 |
michael@0 | 1022 | }; |
michael@0 | 1023 | virtual NS_HIDDEN_(nsresult) RenderDocument(const nsRect& aRect, uint32_t aFlags, |
michael@0 | 1024 | nscolor aBackgroundColor, |
michael@0 | 1025 | gfxContext* aRenderedContext) = 0; |
michael@0 | 1026 | |
michael@0 | 1027 | /** |
michael@0 | 1028 | * Renders a node aNode to a surface and returns it. The aRegion may be used |
michael@0 | 1029 | * to clip the rendering. This region is measured in CSS pixels from the |
michael@0 | 1030 | * edge of the presshell area. The aPoint, aScreenRect and aSurface |
michael@0 | 1031 | * arguments function in a similar manner as RenderSelection. |
michael@0 | 1032 | */ |
michael@0 | 1033 | virtual mozilla::TemporaryRef<SourceSurface> |
michael@0 | 1034 | RenderNode(nsIDOMNode* aNode, |
michael@0 | 1035 | nsIntRegion* aRegion, |
michael@0 | 1036 | nsIntPoint& aPoint, |
michael@0 | 1037 | nsIntRect* aScreenRect) = 0; |
michael@0 | 1038 | |
michael@0 | 1039 | /** |
michael@0 | 1040 | * Renders a selection to a surface and returns it. This method is primarily |
michael@0 | 1041 | * intended to create the drag feedback when dragging a selection. |
michael@0 | 1042 | * |
michael@0 | 1043 | * aScreenRect will be filled in with the bounding rectangle of the |
michael@0 | 1044 | * selection area on screen. |
michael@0 | 1045 | * |
michael@0 | 1046 | * If the area of the selection is large, the image will be scaled down. |
michael@0 | 1047 | * The argument aPoint is used in this case as a reference point when |
michael@0 | 1048 | * determining the new screen rectangle after scaling. Typically, this |
michael@0 | 1049 | * will be the mouse position, so that the screen rectangle is positioned |
michael@0 | 1050 | * such that the mouse is over the same point in the scaled image as in |
michael@0 | 1051 | * the original. When scaling does not occur, the mouse point isn't used |
michael@0 | 1052 | * as the position can be determined from the displayed frames. |
michael@0 | 1053 | */ |
michael@0 | 1054 | virtual mozilla::TemporaryRef<SourceSurface> |
michael@0 | 1055 | RenderSelection(nsISelection* aSelection, |
michael@0 | 1056 | nsIntPoint& aPoint, |
michael@0 | 1057 | nsIntRect* aScreenRect) = 0; |
michael@0 | 1058 | |
michael@0 | 1059 | void AddWeakFrameInternal(nsWeakFrame* aWeakFrame); |
michael@0 | 1060 | virtual void AddWeakFrameExternal(nsWeakFrame* aWeakFrame); |
michael@0 | 1061 | |
michael@0 | 1062 | void AddWeakFrame(nsWeakFrame* aWeakFrame) |
michael@0 | 1063 | { |
michael@0 | 1064 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 1065 | AddWeakFrameInternal(aWeakFrame); |
michael@0 | 1066 | #else |
michael@0 | 1067 | AddWeakFrameExternal(aWeakFrame); |
michael@0 | 1068 | #endif |
michael@0 | 1069 | } |
michael@0 | 1070 | |
michael@0 | 1071 | void RemoveWeakFrameInternal(nsWeakFrame* aWeakFrame); |
michael@0 | 1072 | virtual void RemoveWeakFrameExternal(nsWeakFrame* aWeakFrame); |
michael@0 | 1073 | |
michael@0 | 1074 | void RemoveWeakFrame(nsWeakFrame* aWeakFrame) |
michael@0 | 1075 | { |
michael@0 | 1076 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 1077 | RemoveWeakFrameInternal(aWeakFrame); |
michael@0 | 1078 | #else |
michael@0 | 1079 | RemoveWeakFrameExternal(aWeakFrame); |
michael@0 | 1080 | #endif |
michael@0 | 1081 | } |
michael@0 | 1082 | |
michael@0 | 1083 | #ifdef DEBUG |
michael@0 | 1084 | nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; } |
michael@0 | 1085 | #endif |
michael@0 | 1086 | |
michael@0 | 1087 | /** |
michael@0 | 1088 | * Stop or restart non synthetic test mouse event handling on *all* |
michael@0 | 1089 | * presShells. |
michael@0 | 1090 | * |
michael@0 | 1091 | * @param aDisable If true, disable all non synthetic test mouse |
michael@0 | 1092 | * events on all presShells. Otherwise, enable them. |
michael@0 | 1093 | */ |
michael@0 | 1094 | virtual NS_HIDDEN_(void) DisableNonTestMouseEvents(bool aDisable) = 0; |
michael@0 | 1095 | |
michael@0 | 1096 | /** |
michael@0 | 1097 | * Record the background color of the most recently drawn canvas. This color |
michael@0 | 1098 | * is composited on top of the user's default background color and then used |
michael@0 | 1099 | * to draw the background color of the canvas. See PresShell::Paint, |
michael@0 | 1100 | * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer; |
michael@0 | 1101 | * bug 488242, bug 476557 and other bugs mentioned there. |
michael@0 | 1102 | */ |
michael@0 | 1103 | void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; } |
michael@0 | 1104 | nscolor GetCanvasBackground() { return mCanvasBackgroundColor; } |
michael@0 | 1105 | |
michael@0 | 1106 | /** |
michael@0 | 1107 | * Use the current frame tree (if it exists) to update the background |
michael@0 | 1108 | * color of the most recently drawn canvas. |
michael@0 | 1109 | */ |
michael@0 | 1110 | virtual void UpdateCanvasBackground() = 0; |
michael@0 | 1111 | |
michael@0 | 1112 | /** |
michael@0 | 1113 | * Add a solid color item to the bottom of aList with frame aFrame and bounds |
michael@0 | 1114 | * aBounds. Checks first if this needs to be done by checking if aFrame is a |
michael@0 | 1115 | * canvas frame (if the FORCE_DRAW flag is passed then this check is skipped). |
michael@0 | 1116 | * aBackstopColor is composed behind the background color of the canvas, it is |
michael@0 | 1117 | * transparent by default. |
michael@0 | 1118 | */ |
michael@0 | 1119 | enum { |
michael@0 | 1120 | FORCE_DRAW = 0x01 |
michael@0 | 1121 | }; |
michael@0 | 1122 | virtual void AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder, |
michael@0 | 1123 | nsDisplayList& aList, |
michael@0 | 1124 | nsIFrame* aFrame, |
michael@0 | 1125 | const nsRect& aBounds, |
michael@0 | 1126 | nscolor aBackstopColor = NS_RGBA(0,0,0,0), |
michael@0 | 1127 | uint32_t aFlags = 0) = 0; |
michael@0 | 1128 | |
michael@0 | 1129 | |
michael@0 | 1130 | /** |
michael@0 | 1131 | * Add a solid color item to the bottom of aList with frame aFrame and |
michael@0 | 1132 | * bounds aBounds representing the dark grey background behind the page of a |
michael@0 | 1133 | * print preview presentation. |
michael@0 | 1134 | */ |
michael@0 | 1135 | virtual void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder, |
michael@0 | 1136 | nsDisplayList& aList, |
michael@0 | 1137 | nsIFrame* aFrame, |
michael@0 | 1138 | const nsRect& aBounds) = 0; |
michael@0 | 1139 | |
michael@0 | 1140 | /** |
michael@0 | 1141 | * Computes the backstop color for the view: transparent if in a transparent |
michael@0 | 1142 | * widget, otherwise the PresContext default background color. This color is |
michael@0 | 1143 | * only visible if the contents of the view as a whole are translucent. |
michael@0 | 1144 | */ |
michael@0 | 1145 | virtual nscolor ComputeBackstopColor(nsView* aDisplayRoot) = 0; |
michael@0 | 1146 | |
michael@0 | 1147 | void ObserveNativeAnonMutationsForPrint(bool aObserve) |
michael@0 | 1148 | { |
michael@0 | 1149 | mObservesMutationsForPrint = aObserve; |
michael@0 | 1150 | } |
michael@0 | 1151 | bool ObservesNativeAnonMutationsForPrint() |
michael@0 | 1152 | { |
michael@0 | 1153 | return mObservesMutationsForPrint; |
michael@0 | 1154 | } |
michael@0 | 1155 | |
michael@0 | 1156 | virtual nsresult SetIsActive(bool aIsActive) = 0; |
michael@0 | 1157 | |
michael@0 | 1158 | bool IsActive() |
michael@0 | 1159 | { |
michael@0 | 1160 | return mIsActive; |
michael@0 | 1161 | } |
michael@0 | 1162 | |
michael@0 | 1163 | // mouse capturing |
michael@0 | 1164 | |
michael@0 | 1165 | static CapturingContentInfo gCaptureInfo; |
michael@0 | 1166 | |
michael@0 | 1167 | static nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Touch>* gCaptureTouchList; |
michael@0 | 1168 | static bool gPreventMouseEvents; |
michael@0 | 1169 | |
michael@0 | 1170 | // Keeps a map between pointerId and element that currently capturing pointer |
michael@0 | 1171 | // with such pointerId. If pointerId is absent in this map then nobody is |
michael@0 | 1172 | // capturing it. |
michael@0 | 1173 | static nsRefPtrHashtable<nsUint32HashKey, nsIContent>* gPointerCaptureList; |
michael@0 | 1174 | |
michael@0 | 1175 | struct PointerInfo |
michael@0 | 1176 | { |
michael@0 | 1177 | bool mActiveState; |
michael@0 | 1178 | uint16_t mPointerType; |
michael@0 | 1179 | PointerInfo(bool aActiveState, uint16_t aPointerType) : |
michael@0 | 1180 | mActiveState(aActiveState), mPointerType(aPointerType) {} |
michael@0 | 1181 | }; |
michael@0 | 1182 | // Keeps information about pointers such as pointerId, activeState, pointerType |
michael@0 | 1183 | static nsClassHashtable<nsUint32HashKey, PointerInfo>* gActivePointersIds; |
michael@0 | 1184 | |
michael@0 | 1185 | static void DispatchGotOrLostPointerCaptureEvent(bool aIsGotCapture, |
michael@0 | 1186 | uint32_t aPointerId, |
michael@0 | 1187 | nsIContent* aCaptureTarget); |
michael@0 | 1188 | static void SetPointerCapturingContent(uint32_t aPointerId, nsIContent* aContent); |
michael@0 | 1189 | static void ReleasePointerCapturingContent(uint32_t aPointerId, nsIContent* aContent); |
michael@0 | 1190 | static nsIContent* GetPointerCapturingContent(uint32_t aPointerId); |
michael@0 | 1191 | |
michael@0 | 1192 | // GetPointerInfo returns true if pointer with aPointerId is situated in device, false otherwise. |
michael@0 | 1193 | // aActiveState is additional information, which shows state of pointer like button state for mouse. |
michael@0 | 1194 | static bool GetPointerInfo(uint32_t aPointerId, bool& aActiveState); |
michael@0 | 1195 | |
michael@0 | 1196 | /** |
michael@0 | 1197 | * When capturing content is set, it traps all mouse events and retargets |
michael@0 | 1198 | * them at this content node. If capturing is not allowed |
michael@0 | 1199 | * (gCaptureInfo.mAllowed is false), then capturing is not set. However, if |
michael@0 | 1200 | * the CAPTURE_IGNOREALLOWED flag is set, the allowed state is ignored and |
michael@0 | 1201 | * capturing is set regardless. To disable capture, pass null for the value |
michael@0 | 1202 | * of aContent. |
michael@0 | 1203 | * |
michael@0 | 1204 | * If CAPTURE_RETARGETTOELEMENT is set, all mouse events are targeted at |
michael@0 | 1205 | * aContent only. Otherwise, mouse events are targeted at aContent or its |
michael@0 | 1206 | * descendants. That is, descendants of aContent receive mouse events as |
michael@0 | 1207 | * they normally would, but mouse events outside of aContent are retargeted |
michael@0 | 1208 | * to aContent. |
michael@0 | 1209 | * |
michael@0 | 1210 | * If CAPTURE_PREVENTDRAG is set then drags are prevented from starting while |
michael@0 | 1211 | * this capture is active. |
michael@0 | 1212 | * |
michael@0 | 1213 | * If CAPTURE_POINTERLOCK is set, similar to CAPTURE_RETARGETTOELEMENT, then |
michael@0 | 1214 | * events are targeted at aContent, but capturing is held more strongly (i.e., |
michael@0 | 1215 | * calls to SetCapturingContent won't unlock unless CAPTURE_POINTERLOCK is |
michael@0 | 1216 | * set again). |
michael@0 | 1217 | */ |
michael@0 | 1218 | static void SetCapturingContent(nsIContent* aContent, uint8_t aFlags); |
michael@0 | 1219 | |
michael@0 | 1220 | /** |
michael@0 | 1221 | * Return the active content currently capturing the mouse if any. |
michael@0 | 1222 | */ |
michael@0 | 1223 | static nsIContent* GetCapturingContent() |
michael@0 | 1224 | { |
michael@0 | 1225 | return gCaptureInfo.mContent; |
michael@0 | 1226 | } |
michael@0 | 1227 | |
michael@0 | 1228 | /** |
michael@0 | 1229 | * Allow or disallow mouse capturing. |
michael@0 | 1230 | */ |
michael@0 | 1231 | static void AllowMouseCapture(bool aAllowed) |
michael@0 | 1232 | { |
michael@0 | 1233 | gCaptureInfo.mAllowed = aAllowed; |
michael@0 | 1234 | } |
michael@0 | 1235 | |
michael@0 | 1236 | /** |
michael@0 | 1237 | * Returns true if there is an active mouse capture that wants to prevent |
michael@0 | 1238 | * drags. |
michael@0 | 1239 | */ |
michael@0 | 1240 | static bool IsMouseCapturePreventingDrag() |
michael@0 | 1241 | { |
michael@0 | 1242 | return gCaptureInfo.mPreventDrag && gCaptureInfo.mContent; |
michael@0 | 1243 | } |
michael@0 | 1244 | |
michael@0 | 1245 | /** |
michael@0 | 1246 | * Keep track of how many times this presshell has been rendered to |
michael@0 | 1247 | * a window. |
michael@0 | 1248 | */ |
michael@0 | 1249 | uint64_t GetPaintCount() { return mPaintCount; } |
michael@0 | 1250 | void IncrementPaintCount() { ++mPaintCount; } |
michael@0 | 1251 | |
michael@0 | 1252 | /** |
michael@0 | 1253 | * Get the root DOM window of this presShell. |
michael@0 | 1254 | */ |
michael@0 | 1255 | virtual already_AddRefed<nsPIDOMWindow> GetRootWindow() = 0; |
michael@0 | 1256 | |
michael@0 | 1257 | /** |
michael@0 | 1258 | * Get the layer manager for the widget of the root view, if it has |
michael@0 | 1259 | * one. |
michael@0 | 1260 | */ |
michael@0 | 1261 | virtual LayerManager* GetLayerManager() = 0; |
michael@0 | 1262 | |
michael@0 | 1263 | /** |
michael@0 | 1264 | * Track whether we're ignoring viewport scrolling for the purposes |
michael@0 | 1265 | * of painting. If we are ignoring, then layers aren't clipped to |
michael@0 | 1266 | * the CSS viewport and scrollbars aren't drawn. |
michael@0 | 1267 | */ |
michael@0 | 1268 | virtual void SetIgnoreViewportScrolling(bool aIgnore) = 0; |
michael@0 | 1269 | bool IgnoringViewportScrolling() const |
michael@0 | 1270 | { return mRenderFlags & STATE_IGNORING_VIEWPORT_SCROLLING; } |
michael@0 | 1271 | |
michael@0 | 1272 | /** |
michael@0 | 1273 | * Set a "resolution" for the document, which if not 1.0 will |
michael@0 | 1274 | * allocate more or fewer pixels for rescalable content by a factor |
michael@0 | 1275 | * of |resolution| in both dimensions. Return NS_OK iff the |
michael@0 | 1276 | * resolution bounds are sane, and the resolution of this was |
michael@0 | 1277 | * actually updated. |
michael@0 | 1278 | * |
michael@0 | 1279 | * The resolution defaults to 1.0. |
michael@0 | 1280 | */ |
michael@0 | 1281 | virtual nsresult SetResolution(float aXResolution, float aYResolution) = 0; |
michael@0 | 1282 | gfxSize GetResolution() { return gfxSize(mXResolution, mYResolution); } |
michael@0 | 1283 | float GetXResolution() { return mXResolution; } |
michael@0 | 1284 | float GetYResolution() { return mYResolution; } |
michael@0 | 1285 | virtual gfxSize GetCumulativeResolution() = 0; |
michael@0 | 1286 | |
michael@0 | 1287 | /** |
michael@0 | 1288 | * Returns whether we are in a DrawWindow() call that used the |
michael@0 | 1289 | * DRAWWINDOW_DO_NOT_FLUSH flag. |
michael@0 | 1290 | */ |
michael@0 | 1291 | bool InDrawWindowNotFlushing() const |
michael@0 | 1292 | { return mRenderFlags & STATE_DRAWWINDOW_NOT_FLUSHING; } |
michael@0 | 1293 | |
michael@0 | 1294 | /** |
michael@0 | 1295 | * Set the isFirstPaint flag. |
michael@0 | 1296 | */ |
michael@0 | 1297 | void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; } |
michael@0 | 1298 | |
michael@0 | 1299 | /** |
michael@0 | 1300 | * Get the isFirstPaint flag. |
michael@0 | 1301 | */ |
michael@0 | 1302 | bool GetIsFirstPaint() const { return mIsFirstPaint; } |
michael@0 | 1303 | |
michael@0 | 1304 | uint32_t GetPresShellId() { return mPresShellId; } |
michael@0 | 1305 | |
michael@0 | 1306 | /** |
michael@0 | 1307 | * Dispatch a mouse move event based on the most recent mouse position if |
michael@0 | 1308 | * this PresShell is visible. This is used when the contents of the page |
michael@0 | 1309 | * moved (aFromScroll is false) or scrolled (aFromScroll is true). |
michael@0 | 1310 | */ |
michael@0 | 1311 | virtual void SynthesizeMouseMove(bool aFromScroll) = 0; |
michael@0 | 1312 | |
michael@0 | 1313 | enum PaintFlags { |
michael@0 | 1314 | /* Update the layer tree and paint ThebesLayers. If this is not specified, |
michael@0 | 1315 | * we may still have to do it if the layer tree lost ThebesLayer contents |
michael@0 | 1316 | * we need for compositing. */ |
michael@0 | 1317 | PAINT_LAYERS = 0x01, |
michael@0 | 1318 | /* Composite layers to the window. */ |
michael@0 | 1319 | PAINT_COMPOSITE = 0x02, |
michael@0 | 1320 | }; |
michael@0 | 1321 | virtual void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, |
michael@0 | 1322 | uint32_t aFlags) = 0; |
michael@0 | 1323 | virtual nsresult HandleEvent(nsIFrame* aFrame, |
michael@0 | 1324 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 1325 | bool aDontRetargetEvents, |
michael@0 | 1326 | nsEventStatus* aEventStatus) = 0; |
michael@0 | 1327 | virtual bool ShouldIgnoreInvalidation() = 0; |
michael@0 | 1328 | /** |
michael@0 | 1329 | * Notify that we're going to call Paint with PAINT_LAYERS |
michael@0 | 1330 | * on the pres shell for a widget (which might not be this one, since |
michael@0 | 1331 | * WillPaint is called on all presshells in the same toplevel window as the |
michael@0 | 1332 | * painted widget). This is issued at a time when it's safe to modify |
michael@0 | 1333 | * widget geometry. |
michael@0 | 1334 | */ |
michael@0 | 1335 | virtual void WillPaint() = 0; |
michael@0 | 1336 | /** |
michael@0 | 1337 | * Notify that we're going to call Paint with PAINT_COMPOSITE. |
michael@0 | 1338 | * Fires on the presshell for the painted widget. |
michael@0 | 1339 | * This is issued at a time when it's safe to modify widget geometry. |
michael@0 | 1340 | */ |
michael@0 | 1341 | virtual void WillPaintWindow() = 0; |
michael@0 | 1342 | /** |
michael@0 | 1343 | * Notify that we called Paint with PAINT_COMPOSITE. |
michael@0 | 1344 | * Fires on the presshell for the painted widget. |
michael@0 | 1345 | * This is issued at a time when it's safe to modify widget geometry. |
michael@0 | 1346 | */ |
michael@0 | 1347 | virtual void DidPaintWindow() = 0; |
michael@0 | 1348 | |
michael@0 | 1349 | /** |
michael@0 | 1350 | * Ensures that the refresh driver is running, and schedules a view |
michael@0 | 1351 | * manager flush on the next tick. |
michael@0 | 1352 | * |
michael@0 | 1353 | * @param aType PAINT_DELAYED_COMPRESS : Schedule a paint to be executed after a delay, and |
michael@0 | 1354 | * put FrameLayerBuilder in 'compressed' mode that avoids short cut optimizations. |
michael@0 | 1355 | */ |
michael@0 | 1356 | enum PaintType { |
michael@0 | 1357 | PAINT_DEFAULT, |
michael@0 | 1358 | PAINT_DELAYED_COMPRESS |
michael@0 | 1359 | }; |
michael@0 | 1360 | virtual void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) = 0; |
michael@0 | 1361 | virtual void ClearMouseCaptureOnView(nsView* aView) = 0; |
michael@0 | 1362 | virtual bool IsVisible() = 0; |
michael@0 | 1363 | virtual void DispatchSynthMouseMove(mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 1364 | bool aFlushOnHoverChange) = 0; |
michael@0 | 1365 | |
michael@0 | 1366 | virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, |
michael@0 | 1367 | nsArenaMemoryStats *aArenaObjectsSize, |
michael@0 | 1368 | size_t *aPresShellSize, |
michael@0 | 1369 | size_t *aStyleSetsSize, |
michael@0 | 1370 | size_t *aTextRunsSize, |
michael@0 | 1371 | size_t *aPresContextSize) = 0; |
michael@0 | 1372 | |
michael@0 | 1373 | /** |
michael@0 | 1374 | * Methods that retrieve the cached font inflation preferences. |
michael@0 | 1375 | */ |
michael@0 | 1376 | uint32_t FontSizeInflationEmPerLine() const { |
michael@0 | 1377 | return mFontSizeInflationEmPerLine; |
michael@0 | 1378 | } |
michael@0 | 1379 | |
michael@0 | 1380 | uint32_t FontSizeInflationMinTwips() const { |
michael@0 | 1381 | return mFontSizeInflationMinTwips; |
michael@0 | 1382 | } |
michael@0 | 1383 | |
michael@0 | 1384 | uint32_t FontSizeInflationLineThreshold() const { |
michael@0 | 1385 | return mFontSizeInflationLineThreshold; |
michael@0 | 1386 | } |
michael@0 | 1387 | |
michael@0 | 1388 | bool FontSizeInflationForceEnabled() const { |
michael@0 | 1389 | return mFontSizeInflationForceEnabled; |
michael@0 | 1390 | } |
michael@0 | 1391 | |
michael@0 | 1392 | bool FontSizeInflationDisabledInMasterProcess() const { |
michael@0 | 1393 | return mFontSizeInflationDisabledInMasterProcess; |
michael@0 | 1394 | } |
michael@0 | 1395 | |
michael@0 | 1396 | /** |
michael@0 | 1397 | * Determine if font size inflation is enabled. This value is cached until |
michael@0 | 1398 | * it becomes dirty. |
michael@0 | 1399 | * |
michael@0 | 1400 | * @returns true, if font size inflation is enabled; false otherwise. |
michael@0 | 1401 | */ |
michael@0 | 1402 | bool FontSizeInflationEnabled(); |
michael@0 | 1403 | |
michael@0 | 1404 | /** |
michael@0 | 1405 | * Notify the pres shell that an event occurred making the current value of |
michael@0 | 1406 | * mFontSizeInflationEnabled invalid. This will schedule a recomputation of |
michael@0 | 1407 | * whether font size inflation is enabled on the next call to |
michael@0 | 1408 | * FontSizeInflationEnabled(). |
michael@0 | 1409 | */ |
michael@0 | 1410 | void NotifyFontSizeInflationEnabledIsDirty() |
michael@0 | 1411 | { |
michael@0 | 1412 | mFontSizeInflationEnabledIsDirty = true; |
michael@0 | 1413 | } |
michael@0 | 1414 | |
michael@0 | 1415 | virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver) = 0; |
michael@0 | 1416 | |
michael@0 | 1417 | void InvalidatePresShellIfHidden(); |
michael@0 | 1418 | void CancelInvalidatePresShellIfHidden(); |
michael@0 | 1419 | |
michael@0 | 1420 | // Schedule an update of the list of visible images. |
michael@0 | 1421 | virtual void ScheduleImageVisibilityUpdate() = 0; |
michael@0 | 1422 | |
michael@0 | 1423 | // Clears the current list of visible images on this presshell and replaces it |
michael@0 | 1424 | // with images that are in the display list aList. |
michael@0 | 1425 | virtual void RebuildImageVisibility(const nsDisplayList& aList) = 0; |
michael@0 | 1426 | |
michael@0 | 1427 | // Ensures the image is in the list of visible images. |
michael@0 | 1428 | virtual void EnsureImageInVisibleList(nsIImageLoadingContent* aImage) = 0; |
michael@0 | 1429 | |
michael@0 | 1430 | // Removes the image from the list of visible images if it is present there. |
michael@0 | 1431 | virtual void RemoveImageFromVisibleList(nsIImageLoadingContent* aImage) = 0; |
michael@0 | 1432 | |
michael@0 | 1433 | // Whether we should assume all images are visible. |
michael@0 | 1434 | virtual bool AssumeAllImagesVisible() = 0; |
michael@0 | 1435 | |
michael@0 | 1436 | /** |
michael@0 | 1437 | * Refresh observer management. |
michael@0 | 1438 | */ |
michael@0 | 1439 | protected: |
michael@0 | 1440 | virtual bool AddRefreshObserverExternal(nsARefreshObserver* aObserver, |
michael@0 | 1441 | mozFlushType aFlushType); |
michael@0 | 1442 | bool AddRefreshObserverInternal(nsARefreshObserver* aObserver, |
michael@0 | 1443 | mozFlushType aFlushType); |
michael@0 | 1444 | virtual bool RemoveRefreshObserverExternal(nsARefreshObserver* aObserver, |
michael@0 | 1445 | mozFlushType aFlushType); |
michael@0 | 1446 | bool RemoveRefreshObserverInternal(nsARefreshObserver* aObserver, |
michael@0 | 1447 | mozFlushType aFlushType); |
michael@0 | 1448 | |
michael@0 | 1449 | /** |
michael@0 | 1450 | * Do computations necessary to determine if font size inflation is enabled. |
michael@0 | 1451 | * This value is cached after computation, as the computation is somewhat |
michael@0 | 1452 | * expensive. |
michael@0 | 1453 | */ |
michael@0 | 1454 | void RecomputeFontSizeInflationEnabled(); |
michael@0 | 1455 | |
michael@0 | 1456 | public: |
michael@0 | 1457 | bool AddRefreshObserver(nsARefreshObserver* aObserver, |
michael@0 | 1458 | mozFlushType aFlushType) { |
michael@0 | 1459 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 1460 | return AddRefreshObserverInternal(aObserver, aFlushType); |
michael@0 | 1461 | #else |
michael@0 | 1462 | return AddRefreshObserverExternal(aObserver, aFlushType); |
michael@0 | 1463 | #endif |
michael@0 | 1464 | } |
michael@0 | 1465 | |
michael@0 | 1466 | bool RemoveRefreshObserver(nsARefreshObserver* aObserver, |
michael@0 | 1467 | mozFlushType aFlushType) { |
michael@0 | 1468 | #ifdef MOZILLA_INTERNAL_API |
michael@0 | 1469 | return RemoveRefreshObserverInternal(aObserver, aFlushType); |
michael@0 | 1470 | #else |
michael@0 | 1471 | return RemoveRefreshObserverExternal(aObserver, aFlushType); |
michael@0 | 1472 | #endif |
michael@0 | 1473 | } |
michael@0 | 1474 | |
michael@0 | 1475 | virtual bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver); |
michael@0 | 1476 | virtual bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver); |
michael@0 | 1477 | |
michael@0 | 1478 | /** |
michael@0 | 1479 | * Initialize and shut down static variables. |
michael@0 | 1480 | */ |
michael@0 | 1481 | static void InitializeStatics(); |
michael@0 | 1482 | static void ReleaseStatics(); |
michael@0 | 1483 | |
michael@0 | 1484 | // If a frame in the subtree rooted at aFrame is capturing the mouse then |
michael@0 | 1485 | // clears that capture. |
michael@0 | 1486 | static void ClearMouseCapture(nsIFrame* aFrame); |
michael@0 | 1487 | |
michael@0 | 1488 | void SetScrollPositionClampingScrollPortSize(nscoord aWidth, nscoord aHeight); |
michael@0 | 1489 | bool IsScrollPositionClampingScrollPortSizeSet() { |
michael@0 | 1490 | return mScrollPositionClampingScrollPortSizeSet; |
michael@0 | 1491 | } |
michael@0 | 1492 | nsSize GetScrollPositionClampingScrollPortSize() { |
michael@0 | 1493 | NS_ASSERTION(mScrollPositionClampingScrollPortSizeSet, "asking for scroll port when its not set?"); |
michael@0 | 1494 | return mScrollPositionClampingScrollPortSize; |
michael@0 | 1495 | } |
michael@0 | 1496 | |
michael@0 | 1497 | void SetContentDocumentFixedPositionMargins(const nsMargin& aMargins); |
michael@0 | 1498 | const nsMargin& GetContentDocumentFixedPositionMargins() { |
michael@0 | 1499 | return mContentDocumentFixedPositionMargins; |
michael@0 | 1500 | } |
michael@0 | 1501 | |
michael@0 | 1502 | virtual void WindowSizeMoveDone() = 0; |
michael@0 | 1503 | virtual void SysColorChanged() = 0; |
michael@0 | 1504 | virtual void ThemeChanged() = 0; |
michael@0 | 1505 | virtual void BackingScaleFactorChanged() = 0; |
michael@0 | 1506 | |
michael@0 | 1507 | nscoord MaxLineBoxWidth() { |
michael@0 | 1508 | return mMaxLineBoxWidth; |
michael@0 | 1509 | } |
michael@0 | 1510 | |
michael@0 | 1511 | void SetMaxLineBoxWidth(nscoord aMaxLineBoxWidth); |
michael@0 | 1512 | |
michael@0 | 1513 | /** |
michael@0 | 1514 | * Returns whether or not there is a reflow on zoom event pending. A reflow |
michael@0 | 1515 | * on zoom event is a change to the max line box width, followed by a reflow. |
michael@0 | 1516 | * This subsequent reflow event should treat all frames as though they resized |
michael@0 | 1517 | * horizontally (and thus reflow all their descendants), rather than marking |
michael@0 | 1518 | * all frames dirty from the root. This is the way the pres shell indicates |
michael@0 | 1519 | * that an hresize reflow should take place during reflow state construction. |
michael@0 | 1520 | */ |
michael@0 | 1521 | bool IsReflowOnZoomPending() { |
michael@0 | 1522 | return mReflowOnZoomPending; |
michael@0 | 1523 | } |
michael@0 | 1524 | |
michael@0 | 1525 | /** |
michael@0 | 1526 | * Clear the flag indicating whether a reflow on zoom event is pending. This |
michael@0 | 1527 | * is performed at the very end of DoReflow(). |
michael@0 | 1528 | */ |
michael@0 | 1529 | void ClearReflowOnZoomPending() { |
michael@0 | 1530 | mReflowOnZoomPending = false; |
michael@0 | 1531 | } |
michael@0 | 1532 | |
michael@0 | 1533 | /** |
michael@0 | 1534 | * Documents belonging to an invisible DocShell must not be painted ever. |
michael@0 | 1535 | */ |
michael@0 | 1536 | bool IsNeverPainting() { |
michael@0 | 1537 | return mIsNeverPainting; |
michael@0 | 1538 | } |
michael@0 | 1539 | |
michael@0 | 1540 | void SetNeverPainting(bool aNeverPainting) { |
michael@0 | 1541 | mIsNeverPainting = aNeverPainting; |
michael@0 | 1542 | } |
michael@0 | 1543 | |
michael@0 | 1544 | protected: |
michael@0 | 1545 | friend class nsRefreshDriver; |
michael@0 | 1546 | |
michael@0 | 1547 | // IMPORTANT: The ownership implicit in the following member variables |
michael@0 | 1548 | // has been explicitly checked. If you add any members to this class, |
michael@0 | 1549 | // please make the ownership explicit (pinkerton, scc). |
michael@0 | 1550 | |
michael@0 | 1551 | // These are the same Document and PresContext owned by the DocViewer. |
michael@0 | 1552 | // we must share ownership. |
michael@0 | 1553 | nsIDocument* mDocument; // [STRONG] |
michael@0 | 1554 | nsPresContext* mPresContext; // [STRONG] |
michael@0 | 1555 | nsStyleSet* mStyleSet; // [OWNS] |
michael@0 | 1556 | nsCSSFrameConstructor* mFrameConstructor; // [OWNS] |
michael@0 | 1557 | nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to |
michael@0 | 1558 | nsPresArena mFrameArena; |
michael@0 | 1559 | nsFrameSelection* mSelection; |
michael@0 | 1560 | // Pointer into mFrameConstructor - this is purely so that FrameManager() and |
michael@0 | 1561 | // GetRootFrame() can be inlined: |
michael@0 | 1562 | nsFrameManagerBase* mFrameManager; |
michael@0 | 1563 | mozilla::WeakPtr<nsDocShell> mForwardingContainer; |
michael@0 | 1564 | nsRefreshDriver* mHiddenInvalidationObserverRefreshDriver; |
michael@0 | 1565 | #ifdef ACCESSIBILITY |
michael@0 | 1566 | mozilla::a11y::DocAccessible* mDocAccessible; |
michael@0 | 1567 | #endif |
michael@0 | 1568 | |
michael@0 | 1569 | #ifdef DEBUG |
michael@0 | 1570 | nsIFrame* mDrawEventTargetFrame; |
michael@0 | 1571 | // Ensure that every allocation from the PresArena is eventually freed. |
michael@0 | 1572 | uint32_t mPresArenaAllocCount; |
michael@0 | 1573 | #endif |
michael@0 | 1574 | |
michael@0 | 1575 | // Count of the number of times this presshell has been painted to a window. |
michael@0 | 1576 | uint64_t mPaintCount; |
michael@0 | 1577 | |
michael@0 | 1578 | nsSize mScrollPositionClampingScrollPortSize; |
michael@0 | 1579 | |
michael@0 | 1580 | // This margin is intended to be used when laying out fixed position children |
michael@0 | 1581 | // on this PresShell's viewport frame. See the documentation of |
michael@0 | 1582 | // nsIDOMWindowUtils.setContentDocumentFixedPositionMargins for details of |
michael@0 | 1583 | // their use. |
michael@0 | 1584 | nsMargin mContentDocumentFixedPositionMargins; |
michael@0 | 1585 | |
michael@0 | 1586 | // A list of weak frames. This is a pointer to the last item in the list. |
michael@0 | 1587 | nsWeakFrame* mWeakFrames; |
michael@0 | 1588 | |
michael@0 | 1589 | // Most recent canvas background color. |
michael@0 | 1590 | nscolor mCanvasBackgroundColor; |
michael@0 | 1591 | |
michael@0 | 1592 | // Used to force allocation and rendering of proportionally more or |
michael@0 | 1593 | // less pixels in the given dimension. |
michael@0 | 1594 | float mXResolution; |
michael@0 | 1595 | float mYResolution; |
michael@0 | 1596 | |
michael@0 | 1597 | int16_t mSelectionFlags; |
michael@0 | 1598 | |
michael@0 | 1599 | // Flags controlling how our document is rendered. These persist |
michael@0 | 1600 | // between paints and so are tied with retained layer pixels. |
michael@0 | 1601 | // PresShell flushes retained layers when the rendering state |
michael@0 | 1602 | // changes in a way that prevents us from being able to (usefully) |
michael@0 | 1603 | // re-use old pixels. |
michael@0 | 1604 | RenderFlags mRenderFlags; |
michael@0 | 1605 | |
michael@0 | 1606 | // Indicates that the whole document must be restyled. Changes to scoped |
michael@0 | 1607 | // style sheets are recorded in mChangedScopeStyleRoots rather than here |
michael@0 | 1608 | // in mStylesHaveChanged. |
michael@0 | 1609 | bool mStylesHaveChanged : 1; |
michael@0 | 1610 | bool mDidInitialize : 1; |
michael@0 | 1611 | bool mIsDestroying : 1; |
michael@0 | 1612 | bool mIsZombie : 1; |
michael@0 | 1613 | bool mIsReflowing : 1; |
michael@0 | 1614 | |
michael@0 | 1615 | // For all documents we initially lock down painting. |
michael@0 | 1616 | bool mPaintingSuppressed : 1; |
michael@0 | 1617 | |
michael@0 | 1618 | // Whether or not form controls should use nsITheme in this shell. |
michael@0 | 1619 | bool mIsThemeSupportDisabled : 1; |
michael@0 | 1620 | |
michael@0 | 1621 | bool mIsActive : 1; |
michael@0 | 1622 | bool mFrozen : 1; |
michael@0 | 1623 | bool mIsFirstPaint : 1; |
michael@0 | 1624 | bool mObservesMutationsForPrint : 1; |
michael@0 | 1625 | |
michael@0 | 1626 | // If true, we have a reflow scheduled. Guaranteed to be false if |
michael@0 | 1627 | // mReflowContinueTimer is non-null. |
michael@0 | 1628 | bool mReflowScheduled : 1; |
michael@0 | 1629 | |
michael@0 | 1630 | bool mSuppressInterruptibleReflows : 1; |
michael@0 | 1631 | bool mScrollPositionClampingScrollPortSizeSet : 1; |
michael@0 | 1632 | |
michael@0 | 1633 | uint32_t mPresShellId; |
michael@0 | 1634 | |
michael@0 | 1635 | // List of subtrees rooted at style scope roots that need to be restyled. |
michael@0 | 1636 | // When a change to a scoped style sheet is made, we add the style scope |
michael@0 | 1637 | // root to this array rather than setting mStylesHaveChanged = true, since |
michael@0 | 1638 | // we know we don't need to restyle the whole document. However, if in the |
michael@0 | 1639 | // same update block we have already had other changes that require |
michael@0 | 1640 | // the whole document to be restyled (i.e., mStylesHaveChanged is already |
michael@0 | 1641 | // true), then we don't bother adding the scope root here. |
michael@0 | 1642 | nsAutoTArray<nsRefPtr<mozilla::dom::Element>,1> mChangedScopeStyleRoots; |
michael@0 | 1643 | |
michael@0 | 1644 | static nsIContent* gKeyDownTarget; |
michael@0 | 1645 | |
michael@0 | 1646 | // Cached font inflation values. This is done to prevent changing of font |
michael@0 | 1647 | // inflation until a page is reloaded. |
michael@0 | 1648 | uint32_t mFontSizeInflationEmPerLine; |
michael@0 | 1649 | uint32_t mFontSizeInflationMinTwips; |
michael@0 | 1650 | uint32_t mFontSizeInflationLineThreshold; |
michael@0 | 1651 | bool mFontSizeInflationForceEnabled; |
michael@0 | 1652 | bool mFontSizeInflationDisabledInMasterProcess; |
michael@0 | 1653 | bool mFontSizeInflationEnabled; |
michael@0 | 1654 | bool mPaintingIsFrozen; |
michael@0 | 1655 | |
michael@0 | 1656 | // Dirty bit indicating that mFontSizeInflationEnabled needs to be recomputed. |
michael@0 | 1657 | bool mFontSizeInflationEnabledIsDirty; |
michael@0 | 1658 | |
michael@0 | 1659 | // Flag to indicate whether or not there is a reflow on zoom event pending. |
michael@0 | 1660 | // See IsReflowOnZoomPending() for more information. |
michael@0 | 1661 | bool mReflowOnZoomPending; |
michael@0 | 1662 | |
michael@0 | 1663 | // The maximum width of a line box. Text on a single line that exceeds this |
michael@0 | 1664 | // width will be wrapped. A value of 0 indicates that no limit is enforced. |
michael@0 | 1665 | nscoord mMaxLineBoxWidth; |
michael@0 | 1666 | |
michael@0 | 1667 | // If a document belongs to an invisible DocShell, this flag must be set |
michael@0 | 1668 | // to true, so we can avoid any paint calls for widget related to this |
michael@0 | 1669 | // presshell. |
michael@0 | 1670 | bool mIsNeverPainting; |
michael@0 | 1671 | }; |
michael@0 | 1672 | |
michael@0 | 1673 | NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell, NS_IPRESSHELL_IID) |
michael@0 | 1674 | |
michael@0 | 1675 | #endif /* nsIPresShell_h___ */ |