LCOV - code coverage report
Current view: directory - objdir/dist/include - nsIPresShell.h (source / functions) Found Hit Coverage
Test: app.info Lines: 45 0 0.0 %
Date: 2012-06-02 Functions: 25 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2                 :  * ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Steve Clark <buster@netscape.com>
      24                 :  *   Dan Rosen <dr@netscape.com>
      25                 :  *   Mihai Sucan <mihai.sucan@gmail.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK *****
      40                 :  *
      41                 :  * This Original Code has been modified by IBM Corporation.
      42                 :  * Modifications made by IBM described herein are
      43                 :  * Copyright (c) International Business Machines
      44                 :  * Corporation, 2000
      45                 :  *
      46                 :  * Modifications to Mozilla code or documentation
      47                 :  * identified per MPL Section 3.3
      48                 :  *
      49                 :  * Date         Modified by     Description of modification
      50                 :  * 05/03/2000   IBM Corp.       Observer related defines for reflow
      51                 :  */
      52                 : 
      53                 : /* a presentation of a document, part 2 */
      54                 : 
      55                 : #ifndef nsIPresShell_h___
      56                 : #define nsIPresShell_h___
      57                 : 
      58                 : #include "nsTHashtable.h"
      59                 : #include "nsHashKeys.h"
      60                 : #include "nsISupports.h"
      61                 : #include "nsQueryFrame.h"
      62                 : #include "nsCoord.h"
      63                 : #include "nsColor.h"
      64                 : #include "nsEvent.h"
      65                 : #include "nsCompatibility.h"
      66                 : #include "nsFrameManagerBase.h"
      67                 : #include "nsRect.h"
      68                 : #include "mozFlushType.h"
      69                 : #include "nsWeakReference.h"
      70                 : #include <stdio.h> // for FILE definition
      71                 : #include "nsChangeHint.h"
      72                 : #include "nsGUIEvent.h"
      73                 : #include "nsInterfaceHashtable.h"
      74                 : #include "nsEventStates.h"
      75                 : 
      76                 : class nsIContent;
      77                 : class nsIDocument;
      78                 : class nsIFrame;
      79                 : class nsPresContext;
      80                 : class nsStyleSet;
      81                 : class nsIViewManager;
      82                 : class nsIView;
      83                 : class nsRenderingContext;
      84                 : class nsIPageSequenceFrame;
      85                 : class nsAString;
      86                 : class nsCaret;
      87                 : class nsFrameSelection;
      88                 : class nsFrameManager;
      89                 : class nsILayoutHistoryState;
      90                 : class nsIReflowCallback;
      91                 : class nsIDOMNode;
      92                 : class nsIntRegion;
      93                 : class nsIStyleSheet;
      94                 : class nsCSSFrameConstructor;
      95                 : class nsISelection;
      96                 : template<class E> class nsCOMArray;
      97                 : class nsWeakFrame;
      98                 : class nsIScrollableFrame;
      99                 : class gfxASurface;
     100                 : class gfxContext;
     101                 : class nsIDOMEvent;
     102                 : class nsDisplayList;
     103                 : class nsDisplayListBuilder;
     104                 : class nsPIDOMWindow;
     105                 : struct nsPoint;
     106                 : struct nsIntPoint;
     107                 : struct nsIntRect;
     108                 : class nsRegion;
     109                 : class nsRefreshDriver;
     110                 : class nsARefreshObserver;
     111                 : #ifdef ACCESSIBILITY
     112                 : class nsAccessibilityService;
     113                 : #endif
     114                 : class nsIWidget;
     115                 : 
     116                 : typedef short SelectionType;
     117                 : typedef PRUint64 nsFrameState;
     118                 : 
     119                 : namespace mozilla {
     120                 : namespace dom {
     121                 : class Element;
     122                 : } // namespace dom
     123                 : 
     124                 : namespace layers{
     125                 : class LayerManager;
     126                 : } // namespace layers
     127                 : } // namespace mozilla
     128                 : 
     129                 : // Flags to pass to SetCapturingContent
     130                 : //
     131                 : // when assigning capture, ignore whether capture is allowed or not
     132                 : #define CAPTURE_IGNOREALLOWED 1
     133                 : // true if events should be targeted at the capturing content or its children
     134                 : #define CAPTURE_RETARGETTOELEMENT 2
     135                 : // true if the current capture wants drags to be prevented
     136                 : #define CAPTURE_PREVENTDRAG 4
     137                 : 
     138                 : typedef struct CapturingContentInfo {
     139                 :   // capture should only be allowed during a mousedown event
     140                 :   bool mAllowed;
     141                 :   bool mRetargetToElement;
     142                 :   bool mPreventDrag;
     143                 :   nsIContent* mContent;
     144                 : } CapturingContentInfo;
     145                 : 
     146                 : #define NS_IPRESSHELL_IID    \
     147                 :         { 0x4dc4db09, 0x03d4, 0x4427, \
     148                 :           { 0xbe, 0xfb, 0xc9, 0x29, 0xac, 0x5c, 0x62, 0xab } }
     149                 : 
     150                 : // Constants for ScrollContentIntoView() function
     151                 : #define NS_PRESSHELL_SCROLL_TOP      0
     152                 : #define NS_PRESSHELL_SCROLL_BOTTOM   100
     153                 : #define NS_PRESSHELL_SCROLL_LEFT     0
     154                 : #define NS_PRESSHELL_SCROLL_RIGHT    100
     155                 : #define NS_PRESSHELL_SCROLL_CENTER   50
     156                 : #define NS_PRESSHELL_SCROLL_ANYWHERE -1
     157                 : #define NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE -2
     158                 : 
     159                 : // debug VerifyReflow flags
     160                 : #define VERIFY_REFLOW_ON              0x01
     161                 : #define VERIFY_REFLOW_NOISY           0x02
     162                 : #define VERIFY_REFLOW_ALL             0x04
     163                 : #define VERIFY_REFLOW_DUMP_COMMANDS   0x08
     164                 : #define VERIFY_REFLOW_NOISY_RC        0x10
     165                 : #define VERIFY_REFLOW_REALLY_NOISY_RC 0x20
     166                 : #define VERIFY_REFLOW_DURING_RESIZE_REFLOW  0x40
     167                 : 
     168                 : #undef NOISY_INTERRUPTIBLE_REFLOW
     169                 : 
     170                 : enum nsRectVisibility { 
     171                 :   nsRectVisibility_kVisible, 
     172                 :   nsRectVisibility_kAboveViewport, 
     173                 :   nsRectVisibility_kBelowViewport, 
     174                 :   nsRectVisibility_kLeftOfViewport, 
     175                 :   nsRectVisibility_kRightOfViewport
     176                 : };
     177                 : 
     178                 : /**
     179                 :  * Presentation shell interface. Presentation shells are the
     180                 :  * controlling point for managing the presentation of a document. The
     181                 :  * presentation shell holds a live reference to the document, the
     182                 :  * presentation context, the style manager, the style set and the root
     183                 :  * frame. <p>
     184                 :  *
     185                 :  * When this object is Release'd, it will release the document, the
     186                 :  * presentation context, the style manager, the style set and the root
     187                 :  * frame.
     188                 :  */
     189                 : 
     190                 : // hack to make egcs / gcc 2.95.2 happy
     191                 : class nsIPresShell_base : public nsISupports
     192                 : {
     193                 : public:
     194                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESSHELL_IID)
     195                 : };
     196                 : 
     197                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell_base, NS_IPRESSHELL_IID)
     198                 : 
     199                 : class nsIPresShell : public nsIPresShell_base
     200                 : {
     201                 : protected:
     202                 :   typedef mozilla::layers::LayerManager LayerManager;
     203                 : 
     204                 :   enum {
     205                 :     STATE_IGNORING_VIEWPORT_SCROLLING = 0x1,
     206                 :     STATE_USING_DISPLAYPORT = 0x2
     207                 :   };
     208                 : 
     209                 : public:
     210                 :   virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument,
     211                 :                                    nsPresContext* aPresContext,
     212                 :                                    nsIViewManager* aViewManager,
     213                 :                                    nsStyleSet* aStyleSet,
     214                 :                                    nsCompatibility aCompatMode) = 0;
     215                 : 
     216                 :   /**
     217                 :    * All callers are responsible for calling |Destroy| after calling
     218                 :    * |EndObservingDocument|.  It needs to be separate only because form
     219                 :    * controls incorrectly store their data in the frames rather than the
     220                 :    * content model and printing calls |EndObservingDocument| multiple
     221                 :    * times to make form controls behave nicely when printed.
     222                 :    */
     223                 :   virtual NS_HIDDEN_(void) Destroy() = 0;
     224                 : 
     225               0 :   bool IsDestroying() { return mIsDestroying; }
     226                 : 
     227                 :   // All frames owned by the shell are allocated from an arena.  They
     228                 :   // are also recycled using free lists.  Separate free lists are
     229                 :   // maintained for each frame type (aCode), which must always
     230                 :   // correspond to the same aSize value. AllocateFrame clears the
     231                 :   // memory that it returns.
     232                 :   virtual void* AllocateFrame(nsQueryFrame::FrameIID aCode, size_t aSize) = 0;
     233                 :   virtual void  FreeFrame(nsQueryFrame::FrameIID aCode, void* aChunk) = 0;
     234                 : 
     235                 :   // Objects closely related to the frame tree, but that are not
     236                 :   // actual frames (subclasses of nsFrame) are also allocated from the
     237                 :   // arena, and recycled via a separate set of per-size free lists.
     238                 :   // AllocateMisc does *not* clear the memory that it returns.
     239                 :   virtual void* AllocateMisc(size_t aSize) = 0;
     240                 :   virtual void  FreeMisc(size_t aSize, void* aChunk) = 0;
     241                 : 
     242                 :   /**
     243                 :    * Stack memory allocation:
     244                 :    *
     245                 :    * Callers who wish to allocate memory whose lifetime corresponds to
     246                 :    * the lifetime of a stack-allocated object can use this API.  The
     247                 :    * caller must use a pair of calls to PushStackMemory and
     248                 :    * PopStackMemory, such that all stack object lifetimes are either
     249                 :    * entirely between the calls or containing both calls.
     250                 :    *
     251                 :    * Then, between the calls, the caller can call AllocateStackMemory to
     252                 :    * allocate memory from an arena pool that will be freed by the call
     253                 :    * to PopStackMemory.
     254                 :    *
     255                 :    * The allocations cannot be for more than 4044 bytes.
     256                 :    */
     257                 :   virtual void PushStackMemory() = 0;
     258                 :   virtual void PopStackMemory() = 0;
     259                 :   virtual void* AllocateStackMemory(size_t aSize) = 0;
     260                 : 
     261               0 :   nsIDocument* GetDocument() const { return mDocument; }
     262                 : 
     263               0 :   nsPresContext* GetPresContext() const { return mPresContext; }
     264                 : 
     265               0 :   nsIViewManager* GetViewManager() const { return mViewManager; }
     266                 : 
     267                 : #ifdef _IMPL_NS_LAYOUT
     268               0 :   nsStyleSet* StyleSet() const { return mStyleSet; }
     269                 : 
     270                 :   nsCSSFrameConstructor* FrameConstructor() const { return mFrameConstructor; }
     271                 : 
     272               0 :   nsFrameManager* FrameManager() const {
     273                 :     // reinterpret_cast is valid since nsFrameManager does not add
     274                 :     // any members over nsFrameManagerBase.
     275                 :     return reinterpret_cast<nsFrameManager*>
     276               0 :                            (const_cast<nsIPresShell*>(this)->mFrameManager);
     277                 :   }
     278                 : 
     279                 : #endif
     280                 : 
     281                 :   /* Enable/disable author style level. Disabling author style disables the entire
     282                 :    * author level of the cascade, including the HTML preshint level.
     283                 :    */
     284                 :   // XXX these could easily be inlined, but there is a circular #include
     285                 :   // problem with nsStyleSet.
     286                 :   NS_HIDDEN_(void) SetAuthorStyleDisabled(bool aDisabled);
     287                 :   NS_HIDDEN_(bool) GetAuthorStyleDisabled() const;
     288                 : 
     289                 :   /*
     290                 :    * Called when stylesheets are added/removed/enabled/disabled to rebuild
     291                 :    * all style data for a given pres shell without necessarily reconstructing
     292                 :    * all of the frames.  This will not reconstruct style synchronously; if
     293                 :    * you need to do that, call FlushPendingNotifications to flush out style
     294                 :    * reresolves.
     295                 :    * // XXXbz why do we have this on the interface anyway?  The only consumer
     296                 :    * is calling AddOverrideStyleSheet/RemoveOverrideStyleSheet, and I think
     297                 :    * those should just handle reconstructing style data...
     298                 :    */
     299                 :   virtual NS_HIDDEN_(void) ReconstructStyleDataExternal();
     300                 :   NS_HIDDEN_(void) ReconstructStyleDataInternal();
     301                 : #ifdef _IMPL_NS_LAYOUT
     302               0 :   void ReconstructStyleData() { ReconstructStyleDataInternal(); }
     303                 : #else
     304               0 :   void ReconstructStyleData() { ReconstructStyleDataExternal(); }
     305                 : #endif
     306                 : 
     307                 :   /** Setup all style rules required to implement preferences
     308                 :    * - used for background/text/link colors and link underlining
     309                 :    *    may be extended for any prefs that are implemented via style rules
     310                 :    * - aForceReflow argument is used to force a full reframe to make the rules show
     311                 :    *   (only used when the current page needs to reflect changed pref rules)
     312                 :    *
     313                 :    * - initially created for bugs 31816, 20760, 22963
     314                 :    */
     315                 :   virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(bool aForceReflow) = 0;
     316                 : 
     317                 :   /**
     318                 :    * FrameSelection will return the Frame based selection API.
     319                 :    * You cannot go back and forth anymore with QI between nsIDOM sel and
     320                 :    * nsIFrame sel.
     321                 :    */
     322                 :   already_AddRefed<nsFrameSelection> FrameSelection();
     323                 : 
     324                 :   /**
     325                 :    * ConstFrameSelection returns an object which methods are safe to use for
     326                 :    * example in nsIFrame code.
     327                 :    */
     328               0 :   const nsFrameSelection* ConstFrameSelection() const { return mSelection; }
     329                 : 
     330                 :   // Make shell be a document observer.  If called after Destroy() has
     331                 :   // been called on the shell, this will be ignored.
     332                 :   virtual NS_HIDDEN_(void) BeginObservingDocument() = 0;
     333                 : 
     334                 :   // Make shell stop being a document observer
     335                 :   virtual NS_HIDDEN_(void) EndObservingDocument() = 0;
     336                 : 
     337                 :   /**
     338                 :    * Return whether InitialReflow() was previously called.
     339                 :    */
     340               0 :   bool DidInitialReflow() const { return mDidInitialReflow; }
     341                 : 
     342                 :   /**
     343                 :    * Perform the initial reflow. Constructs the frame for the root content
     344                 :    * object and then reflows the frame model into the specified width and
     345                 :    * height.
     346                 :    *
     347                 :    * The coordinates for aWidth and aHeight must be in standard nscoords.
     348                 :    *
     349                 :    * Callers of this method must hold a reference to this shell that
     350                 :    * is guaranteed to survive through arbitrary script execution.
     351                 :    * Calling InitialReflow can execute arbitrary script.
     352                 :    */
     353                 :   virtual NS_HIDDEN_(nsresult) InitialReflow(nscoord aWidth, nscoord aHeight) = 0;
     354                 : 
     355                 :   /**
     356                 :    * Reflow the frame model into a new width and height.  The
     357                 :    * coordinates for aWidth and aHeight must be in standard nscoord's.
     358                 :    */
     359                 :   virtual NS_HIDDEN_(nsresult) ResizeReflow(nscoord aWidth, nscoord aHeight) = 0;
     360                 :   /**
     361                 :    * Reflow, and also change presshell state so as to only permit
     362                 :    * reflowing off calls to ResizeReflowOverride() in the future.
     363                 :    * ResizeReflow() calls are ignored after ResizeReflowOverride().
     364                 :    */
     365                 :   virtual NS_HIDDEN_(nsresult) ResizeReflowOverride(nscoord aWidth, nscoord aHeight) = 0;
     366                 : 
     367                 :   /**
     368                 :    * Returns true if ResizeReflowOverride has been called.
     369                 :    */
     370                 :   virtual bool GetIsViewportOverridden() = 0;
     371                 : 
     372                 :   /**
     373                 :    * Return true if the presshell expects layout flush.
     374                 :    */
     375                 :   virtual bool IsLayoutFlushObserver() = 0;
     376                 : 
     377                 :   /**
     378                 :    * Reflow the frame model with a reflow reason of eReflowReason_StyleChange
     379                 :    */
     380                 :   virtual NS_HIDDEN_(void) StyleChangeReflow() = 0;
     381                 : 
     382                 :   /**
     383                 :    * This calls through to the frame manager to get the root frame.
     384                 :    */
     385                 :   virtual NS_HIDDEN_(nsIFrame*) GetRootFrameExternal() const;
     386               0 :   nsIFrame* GetRootFrame() const {
     387                 : #ifdef _IMPL_NS_LAYOUT
     388               0 :     return mFrameManager->GetRootFrame();
     389                 : #else
     390               0 :     return GetRootFrameExternal();
     391                 : #endif
     392                 :   }
     393                 : 
     394                 :   /*
     395                 :    * Get root scroll frame from FrameManager()->GetRootFrame().
     396                 :    */
     397                 :   nsIFrame* GetRootScrollFrame() const;
     398                 : 
     399                 :   /*
     400                 :    * The same as GetRootScrollFrame, but returns an nsIScrollableFrame
     401                 :    */
     402                 :   nsIScrollableFrame* GetRootScrollFrameAsScrollable() const;
     403                 : 
     404                 :   /*
     405                 :    * The same as GetRootScrollFrame, but returns an nsIScrollableFrame.
     406                 :    * Can be called by code not linked into gklayout.
     407                 :    */
     408                 :   virtual nsIScrollableFrame* GetRootScrollFrameAsScrollableExternal() const;
     409                 : 
     410                 :   /*
     411                 :    * Gets nearest scrollable frame from current focused content or DOM
     412                 :    * selection if there is no focused content. The frame is scrollable with
     413                 :    * overflow:scroll or overflow:auto in some direction when aDirection is
     414                 :    * eEither.  Otherwise, this returns a nearest frame that is scrollable in
     415                 :    * the specified direction.
     416                 :    */
     417                 :   enum ScrollDirection { eHorizontal, eVertical, eEither };
     418                 :   nsIScrollableFrame* GetFrameToScrollAsScrollable(ScrollDirection aDirection);
     419                 : 
     420                 :   /**
     421                 :    * Returns the page sequence frame associated with the frame hierarchy.
     422                 :    * Returns NULL if not a paginated view.
     423                 :    */
     424                 :   virtual NS_HIDDEN_(nsIPageSequenceFrame*) GetPageSequenceFrame() const = 0;
     425                 : 
     426                 :   /**
     427                 :    * Gets the real primary frame associated with the content object.
     428                 :    *
     429                 :    * In the case of absolutely positioned elements and floated elements,
     430                 :    * the real primary frame is the frame that is out of the flow and not the
     431                 :    * placeholder frame.
     432                 :    */
     433                 :   virtual NS_HIDDEN_(nsIFrame*) GetRealPrimaryFrameFor(nsIContent* aContent) const = 0;
     434                 : 
     435                 :   /**
     436                 :    * Gets the placeholder frame associated with the specified frame. This is
     437                 :    * a helper frame that forwards the request to the frame manager.
     438                 :    */
     439                 :   virtual NS_HIDDEN_(nsIFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame) const = 0;
     440                 : 
     441                 :   /**
     442                 :    * Tell the pres shell that a frame needs to be marked dirty and needs
     443                 :    * Reflow.  It's OK if this is an ancestor of the frame needing reflow as
     444                 :    * long as the ancestor chain between them doesn't cross a reflow root.  The
     445                 :    * bit to add should be either NS_FRAME_IS_DIRTY or
     446                 :    * NS_FRAME_HAS_DIRTY_CHILDREN (but not both!).
     447                 :    */
     448                 :   enum IntrinsicDirty {
     449                 :     // XXXldb eResize should be renamed
     450                 :     eResize,     // don't mark any intrinsic widths dirty
     451                 :     eTreeChange, // mark intrinsic widths dirty on aFrame and its ancestors
     452                 :     eStyleChange // Do eTreeChange, plus all of aFrame's descendants
     453                 :   };
     454                 :   virtual NS_HIDDEN_(void) FrameNeedsReflow(nsIFrame *aFrame,
     455                 :                                             IntrinsicDirty aIntrinsicDirty,
     456                 :                                             nsFrameState aBitToAdd) = 0;
     457                 : 
     458                 :   /**
     459                 :    * Tell the presshell that the given frame's reflow was interrupted.  This
     460                 :    * will mark as having dirty children a path from the given frame (inclusive)
     461                 :    * to the nearest ancestor with a dirty subtree, or to the reflow root
     462                 :    * currently being reflowed if no such ancestor exists (inclusive).  This is
     463                 :    * to be done immediately after reflow of the current reflow root completes.
     464                 :    * This method must only be called during reflow, and the frame it's being
     465                 :    * called on must be in the process of being reflowed when it's called.  This
     466                 :    * method doesn't mark any intrinsic widths dirty and doesn't add any bits
     467                 :    * other than NS_FRAME_HAS_DIRTY_CHILDREN.
     468                 :    */
     469                 :   virtual NS_HIDDEN_(void) FrameNeedsToContinueReflow(nsIFrame *aFrame) = 0;
     470                 : 
     471                 :   virtual NS_HIDDEN_(void) CancelAllPendingReflows() = 0;
     472                 : 
     473                 :   /**
     474                 :    * Recreates the frames for a node
     475                 :    */
     476                 :   virtual NS_HIDDEN_(nsresult) RecreateFramesFor(nsIContent* aContent) = 0;
     477                 : 
     478                 :   void PostRecreateFramesFor(mozilla::dom::Element* aElement);
     479                 :   void RestyleForAnimation(mozilla::dom::Element* aElement,
     480                 :                            nsRestyleHint aHint);
     481                 : 
     482                 :   /**
     483                 :    * Determine if it is safe to flush all pending notifications
     484                 :    * @param aIsSafeToFlush true if it is safe, false otherwise.
     485                 :    * 
     486                 :    */
     487                 :   virtual NS_HIDDEN_(bool) IsSafeToFlush() const = 0;
     488                 : 
     489                 :   /**
     490                 :    * Flush pending notifications of the type specified.  This method
     491                 :    * will not affect the content model; it'll just affect style and
     492                 :    * frames. Callers that actually want up-to-date presentation (other
     493                 :    * than the document itself) should probably be calling
     494                 :    * nsIDocument::FlushPendingNotifications.
     495                 :    *
     496                 :    * @param aType the type of notifications to flush
     497                 :    */
     498                 :   virtual NS_HIDDEN_(void) FlushPendingNotifications(mozFlushType aType) = 0;
     499                 : 
     500                 :   /**
     501                 :    * Callbacks will be called even if reflow itself fails for
     502                 :    * some reason.
     503                 :    */
     504                 :   virtual NS_HIDDEN_(nsresult) PostReflowCallback(nsIReflowCallback* aCallback) = 0;
     505                 :   virtual NS_HIDDEN_(void) CancelReflowCallback(nsIReflowCallback* aCallback) = 0;
     506                 : 
     507                 :   virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame) = 0;
     508                 : 
     509                 :   /**
     510                 :    * Get a reference rendering context. This is a context that should not
     511                 :    * be rendered to, but is suitable for measuring text and performing
     512                 :    * other non-rendering operations.
     513                 :    */
     514                 :   virtual already_AddRefed<nsRenderingContext> GetReferenceRenderingContext() = 0;
     515                 : 
     516                 :   /**
     517                 :    * Informs the pres shell that the document is now at the anchor with
     518                 :    * the given name.  If |aScroll| is true, scrolls the view of the
     519                 :    * document so that the anchor with the specified name is displayed at
     520                 :    * the top of the window.  If |aAnchorName| is empty, then this informs
     521                 :    * the pres shell that there is no current target, and |aScroll| must
     522                 :    * be false.
     523                 :    */
     524                 :   virtual NS_HIDDEN_(nsresult) GoToAnchor(const nsAString& aAnchorName, bool aScroll) = 0;
     525                 : 
     526                 :   /**
     527                 :    * Tells the presshell to scroll again to the last anchor scrolled to by
     528                 :    * GoToAnchor, if any. This scroll only happens if the scroll
     529                 :    * position has not changed since the last GoToAnchor. This is called
     530                 :    * by nsDocumentViewer::LoadComplete. This clears the last anchor
     531                 :    * scrolled to by GoToAnchor (we don't want to keep it alive if it's
     532                 :    * removed from the DOM), so don't call this more than once.
     533                 :    */
     534                 :   virtual NS_HIDDEN_(nsresult) ScrollToAnchor() = 0;
     535                 : 
     536                 :   /**
     537                 :    * Scrolls the view of the document so that the primary frame of the content
     538                 :    * is displayed in the window. Layout is flushed before scrolling.
     539                 :    *
     540                 :    * @param aContent  The content object of which primary frame should be
     541                 :    *                  scrolled into view.
     542                 :    * @param aVPercent How to align the frame vertically. A value of 0
     543                 :    *                  (NS_PRESSHELL_SCROLL_TOP) means the frame's upper edge is
     544                 :    *                  aligned with the top edge of the visible area. A value of
     545                 :    *                  100 (NS_PRESSHELL_SCROLL_BOTTOM) means the frame's bottom
     546                 :    *                  edge is aligned with the bottom edge of the visible area.
     547                 :    *                  For values in between, the point "aVPercent" down the frame
     548                 :    *                  is placed at the point "aVPercent" down the visible area. A
     549                 :    *                  value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
     550                 :    *                  vertically. A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
     551                 :    *                  the frame the minimum amount necessary in order for the entire
     552                 :    *                  frame to be visible vertically (if possible)
     553                 :    * @param aHPercent How to align the frame horizontally. A value of 0
     554                 :    *                  (NS_PRESSHELL_SCROLL_LEFT) means the frame's left edge is
     555                 :    *                  aligned with the left edge of the visible area. A value of
     556                 :    *                  100 (NS_PRESSHELL_SCROLL_RIGHT) means the frame's right
     557                 :    *                  edge is aligned with the right edge of the visible area.
     558                 :    *                  For values in between, the point "aVPercent" across the frame
     559                 :    *                  is placed at the point "aVPercent" across the visible area.
     560                 :    *                  A value of 50 (NS_PRESSHELL_SCROLL_CENTER) centers the frame
     561                 :    *                  horizontally . A value of NS_PRESSHELL_SCROLL_ANYWHERE means move
     562                 :    *                  the frame the minimum amount necessary in order for the entire
     563                 :    *                  frame to be visible horizontally (if possible)
     564                 :    * @param aFlags    If SCROLL_FIRST_ANCESTOR_ONLY is set, only the nearest
     565                 :    *                  scrollable ancestor is scrolled, otherwise all
     566                 :    *                  scrollable ancestors may be scrolled if necessary.
     567                 :    *                  If SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a
     568                 :    *                  direction even if overflow:hidden is specified in that
     569                 :    *                  direction; otherwise we will not scroll in that direction
     570                 :    *                  when overflow:hidden is set for that direction.
     571                 :    *                  If SCROLL_NO_PARENT_FRAMES is set then we only scroll
     572                 :    *                  nodes in this document, not in any parent documents which
     573                 :    *                  contain this document in a iframe or the like.
     574                 :    */
     575                 :   virtual NS_HIDDEN_(nsresult) ScrollContentIntoView(nsIContent* aContent,
     576                 :                                                      PRIntn      aVPercent,
     577                 :                                                      PRIntn      aHPercent,
     578                 :                                                      PRUint32    aFlags) = 0;
     579                 : 
     580                 :   enum {
     581                 :     SCROLL_FIRST_ANCESTOR_ONLY = 0x01,
     582                 :     SCROLL_OVERFLOW_HIDDEN = 0x02,
     583                 :     SCROLL_NO_PARENT_FRAMES = 0x04
     584                 :   };
     585                 :   /**
     586                 :    * Scrolls the view of the document so that the given area of a frame
     587                 :    * is visible, if possible. Layout is not flushed before scrolling.
     588                 :    * 
     589                 :    * @param aRect relative to aFrame
     590                 :    * @param aVPercent see ScrollContentIntoView
     591                 :    * @param aHPercent see ScrollContentIntoView
     592                 :    * @param aFlags if SCROLL_FIRST_ANCESTOR_ONLY is set, only the
     593                 :    * nearest scrollable ancestor is scrolled, otherwise all
     594                 :    * scrollable ancestors may be scrolled if necessary
     595                 :    * if SCROLL_OVERFLOW_HIDDEN is set then we may scroll in a direction
     596                 :    * even if overflow:hidden is specified in that direction; otherwise
     597                 :    * we will not scroll in that direction when overflow:hidden is
     598                 :    * set for that direction
     599                 :    * If SCROLL_NO_PARENT_FRAMES is set then we only scroll
     600                 :    * nodes in this document, not in any parent documents which
     601                 :    * contain this document in a iframe or the like.
     602                 :    * @return true if any scrolling happened, false if no scrolling happened
     603                 :    */
     604                 :   virtual bool ScrollFrameRectIntoView(nsIFrame*     aFrame,
     605                 :                                          const nsRect& aRect,
     606                 :                                          PRIntn        aVPercent,
     607                 :                                          PRIntn        aHPercent,
     608                 :                                          PRUint32      aFlags) = 0;
     609                 : 
     610                 :   /**
     611                 :    * Determine if a rectangle specified in the frame's coordinate system 
     612                 :    * intersects the viewport "enough" to be considered visible.
     613                 :    * @param aFrame frame that aRect coordinates are specified relative to
     614                 :    * @param aRect rectangle in twips to test for visibility 
     615                 :    * @param aMinTwips is the minimum distance in from the edge of the viewport
     616                 :    *                  that an object must be to be counted visible
     617                 :    * @return nsRectVisibility_kVisible if the rect is visible
     618                 :    *         nsRectVisibility_kAboveViewport
     619                 :    *         nsRectVisibility_kBelowViewport 
     620                 :    *         nsRectVisibility_kLeftOfViewport 
     621                 :    *         nsRectVisibility_kRightOfViewport rectangle is outside the viewport
     622                 :    *         in the specified direction 
     623                 :    */
     624                 :   virtual nsRectVisibility GetRectVisibility(nsIFrame *aFrame,
     625                 :                                              const nsRect &aRect,
     626                 :                                              nscoord aMinTwips) const = 0;
     627                 : 
     628                 :   /**
     629                 :    * Suppress notification of the frame manager that frames are
     630                 :    * being destroyed.
     631                 :    */
     632                 :   virtual NS_HIDDEN_(void) SetIgnoreFrameDestruction(bool aIgnore) = 0;
     633                 : 
     634                 :   /**
     635                 :    * Notification sent by a frame informing the pres shell that it is about to
     636                 :    * be destroyed.
     637                 :    * This allows any outstanding references to the frame to be cleaned up
     638                 :    */
     639                 :   virtual NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame) = 0;
     640                 : 
     641                 :   /**
     642                 :    * Get link location.
     643                 :    */
     644                 :   virtual NS_HIDDEN_(nsresult) GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation) const = 0;
     645                 : 
     646                 :   /**
     647                 :    * Get the caret, if it exists. AddRefs it.
     648                 :    */
     649                 :   virtual NS_HIDDEN_(already_AddRefed<nsCaret>) GetCaret() const = 0;
     650                 : 
     651                 :   /**
     652                 :    * Invalidate the caret's current position if it's outside of its frame's
     653                 :    * boundaries. This function is useful if you're batching selection
     654                 :    * notifications and might remove the caret's frame out from under it.
     655                 :    */
     656                 :   virtual NS_HIDDEN_(void) MaybeInvalidateCaretPosition() = 0;
     657                 : 
     658                 :   /**
     659                 :    * Set the current caret to a new caret. To undo this, call RestoreCaret.
     660                 :    */
     661                 :   virtual void SetCaret(nsCaret *aNewCaret) = 0;
     662                 : 
     663                 :   /**
     664                 :    * Restore the caret to the original caret that this pres shell was created
     665                 :    * with.
     666                 :    */
     667                 :   virtual void RestoreCaret() = 0;
     668                 : 
     669                 :   /**
     670                 :    * Should the images have borders etc.  Actual visual effects are determined
     671                 :    * by the frames.  Visual effects may not effect layout, only display.
     672                 :    * Takes effect on next repaint, does not force a repaint itself.
     673                 :    *
     674                 :    * @param aInEnable  if true, visual selection effects are enabled
     675                 :    *                   if false visual selection effects are disabled
     676                 :    */
     677                 :   NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable) = 0;
     678                 : 
     679                 :   /** 
     680                 :     * Gets the current state of non text selection effects
     681                 :     * @return   current state of non text selection,
     682                 :     *           as set by SetDisplayNonTextSelection
     683                 :     */
     684               0 :   PRInt16 GetSelectionFlags() const { return mSelectionFlags; }
     685                 : 
     686                 :   virtual nsISelection* GetCurrentSelection(SelectionType aType) = 0;
     687                 : 
     688                 :   /**
     689                 :     * Interface to dispatch events via the presshell
     690                 :     * @note The caller must have a strong reference to the PresShell.
     691                 :     */
     692                 :   virtual NS_HIDDEN_(nsresult) HandleEventWithTarget(nsEvent* aEvent,
     693                 :                                                      nsIFrame* aFrame,
     694                 :                                                      nsIContent* aContent,
     695                 :                                                      nsEventStatus* aStatus) = 0;
     696                 : 
     697                 :   /**
     698                 :    * Dispatch event to content only (NOT full processing)
     699                 :    * @note The caller must have a strong reference to the PresShell.
     700                 :    */
     701                 :   virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
     702                 :                                                         nsEvent* aEvent,
     703                 :                                                         nsEventStatus* aStatus) = 0;
     704                 : 
     705                 :   /**
     706                 :    * Dispatch event to content only (NOT full processing)
     707                 :    * @note The caller must have a strong reference to the PresShell.
     708                 :    */
     709                 :   virtual NS_HIDDEN_(nsresult) HandleDOMEventWithTarget(nsIContent* aTargetContent,
     710                 :                                                         nsIDOMEvent* aEvent,
     711                 :                                                         nsEventStatus* aStatus) = 0;
     712                 : 
     713                 :   /**
     714                 :     * Gets the current target event frame from the PresShell
     715                 :     */
     716                 :   virtual NS_HIDDEN_(nsIFrame*) GetEventTargetFrame() = 0;
     717                 : 
     718                 :   /**
     719                 :     * Gets the current target event frame from the PresShell
     720                 :     */
     721                 :   virtual NS_HIDDEN_(already_AddRefed<nsIContent>) GetEventTargetContent(nsEvent* aEvent) = 0;
     722                 : 
     723                 :   /**
     724                 :    * Get and set the history state for the current document 
     725                 :    */
     726                 : 
     727                 :   virtual NS_HIDDEN_(nsresult) CaptureHistoryState(nsILayoutHistoryState** aLayoutHistoryState, bool aLeavingPage = false) = 0;
     728                 : 
     729                 :   /**
     730                 :    * Determine if reflow is currently locked
     731                 :    * returns true if reflow is locked, false otherwise
     732                 :    */
     733                 :   bool IsReflowLocked() const { return mIsReflowing; }
     734                 : 
     735                 :   /**
     736                 :    * Called to find out if painting is suppressed for this presshell.  If it is suppressd,
     737                 :    * we don't allow the painting of any layer but the background, and we don't
     738                 :    * recur into our children.
     739                 :    */
     740               0 :   bool IsPaintingSuppressed() const { return mPaintingSuppressed; }
     741                 : 
     742                 :   /**
     743                 :    * Unsuppress painting.
     744                 :    */
     745                 :   virtual NS_HIDDEN_(void) UnsuppressPainting() = 0;
     746                 : 
     747                 :   /**
     748                 :    * Called to disable nsITheme support in a specific presshell.
     749                 :    */
     750               0 :   void DisableThemeSupport()
     751                 :   {
     752                 :     // Doesn't have to be dynamic.  Just set the bool.
     753               0 :     mIsThemeSupportDisabled = true;
     754               0 :   }
     755                 : 
     756                 :   /**
     757                 :    * Indicates whether theme support is enabled.
     758                 :    */
     759                 :   bool IsThemeSupportEnabled() const { return !mIsThemeSupportDisabled; }
     760                 : 
     761                 :   /**
     762                 :    * Get the set of agent style sheets for this presentation
     763                 :    */
     764                 :   virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) = 0;
     765                 : 
     766                 :   /**
     767                 :    * Replace the set of agent style sheets
     768                 :    */
     769                 :   virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) = 0;
     770                 : 
     771                 :   /**
     772                 :    * Add an override style sheet for this presentation
     773                 :    */
     774                 :   virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
     775                 : 
     776                 :   /**
     777                 :    * Remove an override style sheet
     778                 :    */
     779                 :   virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
     780                 : 
     781                 :   /**
     782                 :    * Reconstruct frames for all elements in the document
     783                 :    */
     784                 :   virtual nsresult ReconstructFrames() = 0;
     785                 : 
     786                 :   /**
     787                 :    * Notify that a content node's state has changed
     788                 :    */
     789                 :   virtual void ContentStateChanged(nsIDocument* aDocument,
     790                 :                                    nsIContent* aContent,
     791                 :                                    nsEventStates aStateMask) = 0;
     792                 : 
     793                 :   /**
     794                 :    * Given aFrame, the root frame of a stacking context, find its descendant
     795                 :    * frame under the point aPt that receives a mouse event at that location,
     796                 :    * or nsnull if there is no such frame.
     797                 :    * @param aPt the point, relative to the frame origin
     798                 :    */
     799                 :   virtual nsIFrame* GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt) = 0;
     800                 : 
     801                 :   /**
     802                 :    * See if reflow verification is enabled. To enable reflow verification add
     803                 :    * "verifyreflow:1" to your NSPR_LOG_MODULES environment variable
     804                 :    * (any non-zero debug level will work). Or, call SetVerifyReflowEnable
     805                 :    * with true.
     806                 :    */
     807                 :   static bool GetVerifyReflowEnable();
     808                 : 
     809                 :   /**
     810                 :    * Set the verify-reflow enable flag.
     811                 :    */
     812                 :   static void SetVerifyReflowEnable(bool aEnabled);
     813                 : 
     814                 :   virtual nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);
     815                 : 
     816                 : #ifdef MOZ_REFLOW_PERF
     817                 :   virtual NS_HIDDEN_(void) DumpReflows() = 0;
     818                 :   virtual NS_HIDDEN_(void) CountReflows(const char * aName, nsIFrame * aFrame) = 0;
     819                 :   virtual NS_HIDDEN_(void) PaintCount(const char * aName,
     820                 :                                       nsRenderingContext* aRenderingContext,
     821                 :                                       nsPresContext * aPresContext,
     822                 :                                       nsIFrame * aFrame,
     823                 :                                       const nsPoint& aOffset,
     824                 :                                       PRUint32 aColor) = 0;
     825                 :   virtual NS_HIDDEN_(void) SetPaintFrameCount(bool aOn) = 0;
     826                 :   virtual bool IsPaintingFrameCounts() = 0;
     827                 : #endif
     828                 : 
     829                 : #ifdef DEBUG
     830                 :   // Debugging hooks
     831                 :   virtual void ListStyleContexts(nsIFrame *aRootFrame, FILE *out,
     832                 :                                  PRInt32 aIndent = 0) = 0;
     833                 : 
     834                 :   virtual void ListStyleSheets(FILE *out, PRInt32 aIndent = 0) = 0;
     835                 :   virtual void VerifyStyleTree() = 0;
     836                 : #endif
     837                 : 
     838                 : #ifdef ACCESSIBILITY
     839                 :   /**
     840                 :    * Return true if accessibility is active.
     841                 :    */
     842                 :   static bool IsAccessibilityActive();
     843                 : 
     844                 :   /**
     845                 :    * Return accessibility service if accessibility is active.
     846                 :    */
     847                 :   static nsAccessibilityService* AccService();
     848                 : #endif
     849                 : 
     850                 :   /**
     851                 :    * Stop all active elements (plugins and the caret) in this presentation and
     852                 :    * in the presentations of subdocuments.  Resets painting to a suppressed state.
     853                 :    * XXX this should include image animations
     854                 :    */
     855                 :   virtual void Freeze() = 0;
     856                 :   bool IsFrozen() { return mFrozen; }
     857                 : 
     858                 :   /**
     859                 :    * Restarts active elements (plugins) in this presentation and in the
     860                 :    * presentations of subdocuments, then do a full invalidate of the content area.
     861                 :    */
     862                 :   virtual void Thaw() = 0;
     863                 : 
     864                 :   virtual void FireOrClearDelayedEvents(bool aFireEvents) = 0;
     865                 : 
     866                 :   /**
     867                 :    * When this shell is disconnected from its containing docshell, we
     868                 :    * lose our container pointer.  However, we'd still like to be able to target
     869                 :    * user events at the docshell's parent.  This pointer allows us to do that.
     870                 :    * It should not be used for any other purpose.
     871                 :    */
     872                 :   void SetForwardingContainer(nsWeakPtr aContainer)
     873                 :   {
     874                 :     mForwardingContainer = aContainer;
     875                 :   }
     876                 :   
     877                 :   /**
     878                 :    * Render the document into an arbitrary gfxContext
     879                 :    * Designed for getting a picture of a document or a piece of a document
     880                 :    * Note that callers will generally want to call FlushPendingNotifications
     881                 :    * to get an up-to-date view of the document
     882                 :    * @param aRect is the region to capture into the offscreen buffer, in the
     883                 :    * root frame's coordinate system (if aIgnoreViewportScrolling is false)
     884                 :    * or in the root scrolled frame's coordinate system
     885                 :    * (if aIgnoreViewportScrolling is true). The coordinates are in appunits.
     886                 :    * @param aFlags see below;
     887                 :    *   set RENDER_IS_UNTRUSTED if the contents may be passed to malicious
     888                 :    * agents. E.g. we might choose not to paint the contents of sensitive widgets
     889                 :    * such as the file name in a file upload widget, and we might choose not
     890                 :    * to paint themes.
     891                 :    *   set RENDER_IGNORE_VIEWPORT_SCROLLING to ignore
     892                 :    * clipping/scrolling/scrollbar painting due to scrolling in the viewport
     893                 :    *   set RENDER_CARET to draw the caret if one would be visible
     894                 :    * (by default the caret is never drawn)
     895                 :    *   set RENDER_USE_LAYER_MANAGER to force rendering to go through
     896                 :    * the layer manager for the window. This may be unexpectedly slow
     897                 :    * (if the layer manager must read back data from the GPU) or low-quality
     898                 :    * (if the layer manager reads back pixel data and scales it
     899                 :    * instead of rendering using the appropriate scaling). It may also
     900                 :    * slow everything down if the area rendered does not correspond to the
     901                 :    * normal visible area of the window.
     902                 :    *   set RENDER_ASYNC_DECODE_IMAGES to avoid having images synchronously
     903                 :    * decoded during rendering.
     904                 :    * (by default images decode synchronously with RenderDocument)
     905                 :    *   set RENDER_DOCUMENT_RELATIVE to interpret |aRect| relative to the
     906                 :    * document instead of the CSS viewport
     907                 :    * @param aBackgroundColor a background color to render onto
     908                 :    * @param aRenderedContext the gfxContext to render to. We render so that
     909                 :    * one CSS pixel in the source document is rendered to one unit in the current
     910                 :    * transform.
     911                 :    */
     912                 :   enum {
     913                 :     RENDER_IS_UNTRUSTED = 0x01,
     914                 :     RENDER_IGNORE_VIEWPORT_SCROLLING = 0x02,
     915                 :     RENDER_CARET = 0x04,
     916                 :     RENDER_USE_WIDGET_LAYERS = 0x08,
     917                 :     RENDER_ASYNC_DECODE_IMAGES = 0x10,
     918                 :     RENDER_DOCUMENT_RELATIVE = 0x20
     919                 :   };
     920                 :   virtual NS_HIDDEN_(nsresult) RenderDocument(const nsRect& aRect, PRUint32 aFlags,
     921                 :                                               nscolor aBackgroundColor,
     922                 :                                               gfxContext* aRenderedContext) = 0;
     923                 : 
     924                 :   /**
     925                 :    * Renders a node aNode to a surface and returns it. The aRegion may be used
     926                 :    * to clip the rendering. This region is measured in CSS pixels from the
     927                 :    * edge of the presshell area. The aPoint, aScreenRect and aSurface
     928                 :    * arguments function in a similar manner as RenderSelection.
     929                 :    */
     930                 :   virtual already_AddRefed<gfxASurface> RenderNode(nsIDOMNode* aNode,
     931                 :                                                    nsIntRegion* aRegion,
     932                 :                                                    nsIntPoint& aPoint,
     933                 :                                                    nsIntRect* aScreenRect) = 0;
     934                 : 
     935                 :   /**
     936                 :    * Renders a selection to a surface and returns it. This method is primarily
     937                 :    * intended to create the drag feedback when dragging a selection.
     938                 :    *
     939                 :    * aScreenRect will be filled in with the bounding rectangle of the
     940                 :    * selection area on screen.
     941                 :    *
     942                 :    * If the area of the selection is large, the image will be scaled down.
     943                 :    * The argument aPoint is used in this case as a reference point when
     944                 :    * determining the new screen rectangle after scaling. Typically, this
     945                 :    * will be the mouse position, so that the screen rectangle is positioned
     946                 :    * such that the mouse is over the same point in the scaled image as in
     947                 :    * the original. When scaling does not occur, the mouse point isn't used
     948                 :    * as the position can be determined from the displayed frames.
     949                 :    */
     950                 :   virtual already_AddRefed<gfxASurface> RenderSelection(nsISelection* aSelection,
     951                 :                                                         nsIntPoint& aPoint,
     952                 :                                                         nsIntRect* aScreenRect) = 0;
     953                 : 
     954                 :   void AddWeakFrameInternal(nsWeakFrame* aWeakFrame);
     955                 :   virtual void AddWeakFrameExternal(nsWeakFrame* aWeakFrame);
     956                 : 
     957               0 :   void AddWeakFrame(nsWeakFrame* aWeakFrame)
     958                 :   {
     959                 : #ifdef _IMPL_NS_LAYOUT
     960                 :     AddWeakFrameInternal(aWeakFrame);
     961                 : #else
     962               0 :     AddWeakFrameExternal(aWeakFrame);
     963                 : #endif
     964               0 :   }
     965                 : 
     966                 :   void RemoveWeakFrameInternal(nsWeakFrame* aWeakFrame);
     967                 :   virtual void RemoveWeakFrameExternal(nsWeakFrame* aWeakFrame);
     968                 : 
     969               0 :   void RemoveWeakFrame(nsWeakFrame* aWeakFrame)
     970                 :   {
     971                 : #ifdef _IMPL_NS_LAYOUT
     972               0 :     RemoveWeakFrameInternal(aWeakFrame);
     973                 : #else
     974               0 :     RemoveWeakFrameExternal(aWeakFrame);
     975                 : #endif
     976               0 :   }
     977                 : 
     978                 : #ifdef NS_DEBUG
     979                 :   nsIFrame* GetDrawEventTargetFrame() { return mDrawEventTargetFrame; }
     980                 : #endif
     981                 : 
     982                 :   /**
     983                 :    * Stop or restart non synthetic test mouse event handling on *all*
     984                 :    * presShells.
     985                 :    *
     986                 :    * @param aDisable If true, disable all non synthetic test mouse
     987                 :    * events on all presShells.  Otherwise, enable them.
     988                 :    */
     989                 :   virtual NS_HIDDEN_(void) DisableNonTestMouseEvents(bool aDisable) = 0;
     990                 : 
     991                 :   /**
     992                 :    * Record the background color of the most recently drawn canvas. This color
     993                 :    * is composited on top of the user's default background color and then used
     994                 :    * to draw the background color of the canvas. See PresShell::Paint,
     995                 :    * PresShell::PaintDefaultBackground, and nsDocShell::SetupNewViewer;
     996                 :    * bug 488242, bug 476557 and other bugs mentioned there.
     997                 :    */
     998               0 :   void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; }
     999               0 :   nscolor GetCanvasBackground() { return mCanvasBackgroundColor; }
    1000                 : 
    1001                 :   /**
    1002                 :    * Use the current frame tree (if it exists) to update the background
    1003                 :    * color of the most recently drawn canvas.
    1004                 :    */
    1005                 :   virtual void UpdateCanvasBackground() = 0;
    1006                 : 
    1007                 :   /**
    1008                 :    * Add a solid color item to the bottom of aList with frame aFrame and bounds
    1009                 :    * aBounds. Checks first if this needs to be done by checking if aFrame is a
    1010                 :    * canvas frame (if the FORCE_DRAW flag is passed then this check is skipped).
    1011                 :    * aBackstopColor is composed behind the background color of the canvas, it is
    1012                 :    * transparent by default.
    1013                 :    */
    1014                 :   enum {
    1015                 :     FORCE_DRAW = 0x01
    1016                 :   };
    1017                 :   virtual nsresult AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
    1018                 :                                                 nsDisplayList& aList,
    1019                 :                                                 nsIFrame* aFrame,
    1020                 :                                                 const nsRect& aBounds,
    1021                 :                                                 nscolor aBackstopColor = NS_RGBA(0,0,0,0),
    1022                 :                                                 PRUint32 aFlags = 0) = 0;
    1023                 : 
    1024                 : 
    1025                 :   /**
    1026                 :    * Add a solid color item to the bottom of aList with frame aFrame and
    1027                 :    * bounds aBounds representing the dark grey background behind the page of a
    1028                 :    * print preview presentation.
    1029                 :    */
    1030                 :   virtual nsresult AddPrintPreviewBackgroundItem(nsDisplayListBuilder& aBuilder,
    1031                 :                                                  nsDisplayList& aList,
    1032                 :                                                  nsIFrame* aFrame,
    1033                 :                                                  const nsRect& aBounds) = 0;
    1034                 : 
    1035                 :   /**
    1036                 :    * Computes the backstop color for the view: transparent if in a transparent
    1037                 :    * widget, otherwise the PresContext default background color. This color is
    1038                 :    * only visible if the contents of the view as a whole are translucent.
    1039                 :    */
    1040                 :   virtual nscolor ComputeBackstopColor(nsIView* aDisplayRoot) = 0;
    1041                 : 
    1042               0 :   void ObserveNativeAnonMutationsForPrint(bool aObserve)
    1043                 :   {
    1044               0 :     mObservesMutationsForPrint = aObserve;
    1045               0 :   }
    1046               0 :   bool ObservesNativeAnonMutationsForPrint()
    1047                 :   {
    1048               0 :     return mObservesMutationsForPrint;
    1049                 :   }
    1050                 : 
    1051                 :   virtual nsresult SetIsActive(bool aIsActive) = 0;
    1052                 : 
    1053                 :   bool IsActive()
    1054                 :   {
    1055                 :     return mIsActive;
    1056                 :   }
    1057                 : 
    1058                 :   // mouse capturing
    1059                 : 
    1060                 :   static CapturingContentInfo gCaptureInfo;
    1061                 : 
    1062                 :   static nsInterfaceHashtable<nsUint32HashKey, nsIDOMTouch> gCaptureTouchList;
    1063                 :   static bool gPreventMouseEvents;
    1064                 : 
    1065                 :   /**
    1066                 :    * When capturing content is set, it traps all mouse events and retargets
    1067                 :    * them at this content node. If capturing is not allowed
    1068                 :    * (gCaptureInfo.mAllowed is false), then capturing is not set. However, if
    1069                 :    * the CAPTURE_IGNOREALLOWED flag is set, the allowed state is ignored and
    1070                 :    * capturing is set regardless. To disable capture, pass null for the value
    1071                 :    * of aContent.
    1072                 :    *
    1073                 :    * If CAPTURE_RETARGETTOELEMENT is set, all mouse events are targeted at
    1074                 :    * aContent only. Otherwise, mouse events are targeted at aContent or its
    1075                 :    * descendants. That is, descendants of aContent receive mouse events as
    1076                 :    * they normally would, but mouse events outside of aContent are retargeted
    1077                 :    * to aContent.
    1078                 :    *
    1079                 :    * If CAPTURE_PREVENTDRAG is set then drags are prevented from starting while
    1080                 :    * this capture is active.
    1081                 :    */
    1082                 :   static void SetCapturingContent(nsIContent* aContent, PRUint8 aFlags);
    1083                 : 
    1084                 :   /**
    1085                 :    * Return the active content currently capturing the mouse if any.
    1086                 :    */
    1087               0 :   static nsIContent* GetCapturingContent()
    1088                 :   {
    1089               0 :     return gCaptureInfo.mContent;
    1090                 :   }
    1091                 : 
    1092                 :   /**
    1093                 :    * Allow or disallow mouse capturing.
    1094                 :    */
    1095               0 :   static void AllowMouseCapture(bool aAllowed)
    1096                 :   {
    1097               0 :     gCaptureInfo.mAllowed = aAllowed;
    1098               0 :   }
    1099                 : 
    1100                 :   /**
    1101                 :    * Returns true if there is an active mouse capture that wants to prevent
    1102                 :    * drags.
    1103                 :    */
    1104               0 :   static bool IsMouseCapturePreventingDrag()
    1105                 :   {
    1106               0 :     return gCaptureInfo.mPreventDrag && gCaptureInfo.mContent;
    1107                 :   }
    1108                 : 
    1109                 :   /**
    1110                 :    * Keep track of how many times this presshell has been rendered to
    1111                 :    * a window.
    1112                 :    */
    1113               0 :   PRUint64 GetPaintCount() { return mPaintCount; }
    1114                 :   void IncrementPaintCount() { ++mPaintCount; }
    1115                 : 
    1116                 :   /**
    1117                 :    * Get the root DOM window of this presShell.
    1118                 :    */
    1119                 :   virtual already_AddRefed<nsPIDOMWindow> GetRootWindow() = 0;
    1120                 : 
    1121                 :   /**
    1122                 :    * Get the layer manager for the widget of the root view, if it has
    1123                 :    * one.
    1124                 :    */
    1125                 :   virtual LayerManager* GetLayerManager() = 0;
    1126                 : 
    1127                 :   /**
    1128                 :    * Track whether we're ignoring viewport scrolling for the purposes
    1129                 :    * of painting.  If we are ignoring, then layers aren't clipped to
    1130                 :    * the CSS viewport and scrollbars aren't drawn.
    1131                 :    */
    1132                 :   virtual void SetIgnoreViewportScrolling(bool aIgnore) = 0;
    1133                 :   bool IgnoringViewportScrolling() const
    1134                 :   { return mRenderFlags & STATE_IGNORING_VIEWPORT_SCROLLING; }
    1135                 : 
    1136                 :    /**
    1137                 :    * Set a "resolution" for the document, which if not 1.0 will
    1138                 :    * allocate more or fewer pixels for rescalable content by a factor
    1139                 :    * of |resolution| in both dimensions.  Return NS_OK iff the
    1140                 :    * resolution bounds are sane, and the resolution of this was
    1141                 :    * actually updated.
    1142                 :    *
    1143                 :    * The resolution defaults to 1.0.
    1144                 :    */
    1145                 :   virtual nsresult SetResolution(float aXResolution, float aYResolution) = 0;
    1146                 :   float GetXResolution() { return mXResolution; }
    1147                 :   float GetYResolution() { return mYResolution; }
    1148                 : 
    1149                 :   /**
    1150                 :    * Dispatch a mouse move event based on the most recent mouse position if
    1151                 :    * this PresShell is visible. This is used when the contents of the page
    1152                 :    * moved (aFromScroll is false) or scrolled (aFromScroll is true).
    1153                 :    */
    1154                 :   virtual void SynthesizeMouseMove(bool aFromScroll) = 0;
    1155                 : 
    1156                 :   virtual void Paint(nsIView* aViewToPaint, nsIWidget* aWidget,
    1157                 :                      const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion,
    1158                 :                      bool aWillSendDidPaint) = 0;
    1159                 :   virtual nsresult HandleEvent(nsIFrame*       aFrame,
    1160                 :                                nsGUIEvent*     aEvent,
    1161                 :                                bool            aDontRetargetEvents,
    1162                 :                                nsEventStatus*  aEventStatus) = 0;
    1163                 :   virtual bool ShouldIgnoreInvalidation() = 0;
    1164                 :   /**
    1165                 :    * Notify that the NS_WILL_PAINT event was received. Fires on every
    1166                 :    * visible presshell in the document tree.
    1167                 :    */
    1168                 :   virtual void WillPaint(bool aWillSendDidPaint) = 0;
    1169                 :   /**
    1170                 :    * Notify that the NS_DID_PAINT event was received. Only fires on the
    1171                 :    * root pres shell.
    1172                 :    */
    1173                 :   virtual void DidPaint() = 0;
    1174                 :   virtual void ScheduleViewManagerFlush() = 0;
    1175                 :   virtual void ClearMouseCaptureOnView(nsIView* aView) = 0;
    1176                 :   virtual bool IsVisible() = 0;
    1177                 :   virtual void DispatchSynthMouseMove(nsGUIEvent *aEvent, bool aFlushOnHoverChange) = 0;
    1178                 : 
    1179                 :   virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
    1180                 :                                    size_t *aArenasSize,
    1181                 :                                    size_t *aStyleSetsSize,
    1182                 :                                    size_t *aTextRunsSize) const = 0;
    1183                 : 
    1184                 :   /**
    1185                 :    * Refresh observer management.
    1186                 :    */
    1187                 : protected:
    1188                 :   virtual bool AddRefreshObserverExternal(nsARefreshObserver* aObserver,
    1189                 :                                             mozFlushType aFlushType);
    1190                 :   bool AddRefreshObserverInternal(nsARefreshObserver* aObserver,
    1191                 :                                     mozFlushType aFlushType);
    1192                 :   virtual bool RemoveRefreshObserverExternal(nsARefreshObserver* aObserver,
    1193                 :                                                mozFlushType aFlushType);
    1194                 :   bool RemoveRefreshObserverInternal(nsARefreshObserver* aObserver,
    1195                 :                                        mozFlushType aFlushType);
    1196                 : public:
    1197               0 :   bool AddRefreshObserver(nsARefreshObserver* aObserver,
    1198                 :                             mozFlushType aFlushType) {
    1199                 : #ifdef _IMPL_NS_LAYOUT
    1200                 :     return AddRefreshObserverInternal(aObserver, aFlushType);
    1201                 : #else
    1202               0 :     return AddRefreshObserverExternal(aObserver, aFlushType);
    1203                 : #endif
    1204                 :   }
    1205                 : 
    1206               0 :   bool RemoveRefreshObserver(nsARefreshObserver* aObserver,
    1207                 :                                mozFlushType aFlushType) {
    1208                 : #ifdef _IMPL_NS_LAYOUT
    1209                 :     return RemoveRefreshObserverInternal(aObserver, aFlushType);
    1210                 : #else
    1211               0 :     return RemoveRefreshObserverExternal(aObserver, aFlushType);
    1212                 : #endif
    1213                 :   }
    1214                 : 
    1215                 :   /**
    1216                 :    * Initialize and shut down static variables.
    1217                 :    */
    1218                 :   static void InitializeStatics();
    1219                 :   static void ReleaseStatics();
    1220                 : 
    1221                 :   // If a frame in the subtree rooted at aFrame is capturing the mouse then
    1222                 :   // clears that capture.
    1223                 :   static void ClearMouseCapture(nsIFrame* aFrame);
    1224                 : 
    1225                 : protected:
    1226                 :   friend class nsRefreshDriver;
    1227                 : 
    1228                 :   // IMPORTANT: The ownership implicit in the following member variables
    1229                 :   // has been explicitly checked.  If you add any members to this class,
    1230                 :   // please make the ownership explicit (pinkerton, scc).
    1231                 : 
    1232                 :   // these are the same Document and PresContext owned by the DocViewer.
    1233                 :   // we must share ownership.
    1234                 :   nsIDocument*              mDocument;      // [STRONG]
    1235                 :   nsPresContext*            mPresContext;   // [STRONG]
    1236                 :   nsStyleSet*               mStyleSet;      // [OWNS]
    1237                 :   nsCSSFrameConstructor*    mFrameConstructor; // [OWNS]
    1238                 :   nsIViewManager*           mViewManager;   // [WEAK] docViewer owns it so I don't have to
    1239                 :   nsFrameSelection*         mSelection;
    1240                 :   // Pointer into mFrameConstructor - this is purely so that FrameManager() and
    1241                 :   // GetRootFrame() can be inlined:
    1242                 :   nsFrameManagerBase*       mFrameManager;
    1243                 :   nsWeakPtr                 mForwardingContainer;
    1244                 : 
    1245                 : #ifdef NS_DEBUG
    1246                 :   nsIFrame*                 mDrawEventTargetFrame;
    1247                 : #endif
    1248                 : 
    1249                 :   // Count of the number of times this presshell has been painted to
    1250                 :   // a window
    1251                 :   PRUint64                  mPaintCount;
    1252                 : 
    1253                 :   PRInt16                   mSelectionFlags;
    1254                 : 
    1255                 :   bool                      mStylesHaveChanged;
    1256                 :   bool                      mDidInitialReflow;
    1257                 :   bool                      mIsDestroying;
    1258                 :   bool                      mIsReflowing;
    1259                 :   bool                      mPaintingSuppressed;  // For all documents we initially lock down painting.
    1260                 :   bool                      mIsThemeSupportDisabled;  // Whether or not form controls should use nsITheme in this shell.
    1261                 :   bool                      mIsActive;
    1262                 :   bool                      mFrozen;
    1263                 : 
    1264                 :   bool                      mObservesMutationsForPrint;
    1265                 : 
    1266                 :   bool                      mReflowScheduled; // If true, we have a reflow
    1267                 :                                               // scheduled. Guaranteed to be
    1268                 :                                               // false if mReflowContinueTimer
    1269                 :                                               // is non-null.
    1270                 : 
    1271                 :   bool                      mSuppressInterruptibleReflows;
    1272                 : 
    1273                 :   // A list of weak frames. This is a pointer to the last item in the list.
    1274                 :   nsWeakFrame*              mWeakFrames;
    1275                 : 
    1276                 :   // Most recent canvas background color.
    1277                 :   nscolor                   mCanvasBackgroundColor;
    1278                 : 
    1279                 :   // Flags controlling how our document is rendered.  These persist
    1280                 :   // between paints and so are tied with retained layer pixels.
    1281                 :   // PresShell flushes retained layers when the rendering state
    1282                 :   // changes in a way that prevents us from being able to (usefully)
    1283                 :   // re-use old pixels.
    1284                 :   PRUint32                  mRenderFlags;
    1285                 : 
    1286                 :   // Used to force allocation and rendering of proportionally more or
    1287                 :   // less pixels in the given dimension.
    1288                 :   float                     mXResolution;
    1289                 :   float                     mYResolution;
    1290                 : 
    1291                 :   static nsIContent* gKeyDownTarget;
    1292                 : };
    1293                 : 
    1294                 : /**
    1295                 :  * Create a new empty presentation shell. Upon success, call Init
    1296                 :  * before attempting to use the shell.
    1297                 :  */
    1298                 : nsresult
    1299                 : NS_NewPresShell(nsIPresShell** aInstancePtrResult);
    1300                 : 
    1301                 : #endif /* nsIPresShell_h___ */

Generated by: LCOV version 1.7