2006-01-26 05:29:17 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2006-04-18 03:16:46 +04:00
|
|
|
* vim: set ts=2 sw=2 et tw=78:
|
2006-01-26 05:29:17 +03:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Novell code.
|
|
|
|
*
|
2006-03-31 10:28:40 +04:00
|
|
|
* The Initial Developer of the Original Code is Novell Corporation.
|
2007-10-06 16:08:39 +04:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2006-01-26 05:29:17 +03:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* robert@ocallahan.org
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2006-03-30 09:56:38 +04:00
|
|
|
/*
|
|
|
|
* structures that represent things to be painted (ordered in z-order),
|
|
|
|
* used during painting and hit testing
|
|
|
|
*/
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
#ifndef NSDISPLAYLIST_H_
|
|
|
|
#define NSDISPLAYLIST_H_
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsISelection.h"
|
2008-07-16 14:52:01 +04:00
|
|
|
#include "nsCaret.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "plarena.h"
|
2010-03-01 10:56:19 +03:00
|
|
|
#include "Layers.h"
|
2010-05-21 07:20:48 +04:00
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "FrameLayerBuilder.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
class nsIPresShell;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIRenderingContext;
|
|
|
|
class nsIDeviceContext;
|
2008-04-06 15:34:14 +04:00
|
|
|
class nsDisplayTableItem;
|
2009-08-14 06:09:51 +04:00
|
|
|
class nsDisplayItem;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* An nsIFrame can have many different visual parts. For example an image frame
|
|
|
|
* can have a background, border, and outline, the image itself, and a
|
|
|
|
* translucent selection overlay. In general these parts can be drawn at
|
|
|
|
* discontiguous z-levels; see CSS2.1 appendix E:
|
|
|
|
* http://www.w3.org/TR/CSS21/zindex.html
|
|
|
|
*
|
|
|
|
* We construct a display list for a frame tree that contains one item
|
|
|
|
* for each visual part. The display list is itself a tree since some items
|
|
|
|
* are containers for other items; however, its structure does not match
|
|
|
|
* the structure of its source frame tree. The display list items are sorted
|
|
|
|
* by z-order. A display list can be used to paint the frames, to determine
|
|
|
|
* which frame is the target of a mouse event, and to determine what areas
|
|
|
|
* need to be repainted when scrolling. The display lists built for each task
|
|
|
|
* may be different for efficiency; in particular some frames need special
|
|
|
|
* display list items only for event handling, and do not create these items
|
|
|
|
* when the display list will be used for painting (the common case). For
|
|
|
|
* example, when painting we avoid creating nsDisplayBackground items for
|
|
|
|
* frames that don't display a visible background, but for event handling
|
|
|
|
* we need those backgrounds because they are not transparent to events.
|
|
|
|
*
|
|
|
|
* We could avoid constructing an explicit display list by traversing the
|
|
|
|
* frame tree multiple times in clever ways. However, reifying the display list
|
|
|
|
* reduces code complexity and reduces the number of times each frame must be
|
|
|
|
* traversed to one, which seems to be good for performance. It also means
|
|
|
|
* we can share code for painting, event handling and scroll analysis.
|
|
|
|
*
|
|
|
|
* Display lists are short-lived; content and frame trees cannot change
|
|
|
|
* between a display list being created and destroyed. Display lists should
|
|
|
|
* not be created during reflow because the frame tree may be in an
|
|
|
|
* inconsistent state (e.g., a frame's stored overflow-area may not include
|
|
|
|
* the bounds of all its children). However, it should be fine to create
|
|
|
|
* a display list while a reflow is pending, before it starts.
|
|
|
|
*
|
|
|
|
* A display list covers the "extended" frame tree; the display list for a frame
|
|
|
|
* tree containing FRAME/IFRAME elements can include frames from the subdocuments.
|
|
|
|
*/
|
|
|
|
|
2010-07-16 01:07:49 +04:00
|
|
|
// All types are defined in nsDisplayItemTypes.h
|
2006-01-26 05:29:17 +03:00
|
|
|
#ifdef NS_DEBUG
|
2010-07-16 01:07:49 +04:00
|
|
|
#define NS_DISPLAY_DECL_NAME(n, e) \
|
|
|
|
virtual const char* Name() { return n; } \
|
|
|
|
virtual Type GetType() { return e; }
|
2006-01-26 05:29:17 +03:00
|
|
|
#else
|
2010-07-16 01:07:49 +04:00
|
|
|
#define NS_DISPLAY_DECL_NAME(n, e) \
|
|
|
|
virtual Type GetType() { return e; }
|
2006-01-26 05:29:17 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This manages a display list and is passed as a parameter to
|
|
|
|
* nsIFrame::BuildDisplayList.
|
|
|
|
* It contains the parameters that don't change from frame to frame and manages
|
|
|
|
* the display list memory using a PLArena. It also establishes the reference
|
|
|
|
* coordinate system for all display list items. Some of the parameters are
|
|
|
|
* available from the prescontext/presshell, but we copy them into the builder
|
|
|
|
* for faster/more convenient access.
|
|
|
|
*/
|
2010-06-21 20:21:41 +04:00
|
|
|
class nsDisplayListBuilder {
|
2006-01-26 05:29:17 +03:00
|
|
|
public:
|
2010-03-29 05:46:55 +04:00
|
|
|
typedef mozilla::FramePropertyDescriptor FramePropertyDescriptor;
|
2010-05-21 07:20:48 +04:00
|
|
|
typedef mozilla::FrameLayerBuilder FrameLayerBuilder;
|
2010-03-29 05:46:55 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @param aReferenceFrame the frame at the root of the subtree; its origin
|
|
|
|
* is the origin of the reference coordinate system for this display list
|
|
|
|
* @param aIsForEvents PR_TRUE if we're creating this list in order to
|
|
|
|
* determine which frame is under the mouse position
|
2006-04-18 03:16:46 +04:00
|
|
|
* @param aBuildCaret whether or not we should include the caret in any
|
|
|
|
* display lists that we make.
|
2006-01-26 05:29:17 +03:00
|
|
|
*/
|
|
|
|
nsDisplayListBuilder(nsIFrame* aReferenceFrame, PRBool aIsForEvents,
|
2008-04-11 07:46:37 +04:00
|
|
|
PRBool aBuildCaret);
|
2006-01-26 05:29:17 +03:00
|
|
|
~nsDisplayListBuilder();
|
2007-03-19 06:25:05 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return PR_TRUE if the display is being built in order to determine which
|
|
|
|
* frame is under the mouse position.
|
|
|
|
*/
|
|
|
|
PRBool IsForEventDelivery() { return mEventDelivery; }
|
|
|
|
/**
|
|
|
|
* @return PR_TRUE if "painting is suppressed" during page load and we
|
|
|
|
* should paint only the background of the document.
|
|
|
|
*/
|
|
|
|
PRBool IsBackgroundOnly() { return mIsBackgroundOnly; }
|
2008-08-18 23:09:17 +04:00
|
|
|
/**
|
|
|
|
* Set to PR_TRUE if painting should be suppressed during page load.
|
|
|
|
* Set to PR_FALSE if painting should not be suppressed.
|
|
|
|
*/
|
|
|
|
void SetBackgroundOnly(PRBool aIsBackgroundOnly) { mIsBackgroundOnly = aIsBackgroundOnly; }
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return PR_TRUE if the currently active BuildDisplayList call is being
|
2007-10-19 21:41:29 +04:00
|
|
|
* applied to a frame at the root of a pseudo stacking context. A pseudo
|
2006-01-26 05:29:17 +03:00
|
|
|
* stacking context is either a real stacking context or basically what
|
|
|
|
* CSS2.1 appendix E refers to with "treat the element as if it created
|
|
|
|
* a new stacking context
|
|
|
|
*/
|
|
|
|
PRBool IsAtRootOfPseudoStackingContext() { return mIsAtRootOfPseudoStackingContext; }
|
2008-04-11 07:46:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate that we'll use this display list to analyze the effects
|
|
|
|
* of aMovingFrame moving by aMoveDelta. The move has already been
|
2009-07-04 13:30:59 +04:00
|
|
|
* applied to the frame tree. Moving frames are not allowed to clip or
|
2009-09-07 04:35:14 +04:00
|
|
|
* cover (during ComputeVisibility) non-moving frames. E.g. when we're
|
2009-07-04 13:30:59 +04:00
|
|
|
* constructing a display list to see what should be repainted during a
|
|
|
|
* scroll operation, we specify the scrolled frame as the moving frame.
|
2009-08-14 06:09:51 +04:00
|
|
|
* @param aSaveVisibleRegionOfMovingContent if non-null,
|
|
|
|
* this receives a bounding region for the visible moving content
|
|
|
|
* (considering the moving content both before and after the move)
|
2008-04-11 07:46:37 +04:00
|
|
|
*/
|
2009-08-14 06:09:51 +04:00
|
|
|
void SetMovingFrame(nsIFrame* aMovingFrame, const nsPoint& aMoveDelta,
|
|
|
|
nsRegion* aSaveVisibleRegionOfMovingContent) {
|
2008-04-11 07:46:37 +04:00
|
|
|
mMovingFrame = aMovingFrame;
|
|
|
|
mMoveDelta = aMoveDelta;
|
2009-08-14 06:09:51 +04:00
|
|
|
mSaveVisibleRegionOfMovingContent = aSaveVisibleRegionOfMovingContent;
|
2008-04-11 07:46:37 +04:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return PR_TRUE if we are doing analysis of moving frames
|
|
|
|
*/
|
|
|
|
PRBool HasMovingFrames() { return mMovingFrame != nsnull; }
|
|
|
|
/**
|
2008-04-11 07:46:37 +04:00
|
|
|
* @return the frame that was moved
|
2006-01-26 05:29:17 +03:00
|
|
|
*/
|
|
|
|
nsIFrame* GetRootMovingFrame() { return mMovingFrame; }
|
2008-04-11 07:46:37 +04:00
|
|
|
/**
|
|
|
|
* @return the amount by which mMovingFrame was moved.
|
|
|
|
* Only valid when GetRootMovingFrame() returns non-null.
|
|
|
|
*/
|
|
|
|
const nsPoint& GetMoveDelta() { return mMoveDelta; }
|
2009-08-14 06:09:51 +04:00
|
|
|
/**
|
|
|
|
* Given the bounds of some moving content, and a visible region,
|
|
|
|
* intersect the bounds with the visible region and add it to the
|
|
|
|
* recorded region of visible moving content.
|
|
|
|
*/
|
|
|
|
void AccumulateVisibleRegionOfMovingContent(const nsRegion& aMovingContent,
|
2009-10-07 08:28:41 +04:00
|
|
|
const nsRegion& aVisibleRegionBeforeMove,
|
|
|
|
const nsRegion& aVisibleRegionAfterMove);
|
2009-08-14 06:09:51 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return PR_TRUE if aFrame is, or is a descendant of, the hypothetical
|
|
|
|
* moving frame
|
|
|
|
*/
|
2009-07-22 04:44:57 +04:00
|
|
|
PRBool IsMovingFrame(nsIFrame* aFrame);
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return the selection that painting should be restricted to (or nsnull
|
|
|
|
* in the normal unrestricted case)
|
|
|
|
*/
|
|
|
|
nsISelection* GetBoundingSelection() { return mBoundingSelection; }
|
|
|
|
/**
|
|
|
|
* @return the root of the display list's frame (sub)tree, whose origin
|
|
|
|
* establishes the coordinate system for the display list
|
|
|
|
*/
|
|
|
|
nsIFrame* ReferenceFrame() { return mReferenceFrame; }
|
|
|
|
/**
|
|
|
|
* @return a point pt such that adding pt to a coordinate relative to aFrame
|
|
|
|
* makes it relative to ReferenceFrame(), i.e., returns
|
|
|
|
* aFrame->GetOffsetTo(ReferenceFrame()). It may be optimized to be faster
|
|
|
|
* than aFrame->GetOffsetTo(ReferenceFrame()) (but currently isn't).
|
|
|
|
*/
|
2008-09-13 13:42:11 +04:00
|
|
|
nsPoint ToReferenceFrame(const nsIFrame* aFrame) {
|
2006-01-26 05:29:17 +03:00
|
|
|
return aFrame->GetOffsetTo(ReferenceFrame());
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* When building the display list, the scrollframe aFrame will be "ignored"
|
|
|
|
* for the purposes of clipping, and its scrollbars will be hidden. We use
|
|
|
|
* this to allow RenderOffscreen to render a whole document without beign
|
|
|
|
* clipped by the viewport or drawing the viewport scrollbars.
|
|
|
|
*/
|
|
|
|
void SetIgnoreScrollFrame(nsIFrame* aFrame) { mIgnoreScrollFrame = aFrame; }
|
|
|
|
/**
|
|
|
|
* Get the scrollframe to ignore, if any.
|
|
|
|
*/
|
|
|
|
nsIFrame* GetIgnoreScrollFrame() { return mIgnoreScrollFrame; }
|
2007-03-19 06:25:05 +03:00
|
|
|
/**
|
2010-07-13 00:24:33 +04:00
|
|
|
* Calling this setter makes us:
|
|
|
|
* 1. include all positioned descendant frames in the display list,
|
|
|
|
* wherever they may be positioned (even outside the dirty rects).
|
|
|
|
* 2. exclude all leaf frames that does not have the NS_FRAME_SELECTED_CONTENT
|
|
|
|
* bit.
|
2007-03-19 06:25:05 +03:00
|
|
|
*/
|
2010-07-13 00:24:33 +04:00
|
|
|
void SetSelectedFramesOnly() { mSelectedFramesOnly = PR_TRUE; }
|
|
|
|
PRBool GetSelectedFramesOnly() { return mSelectedFramesOnly; }
|
2009-07-22 04:44:56 +04:00
|
|
|
/**
|
|
|
|
* Calling this setter makes us compute accurate visible regions at the cost
|
|
|
|
* of performance if regions get very complex.
|
|
|
|
*/
|
|
|
|
void SetAccurateVisibleRegions() { mAccurateVisibleRegions = PR_TRUE; }
|
|
|
|
PRBool GetAccurateVisibleRegions() { return mAccurateVisibleRegions; }
|
2007-08-30 00:38:44 +04:00
|
|
|
/**
|
|
|
|
* Allows callers to selectively override the regular paint suppression checks,
|
|
|
|
* so that methods like GetFrameForPoint work when painting is suppressed.
|
|
|
|
*/
|
|
|
|
void IgnorePaintSuppression() { mIsBackgroundOnly = PR_FALSE; }
|
2010-05-13 04:56:08 +04:00
|
|
|
/**
|
|
|
|
* Call this if we're doing normal painting to the window.
|
|
|
|
*/
|
|
|
|
void SetPaintingToWindow(PRBool aToWindow) { mIsPaintingToWindow = aToWindow; }
|
2006-04-18 03:16:46 +04:00
|
|
|
/**
|
|
|
|
* Display the caret if needed.
|
|
|
|
*/
|
|
|
|
nsresult DisplayCaret(nsIFrame* aFrame, const nsRect& aDirtyRect,
|
2010-03-27 07:33:17 +03:00
|
|
|
nsDisplayList* aList) {
|
2006-04-18 03:16:46 +04:00
|
|
|
nsIFrame* frame = GetCaretFrame();
|
|
|
|
if (aFrame != frame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-03-27 07:33:17 +03:00
|
|
|
return frame->DisplayCaret(this, aDirtyRect, aList);
|
2006-04-18 03:16:46 +04:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get the frame that the caret is supposed to draw in.
|
|
|
|
* If the caret is currently invisible, this will be null.
|
|
|
|
*/
|
|
|
|
nsIFrame* GetCaretFrame() {
|
2008-01-04 04:53:01 +03:00
|
|
|
return CurrentPresShellState()->mCaretFrame;
|
2006-04-18 03:16:46 +04:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get the caret associated with the current presshell.
|
|
|
|
*/
|
2008-07-16 14:52:01 +04:00
|
|
|
nsCaret* GetCaret();
|
2006-04-18 03:16:46 +04:00
|
|
|
/**
|
|
|
|
* Notify the display list builder that we're entering a presshell.
|
|
|
|
* aReferenceFrame should be a frame in the new presshell and aDirtyRect
|
|
|
|
* should be the current dirty rect in aReferenceFrame's coordinate space.
|
|
|
|
*/
|
|
|
|
void EnterPresShell(nsIFrame* aReferenceFrame, const nsRect& aDirtyRect);
|
|
|
|
/**
|
|
|
|
* Notify the display list builder that we're leaving a presshell.
|
|
|
|
*/
|
|
|
|
void LeavePresShell(nsIFrame* aReferenceFrame, const nsRect& aDirtyRect);
|
2009-07-22 04:45:14 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if we're currently building a display list that's
|
|
|
|
* directly or indirectly under an nsDisplayTransform or SVG
|
|
|
|
* foreignObject.
|
|
|
|
*/
|
|
|
|
PRBool IsInTransform() { return mInTransform; }
|
|
|
|
/**
|
|
|
|
* Indicate whether or not we're directly or indirectly under and
|
|
|
|
* nsDisplayTransform or SVG foreignObject.
|
|
|
|
*/
|
|
|
|
void SetInTransform(PRBool aInTransform) { mInTransform = aInTransform; }
|
|
|
|
|
2009-09-13 02:44:18 +04:00
|
|
|
/**
|
|
|
|
* @return PR_TRUE if images have been set to decode synchronously.
|
|
|
|
*/
|
|
|
|
PRBool ShouldSyncDecodeImages() { return mSyncDecodeImages; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether we should synchronously decode images. If true, we decode
|
|
|
|
* and draw whatever image data has been loaded. If false, we just draw
|
|
|
|
* whatever has already been decoded.
|
|
|
|
*/
|
|
|
|
void SetSyncDecodeImages(PRBool aSyncDecodeImages) {
|
|
|
|
mSyncDecodeImages = aSyncDecodeImages;
|
|
|
|
}
|
|
|
|
|
2009-09-13 02:44:18 +04:00
|
|
|
/**
|
|
|
|
* Helper method to generate background painting flags based on the
|
|
|
|
* information available in the display list builder. Currently only
|
|
|
|
* accounts for mSyncDecodeImages.
|
|
|
|
*/
|
|
|
|
PRUint32 GetBackgroundPaintFlags();
|
|
|
|
|
2009-08-14 06:09:51 +04:00
|
|
|
/**
|
|
|
|
* Subtracts aRegion from *aVisibleRegion. We avoid letting
|
|
|
|
* aVisibleRegion become overcomplex by simplifying it if necessary ---
|
|
|
|
* unless mAccurateVisibleRegions is set, in which case we let it
|
|
|
|
* get arbitrarily complex.
|
|
|
|
*/
|
|
|
|
void SubtractFromVisibleRegion(nsRegion* aVisibleRegion,
|
|
|
|
const nsRegion& aRegion);
|
|
|
|
|
2006-04-27 06:45:03 +04:00
|
|
|
/**
|
2009-07-28 16:51:09 +04:00
|
|
|
* Mark the frames in aFrames to be displayed if they intersect aDirtyRect
|
|
|
|
* (which is relative to aDirtyFrame). If the frames have placeholders
|
|
|
|
* that might not be displayed, we mark the placeholders and their ancestors
|
|
|
|
* to ensure that display list construction descends into them
|
|
|
|
* anyway. nsDisplayListBuilder will take care of unmarking them when it is
|
|
|
|
* destroyed.
|
2006-04-27 06:45:03 +04:00
|
|
|
*/
|
2009-07-28 16:51:09 +04:00
|
|
|
void MarkFramesForDisplayList(nsIFrame* aDirtyFrame,
|
|
|
|
const nsFrameList& aFrames,
|
2006-04-27 06:45:03 +04:00
|
|
|
const nsRect& aDirtyRect);
|
2010-05-21 07:20:48 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the FrameLayerBuilder.
|
|
|
|
*/
|
|
|
|
FrameLayerBuilder* LayerBuilder() { return &mLayerBuilder; }
|
2006-04-27 06:45:03 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Allocate memory in our arena. It will only be freed when this display list
|
|
|
|
* builder is destroyed. This memory holds nsDisplayItems. nsDisplayItem
|
|
|
|
* destructors are called as soon as the item is no longer used.
|
|
|
|
*/
|
|
|
|
void* Allocate(size_t aSize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A helper class to temporarily set the value of
|
|
|
|
* mIsAtRootOfPseudoStackingContext.
|
|
|
|
*/
|
|
|
|
class AutoIsRootSetter;
|
2006-01-26 06:33:38 +03:00
|
|
|
friend class AutoIsRootSetter;
|
2006-01-26 05:29:17 +03:00
|
|
|
class AutoIsRootSetter {
|
|
|
|
public:
|
|
|
|
AutoIsRootSetter(nsDisplayListBuilder* aBuilder, PRBool aIsRoot)
|
|
|
|
: mBuilder(aBuilder), mOldValue(aBuilder->mIsAtRootOfPseudoStackingContext) {
|
|
|
|
aBuilder->mIsAtRootOfPseudoStackingContext = aIsRoot;
|
|
|
|
}
|
|
|
|
~AutoIsRootSetter() {
|
|
|
|
mBuilder->mIsAtRootOfPseudoStackingContext = mOldValue;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsDisplayListBuilder* mBuilder;
|
|
|
|
PRPackedBool mOldValue;
|
|
|
|
};
|
2009-07-22 04:45:14 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A helper class to temporarily set the value of mInTransform.
|
|
|
|
*/
|
|
|
|
class AutoInTransformSetter;
|
|
|
|
friend class AutoInTransformSetter;
|
|
|
|
class AutoInTransformSetter {
|
|
|
|
public:
|
|
|
|
AutoInTransformSetter(nsDisplayListBuilder* aBuilder, PRBool aInTransform)
|
|
|
|
: mBuilder(aBuilder), mOldValue(aBuilder->mInTransform) {
|
|
|
|
aBuilder->mInTransform = aInTransform;
|
|
|
|
}
|
|
|
|
~AutoInTransformSetter() {
|
|
|
|
mBuilder->mInTransform = mOldValue;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsDisplayListBuilder* mBuilder;
|
|
|
|
PRPackedBool mOldValue;
|
|
|
|
};
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2008-04-06 15:34:14 +04:00
|
|
|
// Helpers for tables
|
|
|
|
nsDisplayTableItem* GetCurrentTableItem() { return mCurrentTableItem; }
|
|
|
|
void SetCurrentTableItem(nsDisplayTableItem* aTableItem) { mCurrentTableItem = aTableItem; }
|
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(OutOfFlowDirtyRectProperty, nsIFrame::DestroyRect)
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
2008-01-04 04:53:01 +03:00
|
|
|
struct PresShellState {
|
|
|
|
nsIPresShell* mPresShell;
|
|
|
|
nsIFrame* mCaretFrame;
|
|
|
|
PRUint32 mFirstFrameMarkedForDisplay;
|
|
|
|
};
|
|
|
|
PresShellState* CurrentPresShellState() {
|
|
|
|
NS_ASSERTION(mPresShellStates.Length() > 0,
|
|
|
|
"Someone forgot to enter a presshell");
|
|
|
|
return &mPresShellStates[mPresShellStates.Length() - 1];
|
|
|
|
}
|
2010-05-21 07:20:48 +04:00
|
|
|
|
|
|
|
FrameLayerBuilder mLayerBuilder;
|
2008-01-04 04:53:01 +03:00
|
|
|
nsIFrame* mReferenceFrame;
|
|
|
|
nsIFrame* mMovingFrame;
|
2009-08-14 06:09:51 +04:00
|
|
|
nsRegion* mSaveVisibleRegionOfMovingContent;
|
2008-01-04 04:53:01 +03:00
|
|
|
nsIFrame* mIgnoreScrollFrame;
|
2008-04-11 07:46:37 +04:00
|
|
|
nsPoint mMoveDelta; // only valid when mMovingFrame is non-null
|
2008-01-04 04:53:01 +03:00
|
|
|
PLArenaPool mPool;
|
|
|
|
nsCOMPtr<nsISelection> mBoundingSelection;
|
|
|
|
nsAutoTArray<PresShellState,8> mPresShellStates;
|
|
|
|
nsAutoTArray<nsIFrame*,100> mFramesMarkedForDisplay;
|
2008-04-06 15:34:14 +04:00
|
|
|
nsDisplayTableItem* mCurrentTableItem;
|
2008-01-04 04:53:01 +03:00
|
|
|
PRPackedBool mBuildCaret;
|
|
|
|
PRPackedBool mEventDelivery;
|
|
|
|
PRPackedBool mIsBackgroundOnly;
|
|
|
|
PRPackedBool mIsAtRootOfPseudoStackingContext;
|
2010-07-13 00:24:33 +04:00
|
|
|
PRPackedBool mSelectedFramesOnly;
|
2009-07-22 04:44:56 +04:00
|
|
|
PRPackedBool mAccurateVisibleRegions;
|
2009-07-22 04:45:14 +04:00
|
|
|
// True when we're building a display list that's directly or indirectly
|
|
|
|
// under an nsDisplayTransform
|
|
|
|
PRPackedBool mInTransform;
|
2009-09-13 02:44:18 +04:00
|
|
|
PRPackedBool mSyncDecodeImages;
|
2010-05-13 04:56:08 +04:00
|
|
|
PRPackedBool mIsPaintingToWindow;
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsDisplayItem;
|
|
|
|
class nsDisplayList;
|
|
|
|
/**
|
|
|
|
* nsDisplayItems are put in singly-linked lists rooted in an nsDisplayList.
|
|
|
|
* nsDisplayItemLink holds the link. The lists are linked from lowest to
|
|
|
|
* highest in z-order.
|
|
|
|
*/
|
|
|
|
class nsDisplayItemLink {
|
2006-01-29 21:48:58 +03:00
|
|
|
// This is never instantiated directly, so no need to count constructors and
|
|
|
|
// destructors.
|
2006-01-26 05:29:17 +03:00
|
|
|
protected:
|
2006-03-14 23:43:18 +03:00
|
|
|
nsDisplayItemLink() : mAbove(nsnull) {}
|
2006-01-26 05:29:17 +03:00
|
|
|
nsDisplayItem* mAbove;
|
|
|
|
|
|
|
|
friend class nsDisplayList;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the unit of rendering and event testing. Each instance of this
|
|
|
|
* class represents an entity that can be drawn on the screen, e.g., a
|
|
|
|
* frame's CSS background, or a frame's text string.
|
|
|
|
*
|
|
|
|
* nsDisplayListItems can be containers --- i.e., they can perform hit testing
|
|
|
|
* and painting by recursively traversing a list of child items.
|
|
|
|
*
|
|
|
|
* These are arena-allocated during display list construction. A typical
|
|
|
|
* subclass would just have a frame pointer, so its object would be just three
|
|
|
|
* pointers (vtable, next-item, frame).
|
|
|
|
*
|
|
|
|
* Display items belong to a list at all times (except temporarily as they
|
|
|
|
* move from one list to another).
|
|
|
|
*/
|
|
|
|
class nsDisplayItem : public nsDisplayItemLink {
|
|
|
|
public:
|
2010-03-01 10:56:19 +03:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
|
2006-01-29 21:48:58 +03:00
|
|
|
// This is never instantiated directly (it has pure virtual methods), so no
|
|
|
|
// need to count constructors and destructors.
|
2006-03-14 23:43:18 +03:00
|
|
|
nsDisplayItem(nsIFrame* aFrame) : mFrame(aFrame) {}
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual ~nsDisplayItem() {}
|
|
|
|
|
2006-01-29 21:48:58 +03:00
|
|
|
void* operator new(size_t aSize,
|
|
|
|
nsDisplayListBuilder* aBuilder) CPP_THROW_NEW {
|
2006-01-26 05:29:17 +03:00
|
|
|
return aBuilder->Allocate(aSize);
|
|
|
|
}
|
|
|
|
|
2010-07-16 01:07:49 +04:00
|
|
|
// Contains all the type integers for each display list item type
|
|
|
|
#include "nsDisplayItemTypes.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2008-01-04 05:08:29 +03:00
|
|
|
struct HitTestState {
|
|
|
|
~HitTestState() {
|
|
|
|
NS_ASSERTION(mItemBuffer.Length() == 0,
|
|
|
|
"mItemBuffer should have been cleared");
|
|
|
|
}
|
|
|
|
nsAutoTArray<nsDisplayItem*, 100> mItemBuffer;
|
|
|
|
};
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Some consecutive items should be rendered together as a unit, e.g.,
|
|
|
|
* outlines for the same element. For this, we need a way for items to
|
|
|
|
* identify their type.
|
|
|
|
*/
|
2010-07-16 01:07:49 +04:00
|
|
|
virtual Type GetType() = 0;
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* This is called after we've constructed a display list for event handling.
|
2010-06-06 00:29:49 +04:00
|
|
|
* When this is called, we've already ensured that aRect intersects the
|
|
|
|
* item's bounds.
|
2006-01-26 05:29:17 +03:00
|
|
|
*
|
2008-01-04 05:08:29 +03:00
|
|
|
* @param aState must point to a HitTestState. If you don't have one,
|
|
|
|
* just create one with the default constructor and pass it in.
|
2010-06-06 00:29:49 +04:00
|
|
|
* @param aOutFrames each item appends the frame(s) in this display item that
|
|
|
|
* the rect is considered over (if any) to aOutFrames.
|
2006-01-26 05:29:17 +03:00
|
|
|
*/
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) {}
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return the frame that this display item is based on. This is used to sort
|
|
|
|
* items by z-index and content order and for some other uses. For some items
|
|
|
|
* that wrap item lists, this could return nsnull because there is no single
|
|
|
|
* underlying frame; for leaf items it will never return nsnull.
|
|
|
|
*/
|
2006-03-14 23:43:18 +03:00
|
|
|
inline nsIFrame* GetUnderlyingFrame() { return mFrame; }
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* The default bounds is the frame border rect.
|
|
|
|
* @return a rectangle relative to aBuilder->ReferenceFrame() that
|
|
|
|
* contains the area drawn by this display item
|
|
|
|
*/
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder) {
|
|
|
|
nsIFrame* f = GetUnderlyingFrame();
|
|
|
|
return nsRect(aBuilder->ToReferenceFrame(f), f->GetSize());
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return PR_TRUE if the item is definitely opaque --- i.e., paints
|
|
|
|
* every pixel within its bounds opaquely
|
|
|
|
*/
|
|
|
|
virtual PRBool IsOpaque(nsDisplayListBuilder* aBuilder) { return PR_FALSE; }
|
|
|
|
/**
|
2010-05-13 04:56:11 +04:00
|
|
|
* If this returns true, then aColor is set to the uniform color
|
2006-01-26 05:29:17 +03:00
|
|
|
* @return PR_TRUE if the item is guaranteed to paint every pixel in its
|
|
|
|
* bounds with the same (possibly translucent) color
|
|
|
|
*/
|
2010-05-13 04:56:11 +04:00
|
|
|
virtual PRBool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) { return PR_FALSE; }
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return PR_FALSE if the painting performed by the item is invariant
|
2008-04-11 07:46:37 +04:00
|
|
|
* when frame aFrame is moved relative to aBuilder->GetRootMovingFrame().
|
|
|
|
* This can only be called when aBuilder->IsMovingFrame(mFrame) is true.
|
|
|
|
* It return PR_TRUE for all wrapped lists.
|
2006-01-26 05:29:17 +03:00
|
|
|
*/
|
2008-04-11 07:46:37 +04:00
|
|
|
virtual PRBool IsVaryingRelativeToMovingFrame(nsDisplayListBuilder* aBuilder)
|
|
|
|
{ return PR_FALSE; }
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Actually paint this item to some rendering context.
|
2009-09-07 04:35:14 +04:00
|
|
|
* Content outside mVisibleRect need not be painted.
|
2010-03-01 11:03:49 +03:00
|
|
|
* aCtx must be set up as for nsDisplayList::Paint.
|
2006-01-26 05:29:17 +03:00
|
|
|
*/
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx) {}
|
2010-03-01 10:56:19 +03:00
|
|
|
/**
|
|
|
|
* Get the layer drawn by this display item, if any. If this display
|
|
|
|
* item doesn't have its own layer, then Paint will be called on it
|
|
|
|
* later. If it returns a layer here then Paint will not be called.
|
|
|
|
* This is called while aManager is in the construction phase.
|
|
|
|
* This is where content can decide to be rendered by the layer
|
|
|
|
* system (with the possibility of accelerated or off-main-thread
|
|
|
|
* rendering) instead of cairo.
|
|
|
|
*
|
|
|
|
* The caller (nsDisplayList) is responsible for setting the visible
|
|
|
|
* region of the layer.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager)
|
|
|
|
{ return nsnull; }
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* On entry, aVisibleRegion contains the region (relative to ReferenceFrame())
|
|
|
|
* which may be visible. If the display item opaquely covers an area, it
|
|
|
|
* can remove that area from aVisibleRegion before returning.
|
2009-10-07 08:28:41 +04:00
|
|
|
* If we're doing scroll analysis with moving frames, then
|
|
|
|
* aVisibleRegionBeforeMove will be non-null and contains the region that
|
|
|
|
* would have been visible before the move. aVisibleRegion contains the
|
|
|
|
* region that is visible after the move.
|
2009-09-07 04:35:14 +04:00
|
|
|
* nsDisplayList::ComputeVisibility automatically subtracts the bounds
|
|
|
|
* of items that return true from IsOpaque(), and automatically
|
|
|
|
* removes items whose bounds do not intersect the visible area,
|
|
|
|
* so implementations of nsDisplayItem::ComputeVisibility do not
|
|
|
|
* need to do these things.
|
|
|
|
* nsDisplayList::ComputeVisibility will already have set mVisibleRect on
|
2009-10-07 08:28:41 +04:00
|
|
|
* this item to the intersection of *aVisibleRegion (unioned with
|
|
|
|
* *aVisibleRegionBeforeMove, if that's non-null) and this item's bounds.
|
2009-09-07 04:35:14 +04:00
|
|
|
*
|
2006-01-26 05:29:17 +03:00
|
|
|
* @return PR_TRUE if the item is visible, PR_FALSE if no part of the item
|
|
|
|
* is visible
|
|
|
|
*/
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2009-10-07 08:28:41 +04:00
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove)
|
|
|
|
{ return PR_TRUE; }
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Try to merge with the other item (which is below us in the display
|
|
|
|
* list). This gets used by nsDisplayClip to coalesce clipping operations
|
|
|
|
* (optimization), by nsDisplayOpacity to merge rendering for the same
|
|
|
|
* content element into a single opacity group (correctness), and will be
|
|
|
|
* used by nsDisplayOutline to merge multiple outlines for the same element
|
|
|
|
* (also for correctness).
|
|
|
|
* @return PR_TRUE if the merge was successful and the other item should be deleted
|
|
|
|
*/
|
|
|
|
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If this is a leaf item we return null, otherwise we return the wrapped
|
|
|
|
* list.
|
|
|
|
*/
|
|
|
|
virtual nsDisplayList* GetList() { return nsnull; }
|
2010-05-13 04:56:11 +04:00
|
|
|
|
2010-05-21 07:20:48 +04:00
|
|
|
/**
|
|
|
|
* Returns the visible rect. Should only be called after ComputeVisibility
|
|
|
|
* has happened.
|
|
|
|
*/
|
2010-05-13 04:56:11 +04:00
|
|
|
const nsRect& GetVisibleRect() { return mVisibleRect; }
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
/**
|
|
|
|
* For debugging and stuff
|
|
|
|
*/
|
|
|
|
virtual const char* Name() = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsDisplayItem* GetAbove() { return mAbove; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class nsDisplayList;
|
|
|
|
|
|
|
|
nsDisplayItem() {
|
|
|
|
mAbove = nsnull;
|
|
|
|
}
|
|
|
|
|
2006-03-14 23:43:18 +03:00
|
|
|
nsIFrame* mFrame;
|
2009-09-07 04:35:14 +04:00
|
|
|
// This is the rectangle that needs to be painted.
|
|
|
|
// nsDisplayList::ComputeVisibility sets this to the visible region
|
|
|
|
// of the item by intersecting the current visible region with the bounds
|
|
|
|
// of the item. Paint implementations can use this to limit their drawing.
|
|
|
|
// Guaranteed to be contained in GetBounds().
|
|
|
|
nsRect mVisibleRect;
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manages a singly-linked list of display list items.
|
|
|
|
*
|
|
|
|
* mSentinel is the sentinel list value, the first value in the null-terminated
|
|
|
|
* linked list of items. mTop is the last item in the list (whose 'above'
|
|
|
|
* pointer is null). This class has no virtual methods. So list objects are just
|
|
|
|
* two pointers.
|
|
|
|
*
|
|
|
|
* Stepping upward through this list is very fast. Stepping downward is very
|
|
|
|
* slow so we don't support it. The methods that need to step downward
|
2009-09-07 04:35:14 +04:00
|
|
|
* (HitTest(), ComputeVisibility()) internally build a temporary array of all
|
2006-01-26 05:29:17 +03:00
|
|
|
* the items while they do the downward traversal, so overall they're still
|
|
|
|
* linear time. We have optimized for efficient AppendToTop() of both
|
|
|
|
* items and lists, with minimal codesize. AppendToBottom() is efficient too.
|
|
|
|
*/
|
|
|
|
class nsDisplayList {
|
|
|
|
public:
|
2010-03-01 10:56:19 +03:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
typedef mozilla::layers::ThebesLayer ThebesLayer;
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Create an empty list.
|
|
|
|
*/
|
2010-03-01 10:56:19 +03:00
|
|
|
nsDisplayList() :
|
|
|
|
mIsOpaque(PR_FALSE)
|
|
|
|
{
|
2009-09-07 04:35:14 +04:00
|
|
|
mTop = &mSentinel;
|
|
|
|
mSentinel.mAbove = nsnull;
|
|
|
|
#ifdef DEBUG
|
|
|
|
mDidComputeVisibility = PR_FALSE;
|
|
|
|
#endif
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
~nsDisplayList() {
|
|
|
|
if (mSentinel.mAbove) {
|
|
|
|
NS_WARNING("Nonempty list left over?");
|
|
|
|
}
|
|
|
|
DeleteAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append an item to the top of the list. The item must not currently
|
|
|
|
* be in a list and cannot be null.
|
|
|
|
*/
|
|
|
|
void AppendToTop(nsDisplayItem* aItem) {
|
|
|
|
NS_ASSERTION(aItem, "No item to append!");
|
|
|
|
NS_ASSERTION(!aItem->mAbove, "Already in a list!");
|
|
|
|
mTop->mAbove = aItem;
|
|
|
|
mTop = aItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append a new item to the top of the list. If the item is null we return
|
|
|
|
* NS_ERROR_OUT_OF_MEMORY. The intended usage is AppendNewToTop(new ...);
|
|
|
|
*/
|
|
|
|
nsresult AppendNewToTop(nsDisplayItem* aItem) {
|
|
|
|
if (!aItem)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
AppendToTop(aItem);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-06 23:38:47 +03:00
|
|
|
/**
|
|
|
|
* Append a new item to the bottom of the list. If the item is null we return
|
|
|
|
* NS_ERROR_OUT_OF_MEMORY. The intended usage is AppendNewToBottom(new ...);
|
|
|
|
*/
|
|
|
|
nsresult AppendNewToBottom(nsDisplayItem* aItem) {
|
|
|
|
if (!aItem)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
AppendToBottom(aItem);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Append a new item to the bottom of the list. The item must be non-null
|
|
|
|
* and not already in a list.
|
|
|
|
*/
|
|
|
|
void AppendToBottom(nsDisplayItem* aItem) {
|
|
|
|
NS_ASSERTION(aItem, "No item to append!");
|
|
|
|
NS_ASSERTION(!aItem->mAbove, "Already in a list!");
|
|
|
|
aItem->mAbove = mSentinel.mAbove;
|
|
|
|
mSentinel.mAbove = aItem;
|
|
|
|
if (mTop == &mSentinel) {
|
|
|
|
mTop = aItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all items from aList and appends them to the top of this list
|
|
|
|
*/
|
|
|
|
void AppendToTop(nsDisplayList* aList) {
|
|
|
|
if (aList->mSentinel.mAbove) {
|
|
|
|
mTop->mAbove = aList->mSentinel.mAbove;
|
|
|
|
mTop = aList->mTop;
|
|
|
|
aList->mTop = &aList->mSentinel;
|
|
|
|
aList->mSentinel.mAbove = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all items from aList and prepends them to the bottom of this list
|
|
|
|
*/
|
|
|
|
void AppendToBottom(nsDisplayList* aList) {
|
|
|
|
if (aList->mSentinel.mAbove) {
|
|
|
|
aList->mTop->mAbove = mSentinel.mAbove;
|
|
|
|
mTop = aList->mTop;
|
|
|
|
mSentinel.mAbove = aList->mSentinel.mAbove;
|
|
|
|
|
|
|
|
aList->mTop = &aList->mSentinel;
|
|
|
|
aList->mSentinel.mAbove = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an item from the bottom of the list and return it.
|
|
|
|
*/
|
|
|
|
nsDisplayItem* RemoveBottom();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all items from the list and call their destructors.
|
|
|
|
*/
|
|
|
|
void DeleteAll();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the item at the top of the list, or null if the list is empty
|
|
|
|
*/
|
|
|
|
nsDisplayItem* GetTop() const {
|
2007-07-08 11:08:04 +04:00
|
|
|
return mTop != &mSentinel ? static_cast<nsDisplayItem*>(mTop) : nsnull;
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return the item at the bottom of the list, or null if the list is empty
|
|
|
|
*/
|
|
|
|
nsDisplayItem* GetBottom() const { return mSentinel.mAbove; }
|
|
|
|
PRBool IsEmpty() const { return mTop == &mSentinel; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is *linear time*!
|
|
|
|
* @return the number of items in the list
|
|
|
|
*/
|
|
|
|
PRUint32 Count() const;
|
|
|
|
/**
|
|
|
|
* Stable sort the list by the z-order of GetUnderlyingFrame() on
|
|
|
|
* each item. 'auto' is counted as zero. Content order is used as the
|
|
|
|
* secondary order.
|
|
|
|
* @param aCommonAncestor a common ancestor of all the content elements
|
|
|
|
* associated with the display items, for speeding up tree order
|
|
|
|
* checks, or nsnull if not known; it's only a hint, if it is not an
|
|
|
|
* ancestor of some elements, then we lose performance but not correctness
|
|
|
|
*/
|
|
|
|
void SortByZOrder(nsDisplayListBuilder* aBuilder, nsIContent* aCommonAncestor);
|
|
|
|
/**
|
|
|
|
* Stable sort the list by the tree order of the content of
|
|
|
|
* GetUnderlyingFrame() on each item. z-index is ignored.
|
|
|
|
* @param aCommonAncestor a common ancestor of all the content elements
|
|
|
|
* associated with the display items, for speeding up tree order
|
|
|
|
* checks, or nsnull if not known; it's only a hint, if it is not an
|
|
|
|
* ancestor of some elements, then we lose performance but not correctness
|
|
|
|
*/
|
|
|
|
void SortByContentOrder(nsDisplayListBuilder* aBuilder, nsIContent* aCommonAncestor);
|
|
|
|
|
2006-04-18 02:16:24 +04:00
|
|
|
/**
|
|
|
|
* Generic stable sort. Take care, because some of the items might be nsDisplayLists
|
|
|
|
* themselves.
|
|
|
|
* aCmp(item1, item2) should return true if item1 <= item2. We sort the items
|
|
|
|
* into increasing order.
|
|
|
|
*/
|
|
|
|
typedef PRBool (* SortLEQ)(nsDisplayItem* aItem1, nsDisplayItem* aItem2,
|
|
|
|
void* aClosure);
|
2006-04-27 06:25:23 +04:00
|
|
|
void Sort(nsDisplayListBuilder* aBuilder, SortLEQ aCmp, void* aClosure);
|
2006-04-18 02:16:24 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Optimize the display list for visibility, removing any elements that
|
|
|
|
* are not visible. We put this logic here so it can be shared by top-level
|
|
|
|
* painting and also display items that maintain child lists.
|
2009-09-07 04:35:14 +04:00
|
|
|
* This is also a good place to put ComputeVisibility-related logic
|
|
|
|
* that must be applied to every display item. In particular, this
|
|
|
|
* sets mVisibleRect on each display item.
|
2010-03-01 10:56:19 +03:00
|
|
|
* This also sets mIsOpaque to whether aVisibleRegion is empty on return.
|
2006-01-26 05:29:17 +03:00
|
|
|
*
|
|
|
|
* @param aVisibleRegion the area that is visible, relative to the
|
|
|
|
* reference frame; on return, this contains the area visible under the list
|
|
|
|
*/
|
2009-10-07 08:28:41 +04:00
|
|
|
void ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2010-03-01 10:56:19 +03:00
|
|
|
/**
|
|
|
|
* Returns true if the visible region output from ComputeVisiblity was
|
|
|
|
* empty, i.e. everything visible in this list is opaque.
|
|
|
|
*/
|
|
|
|
PRBool IsOpaque() const {
|
|
|
|
NS_ASSERTION(mDidComputeVisibility, "Need to have called ComputeVisibility");
|
|
|
|
return mIsOpaque;
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Paint the list to the rendering context. We assume that (0,0) in aCtx
|
2008-02-25 04:39:34 +03:00
|
|
|
* corresponds to the origin of the reference frame. For best results,
|
|
|
|
* aCtx's current transform should make (0,0) pixel-aligned. The
|
|
|
|
* rectangle in aDirtyRect is painted, which *must* be contained in the
|
|
|
|
* dirty rect used to construct the display list.
|
2009-09-07 04:35:14 +04:00
|
|
|
*
|
2010-03-01 11:03:49 +03:00
|
|
|
* If aFlags contains PAINT_USE_WIDGET_LAYERS and
|
|
|
|
* ShouldUseWidgetLayerManager() is set, then we will paint using
|
|
|
|
* the reference frame's widget's layer manager (and ctx may be null),
|
|
|
|
* otherwise we will use a temporary BasicLayerManager and ctx must
|
|
|
|
* not be null.
|
|
|
|
*
|
2009-09-07 04:35:14 +04:00
|
|
|
* ComputeVisibility must be called before Paint.
|
2010-03-10 23:55:05 +03:00
|
|
|
*
|
|
|
|
* This must only be called on the root display list of the display list
|
|
|
|
* tree.
|
2006-01-26 05:29:17 +03:00
|
|
|
*/
|
2010-03-01 11:03:49 +03:00
|
|
|
enum {
|
|
|
|
PAINT_DEFAULT = 0,
|
|
|
|
PAINT_USE_WIDGET_LAYERS = 0x01
|
|
|
|
};
|
2010-03-10 23:55:05 +03:00
|
|
|
void PaintRoot(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
|
|
|
PRUint32 aFlags) const;
|
|
|
|
/**
|
|
|
|
* Like PaintRoot, but used for internal display sublists.
|
|
|
|
* aForFrame is the frame that the list is associated with.
|
|
|
|
*/
|
|
|
|
void PaintForFrame(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
|
|
|
nsIFrame* aForFrame, PRUint32 aFlags) const;
|
2008-09-11 04:24:16 +04:00
|
|
|
/**
|
|
|
|
* Get the bounds. Takes the union of the bounds of all children.
|
|
|
|
*/
|
|
|
|
nsRect GetBounds(nsDisplayListBuilder* aBuilder) const;
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Find the topmost display item that returns a non-null frame, and return
|
|
|
|
* the frame.
|
|
|
|
*/
|
2010-04-08 04:31:26 +04:00
|
|
|
void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
nsDisplayItem::HitTestState* aState,
|
|
|
|
nsTArray<nsIFrame*> *aOutFrames) const;
|
2008-01-04 05:08:29 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
2006-01-29 21:48:58 +03:00
|
|
|
// This class is only used on stack, so we don't have to worry about leaking
|
|
|
|
// it. Don't let us be heap-allocated!
|
|
|
|
void* operator new(size_t sz) CPP_THROW_NEW;
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
// Utility function used to massage the list during ComputeVisibility.
|
2007-11-11 23:31:39 +03:00
|
|
|
void FlattenTo(nsTArray<nsDisplayItem*>* aElements);
|
2006-01-26 05:29:17 +03:00
|
|
|
// Utility function used to massage the list during sorting, to rewrite
|
|
|
|
// any wrapper items with null GetUnderlyingFrame
|
|
|
|
void ExplodeAnonymousChildLists(nsDisplayListBuilder* aBuilder);
|
|
|
|
|
|
|
|
nsDisplayItemLink mSentinel;
|
|
|
|
nsDisplayItemLink* mTop;
|
2009-09-07 04:35:14 +04:00
|
|
|
|
2010-03-10 23:55:05 +03:00
|
|
|
// This is set by ComputeVisibility
|
|
|
|
nsRect mVisibleRect;
|
2010-03-01 10:56:19 +03:00
|
|
|
// This is set to true by ComputeVisibility if the final visible region
|
|
|
|
// is empty (i.e. everything that was visible is covered by some
|
|
|
|
// opaque content in this list).
|
|
|
|
PRPackedBool mIsOpaque;
|
2009-09-07 04:35:14 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRPackedBool mDidComputeVisibility;
|
|
|
|
#endif
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is passed as a parameter to nsIFrame::BuildDisplayList. That method
|
|
|
|
* will put any generated items onto the appropriate list given here. It's
|
|
|
|
* basically just a collection with one list for each separate stacking layer.
|
|
|
|
* The lists themselves are external to this object and thus can be shared
|
|
|
|
* with others. Some of the list pointers may even refer to the same list.
|
|
|
|
*/
|
2006-01-26 08:14:30 +03:00
|
|
|
class nsDisplayListSet {
|
|
|
|
public:
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* @return a list where one should place the border and/or background for
|
|
|
|
* this frame (everything from steps 1 and 2 of CSS 2.1 appendix E)
|
|
|
|
*/
|
|
|
|
nsDisplayList* BorderBackground() const { return mBorderBackground; }
|
|
|
|
/**
|
|
|
|
* @return a list where one should place the borders and/or backgrounds for
|
|
|
|
* block-level in-flow descendants (step 4 of CSS 2.1 appendix E)
|
|
|
|
*/
|
|
|
|
nsDisplayList* BlockBorderBackgrounds() const { return mBlockBorderBackgrounds; }
|
|
|
|
/**
|
|
|
|
* @return a list where one should place descendant floats (step 5 of
|
|
|
|
* CSS 2.1 appendix E)
|
|
|
|
*/
|
|
|
|
nsDisplayList* Floats() const { return mFloats; }
|
|
|
|
/**
|
|
|
|
* @return a list where one should place the (pseudo) stacking contexts
|
|
|
|
* for descendants of this frame (everything from steps 3, 7 and 8
|
|
|
|
* of CSS 2.1 appendix E)
|
|
|
|
*/
|
|
|
|
nsDisplayList* PositionedDescendants() const { return mPositioned; }
|
|
|
|
/**
|
|
|
|
* @return a list where one should place the outlines
|
|
|
|
* for this frame and its descendants (step 9 of CSS 2.1 appendix E)
|
|
|
|
*/
|
|
|
|
nsDisplayList* Outlines() const { return mOutlines; }
|
|
|
|
/**
|
|
|
|
* @return a list where one should place all other content
|
|
|
|
*/
|
|
|
|
nsDisplayList* Content() const { return mContent; }
|
|
|
|
|
|
|
|
nsDisplayListSet(nsDisplayList* aBorderBackground,
|
|
|
|
nsDisplayList* aBlockBorderBackgrounds,
|
|
|
|
nsDisplayList* aFloats,
|
|
|
|
nsDisplayList* aContent,
|
|
|
|
nsDisplayList* aPositionedDescendants,
|
|
|
|
nsDisplayList* aOutlines) :
|
|
|
|
mBorderBackground(aBorderBackground),
|
|
|
|
mBlockBorderBackgrounds(aBlockBorderBackgrounds),
|
|
|
|
mFloats(aFloats),
|
|
|
|
mContent(aContent),
|
|
|
|
mPositioned(aPositionedDescendants),
|
|
|
|
mOutlines(aOutlines) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A copy constructor that lets the caller override the BorderBackground
|
|
|
|
* list.
|
|
|
|
*/
|
|
|
|
nsDisplayListSet(const nsDisplayListSet& aLists,
|
|
|
|
nsDisplayList* aBorderBackground) :
|
|
|
|
mBorderBackground(aBorderBackground),
|
|
|
|
mBlockBorderBackgrounds(aLists.BlockBorderBackgrounds()),
|
|
|
|
mFloats(aLists.Floats()),
|
|
|
|
mContent(aLists.Content()),
|
|
|
|
mPositioned(aLists.PositionedDescendants()),
|
|
|
|
mOutlines(aLists.Outlines()) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move all display items in our lists to top of the corresponding lists in the
|
|
|
|
* destination.
|
|
|
|
*/
|
|
|
|
void MoveTo(const nsDisplayListSet& aDestination) const;
|
2006-01-29 21:48:58 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// This class is only used on stack, so we don't have to worry about leaking
|
|
|
|
// it. Don't let us be heap-allocated!
|
|
|
|
void* operator new(size_t sz) CPP_THROW_NEW;
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
protected:
|
|
|
|
nsDisplayList* mBorderBackground;
|
|
|
|
nsDisplayList* mBlockBorderBackgrounds;
|
|
|
|
nsDisplayList* mFloats;
|
|
|
|
nsDisplayList* mContent;
|
|
|
|
nsDisplayList* mPositioned;
|
|
|
|
nsDisplayList* mOutlines;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A specialization of nsDisplayListSet where the lists are actually internal
|
|
|
|
* to the object, and all distinct.
|
|
|
|
*/
|
|
|
|
struct nsDisplayListCollection : public nsDisplayListSet {
|
|
|
|
nsDisplayListCollection() :
|
|
|
|
nsDisplayListSet(&mLists[0], &mLists[1], &mLists[2], &mLists[3], &mLists[4],
|
|
|
|
&mLists[5]) {}
|
|
|
|
nsDisplayListCollection(nsDisplayList* aBorderBackground) :
|
|
|
|
nsDisplayListSet(aBorderBackground, &mLists[1], &mLists[2], &mLists[3], &mLists[4],
|
|
|
|
&mLists[5]) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort all lists by content order.
|
|
|
|
*/
|
|
|
|
void SortAllByContentOrder(nsDisplayListBuilder* aBuilder, nsIContent* aCommonAncestor) {
|
|
|
|
for (PRInt32 i = 0; i < 6; ++i) {
|
|
|
|
mLists[i].SortByContentOrder(aBuilder, aCommonAncestor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2006-01-29 21:48:58 +03:00
|
|
|
// This class is only used on stack, so we don't have to worry about leaking
|
|
|
|
// it. Don't let us be heap-allocated!
|
|
|
|
void* operator new(size_t sz) CPP_THROW_NEW;
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsDisplayList mLists[6];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use this class to implement not-very-frequently-used display items
|
|
|
|
* that are not opaque, do not receive events, and are bounded by a frame's
|
|
|
|
* border-rect.
|
|
|
|
*
|
|
|
|
* This should not be used for display items which are created frequently,
|
|
|
|
* because each item is one or two pointers bigger than an item from a
|
|
|
|
* custom display item class could be, and fractionally slower. However it does
|
|
|
|
* save code size. We use this for infrequently-used item types.
|
|
|
|
*/
|
|
|
|
class nsDisplayGeneric : public nsDisplayItem {
|
|
|
|
public:
|
|
|
|
typedef void (* PaintCallback)(nsIFrame* aFrame, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect, nsPoint aFramePt);
|
|
|
|
|
2010-07-16 01:07:49 +04:00
|
|
|
nsDisplayGeneric(nsIFrame* aFrame, PaintCallback aPaint, const char* aName, Type aType)
|
2006-03-14 23:43:18 +03:00
|
|
|
: nsDisplayItem(aFrame), mPaint(aPaint)
|
2006-01-26 05:29:17 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mName(aName)
|
|
|
|
#endif
|
2010-07-16 01:07:49 +04:00
|
|
|
, mType(aType)
|
2006-01-29 21:48:58 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayGeneric);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayGeneric() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayGeneric);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx) {
|
|
|
|
mPaint(mFrame, aCtx, mVisibleRect, aBuilder->ToReferenceFrame(mFrame));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME(mName, mType)
|
2006-01-26 05:29:17 +03:00
|
|
|
protected:
|
|
|
|
PaintCallback mPaint;
|
|
|
|
#ifdef DEBUG
|
|
|
|
const char* mName;
|
|
|
|
#endif
|
2010-07-16 01:07:49 +04:00
|
|
|
Type mType;
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
2006-09-19 08:26:20 +04:00
|
|
|
#if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
|
|
|
|
/**
|
|
|
|
* This class implements painting of reflow counts. Ideally, we would simply
|
2009-08-21 01:52:48 +04:00
|
|
|
* make all the frame names be those returned by nsFrame::GetFrameName
|
2006-09-19 08:26:20 +04:00
|
|
|
* (except that tosses in the content tag name!) and support only one color
|
|
|
|
* and eliminate this class altogether in favor of nsDisplayGeneric, but for
|
|
|
|
* the time being we can't pass args to a PaintCallback, so just have a
|
|
|
|
* separate class to do the right thing. Sadly, this alsmo means we need to
|
|
|
|
* hack all leaf frame classes to handle this.
|
|
|
|
*
|
|
|
|
* XXXbz the color thing is a bit of a mess, but 0 basically means "not set"
|
|
|
|
* here... I could switch it all to nscolor, but why bother?
|
|
|
|
*/
|
|
|
|
class nsDisplayReflowCount : public nsDisplayItem {
|
|
|
|
public:
|
|
|
|
nsDisplayReflowCount(nsIFrame* aFrame, const char* aFrameName,
|
|
|
|
PRUint32 aColor = 0)
|
|
|
|
: nsDisplayItem(aFrame),
|
|
|
|
mFrameName(aFrameName),
|
|
|
|
mColor(aColor)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayReflowCount);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayReflowCount() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayReflowCount);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx) {
|
2006-09-19 08:26:20 +04:00
|
|
|
nsPoint pt = aBuilder->ToReferenceFrame(mFrame);
|
|
|
|
nsIRenderingContext::AutoPushTranslation translate(aCtx, pt.x, pt.y);
|
2007-03-31 01:11:41 +04:00
|
|
|
mFrame->PresContext()->PresShell()->PaintCount(mFrameName, aCtx,
|
|
|
|
mFrame->PresContext(),
|
2006-09-19 08:26:20 +04:00
|
|
|
mFrame, mColor);
|
|
|
|
}
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("nsDisplayReflowCount", TYPE_REFLOW_COUNT)
|
2006-09-19 08:26:20 +04:00
|
|
|
protected:
|
|
|
|
const char* mFrameName;
|
|
|
|
nscolor mColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name) \
|
|
|
|
PR_BEGIN_MACRO \
|
2009-07-22 04:44:52 +04:00
|
|
|
if (!aBuilder->IsBackgroundOnly() && !aBuilder->IsForEventDelivery() && \
|
|
|
|
PresContext()->PresShell()->IsPaintingFrameCounts()) { \
|
2006-09-19 08:26:20 +04:00
|
|
|
nsresult _rv = \
|
|
|
|
aLists.Outlines()->AppendNewToTop(new (aBuilder) \
|
|
|
|
nsDisplayReflowCount(this, _name)); \
|
|
|
|
NS_ENSURE_SUCCESS(_rv, _rv); \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT_DSP_COLOR(_name, _color) \
|
|
|
|
PR_BEGIN_MACRO \
|
2009-07-22 04:44:52 +04:00
|
|
|
if (!aBuilder->IsBackgroundOnly() && !aBuilder->IsForEventDelivery() && \
|
|
|
|
PresContext()->PresShell()->IsPaintingFrameCounts()) { \
|
2006-09-19 08:26:20 +04:00
|
|
|
nsresult _rv = \
|
|
|
|
aLists.Outlines()->AppendNewToTop(new (aBuilder) \
|
|
|
|
nsDisplayReflowCount(this, _name, \
|
|
|
|
_color)); \
|
|
|
|
NS_ENSURE_SUCCESS(_rv, _rv); \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
/*
|
|
|
|
Macro to be used for classes that don't actually implement BuildDisplayList
|
|
|
|
*/
|
|
|
|
#define DECL_DO_GLOBAL_REFLOW_COUNT_DSP(_class, _super) \
|
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder, \
|
|
|
|
const nsRect& aDirtyRect, \
|
|
|
|
const nsDisplayListSet& aLists) { \
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP(#_class); \
|
|
|
|
return _super::BuildDisplayList(aBuilder, aDirtyRect, aLists); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF
|
|
|
|
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name)
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT_DSP_COLOR(_name, _color)
|
|
|
|
#define DECL_DO_GLOBAL_REFLOW_COUNT_DSP(_class, _super)
|
|
|
|
|
|
|
|
#endif // MOZ_REFLOW_PERF_DSP && MOZ_REFLOW_PERF
|
|
|
|
|
2006-04-18 03:16:46 +04:00
|
|
|
class nsDisplayCaret : public nsDisplayItem {
|
|
|
|
public:
|
2008-07-16 14:52:01 +04:00
|
|
|
nsDisplayCaret(nsIFrame* aCaretFrame, nsCaret *aCaret)
|
2006-04-18 03:16:46 +04:00
|
|
|
: nsDisplayItem(aCaretFrame), mCaret(aCaret) {
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayCaret);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayCaret() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayCaret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder) {
|
|
|
|
// The caret returns a rect in the coordinates of mFrame.
|
|
|
|
return mCaret->GetCaretRect() + aBuilder->ToReferenceFrame(mFrame);
|
|
|
|
}
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("Caret", TYPE_CARET)
|
2006-04-18 03:16:46 +04:00
|
|
|
protected:
|
2008-07-16 14:52:01 +04:00
|
|
|
nsRefPtr<nsCaret> mCaret;
|
2006-04-18 03:16:46 +04:00
|
|
|
};
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* The standard display item to paint the CSS borders of a frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayBorder : public nsDisplayItem {
|
|
|
|
public:
|
2006-03-14 23:43:18 +03:00
|
|
|
nsDisplayBorder(nsIFrame* aFrame) : nsDisplayItem(aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayBorder);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayBorder() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBorder);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
2009-10-07 08:28:41 +04:00
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("Border", TYPE_BORDER)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
2009-04-25 12:19:23 +04:00
|
|
|
/**
|
2009-04-30 14:07:18 +04:00
|
|
|
* A simple display item that just renders a solid color across the
|
2009-07-04 13:30:59 +04:00
|
|
|
* specified bounds. For canvas frames (in the CSS sense) we split off the
|
|
|
|
* drawing of the background color into this class (from nsDisplayBackground
|
|
|
|
* via nsDisplayCanvasBackground). This is done so that we can always draw a
|
|
|
|
* background color to avoid ugly flashes of white when we can't draw a full
|
|
|
|
* frame tree (ie when a page is loading). The bounds can differ from the
|
|
|
|
* frame's bounds -- this is needed when a frame/iframe is loading and there
|
|
|
|
* is not yet a frame tree to go in the frame/iframe so we use the subdoc
|
|
|
|
* frame of the parent document as a standin.
|
2009-04-25 12:19:23 +04:00
|
|
|
*/
|
|
|
|
class nsDisplaySolidColor : public nsDisplayItem {
|
|
|
|
public:
|
2009-04-30 14:07:18 +04:00
|
|
|
nsDisplaySolidColor(nsIFrame* aFrame, const nsRect& aBounds, nscolor aColor)
|
|
|
|
: nsDisplayItem(aFrame), mBounds(aBounds), mColor(aColor) {
|
2009-04-25 12:19:23 +04:00
|
|
|
MOZ_COUNT_CTOR(nsDisplaySolidColor);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplaySolidColor() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplaySolidColor);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder) { return mBounds; }
|
|
|
|
|
|
|
|
virtual PRBool IsOpaque(nsDisplayListBuilder* aBuilder) {
|
|
|
|
return (NS_GET_A(mColor) == 255);
|
|
|
|
}
|
|
|
|
|
2010-05-13 04:56:11 +04:00
|
|
|
virtual PRBool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor)
|
|
|
|
{
|
|
|
|
*aColor = mColor;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2009-04-25 12:19:23 +04:00
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
2009-04-25 12:19:23 +04:00
|
|
|
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("SolidColor", TYPE_SOLID_COLOR)
|
|
|
|
|
2009-04-25 12:19:23 +04:00
|
|
|
private:
|
|
|
|
nsRect mBounds;
|
|
|
|
nscolor mColor;
|
|
|
|
};
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* The standard display item to paint the CSS background of a frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayBackground : public nsDisplayItem {
|
|
|
|
public:
|
2006-03-14 23:43:18 +03:00
|
|
|
nsDisplayBackground(nsIFrame* aFrame) : nsDisplayItem(aFrame) {
|
2010-06-11 02:53:57 +04:00
|
|
|
mIsThemed = mFrame->IsThemed(&mThemeTransparency);
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
|
|
|
{
|
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual PRBool IsOpaque(nsDisplayListBuilder* aBuilder);
|
2008-04-11 07:46:37 +04:00
|
|
|
virtual PRBool IsVaryingRelativeToMovingFrame(nsDisplayListBuilder* aBuilder);
|
2010-05-13 04:56:11 +04:00
|
|
|
virtual PRBool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor);
|
2007-12-18 08:26:38 +03:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("Background", TYPE_BACKGROUND)
|
2007-12-18 08:26:38 +03:00
|
|
|
private:
|
2010-06-11 02:53:57 +04:00
|
|
|
/* Used to cache mFrame->IsThemed() since it isn't a cheap call */
|
|
|
|
PRPackedBool mIsThemed;
|
|
|
|
nsITheme::Transparency mThemeTransparency;
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
2008-07-08 04:57:47 +04:00
|
|
|
/**
|
2009-02-10 11:45:13 +03:00
|
|
|
* The standard display item to paint the outer CSS box-shadows of a frame.
|
2008-07-08 04:57:47 +04:00
|
|
|
*/
|
2009-02-10 11:45:13 +03:00
|
|
|
class nsDisplayBoxShadowOuter : public nsDisplayItem {
|
2008-07-08 04:57:47 +04:00
|
|
|
public:
|
2009-02-10 11:45:13 +03:00
|
|
|
nsDisplayBoxShadowOuter(nsIFrame* aFrame) : nsDisplayItem(aFrame) {
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayBoxShadowOuter);
|
2008-07-08 04:57:47 +04:00
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
2009-02-10 11:45:13 +03:00
|
|
|
virtual ~nsDisplayBoxShadowOuter() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBoxShadowOuter);
|
2008-07-08 04:57:47 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
2008-07-08 04:57:47 +04:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
|
2009-10-07 08:28:41 +04:00
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("BoxShadowOuter", TYPE_BOX_SHADOW_OUTER)
|
2009-12-01 02:14:04 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsRegion mVisibleRegion;
|
2009-02-10 11:45:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The standard display item to paint the inner CSS box-shadows of a frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayBoxShadowInner : public nsDisplayItem {
|
|
|
|
public:
|
|
|
|
nsDisplayBoxShadowInner(nsIFrame* aFrame) : nsDisplayItem(aFrame) {
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayBoxShadowInner);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayBoxShadowInner() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBoxShadowInner);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
2009-12-01 02:14:04 +03:00
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("BoxShadowInner", TYPE_BOX_SHADOW_INNER)
|
2009-12-01 02:14:04 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsRegion mVisibleRegion;
|
2008-07-08 04:57:47 +04:00
|
|
|
};
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* The standard display item to paint the CSS outline of a frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayOutline : public nsDisplayItem {
|
|
|
|
public:
|
2006-03-14 23:43:18 +03:00
|
|
|
nsDisplayOutline(nsIFrame* aFrame) : nsDisplayItem(aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayOutline);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayOutline() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayOutline);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
2009-10-07 08:28:41 +04:00
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("Outline", TYPE_OUTLINE)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class that lets you receive events within the frame bounds but never paints.
|
|
|
|
*/
|
|
|
|
class nsDisplayEventReceiver : public nsDisplayItem {
|
|
|
|
public:
|
2006-03-14 23:43:18 +03:00
|
|
|
nsDisplayEventReceiver(nsIFrame* aFrame) : nsDisplayItem(aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayEventReceiver);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayEventReceiver() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayEventReceiver);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
|
|
|
{
|
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("EventReceiver", TYPE_EVENT_RECEIVER)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class that lets you wrap a display list as a display item.
|
|
|
|
*
|
|
|
|
* GetUnderlyingFrame() is troublesome for wrapped lists because if the wrapped
|
|
|
|
* list has many items, it's not clear which one has the 'underlying frame'.
|
|
|
|
* Thus we force the creator to specify what the underlying frame is. The
|
|
|
|
* underlying frame should be the root of a stacking context, because sorting
|
|
|
|
* a list containing this item will not get at the children.
|
|
|
|
*
|
|
|
|
* In some cases (e.g., clipping) we want to wrap a list but we don't have a
|
|
|
|
* particular underlying frame that is a stacking context root. In that case
|
|
|
|
* we allow the frame to be nsnull. Callers to GetUnderlyingFrame must
|
|
|
|
* detect and handle this case.
|
|
|
|
*/
|
|
|
|
class nsDisplayWrapList : public nsDisplayItem {
|
2006-01-29 21:48:58 +03:00
|
|
|
// This is never instantiated directly, so no need to count constructors and
|
|
|
|
// destructors.
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Takes all the items from aList and puts them in our list.
|
|
|
|
*/
|
|
|
|
nsDisplayWrapList(nsIFrame* aFrame, nsDisplayList* aList);
|
|
|
|
nsDisplayWrapList(nsIFrame* aFrame, nsDisplayItem* aItem);
|
|
|
|
virtual ~nsDisplayWrapList();
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
|
|
|
|
virtual PRBool IsOpaque(nsDisplayListBuilder* aBuilder);
|
2010-05-13 04:56:11 +04:00
|
|
|
virtual PRBool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor);
|
2008-04-11 07:46:37 +04:00
|
|
|
virtual PRBool IsVaryingRelativeToMovingFrame(nsDisplayListBuilder* aBuilder);
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2009-10-07 08:28:41 +04:00
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) {
|
|
|
|
NS_WARNING("This list should already have been flattened!!!");
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("WrapList", TYPE_WRAP_LIST)
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
virtual nsDisplayList* GetList() { return &mList; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This creates a copy of this item, but wrapping aItem instead of
|
|
|
|
* our existing list. Only gets called if this item returned nsnull
|
|
|
|
* for GetUnderlyingFrame(). aItem is guaranteed to return non-null from
|
|
|
|
* GetUnderlyingFrame().
|
|
|
|
*/
|
|
|
|
virtual nsDisplayWrapList* WrapWithClone(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) {
|
|
|
|
NS_NOTREACHED("We never returned nsnull for GetUnderlyingFrame!");
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2006-01-29 21:48:58 +03:00
|
|
|
nsDisplayWrapList() {}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsDisplayList mList;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We call WrapDisplayList on the in-flow lists: BorderBackground(),
|
|
|
|
* BlockBorderBackgrounds() and Content().
|
|
|
|
* We call WrapDisplayItem on each item of Outlines(), PositionedDescendants(),
|
|
|
|
* and Floats(). This is done to support special wrapping processing for frames
|
|
|
|
* that may not be in-flow descendants of the current frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayWrapper {
|
|
|
|
public:
|
2006-01-29 21:48:58 +03:00
|
|
|
// This is never instantiated directly (it has pure virtual methods), so no
|
|
|
|
// need to count constructors and destructors.
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual PRBool WrapBorderBackground() { return PR_TRUE; }
|
|
|
|
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayList* aList) = 0;
|
|
|
|
virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) = 0;
|
|
|
|
|
|
|
|
nsresult WrapLists(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
const nsDisplayListSet& aIn, const nsDisplayListSet& aOut);
|
|
|
|
nsresult WrapListsInPlace(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
const nsDisplayListSet& aLists);
|
2006-01-29 21:48:58 +03:00
|
|
|
protected:
|
|
|
|
nsDisplayWrapper() {}
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The standard display item to paint a stacking context with translucency
|
|
|
|
* set by the stacking context root frame's 'opacity' style.
|
|
|
|
*/
|
|
|
|
class nsDisplayOpacity : public nsDisplayWrapList {
|
|
|
|
public:
|
|
|
|
nsDisplayOpacity(nsIFrame* aFrame, nsDisplayList* aList);
|
2006-01-29 21:48:58 +03:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayOpacity();
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual PRBool IsOpaque(nsDisplayListBuilder* aBuilder);
|
2010-03-01 10:56:19 +03:00
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager);
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2009-10-07 08:28:41 +04:00
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsDisplayClip can clip a list of items, but we take a single item
|
|
|
|
* initially and then later merge other items into it when we merge
|
|
|
|
* adjacent matching nsDisplayClips
|
|
|
|
*/
|
|
|
|
class nsDisplayClip : public nsDisplayWrapList {
|
|
|
|
public:
|
2008-04-18 13:21:21 +04:00
|
|
|
/**
|
|
|
|
* @param aFrame the frame that should be considered the underlying
|
|
|
|
* frame for this content, e.g. the frame whose z-index we have.
|
|
|
|
* @param aClippingFrame the frame that is inducing the clipping.
|
|
|
|
*/
|
|
|
|
nsDisplayClip(nsIFrame* aFrame, nsIFrame* aClippingFrame,
|
|
|
|
nsDisplayItem* aItem, const nsRect& aRect);
|
|
|
|
nsDisplayClip(nsIFrame* aFrame, nsIFrame* aClippingFrame,
|
|
|
|
nsDisplayList* aList, const nsRect& aRect);
|
2006-01-29 21:48:58 +03:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayClip();
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2009-10-07 08:28:41 +04:00
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("Clip", TYPE_CLIP)
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
nsRect GetClipRect() { return mClip; }
|
2008-04-08 17:06:12 +04:00
|
|
|
void SetClipRect(const nsRect& aRect) { mClip = aRect; }
|
2008-04-18 13:21:21 +04:00
|
|
|
nsIFrame* GetClippingFrame() { return mClippingFrame; }
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
virtual nsDisplayWrapList* WrapWithClone(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem);
|
|
|
|
|
|
|
|
private:
|
2008-04-18 13:21:21 +04:00
|
|
|
// The frame that is responsible for the clipping. This may be different
|
|
|
|
// from mFrame because mFrame represents the content that is being
|
|
|
|
// clipped, and for example may be used to obtain the z-index of the
|
|
|
|
// content.
|
|
|
|
nsIFrame* mClippingFrame;
|
|
|
|
nsRect mClip;
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
2008-09-11 04:24:16 +04:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
/**
|
|
|
|
* A display item to paint a stacking context with effects
|
|
|
|
* set by the stacking context root frame's style.
|
|
|
|
*/
|
|
|
|
class nsDisplaySVGEffects : public nsDisplayWrapList {
|
|
|
|
public:
|
|
|
|
nsDisplaySVGEffects(nsIFrame* aFrame, nsDisplayList* aList);
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplaySVGEffects();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual PRBool IsOpaque(nsDisplayListBuilder* aBuilder);
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
|
2008-09-11 04:24:16 +04:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder) {
|
|
|
|
return mBounds + aBuilder->ToReferenceFrame(mEffectsFrame);
|
|
|
|
}
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
|
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2009-10-07 08:28:41 +04:00
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
nsRegion* aVisibleRegionBeforeMove);
|
2008-09-11 04:24:16 +04:00
|
|
|
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("SVGEffects", TYPE_SVG_EFFECTS)
|
2008-09-11 04:24:16 +04:00
|
|
|
|
|
|
|
nsIFrame* GetEffectsFrame() { return mEffectsFrame; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsIFrame* mEffectsFrame;
|
|
|
|
// relative to mEffectsFrame
|
|
|
|
nsRect mBounds;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2008-09-13 13:42:11 +04:00
|
|
|
/* A display item that applies a transformation to all of its descendent
|
|
|
|
* elements. This wrapper should only be used if there is a transform applied
|
|
|
|
* to the root element.
|
|
|
|
* INVARIANT: The wrapped frame is transformed.
|
|
|
|
* INVARIANT: The wrapped frame is non-null.
|
|
|
|
*/
|
|
|
|
class nsDisplayTransform: public nsDisplayItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Constructor accepts a display list, empties it, and wraps it up. It also
|
|
|
|
* ferries the underlying frame to the nsDisplayItem constructor.
|
|
|
|
*/
|
|
|
|
nsDisplayTransform(nsIFrame *aFrame, nsDisplayList *aList) :
|
|
|
|
nsDisplayItem(aFrame), mStoredList(aFrame, aList)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayTransform);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayTransform()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayTransform);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("nsDisplayTransform", TYPE_TRANSFORM);
|
2008-09-13 13:42:11 +04:00
|
|
|
|
2009-04-06 04:37:04 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsDisplayWrapList* GetStoredList() { return &mStoredList; }
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder *aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState *aState, nsTArray<nsIFrame*> *aOutFrames);
|
2008-09-13 13:42:11 +04:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder *aBuilder);
|
|
|
|
virtual PRBool IsOpaque(nsDisplayListBuilder *aBuilder);
|
2010-05-13 04:56:11 +04:00
|
|
|
virtual PRBool IsUniform(nsDisplayListBuilder *aBuilder, nscolor* aColor);
|
2008-09-13 13:42:11 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder *aBuilder,
|
2009-09-07 04:35:14 +04:00
|
|
|
nsIRenderingContext *aCtx);
|
|
|
|
virtual PRBool ComputeVisibility(nsDisplayListBuilder *aBuilder,
|
2009-10-07 08:28:41 +04:00
|
|
|
nsRegion *aVisibleRegion,
|
|
|
|
nsRegion *aVisibleRegionBeforeMove);
|
2008-09-13 13:42:11 +04:00
|
|
|
virtual PRBool TryMerge(nsDisplayListBuilder *aBuilder, nsDisplayItem *aItem);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TransformRect takes in as parameters a rectangle (in aFrame's coordinate
|
|
|
|
* space) and returns the smallest rectangle (in aFrame's coordinate space)
|
|
|
|
* containing the transformed image of that rectangle. That is, it takes
|
|
|
|
* the four corners of the rectangle, transforms them according to the
|
|
|
|
* matrix associated with the specified frame, then returns the smallest
|
|
|
|
* rectangle containing the four transformed points.
|
|
|
|
*
|
|
|
|
* @param untransformedBounds The rectangle (in app units) to transform.
|
|
|
|
* @param aFrame The frame whose transformation should be applied. This
|
|
|
|
* function raises an assertion if aFrame is null or doesn't have a
|
|
|
|
* transform applied to it.
|
|
|
|
* @param aOrigin The origin of the transform relative to aFrame's local
|
|
|
|
* coordinate space.
|
|
|
|
* @param aBoundsOverride (optional) Rather than using the frame's computed
|
|
|
|
* bounding rect as frame bounds, use this rectangle instead. Pass
|
|
|
|
* nsnull (or nothing at all) to use the default.
|
|
|
|
*/
|
|
|
|
static nsRect TransformRect(const nsRect &aUntransformedBounds,
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsPoint &aOrigin,
|
|
|
|
const nsRect* aBoundsOverride = nsnull);
|
|
|
|
|
|
|
|
/* UntransformRect is like TransformRect, except that it inverts the
|
|
|
|
* transform.
|
|
|
|
*/
|
|
|
|
static nsRect UntransformRect(const nsRect &aUntransformedBounds,
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsPoint &aOrigin);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the bounds of a frame as defined for transforms. If
|
|
|
|
* UNIFIED_CONTINUATIONS is not defined, this is simply the frame's bounding
|
|
|
|
* rectangle, translated to the origin. Otherwise, returns the smallest
|
|
|
|
* rectangle containing a frame and all of its continuations. For example,
|
|
|
|
* if there is a <span> element with several continuations split over
|
|
|
|
* several lines, this function will return the rectangle containing all of
|
|
|
|
* those continuations. This rectangle is relative to the origin of the
|
|
|
|
* frame's local coordinate space.
|
|
|
|
*
|
|
|
|
* @param aFrame The frame to get the bounding rect for.
|
|
|
|
* @return The frame's bounding rect, as described above.
|
|
|
|
*/
|
|
|
|
static nsRect GetFrameBoundsForTransform(const nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a frame with the -moz-transform property, returns the
|
|
|
|
* transformation matrix for that frame.
|
|
|
|
*
|
|
|
|
* @param aFrame The frame to get the matrix from.
|
|
|
|
* @param aOrigin Relative to which point this transform should be applied.
|
|
|
|
* @param aScaleFactor The number of app units per graphics unit.
|
|
|
|
* @param aBoundsOverride [optional] If this is nsnull (the default), the
|
|
|
|
* computation will use the value of GetFrameBoundsForTransform(aFrame)
|
|
|
|
* for the frame's bounding rectangle. Otherwise, it will use the
|
|
|
|
* value of aBoundsOverride. This is mostly for internal use and in
|
|
|
|
* most cases you will not need to specify a value.
|
|
|
|
*/
|
|
|
|
static gfxMatrix GetResultingTransformMatrix(const nsIFrame* aFrame,
|
|
|
|
const nsPoint& aOrigin,
|
|
|
|
float aFactor,
|
|
|
|
const nsRect* aBoundsOverride = nsnull);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsDisplayWrapList mStoredList;
|
|
|
|
};
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
#endif /*NSDISPLAYLIST_H_*/
|