2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: set ts=2 sw=2 et tw=78:
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* structures that represent things to be painted (ordered in z-order),
|
|
|
|
* used during painting and hit testing
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NSDISPLAYLIST_H_
|
|
|
|
#define NSDISPLAYLIST_H_
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsISelection.h"
|
2008-07-16 03:52:01 -07:00
|
|
|
#include "nsCaret.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "plarena.h"
|
2010-05-20 20:20:48 -07:00
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "FrameLayerBuilder.h"
|
2010-10-19 10:02:25 -07:00
|
|
|
#include "nsThemeConstants.h"
|
2012-08-13 03:10:10 -07:00
|
|
|
#include "nsLayoutUtils.h"
|
2012-08-28 22:39:01 -07:00
|
|
|
#include "nsDisplayListInvalidation.h"
|
2013-03-04 01:56:01 -08:00
|
|
|
#include "DisplayListClipState.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-11 17:17:44 -07:00
|
|
|
#include "mozilla/StandardInteger.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include <stdlib.h>
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIPresShell;
|
|
|
|
class nsIContent;
|
2011-04-07 18:04:40 -07:00
|
|
|
class nsRenderingContext;
|
2011-04-16 18:22:44 -07:00
|
|
|
class nsDeviceContext;
|
2008-04-06 04:34:14 -07:00
|
|
|
class nsDisplayTableItem;
|
2009-08-13 19:09:51 -07:00
|
|
|
class nsDisplayItem;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class ImageLayer;
|
|
|
|
class ImageContainer;
|
|
|
|
} //namepsace
|
|
|
|
} //namepsace
|
|
|
|
|
2007-03-22 10:30:00 -07: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.
|
2012-09-16 03:32:59 -07:00
|
|
|
*
|
|
|
|
* Display item's coordinates are relative to their nearest reference frame ancestor.
|
|
|
|
* Both the display root and any frame with a transform act as a reference frame
|
|
|
|
* for their frame subtrees.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
2010-07-15 14:07:49 -07:00
|
|
|
// All types are defined in nsDisplayItemTypes.h
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2010-07-15 14:07:49 -07:00
|
|
|
#define NS_DISPLAY_DECL_NAME(n, e) \
|
|
|
|
virtual const char* Name() { return n; } \
|
|
|
|
virtual Type GetType() { return e; }
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
2010-07-15 14:07:49 -07:00
|
|
|
#define NS_DISPLAY_DECL_NAME(n, e) \
|
|
|
|
virtual Type GetType() { return e; }
|
2007-03-22 10:30:00 -07: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 09:21:41 -07:00
|
|
|
class nsDisplayListBuilder {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2010-03-28 18:46:55 -07:00
|
|
|
typedef mozilla::FramePropertyDescriptor FramePropertyDescriptor;
|
2010-05-20 20:20:48 -07:00
|
|
|
typedef mozilla::FrameLayerBuilder FrameLayerBuilder;
|
2013-03-04 01:56:02 -08:00
|
|
|
typedef mozilla::DisplayItemClip DisplayItemClip;
|
2013-03-04 01:56:02 -08:00
|
|
|
typedef mozilla::DisplayListClipState DisplayListClipState;
|
2011-01-11 05:03:16 -08:00
|
|
|
typedef nsIWidget::ThemeGeometry ThemeGeometry;
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07: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
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aIsForEvents true if we're creating this list in order to
|
2007-03-22 10:30:00 -07:00
|
|
|
* determine which frame is under the mouse position
|
|
|
|
* @param aBuildCaret whether or not we should include the caret in any
|
|
|
|
* display lists that we make.
|
|
|
|
*/
|
2010-11-08 01:06:14 -08:00
|
|
|
enum Mode {
|
2012-07-31 10:28:22 -07:00
|
|
|
PAINTING,
|
|
|
|
EVENT_DELIVERY,
|
|
|
|
PLUGIN_GEOMETRY,
|
2013-02-24 16:59:21 -08:00
|
|
|
IMAGE_VISIBILITY,
|
2012-07-31 10:28:22 -07:00
|
|
|
OTHER
|
2010-11-08 01:06:14 -08:00
|
|
|
};
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDisplayListBuilder(nsIFrame* aReferenceFrame, Mode aMode, bool aBuildCaret);
|
2007-03-22 10:30:00 -07:00
|
|
|
~nsDisplayListBuilder();
|
|
|
|
|
2012-10-06 06:03:23 -07:00
|
|
|
void SetWillComputePluginGeometry(bool aWillComputePluginGeometry)
|
|
|
|
{
|
|
|
|
mWillComputePluginGeometry = aWillComputePluginGeometry;
|
|
|
|
}
|
|
|
|
void SetForPluginGeometry()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mMode == PAINTING, "Can only switch from PAINTING to PLUGIN_GEOMETRY");
|
|
|
|
NS_ASSERTION(mWillComputePluginGeometry, "Should have signalled this in advance");
|
|
|
|
mMode = PLUGIN_GEOMETRY;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the display is being built in order to determine which
|
2007-03-22 10:30:00 -07:00
|
|
|
* frame is under the mouse position.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsForEventDelivery() { return mMode == EVENT_DELIVERY; }
|
2010-11-08 01:06:14 -08:00
|
|
|
/**
|
2012-10-06 06:03:23 -07:00
|
|
|
* Be careful with this. The display list will be built in PAINTING mode
|
|
|
|
* first and then switched to PLUGIN_GEOMETRY before a second call to
|
|
|
|
* ComputeVisibility.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the display list is being built to compute geometry
|
2010-11-08 01:06:14 -08:00
|
|
|
* for plugins.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsForPluginGeometry() { return mMode == PLUGIN_GEOMETRY; }
|
2010-12-21 12:12:00 -08:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the display list is being built for painting.
|
2010-12-21 12:12:00 -08:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsForPainting() { return mMode == PAINTING; }
|
2013-02-24 16:59:21 -08:00
|
|
|
/**
|
|
|
|
* @return true if the display list is being built for determining image
|
|
|
|
* visibility.
|
|
|
|
*/
|
|
|
|
bool IsForImageVisibility() { return mMode == IMAGE_VISIBILITY; }
|
2012-10-06 06:03:23 -07:00
|
|
|
bool WillComputePluginGeometry() { return mWillComputePluginGeometry; }
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if "painting is suppressed" during page load and we
|
2007-03-22 10:30:00 -07:00
|
|
|
* should paint only the background of the document.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsBackgroundOnly() {
|
2010-09-01 13:44:48 -07:00
|
|
|
NS_ASSERTION(mPresShellStates.Length() > 0,
|
|
|
|
"don't call this if we're not in a presshell");
|
|
|
|
return CurrentPresShellState()->mIsBackgroundOnly;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the currently active BuildDisplayList call is being
|
2007-10-19 10:41:29 -07:00
|
|
|
* applied to a frame at the root of a pseudo stacking context. A pseudo
|
2007-03-22 10:30:00 -07: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
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAtRootOfPseudoStackingContext() { return mIsAtRootOfPseudoStackingContext; }
|
2008-04-10 20:46:37 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the selection that painting should be restricted to (or nullptr
|
2007-03-22 10:30:00 -07:00
|
|
|
* in the normal unrestricted case)
|
|
|
|
*/
|
|
|
|
nsISelection* GetBoundingSelection() { return mBoundingSelection; }
|
2012-09-16 03:32:59 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the root of given frame's (sub)tree, whose origin
|
|
|
|
* establishes the coordinate system for the child display items.
|
|
|
|
*/
|
|
|
|
const nsIFrame* FindReferenceFrameFor(const nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
if (aFrame == mCachedOffsetFrame) {
|
|
|
|
return mCachedReferenceFrame;
|
|
|
|
}
|
|
|
|
for (const nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f))
|
|
|
|
{
|
2013-01-13 21:30:47 -08:00
|
|
|
if (f == mReferenceFrame || f->IsTransformed()) {
|
2012-09-16 03:32:59 -07:00
|
|
|
mCachedOffsetFrame = aFrame;
|
|
|
|
mCachedReferenceFrame = f;
|
|
|
|
mCachedOffset = aFrame->GetOffsetToCrossDoc(f);
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mCachedOffsetFrame = aFrame;
|
|
|
|
mCachedReferenceFrame = mReferenceFrame;
|
|
|
|
mCachedOffset = aFrame->GetOffsetToCrossDoc(mReferenceFrame);
|
|
|
|
return mReferenceFrame;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* @return the root of the display list's frame (sub)tree, whose origin
|
|
|
|
* establishes the coordinate system for the display list
|
|
|
|
*/
|
2012-09-16 03:32:59 -07:00
|
|
|
nsIFrame* RootReferenceFrame()
|
|
|
|
{
|
|
|
|
return mReferenceFrame;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* @return a point pt such that adding pt to a coordinate relative to aFrame
|
|
|
|
* makes it relative to ReferenceFrame(), i.e., returns
|
2010-07-18 19:23:47 -07:00
|
|
|
* aFrame->GetOffsetToCrossDoc(ReferenceFrame()). The returned point is in
|
|
|
|
* the appunits of aFrame. It may be optimized to be faster than
|
|
|
|
* aFrame->GetOffsetToCrossDoc(ReferenceFrame()) (but currently isn't).
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-04-17 22:14:14 -07:00
|
|
|
const nsPoint& ToReferenceFrame(const nsIFrame* aFrame) {
|
|
|
|
if (aFrame != mCachedOffsetFrame) {
|
2012-09-16 03:32:59 -07:00
|
|
|
FindReferenceFrameFor(aFrame);
|
2012-04-17 22:14:14 -07:00
|
|
|
}
|
|
|
|
return mCachedOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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; }
|
|
|
|
/**
|
2010-12-07 05:54:50 -08:00
|
|
|
* Calling this setter makes us include all out-of-flow descendant
|
|
|
|
* frames in the display list, wherever they may be positioned (even
|
|
|
|
* outside the dirty rects).
|
|
|
|
*/
|
2011-10-17 07:59:28 -07:00
|
|
|
void SetIncludeAllOutOfFlows() { mIncludeAllOutOfFlows = true; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetIncludeAllOutOfFlows() const { return mIncludeAllOutOfFlows; }
|
2010-12-07 05:54:50 -08:00
|
|
|
/**
|
2011-12-20 01:15:41 -08:00
|
|
|
* Calling this setter makes us exclude all leaf frames that aren't
|
|
|
|
* selected.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-10-17 07:59:28 -07:00
|
|
|
void SetSelectedFramesOnly() { mSelectedFramesOnly = true; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetSelectedFramesOnly() { return mSelectedFramesOnly; }
|
2009-07-21 17:44:56 -07:00
|
|
|
/**
|
|
|
|
* Calling this setter makes us compute accurate visible regions at the cost
|
|
|
|
* of performance if regions get very complex.
|
|
|
|
*/
|
2011-10-17 07:59:28 -07:00
|
|
|
void SetAccurateVisibleRegions() { mAccurateVisibleRegions = true; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetAccurateVisibleRegions() { return mAccurateVisibleRegions; }
|
2007-08-29 13:38:44 -07:00
|
|
|
/**
|
|
|
|
* Allows callers to selectively override the regular paint suppression checks,
|
|
|
|
* so that methods like GetFrameForPoint work when painting is suppressed.
|
|
|
|
*/
|
2011-10-17 07:59:28 -07:00
|
|
|
void IgnorePaintSuppression() { mIgnoreSuppression = true; }
|
2010-09-11 11:24:49 -07:00
|
|
|
/**
|
|
|
|
* @return Returns if this builder will ignore paint suppression.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsIgnoringPaintSuppression() { return mIgnoreSuppression; }
|
2010-09-01 13:44:48 -07:00
|
|
|
/**
|
|
|
|
* @return Returns if this builder had to ignore painting suppression on some
|
|
|
|
* document when building the display list.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetHadToIgnorePaintSuppression() { return mHadToIgnoreSuppression; }
|
2010-05-12 17:56:08 -07:00
|
|
|
/**
|
|
|
|
* Call this if we're doing normal painting to the window.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetPaintingToWindow(bool aToWindow) { mIsPaintingToWindow = aToWindow; }
|
|
|
|
bool IsPaintingToWindow() const { return mIsPaintingToWindow; }
|
2012-07-22 20:00:36 -07:00
|
|
|
|
2012-10-06 06:03:23 -07:00
|
|
|
/**
|
|
|
|
* Returns true if merging and flattening of display lists should be
|
|
|
|
* performed while computing visibility.
|
|
|
|
*/
|
|
|
|
bool AllowMergingAndFlattening() { return mAllowMergingAndFlattening; }
|
|
|
|
void SetAllowMergingAndFlattening(bool aAllow) { mAllowMergingAndFlattening = aAllow; }
|
|
|
|
|
2012-07-25 00:06:19 -07:00
|
|
|
/**
|
|
|
|
* @return Returns if the builder is currently building an
|
|
|
|
* nsDisplayFixedPosition sub-tree.
|
|
|
|
*/
|
|
|
|
bool IsInFixedPosition() const { return mIsInFixedPosition; }
|
|
|
|
|
2012-07-22 20:00:36 -07:00
|
|
|
bool SetIsCompositingCheap(bool aCompositingCheap) {
|
|
|
|
bool temp = mIsCompositingCheap;
|
|
|
|
mIsCompositingCheap = aCompositingCheap;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
bool IsCompositingCheap() const { return mIsCompositingCheap; }
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Display the caret if needed.
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void DisplayCaret(nsIFrame* aFrame, const nsRect& aDirtyRect,
|
|
|
|
nsDisplayList* aList) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* frame = GetCaretFrame();
|
2013-02-14 03:12:27 -08:00
|
|
|
if (aFrame == frame) {
|
|
|
|
frame->DisplayCaret(this, aDirtyRect, aList);
|
2007-03-22 10:30:00 -07: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-03 17:53:01 -08:00
|
|
|
return CurrentPresShellState()->mCaretFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get the caret associated with the current presshell.
|
|
|
|
*/
|
2008-07-16 03:52:01 -07:00
|
|
|
nsCaret* GetCaret();
|
2007-03-22 10:30:00 -07: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-21 17:45:14 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if we're currently building a display list that's
|
2012-07-20 11:12:29 -07:00
|
|
|
* directly or indirectly under an nsDisplayTransform.
|
2009-07-21 17:45:14 -07:00
|
|
|
*/
|
2012-07-20 11:12:29 -07:00
|
|
|
bool IsInTransform() const { return mInTransform; }
|
2009-07-21 17:45:14 -07:00
|
|
|
/**
|
|
|
|
* Indicate whether or not we're directly or indirectly under and
|
|
|
|
* nsDisplayTransform or SVG foreignObject.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetInTransform(bool aInTransform) { mInTransform = aInTransform; }
|
2009-07-21 17:45:14 -07:00
|
|
|
|
2011-04-08 09:35:16 -07:00
|
|
|
/**
|
|
|
|
* Call this if using display port for scrolling.
|
|
|
|
*/
|
2011-05-13 06:21:59 -07:00
|
|
|
void SetDisplayPort(const nsRect& aDisplayPort);
|
2012-07-30 07:20:58 -07:00
|
|
|
const nsRect* GetDisplayPort() { return mHasDisplayPort ? &mDisplayPort : nullptr; }
|
2011-04-08 09:35:16 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call this if ReferenceFrame() is a viewport frame with fixed-position
|
|
|
|
* children, or when we construct an item which will return true from
|
|
|
|
* ShouldFixToViewport()
|
|
|
|
*/
|
2011-10-17 07:59:28 -07:00
|
|
|
void SetHasFixedItems() { mHasFixedItems = true; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetHasFixedItems() { return mHasFixedItems; }
|
2011-04-08 09:35:16 -07:00
|
|
|
|
2012-09-13 03:34:34 -07:00
|
|
|
/**
|
|
|
|
* Determines if this item is scrolled by content-document display-port
|
|
|
|
* scrolling. aActiveScrolledRoot will be set to the active scrolled root
|
|
|
|
* of the item. This may not necessarily correspond to the active scrolled
|
|
|
|
* root of the item's underlying frame.
|
|
|
|
* If specified, aOverrideActiveScrolledRoot will be treated as the active
|
|
|
|
* scrolled root.
|
|
|
|
*/
|
|
|
|
bool IsFixedItem(nsDisplayItem* aItem,
|
2012-09-12 17:32:53 -07:00
|
|
|
const nsIFrame** aActiveScrolledRoot = nullptr,
|
|
|
|
const nsIFrame* aOverrideActiveScrolledRoot = nullptr);
|
2012-09-13 03:34:34 -07:00
|
|
|
|
2009-09-12 15:44:18 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if images have been set to decode synchronously.
|
2009-09-12 15:44:18 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ShouldSyncDecodeImages() { return mSyncDecodeImages; }
|
2009-09-12 15:44:18 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetSyncDecodeImages(bool aSyncDecodeImages) {
|
2009-09-12 15:44:18 -07:00
|
|
|
mSyncDecodeImages = aSyncDecodeImages;
|
|
|
|
}
|
|
|
|
|
2009-09-12 15:44:18 -07:00
|
|
|
/**
|
|
|
|
* Helper method to generate background painting flags based on the
|
|
|
|
* information available in the display list builder. Currently only
|
|
|
|
* accounts for mSyncDecodeImages.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetBackgroundPaintFlags();
|
2009-09-12 15:44:18 -07:00
|
|
|
|
2009-08-13 19:09:51 -07: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
|
2011-05-13 09:40:46 -07:00
|
|
|
* get arbitrarily complex.
|
2009-08-13 19:09:51 -07:00
|
|
|
*/
|
|
|
|
void SubtractFromVisibleRegion(nsRegion* aVisibleRegion,
|
2011-05-13 09:40:46 -07:00
|
|
|
const nsRegion& aRegion);
|
2009-08-13 19:09:51 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2009-07-28 05:51:09 -07: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.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2009-07-28 05:51:09 -07:00
|
|
|
void MarkFramesForDisplayList(nsIFrame* aDirtyFrame,
|
|
|
|
const nsFrameList& aFrames,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect);
|
2012-05-11 00:49:14 -07:00
|
|
|
/**
|
|
|
|
* Mark all child frames that Preserve3D() as needing display.
|
|
|
|
* Because these frames include transforms set on their parent, dirty rects
|
|
|
|
* for intermediate frames may be empty, yet child frames could still be visible.
|
|
|
|
*/
|
|
|
|
void MarkPreserve3DFramesForDisplayList(nsIFrame* aDirtyFrame, const nsRect& aDirtyRect);
|
2010-05-20 20:20:48 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
/**
|
|
|
|
* Get the area of the final transparent region.
|
|
|
|
*/
|
|
|
|
const nsRegion* GetFinalTransparentRegion() { return mFinalTransparentRegion; }
|
|
|
|
/**
|
|
|
|
* Record the area of the final transparent region after all visibility
|
|
|
|
* calculations were performed.
|
|
|
|
*/
|
|
|
|
void SetFinalTransparentRegion(const nsRegion& aFinalTransparentRegion)
|
|
|
|
{
|
|
|
|
mFinalTransparentRegion = &aFinalTransparentRegion;
|
|
|
|
}
|
|
|
|
|
2011-01-15 01:40:33 -08:00
|
|
|
const nsTArray<ThemeGeometry>& GetThemeGeometries() { return mThemeGeometries; }
|
|
|
|
|
2010-12-07 05:54:50 -08:00
|
|
|
/**
|
|
|
|
* Returns true if we need to descend into this frame when building
|
|
|
|
* the display list, even though it doesn't intersect the dirty
|
|
|
|
* rect, because it may have out-of-flows that do so.
|
|
|
|
*/
|
|
|
|
bool ShouldDescendIntoFrame(nsIFrame* aFrame) const {
|
|
|
|
return
|
|
|
|
(aFrame->GetStateBits() & NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO) ||
|
|
|
|
GetIncludeAllOutOfFlows();
|
|
|
|
}
|
2011-01-11 05:03:16 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies the builder that a particular themed widget exists
|
|
|
|
* at the given rectangle within the currently built display list.
|
|
|
|
* For certain appearance values (currently only
|
2013-05-22 05:10:46 -07:00
|
|
|
* NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR and NS_THEME_TOOLBAR) this gets
|
|
|
|
* called during every display list construction, for every themed widget of
|
|
|
|
* the right type within the display list, except for themed widgets which
|
|
|
|
* are transformed or have effects applied to them (e.g. CSS opacity or
|
|
|
|
* filters).
|
2011-01-11 05:03:16 -08:00
|
|
|
*
|
|
|
|
* @param aWidgetType the -moz-appearance value for the themed widget
|
|
|
|
* @param aRect the device-pixel rect relative to the widget's displayRoot
|
|
|
|
* for the themed widget
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void RegisterThemeGeometry(uint8_t aWidgetType,
|
2011-01-11 05:03:16 -08:00
|
|
|
const nsIntRect& aRect) {
|
2011-01-15 01:40:33 -08:00
|
|
|
if (mIsPaintingToWindow && mPresShellStates.Length() == 1) {
|
2011-01-11 05:03:16 -08:00
|
|
|
ThemeGeometry geometry(aWidgetType, aRect);
|
2011-01-15 01:40:33 -08:00
|
|
|
mThemeGeometries.AppendElement(geometry);
|
2011-01-11 05:03:16 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07: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);
|
2013-04-14 22:11:10 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a new DisplayListClip in the arena. Will be cleaned up
|
|
|
|
* automatically when the arena goes away.
|
|
|
|
*/
|
2013-05-07 22:16:30 -07:00
|
|
|
const DisplayItemClip* AllocateDisplayItemClip(const DisplayItemClip& aOriginal);
|
2013-04-14 22:11:10 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* A helper class to temporarily set the value of
|
2012-07-25 00:06:19 -07:00
|
|
|
* mIsAtRootOfPseudoStackingContext and mIsInFixedPosition, and temporarily
|
|
|
|
* update mCachedOffsetFrame/mCachedOffset from a frame to its child.
|
2013-03-04 01:56:01 -08:00
|
|
|
* Also saves and restores mClipState.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-04-17 22:14:14 -07:00
|
|
|
class AutoBuildingDisplayList;
|
|
|
|
friend class AutoBuildingDisplayList;
|
|
|
|
class AutoBuildingDisplayList {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-04-17 22:14:14 -07:00
|
|
|
AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder, bool aIsRoot)
|
|
|
|
: mBuilder(aBuilder),
|
|
|
|
mPrevCachedOffsetFrame(aBuilder->mCachedOffsetFrame),
|
2012-09-16 03:32:59 -07:00
|
|
|
mPrevCachedReferenceFrame(aBuilder->mCachedReferenceFrame),
|
2012-04-17 22:14:14 -07:00
|
|
|
mPrevCachedOffset(aBuilder->mCachedOffset),
|
|
|
|
mPrevIsAtRootOfPseudoStackingContext(aBuilder->mIsAtRootOfPseudoStackingContext) {
|
|
|
|
aBuilder->mIsAtRootOfPseudoStackingContext = aIsRoot;
|
|
|
|
}
|
|
|
|
AutoBuildingDisplayList(nsDisplayListBuilder* aBuilder,
|
2012-07-25 00:06:19 -07:00
|
|
|
nsIFrame* aForChild, bool aIsRoot,
|
|
|
|
bool aIsInFixedPosition)
|
2012-04-17 22:14:14 -07:00
|
|
|
: mBuilder(aBuilder),
|
|
|
|
mPrevCachedOffsetFrame(aBuilder->mCachedOffsetFrame),
|
2012-09-16 03:32:59 -07:00
|
|
|
mPrevCachedReferenceFrame(aBuilder->mCachedReferenceFrame),
|
2012-04-17 22:14:14 -07:00
|
|
|
mPrevCachedOffset(aBuilder->mCachedOffset),
|
2012-07-25 00:06:19 -07:00
|
|
|
mPrevIsAtRootOfPseudoStackingContext(aBuilder->mIsAtRootOfPseudoStackingContext),
|
|
|
|
mPrevIsInFixedPosition(aBuilder->mIsInFixedPosition) {
|
2012-09-16 03:32:59 -07:00
|
|
|
if (aForChild->IsTransformed()) {
|
|
|
|
aBuilder->mCachedOffset = nsPoint();
|
|
|
|
aBuilder->mCachedReferenceFrame = aForChild;
|
|
|
|
} else if (mPrevCachedOffsetFrame == aForChild->GetParent()) {
|
2012-04-17 22:14:14 -07:00
|
|
|
aBuilder->mCachedOffset += aForChild->GetPosition();
|
|
|
|
} else {
|
2012-09-16 03:32:59 -07:00
|
|
|
aBuilder->mCachedOffset = aBuilder->ToReferenceFrame(aForChild);
|
2012-04-17 22:14:14 -07:00
|
|
|
}
|
|
|
|
aBuilder->mCachedOffsetFrame = aForChild;
|
2007-03-22 10:30:00 -07:00
|
|
|
aBuilder->mIsAtRootOfPseudoStackingContext = aIsRoot;
|
2012-07-25 00:06:19 -07:00
|
|
|
if (aIsInFixedPosition) {
|
|
|
|
aBuilder->mIsInFixedPosition = aIsInFixedPosition;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-04-17 22:14:14 -07:00
|
|
|
~AutoBuildingDisplayList() {
|
|
|
|
mBuilder->mCachedOffsetFrame = mPrevCachedOffsetFrame;
|
2012-09-16 03:32:59 -07:00
|
|
|
mBuilder->mCachedReferenceFrame = mPrevCachedReferenceFrame;
|
2012-04-17 22:14:14 -07:00
|
|
|
mBuilder->mCachedOffset = mPrevCachedOffset;
|
|
|
|
mBuilder->mIsAtRootOfPseudoStackingContext = mPrevIsAtRootOfPseudoStackingContext;
|
2012-07-25 00:06:19 -07:00
|
|
|
mBuilder->mIsInFixedPosition = mPrevIsInFixedPosition;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsDisplayListBuilder* mBuilder;
|
2012-04-17 22:14:14 -07:00
|
|
|
const nsIFrame* mPrevCachedOffsetFrame;
|
2012-09-16 03:32:59 -07:00
|
|
|
const nsIFrame* mPrevCachedReferenceFrame;
|
2012-04-17 22:14:14 -07:00
|
|
|
nsPoint mPrevCachedOffset;
|
|
|
|
bool mPrevIsAtRootOfPseudoStackingContext;
|
2012-07-25 00:06:19 -07:00
|
|
|
bool mPrevIsInFixedPosition;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
2009-07-21 17:45:14 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A helper class to temporarily set the value of mInTransform.
|
|
|
|
*/
|
|
|
|
class AutoInTransformSetter;
|
|
|
|
friend class AutoInTransformSetter;
|
|
|
|
class AutoInTransformSetter {
|
|
|
|
public:
|
2011-09-28 23:19:26 -07:00
|
|
|
AutoInTransformSetter(nsDisplayListBuilder* aBuilder, bool aInTransform)
|
2012-04-17 22:14:14 -07:00
|
|
|
: mBuilder(aBuilder), mOldValue(aBuilder->mInTransform) {
|
2009-07-21 17:45:14 -07:00
|
|
|
aBuilder->mInTransform = aInTransform;
|
|
|
|
}
|
|
|
|
~AutoInTransformSetter() {
|
|
|
|
mBuilder->mInTransform = mOldValue;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsDisplayListBuilder* mBuilder;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mOldValue;
|
2012-04-17 22:14:14 -07:00
|
|
|
};
|
|
|
|
|
2008-04-06 04:34:14 -07:00
|
|
|
// Helpers for tables
|
|
|
|
nsDisplayTableItem* GetCurrentTableItem() { return mCurrentTableItem; }
|
|
|
|
void SetCurrentTableItem(nsDisplayTableItem* aTableItem) { mCurrentTableItem = aTableItem; }
|
|
|
|
|
2013-03-04 01:56:02 -08:00
|
|
|
struct OutOfFlowDisplayData {
|
|
|
|
OutOfFlowDisplayData(const DisplayItemClip* aContainingBlockClip,
|
|
|
|
const nsRect &aDirtyRect)
|
|
|
|
: mContainingBlockClip(aContainingBlockClip)
|
|
|
|
, mDirtyRect(aDirtyRect)
|
|
|
|
{}
|
|
|
|
const DisplayItemClip* mContainingBlockClip;
|
|
|
|
nsRect mDirtyRect;
|
|
|
|
};
|
|
|
|
static void DestroyOutOfFlowDisplayData(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<OutOfFlowDisplayData*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(OutOfFlowDisplayDataProperty, DestroyOutOfFlowDisplayData)
|
2012-05-11 00:49:14 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(Preserve3DDirtyRectProperty, nsIFrame::DestroyRect)
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2011-01-04 02:39:47 -08:00
|
|
|
nsPresContext* CurrentPresContext() {
|
|
|
|
return CurrentPresShellState()->mPresShell->GetPresContext();
|
|
|
|
}
|
|
|
|
|
2011-05-13 09:40:46 -07:00
|
|
|
/**
|
|
|
|
* Accumulates the bounds of box frames that have moz-appearance
|
|
|
|
* -moz-win-exclude-glass style. Used in setting glass margins on
|
|
|
|
* Windows.
|
|
|
|
*/
|
|
|
|
void AddExcludedGlassRegion(nsRect &bounds) {
|
|
|
|
mExcludedGlassRegion.Or(mExcludedGlassRegion, bounds);
|
|
|
|
}
|
|
|
|
const nsRegion& GetExcludedGlassRegion() {
|
|
|
|
return mExcludedGlassRegion;
|
|
|
|
}
|
2012-05-02 21:29:05 -07:00
|
|
|
void SetGlassDisplayItem(nsDisplayItem* aItem) {
|
|
|
|
if (mGlassDisplayItem) {
|
|
|
|
// Web pages or extensions could trigger this by using
|
|
|
|
// -moz-appearance:win-borderless-glass etc on their own elements.
|
|
|
|
// Keep the first one, since that will be the background of the root
|
|
|
|
// window
|
|
|
|
NS_WARNING("Multiple glass backgrounds found?");
|
|
|
|
} else {
|
|
|
|
mGlassDisplayItem = aItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool NeedToForceTransparentSurfaceForItem(nsDisplayItem* aItem) {
|
|
|
|
return aItem == mGlassDisplayItem;
|
|
|
|
}
|
2011-05-13 09:40:46 -07:00
|
|
|
|
2012-10-17 22:34:58 -07:00
|
|
|
void SetContainsPluginItem() { mContainsPluginItem = true; }
|
|
|
|
bool ContainsPluginItem() { return mContainsPluginItem; }
|
|
|
|
|
2013-03-04 01:56:01 -08:00
|
|
|
DisplayListClipState& ClipState() { return mClipState; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2011-04-08 09:35:16 -07:00
|
|
|
void MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame, nsIFrame* aFrame,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
|
2008-01-03 17:53:01 -08:00
|
|
|
struct PresShellState {
|
|
|
|
nsIPresShell* mPresShell;
|
|
|
|
nsIFrame* mCaretFrame;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mFirstFrameMarkedForDisplay;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsBackgroundOnly;
|
2008-01-03 17:53:01 -08:00
|
|
|
};
|
|
|
|
PresShellState* CurrentPresShellState() {
|
|
|
|
NS_ASSERTION(mPresShellStates.Length() > 0,
|
|
|
|
"Someone forgot to enter a presshell");
|
|
|
|
return &mPresShellStates[mPresShellStates.Length() - 1];
|
|
|
|
}
|
2010-05-20 20:20:48 -07:00
|
|
|
|
2008-01-03 17:53:01 -08:00
|
|
|
nsIFrame* mReferenceFrame;
|
|
|
|
nsIFrame* mIgnoreScrollFrame;
|
|
|
|
PLArenaPool mPool;
|
|
|
|
nsCOMPtr<nsISelection> mBoundingSelection;
|
|
|
|
nsAutoTArray<PresShellState,8> mPresShellStates;
|
|
|
|
nsAutoTArray<nsIFrame*,100> mFramesMarkedForDisplay;
|
2011-01-15 01:40:33 -08:00
|
|
|
nsAutoTArray<ThemeGeometry,2> mThemeGeometries;
|
2008-04-06 04:34:14 -07:00
|
|
|
nsDisplayTableItem* mCurrentTableItem;
|
2013-03-04 01:56:01 -08:00
|
|
|
DisplayListClipState mClipState;
|
2011-01-02 17:48:09 -08:00
|
|
|
const nsRegion* mFinalTransparentRegion;
|
2012-04-17 22:14:14 -07:00
|
|
|
// When mCachedOffsetFrame is non-null, mCachedOffset is the offset from
|
|
|
|
// mCachedOffsetFrame to mReferenceFrame.
|
|
|
|
const nsIFrame* mCachedOffsetFrame;
|
2012-09-16 03:32:59 -07:00
|
|
|
const nsIFrame* mCachedReferenceFrame;
|
2012-04-17 22:14:14 -07:00
|
|
|
nsPoint mCachedOffset;
|
2011-05-13 05:23:19 -07:00
|
|
|
nsRect mDisplayPort;
|
2011-05-13 09:40:46 -07:00
|
|
|
nsRegion mExcludedGlassRegion;
|
2012-05-02 21:29:05 -07:00
|
|
|
// The display item for the Windows window glass background, if any
|
|
|
|
nsDisplayItem* mGlassDisplayItem;
|
2013-04-14 22:11:10 -07:00
|
|
|
nsTArray<DisplayItemClip*> mDisplayItemClipsToDestroy;
|
2010-11-08 01:06:14 -08:00
|
|
|
Mode mMode;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mBuildCaret;
|
|
|
|
bool mIgnoreSuppression;
|
|
|
|
bool mHadToIgnoreSuppression;
|
|
|
|
bool mIsAtRootOfPseudoStackingContext;
|
|
|
|
bool mIncludeAllOutOfFlows;
|
|
|
|
bool mSelectedFramesOnly;
|
|
|
|
bool mAccurateVisibleRegions;
|
2012-10-06 06:03:23 -07:00
|
|
|
bool mAllowMergingAndFlattening;
|
|
|
|
bool mWillComputePluginGeometry;
|
2009-07-21 17:45:14 -07:00
|
|
|
// True when we're building a display list that's directly or indirectly
|
|
|
|
// under an nsDisplayTransform
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInTransform;
|
|
|
|
bool mSyncDecodeImages;
|
|
|
|
bool mIsPaintingToWindow;
|
|
|
|
bool mHasDisplayPort;
|
|
|
|
bool mHasFixedItems;
|
2012-07-25 00:06:19 -07:00
|
|
|
bool mIsInFixedPosition;
|
2012-07-22 20:00:36 -07:00
|
|
|
bool mIsCompositingCheap;
|
2012-10-17 22:34:58 -07:00
|
|
|
bool mContainsPluginItem;
|
2007-03-22 10:30:00 -07: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 {
|
|
|
|
// This is never instantiated directly, so no need to count constructors and
|
|
|
|
// destructors.
|
|
|
|
protected:
|
2012-07-30 07:20:58 -07:00
|
|
|
nsDisplayItemLink() : mAbove(nullptr) {}
|
2007-03-22 10:30:00 -07: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:
|
2012-05-03 07:05:55 -07:00
|
|
|
typedef mozilla::FrameLayerBuilder::ContainerParameters ContainerParameters;
|
2013-03-04 01:56:02 -08:00
|
|
|
typedef mozilla::DisplayItemClip DisplayItemClip;
|
2011-01-13 09:45:14 -08:00
|
|
|
typedef mozilla::layers::FrameMetrics::ViewID ViewID;
|
2010-02-28 23:56:19 -08:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
2010-07-15 14:08:05 -07:00
|
|
|
typedef mozilla::LayerState LayerState;
|
2010-02-28 23:56:19 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// This is never instantiated directly (it has pure virtual methods), so no
|
|
|
|
// need to count constructors and destructors.
|
2012-03-01 00:26:09 -08:00
|
|
|
nsDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: mFrame(aFrame)
|
2013-03-04 01:56:02 -08:00
|
|
|
, mClip(aBuilder->ClipState().GetCurrentCombinedClip(aBuilder))
|
2012-03-01 00:26:09 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
, mPainted(false)
|
|
|
|
#endif
|
|
|
|
{
|
2013-03-04 01:56:02 -08:00
|
|
|
mReferenceFrame = aBuilder->FindReferenceFrameFor(aFrame);
|
|
|
|
mToReferenceFrame = aBuilder->ToReferenceFrame(aFrame);
|
2010-08-13 03:01:13 -07:00
|
|
|
}
|
2012-04-17 22:14:14 -07:00
|
|
|
nsDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
2012-09-16 03:32:59 -07:00
|
|
|
const nsIFrame* aReferenceFrame,
|
2012-04-17 22:14:14 -07:00
|
|
|
const nsPoint& aToReferenceFrame)
|
|
|
|
: mFrame(aFrame)
|
2013-03-04 01:56:02 -08:00
|
|
|
, mClip(aBuilder->ClipState().GetCurrentCombinedClip(aBuilder))
|
2012-09-16 03:32:59 -07:00
|
|
|
, mReferenceFrame(aReferenceFrame)
|
2012-04-17 22:14:14 -07:00
|
|
|
, mToReferenceFrame(aToReferenceFrame)
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
, mPainted(false)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
}
|
2013-03-04 01:56:02 -08:00
|
|
|
/**
|
|
|
|
* This constructor is only used in rare cases when we need to construct
|
|
|
|
* temporary items.
|
|
|
|
*/
|
|
|
|
nsDisplayItem(nsIFrame* aFrame)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
, mClip(nullptr)
|
|
|
|
, mReferenceFrame(nullptr)
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
, mPainted(false)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
}
|
2013-04-14 22:11:10 -07:00
|
|
|
virtual ~nsDisplayItem() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void* operator new(size_t aSize,
|
|
|
|
nsDisplayListBuilder* aBuilder) CPP_THROW_NEW {
|
|
|
|
return aBuilder->Allocate(aSize);
|
|
|
|
}
|
|
|
|
|
2010-07-15 14:07:49 -07:00
|
|
|
// Contains all the type integers for each display list item type
|
|
|
|
#include "nsDisplayItemTypes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-03 18:08:29 -08:00
|
|
|
struct HitTestState {
|
2011-01-13 09:45:14 -08:00
|
|
|
typedef nsTArray<ViewID> ShadowArray;
|
|
|
|
|
|
|
|
HitTestState(ShadowArray* aShadows = NULL)
|
|
|
|
: mShadows(aShadows) {
|
|
|
|
}
|
|
|
|
|
2008-01-03 18:08:29 -08:00
|
|
|
~HitTestState() {
|
|
|
|
NS_ASSERTION(mItemBuffer.Length() == 0,
|
|
|
|
"mItemBuffer should have been cleared");
|
|
|
|
}
|
2011-01-13 09:45:14 -08:00
|
|
|
|
2008-01-03 18:08:29 -08:00
|
|
|
nsAutoTArray<nsDisplayItem*, 100> mItemBuffer;
|
2011-01-13 09:45:14 -08:00
|
|
|
|
|
|
|
// It is sometimes useful to hit test for frames that are not in this
|
|
|
|
// process. Display items may append IDs into this array if it is
|
|
|
|
// non-null.
|
|
|
|
ShadowArray* mShadows;
|
2008-01-03 18:08:29 -08:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07: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
|
2010-07-15 14:07:49 -07:00
|
|
|
* identify their type. We use the type for other purposes too.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-07-15 14:07:49 -07:00
|
|
|
virtual Type GetType() = 0;
|
2010-07-15 14:07:49 -07:00
|
|
|
/**
|
2013-03-04 01:56:02 -08:00
|
|
|
* Pairing this with the GetUnderlyingFrame() pointer gives a key that
|
|
|
|
* uniquely identifies this display item in the display item tree.
|
|
|
|
* XXX check ScrollLayerWrapper/nsOptionEventGrabberWrapper/nsXULEventRedirectorWrapper
|
2010-07-15 14:07:49 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetPerFrameKey() { return uint32_t(GetType()); }
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* This is called after we've constructed a display list for event handling.
|
2010-06-05 13:29:49 -07:00
|
|
|
* When this is called, we've already ensured that aRect intersects the
|
2013-03-04 01:56:02 -08:00
|
|
|
* item's bounds and that clipping has been taking into account.
|
2011-09-08 04:15:00 -07:00
|
|
|
*
|
|
|
|
* @param aRect the point or rect being tested, relative to the reference
|
|
|
|
* frame. If the width and height are both 1 app unit, it indicates we're
|
|
|
|
* hit testing a point, not a rect.
|
2008-01-03 18:08:29 -08: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-05 13:29:49 -07:00
|
|
|
* @param aOutFrames each item appends the frame(s) in this display item that
|
|
|
|
* the rect is considered over (if any) to aOutFrames.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* @return the frame that this display item is based on. This is used to sort
|
2013-03-04 01:56:02 -08:00
|
|
|
* items by z-index and content order and for some other uses. Never
|
|
|
|
* returns null.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-04-19 05:02:13 -07:00
|
|
|
inline nsIFrame* Frame() const { return mFrame; }
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* The default bounds is the frame border rect.
|
2012-04-10 04:24:18 -07:00
|
|
|
* @param aSnap *aSnap is set to true if the returned rect will be
|
|
|
|
* snapped to nearest device pixel edges during actual drawing.
|
|
|
|
* It might be set to false and snap anyway, so code computing the set of
|
|
|
|
* pixels affected by this display item needs to round outwards to pixel
|
|
|
|
* boundaries when *aSnap is set to false.
|
2013-03-04 01:56:02 -08:00
|
|
|
* This does not take the item's clipping into account.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return a rectangle relative to aBuilder->ReferenceFrame() that
|
|
|
|
* contains the area drawn by this display item
|
|
|
|
*/
|
2012-04-10 04:24:18 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
|
|
|
|
{
|
|
|
|
*aSnap = false;
|
2013-04-19 05:02:13 -07:00
|
|
|
return nsRect(ToReferenceFrame(), Frame()->GetSize());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-03-04 01:56:02 -08:00
|
|
|
/**
|
|
|
|
* Returns the result of GetBounds intersected with the item's clip.
|
|
|
|
* The intersection is approximate since rounded corners are not taking into
|
|
|
|
* account.
|
|
|
|
*/
|
|
|
|
nsRect GetClippedBounds(nsDisplayListBuilder* aBuilder);
|
2012-08-28 22:39:01 -07:00
|
|
|
nsRect GetBorderRect() {
|
2013-04-19 05:02:13 -07:00
|
|
|
return nsRect(ToReferenceFrame(), Frame()->GetSize());
|
2012-08-28 22:39:01 -07:00
|
|
|
}
|
|
|
|
nsRect GetPaddingRect() {
|
2013-04-19 05:02:13 -07:00
|
|
|
return Frame()->GetPaddingRectRelativeToSelf() + ToReferenceFrame();
|
2012-08-28 22:39:01 -07:00
|
|
|
}
|
|
|
|
nsRect GetContentRect() {
|
2013-04-19 05:02:13 -07:00
|
|
|
return Frame()->GetContentRectRelativeToSelf() + ToReferenceFrame();
|
2012-08-28 22:39:01 -07:00
|
|
|
}
|
|
|
|
|
2012-08-28 22:47:15 -07:00
|
|
|
/**
|
|
|
|
* Checks if the frame(s) owning this display item have been marked as invalid,
|
|
|
|
* and needing repainting.
|
|
|
|
*/
|
2012-08-28 22:48:45 -07:00
|
|
|
virtual bool IsInvalid(nsRect& aRect) {
|
|
|
|
bool result = mFrame ? mFrame->IsInvalid(aRect) : false;
|
|
|
|
aRect += ToReferenceFrame();
|
|
|
|
return result;
|
|
|
|
}
|
2012-08-28 22:47:15 -07:00
|
|
|
|
2012-08-28 22:39:01 -07:00
|
|
|
/**
|
|
|
|
* Creates and initializes an nsDisplayItemGeometry object that retains the current
|
|
|
|
* areas covered by this display item. These need to retain enough information
|
|
|
|
* such that they can be compared against a future nsDisplayItem of the same type,
|
|
|
|
* and determine if repainting needs to happen.
|
|
|
|
*
|
|
|
|
* Subclasses wishing to store more information need to override both this
|
|
|
|
* and ComputeInvalidationRegion, as well as implementing an nsDisplayItemGeometry
|
|
|
|
* subclass.
|
|
|
|
*
|
|
|
|
* The default implementation tracks both the display item bounds, and the frame's
|
|
|
|
* border rect.
|
|
|
|
*/
|
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
|
|
|
return new nsDisplayItemGenericGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares an nsDisplayItemGeometry object from a previous paint against the
|
|
|
|
* current item. Computes if the geometry of the item has changed, and the
|
|
|
|
* invalidation area required for correct repainting.
|
|
|
|
*
|
|
|
|
* The existing geometry will have been created from a display item with a
|
|
|
|
* matching GetPerFrameKey()/mFrame pair to the current item.
|
|
|
|
*
|
|
|
|
* The default implementation compares the display item bounds, and the frame's
|
|
|
|
* border rect, and invalidates the entire bounds if either rect changes.
|
|
|
|
*
|
|
|
|
* @param aGeometry The geometry of the matching display item from the
|
|
|
|
* previous paint.
|
|
|
|
* @param aInvalidRegion Output param, the region to invalidate, or
|
|
|
|
* unchanged if none.
|
|
|
|
*/
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion)
|
|
|
|
{
|
|
|
|
const nsDisplayItemGenericGeometry* geometry = static_cast<const nsDisplayItemGenericGeometry*>(aGeometry);
|
|
|
|
bool snap;
|
|
|
|
if (!geometry->mBounds.IsEqualInterior(GetBounds(aBuilder, &snap)) ||
|
|
|
|
!geometry->mBorderRect.IsEqualInterior(GetBorderRect())) {
|
|
|
|
aInvalidRegion->Or(GetBounds(aBuilder, &snap), geometry->mBounds);
|
|
|
|
}
|
|
|
|
}
|
2012-12-09 21:34:31 -08:00
|
|
|
|
2013-03-07 18:15:10 -08:00
|
|
|
/**
|
|
|
|
* An alternative default implementation of ComputeInvalidationRegion,
|
|
|
|
* that instead invalidates only the changed area between the two items.
|
|
|
|
*/
|
|
|
|
void ComputeInvalidationRegionDifference(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemBoundsGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion)
|
|
|
|
{
|
|
|
|
bool snap;
|
|
|
|
nsRect bounds = GetBounds(aBuilder, &snap);
|
|
|
|
|
|
|
|
if (!aGeometry->mBounds.IsEqualInterior(bounds)) {
|
|
|
|
nscoord radii[8];
|
|
|
|
if (aGeometry->mHasRoundedCorners ||
|
2013-04-19 05:02:13 -07:00
|
|
|
Frame()->GetBorderRadii(radii)) {
|
2013-03-07 18:15:10 -08:00
|
|
|
aInvalidRegion->Or(aGeometry->mBounds, bounds);
|
|
|
|
} else {
|
|
|
|
aInvalidRegion->Xor(aGeometry->mBounds, bounds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-09 21:34:31 -08:00
|
|
|
/**
|
|
|
|
* Called when the area rendered by this display item has changed (been
|
|
|
|
* invalidated or changed geometry) since the last paint. This includes
|
|
|
|
* when the display item was not rendered at all in the last paint.
|
|
|
|
* It does NOT get called when a display item was being rendered and no
|
|
|
|
* longer is, because generally that means there is no display item to
|
|
|
|
* call this method on.
|
|
|
|
*/
|
|
|
|
virtual void NotifyRenderingChanged() {}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2012-04-10 04:24:18 -07:00
|
|
|
* @param aSnap set to true if the edges of the rectangles of the opaque
|
|
|
|
* region would be snapped to device pixels when drawing
|
2012-04-10 21:48:37 -07:00
|
|
|
* @return a region of the item that is opaque --- that is, every pixel
|
|
|
|
* that is visible (according to ComputeVisibility) is painted with an opaque
|
|
|
|
* color. This is useful for determining when one piece
|
2011-06-16 04:06:05 -07:00
|
|
|
* of content completely obscures another so that we can do occlusion
|
|
|
|
* culling.
|
2013-03-04 01:56:02 -08:00
|
|
|
* This does not take clipping into account.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2012-05-02 21:29:05 -07:00
|
|
|
bool* aSnap)
|
2010-10-19 10:02:25 -07:00
|
|
|
{
|
2012-04-10 04:24:18 -07:00
|
|
|
*aSnap = false;
|
2011-01-02 17:48:09 -08:00
|
|
|
return nsRegion();
|
2010-10-19 10:02:25 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2010-05-12 17:56:11 -07:00
|
|
|
* If this returns true, then aColor is set to the uniform color
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the item is guaranteed to paint every pixel in its
|
2007-03-22 10:30:00 -07:00
|
|
|
* bounds with the same (possibly translucent) color
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) { return false; }
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return false if the painting performed by the item is invariant
|
2010-08-13 02:54:37 -07:00
|
|
|
* when the item's underlying frame is moved relative to aFrame.
|
2010-07-15 14:08:12 -07:00
|
|
|
* In other words, if you render the item at locations P and P', the rendering
|
|
|
|
* only differs by the translation.
|
2011-10-17 07:59:28 -07:00
|
|
|
* It return true for all wrapped lists.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsVaryingRelativeToMovingFrame(nsDisplayListBuilder* aBuilder,
|
2010-08-13 02:54:37 -07:00
|
|
|
nsIFrame* aFrame)
|
2011-10-17 07:59:28 -07:00
|
|
|
{ return false; }
|
2010-07-15 14:08:06 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the contents of this item are rendered fixed relative
|
2010-07-15 14:08:12 -07:00
|
|
|
* to the nearest viewport *and* they cover the viewport's scrollport.
|
|
|
|
* Only return true if the contents actually vary when scrolling in the viewport.
|
2010-07-15 14:08:06 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder)
|
2011-10-17 07:59:28 -07:00
|
|
|
{ return false; }
|
2010-07-15 14:08:05 -07:00
|
|
|
|
2012-11-22 15:29:05 -08:00
|
|
|
/**
|
|
|
|
* Returns true if all layers that can be active should be forced to be
|
|
|
|
* active. Requires setting the pref layers.force-active=true.
|
|
|
|
*/
|
|
|
|
static bool ForceActiveLayers();
|
|
|
|
|
2010-07-15 14:08:05 -07:00
|
|
|
/**
|
|
|
|
* @return LAYER_NONE if BuildLayer will return null. In this case
|
|
|
|
* there is no layer for the item, and Paint should be called instead
|
|
|
|
* to paint the content using Thebes.
|
|
|
|
* Return LAYER_INACTIVE if there is a layer --- BuildLayer will
|
|
|
|
* not return null (unless there's an error) --- but the layer contents
|
|
|
|
* are not changing frequently. In this case it makes sense to composite
|
|
|
|
* the layer into a ThebesLayer with other content, so we don't have to
|
|
|
|
* recomposite it every time we paint.
|
|
|
|
* Note: GetLayerState is only allowed to return LAYER_INACTIVE if all
|
|
|
|
* descendant display items returned LAYER_INACTIVE or LAYER_NONE. Also,
|
|
|
|
* all descendant display item frames must have an active scrolled root
|
|
|
|
* that's either the same as this item's frame's active scrolled root, or
|
|
|
|
* a descendant of this item's frame. This ensures that the entire
|
|
|
|
* set of display items can be collapsed onto a single ThebesLayer.
|
|
|
|
* Return LAYER_ACTIVE if the layer is active, that is, its contents are
|
|
|
|
* changing frequently. In this case it makes sense to keep the layer
|
|
|
|
* as a separate buffer in VRAM and composite it into the destination
|
|
|
|
* every time we paint.
|
2012-11-22 15:29:05 -08:00
|
|
|
*
|
|
|
|
* Users of GetLayerState should check ForceActiveLayers() and if it returns
|
|
|
|
* true, change a returned value of LAYER_INACTIVE to LAYER_ACTIVE.
|
2010-07-15 14:08:05 -07:00
|
|
|
*/
|
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 07:05:55 -07:00
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerParameters& aParameters)
|
2010-07-15 14:08:05 -07:00
|
|
|
{ return mozilla::LAYER_NONE; }
|
2013-03-19 06:08:29 -07:00
|
|
|
/**
|
|
|
|
* Return true to indicate the layer should be constructed even if it's
|
|
|
|
* completely invisible.
|
|
|
|
*/
|
|
|
|
virtual bool ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder)
|
|
|
|
{ return false; }
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Actually paint this item to some rendering context.
|
2009-09-06 17:35:14 -07:00
|
|
|
* Content outside mVisibleRect need not be painted.
|
2010-03-01 00:03:49 -08:00
|
|
|
* aCtx must be set up as for nsDisplayList::Paint.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) {}
|
2012-03-01 00:26:09 -08:00
|
|
|
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
/**
|
|
|
|
* Mark this display item as being painted via FrameLayerBuilder::DrawThebesLayer.
|
|
|
|
*/
|
|
|
|
bool Painted() { return mPainted; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if this display item has been painted.
|
|
|
|
*/
|
|
|
|
void SetPainted() { mPainted = true; }
|
|
|
|
#endif
|
|
|
|
|
2010-02-28 23:56:19 -08:00
|
|
|
/**
|
2010-07-15 14:08:05 -07:00
|
|
|
* Get the layer drawn by this display item. Call this only if
|
|
|
|
* GetLayerState() returns something other than LAYER_NONE.
|
|
|
|
* If GetLayerState returned LAYER_NONE then Paint will be called
|
|
|
|
* instead.
|
2010-02-28 23:56:19 -08:00
|
|
|
* This is called while aManager is in the construction phase.
|
|
|
|
*
|
|
|
|
* The caller (nsDisplayList) is responsible for setting the visible
|
|
|
|
* region of the layer.
|
2011-06-22 05:11:27 -07:00
|
|
|
*
|
|
|
|
* @param aContainerParameters should be passed to
|
|
|
|
* FrameLayerBuilder::BuildContainerLayerFor if a ContainerLayer is
|
|
|
|
* constructed.
|
2010-02-28 23:56:19 -08:00
|
|
|
*/
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 05:11:27 -07:00
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerParameters& aContainerParameters)
|
2012-07-30 07:20:58 -07:00
|
|
|
{ return nullptr; }
|
2007-03-22 10:30:00 -07: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.
|
2011-01-02 17:48:09 -08:00
|
|
|
* nsDisplayList::ComputeVisibility automatically subtracts the region
|
|
|
|
* returned by GetOpaqueRegion, and automatically removes items whose bounds
|
|
|
|
* do not intersect the visible area, so implementations of
|
|
|
|
* nsDisplayItem::ComputeVisibility do not need to do these things.
|
2009-09-06 17:35:14 -07:00
|
|
|
* nsDisplayList::ComputeVisibility will already have set mVisibleRect on
|
2010-12-31 14:48:47 -08:00
|
|
|
* this item to the intersection of *aVisibleRegion and this item's bounds.
|
2010-08-27 16:15:08 -07:00
|
|
|
* We rely on that, so this should only be called by
|
|
|
|
* nsDisplayList::ComputeVisibility or nsDisplayItem::RecomputeVisibility.
|
2011-02-16 14:43:30 -08:00
|
|
|
* aAllowVisibleRegionExpansion is a rect where we are allowed to
|
|
|
|
* expand the visible region and is only used for making sure the
|
|
|
|
* background behind a plugin is visible.
|
2012-10-06 06:03:23 -07:00
|
|
|
* This method needs to be idempotent.
|
2011-02-16 14:43:30 -08:00
|
|
|
*
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the item is visible, false if no part of the item
|
2011-05-13 09:40:46 -07:00
|
|
|
* is visible.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2011-05-13 09:40:46 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion)
|
2010-07-15 14:08:09 -07:00
|
|
|
{ return !mVisibleRect.IsEmpty(); }
|
2009-10-06 21:28:41 -07:00
|
|
|
|
2007-03-22 10:30:00 -07: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).
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if the merge was successful and the other item should be deleted
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-05-01 18:53:01 -07:00
|
|
|
|
2012-04-16 22:44:32 -07:00
|
|
|
/**
|
|
|
|
* Appends the underlying frames of all display items that have been
|
|
|
|
* merged into this one (excluding this item's own underlying frame)
|
|
|
|
* to aFrames.
|
|
|
|
*/
|
|
|
|
virtual void GetMergedFrames(nsTArray<nsIFrame*>* aFrames) {}
|
|
|
|
|
2011-05-01 18:53:01 -07:00
|
|
|
/**
|
|
|
|
* During the visibility computation and after TryMerge, display lists may
|
2011-10-17 07:59:28 -07:00
|
|
|
* return true here to flatten themselves away, removing them. This
|
2011-05-01 18:53:01 -07:00
|
|
|
* flattening is distinctly different from FlattenTo, which occurs before
|
|
|
|
* items are merged together.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-05-01 18:53:01 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2012-11-02 05:59:03 -07:00
|
|
|
* If this has a child list where the children are in the same coordinate
|
|
|
|
* system as this item (i.e., they have the same reference frame),
|
|
|
|
* return the list.
|
|
|
|
*/
|
|
|
|
virtual nsDisplayList* GetSameCoordinateSystemChildren() { return nullptr; }
|
2013-03-04 01:56:02 -08:00
|
|
|
virtual void UpdateBounds(nsDisplayListBuilder* aBuilder) {}
|
2012-11-02 05:59:03 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this has a child list, return it, even if the children are in
|
|
|
|
* a different coordinate system to this item.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-11-02 05:59:03 -07:00
|
|
|
virtual nsDisplayList* GetChildren() { return nullptr; }
|
2010-05-12 17:56:11 -07:00
|
|
|
|
2010-05-20 20:20:48 -07:00
|
|
|
/**
|
|
|
|
* Returns the visible rect. Should only be called after ComputeVisibility
|
|
|
|
* has happened.
|
|
|
|
*/
|
2010-05-12 17:56:11 -07:00
|
|
|
const nsRect& GetVisibleRect() { return mVisibleRect; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* For debugging and stuff
|
|
|
|
*/
|
|
|
|
virtual const char* Name() = 0;
|
2013-01-29 21:07:30 -08:00
|
|
|
|
|
|
|
virtual void WriteDebugInfo(FILE *aOutput) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
nsDisplayItem* GetAbove() { return mAbove; }
|
2010-07-15 14:07:51 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Like ComputeVisibility, but does the work that nsDisplayList
|
|
|
|
* does per-item:
|
|
|
|
* -- Intersects GetBounds with aVisibleRegion and puts the result
|
|
|
|
* in mVisibleRect
|
|
|
|
* -- Subtracts bounds from aVisibleRegion if the item is opaque
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool RecomputeVisibility(nsDisplayListBuilder* aBuilder,
|
2010-07-15 14:07:51 -07:00
|
|
|
nsRegion* aVisibleRegion);
|
|
|
|
|
2010-08-13 03:01:58 -07:00
|
|
|
/**
|
|
|
|
* Returns the result of aBuilder->ToReferenceFrame(GetUnderlyingFrame())
|
|
|
|
*/
|
2011-06-22 11:11:48 -07:00
|
|
|
const nsPoint& ToReferenceFrame() const {
|
2010-08-13 03:01:13 -07:00
|
|
|
NS_ASSERTION(mFrame, "No frame?");
|
|
|
|
return mToReferenceFrame;
|
|
|
|
}
|
2012-09-16 03:32:59 -07:00
|
|
|
/**
|
|
|
|
* @return the root of the display list's frame (sub)tree, whose origin
|
|
|
|
* establishes the coordinate system for the display list
|
|
|
|
*/
|
|
|
|
const nsIFrame* ReferenceFrame() const { return mReferenceFrame; }
|
2010-08-13 03:01:13 -07:00
|
|
|
|
2012-10-15 18:10:48 -07:00
|
|
|
/**
|
|
|
|
* Returns the reference frame for display item children of this item.
|
|
|
|
*/
|
|
|
|
virtual const nsIFrame* ReferenceFrameForChildren() const { return mReferenceFrame; }
|
|
|
|
|
2010-10-10 17:58:20 -07:00
|
|
|
/**
|
2011-01-02 17:48:09 -08:00
|
|
|
* Checks if this display item (or any children) contains content that might
|
|
|
|
* be rendered with component alpha (e.g. subpixel antialiasing). Returns the
|
|
|
|
* bounds of the area that needs component alpha, or an empty rect if nothing
|
|
|
|
* in the item does.
|
2010-10-10 17:58:20 -07:00
|
|
|
*/
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder) { return nsRect(); }
|
2010-10-10 17:58:20 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
/**
|
|
|
|
* Disable usage of component alpha. Currently only relevant for items that have text.
|
|
|
|
*/
|
|
|
|
virtual void DisableComponentAlpha() {}
|
|
|
|
|
2012-08-22 23:05:27 -07:00
|
|
|
/**
|
|
|
|
* Check if we can add async animations to the layer for this display item.
|
|
|
|
*/
|
|
|
|
virtual bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-18 19:28:18 -08:00
|
|
|
|
|
|
|
virtual bool SupportsOptimizingToImage() { return false; }
|
2012-08-22 23:05:27 -07:00
|
|
|
|
2013-03-04 01:56:02 -08:00
|
|
|
const DisplayItemClip& GetClip()
|
|
|
|
{
|
|
|
|
return mClip ? *mClip : DisplayItemClip::NoClip();
|
|
|
|
}
|
|
|
|
void SetClip(nsDisplayListBuilder* aBuilder, const DisplayItemClip& aClip)
|
|
|
|
{
|
|
|
|
if (!aClip.HasClip()) {
|
|
|
|
mClip = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
2013-04-14 22:11:10 -07:00
|
|
|
mClip = aBuilder->AllocateDisplayItemClip(aClip);
|
2013-03-04 01:56:02 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
friend class nsDisplayList;
|
2012-08-22 23:05:27 -07:00
|
|
|
|
2013-03-04 01:56:02 -08:00
|
|
|
nsDisplayItem() { mAbove = nullptr; }
|
2012-08-22 23:05:27 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* mFrame;
|
2013-03-04 01:56:02 -08:00
|
|
|
const DisplayItemClip* mClip;
|
2012-09-16 03:32:59 -07:00
|
|
|
// Result of FindReferenceFrameFor(mFrame), if mFrame is non-null
|
|
|
|
const nsIFrame* mReferenceFrame;
|
2010-08-13 03:01:13 -07:00
|
|
|
// Result of ToReferenceFrame(mFrame), if mFrame is non-null
|
|
|
|
nsPoint mToReferenceFrame;
|
2009-09-06 17:35:14 -07: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;
|
2012-03-01 00:26:09 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
// True if this frame has been painted.
|
|
|
|
bool mPainted;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07: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-06 17:35:14 -07:00
|
|
|
* (HitTest(), ComputeVisibility()) internally build a temporary array of all
|
2007-03-22 10:30:00 -07: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-02-28 23:56:19 -08:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
typedef mozilla::layers::ThebesLayer ThebesLayer;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Create an empty list.
|
|
|
|
*/
|
2010-02-28 23:56:19 -08:00
|
|
|
nsDisplayList() :
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsOpaque(false)
|
2010-02-28 23:56:19 -08:00
|
|
|
{
|
2009-09-06 17:35:14 -07:00
|
|
|
mTop = &mSentinel;
|
2012-07-30 07:20:58 -07:00
|
|
|
mSentinel.mAbove = nullptr;
|
2009-09-06 17:35:14 -07:00
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
mDidComputeVisibility = false;
|
2009-09-06 17:35:14 -07:00
|
|
|
#endif
|
|
|
|
}
|
2007-03-22 10:30:00 -07: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 ...);
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void AppendNewToTop(nsDisplayItem* aItem) {
|
|
|
|
if (aItem) {
|
|
|
|
AppendToTop(aItem);
|
|
|
|
}
|
2007-03-22 10:30:00 -07: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 ...);
|
|
|
|
*/
|
2013-02-14 03:12:27 -08:00
|
|
|
void AppendNewToBottom(nsDisplayItem* aItem) {
|
|
|
|
if (aItem) {
|
|
|
|
AppendToBottom(aItem);
|
|
|
|
}
|
2007-03-22 10:30:00 -07: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;
|
2012-07-30 07:20:58 -07:00
|
|
|
aList->mSentinel.mAbove = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
mSentinel.mAbove = aList->mSentinel.mAbove;
|
2012-07-21 19:06:58 -07:00
|
|
|
if (mTop == &mSentinel) {
|
|
|
|
mTop = aList->mTop;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
aList->mTop = &aList->mSentinel;
|
2012-07-30 07:20:58 -07:00
|
|
|
aList->mSentinel.mAbove = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 {
|
2012-07-30 07:20:58 -07:00
|
|
|
return mTop != &mSentinel ? static_cast<nsDisplayItem*>(mTop) : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return the item at the bottom of the list, or null if the list is empty
|
|
|
|
*/
|
|
|
|
nsDisplayItem* GetBottom() const { return mSentinel.mAbove; }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsEmpty() const { return mTop == &mSentinel; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is *linear time*!
|
|
|
|
* @return the number of items in the list
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t Count() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* 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
|
2012-07-30 07:20:58 -07:00
|
|
|
* checks, or nullptr if not known; it's only a hint, if it is not an
|
2007-03-22 10:30:00 -07:00
|
|
|
* 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
|
2012-07-30 07:20:58 -07:00
|
|
|
* checks, or nullptr if not known; it's only a hint, if it is not an
|
2007-03-22 10:30:00 -07:00
|
|
|
* ancestor of some elements, then we lose performance but not correctness
|
|
|
|
*/
|
|
|
|
void SortByContentOrder(nsDisplayListBuilder* aBuilder, nsIContent* aCommonAncestor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
typedef bool (* SortLEQ)(nsDisplayItem* aItem1, nsDisplayItem* aItem2,
|
2007-03-22 10:30:00 -07:00
|
|
|
void* aClosure);
|
|
|
|
void Sort(nsDisplayListBuilder* aBuilder, SortLEQ aCmp, void* aClosure);
|
|
|
|
|
|
|
|
/**
|
2010-07-15 14:08:09 -07:00
|
|
|
* Compute visiblity for the items in the list.
|
|
|
|
* We put this logic here so it can be shared by top-level
|
2007-03-22 10:30:00 -07:00
|
|
|
* painting and also display items that maintain child lists.
|
2009-09-06 17:35:14 -07: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-08-27 16:15:08 -07:00
|
|
|
* This sets mIsOpaque if the entire visible area of this list has
|
|
|
|
* been removed from aVisibleRegion when we return.
|
2010-07-15 14:08:09 -07:00
|
|
|
* This does not remove any items from the list, so we can recompute
|
|
|
|
* visiblity with different regions later (see
|
|
|
|
* FrameLayerBuilder::DrawThebesLayer).
|
2012-10-06 06:03:23 -07:00
|
|
|
* This method needs to be idempotent.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* @param aVisibleRegion the area that is visible, relative to the
|
2010-08-27 16:15:08 -07:00
|
|
|
* reference frame; on return, this contains the area visible under the list.
|
|
|
|
* I.e., opaque contents of this list are subtracted from aVisibleRegion.
|
|
|
|
* @param aListVisibleBounds must be equal to the bounds of the intersection
|
|
|
|
* of aVisibleRegion and GetBounds() for this list.
|
2011-05-13 09:40:46 -07:00
|
|
|
* @return true if any item in the list is visible.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
|
2012-10-06 06:03:23 -07:00
|
|
|
nsRegion* aVisibleRegion,
|
|
|
|
const nsRect& aListVisibleBounds,
|
|
|
|
const nsRect& aAllowVisibleRegionExpansion);
|
2010-08-27 16:15:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* As ComputeVisibilityForSublist, but computes visibility for a root
|
|
|
|
* list (a list that does not belong to an nsDisplayItem).
|
2012-10-06 06:03:23 -07:00
|
|
|
* This method needs to be idempotent.
|
2010-08-27 16:15:08 -07:00
|
|
|
*
|
|
|
|
* @param aVisibleRegion the area that is visible
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
|
2012-10-06 06:03:23 -07:00
|
|
|
nsRegion* aVisibleRegion);
|
2010-08-27 16:15:08 -07:00
|
|
|
|
2010-02-28 23:56:19 -08:00
|
|
|
/**
|
|
|
|
* Returns true if the visible region output from ComputeVisiblity was
|
|
|
|
* empty, i.e. everything visible in this list is opaque.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsOpaque() const {
|
2010-02-28 23:56:19 -08:00
|
|
|
NS_ASSERTION(mDidComputeVisibility, "Need to have called ComputeVisibility");
|
|
|
|
return mIsOpaque;
|
|
|
|
}
|
2010-10-19 10:02:25 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if during ComputeVisibility any display item
|
|
|
|
* set the surface to be transparent.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool NeedsTransparentSurface() const {
|
2010-10-19 10:02:25 -07:00
|
|
|
NS_ASSERTION(mDidComputeVisibility, "Need to have called ComputeVisibility");
|
|
|
|
return mForceTransparentSurface;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Paint the list to the rendering context. We assume that (0,0) in aCtx
|
2008-02-24 17:39:34 -08: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-06 17:35:14 -07:00
|
|
|
*
|
2010-03-01 00:03:49 -08: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.
|
|
|
|
*
|
2010-07-15 14:07:52 -07:00
|
|
|
* If PAINT_FLUSH_LAYERS is set, we'll force a completely new layer
|
|
|
|
* tree to be created for this paint *and* the next paint.
|
|
|
|
*
|
2011-01-19 00:27:54 -08:00
|
|
|
* If PAINT_EXISTING_TRANSACTION is set, the reference frame's widget's
|
|
|
|
* layer manager has already had BeginTransaction() called on it and
|
|
|
|
* we should not call it again.
|
|
|
|
*
|
2009-09-06 17:35:14 -07:00
|
|
|
* ComputeVisibility must be called before Paint.
|
2010-03-10 12:55:05 -08:00
|
|
|
*
|
|
|
|
* This must only be called on the root display list of the display list
|
|
|
|
* tree.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-03-01 00:03:49 -08:00
|
|
|
enum {
|
|
|
|
PAINT_DEFAULT = 0,
|
2010-07-15 14:07:52 -07:00
|
|
|
PAINT_USE_WIDGET_LAYERS = 0x01,
|
2011-01-19 00:27:54 -08:00
|
|
|
PAINT_FLUSH_LAYERS = 0x02,
|
2012-08-13 03:10:10 -07:00
|
|
|
PAINT_EXISTING_TRANSACTION = 0x04,
|
2013-01-16 14:59:23 -08:00
|
|
|
PAINT_NO_COMPOSITE = 0x08,
|
|
|
|
PAINT_NO_CLEAR_INVALIDATIONS = 0x10
|
2010-03-01 00:03:49 -08:00
|
|
|
};
|
2011-04-07 18:04:40 -07:00
|
|
|
void PaintRoot(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags) const;
|
2010-03-10 12:55:05 -08:00
|
|
|
/**
|
|
|
|
* Like PaintRoot, but used for internal display sublists.
|
|
|
|
* aForFrame is the frame that the list is associated with.
|
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
void PaintForFrame(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIFrame* aForFrame, uint32_t aFlags) const;
|
2008-09-10 17:24:16 -07:00
|
|
|
/**
|
|
|
|
* Get the bounds. Takes the union of the bounds of all children.
|
|
|
|
*/
|
|
|
|
nsRect GetBounds(nsDisplayListBuilder* aBuilder) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Find the topmost display item that returns a non-null frame, and return
|
|
|
|
* the frame.
|
|
|
|
*/
|
2010-04-07 17:31:26 -07:00
|
|
|
void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
nsDisplayItem::HitTestState* aState,
|
|
|
|
nsTArray<nsIFrame*> *aOutFrames) const;
|
2008-01-03 18:08:29 -08:00
|
|
|
|
2010-07-15 14:08:09 -07:00
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DidComputeVisibility() const { return mDidComputeVisibility; }
|
2010-07-15 14:08:09 -07:00
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
|
2009-09-06 17:35:14 -07:00
|
|
|
// Utility function used to massage the list during ComputeVisibility.
|
2007-11-11 12:31:39 -08:00
|
|
|
void FlattenTo(nsTArray<nsDisplayItem*>* aElements);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsDisplayItemLink mSentinel;
|
|
|
|
nsDisplayItemLink* mTop;
|
2009-09-06 17:35:14 -07:00
|
|
|
|
2010-03-10 12:55:05 -08:00
|
|
|
// This is set by ComputeVisibility
|
|
|
|
nsRect mVisibleRect;
|
2010-02-28 23:56:19 -08: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).
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsOpaque;
|
2010-10-19 10:02:25 -07:00
|
|
|
// This is set to true by ComputeVisibility if any display item in this
|
2012-05-02 21:29:05 -07:00
|
|
|
// list needs to force the surface containing this list to be transparent.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mForceTransparentSurface;
|
2009-09-06 17:35:14 -07:00
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDidComputeVisibility;
|
2009-09-06 17:35:14 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07: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.
|
|
|
|
*/
|
|
|
|
class nsDisplayListSet {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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) {
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0; i < 6; ++i) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mLists[i].SortByContentOrder(aBuilder, aCommonAncestor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
nsDisplayList mLists[6];
|
|
|
|
};
|
|
|
|
|
2012-11-18 19:28:18 -08:00
|
|
|
|
|
|
|
class nsDisplayImageContainer : public nsDisplayItem {
|
|
|
|
public:
|
|
|
|
typedef mozilla::layers::ImageContainer ImageContainer;
|
|
|
|
typedef mozilla::layers::ImageLayer ImageLayer;
|
|
|
|
|
|
|
|
nsDisplayImageContainer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
|
|
|
{}
|
|
|
|
|
2012-11-27 18:34:45 -08:00
|
|
|
virtual already_AddRefed<ImageContainer> GetContainer(LayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aBuilder) = 0;
|
2012-11-18 19:28:18 -08:00
|
|
|
virtual void ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset) = 0;
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool SupportsOptimizingToImage() MOZ_OVERRIDE { return true; }
|
2012-11-18 19:28:18 -08:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* 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:
|
2011-04-07 18:04:40 -07:00
|
|
|
typedef void (* PaintCallback)(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect, nsPoint aFramePt);
|
|
|
|
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayGeneric(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
PaintCallback aPaint, const char* aName, Type aType)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame), mPaint(aPaint)
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2007-03-22 10:30:00 -07:00
|
|
|
, mName(aName)
|
|
|
|
#endif
|
2010-07-15 14:07:49 -07:00
|
|
|
, mType(aType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayGeneric);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayGeneric() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayGeneric);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE {
|
2010-08-13 03:01:58 -07:00
|
|
|
mPaint(mFrame, aCtx, mVisibleRect, ToReferenceFrame());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME(mName, mType)
|
2010-10-10 17:58:20 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder) {
|
2012-04-10 04:24:18 -07:00
|
|
|
if (mType == nsDisplayItem::TYPE_HEADER_FOOTER) {
|
|
|
|
bool snap;
|
|
|
|
return GetBounds(aBuilder, &snap);
|
|
|
|
}
|
2011-01-02 17:48:09 -08:00
|
|
|
return nsRect();
|
2010-10-10 17:58:20 -07:00
|
|
|
}
|
2011-01-02 17:48:09 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
PaintCallback mPaint;
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2007-03-22 10:30:00 -07:00
|
|
|
const char* mName;
|
|
|
|
#endif
|
2010-07-15 14:07:49 -07:00
|
|
|
Type mType;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
|
|
|
|
/**
|
|
|
|
* This class implements painting of reflow counts. Ideally, we would simply
|
2009-08-20 14:52:48 -07:00
|
|
|
* make all the frame names be those returned by nsFrame::GetFrameName
|
2007-03-22 10:30:00 -07: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:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayReflowCount(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
const char* aFrameName,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aColor = 0)
|
2010-08-13 03:01:13 -07:00
|
|
|
: nsDisplayItem(aBuilder, aFrame),
|
2007-03-22 10:30:00 -07:00
|
|
|
mFrameName(aFrameName),
|
|
|
|
mColor(aColor)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayReflowCount);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayReflowCount() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayReflowCount);
|
|
|
|
}
|
|
|
|
#endif
|
2011-04-07 18:04:40 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE {
|
2007-03-30 14:11:41 -07:00
|
|
|
mFrame->PresContext()->PresShell()->PaintCount(mFrameName, aCtx,
|
2011-04-07 18:04:40 -07:00
|
|
|
mFrame->PresContext(),
|
|
|
|
mFrame, ToReferenceFrame(),
|
|
|
|
mColor);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("nsDisplayReflowCount", TYPE_REFLOW_COUNT)
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
const char* mFrameName;
|
|
|
|
nscolor mColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT_DSP(_name) \
|
|
|
|
PR_BEGIN_MACRO \
|
2009-07-21 17:44:52 -07:00
|
|
|
if (!aBuilder->IsBackgroundOnly() && !aBuilder->IsForEventDelivery() && \
|
|
|
|
PresContext()->PresShell()->IsPaintingFrameCounts()) { \
|
2010-08-13 03:01:13 -07:00
|
|
|
aLists.Outlines()->AppendNewToTop( \
|
|
|
|
new (aBuilder) nsDisplayReflowCount(aBuilder, this, _name)); \
|
2007-03-22 10:30:00 -07:00
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
#define DO_GLOBAL_REFLOW_COUNT_DSP_COLOR(_name, _color) \
|
|
|
|
PR_BEGIN_MACRO \
|
2009-07-21 17:44:52 -07:00
|
|
|
if (!aBuilder->IsBackgroundOnly() && !aBuilder->IsForEventDelivery() && \
|
|
|
|
PresContext()->PresShell()->IsPaintingFrameCounts()) { \
|
2010-08-13 03:01:13 -07:00
|
|
|
aLists.Outlines()->AppendNewToTop( \
|
|
|
|
new (aBuilder) nsDisplayReflowCount(aBuilder, this, _name, _color)); \
|
2007-03-22 10:30:00 -07:00
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
/*
|
|
|
|
Macro to be used for classes that don't actually implement BuildDisplayList
|
|
|
|
*/
|
|
|
|
#define DECL_DO_GLOBAL_REFLOW_COUNT_DSP(_class, _super) \
|
2013-02-14 03:12:27 -08:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder, \
|
|
|
|
const nsRect& aDirtyRect, \
|
|
|
|
const nsDisplayListSet& aLists) { \
|
2007-03-22 10:30:00 -07:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP(#_class); \
|
2013-02-14 03:12:27 -08:00
|
|
|
_super::BuildDisplayList(aBuilder, aDirtyRect, aLists); \
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
class nsDisplayCaret : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayCaret(nsDisplayListBuilder* aBuilder, nsIFrame* aCaretFrame,
|
|
|
|
nsCaret *aCaret)
|
|
|
|
: nsDisplayItem(aBuilder, aCaretFrame), mCaret(aCaret) {
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayCaret);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayCaret() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayCaret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE {
|
2012-04-10 04:24:18 -07:00
|
|
|
*aSnap = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
// The caret returns a rect in the coordinates of mFrame.
|
2010-08-13 03:01:58 -07:00
|
|
|
return mCaret->GetCaretRect() + ToReferenceFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("Caret", TYPE_CARET)
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2008-07-16 03:52:01 -07:00
|
|
|
nsRefPtr<nsCaret> mCaret;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The standard display item to paint the CSS borders of a frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayBorder : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayBorder(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) :
|
2012-04-10 04:24:18 -07:00
|
|
|
nsDisplayItem(aBuilder, aFrame)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayBorder);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayBorder() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBorder);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("Border", TYPE_BORDER)
|
2012-08-28 22:39:01 -07:00
|
|
|
|
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder);
|
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2009-04-25 01:19:23 -07:00
|
|
|
/**
|
2009-04-30 03:07:18 -07:00
|
|
|
* A simple display item that just renders a solid color across the
|
2009-07-04 02:30:59 -07: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 01:19:23 -07:00
|
|
|
*/
|
|
|
|
class nsDisplaySolidColor : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplaySolidColor(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
2011-05-13 09:40:46 -07:00
|
|
|
const nsRect& aBounds, nscolor aColor)
|
2012-04-10 04:24:18 -07:00
|
|
|
: nsDisplayItem(aBuilder, aFrame), mBounds(aBounds), mColor(aColor)
|
|
|
|
{
|
2011-01-16 02:38:45 -08:00
|
|
|
NS_ASSERTION(NS_GET_A(aColor) > 0, "Don't create invisible nsDisplaySolidColors!");
|
2009-04-25 01:19:23 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplaySolidColor);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplaySolidColor() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplaySolidColor);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
2009-04-25 01:19:23 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool* aSnap) MOZ_OVERRIDE {
|
2012-04-10 04:24:18 -07:00
|
|
|
*aSnap = false;
|
2011-01-02 17:48:09 -08:00
|
|
|
nsRegion result;
|
|
|
|
if (NS_GET_A(mColor) == 255) {
|
2012-04-10 04:24:18 -07:00
|
|
|
result = GetBounds(aBuilder, aSnap);
|
2011-01-02 17:48:09 -08:00
|
|
|
}
|
|
|
|
return result;
|
2009-04-25 01:19:23 -07:00
|
|
|
}
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) MOZ_OVERRIDE
|
2010-05-12 17:56:11 -07:00
|
|
|
{
|
|
|
|
*aColor = mColor;
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-05-12 17:56:11 -07:00
|
|
|
}
|
2009-04-25 01:19:23 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2009-04-25 01:19:23 -07:00
|
|
|
|
2013-03-07 18:15:10 -08:00
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return new nsDisplayItemBoundsGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE
|
2013-03-07 18:15:10 -08:00
|
|
|
{
|
|
|
|
const nsDisplayItemBoundsGeometry* geometry = static_cast<const nsDisplayItemBoundsGeometry*>(aGeometry);
|
|
|
|
ComputeInvalidationRegionDifference(aBuilder, geometry, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("SolidColor", TYPE_SOLID_COLOR)
|
|
|
|
|
2009-04-25 01:19:23 -07:00
|
|
|
private:
|
|
|
|
nsRect mBounds;
|
|
|
|
nscolor mColor;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2012-11-09 15:14:59 -08:00
|
|
|
* A display item to paint one background-image for a frame. Each background
|
|
|
|
* image layer gets its own nsDisplayBackgroundImage.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-11-18 19:28:18 -08:00
|
|
|
class nsDisplayBackgroundImage : public nsDisplayImageContainer {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-11-09 15:14:14 -08:00
|
|
|
/**
|
|
|
|
* aLayer signifies which background layer this item represents.
|
|
|
|
* aIsThemed should be the value of aFrame->IsThemed.
|
|
|
|
* aBackgroundStyle should be the result of
|
|
|
|
* nsCSSRendering::FindBackground, or null if FindBackground returned false.
|
|
|
|
*/
|
2012-11-09 15:14:59 -08:00
|
|
|
nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
uint32_t aLayer, bool aIsThemed,
|
|
|
|
const nsStyleBackground* aBackgroundStyle);
|
|
|
|
virtual ~nsDisplayBackgroundImage();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-13 03:34:23 -07:00
|
|
|
// This will create and append new items for all the layers of the
|
|
|
|
// background. If given, aBackground will be set with the address of the
|
|
|
|
// bottom-most background item.
|
|
|
|
static nsresult AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList,
|
2012-11-09 15:14:59 -08:00
|
|
|
nsDisplayBackgroundImage** aBackground = nullptr);
|
2012-09-13 03:34:23 -07:00
|
|
|
|
2012-05-03 13:13:12 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE;
|
2012-05-03 13:13:12 -07:00
|
|
|
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2012-05-03 13:13:12 -07:00
|
|
|
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2012-09-14 09:10:08 -07:00
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool* aSnap) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsVaryingRelativeToMovingFrame(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
nsIFrame* aFrame) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) MOZ_OVERRIDE;
|
2012-11-08 07:05:32 -08:00
|
|
|
/**
|
|
|
|
* GetBounds() returns the background painting area.
|
|
|
|
*/
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
|
|
|
virtual uint32_t GetPerFrameKey() MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("Background", TYPE_BACKGROUND)
|
2012-04-13 04:44:06 -07:00
|
|
|
// Returns the value of GetUnderlyingFrame()->IsThemed(), but cached
|
|
|
|
bool IsThemed() { return mIsThemed; }
|
|
|
|
|
2012-11-08 07:05:32 -08:00
|
|
|
/**
|
|
|
|
* Return the background positioning area.
|
|
|
|
* (GetBounds() returns the background painting area.)
|
|
|
|
* Can be called only when mBackgroundStyle is non-null.
|
|
|
|
*/
|
|
|
|
nsRect GetPositioningArea();
|
|
|
|
|
2012-08-28 22:39:01 -07:00
|
|
|
/**
|
|
|
|
* Returns true if existing rendered pixels of this display item may need
|
2012-11-08 07:05:32 -08:00
|
|
|
* to be redrawn if the positioning area size changes but its position does
|
|
|
|
* not.
|
|
|
|
* If false, only the changed painting area needs to be redrawn when the
|
|
|
|
* positioning area size changes but its position does not.
|
2012-08-28 22:39:01 -07:00
|
|
|
*/
|
2012-11-08 07:05:32 -08:00
|
|
|
bool RenderingMightDependOnPositioningAreaSizeChange();
|
|
|
|
|
2012-11-18 19:28:18 -08:00
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE
|
2012-08-28 22:39:01 -07:00
|
|
|
{
|
|
|
|
return new nsDisplayBackgroundGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2012-11-18 19:28:18 -08:00
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE;
|
|
|
|
|
2012-11-27 18:34:45 -08:00
|
|
|
virtual already_AddRefed<ImageContainer> GetContainer(LayerManager* aManager,
|
|
|
|
nsDisplayListBuilder *aBuilder) MOZ_OVERRIDE;
|
2012-11-18 19:28:18 -08:00
|
|
|
virtual void ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset) MOZ_OVERRIDE;
|
2012-08-28 22:39:01 -07:00
|
|
|
|
2012-10-24 22:32:25 -07:00
|
|
|
static nsRegion GetInsideClipRegion(nsDisplayItem* aItem, nsPresContext* aPresContext, uint8_t aClip,
|
|
|
|
const nsRect& aRect, bool* aSnap);
|
2013-01-29 21:07:30 -08:00
|
|
|
|
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual void WriteDebugInfo(FILE *aOutput) MOZ_OVERRIDE;
|
2013-01-29 21:07:30 -08:00
|
|
|
#endif
|
2010-07-15 14:08:06 -07:00
|
|
|
protected:
|
2012-05-03 13:13:12 -07:00
|
|
|
typedef class mozilla::layers::ImageContainer ImageContainer;
|
|
|
|
typedef class mozilla::layers::ImageLayer ImageLayer;
|
|
|
|
|
2012-11-27 18:34:45 -08:00
|
|
|
bool TryOptimizeToImageLayer(LayerManager* aManager, nsDisplayListBuilder* aBuilder);
|
2012-11-14 17:35:18 -08:00
|
|
|
bool IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aClipRect,
|
|
|
|
gfxRect* aDestRect);
|
2012-11-27 20:05:32 -08:00
|
|
|
nsRect GetBoundsInternal();
|
2012-05-03 13:13:12 -07:00
|
|
|
|
2012-12-12 17:15:55 -08:00
|
|
|
void PaintInternal(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx,
|
|
|
|
const nsRect& aBounds, nsRect* aClipRect);
|
|
|
|
|
2012-11-07 20:08:40 -08:00
|
|
|
// Cache the result of nsCSSRendering::FindBackground. Always null if
|
|
|
|
// mIsThemed is true or if FindBackground returned false.
|
|
|
|
const nsStyleBackground* mBackgroundStyle;
|
|
|
|
/* If this background can be a simple image layer, we store the format here. */
|
|
|
|
nsRefPtr<ImageContainer> mImageContainer;
|
|
|
|
gfxRect mDestRect;
|
2012-11-27 20:05:32 -08:00
|
|
|
/* Bounds of this display item */
|
|
|
|
nsRect mBounds;
|
2012-11-07 20:08:40 -08:00
|
|
|
uint32_t mLayer;
|
|
|
|
|
|
|
|
nsITheme::Transparency mThemeTransparency;
|
2010-06-10 15:53:57 -07:00
|
|
|
/* Used to cache mFrame->IsThemed() since it isn't a cheap call */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsThemed;
|
2012-09-13 03:34:23 -07:00
|
|
|
/* true if this item represents the bottom-most background layer */
|
|
|
|
bool mIsBottommostLayer;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-10-24 22:32:25 -07:00
|
|
|
class nsDisplayBackgroundColor : public nsDisplayItem
|
|
|
|
{
|
|
|
|
public:
|
2012-11-07 20:08:40 -08:00
|
|
|
nsDisplayBackgroundColor(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
const nsStyleBackground* aBackgroundStyle,
|
|
|
|
nscolor aColor)
|
2012-10-24 22:32:25 -07:00
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
2012-11-07 20:08:40 -08:00
|
|
|
, mBackgroundStyle(aBackgroundStyle)
|
2012-10-24 22:32:25 -07:00
|
|
|
, mColor(aColor)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) MOZ_OVERRIDE;
|
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
|
|
|
|
2012-11-13 11:57:59 -08:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
*aSnap = true;
|
2013-04-19 05:02:13 -07:00
|
|
|
return nsRect(ToReferenceFrame(), Frame()->GetSize());
|
2012-11-13 11:57:59 -08:00
|
|
|
}
|
|
|
|
|
2013-03-07 18:15:10 -08:00
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return new nsDisplayItemBoundsGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE
|
2013-03-07 18:15:10 -08:00
|
|
|
{
|
|
|
|
const nsDisplayItemBoundsGeometry* geometry = static_cast<const nsDisplayItemBoundsGeometry*>(aGeometry);
|
|
|
|
ComputeInvalidationRegionDifference(aBuilder, geometry, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2012-10-24 22:32:25 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("BackgroundColor", TYPE_BACKGROUND_COLOR)
|
2013-01-29 21:07:30 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
virtual void WriteDebugInfo(FILE *aOutput) {
|
|
|
|
fprintf(aOutput, "(rgba %d,%d,%d,%d)",
|
|
|
|
NS_GET_R(mColor), NS_GET_G(mColor),
|
|
|
|
NS_GET_B(mColor), NS_GET_A(mColor));
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2012-10-24 22:32:25 -07:00
|
|
|
|
2012-11-07 20:08:40 -08:00
|
|
|
protected:
|
|
|
|
const nsStyleBackground* mBackgroundStyle;
|
2012-10-24 22:32:25 -07:00
|
|
|
nscolor mColor;
|
|
|
|
};
|
|
|
|
|
2008-07-07 17:57:47 -07:00
|
|
|
/**
|
2009-02-10 00:45:13 -08:00
|
|
|
* The standard display item to paint the outer CSS box-shadows of a frame.
|
2008-07-07 17:57:47 -07:00
|
|
|
*/
|
2009-02-10 00:45:13 -08:00
|
|
|
class nsDisplayBoxShadowOuter : public nsDisplayItem {
|
2008-07-07 17:57:47 -07:00
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayBoxShadowOuter(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2009-02-10 00:45:13 -08:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayBoxShadowOuter);
|
2012-12-11 12:36:54 -08:00
|
|
|
mBounds = GetBoundsInternal();
|
2008-07-07 17:57:47 -07:00
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
2009-02-10 00:45:13 -08:00
|
|
|
virtual ~nsDisplayBoxShadowOuter() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBoxShadowOuter);
|
2008-07-07 17:57:47 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("BoxShadowOuter", TYPE_BOX_SHADOW_OUTER)
|
2012-08-28 22:39:01 -07:00
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion)
|
|
|
|
{
|
|
|
|
const nsDisplayItemGenericGeometry* geometry = static_cast<const nsDisplayItemGenericGeometry*>(aGeometry);
|
|
|
|
bool snap;
|
|
|
|
if (!geometry->mBounds.IsEqualInterior(GetBounds(aBuilder, &snap)) ||
|
|
|
|
!geometry->mBorderRect.IsEqualInterior(GetBorderRect())) {
|
|
|
|
nsRegion oldShadow, newShadow;
|
|
|
|
oldShadow = oldShadow.Sub(geometry->mBounds, geometry->mBorderRect);
|
|
|
|
newShadow = newShadow.Sub(GetBounds(aBuilder, &snap), GetBorderRect());
|
|
|
|
aInvalidRegion->Or(oldShadow, newShadow);
|
|
|
|
}
|
|
|
|
}
|
2009-11-30 15:14:04 -08:00
|
|
|
|
2012-12-11 12:36:54 -08:00
|
|
|
nsRect GetBoundsInternal();
|
|
|
|
|
2009-11-30 15:14:04 -08:00
|
|
|
private:
|
|
|
|
nsRegion mVisibleRegion;
|
2012-12-11 12:36:54 -08:00
|
|
|
nsRect mBounds;
|
2009-02-10 00:45:13 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The standard display item to paint the inner CSS box-shadows of a frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayBoxShadowInner : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayBoxShadowInner(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2009-02-10 00:45:13 -08:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayBoxShadowInner);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayBoxShadowInner() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayBoxShadowInner);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("BoxShadowInner", TYPE_BOX_SHADOW_INNER)
|
2012-08-28 22:39:01 -07:00
|
|
|
|
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
|
|
|
return new nsDisplayBoxShadowInnerGeometry(this, aBuilder);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2013-05-14 09:33:23 -07:00
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE
|
2012-08-28 22:39:01 -07:00
|
|
|
{
|
|
|
|
const nsDisplayBoxShadowInnerGeometry* geometry = static_cast<const nsDisplayBoxShadowInnerGeometry*>(aGeometry);
|
|
|
|
if (!geometry->mPaddingRect.IsEqualInterior(GetPaddingRect())) {
|
|
|
|
// nsDisplayBoxShadowInner is based around the padding rect, but it can
|
|
|
|
// touch pixels outside of this. We should invalidate the entire bounds.
|
|
|
|
bool snap;
|
|
|
|
aInvalidRegion->Or(geometry->mBounds, GetBounds(aBuilder, &snap));
|
|
|
|
}
|
|
|
|
}
|
2009-11-30 15:14:04 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsRegion mVisibleRegion;
|
2008-07-07 17:57:47 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* The standard display item to paint the CSS outline of a frame.
|
|
|
|
*/
|
|
|
|
class nsDisplayOutline : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayOutline(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) :
|
|
|
|
nsDisplayItem(aBuilder, aFrame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayOutline);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayOutline() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayOutline);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("Outline", TYPE_OUTLINE)
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class that lets you receive events within the frame bounds but never paints.
|
|
|
|
*/
|
|
|
|
class nsDisplayEventReceiver : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayEventReceiver(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayEventReceiver);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayEventReceiver() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayEventReceiver);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2012-09-14 09:10:08 -07:00
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("EventReceiver", TYPE_EVENT_RECEIVER)
|
2007-03-22 10:30:00 -07: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
|
2012-07-30 07:20:58 -07:00
|
|
|
* we allow the frame to be nullptr. Callers to GetUnderlyingFrame must
|
2007-03-22 10:30:00 -07:00
|
|
|
* detect and handle this case.
|
|
|
|
*/
|
|
|
|
class nsDisplayWrapList : public nsDisplayItem {
|
|
|
|
// This is never instantiated directly, so no need to count constructors and
|
|
|
|
// destructors.
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Takes all the items from aList and puts them in our list.
|
|
|
|
*/
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayWrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList);
|
|
|
|
nsDisplayWrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsDisplayItem* aItem);
|
2012-04-17 22:14:14 -07:00
|
|
|
nsDisplayWrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
2012-09-16 03:32:59 -07:00
|
|
|
nsDisplayItem* aItem, const nsIFrame* aReferenceFrame, const nsPoint& aToReferenceFrame);
|
2012-04-17 22:14:14 -07:00
|
|
|
nsDisplayWrapList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsDisplayWrapList();
|
2012-04-18 19:40:43 -07:00
|
|
|
/**
|
|
|
|
* Call this if the wrapped list is changed.
|
|
|
|
*/
|
2013-03-04 01:56:02 -08:00
|
|
|
virtual void UpdateBounds(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE
|
2012-04-18 19:40:43 -07:00
|
|
|
{
|
|
|
|
mBounds = mList.GetBounds(aBuilder);
|
|
|
|
}
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2012-09-14 09:10:08 -07:00
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool* aSnap) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsUniform(nsDisplayListBuilder* aBuilder, nscolor* aColor) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsVaryingRelativeToMovingFrame(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
nsIFrame* aFrame) MOZ_OVERRIDE;
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2012-04-13 04:44:06 -07:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) MOZ_OVERRIDE {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_WARNING("This list should already have been flattened!!!");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void GetMergedFrames(nsTArray<nsIFrame*>* aFrames) MOZ_OVERRIDE
|
2012-04-16 22:44:32 -07:00
|
|
|
{
|
|
|
|
aFrames->AppendElements(mMergedFrames);
|
|
|
|
}
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool IsInvalid(nsRect& aRect) MOZ_OVERRIDE
|
2012-08-28 22:47:15 -07:00
|
|
|
{
|
2012-08-28 22:48:45 -07:00
|
|
|
if (mFrame->IsInvalid(aRect) && aRect.IsEmpty()) {
|
2012-08-28 22:47:15 -07:00
|
|
|
return true;
|
|
|
|
}
|
2012-08-28 22:48:45 -07:00
|
|
|
nsRect temp;
|
2012-08-28 22:47:15 -07:00
|
|
|
for (uint32_t i = 0; i < mMergedFrames.Length(); i++) {
|
2012-08-28 22:48:45 -07:00
|
|
|
if (mMergedFrames[i]->IsInvalid(temp) && temp.IsEmpty()) {
|
|
|
|
aRect.SetEmpty();
|
2012-08-28 22:47:15 -07:00
|
|
|
return true;
|
|
|
|
}
|
2012-08-28 22:48:45 -07:00
|
|
|
aRect = aRect.Union(temp);
|
2012-08-28 22:47:15 -07:00
|
|
|
}
|
2012-08-28 22:48:45 -07:00
|
|
|
aRect += ToReferenceFrame();
|
|
|
|
return !aRect.IsEmpty();
|
2012-08-28 22:47:15 -07:00
|
|
|
}
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("WrapList", TYPE_WRAP_LIST)
|
2010-10-10 17:58:20 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-02 05:59:03 -07:00
|
|
|
virtual nsDisplayList* GetSameCoordinateSystemChildren() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mList.IsEmpty() || !ReferenceFrame() ||
|
|
|
|
!mList.GetBottom()->ReferenceFrame() ||
|
|
|
|
mList.GetBottom()->ReferenceFrame() == ReferenceFrame(),
|
|
|
|
"Children must have same reference frame");
|
|
|
|
return &mList;
|
|
|
|
}
|
|
|
|
virtual nsDisplayList* GetChildren() MOZ_OVERRIDE { return &mList; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* This creates a copy of this item, but wrapping aItem instead of
|
2012-07-30 07:20:58 -07:00
|
|
|
* our existing list. Only gets called if this item returned nullptr
|
2007-03-22 10:30:00 -07:00
|
|
|
* for GetUnderlyingFrame(). aItem is guaranteed to return non-null from
|
|
|
|
* GetUnderlyingFrame().
|
|
|
|
*/
|
|
|
|
virtual nsDisplayWrapList* WrapWithClone(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) {
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_NOTREACHED("We never returned nullptr for GetUnderlyingFrame!");
|
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-15 14:08:05 -07:00
|
|
|
/**
|
|
|
|
* Returns true if all descendant display items can be placed in the same
|
|
|
|
* ThebesLayer --- GetLayerState returns LAYER_INACTIVE or LAYER_NONE,
|
|
|
|
* and they all have the given aActiveScrolledRoot.
|
|
|
|
*/
|
2012-11-13 22:26:29 -08:00
|
|
|
static LayerState RequiredLayerStateForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerParameters& aParameters,
|
|
|
|
const nsDisplayList& aList,
|
|
|
|
nsIFrame* aActiveScrolledRoot);
|
2010-07-15 14:08:05 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
nsDisplayWrapList() {}
|
2012-04-13 04:44:06 -07:00
|
|
|
|
|
|
|
void MergeFrom(nsDisplayWrapList* aOther)
|
|
|
|
{
|
|
|
|
mList.AppendToBottom(&aOther->mList);
|
|
|
|
mBounds.UnionRect(mBounds, aOther->mBounds);
|
|
|
|
}
|
2012-04-16 22:44:32 -07:00
|
|
|
void MergeFromTrackingMergedFrames(nsDisplayWrapList* aOther)
|
|
|
|
{
|
|
|
|
MergeFrom(aOther);
|
|
|
|
mMergedFrames.AppendElement(aOther->mFrame);
|
|
|
|
mMergedFrames.MoveElementsFrom(aOther->mMergedFrames);
|
|
|
|
}
|
2012-04-13 04:44:06 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDisplayList mList;
|
2012-04-16 22:44:32 -07:00
|
|
|
// The frames from items that have been merged into this item, excluding
|
|
|
|
// this item's own frame.
|
|
|
|
nsTArray<nsIFrame*> mMergedFrames;
|
2012-04-13 04:44:06 -07:00
|
|
|
nsRect mBounds;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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:
|
|
|
|
// This is never instantiated directly (it has pure virtual methods), so no
|
|
|
|
// need to count constructors and destructors.
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool WrapBorderBackground() { return true; }
|
2007-03-22 10:30:00 -07:00
|
|
|
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);
|
|
|
|
protected:
|
|
|
|
nsDisplayWrapper() {}
|
|
|
|
};
|
2012-08-22 23:05:27 -07:00
|
|
|
|
2007-03-22 10:30:00 -07: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:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayOpacity(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayOpacity();
|
|
|
|
#endif
|
2012-08-22 23:05:27 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool* aSnap) MOZ_OVERRIDE;
|
2010-02-28 23:56:19 -08:00
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 05:11:27 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2010-07-15 14:08:05 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 07:05:55 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) MOZ_OVERRIDE;
|
2012-10-17 01:00:00 -07:00
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
// We don't need to compute an invalidation region since we have LayerTreeInvalidation
|
|
|
|
}
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY)
|
2013-01-29 21:07:30 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
virtual void WriteDebugInfo(FILE *aOutput) {
|
2013-02-16 13:51:02 -08:00
|
|
|
fprintf(aOutput, "(opacity %f)", mFrame->StyleDisplay()->mOpacity);
|
2013-01-29 21:07:30 -08:00
|
|
|
}
|
|
|
|
#endif
|
2012-08-22 23:05:27 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2010-07-15 14:08:03 -07:00
|
|
|
/**
|
|
|
|
* A display item that has no purpose but to ensure its contents get
|
|
|
|
* their own layer.
|
|
|
|
*/
|
|
|
|
class nsDisplayOwnLayer : public nsDisplayWrapList {
|
|
|
|
public:
|
2012-08-28 22:47:18 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* nsDisplayOwnLayer constructor flags
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
GENERATE_SUBDOC_INVALIDATIONS = 0x01
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aFlags GENERATE_SUBDOC_INVALIDATIONS :
|
|
|
|
* Add UserData to the created ContainerLayer, so that invalidations
|
|
|
|
* for this layer are send to our nsPresContext.
|
|
|
|
*/
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
2012-08-28 22:47:18 -07:00
|
|
|
nsDisplayList* aList, uint32_t aFlags = 0);
|
2010-07-15 14:08:03 -07:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayOwnLayer();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 05:11:27 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2010-07-15 14:08:05 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 07:05:55 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE
|
2010-07-15 14:08:05 -07:00
|
|
|
{
|
2012-07-22 20:00:36 -07:00
|
|
|
return mozilla::LAYER_ACTIVE_FORCE;
|
2010-07-15 14:08:05 -07:00
|
|
|
}
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) MOZ_OVERRIDE
|
2010-07-15 14:08:03 -07:00
|
|
|
{
|
|
|
|
// Don't allow merging, each sublist must have its own layer
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-07-15 14:08:03 -07:00
|
|
|
}
|
|
|
|
NS_DISPLAY_DECL_NAME("OwnLayer", TYPE_OWN_LAYER)
|
2012-08-28 22:47:18 -07:00
|
|
|
private:
|
|
|
|
uint32_t mFlags;
|
2010-07-15 14:08:03 -07:00
|
|
|
};
|
|
|
|
|
2012-06-27 08:43:57 -07:00
|
|
|
/**
|
|
|
|
* A display item used to represent fixed position elements. This will ensure
|
|
|
|
* the contents gets its own layer, and that the built layer will have
|
|
|
|
* position-related metadata set on it.
|
|
|
|
*/
|
|
|
|
class nsDisplayFixedPosition : public nsDisplayOwnLayer {
|
|
|
|
public:
|
|
|
|
nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
2012-07-25 00:06:19 -07:00
|
|
|
nsIFrame* aFixedPosFrame, nsDisplayList* aList);
|
2012-06-27 08:43:57 -07:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayFixedPosition();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2012-07-26 20:02:01 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE
|
2012-07-26 20:02:01 -07:00
|
|
|
{
|
|
|
|
return mozilla::LAYER_ACTIVE;
|
|
|
|
}
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) MOZ_OVERRIDE;
|
2012-08-10 01:36:33 -07:00
|
|
|
|
2012-07-14 00:49:05 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("FixedPosition", TYPE_FIXED_POSITION)
|
2012-07-25 00:06:19 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
nsIFrame* mFixedPosFrame;
|
2012-06-27 08:43:57 -07:00
|
|
|
};
|
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
/**
|
2011-05-01 18:53:01 -07:00
|
|
|
* This potentially creates a layer for the given list of items, whose
|
|
|
|
* visibility is determined by the displayport for the given frame instead of
|
|
|
|
* what is passed in to ComputeVisibility.
|
2011-01-13 09:45:14 -08:00
|
|
|
*
|
|
|
|
* Here in content, we can use this to render more content than is actually
|
|
|
|
* visible. Then, the compositing process can manipulate the generated layer
|
|
|
|
* through transformations so that asynchronous scrolling can be implemented.
|
|
|
|
*
|
|
|
|
* Note that setting the displayport will not change any hit testing! The
|
|
|
|
* content process will know nothing about what the user is actually seeing,
|
|
|
|
* so it can only do hit testing for what is supposed to be the visible region.
|
2011-05-01 18:53:01 -07:00
|
|
|
*
|
|
|
|
* It is possible for scroll boxes to have content that can be both above and
|
|
|
|
* below content outside of the scroll box. We cannot create layers for these
|
|
|
|
* cases. This is accomplished by wrapping display items with
|
|
|
|
* nsDisplayScrollLayers. nsDisplayScrollLayers with the same scroll frame will
|
|
|
|
* be merged together. If more than one nsDisplayScrollLayer exists after
|
|
|
|
* merging, all nsDisplayScrollLayers will be flattened out so that no new
|
|
|
|
* layer is created at all.
|
2011-01-13 09:45:14 -08:00
|
|
|
*/
|
2011-05-01 18:53:01 -07:00
|
|
|
class nsDisplayScrollLayer : public nsDisplayWrapList
|
2011-01-13 09:45:14 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2011-05-01 18:53:01 -07:00
|
|
|
* @param aScrolledFrame This will determine what the displayport is. It should be
|
|
|
|
* the root content frame of the scrolled area. Note
|
|
|
|
* that nsDisplayScrollLayer will expect for
|
|
|
|
* ScrollLayerCount to be defined on aScrolledFrame.
|
|
|
|
* @param aScrollFrame The viewport frame you see this content through.
|
2011-01-13 09:45:14 -08:00
|
|
|
*/
|
|
|
|
nsDisplayScrollLayer(nsDisplayListBuilder* aBuilder, nsDisplayList* aList,
|
2011-05-01 18:53:01 -07:00
|
|
|
nsIFrame* aForFrame, nsIFrame* aScrolledFrame,
|
|
|
|
nsIFrame* aScrollFrame);
|
|
|
|
nsDisplayScrollLayer(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
|
|
|
|
nsIFrame* aForFrame, nsIFrame* aScrolledFrame,
|
|
|
|
nsIFrame* aScrollFrame);
|
|
|
|
nsDisplayScrollLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aForFrame, nsIFrame* aScrolledFrame,
|
|
|
|
nsIFrame* aScrollFrame);
|
2011-01-13 09:45:14 -08:00
|
|
|
NS_DISPLAY_DECL_NAME("ScrollLayer", TYPE_SCROLL_LAYER)
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayScrollLayer();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 05:11:27 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2011-01-13 09:45:14 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
2011-01-13 09:45:14 -08:00
|
|
|
|
2011-03-15 16:20:19 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 07:05:55 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE;
|
2011-05-01 18:53:01 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
nsDisplayItem* aItem) MOZ_OVERRIDE;
|
2011-05-01 18:53:01 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
|
2011-05-01 18:53:01 -07:00
|
|
|
|
|
|
|
// Get the number of nsDisplayScrollLayers for a scroll frame. Note that this
|
|
|
|
// number does not include nsDisplayScrollInfoLayers. If this number is not 1
|
|
|
|
// after merging, all the nsDisplayScrollLayers should flatten away.
|
2012-04-11 17:17:44 -07:00
|
|
|
intptr_t GetScrollLayerCount();
|
|
|
|
intptr_t RemoveScrollLayerCount();
|
2011-05-01 18:53:01 -07:00
|
|
|
|
2012-08-30 00:31:16 -07:00
|
|
|
virtual nsIFrame* GetScrolledFrame() { return mScrolledFrame; }
|
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
private:
|
2011-05-01 18:53:01 -07:00
|
|
|
nsIFrame* mScrollFrame;
|
|
|
|
nsIFrame* mScrolledFrame;
|
2011-01-13 09:45:14 -08:00
|
|
|
};
|
|
|
|
|
2011-04-11 13:53:01 -07:00
|
|
|
/**
|
|
|
|
* Like nsDisplayScrollLayer, but only has metadata on the scroll frame. This
|
|
|
|
* creates a layer that has no Thebes child layer, but still allows the
|
|
|
|
* compositor process to know of the scroll frame's existence.
|
2011-05-01 18:53:01 -07:00
|
|
|
*
|
|
|
|
* After visibility computation, nsDisplayScrollInfoLayers should only exist if
|
|
|
|
* nsDisplayScrollLayers were all flattened away.
|
|
|
|
*
|
|
|
|
* Important!! Add info layers to the bottom of the list so they are only
|
|
|
|
* considered after the others have flattened out!
|
2011-04-11 13:53:01 -07:00
|
|
|
*/
|
|
|
|
class nsDisplayScrollInfoLayer : public nsDisplayScrollLayer
|
|
|
|
{
|
|
|
|
public:
|
2011-05-01 18:53:01 -07:00
|
|
|
nsDisplayScrollInfoLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aScrolledFrame, nsIFrame* aScrollFrame);
|
2011-04-11 13:53:01 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("ScrollInfoLayer", TYPE_SCROLL_INFO_LAYER)
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayScrollInfoLayer();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 07:05:55 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE;
|
2013-03-19 06:08:29 -07:00
|
|
|
virtual bool ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE
|
|
|
|
{ return true; }
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
nsDisplayItem* aItem) MOZ_OVERRIDE;
|
2011-04-11 13:53:01 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
|
2011-04-11 13:53:01 -07:00
|
|
|
};
|
|
|
|
|
2010-07-18 19:23:48 -07:00
|
|
|
/**
|
|
|
|
* nsDisplayZoom is used for subdocuments that have a different full zoom than
|
2010-08-08 11:49:06 -07:00
|
|
|
* their parent documents. This item creates a container layer.
|
2010-07-18 19:23:48 -07:00
|
|
|
*/
|
2010-08-08 11:49:06 -07:00
|
|
|
class nsDisplayZoom : public nsDisplayOwnLayer {
|
2010-07-18 19:23:48 -07:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @param aFrame is the root frame of the subdocument.
|
|
|
|
* @param aList contains the display items for the subdocument.
|
|
|
|
* @param aAPD is the app units per dev pixel ratio of the subdocument.
|
|
|
|
* @param aParentAPD is the app units per dev pixel ratio of the parent
|
|
|
|
* document.
|
2012-08-28 22:47:18 -07:00
|
|
|
* @param aFlags GENERATE_SUBDOC_INVALIDATIONS :
|
|
|
|
* Add UserData to the created ContainerLayer, so that invalidations
|
|
|
|
* for this layer are send to our nsPresContext.
|
2010-07-18 19:23:48 -07:00
|
|
|
*/
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayZoom(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList,
|
2012-08-28 22:47:18 -07:00
|
|
|
int32_t aAPD, int32_t aParentAPD,
|
|
|
|
uint32_t aFlags = 0);
|
2010-07-18 19:23:48 -07:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayZoom();
|
|
|
|
#endif
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2010-07-18 19:23:48 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2012-09-14 09:10:08 -07:00
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
2012-07-26 20:02:01 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE
|
2012-07-26 20:02:01 -07:00
|
|
|
{
|
|
|
|
return mozilla::LAYER_ACTIVE;
|
|
|
|
}
|
2010-07-18 19:23:48 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("Zoom", TYPE_ZOOM)
|
|
|
|
|
2010-08-08 11:49:06 -07:00
|
|
|
// Get the app units per dev pixel ratio of the child document.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetChildAppUnitsPerDevPixel() { return mAPD; }
|
2010-08-08 11:49:06 -07:00
|
|
|
// Get the app units per dev pixel ratio of the parent document.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetParentAppUnitsPerDevPixel() { return mParentAPD; }
|
2010-08-08 11:49:06 -07:00
|
|
|
|
2010-07-18 19:23:48 -07:00
|
|
|
private:
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mAPD, mParentAPD;
|
2010-07-18 19:23:48 -07:00
|
|
|
};
|
|
|
|
|
2008-09-10 17:24:16 -07:00
|
|
|
/**
|
|
|
|
* A display item to paint a stacking context with effects
|
|
|
|
* set by the stacking context root frame's style.
|
|
|
|
*/
|
|
|
|
class nsDisplaySVGEffects : public nsDisplayWrapList {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplaySVGEffects(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList);
|
2008-09-10 17:24:16 -07:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplaySVGEffects();
|
|
|
|
#endif
|
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool* aSnap) MOZ_OVERRIDE;
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2012-09-14 09:10:08 -07:00
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE {
|
2012-04-10 04:24:18 -07:00
|
|
|
*aSnap = false;
|
2012-04-17 22:12:53 -07:00
|
|
|
return mEffectsBounds + ToReferenceFrame();
|
2008-09-10 17:24:16 -07:00
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion* aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
|
|
|
virtual bool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) MOZ_OVERRIDE;
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("SVGEffects", TYPE_SVG_EFFECTS)
|
2008-09-10 17:24:16 -07:00
|
|
|
|
2012-07-17 10:03:51 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerParameters& aParameters);
|
|
|
|
|
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2012-10-17 01:00:00 -07:00
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
// We don't need to compute an invalidation region since we have LayerTreeInvalidation
|
|
|
|
}
|
2012-07-17 10:03:51 -07:00
|
|
|
|
|
|
|
void PaintAsLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRenderingContext* aCtx,
|
|
|
|
LayerManager* aManager);
|
|
|
|
|
2011-11-16 19:44:16 -08:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
void PrintEffects(FILE* aOutput);
|
|
|
|
#endif
|
|
|
|
|
2008-09-10 17:24:16 -07:00
|
|
|
private:
|
2012-04-17 22:12:53 -07:00
|
|
|
// relative to mFrame
|
|
|
|
nsRect mEffectsBounds;
|
2008-09-10 17:24:16 -07:00
|
|
|
};
|
|
|
|
|
2011-05-25 01:01:11 -07:00
|
|
|
/* A display item that applies a transformation to all of its descendant
|
2008-09-13 02:42:11 -07:00
|
|
|
* elements. This wrapper should only be used if there is a transform applied
|
|
|
|
* to the root element.
|
2011-05-25 01:01:11 -07:00
|
|
|
*
|
|
|
|
* The reason that a "bounds" rect is involved in transform calculations is
|
|
|
|
* because CSS-transforms allow percentage values for the x and y components
|
|
|
|
* of <translation-value>s, where percentages are percentages of the element's
|
2011-09-08 04:15:00 -07:00
|
|
|
* border box.
|
2011-05-25 01:01:11 -07:00
|
|
|
*
|
2012-09-19 16:14:07 -07:00
|
|
|
* INVARIANT: The wrapped frame is transformed or we supplied a transform getter
|
|
|
|
* function.
|
2008-09-13 02:42:11 -07:00
|
|
|
* INVARIANT: The wrapped frame is non-null.
|
|
|
|
*/
|
|
|
|
class nsDisplayTransform: public nsDisplayItem
|
|
|
|
{
|
|
|
|
public:
|
2012-09-19 16:14:07 -07:00
|
|
|
/**
|
|
|
|
* Returns a matrix (in pixels) for the current frame. The matrix should be relative to
|
|
|
|
* the current frame's coordinate space.
|
|
|
|
*
|
|
|
|
* @param aFrame The frame to compute the transform for.
|
|
|
|
* @param aAppUnitsPerPixel The number of app units per graphics unit.
|
|
|
|
*/
|
|
|
|
typedef gfx3DMatrix (* ComputeTransformFunction)(nsIFrame* aFrame, float aAppUnitsPerPixel);
|
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/* Constructor accepts a display list, empties it, and wraps it up. It also
|
|
|
|
* ferries the underlying frame to the nsDisplayItem constructor.
|
|
|
|
*/
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
2012-09-16 03:32:59 -07:00
|
|
|
nsDisplayList *aList, uint32_t aIndex = 0);
|
2012-09-19 16:14:07 -07:00
|
|
|
nsDisplayTransform(nsDisplayListBuilder* aBuilder, nsIFrame *aFrame,
|
|
|
|
nsDisplayList *aList, ComputeTransformFunction aTransformGetter, uint32_t aIndex = 0);
|
2011-08-26 17:01:46 -07:00
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayTransform()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayTransform);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-07-14 21:16:47 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("nsDisplayTransform", TYPE_TRANSFORM)
|
2008-09-13 02:42:11 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
|
|
|
if (mStoredList.GetComponentAlphaBounds(aBuilder).IsEmpty())
|
|
|
|
return nsRect();
|
2012-04-10 04:24:18 -07:00
|
|
|
bool snap;
|
|
|
|
return GetBounds(aBuilder, &snap);
|
2011-01-02 17:48:09 -08:00
|
|
|
}
|
2010-10-10 17:58:20 -07:00
|
|
|
|
2012-11-02 05:59:03 -07:00
|
|
|
virtual nsDisplayList* GetChildren() MOZ_OVERRIDE { return mStoredList.GetChildren(); }
|
2009-04-05 17:37:04 -07:00
|
|
|
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder *aBuilder, const nsRect& aRect,
|
2012-09-14 09:10:08 -07:00
|
|
|
HitTestState *aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder *aBuilder, bool* aSnap) MOZ_OVERRIDE;
|
2011-01-02 17:48:09 -08:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder *aBuilder,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool* aSnap) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsUniform(nsDisplayListBuilder *aBuilder, nscolor* aColor) MOZ_OVERRIDE;
|
2010-08-01 20:07:04 -07:00
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 07:05:55 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aParameters) MOZ_OVERRIDE;
|
2010-08-01 20:07:04 -07:00
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 05:11:27 -07:00
|
|
|
LayerManager* aManager,
|
2012-09-14 09:10:08 -07:00
|
|
|
const ContainerParameters& aContainerParameters) MOZ_OVERRIDE;
|
2013-03-19 06:08:29 -07:00
|
|
|
virtual bool ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder *aBuilder,
|
2011-01-27 14:58:50 -08:00
|
|
|
nsRegion *aVisibleRegion,
|
2012-09-14 09:10:08 -07:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE;
|
|
|
|
virtual bool TryMerge(nsDisplayListBuilder *aBuilder, nsDisplayItem *aItem) MOZ_OVERRIDE;
|
2011-10-02 21:02:25 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual uint32_t GetPerFrameKey() MOZ_OVERRIDE { return (mIndex << nsDisplayItem::TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); }
|
2012-10-17 01:00:00 -07:00
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
// We don't need to compute an invalidation region since we have LayerTreeInvalidation
|
|
|
|
}
|
2011-10-02 21:02:25 -07:00
|
|
|
|
2012-10-15 18:10:48 -07:00
|
|
|
virtual const nsIFrame* ReferenceFrameForChildren() const MOZ_OVERRIDE {
|
|
|
|
// If we were created using a transform-getter, then we don't
|
|
|
|
// belong to a transformed frame, and aren't a reference frame
|
|
|
|
// for our children.
|
|
|
|
if (!mTransformGetter) {
|
|
|
|
return mFrame;
|
|
|
|
}
|
|
|
|
return nsDisplayItem::ReferenceFrameForChildren();
|
|
|
|
}
|
|
|
|
|
2011-10-02 21:02:25 -07:00
|
|
|
enum {
|
2012-09-27 23:57:33 -07:00
|
|
|
INDEX_MAX = UINT32_MAX >> nsDisplayItem::TYPE_BITS
|
2011-10-02 21:02:25 -07:00
|
|
|
};
|
2008-09-13 02:42:11 -07:00
|
|
|
|
2012-02-16 22:08:33 -08:00
|
|
|
const gfx3DMatrix& GetTransform(float aAppUnitsPerPixel);
|
2011-07-22 15:28:07 -07:00
|
|
|
|
2011-10-06 14:24:02 -07:00
|
|
|
float GetHitDepthAtPoint(const nsPoint& aPoint);
|
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/**
|
|
|
|
* 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
|
2012-07-30 07:20:58 -07:00
|
|
|
* nullptr (or nothing at all) to use the default.
|
2008-09-13 02:42:11 -07:00
|
|
|
*/
|
|
|
|
static nsRect TransformRect(const nsRect &aUntransformedBounds,
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsPoint &aOrigin,
|
2012-07-30 07:20:58 -07:00
|
|
|
const nsRect* aBoundsOverride = nullptr);
|
2008-09-13 02:42:11 -07:00
|
|
|
|
2011-02-24 14:55:23 -08:00
|
|
|
static nsRect TransformRectOut(const nsRect &aUntransformedBounds,
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsPoint &aOrigin,
|
2012-07-30 07:20:58 -07:00
|
|
|
const nsRect* aBoundsOverride = nullptr);
|
2011-02-24 14:55:23 -08:00
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/* UntransformRect is like TransformRect, except that it inverts the
|
|
|
|
* transform.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool UntransformRect(const nsRect &aUntransformedBounds,
|
2008-09-13 02:42:11 -07:00
|
|
|
const nsIFrame* aFrame,
|
2011-07-22 15:28:51 -07:00
|
|
|
const nsPoint &aOrigin,
|
|
|
|
nsRect* aOutRect);
|
2012-02-14 01:12:49 -08:00
|
|
|
|
|
|
|
static bool UntransformRectMatrix(const nsRect &aUntransformedBounds,
|
|
|
|
const gfx3DMatrix& aMatrix,
|
2012-02-16 22:08:33 -08:00
|
|
|
float aAppUnitsPerPixel,
|
2012-02-14 01:12:49 -08:00
|
|
|
nsRect* aOutRect);
|
2008-09-13 02:42:11 -07:00
|
|
|
|
2012-07-31 10:28:21 -07:00
|
|
|
static gfxPoint3D GetDeltaToMozTransformOrigin(const nsIFrame* aFrame,
|
|
|
|
float aAppUnitsPerPixel,
|
|
|
|
const nsRect* aBoundsOverride);
|
|
|
|
|
|
|
|
static gfxPoint3D GetDeltaToMozPerspectiveOrigin(const nsIFrame* aFrame,
|
|
|
|
float aAppUnitsPerPixel);
|
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/**
|
2011-06-16 04:06:05 -07:00
|
|
|
* Returns the bounds of a frame as defined for resolving percentage
|
|
|
|
* <translation-value>s in CSS transforms. If
|
2008-09-13 02:42:11 -07:00
|
|
|
* 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);
|
|
|
|
|
2012-09-17 15:34:21 -07:00
|
|
|
struct FrameTransformProperties
|
|
|
|
{
|
|
|
|
FrameTransformProperties(const nsIFrame* aFrame,
|
|
|
|
float aAppUnitsPerPixel,
|
|
|
|
const nsRect* aBoundsOverride);
|
|
|
|
FrameTransformProperties(const nsCSSValueList* aTransformList,
|
|
|
|
const gfxPoint3D& aToMozOrigin,
|
|
|
|
const gfxPoint3D& aToPerspectiveOrigin,
|
|
|
|
nscoord aChildPerspective)
|
|
|
|
: mFrame(nullptr)
|
|
|
|
, mTransformList(aTransformList)
|
|
|
|
, mToMozOrigin(aToMozOrigin)
|
|
|
|
, mToPerspectiveOrigin(aToPerspectiveOrigin)
|
|
|
|
, mChildPerspective(aChildPerspective)
|
|
|
|
{}
|
|
|
|
|
|
|
|
const nsIFrame* mFrame;
|
|
|
|
const nsCSSValueList* mTransformList;
|
|
|
|
const gfxPoint3D mToMozOrigin;
|
|
|
|
const gfxPoint3D mToPerspectiveOrigin;
|
|
|
|
nscoord mChildPerspective;
|
|
|
|
};
|
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/**
|
2012-05-16 21:05:09 -07:00
|
|
|
* Given a frame with the -moz-transform property or an SVG transform,
|
|
|
|
* returns the transformation matrix for that frame.
|
2008-09-13 02:42:11 -07:00
|
|
|
*
|
|
|
|
* @param aFrame The frame to get the matrix from.
|
|
|
|
* @param aOrigin Relative to which point this transform should be applied.
|
2012-02-16 22:08:33 -08:00
|
|
|
* @param aAppUnitsPerPixel The number of app units per graphics unit.
|
2012-07-30 07:20:58 -07:00
|
|
|
* @param aBoundsOverride [optional] If this is nullptr (the default), the
|
2008-09-13 02:42:11 -07:00
|
|
|
* 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.
|
|
|
|
*/
|
2011-07-22 15:28:51 -07:00
|
|
|
static gfx3DMatrix GetResultingTransformMatrix(const nsIFrame* aFrame,
|
|
|
|
const nsPoint& aOrigin,
|
2012-02-16 22:08:33 -08:00
|
|
|
float aAppUnitsPerPixel,
|
2012-07-30 07:20:58 -07:00
|
|
|
const nsRect* aBoundsOverride = nullptr,
|
2012-09-17 15:34:21 -07:00
|
|
|
nsIFrame** aOutAncestor = nullptr);
|
|
|
|
static gfx3DMatrix GetResultingTransformMatrix(const FrameTransformProperties& aProperties,
|
|
|
|
const nsPoint& aOrigin,
|
|
|
|
float aAppUnitsPerPixel,
|
|
|
|
const nsRect* aBoundsOverride = nullptr,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame** aOutAncestor = nullptr);
|
2011-12-18 13:57:35 -08:00
|
|
|
/**
|
|
|
|
* Return true when we should try to prerender the entire contents of the
|
|
|
|
* transformed frame even when it's not completely visible (yet).
|
|
|
|
*/
|
|
|
|
static bool ShouldPrerenderTransformedContent(nsDisplayListBuilder* aBuilder,
|
2012-08-25 18:27:28 -07:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
bool aLogAnimations = false);
|
2012-09-14 09:10:08 -07:00
|
|
|
bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
|
2008-09-13 02:42:11 -07:00
|
|
|
|
|
|
|
private:
|
2012-09-17 15:34:21 -07:00
|
|
|
static gfx3DMatrix GetResultingTransformMatrixInternal(const FrameTransformProperties& aProperties,
|
2012-09-16 03:32:59 -07:00
|
|
|
const nsPoint& aOrigin,
|
|
|
|
float aAppUnitsPerPixel,
|
|
|
|
const nsRect* aBoundsOverride,
|
2012-09-25 15:47:41 -07:00
|
|
|
nsIFrame** aOutAncestor);
|
2012-09-16 03:32:59 -07:00
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
nsDisplayWrapList mStoredList;
|
2011-08-26 17:01:46 -07:00
|
|
|
gfx3DMatrix mTransform;
|
2012-09-19 16:14:07 -07:00
|
|
|
ComputeTransformFunction mTransformGetter;
|
2012-02-16 22:08:33 -08:00
|
|
|
float mCachedAppUnitsPerPixel;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mIndex;
|
2008-09-13 02:42:11 -07:00
|
|
|
};
|
|
|
|
|
2011-06-22 11:11:48 -07:00
|
|
|
/**
|
|
|
|
* This class adds basic support for limiting the rendering to the part inside
|
|
|
|
* the specified edges. It's a base class for the display item classes that
|
|
|
|
* does the actual work. The two members, mLeftEdge and mRightEdge, are
|
|
|
|
* relative to the edges of the frame's scrollable overflow rectangle and is
|
|
|
|
* the amount to suppress on each side.
|
|
|
|
*
|
|
|
|
* Setting none, both or only one edge is allowed.
|
|
|
|
* The values must be non-negative.
|
|
|
|
* The default value for both edges is zero, which means everything is painted.
|
|
|
|
*/
|
|
|
|
class nsCharClipDisplayItem : public nsDisplayItem {
|
|
|
|
public:
|
|
|
|
nsCharClipDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame), mLeftEdge(0), mRightEdge(0) {}
|
|
|
|
|
2012-08-08 04:37:14 -07:00
|
|
|
nsCharClipDisplayItem(nsIFrame* aFrame)
|
2013-03-04 01:56:02 -08:00
|
|
|
: nsDisplayItem(aFrame) {}
|
2012-08-08 04:37:14 -07:00
|
|
|
|
2011-06-22 11:11:48 -07:00
|
|
|
struct ClipEdges {
|
|
|
|
ClipEdges(const nsDisplayItem& aItem,
|
|
|
|
nscoord aLeftEdge, nscoord aRightEdge) {
|
2013-04-19 05:02:13 -07:00
|
|
|
nsRect r = aItem.Frame()->GetScrollableOverflowRect() +
|
2011-06-22 11:11:48 -07:00
|
|
|
aItem.ToReferenceFrame();
|
|
|
|
mX = aLeftEdge > 0 ? r.x + aLeftEdge : nscoord_MIN;
|
2013-01-15 04:22:03 -08:00
|
|
|
mXMost = aRightEdge > 0 ? std::max(r.XMost() - aRightEdge, mX) : nscoord_MAX;
|
2011-06-22 11:11:48 -07:00
|
|
|
}
|
|
|
|
void Intersect(nscoord* aX, nscoord* aWidth) const {
|
|
|
|
nscoord xmost1 = *aX + *aWidth;
|
2013-01-15 04:22:03 -08:00
|
|
|
*aX = std::max(*aX, mX);
|
|
|
|
*aWidth = std::max(std::min(xmost1, mXMost) - *aX, 0);
|
2011-06-22 11:11:48 -07:00
|
|
|
}
|
|
|
|
nscoord mX;
|
|
|
|
nscoord mXMost;
|
|
|
|
};
|
|
|
|
|
|
|
|
ClipEdges Edges() const { return ClipEdges(*this, mLeftEdge, mRightEdge); }
|
|
|
|
|
|
|
|
static nsCharClipDisplayItem* CheckCast(nsDisplayItem* aItem) {
|
|
|
|
nsDisplayItem::Type t = aItem->GetType();
|
|
|
|
return (t == nsDisplayItem::TYPE_TEXT ||
|
|
|
|
t == nsDisplayItem::TYPE_TEXT_DECORATION ||
|
|
|
|
t == nsDisplayItem::TYPE_TEXT_SHADOW)
|
2012-07-30 07:20:58 -07:00
|
|
|
? static_cast<nsCharClipDisplayItem*>(aItem) : nullptr;
|
2011-06-22 11:11:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord mLeftEdge; // length from the left side
|
|
|
|
nscoord mRightEdge; // length from the right side
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /*NSDISPLAYLIST_H_*/
|