layout/base/nsIPresShell.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/nsIPresShell.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1675 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 + *
     1.9 + * This Original Code has been modified by IBM Corporation.
    1.10 + * Modifications made by IBM described herein are
    1.11 + * Copyright (c) International Business Machines
    1.12 + * Corporation, 2000
    1.13 + *
    1.14 + * Modifications to Mozilla code or documentation
    1.15 + * identified per MPL Section 3.3
    1.16 + *
    1.17 + * Date         Modified by     Description of modification
    1.18 + * 05/03/2000   IBM Corp.       Observer related defines for reflow
    1.19 + */
    1.20 +
    1.21 +/* a presentation of a document, part 2 */
    1.22 +
    1.23 +#ifndef nsIPresShell_h___
    1.24 +#define nsIPresShell_h___
    1.25 +
    1.26 +#include "mozilla/EventForwards.h"
    1.27 +#include "mozilla/MemoryReporting.h"
    1.28 +#include "mozilla/WeakPtr.h"
    1.29 +#include "gfxPoint.h"
    1.30 +#include "nsTHashtable.h"
    1.31 +#include "nsHashKeys.h"
    1.32 +#include "nsISupports.h"
    1.33 +#include "nsQueryFrame.h"
    1.34 +#include "nsCoord.h"
    1.35 +#include "nsColor.h"
    1.36 +#include "nsCompatibility.h"
    1.37 +#include "nsFrameManagerBase.h"
    1.38 +#include "mozFlushType.h"
    1.39 +#include "nsWeakReference.h"
    1.40 +#include <stdio.h> // for FILE definition
    1.41 +#include "nsChangeHint.h"
    1.42 +#include "nsRefPtrHashtable.h"
    1.43 +#include "nsClassHashtable.h"
    1.44 +#include "nsPresArena.h"
    1.45 +#include "nsIImageLoadingContent.h"
    1.46 +#include "nsMargin.h"
    1.47 +#include "nsFrameState.h"
    1.48 +
    1.49 +class nsIContent;
    1.50 +class nsDocShell;
    1.51 +class nsIDocument;
    1.52 +class nsIFrame;
    1.53 +class nsPresContext;
    1.54 +class nsStyleSet;
    1.55 +class nsViewManager;
    1.56 +class nsView;
    1.57 +class nsRenderingContext;
    1.58 +class nsIPageSequenceFrame;
    1.59 +class nsAString;
    1.60 +class nsCaret;
    1.61 +class nsFrameSelection;
    1.62 +class nsFrameManager;
    1.63 +class nsILayoutHistoryState;
    1.64 +class nsIReflowCallback;
    1.65 +class nsIDOMNode;
    1.66 +class nsIntRegion;
    1.67 +class nsIStyleSheet;
    1.68 +class nsCSSFrameConstructor;
    1.69 +class nsISelection;
    1.70 +template<class E> class nsCOMArray;
    1.71 +class nsWeakFrame;
    1.72 +class nsIScrollableFrame;
    1.73 +class gfxContext;
    1.74 +class nsIDOMEvent;
    1.75 +class nsDisplayList;
    1.76 +class nsDisplayListBuilder;
    1.77 +class nsPIDOMWindow;
    1.78 +struct nsPoint;
    1.79 +struct nsIntPoint;
    1.80 +struct nsIntRect;
    1.81 +struct nsRect;
    1.82 +class nsRegion;
    1.83 +class nsRefreshDriver;
    1.84 +class nsARefreshObserver;
    1.85 +class nsAPostRefreshObserver;
    1.86 +#ifdef ACCESSIBILITY
    1.87 +class nsAccessibilityService;
    1.88 +namespace mozilla {
    1.89 +namespace a11y {
    1.90 +class DocAccessible;
    1.91 +} // namespace a11y
    1.92 +} // namespace mozilla
    1.93 +#endif
    1.94 +class nsIWidget;
    1.95 +struct nsArenaMemoryStats;
    1.96 +
    1.97 +typedef short SelectionType;
    1.98 +
    1.99 +namespace mozilla {
   1.100 +class EventStates;
   1.101 +
   1.102 +namespace dom {
   1.103 +class Element;
   1.104 +class Touch;
   1.105 +class Selection;
   1.106 +class ShadowRoot;
   1.107 +} // namespace dom
   1.108 +
   1.109 +namespace layers {
   1.110 +class LayerManager;
   1.111 +} // namespace layers
   1.112 +
   1.113 +namespace gfx {
   1.114 +class SourceSurface;
   1.115 +} // namespace gfx
   1.116 +} // namespace mozilla
   1.117 +
   1.118 +// Flags to pass to SetCapturingContent
   1.119 +//
   1.120 +// when assigning capture, ignore whether capture is allowed or not
   1.121 +#define CAPTURE_IGNOREALLOWED 1
   1.122 +// true if events should be targeted at the capturing content or its children
   1.123 +#define CAPTURE_RETARGETTOELEMENT 2
   1.124 +// true if the current capture wants drags to be prevented
   1.125 +#define CAPTURE_PREVENTDRAG 4
   1.126 +// true when the mouse is pointer locked, and events are sent to locked element
   1.127 +#define CAPTURE_POINTERLOCK 8
   1.128 +
   1.129 +typedef struct CapturingContentInfo {
   1.130 +  // capture should only be allowed during a mousedown event
   1.131 +  bool mAllowed;
   1.132 +  bool mPointerLock;
   1.133 +  bool mRetargetToElement;
   1.134 +  bool mPreventDrag;
   1.135 +  nsIContent* mContent;
   1.136 +} CapturingContentInfo;
   1.137 +
   1.138 +//61e60df7-128a-4cdd-a684-5f0bd2ceb61f
   1.139 +#define NS_IPRESSHELL_IID \
   1.140 +{ 0x61e60df7, 0x128a, 0x4cdd, \
   1.141 +  {0xa6, 0x84, 0x5f, 0x0b, 0xd2, 0xce, 0xb6, 0x1f}}
   1.142 +
   1.143 +// debug VerifyReflow flags
   1.144 +#define VERIFY_REFLOW_ON                    0x01
   1.145 +#define VERIFY_REFLOW_NOISY                 0x02
   1.146 +#define VERIFY_REFLOW_ALL                   0x04
   1.147 +#define VERIFY_REFLOW_DUMP_COMMANDS         0x08
   1.148 +#define VERIFY_REFLOW_NOISY_RC              0x10
   1.149 +#define VERIFY_REFLOW_REALLY_NOISY_RC       0x20
   1.150 +#define VERIFY_REFLOW_DURING_RESIZE_REFLOW  0x40
   1.151 +
   1.152 +#undef NOISY_INTERRUPTIBLE_REFLOW
   1.153 +
   1.154 +enum nsRectVisibility {
   1.155 +  nsRectVisibility_kVisible,
   1.156 +  nsRectVisibility_kAboveViewport,
   1.157 +  nsRectVisibility_kBelowViewport,
   1.158 +  nsRectVisibility_kLeftOfViewport,
   1.159 +  nsRectVisibility_kRightOfViewport
   1.160 +};
   1.161 +
   1.162 +/**
   1.163 + * Presentation shell interface. Presentation shells are the
   1.164 + * controlling point for managing the presentation of a document. The
   1.165 + * presentation shell holds a live reference to the document, the
   1.166 + * presentation context, the style manager, the style set and the root
   1.167 + * frame. <p>
   1.168 + *
   1.169 + * When this object is Release'd, it will release the document, the
   1.170 + * presentation context, the style manager, the style set and the root
   1.171 + * frame.
   1.172 + */
   1.173 +
   1.174 +class nsIPresShell : public nsISupports
   1.175 +{
   1.176 +public:
   1.177 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID)
   1.178 +
   1.179 +protected:
   1.180 +  typedef mozilla::layers::LayerManager LayerManager;
   1.181 +  typedef mozilla::gfx::SourceSurface SourceSurface;
   1.182 +
   1.183 +  enum eRenderFlag {
   1.184 +    STATE_IGNORING_VIEWPORT_SCROLLING = 0x1,
   1.185 +    STATE_DRAWWINDOW_NOT_FLUSHING = 0x2
   1.186 +  };
   1.187 +  typedef uint8_t RenderFlags; // for storing the above flags
   1.188 +
   1.189 +public:
   1.190 +  /**
   1.191 +   * All callers are responsible for calling |Destroy| after calling
   1.192 +   * |EndObservingDocument|.  It needs to be separate only because form
   1.193 +   * controls incorrectly store their data in the frames rather than the
   1.194 +   * content model and printing calls |EndObservingDocument| multiple
   1.195 +   * times to make form controls behave nicely when printed.
   1.196 +   */
   1.197 +  virtual NS_HIDDEN_(void) Destroy() = 0;
   1.198 +
   1.199 +  bool IsDestroying() { return mIsDestroying; }
   1.200 +
   1.201 +  /**
   1.202 +   * Make a one-way transition into a "zombie" state.  In this state,
   1.203 +   * no reflow is done, no painting is done, and no refresh driver
   1.204 +   * ticks are processed.  This is a dangerous state: it can leave
   1.205 +   * areas of the composition target unpainted if callers aren't
   1.206 +   * careful.  (Don't let your zombie presshell out of the shed.)
   1.207 +   *
   1.208 +   * This is used in cases where a presshell is created for reasons
   1.209 +   * other than reflow/painting.
   1.210 +   */
   1.211 +  virtual NS_HIDDEN_(void) MakeZombie() = 0;
   1.212 +
   1.213 +  /**
   1.214 +   * All frames owned by the shell are allocated from an arena.  They
   1.215 +   * are also recycled using free lists.  Separate free lists are
   1.216 +   * maintained for each frame type (aID), which must always correspond
   1.217 +   * to the same aSize value.  AllocateFrame returns zero-filled memory.
   1.218 +   * AllocateFrame is infallible and will abort on out-of-memory.
   1.219 +   */
   1.220 +  void* AllocateFrame(nsQueryFrame::FrameIID aID, size_t aSize)
   1.221 +  {
   1.222 +#ifdef DEBUG
   1.223 +    mPresArenaAllocCount++;
   1.224 +#endif
   1.225 +    void* result = mFrameArena.AllocateByFrameID(aID, aSize);
   1.226 +    memset(result, 0, aSize);
   1.227 +    return result;
   1.228 +  }
   1.229 +
   1.230 +  void FreeFrame(nsQueryFrame::FrameIID aID, void* aPtr)
   1.231 +  {
   1.232 +#ifdef DEBUG
   1.233 +    mPresArenaAllocCount--;
   1.234 +#endif
   1.235 +    if (!mIsDestroying)
   1.236 +      mFrameArena.FreeByFrameID(aID, aPtr);
   1.237 +  }
   1.238 +
   1.239 +  /**
   1.240 +   * This is for allocating other types of objects (not frames).  Separate free
   1.241 +   * lists are maintained for each type (aID), which must always correspond to
   1.242 +   * the same aSize value.  AllocateByObjectID returns zero-filled memory.
   1.243 +   * AllocateByObjectID is infallible and will abort on out-of-memory.
   1.244 +   */
   1.245 +  void* AllocateByObjectID(nsPresArena::ObjectID aID, size_t aSize)
   1.246 +  {
   1.247 +#ifdef DEBUG
   1.248 +    mPresArenaAllocCount++;
   1.249 +#endif
   1.250 +    void* result = mFrameArena.AllocateByObjectID(aID, aSize);
   1.251 +    memset(result, 0, aSize);
   1.252 +    return result;
   1.253 +  }
   1.254 +
   1.255 +  void FreeByObjectID(nsPresArena::ObjectID aID, void* aPtr)
   1.256 +  {
   1.257 +#ifdef DEBUG
   1.258 +    mPresArenaAllocCount--;
   1.259 +#endif
   1.260 +    if (!mIsDestroying)
   1.261 +      mFrameArena.FreeByObjectID(aID, aPtr);
   1.262 +  }
   1.263 +
   1.264 +  /**
   1.265 +   * Other objects closely related to the frame tree that are allocated
   1.266 +   * from a separate set of per-size free lists.  Note that different types
   1.267 +   * of objects that has the same size are allocated from the same list.
   1.268 +   * AllocateMisc does *not* clear the memory that it returns.
   1.269 +   * AllocateMisc is infallible and will abort on out-of-memory.
   1.270 +   *
   1.271 +   * @deprecated use AllocateByObjectID/FreeByObjectID instead
   1.272 +   */
   1.273 +  void* AllocateMisc(size_t aSize)
   1.274 +  {
   1.275 +#ifdef DEBUG
   1.276 +    mPresArenaAllocCount++;
   1.277 +#endif
   1.278 +    return mFrameArena.AllocateBySize(aSize);
   1.279 +  }
   1.280 +
   1.281 +  void FreeMisc(size_t aSize, void* aPtr)
   1.282 +  {
   1.283 +#ifdef DEBUG
   1.284 +    mPresArenaAllocCount--;
   1.285 +#endif
   1.286 +    if (!mIsDestroying)
   1.287 +      mFrameArena.FreeBySize(aSize, aPtr);
   1.288 +  }
   1.289 +
   1.290 +  nsIDocument* GetDocument() const { return mDocument; }
   1.291 +
   1.292 +  nsPresContext* GetPresContext() const { return mPresContext; }
   1.293 +
   1.294 +  nsViewManager* GetViewManager() const { return mViewManager; }
   1.295 +
   1.296 +#ifdef ACCESSIBILITY
   1.297 +  /**
   1.298 +   * Return the document accessible for this pres shell if there is one.
   1.299 +   */
   1.300 +  mozilla::a11y::DocAccessible* GetDocAccessible() const
   1.301 +  {
   1.302 +    return mDocAccessible;
   1.303 +  }
   1.304 +
   1.305 +  /**
   1.306 +   * Set the document accessible for this pres shell.
   1.307 +   */
   1.308 +  void SetDocAccessible(mozilla::a11y::DocAccessible* aDocAccessible)
   1.309 +  {
   1.310 +    mDocAccessible = aDocAccessible;
   1.311 +  }
   1.312 +#endif
   1.313 +
   1.314 +#ifdef MOZILLA_INTERNAL_API
   1.315 +  nsStyleSet* StyleSet() const { return mStyleSet; }
   1.316 +
   1.317 +  nsCSSFrameConstructor* FrameConstructor() const { return mFrameConstructor; }
   1.318 +
   1.319 +  nsFrameManager* FrameManager() const {
   1.320 +    // reinterpret_cast is valid since nsFrameManager does not add
   1.321 +    // any members over nsFrameManagerBase.
   1.322 +    return reinterpret_cast<nsFrameManager*>
   1.323 +                           (const_cast<nsIPresShell*>(this)->mFrameManager);
   1.324 +  }
   1.325 +
   1.326 +#endif
   1.327 +
   1.328 +  /* Enable/disable author style level. Disabling author style disables the entire
   1.329 +   * author level of the cascade, including the HTML preshint level.
   1.330 +   */
   1.331 +  // XXX these could easily be inlined, but there is a circular #include
   1.332 +  // problem with nsStyleSet.
   1.333 +  NS_HIDDEN_(void) SetAuthorStyleDisabled(bool aDisabled);
   1.334 +  NS_HIDDEN_(bool) GetAuthorStyleDisabled() const;
   1.335 +
   1.336 +  /*
   1.337 +   * Called when stylesheets are added/removed/enabled/disabled to rebuild
   1.338 +   * all style data for a given pres shell without necessarily reconstructing
   1.339 +   * all of the frames.  This will not reconstruct style synchronously; if
   1.340 +   * you need to do that, call FlushPendingNotifications to flush out style
   1.341 +   * reresolves.
   1.342 +   * // XXXbz why do we have this on the interface anyway?  The only consumer
   1.343 +   * is calling AddOverrideStyleSheet/RemoveOverrideStyleSheet, and I think
   1.344 +   * those should just handle reconstructing style data...
   1.345 +   */
   1.346 +  virtual NS_HIDDEN_(void) ReconstructStyleDataExternal();
   1.347 +  NS_HIDDEN_(void) ReconstructStyleDataInternal();
   1.348 +#ifdef MOZILLA_INTERNAL_API
   1.349 +  void ReconstructStyleData() { ReconstructStyleDataInternal(); }
   1.350 +#else
   1.351 +  void ReconstructStyleData() { ReconstructStyleDataExternal(); }
   1.352 +#endif
   1.353 +
   1.354 +  /** Setup all style rules required to implement preferences
   1.355 +   * - used for background/text/link colors and link underlining
   1.356 +   *    may be extended for any prefs that are implemented via style rules
   1.357 +   * - aForceReflow argument is used to force a full reframe to make the rules show
   1.358 +   *   (only used when the current page needs to reflect changed pref rules)
   1.359 +   *
   1.360 +   * - initially created for bugs 31816, 20760, 22963
   1.361 +   */
   1.362 +  virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(bool aForceReflow) = 0;
   1.363 +
   1.364 +  /**
   1.365 +   * FrameSelection will return the Frame based selection API.
   1.366 +   * You cannot go back and forth anymore with QI between nsIDOM sel and
   1.367 +   * nsIFrame sel.
   1.368 +   */
   1.369 +  already_AddRefed<nsFrameSelection> FrameSelection();
   1.370 +
   1.371 +  /**
   1.372 +   * ConstFrameSelection returns an object which methods are safe to use for
   1.373 +   * example in nsIFrame code.
   1.374 +   */
   1.375 +  const nsFrameSelection* ConstFrameSelection() const { return mSelection; }
   1.376 +
   1.377 +  // Make shell be a document observer.  If called after Destroy() has
   1.378 +  // been called on the shell, this will be ignored.
   1.379 +  virtual NS_HIDDEN_(void) BeginObservingDocument() = 0;
   1.380 +
   1.381 +  // Make shell stop being a document observer
   1.382 +  virtual NS_HIDDEN_(void) EndObservingDocument() = 0;
   1.383 +
   1.384 +  /**
   1.385 +   * Return whether Initialize() was previously called.
   1.386 +   */
   1.387 +  bool DidInitialize() const { return mDidInitialize; }
   1.388 +
   1.389 +  /**
   1.390 +   * Perform initialization. Constructs the frame for the root content
   1.391 +   * object and then enqueues a reflow of the frame model into the
   1.392 +   * specified width and height.
   1.393 +   *
   1.394 +   * The coordinates for aWidth and aHeight must be in standard nscoords.
   1.395 +   *
   1.396 +   * Callers of this method must hold a reference to this shell that
   1.397 +   * is guaranteed to survive through arbitrary script execution.
   1.398 +   * Calling Initialize can execute arbitrary script.
   1.399 +   */
   1.400 +  virtual NS_HIDDEN_(nsresult) Initialize(nscoord aWidth, nscoord aHeight) = 0;
   1.401 +
   1.402 +  /**
   1.403 +   * Reflow the frame model into a new width and height.  The
   1.404 +   * coordinates for aWidth and aHeight must be in standard nscoord's.
   1.405 +   */
   1.406 +  virtual NS_HIDDEN_(nsresult) ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
   1.407 +  /**
   1.408 +   * Reflow, and also change presshell state so as to only permit
   1.409 +   * reflowing off calls to ResizeReflowOverride() in the future.
   1.410 +   * ResizeReflow() calls are ignored after ResizeReflowOverride().
   1.411 +   */
   1.412 +  virtual NS_HIDDEN_(nsresult) ResizeReflowOverride(nscoord aWidth, nscoord aHeight) = 0;
   1.413 +
   1.414 +  /**
   1.415 +   * Returns true if ResizeReflowOverride has been called.
   1.416 +   */
   1.417 +  virtual bool GetIsViewportOverridden() = 0;
   1.418 +
   1.419 +  /**
   1.420 +   * Return true if the presshell expects layout flush.
   1.421 +   */
   1.422 +  virtual bool IsLayoutFlushObserver() = 0;
   1.423 +
   1.424 +  /**
   1.425 +   * Called when document load completes.
   1.426 +   */
   1.427 +  virtual NS_HIDDEN_(void) LoadComplete() = 0;
   1.428 +
   1.429 +  /**
   1.430 +   * This calls through to the frame manager to get the root frame.
   1.431 +   */
   1.432 +  virtual NS_HIDDEN_(nsIFrame*) GetRootFrameExternal() const;
   1.433 +  nsIFrame* GetRootFrame() const {
   1.434 +#ifdef MOZILLA_INTERNAL_API
   1.435 +    return mFrameManager->GetRootFrame();
   1.436 +#else
   1.437 +    return GetRootFrameExternal();
   1.438 +#endif
   1.439 +  }
   1.440 +
   1.441 +  /*
   1.442 +   * Get root scroll frame from FrameManager()->GetRootFrame().
   1.443 +   */
   1.444 +  nsIFrame* GetRootScrollFrame() const;
   1.445 +
   1.446 +  /*
   1.447 +   * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
   1.448 +   */
   1.449 +  nsIScrollableFrame* GetRootScrollFrameAsScrollable() const;
   1.450 +
   1.451 +  /*
   1.452 +   * The same as GetRootScrollFrame, but returns an nsIScrollableFrame.
   1.453 +   * Can be called by code not linked into gklayout.
   1.454 +   */
   1.455 +  virtual nsIScrollableFrame* GetRootScrollFrameAsScrollableExternal() const;
   1.456 +
   1.457 +  /*
   1.458 +   * Gets nearest scrollable frame from current focused content or DOM
   1.459 +   * selection if there is no focused content. The frame is scrollable with
   1.460 +   * overflow:scroll or overflow:auto in some direction when aDirection is
   1.461 +   * eEither.  Otherwise, this returns a nearest frame that is scrollable in
   1.462 +   * the specified direction.
   1.463 +   */
   1.464 +  enum ScrollDirection { eHorizontal, eVertical, eEither };
   1.465 +  nsIScrollableFrame* GetFrameToScrollAsScrollable(ScrollDirection aDirection);
   1.466 +
   1.467 +  /**
   1.468 +   * Returns the page sequence frame associated with the frame hierarchy.
   1.469 +   * Returns nullptr if not a paginated view.
   1.470 +   */
   1.471 +  virtual NS_HIDDEN_(nsIPageSequenceFrame*) GetPageSequenceFrame() const = 0;
   1.472 +
   1.473 +  /**
   1.474 +   * Gets the real primary frame associated with the content object.
   1.475 +   *
   1.476 +   * In the case of absolutely positioned elements and floated elements,
   1.477 +   * the real primary frame is the frame that is out of the flow and not the
   1.478 +   * placeholder frame.
   1.479 +   */
   1.480 +  virtual NS_HIDDEN_(nsIFrame*) GetRealPrimaryFrameFor(nsIContent* aContent) const = 0;
   1.481 +
   1.482 +  /**
   1.483 +   * Gets the placeholder frame associated with the specified frame. This is
   1.484 +   * a helper frame that forwards the request to the frame manager.
   1.485 +   */
   1.486 +  virtual NS_HIDDEN_(nsIFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame) const = 0;
   1.487 +
   1.488 +  /**
   1.489 +   * Tell the pres shell that a frame needs to be marked dirty and needs
   1.490 +   * Reflow.  It's OK if this is an ancestor of the frame needing reflow as
   1.491 +   * long as the ancestor chain between them doesn't cross a reflow root.
   1.492 +   *
   1.493 +   * The bit to add should be NS_FRAME_IS_DIRTY, NS_FRAME_HAS_DIRTY_CHILDREN
   1.494 +   * or nsFrameState(0); passing 0 means that dirty bits won't be set on the
   1.495 +   * frame or its ancestors/descendants, but that intrinsic widths will still
   1.496 +   * be marked dirty.  Passing aIntrinsicDirty = eResize and aBitToAdd = 0
   1.497 +   * would result in no work being done, so don't do that.
   1.498 +   */
   1.499 +  enum IntrinsicDirty {
   1.500 +    // XXXldb eResize should be renamed
   1.501 +    eResize,     // don't mark any intrinsic widths dirty
   1.502 +    eTreeChange, // mark intrinsic widths dirty on aFrame and its ancestors
   1.503 +    eStyleChange // Do eTreeChange, plus all of aFrame's descendants
   1.504 +  };
   1.505 +  virtual NS_HIDDEN_(void) FrameNeedsReflow(nsIFrame *aFrame,
   1.506 +                                            IntrinsicDirty aIntrinsicDirty,
   1.507 +                                            nsFrameState aBitToAdd) = 0;
   1.508 +
   1.509 +  /**
   1.510 +   * Calls FrameNeedsReflow on all fixed position children of the root frame.
   1.511 +   */
   1.512 +  virtual void MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty);
   1.513 +
   1.514 +  /**
   1.515 +   * Tell the presshell that the given frame's reflow was interrupted.  This
   1.516 +   * will mark as having dirty children a path from the given frame (inclusive)
   1.517 +   * to the nearest ancestor with a dirty subtree, or to the reflow root
   1.518 +   * currently being reflowed if no such ancestor exists (inclusive).  This is
   1.519 +   * to be done immediately after reflow of the current reflow root completes.
   1.520 +   * This method must only be called during reflow, and the frame it's being
   1.521 +   * called on must be in the process of being reflowed when it's called.  This
   1.522 +   * method doesn't mark any intrinsic widths dirty and doesn't add any bits
   1.523 +   * other than NS_FRAME_HAS_DIRTY_CHILDREN.
   1.524 +   */
   1.525 +  virtual NS_HIDDEN_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame) = 0;
   1.526 +
   1.527 +  virtual NS_HIDDEN_(void) CancelAllPendingReflows() = 0;
   1.528 +
   1.529 +  /**
   1.530 +   * Recreates the frames for a node
   1.531 +   */
   1.532 +  virtual NS_HIDDEN_(nsresult) RecreateFramesFor(nsIContent* aContent) = 0;
   1.533 +
   1.534 +  void PostRecreateFramesFor(mozilla::dom::Element* aElement);
   1.535 +  void RestyleForAnimation(mozilla::dom::Element* aElement,
   1.536 +                           nsRestyleHint aHint);
   1.537 +
   1.538 +  // ShadowRoot has APIs that can change styles so we only
   1.539 +  // want to restyle elements in the ShadowRoot and not the whole
   1.540 +  // document.
   1.541 +  virtual void RestyleShadowRoot(mozilla::dom::ShadowRoot* aShadowRoot) = 0;
   1.542 +
   1.543 +  /**
   1.544 +   * Determine if it is safe to flush all pending notifications
   1.545 +   * @param aIsSafeToFlush true if it is safe, false otherwise.
   1.546 +   *
   1.547 +   */
   1.548 +  virtual NS_HIDDEN_(bool) IsSafeToFlush() const = 0;
   1.549 +
   1.550 +  /**
   1.551 +   * Flush pending notifications of the type specified.  This method
   1.552 +   * will not affect the content model; it'll just affect style and
   1.553 +   * frames. Callers that actually want up-to-date presentation (other
   1.554 +   * than the document itself) should probably be calling
   1.555 +   * nsIDocument::FlushPendingNotifications.
   1.556 +   *
   1.557 +   * @param aType the type of notifications to flush
   1.558 +   */
   1.559 +  virtual NS_HIDDEN_(void) FlushPendingNotifications(mozFlushType aType) = 0;
   1.560 +  virtual NS_HIDDEN_(void) FlushPendingNotifications(mozilla::ChangesToFlush aType) = 0;
   1.561 +
   1.562 +  /**
   1.563 +   * Callbacks will be called even if reflow itself fails for
   1.564 +   * some reason.
   1.565 +   */
   1.566 +  virtual NS_HIDDEN_(nsresult) PostReflowCallback(nsIReflowCallback* aCallback) = 0;
   1.567 +  virtual NS_HIDDEN_(void) CancelReflowCallback(nsIReflowCallback* aCallback) = 0;
   1.568 +
   1.569 +  virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame) = 0;
   1.570 +
   1.571 +  /**
   1.572 +   * Get a reference rendering context. This is a context that should not
   1.573 +   * be rendered to, but is suitable for measuring text and performing
   1.574 +   * other non-rendering operations. Guaranteed to return non-null.
   1.575 +   */
   1.576 +  virtual already_AddRefed<nsRenderingContext> CreateReferenceRenderingContext() = 0;
   1.577 +
   1.578 +  /**
   1.579 +   * Informs the pres shell that the document is now at the anchor with
   1.580 +   * the given name.  If |aScroll| is true, scrolls the view of the
   1.581 +   * document so that the anchor with the specified name is displayed at
   1.582 +   * the top of the window.  If |aAnchorName| is empty, then this informs
   1.583 +   * the pres shell that there is no current target, and |aScroll| must
   1.584 +   * be false.
   1.585 +   */
   1.586 +  virtual NS_HIDDEN_(nsresult) GoToAnchor(const nsAString& aAnchorName, bool aScroll) = 0;
   1.587 +
   1.588 +  /**
   1.589 +   * Tells the presshell to scroll again to the last anchor scrolled to by
   1.590 +   * GoToAnchor, if any. This scroll only happens if the scroll
   1.591 +   * position has not changed since the last GoToAnchor. This is called
   1.592 +   * by nsDocumentViewer::LoadComplete. This clears the last anchor
   1.593 +   * scrolled to by GoToAnchor (we don't want to keep it alive if it's
   1.594 +   * removed from the DOM), so don't call this more than once.
   1.595 +   */
   1.596 +  virtual NS_HIDDEN_(nsresult) ScrollToAnchor() = 0;
   1.597 +
   1.598 +  enum {
   1.599 +    SCROLL_TOP     = 0,
   1.600 +    SCROLL_BOTTOM  = 100,
   1.601 +    SCROLL_LEFT    = 0,
   1.602 +    SCROLL_RIGHT   = 100,
   1.603 +    SCROLL_CENTER  = 50,
   1.604 +    SCROLL_MINIMUM = -1
   1.605 +  };
   1.606 +
   1.607 +  enum WhenToScroll {
   1.608 +    SCROLL_ALWAYS,
   1.609 +    SCROLL_IF_NOT_VISIBLE,
   1.610 +    SCROLL_IF_NOT_FULLY_VISIBLE
   1.611 +  };
   1.612 +  typedef struct ScrollAxis {
   1.613 +    int16_t mWhereToScroll;
   1.614 +    WhenToScroll mWhenToScroll : 8;
   1.615 +    bool mOnlyIfPerceivedScrollableDirection : 1;
   1.616 +  /**
   1.617 +   * @param aWhere: Either a percentage or a special value.
   1.618 +   *                nsIPresShell defines:
   1.619 +   *                * (Default) SCROLL_MINIMUM = -1: The visible area is
   1.620 +   *                scrolled to show the entire frame. If the frame is too
   1.621 +   *                large, the top and left edges are given precedence.
   1.622 +   *                * SCROLL_TOP = 0: The frame's upper edge is aligned with the
   1.623 +   *                top edge of the visible area.
   1.624 +   *                * SCROLL_BOTTOM = 100: The frame's bottom edge is aligned
   1.625 +   *                with the bottom edge of the visible area.
   1.626 +   *                * SCROLL_LEFT = 0: The frame's left edge is aligned with the
   1.627 +   *                left edge of the visible area.
   1.628 +   *                * SCROLL_RIGHT = 100: The frame's right edge is aligned with
   1.629 +   *                the right edge of the visible area.
   1.630 +   *                * SCROLL_CENTER = 50: The frame is centered along the axis
   1.631 +   *                the ScrollAxis is used for.
   1.632 +   *
   1.633 +   *                Other values are treated as a percentage, and the point
   1.634 +   *                "percent" down the frame is placed at the point "percent"
   1.635 +   *                down the visible area.
   1.636 +   * @param aWhen:
   1.637 +   *                * (Default) SCROLL_IF_NOT_FULLY_VISIBLE: Move the frame only
   1.638 +   *                if it is not fully visible (including if it's not visible
   1.639 +   *                at all). Note that in this case if the frame is too large to
   1.640 +   *                fit in view, it will only be scrolled if more of it can fit
   1.641 +   *                than is already in view.
   1.642 +   *                * SCROLL_IF_NOT_VISIBLE: Move the frame only if none of it
   1.643 +   *                is visible.
   1.644 +   *                * SCROLL_ALWAYS: Move the frame regardless of its current
   1.645 +   *                visibility.
   1.646 +   * @param aOnlyIfPerceivedScrollableDirection:
   1.647 +   *                If the direction is not a perceived scrollable direction (i.e.
   1.648 +   *                no scrollbar showing and less than one device pixel of
   1.649 +   *                scrollable distance), don't scroll. Defaults to false.
   1.650 +   */
   1.651 +    ScrollAxis(int16_t aWhere = SCROLL_MINIMUM,
   1.652 +               WhenToScroll aWhen = SCROLL_IF_NOT_FULLY_VISIBLE,
   1.653 +               bool aOnlyIfPerceivedScrollableDirection = false) :
   1.654 +      mWhereToScroll(aWhere), mWhenToScroll(aWhen),
   1.655 +      mOnlyIfPerceivedScrollableDirection(aOnlyIfPerceivedScrollableDirection)
   1.656 +    {}
   1.657 +  } ScrollAxis;
   1.658 +  /**
   1.659 +   * Scrolls the view of the document so that the primary frame of the content
   1.660 +   * is displayed in the window. Layout is flushed before scrolling.
   1.661 +   *
   1.662 +   * @param aContent  The content object of which primary frame should be
   1.663 +   *                  scrolled into view.
   1.664 +   * @param aVertical How to align the frame vertically and when to do so.
   1.665 +   *                  This is a ScrollAxis of Where and When.
   1.666 +   * @param aHorizontal How to align the frame horizontally and when to do so.
   1.667 +   *                  This is a ScrollAxis of Where and When.
   1.668 +   * @param aFlags    If SCROLL_FIRST_ANCESTOR_ONLY is set, only the nearest
   1.669 +   *                  scrollable ancestor is scrolled, otherwise all
   1.670 +   *                  scrollable ancestors may be scrolled if necessary.
   1.671 +   *                  If SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a
   1.672 +   *                  direction even if overflow:hidden is specified in that
   1.673 +   *                  direction; otherwise we will not scroll in that direction
   1.674 +   *                  when overflow:hidden is set for that direction.
   1.675 +   *                  If SCROLL_NO_PARENT_FRAMES is set then we only scroll
   1.676 +   *                  nodes in this document, not in any parent documents which
   1.677 +   *                  contain this document in a iframe or the like.
   1.678 +   */
   1.679 +  virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent,
   1.680 +                                                     ScrollAxis  aVertical,
   1.681 +                                                     ScrollAxis  aHorizontal,
   1.682 +                                                     uint32_t    aFlags) = 0;
   1.683 +
   1.684 +  enum {
   1.685 +    SCROLL_FIRST_ANCESTOR_ONLY = 0x01,
   1.686 +    SCROLL_OVERFLOW_HIDDEN = 0x02,
   1.687 +    SCROLL_NO_PARENT_FRAMES = 0x04
   1.688 +  };
   1.689 +  /**
   1.690 +   * Scrolls the view of the document so that the given area of a frame
   1.691 +   * is visible, if possible. Layout is not flushed before scrolling.
   1.692 +   *
   1.693 +   * @param aRect relative to aFrame
   1.694 +   * @param aVertical see ScrollContentIntoView and ScrollAxis
   1.695 +   * @param aHorizontal see ScrollContentIntoView and ScrollAxis
   1.696 +   * @param aFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
   1.697 +   * nearest scrollable ancestor is scrolled, otherwise all
   1.698 +   * scrollable ancestors may be scrolled if necessary
   1.699 +   * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction
   1.700 +   * even if overflow:hidden is specified in that direction; otherwise
   1.701 +   * we will not scroll in that direction when overflow:hidden is
   1.702 +   * set for that direction
   1.703 +   * If SCROLL_NO_PARENT_FRAMES is set then we only scroll
   1.704 +   * nodes in this document, not in any parent documents which
   1.705 +   * contain this document in a iframe or the like.
   1.706 +   * @return true if any scrolling happened, false if no scrolling happened
   1.707 +   */
   1.708 +  virtual bool ScrollFrameRectIntoView(nsIFrame*     aFrame,
   1.709 +                                       const nsRect& aRect,
   1.710 +                                       ScrollAxis    aVertical,
   1.711 +                                       ScrollAxis    aHorizontal,
   1.712 +                                       uint32_t      aFlags) = 0;
   1.713 +
   1.714 +  /**
   1.715 +   * Determine if a rectangle specified in the frame's coordinate system
   1.716 +   * intersects the viewport "enough" to be considered visible.
   1.717 +   * @param aFrame frame that aRect coordinates are specified relative to
   1.718 +   * @param aRect rectangle in twips to test for visibility
   1.719 +   * @param aMinTwips is the minimum distance in from the edge of the viewport
   1.720 +   *                  that an object must be to be counted visible
   1.721 +   * @return nsRectVisibility_kVisible if the rect is visible
   1.722 +   *         nsRectVisibility_kAboveViewport
   1.723 +   *         nsRectVisibility_kBelowViewport
   1.724 +   *         nsRectVisibility_kLeftOfViewport
   1.725 +   *         nsRectVisibility_kRightOfViewport rectangle is outside the viewport
   1.726 +   *         in the specified direction
   1.727 +   */
   1.728 +  virtual nsRectVisibility GetRectVisibility(nsIFrame *aFrame,
   1.729 +                                             const nsRect &aRect,
   1.730 +                                             nscoord aMinTwips) const = 0;
   1.731 +
   1.732 +  /**
   1.733 +   * Suppress notification of the frame manager that frames are
   1.734 +   * being destroyed.
   1.735 +   */
   1.736 +  virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(bool aIgnore) = 0;
   1.737 +
   1.738 +  /**
   1.739 +   * Notification sent by a frame informing the pres shell that it is about to
   1.740 +   * be destroyed.
   1.741 +   * This allows any outstanding references to the frame to be cleaned up
   1.742 +   */
   1.743 +  virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
   1.744 +
   1.745 +  /**
   1.746 +   * Get the caret, if it exists. AddRefs it.
   1.747 +   */
   1.748 +  virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret() const = 0;
   1.749 +
   1.750 +  /**
   1.751 +   * Invalidate the caret's current position if it's outside of its frame's
   1.752 +   * boundaries. This function is useful if you're batching selection
   1.753 +   * notifications and might remove the caret's frame out from under it.
   1.754 +   */
   1.755 +  virtual NS_HIDDEN_(void) MaybeInvalidateCaretPosition() = 0;
   1.756 +
   1.757 +  /**
   1.758 +   * Set the current caret to a new caret. To undo this, call RestoreCaret.
   1.759 +   */
   1.760 +  virtual void SetCaret(nsCaret *aNewCaret) = 0;
   1.761 +
   1.762 +  /**
   1.763 +   * Restore the caret to the original caret that this pres shell was created
   1.764 +   * with.
   1.765 +   */
   1.766 +  virtual void RestoreCaret() = 0;
   1.767 +
   1.768 +  /**
   1.769 +   * Should the images have borders etc.  Actual visual effects are determined
   1.770 +   * by the frames.  Visual effects may not effect layout, only display.
   1.771 +   * Takes effect on next repaint, does not force a repaint itself.
   1.772 +   *
   1.773 +   * @param aInEnable  if true, visual selection effects are enabled
   1.774 +   *                   if false visual selection effects are disabled
   1.775 +   */
   1.776 +  NS_IMETHOD SetSelectionFlags(int16_t aInEnable) = 0;
   1.777 +
   1.778 +  /**
   1.779 +    * Gets the current state of non text selection effects
   1.780 +    * @return   current state of non text selection,
   1.781 +    *           as set by SetDisplayNonTextSelection
   1.782 +    */
   1.783 +  int16_t GetSelectionFlags() const { return mSelectionFlags; }
   1.784 +
   1.785 +  virtual mozilla::dom::Selection* GetCurrentSelection(SelectionType aType) = 0;
   1.786 +
   1.787 +  /**
   1.788 +    * Interface to dispatch events via the presshell
   1.789 +    * @note The caller must have a strong reference to the PresShell.
   1.790 +    */
   1.791 +  virtual NS_HIDDEN_(nsresult) HandleEventWithTarget(
   1.792 +                                 mozilla::WidgetEvent* aEvent,
   1.793 +                                 nsIFrame* aFrame,
   1.794 +                                 nsIContent* aContent,
   1.795 +                                 nsEventStatus* aStatus) = 0;
   1.796 +
   1.797 +  /**
   1.798 +   * Dispatch event to content only (NOT full processing)
   1.799 +   * @note The caller must have a strong reference to the PresShell.
   1.800 +   */
   1.801 +  virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(
   1.802 +                                 nsIContent* aTargetContent,
   1.803 +                                 mozilla::WidgetEvent* aEvent,
   1.804 +                                 nsEventStatus* aStatus) = 0;
   1.805 +
   1.806 +  /**
   1.807 +   * Dispatch event to content only (NOT full processing)
   1.808 +   * @note The caller must have a strong reference to the PresShell.
   1.809 +   */
   1.810 +  virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
   1.811 +                                                        nsIDOMEvent* aEvent,
   1.812 +                                                        nsEventStatus* aStatus) = 0;
   1.813 +
   1.814 +  /**
   1.815 +    * Gets the current target event frame from the PresShell
   1.816 +    */
   1.817 +  virtual NS_HIDDEN_(nsIFrame*) GetEventTargetFrame() = 0;
   1.818 +
   1.819 +  /**
   1.820 +    * Gets the current target event frame from the PresShell
   1.821 +    */
   1.822 +  virtual NS_HIDDEN_(already_AddRefed<nsIContent>) GetEventTargetContent(
   1.823 +                                                     mozilla::WidgetEvent* aEvent) = 0;
   1.824 +
   1.825 +  /**
   1.826 +   * Get and set the history state for the current document
   1.827 +   */
   1.828 +
   1.829 +  virtual NS_HIDDEN_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState) = 0;
   1.830 +
   1.831 +  /**
   1.832 +   * Determine if reflow is currently locked
   1.833 +   * returns true if reflow is locked, false otherwise
   1.834 +   */
   1.835 +  bool IsReflowLocked() const { return mIsReflowing; }
   1.836 +
   1.837 +  /**
   1.838 +   * Called to find out if painting is suppressed for this presshell.  If it is suppressd,
   1.839 +   * we don't allow the painting of any layer but the background, and we don't
   1.840 +   * recur into our children.
   1.841 +   */
   1.842 +  bool IsPaintingSuppressed() const { return mPaintingSuppressed; }
   1.843 +
   1.844 +  /**
   1.845 +   * Pause painting by freezing the refresh driver of this and all parent
   1.846 +   * presentations. This may not have the desired effect if this pres shell
   1.847 +   * has its own refresh driver.
   1.848 +   */
   1.849 +  virtual void PausePainting() = 0;
   1.850 +
   1.851 +  /**
   1.852 +   * Resume painting by thawing the refresh driver of this and all parent
   1.853 +   * presentations. This may not have the desired effect if this pres shell
   1.854 +   * has its own refresh driver.
   1.855 +   */
   1.856 +  virtual void ResumePainting() = 0;
   1.857 +
   1.858 +  /**
   1.859 +   * Unsuppress painting.
   1.860 +   */
   1.861 +  virtual NS_HIDDEN_(void) UnsuppressPainting() = 0;
   1.862 +
   1.863 +  /**
   1.864 +   * Called to disable nsITheme support in a specific presshell.
   1.865 +   */
   1.866 +  void DisableThemeSupport()
   1.867 +  {
   1.868 +    // Doesn't have to be dynamic.  Just set the bool.
   1.869 +    mIsThemeSupportDisabled = true;
   1.870 +  }
   1.871 +
   1.872 +  /**
   1.873 +   * Indicates whether theme support is enabled.
   1.874 +   */
   1.875 +  bool IsThemeSupportEnabled() const { return !mIsThemeSupportDisabled; }
   1.876 +
   1.877 +  /**
   1.878 +   * Get the set of agent style sheets for this presentation
   1.879 +   */
   1.880 +  virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) = 0;
   1.881 +
   1.882 +  /**
   1.883 +   * Replace the set of agent style sheets
   1.884 +   */
   1.885 +  virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) = 0;
   1.886 +
   1.887 +  /**
   1.888 +   * Add an override style sheet for this presentation
   1.889 +   */
   1.890 +  virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
   1.891 +
   1.892 +  /**
   1.893 +   * Remove an override style sheet
   1.894 +   */
   1.895 +  virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
   1.896 +
   1.897 +  /**
   1.898 +   * Reconstruct frames for all elements in the document
   1.899 +   */
   1.900 +  virtual nsresult ReconstructFrames() = 0;
   1.901 +
   1.902 +  /**
   1.903 +   * Notify that a content node's state has changed
   1.904 +   */
   1.905 +  virtual void ContentStateChanged(nsIDocument* aDocument,
   1.906 +                                   nsIContent* aContent,
   1.907 +                                   mozilla::EventStates aStateMask) = 0;
   1.908 +
   1.909 +  /**
   1.910 +   * See if reflow verification is enabled. To enable reflow verification add
   1.911 +   * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable
   1.912 +   * (any non-zero debug level will work). Or, call SetVerifyReflowEnable
   1.913 +   * with true.
   1.914 +   */
   1.915 +  static bool GetVerifyReflowEnable();
   1.916 +
   1.917 +  /**
   1.918 +   * Set the verify-reflow enable flag.
   1.919 +   */
   1.920 +  static void SetVerifyReflowEnable(bool aEnabled);
   1.921 +
   1.922 +  virtual nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);
   1.923 +
   1.924 +#ifdef MOZ_REFLOW_PERF
   1.925 +  virtual NS_HIDDEN_(void) DumpReflows() = 0;
   1.926 +  virtual NS_HIDDEN_(void) CountReflows(const char * aName, nsIFrame * aFrame) = 0;
   1.927 +  virtual NS_HIDDEN_(void) PaintCount(const char * aName,
   1.928 +                                      nsRenderingContext* aRenderingContext,
   1.929 +                                      nsPresContext * aPresContext,
   1.930 +                                      nsIFrame * aFrame,
   1.931 +                                      const nsPoint& aOffset,
   1.932 +                                      uint32_t aColor) = 0;
   1.933 +  virtual NS_HIDDEN_(void) SetPaintFrameCount(bool aOn) = 0;
   1.934 +  virtual bool IsPaintingFrameCounts() = 0;
   1.935 +#endif
   1.936 +
   1.937 +#ifdef DEBUG
   1.938 +  // Debugging hooks
   1.939 +  virtual void ListStyleContexts(nsIFrame *aRootFrame, FILE *out,
   1.940 +                                 int32_t aIndent = 0) = 0;
   1.941 +
   1.942 +  virtual void ListStyleSheets(FILE *out, int32_t aIndent = 0) = 0;
   1.943 +  virtual void VerifyStyleTree() = 0;
   1.944 +#endif
   1.945 +
   1.946 +#ifdef ACCESSIBILITY
   1.947 +  /**
   1.948 +   * Return true if accessibility is active.
   1.949 +   */
   1.950 +  static bool IsAccessibilityActive();
   1.951 +
   1.952 +  /**
   1.953 +   * Return accessibility service if accessibility is active.
   1.954 +   */
   1.955 +  static nsAccessibilityService* AccService();
   1.956 +#endif
   1.957 +
   1.958 +  /**
   1.959 +   * Stop all active elements (plugins and the caret) in this presentation and
   1.960 +   * in the presentations of subdocuments.  Resets painting to a suppressed state.
   1.961 +   * XXX this should include image animations
   1.962 +   */
   1.963 +  virtual void Freeze() = 0;
   1.964 +  bool IsFrozen() { return mFrozen; }
   1.965 +
   1.966 +  /**
   1.967 +   * Restarts active elements (plugins) in this presentation and in the
   1.968 +   * presentations of subdocuments, then do a full invalidate of the content area.
   1.969 +   */
   1.970 +  virtual void Thaw() = 0;
   1.971 +
   1.972 +  virtual void FireOrClearDelayedEvents(bool aFireEvents) = 0;
   1.973 +
   1.974 +  /**
   1.975 +   * When this shell is disconnected from its containing docshell, we
   1.976 +   * lose our container pointer.  However, we'd still like to be able to target
   1.977 +   * user events at the docshell's parent.  This pointer allows us to do that.
   1.978 +   * It should not be used for any other purpose.
   1.979 +   */
   1.980 +  void SetForwardingContainer(const mozilla::WeakPtr<nsDocShell> &aContainer);
   1.981 +
   1.982 +  /**
   1.983 +   * Render the document into an arbitrary gfxContext
   1.984 +   * Designed for getting a picture of a document or a piece of a document
   1.985 +   * Note that callers will generally want to call FlushPendingNotifications
   1.986 +   * to get an up-to-date view of the document
   1.987 +   * @param aRect is the region to capture into the offscreen buffer, in the
   1.988 +   * root frame's coordinate system (if aIgnoreViewportScrolling is false)
   1.989 +   * or in the root scrolled frame's coordinate system
   1.990 +   * (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
   1.991 +   * @param aFlags see below;
   1.992 +   *   set RENDER_IS_UNTRUSTED if the contents may be passed to malicious
   1.993 +   * agents. E.g. we might choose not to paint the contents of sensitive widgets
   1.994 +   * such as the file name in a file upload widget, and we might choose not
   1.995 +   * to paint themes.
   1.996 +   *   set RENDER_IGNORE_VIEWPORT_SCROLLING to ignore
   1.997 +   * clipping/scrolling/scrollbar painting due to scrolling in the viewport
   1.998 +   *   set RENDER_CARET to draw the caret if one would be visible
   1.999 +   * (by default the caret is never drawn)
  1.1000 +   *   set RENDER_USE_LAYER_MANAGER to force rendering to go through
  1.1001 +   * the layer manager for the window. This may be unexpectedly slow
  1.1002 +   * (if the layer manager must read back data from the GPU) or low-quality
  1.1003 +   * (if the layer manager reads back pixel data and scales it
  1.1004 +   * instead of rendering using the appropriate scaling). It may also
  1.1005 +   * slow everything down if the area rendered does not correspond to the
  1.1006 +   * normal visible area of the window.
  1.1007 +   *   set RENDER_ASYNC_DECODE_IMAGES to avoid having images synchronously
  1.1008 +   * decoded during rendering.
  1.1009 +   * (by default images decode synchronously with RenderDocument)
  1.1010 +   *   set RENDER_DOCUMENT_RELATIVE to interpret |aRect| relative to the
  1.1011 +   * document instead of the CSS viewport
  1.1012 +   * @param aBackgroundColor a background color to render onto
  1.1013 +   * @param aRenderedContext the gfxContext to render to. We render so that
  1.1014 +   * one CSS pixel in the source document is rendered to one unit in the current
  1.1015 +   * transform.
  1.1016 +   */
  1.1017 +  enum {
  1.1018 +    RENDER_IS_UNTRUSTED = 0x01,
  1.1019 +    RENDER_IGNORE_VIEWPORT_SCROLLING = 0x02,
  1.1020 +    RENDER_CARET = 0x04,
  1.1021 +    RENDER_USE_WIDGET_LAYERS = 0x08,
  1.1022 +    RENDER_ASYNC_DECODE_IMAGES = 0x10,
  1.1023 +    RENDER_DOCUMENT_RELATIVE = 0x20,
  1.1024 +    RENDER_DRAWWINDOW_NOT_FLUSHING = 0x40
  1.1025 +  };
  1.1026 +  virtual NS_HIDDEN_(nsresult) RenderDocument(const nsRect& aRect, uint32_t aFlags,
  1.1027 +                                              nscolor aBackgroundColor,
  1.1028 +                                              gfxContext* aRenderedContext) = 0;
  1.1029 +
  1.1030 +  /**
  1.1031 +   * Renders a node aNode to a surface and returns it. The aRegion may be used
  1.1032 +   * to clip the rendering. This region is measured in CSS pixels from the
  1.1033 +   * edge of the presshell area. The aPoint, aScreenRect and aSurface
  1.1034 +   * arguments function in a similar manner as RenderSelection.
  1.1035 +   */
  1.1036 +  virtual mozilla::TemporaryRef<SourceSurface>
  1.1037 +  RenderNode(nsIDOMNode* aNode,
  1.1038 +             nsIntRegion* aRegion,
  1.1039 +             nsIntPoint& aPoint,
  1.1040 +             nsIntRect* aScreenRect) = 0;
  1.1041 +
  1.1042 +  /**
  1.1043 +   * Renders a selection to a surface and returns it. This method is primarily
  1.1044 +   * intended to create the drag feedback when dragging a selection.
  1.1045 +   *
  1.1046 +   * aScreenRect will be filled in with the bounding rectangle of the
  1.1047 +   * selection area on screen.
  1.1048 +   *
  1.1049 +   * If the area of the selection is large, the image will be scaled down.
  1.1050 +   * The argument aPoint is used in this case as a reference point when
  1.1051 +   * determining the new screen rectangle after scaling. Typically, this
  1.1052 +   * will be the mouse position, so that the screen rectangle is positioned
  1.1053 +   * such that the mouse is over the same point in the scaled image as in
  1.1054 +   * the original. When scaling does not occur, the mouse point isn't used
  1.1055 +   * as the position can be determined from the displayed frames.
  1.1056 +   */
  1.1057 +  virtual mozilla::TemporaryRef<SourceSurface>
  1.1058 +  RenderSelection(nsISelection* aSelection,
  1.1059 +                  nsIntPoint& aPoint,
  1.1060 +                  nsIntRect* aScreenRect) = 0;
  1.1061 +
  1.1062 +  void AddWeakFrameInternal(nsWeakFrame* aWeakFrame);
  1.1063 +  virtual void AddWeakFrameExternal(nsWeakFrame* aWeakFrame);
  1.1064 +
  1.1065 +  void AddWeakFrame(nsWeakFrame* aWeakFrame)
  1.1066 +  {
  1.1067 +#ifdef MOZILLA_INTERNAL_API
  1.1068 +    AddWeakFrameInternal(aWeakFrame);
  1.1069 +#else
  1.1070 +    AddWeakFrameExternal(aWeakFrame);
  1.1071 +#endif
  1.1072 +  }
  1.1073 +
  1.1074 +  void RemoveWeakFrameInternal(nsWeakFrame* aWeakFrame);
  1.1075 +  virtual void RemoveWeakFrameExternal(nsWeakFrame* aWeakFrame);
  1.1076 +
  1.1077 +  void RemoveWeakFrame(nsWeakFrame* aWeakFrame)
  1.1078 +  {
  1.1079 +#ifdef MOZILLA_INTERNAL_API
  1.1080 +    RemoveWeakFrameInternal(aWeakFrame);
  1.1081 +#else
  1.1082 +    RemoveWeakFrameExternal(aWeakFrame);
  1.1083 +#endif
  1.1084 +  }
  1.1085 +
  1.1086 +#ifdef DEBUG
  1.1087 +  nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
  1.1088 +#endif
  1.1089 +
  1.1090 +  /**
  1.1091 +   * Stop or restart non synthetic test mouse event handling on *all*
  1.1092 +   * presShells.
  1.1093 +   *
  1.1094 +   * @param aDisable If true, disable all non synthetic test mouse
  1.1095 +   * events on all presShells.  Otherwise, enable them.
  1.1096 +   */
  1.1097 +  virtual NS_HIDDEN_(void) DisableNonTestMouseEvents(bool aDisable) = 0;
  1.1098 +
  1.1099 +  /**
  1.1100 +   * Record the background color of the most recently drawn canvas. This color
  1.1101 +   * is composited on top of the user's default background color and then used
  1.1102 +   * to draw the background color of the canvas. See PresShell::Paint,
  1.1103 +   * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
  1.1104 +   * bug 488242, bug 476557 and other bugs mentioned there.
  1.1105 +   */
  1.1106 +  void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; }
  1.1107 +  nscolor GetCanvasBackground() { return mCanvasBackgroundColor; }
  1.1108 +
  1.1109 +  /**
  1.1110 +   * Use the current frame tree (if it exists) to update the background
  1.1111 +   * color of the most recently drawn canvas.
  1.1112 +   */
  1.1113 +  virtual void UpdateCanvasBackground() = 0;
  1.1114 +
  1.1115 +  /**
  1.1116 +   * Add a solid color item to the bottom of aList with frame aFrame and bounds
  1.1117 +   * aBounds. Checks first if this needs to be done by checking if aFrame is a
  1.1118 +   * canvas frame (if the FORCE_DRAW flag is passed then this check is skipped).
  1.1119 +   * aBackstopColor is composed behind the background color of the canvas, it is
  1.1120 +   * transparent by default.
  1.1121 +   */
  1.1122 +  enum {
  1.1123 +    FORCE_DRAW = 0x01
  1.1124 +  };
  1.1125 +  virtual void AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
  1.1126 +                                            nsDisplayList& aList,
  1.1127 +                                            nsIFrame* aFrame,
  1.1128 +                                            const nsRect& aBounds,
  1.1129 +                                            nscolor aBackstopColor = NS_RGBA(0,0,0,0),
  1.1130 +                                            uint32_t aFlags = 0) = 0;
  1.1131 +
  1.1132 +
  1.1133 +  /**
  1.1134 +   * Add a solid color item to the bottom of aList with frame aFrame and
  1.1135 +   * bounds aBounds representing the dark grey background behind the page of a
  1.1136 +   * print preview presentation.
  1.1137 +   */
  1.1138 +  virtual void AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
  1.1139 +                                             nsDisplayList& aList,
  1.1140 +                                             nsIFrame* aFrame,
  1.1141 +                                             const nsRect& aBounds) = 0;
  1.1142 +
  1.1143 +  /**
  1.1144 +   * Computes the backstop color for the view: transparent if in a transparent
  1.1145 +   * widget, otherwise the PresContext default background color. This color is
  1.1146 +   * only visible if the contents of the view as a whole are translucent.
  1.1147 +   */
  1.1148 +  virtual nscolor ComputeBackstopColor(nsView* aDisplayRoot) = 0;
  1.1149 +
  1.1150 +  void ObserveNativeAnonMutationsForPrint(bool aObserve)
  1.1151 +  {
  1.1152 +    mObservesMutationsForPrint = aObserve;
  1.1153 +  }
  1.1154 +  bool ObservesNativeAnonMutationsForPrint()
  1.1155 +  {
  1.1156 +    return mObservesMutationsForPrint;
  1.1157 +  }
  1.1158 +
  1.1159 +  virtual nsresult SetIsActive(bool aIsActive) = 0;
  1.1160 +
  1.1161 +  bool IsActive()
  1.1162 +  {
  1.1163 +    return mIsActive;
  1.1164 +  }
  1.1165 +
  1.1166 +  // mouse capturing
  1.1167 +
  1.1168 +  static CapturingContentInfo gCaptureInfo;
  1.1169 +
  1.1170 +  static nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Touch>* gCaptureTouchList;
  1.1171 +  static bool gPreventMouseEvents;
  1.1172 +
  1.1173 +  // Keeps a map between pointerId and element that currently capturing pointer
  1.1174 +  // with such pointerId. If pointerId is absent in this map then nobody is
  1.1175 +  // capturing it.
  1.1176 +  static nsRefPtrHashtable<nsUint32HashKey, nsIContent>* gPointerCaptureList;
  1.1177 +
  1.1178 +  struct PointerInfo
  1.1179 +  {
  1.1180 +    bool      mActiveState;
  1.1181 +    uint16_t  mPointerType;
  1.1182 +    PointerInfo(bool aActiveState, uint16_t aPointerType) :
  1.1183 +      mActiveState(aActiveState), mPointerType(aPointerType) {}
  1.1184 +  };
  1.1185 +  // Keeps information about pointers such as pointerId, activeState, pointerType
  1.1186 +  static nsClassHashtable<nsUint32HashKey, PointerInfo>* gActivePointersIds;
  1.1187 +
  1.1188 +  static void DispatchGotOrLostPointerCaptureEvent(bool aIsGotCapture,
  1.1189 +                                                    uint32_t aPointerId,
  1.1190 +                                                    nsIContent* aCaptureTarget);
  1.1191 +  static void SetPointerCapturingContent(uint32_t aPointerId, nsIContent* aContent);
  1.1192 +  static void ReleasePointerCapturingContent(uint32_t aPointerId, nsIContent* aContent);
  1.1193 +  static nsIContent* GetPointerCapturingContent(uint32_t aPointerId);
  1.1194 +
  1.1195 +  // GetPointerInfo returns true if pointer with aPointerId is situated in device, false otherwise.
  1.1196 +  // aActiveState is additional information, which shows state of pointer like button state for mouse.
  1.1197 +  static bool GetPointerInfo(uint32_t aPointerId, bool& aActiveState);
  1.1198 +
  1.1199 +  /**
  1.1200 +   * When capturing content is set, it traps all mouse events and retargets
  1.1201 +   * them at this content node. If capturing is not allowed
  1.1202 +   * (gCaptureInfo.mAllowed is false), then capturing is not set. However, if
  1.1203 +   * the CAPTURE_IGNOREALLOWED flag is set, the allowed state is ignored and
  1.1204 +   * capturing is set regardless. To disable capture, pass null for the value
  1.1205 +   * of aContent.
  1.1206 +   *
  1.1207 +   * If CAPTURE_RETARGETTOELEMENT is set, all mouse events are targeted at
  1.1208 +   * aContent only. Otherwise, mouse events are targeted at aContent or its
  1.1209 +   * descendants. That is, descendants of aContent receive mouse events as
  1.1210 +   * they normally would, but mouse events outside of aContent are retargeted
  1.1211 +   * to aContent.
  1.1212 +   *
  1.1213 +   * If CAPTURE_PREVENTDRAG is set then drags are prevented from starting while
  1.1214 +   * this capture is active.
  1.1215 +   *
  1.1216 +   * If CAPTURE_POINTERLOCK is set, similar to CAPTURE_RETARGETTOELEMENT, then
  1.1217 +   * events are targeted at aContent, but capturing is held more strongly (i.e.,
  1.1218 +   * calls to SetCapturingContent won't unlock unless CAPTURE_POINTERLOCK is
  1.1219 +   * set again).
  1.1220 +   */
  1.1221 +  static void SetCapturingContent(nsIContent* aContent, uint8_t aFlags);
  1.1222 +
  1.1223 +  /**
  1.1224 +   * Return the active content currently capturing the mouse if any.
  1.1225 +   */
  1.1226 +  static nsIContent* GetCapturingContent()
  1.1227 +  {
  1.1228 +    return gCaptureInfo.mContent;
  1.1229 +  }
  1.1230 +
  1.1231 +  /**
  1.1232 +   * Allow or disallow mouse capturing.
  1.1233 +   */
  1.1234 +  static void AllowMouseCapture(bool aAllowed)
  1.1235 +  {
  1.1236 +    gCaptureInfo.mAllowed = aAllowed;
  1.1237 +  }
  1.1238 +
  1.1239 +  /**
  1.1240 +   * Returns true if there is an active mouse capture that wants to prevent
  1.1241 +   * drags.
  1.1242 +   */
  1.1243 +  static bool IsMouseCapturePreventingDrag()
  1.1244 +  {
  1.1245 +    return gCaptureInfo.mPreventDrag && gCaptureInfo.mContent;
  1.1246 +  }
  1.1247 +
  1.1248 +  /**
  1.1249 +   * Keep track of how many times this presshell has been rendered to
  1.1250 +   * a window.
  1.1251 +   */
  1.1252 +  uint64_t GetPaintCount() { return mPaintCount; }
  1.1253 +  void IncrementPaintCount() { ++mPaintCount; }
  1.1254 +
  1.1255 +  /**
  1.1256 +   * Get the root DOM window of this presShell.
  1.1257 +   */
  1.1258 +  virtual already_AddRefed<nsPIDOMWindow> GetRootWindow() = 0;
  1.1259 +
  1.1260 +  /**
  1.1261 +   * Get the layer manager for the widget of the root view, if it has
  1.1262 +   * one.
  1.1263 +   */
  1.1264 +  virtual LayerManager* GetLayerManager() = 0;
  1.1265 +
  1.1266 +  /**
  1.1267 +   * Track whether we're ignoring viewport scrolling for the purposes
  1.1268 +   * of painting.  If we are ignoring, then layers aren't clipped to
  1.1269 +   * the CSS viewport and scrollbars aren't drawn.
  1.1270 +   */
  1.1271 +  virtual void SetIgnoreViewportScrolling(bool aIgnore) = 0;
  1.1272 +  bool IgnoringViewportScrolling() const
  1.1273 +  { return mRenderFlags & STATE_IGNORING_VIEWPORT_SCROLLING; }
  1.1274 +
  1.1275 +   /**
  1.1276 +   * Set a "resolution" for the document, which if not 1.0 will
  1.1277 +   * allocate more or fewer pixels for rescalable content by a factor
  1.1278 +   * of |resolution| in both dimensions.  Return NS_OK iff the
  1.1279 +   * resolution bounds are sane, and the resolution of this was
  1.1280 +   * actually updated.
  1.1281 +   *
  1.1282 +   * The resolution defaults to 1.0.
  1.1283 +   */
  1.1284 +  virtual nsresult SetResolution(float aXResolution, float aYResolution) = 0;
  1.1285 +  gfxSize GetResolution() { return gfxSize(mXResolution, mYResolution); }
  1.1286 +  float GetXResolution() { return mXResolution; }
  1.1287 +  float GetYResolution() { return mYResolution; }
  1.1288 +  virtual gfxSize GetCumulativeResolution() = 0;
  1.1289 +
  1.1290 +  /**
  1.1291 +   * Returns whether we are in a DrawWindow() call that used the
  1.1292 +   * DRAWWINDOW_DO_NOT_FLUSH flag.
  1.1293 +   */
  1.1294 +  bool InDrawWindowNotFlushing() const
  1.1295 +  { return mRenderFlags & STATE_DRAWWINDOW_NOT_FLUSHING; }
  1.1296 +
  1.1297 +  /**
  1.1298 +   * Set the isFirstPaint flag.
  1.1299 +   */
  1.1300 +  void SetIsFirstPaint(bool aIsFirstPaint) { mIsFirstPaint = aIsFirstPaint; }
  1.1301 +
  1.1302 +  /**
  1.1303 +   * Get the isFirstPaint flag.
  1.1304 +   */
  1.1305 +  bool GetIsFirstPaint() const { return mIsFirstPaint; }
  1.1306 +
  1.1307 +  uint32_t GetPresShellId() { return mPresShellId; }
  1.1308 +
  1.1309 +  /**
  1.1310 +   * Dispatch a mouse move event based on the most recent mouse position if
  1.1311 +   * this PresShell is visible. This is used when the contents of the page
  1.1312 +   * moved (aFromScroll is false) or scrolled (aFromScroll is true).
  1.1313 +   */
  1.1314 +  virtual void SynthesizeMouseMove(bool aFromScroll) = 0;
  1.1315 +
  1.1316 +  enum PaintFlags {
  1.1317 +    /* Update the layer tree and paint ThebesLayers. If this is not specified,
  1.1318 +     * we may still have to do it if the layer tree lost ThebesLayer contents
  1.1319 +     * we need for compositing. */
  1.1320 +    PAINT_LAYERS = 0x01,
  1.1321 +    /* Composite layers to the window. */
  1.1322 +    PAINT_COMPOSITE = 0x02,
  1.1323 +  };
  1.1324 +  virtual void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
  1.1325 +                     uint32_t aFlags) = 0;
  1.1326 +  virtual nsresult HandleEvent(nsIFrame* aFrame,
  1.1327 +                               mozilla::WidgetGUIEvent* aEvent,
  1.1328 +                               bool aDontRetargetEvents,
  1.1329 +                               nsEventStatus* aEventStatus) = 0;
  1.1330 +  virtual bool ShouldIgnoreInvalidation() = 0;
  1.1331 +  /**
  1.1332 +   * Notify that we're going to call Paint with PAINT_LAYERS
  1.1333 +   * on the pres shell for a widget (which might not be this one, since
  1.1334 +   * WillPaint is called on all presshells in the same toplevel window as the
  1.1335 +   * painted widget). This is issued at a time when it's safe to modify
  1.1336 +   * widget geometry.
  1.1337 +   */
  1.1338 +  virtual void WillPaint() = 0;
  1.1339 +  /**
  1.1340 +   * Notify that we're going to call Paint with PAINT_COMPOSITE.
  1.1341 +   * Fires on the presshell for the painted widget.
  1.1342 +   * This is issued at a time when it's safe to modify widget geometry.
  1.1343 +   */
  1.1344 +  virtual void WillPaintWindow() = 0;
  1.1345 +  /**
  1.1346 +   * Notify that we called Paint with PAINT_COMPOSITE.
  1.1347 +   * Fires on the presshell for the painted widget.
  1.1348 +   * This is issued at a time when it's safe to modify widget geometry.
  1.1349 +   */
  1.1350 +  virtual void DidPaintWindow() = 0;
  1.1351 +
  1.1352 +  /**
  1.1353 +   * Ensures that the refresh driver is running, and schedules a view
  1.1354 +   * manager flush on the next tick.
  1.1355 +   *
  1.1356 +   * @param aType PAINT_DELAYED_COMPRESS : Schedule a paint to be executed after a delay, and
  1.1357 +   * put FrameLayerBuilder in 'compressed' mode that avoids short cut optimizations.
  1.1358 +   */
  1.1359 +  enum PaintType {
  1.1360 +    PAINT_DEFAULT,
  1.1361 +    PAINT_DELAYED_COMPRESS
  1.1362 +  };
  1.1363 +  virtual void ScheduleViewManagerFlush(PaintType aType = PAINT_DEFAULT) = 0;
  1.1364 +  virtual void ClearMouseCaptureOnView(nsView* aView) = 0;
  1.1365 +  virtual bool IsVisible() = 0;
  1.1366 +  virtual void DispatchSynthMouseMove(mozilla::WidgetGUIEvent* aEvent,
  1.1367 +                                      bool aFlushOnHoverChange) = 0;
  1.1368 +
  1.1369 +  virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
  1.1370 +                                      nsArenaMemoryStats *aArenaObjectsSize,
  1.1371 +                                      size_t *aPresShellSize,
  1.1372 +                                      size_t *aStyleSetsSize,
  1.1373 +                                      size_t *aTextRunsSize,
  1.1374 +                                      size_t *aPresContextSize) = 0;
  1.1375 +
  1.1376 +  /**
  1.1377 +   * Methods that retrieve the cached font inflation preferences.
  1.1378 +   */
  1.1379 +  uint32_t FontSizeInflationEmPerLine() const {
  1.1380 +    return mFontSizeInflationEmPerLine;
  1.1381 +  }
  1.1382 +
  1.1383 +  uint32_t FontSizeInflationMinTwips() const {
  1.1384 +    return mFontSizeInflationMinTwips;
  1.1385 +  }
  1.1386 +
  1.1387 +  uint32_t FontSizeInflationLineThreshold() const {
  1.1388 +    return mFontSizeInflationLineThreshold;
  1.1389 +  }
  1.1390 +
  1.1391 +  bool FontSizeInflationForceEnabled() const {
  1.1392 +    return mFontSizeInflationForceEnabled;
  1.1393 +  }
  1.1394 +
  1.1395 +  bool FontSizeInflationDisabledInMasterProcess() const {
  1.1396 +    return mFontSizeInflationDisabledInMasterProcess;
  1.1397 +  }
  1.1398 +
  1.1399 +  /**
  1.1400 +   * Determine if font size inflation is enabled. This value is cached until
  1.1401 +   * it becomes dirty.
  1.1402 +   *
  1.1403 +   * @returns true, if font size inflation is enabled; false otherwise.
  1.1404 +   */
  1.1405 +  bool FontSizeInflationEnabled();
  1.1406 +
  1.1407 +  /**
  1.1408 +   * Notify the pres shell that an event occurred making the current value of
  1.1409 +   * mFontSizeInflationEnabled invalid. This will schedule a recomputation of
  1.1410 +   * whether font size inflation is enabled on the next call to
  1.1411 +   * FontSizeInflationEnabled().
  1.1412 +   */
  1.1413 +  void NotifyFontSizeInflationEnabledIsDirty()
  1.1414 +  {
  1.1415 +    mFontSizeInflationEnabledIsDirty = true;
  1.1416 +  }
  1.1417 +
  1.1418 +  virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver) = 0;
  1.1419 +
  1.1420 +  void InvalidatePresShellIfHidden();
  1.1421 +  void CancelInvalidatePresShellIfHidden();
  1.1422 +
  1.1423 +  // Schedule an update of the list of visible images.
  1.1424 +  virtual void ScheduleImageVisibilityUpdate() = 0;
  1.1425 +
  1.1426 +  // Clears the current list of visible images on this presshell and replaces it
  1.1427 +  // with images that are in the display list aList.
  1.1428 +  virtual void RebuildImageVisibility(const nsDisplayList& aList) = 0;
  1.1429 +
  1.1430 +  // Ensures the image is in the list of visible images.
  1.1431 +  virtual void EnsureImageInVisibleList(nsIImageLoadingContent* aImage) = 0;
  1.1432 +
  1.1433 +  // Removes the image from the list of visible images if it is present there.
  1.1434 +  virtual void RemoveImageFromVisibleList(nsIImageLoadingContent* aImage) = 0;
  1.1435 +
  1.1436 +  // Whether we should assume all images are visible.
  1.1437 +  virtual bool AssumeAllImagesVisible() = 0;
  1.1438 +
  1.1439 +  /**
  1.1440 +   * Refresh observer management.
  1.1441 +   */
  1.1442 +protected:
  1.1443 +  virtual bool AddRefreshObserverExternal(nsARefreshObserver* aObserver,
  1.1444 +                                          mozFlushType aFlushType);
  1.1445 +  bool AddRefreshObserverInternal(nsARefreshObserver* aObserver,
  1.1446 +                                  mozFlushType aFlushType);
  1.1447 +  virtual bool RemoveRefreshObserverExternal(nsARefreshObserver* aObserver,
  1.1448 +                                             mozFlushType aFlushType);
  1.1449 +  bool RemoveRefreshObserverInternal(nsARefreshObserver* aObserver,
  1.1450 +                                     mozFlushType aFlushType);
  1.1451 +
  1.1452 +  /**
  1.1453 +   * Do computations necessary to determine if font size inflation is enabled.
  1.1454 +   * This value is cached after computation, as the computation is somewhat
  1.1455 +   * expensive.
  1.1456 +   */
  1.1457 +  void RecomputeFontSizeInflationEnabled();
  1.1458 +
  1.1459 +public:
  1.1460 +  bool AddRefreshObserver(nsARefreshObserver* aObserver,
  1.1461 +                          mozFlushType aFlushType) {
  1.1462 +#ifdef MOZILLA_INTERNAL_API
  1.1463 +    return AddRefreshObserverInternal(aObserver, aFlushType);
  1.1464 +#else
  1.1465 +    return AddRefreshObserverExternal(aObserver, aFlushType);
  1.1466 +#endif
  1.1467 +  }
  1.1468 +
  1.1469 +  bool RemoveRefreshObserver(nsARefreshObserver* aObserver,
  1.1470 +                             mozFlushType aFlushType) {
  1.1471 +#ifdef MOZILLA_INTERNAL_API
  1.1472 +    return RemoveRefreshObserverInternal(aObserver, aFlushType);
  1.1473 +#else
  1.1474 +    return RemoveRefreshObserverExternal(aObserver, aFlushType);
  1.1475 +#endif
  1.1476 +  }
  1.1477 +
  1.1478 +  virtual bool AddPostRefreshObserver(nsAPostRefreshObserver* aObserver);
  1.1479 +  virtual bool RemovePostRefreshObserver(nsAPostRefreshObserver* aObserver);
  1.1480 +
  1.1481 +  /**
  1.1482 +   * Initialize and shut down static variables.
  1.1483 +   */
  1.1484 +  static void InitializeStatics();
  1.1485 +  static void ReleaseStatics();
  1.1486 +
  1.1487 +  // If a frame in the subtree rooted at aFrame is capturing the mouse then
  1.1488 +  // clears that capture.
  1.1489 +  static void ClearMouseCapture(nsIFrame* aFrame);
  1.1490 +
  1.1491 +  void SetScrollPositionClampingScrollPortSize(nscoord aWidth, nscoord aHeight);
  1.1492 +  bool IsScrollPositionClampingScrollPortSizeSet() {
  1.1493 +    return mScrollPositionClampingScrollPortSizeSet;
  1.1494 +  }
  1.1495 +  nsSize GetScrollPositionClampingScrollPortSize() {
  1.1496 +    NS_ASSERTION(mScrollPositionClampingScrollPortSizeSet, "asking for scroll port when its not set?");
  1.1497 +    return mScrollPositionClampingScrollPortSize;
  1.1498 +  }
  1.1499 +
  1.1500 +  void SetContentDocumentFixedPositionMargins(const nsMargin& aMargins);
  1.1501 +  const nsMargin& GetContentDocumentFixedPositionMargins() {
  1.1502 +    return mContentDocumentFixedPositionMargins;
  1.1503 +  }
  1.1504 +
  1.1505 +  virtual void WindowSizeMoveDone() = 0;
  1.1506 +  virtual void SysColorChanged() = 0;
  1.1507 +  virtual void ThemeChanged() = 0;
  1.1508 +  virtual void BackingScaleFactorChanged() = 0;
  1.1509 +
  1.1510 +  nscoord MaxLineBoxWidth() {
  1.1511 +    return mMaxLineBoxWidth;
  1.1512 +  }
  1.1513 +
  1.1514 +  void SetMaxLineBoxWidth(nscoord aMaxLineBoxWidth);
  1.1515 +
  1.1516 +  /**
  1.1517 +   * Returns whether or not there is a reflow on zoom event pending. A reflow
  1.1518 +   * on zoom event is a change to the max line box width, followed by a reflow.
  1.1519 +   * This subsequent reflow event should treat all frames as though they resized
  1.1520 +   * horizontally (and thus reflow all their descendants), rather than marking
  1.1521 +   * all frames dirty from the root. This is the way the pres shell indicates
  1.1522 +   * that an hresize reflow should take place during reflow state construction.
  1.1523 +   */
  1.1524 +  bool IsReflowOnZoomPending() {
  1.1525 +    return mReflowOnZoomPending;
  1.1526 +  }
  1.1527 +
  1.1528 +  /**
  1.1529 +   * Clear the flag indicating whether a reflow on zoom event is pending. This
  1.1530 +   * is performed at the very end of DoReflow().
  1.1531 +   */
  1.1532 +  void ClearReflowOnZoomPending() {
  1.1533 +    mReflowOnZoomPending = false;
  1.1534 +  }
  1.1535 +
  1.1536 +  /**
  1.1537 +   * Documents belonging to an invisible DocShell must not be painted ever.
  1.1538 +   */
  1.1539 +  bool IsNeverPainting() {
  1.1540 +    return mIsNeverPainting;
  1.1541 +  }
  1.1542 +
  1.1543 +  void SetNeverPainting(bool aNeverPainting) {
  1.1544 +    mIsNeverPainting = aNeverPainting;
  1.1545 +  }
  1.1546 +
  1.1547 +protected:
  1.1548 +  friend class nsRefreshDriver;
  1.1549 +
  1.1550 +  // IMPORTANT: The ownership implicit in the following member variables
  1.1551 +  // has been explicitly checked.  If you add any members to this class,
  1.1552 +  // please make the ownership explicit (pinkerton, scc).
  1.1553 +
  1.1554 +  // These are the same Document and PresContext owned by the DocViewer.
  1.1555 +  // we must share ownership.
  1.1556 +  nsIDocument*              mDocument;      // [STRONG]
  1.1557 +  nsPresContext*            mPresContext;   // [STRONG]
  1.1558 +  nsStyleSet*               mStyleSet;      // [OWNS]
  1.1559 +  nsCSSFrameConstructor*    mFrameConstructor; // [OWNS]
  1.1560 +  nsViewManager*           mViewManager;   // [WEAK] docViewer owns it so I don't have to
  1.1561 +  nsPresArena               mFrameArena;
  1.1562 +  nsFrameSelection*         mSelection;
  1.1563 +  // Pointer into mFrameConstructor - this is purely so that FrameManager() and
  1.1564 +  // GetRootFrame() can be inlined:
  1.1565 +  nsFrameManagerBase*       mFrameManager;
  1.1566 +  mozilla::WeakPtr<nsDocShell>                 mForwardingContainer;
  1.1567 +  nsRefreshDriver*          mHiddenInvalidationObserverRefreshDriver;
  1.1568 +#ifdef ACCESSIBILITY
  1.1569 +  mozilla::a11y::DocAccessible* mDocAccessible;
  1.1570 +#endif
  1.1571 +
  1.1572 +#ifdef DEBUG
  1.1573 +  nsIFrame*                 mDrawEventTargetFrame;
  1.1574 +  // Ensure that every allocation from the PresArena is eventually freed.
  1.1575 +  uint32_t                  mPresArenaAllocCount;
  1.1576 +#endif
  1.1577 +
  1.1578 +  // Count of the number of times this presshell has been painted to a window.
  1.1579 +  uint64_t                  mPaintCount;
  1.1580 +
  1.1581 +  nsSize                    mScrollPositionClampingScrollPortSize;
  1.1582 +
  1.1583 +  // This margin is intended to be used when laying out fixed position children
  1.1584 +  // on this PresShell's viewport frame. See the documentation of
  1.1585 +  // nsIDOMWindowUtils.setContentDocumentFixedPositionMargins for details of
  1.1586 +  // their use.
  1.1587 +  nsMargin                  mContentDocumentFixedPositionMargins;
  1.1588 +
  1.1589 +  // A list of weak frames. This is a pointer to the last item in the list.
  1.1590 +  nsWeakFrame*              mWeakFrames;
  1.1591 +
  1.1592 +  // Most recent canvas background color.
  1.1593 +  nscolor                   mCanvasBackgroundColor;
  1.1594 +
  1.1595 +  // Used to force allocation and rendering of proportionally more or
  1.1596 +  // less pixels in the given dimension.
  1.1597 +  float                     mXResolution;
  1.1598 +  float                     mYResolution;
  1.1599 +
  1.1600 +  int16_t                   mSelectionFlags;
  1.1601 +
  1.1602 +  // Flags controlling how our document is rendered.  These persist
  1.1603 +  // between paints and so are tied with retained layer pixels.
  1.1604 +  // PresShell flushes retained layers when the rendering state
  1.1605 +  // changes in a way that prevents us from being able to (usefully)
  1.1606 +  // re-use old pixels.
  1.1607 +  RenderFlags               mRenderFlags;
  1.1608 +
  1.1609 +  // Indicates that the whole document must be restyled.  Changes to scoped
  1.1610 +  // style sheets are recorded in mChangedScopeStyleRoots rather than here
  1.1611 +  // in mStylesHaveChanged.
  1.1612 +  bool                      mStylesHaveChanged : 1;
  1.1613 +  bool                      mDidInitialize : 1;
  1.1614 +  bool                      mIsDestroying : 1;
  1.1615 +  bool                      mIsZombie : 1;
  1.1616 +  bool                      mIsReflowing : 1;
  1.1617 +
  1.1618 +  // For all documents we initially lock down painting.
  1.1619 +  bool                      mPaintingSuppressed : 1;
  1.1620 +
  1.1621 +  // Whether or not form controls should use nsITheme in this shell.
  1.1622 +  bool                      mIsThemeSupportDisabled : 1;
  1.1623 +
  1.1624 +  bool                      mIsActive : 1;
  1.1625 +  bool                      mFrozen : 1;
  1.1626 +  bool                      mIsFirstPaint : 1;
  1.1627 +  bool                      mObservesMutationsForPrint : 1;
  1.1628 +
  1.1629 +  // If true, we have a reflow scheduled. Guaranteed to be false if
  1.1630 +  // mReflowContinueTimer is non-null.
  1.1631 +  bool                      mReflowScheduled : 1;
  1.1632 +
  1.1633 +  bool                      mSuppressInterruptibleReflows : 1;
  1.1634 +  bool                      mScrollPositionClampingScrollPortSizeSet : 1;
  1.1635 +
  1.1636 +  uint32_t                  mPresShellId;
  1.1637 +
  1.1638 +  // List of subtrees rooted at style scope roots that need to be restyled.
  1.1639 +  // When a change to a scoped style sheet is made, we add the style scope
  1.1640 +  // root to this array rather than setting mStylesHaveChanged = true, since
  1.1641 +  // we know we don't need to restyle the whole document.  However, if in the
  1.1642 +  // same update block we have already had other changes that require
  1.1643 +  // the whole document to be restyled (i.e., mStylesHaveChanged is already
  1.1644 +  // true), then we don't bother adding the scope root here.
  1.1645 +  nsAutoTArray<nsRefPtr<mozilla::dom::Element>,1> mChangedScopeStyleRoots;
  1.1646 +
  1.1647 +  static nsIContent*        gKeyDownTarget;
  1.1648 +
  1.1649 +  // Cached font inflation values. This is done to prevent changing of font
  1.1650 +  // inflation until a page is reloaded.
  1.1651 +  uint32_t mFontSizeInflationEmPerLine;
  1.1652 +  uint32_t mFontSizeInflationMinTwips;
  1.1653 +  uint32_t mFontSizeInflationLineThreshold;
  1.1654 +  bool mFontSizeInflationForceEnabled;
  1.1655 +  bool mFontSizeInflationDisabledInMasterProcess;
  1.1656 +  bool mFontSizeInflationEnabled;
  1.1657 +  bool mPaintingIsFrozen;
  1.1658 +
  1.1659 +  // Dirty bit indicating that mFontSizeInflationEnabled needs to be recomputed.
  1.1660 +  bool mFontSizeInflationEnabledIsDirty;
  1.1661 +
  1.1662 +  // Flag to indicate whether or not there is a reflow on zoom event pending.
  1.1663 +  // See IsReflowOnZoomPending() for more information.
  1.1664 +  bool mReflowOnZoomPending;
  1.1665 +
  1.1666 +  // The maximum width of a line box. Text on a single line that exceeds this
  1.1667 +  // width will be wrapped. A value of 0 indicates that no limit is enforced.
  1.1668 +  nscoord mMaxLineBoxWidth;
  1.1669 +
  1.1670 +  // If a document belongs to an invisible DocShell, this flag must be set
  1.1671 +  // to true, so we can avoid any paint calls for widget related to this
  1.1672 +  // presshell.
  1.1673 +  bool mIsNeverPainting;
  1.1674 +};
  1.1675 +
  1.1676 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell, NS_IPRESSHELL_IID)
  1.1677 +
  1.1678 +#endif /* nsIPresShell_h___ */

mercurial