2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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
|
|
|
|
|
|
|
#ifndef nsLayoutUtils_h__
|
|
|
|
#define nsLayoutUtils_h__
|
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
|
|
|
#include "nsChangeHint.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsFrameList.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "GraphicsFilter.h"
|
|
|
|
#include "nsCSSPseudoElements.h"
|
|
|
|
#include "FrameMetrics.h"
|
|
|
|
#include "gfx3DMatrix.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsCSSProperty.h"
|
|
|
|
#include "nsStyleCoord.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsRuleNode.h"
|
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "Units.h"
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIFormControlFrame;
|
|
|
|
class nsPresContext;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsIScrollableFrame;
|
|
|
|
class nsIDOMEvent;
|
|
|
|
class nsRegion;
|
|
|
|
class nsDisplayListBuilder;
|
2011-04-05 22:00:25 -07:00
|
|
|
class nsDisplayItem;
|
2011-04-07 18:05:49 -07:00
|
|
|
class nsFontMetrics;
|
2011-06-15 23:31:36 -07:00
|
|
|
class nsFontFaceList;
|
2012-05-31 11:16:49 -07:00
|
|
|
class nsIImageLoadingContent;
|
2013-08-19 15:55:18 -07:00
|
|
|
class nsStyleContext;
|
|
|
|
class nsBlockFrame;
|
2013-10-01 14:00:38 -07:00
|
|
|
class gfxASurface;
|
2013-08-19 15:55:18 -07:00
|
|
|
class gfxDrawable;
|
|
|
|
class nsView;
|
2013-09-30 14:26:04 -07:00
|
|
|
class nsIFrame;
|
|
|
|
class nsStyleCoord;
|
|
|
|
class nsStyleCorners;
|
|
|
|
class gfxContext;
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
class imgIRequest;
|
|
|
|
class nsIDocument;
|
2013-09-20 03:21:03 -07:00
|
|
|
class gfxPoint;
|
2013-09-30 14:26:04 -07:00
|
|
|
struct nsStyleFont;
|
|
|
|
struct nsStyleImageOrientation;
|
|
|
|
struct nsOverflowAreas;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-03 13:50:16 -08:00
|
|
|
namespace mozilla {
|
2013-02-28 12:22:43 -08:00
|
|
|
class SVGImageContext;
|
2013-09-30 14:26:04 -07:00
|
|
|
struct IntrinsicSize;
|
2013-09-26 23:02:03 -07:00
|
|
|
struct ContainerLayerParameters;
|
2011-12-03 13:50:16 -08:00
|
|
|
namespace dom {
|
2013-09-20 03:21:03 -07:00
|
|
|
class DOMRectList;
|
2011-12-03 13:50:16 -08:00
|
|
|
class Element;
|
2012-12-31 09:25:46 -08:00
|
|
|
class HTMLImageElement;
|
2013-01-03 21:16:14 -08:00
|
|
|
class HTMLCanvasElement;
|
2013-03-19 05:27:35 -07:00
|
|
|
class HTMLVideoElement;
|
2011-12-03 13:50:16 -08:00
|
|
|
} // namespace dom
|
2013-09-26 23:02:03 -07:00
|
|
|
namespace layers {
|
|
|
|
class Layer;
|
|
|
|
}
|
2014-03-08 01:25:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
struct DisplayPortPropertyData {
|
|
|
|
DisplayPortPropertyData(const nsRect& aRect, uint32_t aPriority)
|
|
|
|
: mRect(aRect)
|
|
|
|
, mPriority(aPriority)
|
|
|
|
{}
|
|
|
|
nsRect mRect;
|
|
|
|
uint32_t mPriority;
|
|
|
|
};
|
2013-12-11 12:48:06 -08:00
|
|
|
|
|
|
|
template <class AnimationsOrTransitions>
|
|
|
|
extern AnimationsOrTransitions* HasAnimationOrTransition(nsIContent* aContent,
|
|
|
|
nsIAtom* aAnimationProperty,
|
|
|
|
nsCSSProperty aProperty);
|
|
|
|
|
2011-12-03 13:50:16 -08:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* nsLayoutUtils is a namespace class used for various helper
|
|
|
|
* functions that are useful in multiple places in layout. The goal
|
|
|
|
* is not to define multiple copies of the same static helper.
|
|
|
|
*/
|
|
|
|
class nsLayoutUtils
|
|
|
|
{
|
2013-10-01 14:01:19 -07:00
|
|
|
typedef ::GraphicsFilter GraphicsFilter;
|
2013-09-20 03:21:03 -07:00
|
|
|
typedef mozilla::dom::DOMRectList DOMRectList;
|
2013-09-26 23:02:03 -07:00
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
|
2013-12-11 13:05:27 -08:00
|
|
|
typedef mozilla::gfx::SourceSurface SourceSurface;
|
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
2010-10-11 13:07:59 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2013-08-08 12:56:08 -07:00
|
|
|
typedef mozilla::layers::FrameMetrics FrameMetrics;
|
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
2013-09-20 03:21:03 -07:00
|
|
|
typedef mozilla::CSSPoint CSSPoint;
|
2009-12-23 21:20:41 -08:00
|
|
|
|
2013-08-08 12:56:08 -07:00
|
|
|
/**
|
|
|
|
* Finds previously assigned ViewID for the given content element, if any.
|
|
|
|
* Returns whether a ViewID was previously assigned.
|
|
|
|
*/
|
2013-11-13 10:22:24 -08:00
|
|
|
static bool FindIDFor(const nsIContent* aContent, ViewID* aOutViewId);
|
2013-08-08 12:56:08 -07:00
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
/**
|
|
|
|
* Finds previously assigned or generates a unique ViewID for the given
|
2013-11-08 16:07:00 -08:00
|
|
|
* content element.
|
2011-01-13 09:45:14 -08:00
|
|
|
*/
|
2013-11-08 16:07:00 -08:00
|
|
|
static ViewID FindOrCreateIDFor(nsIContent* aContent);
|
2011-01-13 09:45:14 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find content for given ID.
|
|
|
|
*/
|
|
|
|
static nsIContent* FindContentFor(ViewID aId);
|
|
|
|
|
2013-07-30 11:03:42 -07:00
|
|
|
/**
|
|
|
|
* Find the scrollable frame for a given ID.
|
|
|
|
*/
|
|
|
|
static nsIScrollableFrame* FindScrollableFrameFor(ViewID aId);
|
|
|
|
|
2011-03-15 16:20:19 -07:00
|
|
|
/**
|
|
|
|
* Get display port for the given element.
|
|
|
|
*/
|
2013-09-26 22:57:20 -07:00
|
|
|
static bool GetDisplayPort(nsIContent* aContent, nsRect *aResult = nullptr);
|
2011-03-15 16:20:19 -07:00
|
|
|
|
2012-11-21 14:34:18 -08:00
|
|
|
/**
|
|
|
|
* Get the critical display port for the given element.
|
|
|
|
*/
|
2013-09-26 22:57:20 -07:00
|
|
|
static bool GetCriticalDisplayPort(nsIContent* aContent, nsRect* aResult = nullptr);
|
2012-11-21 14:34:18 -08:00
|
|
|
|
2009-12-23 21:20:41 -08:00
|
|
|
/**
|
2011-08-24 13:54:30 -07:00
|
|
|
* Use heuristics to figure out the child list that
|
2010-07-02 21:18:55 -07:00
|
|
|
* aChildFrame is currently in.
|
2009-12-23 21:20:41 -08:00
|
|
|
*/
|
2013-09-30 14:26:04 -07:00
|
|
|
static mozilla::layout::FrameChildListID GetChildListNameFor(nsIFrame* aChildFrame);
|
2009-12-23 21:20:41 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2008-08-17 18:16:42 -07:00
|
|
|
* GetBeforeFrame returns the outermost :before frame of the given frame, if
|
2007-03-22 10:30:00 -07:00
|
|
|
* one exists. This is typically O(1). The frame passed in must be
|
2010-04-27 09:15:01 -07:00
|
|
|
* the first-in-flow.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* @param aFrame the frame whose :before is wanted
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the :before frame or nullptr if there isn't one
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
static nsIFrame* GetBeforeFrame(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
2008-08-17 18:16:42 -07:00
|
|
|
* GetAfterFrame returns the outermost :after frame of the given frame, if one
|
2007-03-22 10:30:00 -07:00
|
|
|
* exists. This will walk the in-flow chain to the last-in-flow if
|
|
|
|
* needed. This function is typically O(N) in the number of child
|
|
|
|
* frames, following in-flows, etc.
|
|
|
|
*
|
|
|
|
* @param aFrame the frame whose :after is wanted
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the :after frame or nullptr if there isn't one
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
static nsIFrame* GetAfterFrame(nsIFrame* aFrame);
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
/**
|
2007-03-22 10:30:00 -07:00
|
|
|
* Given a frame, search up the frame tree until we find an
|
2007-07-03 18:13:07 -07:00
|
|
|
* ancestor that (or the frame itself) is of type aFrameType, if any.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2007-07-03 18:13:07 -07:00
|
|
|
* @param aFrame the frame to start at
|
|
|
|
* @param aFrameType the frame type to look for
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return a frame of the given type or nullptr if no
|
2007-07-03 18:13:07 -07:00
|
|
|
* such ancestor exists
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetClosestFrameOfType(nsIFrame* aFrame, nsIAtom* aFrameType);
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
/**
|
2007-07-03 18:13:07 -07:00
|
|
|
* Given a frame, search up the frame tree until we find an
|
|
|
|
* ancestor that (or the frame itself) is a "Page" frame, if any.
|
|
|
|
*
|
|
|
|
* @param aFrame the frame to start at
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return a frame of type nsGkAtoms::pageFrame or nullptr if no
|
2007-03-22 10:30:00 -07:00
|
|
|
* such ancestor exists
|
|
|
|
*/
|
2007-07-03 18:13:07 -07:00
|
|
|
static nsIFrame* GetPageFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
return GetClosestFrameOfType(aFrame, nsGkAtoms::pageFrame);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-01 09:21:00 -08:00
|
|
|
/**
|
|
|
|
* Given a frame which is the primary frame for an element,
|
|
|
|
* return the frame that has the non-psuedoelement style context for
|
|
|
|
* the content.
|
|
|
|
* This is aPrimaryFrame itself except for tableOuter frames.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetStyleFrame(nsIFrame* aPrimaryFrame);
|
|
|
|
|
2013-06-24 22:32:10 -07:00
|
|
|
/**
|
|
|
|
* Given a content node,
|
|
|
|
* return the frame that has the non-psuedoelement style context for
|
|
|
|
* the content. May return null.
|
|
|
|
* This is aContent->GetPrimaryFrame() except for tableOuter frames.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetStyleFrame(const nsIContent* aContent);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* IsGeneratedContentFor returns true if aFrame is the outermost
|
2008-08-17 18:16:42 -07:00
|
|
|
* frame for generated content of type aPseudoElement for aContent.
|
|
|
|
* aFrame *might not* have the aPseudoElement pseudo-style! For example
|
|
|
|
* it might be a table outer frame and the inner table frame might
|
|
|
|
* have the pseudo-style.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* @param aContent the content node we're looking at. If this is
|
|
|
|
* null, then we just assume that aFrame has the right content
|
|
|
|
* pointer.
|
|
|
|
* @param aFrame the frame we're looking at
|
|
|
|
* @param aPseudoElement the pseudo type we're interested in
|
|
|
|
* @return whether aFrame is the generated aPseudoElement frame for aContent
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsGeneratedContentFor(nsIContent* aContent, nsIFrame* aFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aPseudoElement);
|
|
|
|
|
2010-10-13 03:52:45 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
// TODO: remove, see bug 598468.
|
|
|
|
static bool gPreventAssertInCompareTreePosition;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* CompareTreePosition determines whether aContent1 comes before or
|
|
|
|
* after aContent2 in a preorder traversal of the content tree.
|
2010-04-27 09:15:01 -07:00
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aCommonAncestor either null, or a common ancestor of
|
|
|
|
* aContent1 and aContent2. Actually this is
|
|
|
|
* only a hint; if it's not an ancestor of
|
|
|
|
* aContent1 or aContent2, this function will
|
|
|
|
* still work, but it will be slower than
|
|
|
|
* normal.
|
|
|
|
* @return < 0 if aContent1 is before aContent2
|
|
|
|
* > 0 if aContent1 is after aContent2,
|
|
|
|
* 0 otherwise (meaning they're the same, or they're in
|
|
|
|
* different documents)
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t CompareTreePosition(nsIContent* aContent1,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIContent* aContent2,
|
2012-07-30 07:20:58 -07:00
|
|
|
const nsIContent* aCommonAncestor = nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return DoCompareTreePosition(aContent1, aContent2, -1, 1, aCommonAncestor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* More generic version of |CompareTreePosition|. |aIf1Ancestor|
|
|
|
|
* gives the value to return when 1 is an ancestor of 2, and likewise
|
|
|
|
* for |aIf2Ancestor|. Passing (-1, 1) gives preorder traversal
|
|
|
|
* order, and (1, -1) gives postorder traversal order.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t DoCompareTreePosition(nsIContent* aContent1,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIContent* aContent2,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aIf1Ancestor,
|
|
|
|
int32_t aIf2Ancestor,
|
2012-07-30 07:20:58 -07:00
|
|
|
const nsIContent* aCommonAncestor = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CompareTreePosition determines whether aFrame1 comes before or
|
|
|
|
* after aFrame2 in a preorder traversal of the frame tree, where out
|
|
|
|
* of flow frames are treated as children of their placeholders. This is
|
|
|
|
* basically the same ordering as DoCompareTreePosition(nsIContent*) except
|
|
|
|
* that it handles anonymous content properly and there are subtleties with
|
|
|
|
* continuations.
|
2010-04-27 09:15:01 -07:00
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aCommonAncestor either null, or a common ancestor of
|
|
|
|
* aContent1 and aContent2. Actually this is
|
|
|
|
* only a hint; if it's not an ancestor of
|
|
|
|
* aContent1 or aContent2, this function will
|
|
|
|
* still work, but it will be slower than
|
|
|
|
* normal.
|
|
|
|
* @return < 0 if aContent1 is before aContent2
|
|
|
|
* > 0 if aContent1 is after aContent2,
|
|
|
|
* 0 otherwise (meaning they're the same, or they're in
|
|
|
|
* different frame trees)
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t CompareTreePosition(nsIFrame* aFrame1,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aFrame2,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* aCommonAncestor = nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return DoCompareTreePosition(aFrame1, aFrame2, -1, 1, aCommonAncestor);
|
|
|
|
}
|
|
|
|
|
2013-10-22 05:06:01 -07:00
|
|
|
static int32_t CompareTreePosition(nsIFrame* aFrame1,
|
|
|
|
nsIFrame* aFrame2,
|
|
|
|
nsTArray<nsIFrame*>& aFrame2Ancestors,
|
|
|
|
nsIFrame* aCommonAncestor = nullptr)
|
|
|
|
{
|
|
|
|
return DoCompareTreePosition(aFrame1, aFrame2, aFrame2Ancestors,
|
|
|
|
-1, 1, aCommonAncestor);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* More generic version of |CompareTreePosition|. |aIf1Ancestor|
|
|
|
|
* gives the value to return when 1 is an ancestor of 2, and likewise
|
|
|
|
* for |aIf2Ancestor|. Passing (-1, 1) gives preorder traversal
|
|
|
|
* order, and (1, -1) gives postorder traversal order.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t DoCompareTreePosition(nsIFrame* aFrame1,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aFrame2,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aIf1Ancestor,
|
|
|
|
int32_t aIf2Ancestor,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* aCommonAncestor = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-22 05:06:01 -07:00
|
|
|
static nsIFrame* FillAncestors(nsIFrame* aFrame,
|
|
|
|
nsIFrame* aStopAtAncestor,
|
|
|
|
nsTArray<nsIFrame*>* aAncestors);
|
|
|
|
|
|
|
|
static int32_t DoCompareTreePosition(nsIFrame* aFrame1,
|
|
|
|
nsIFrame* aFrame2,
|
|
|
|
nsTArray<nsIFrame*>& aFrame2Ancestors,
|
|
|
|
int32_t aIf1Ancestor,
|
|
|
|
int32_t aIf2Ancestor,
|
|
|
|
nsIFrame* aCommonAncestor);
|
|
|
|
|
2008-01-27 00:13:19 -08:00
|
|
|
/**
|
2013-09-25 04:42:34 -07:00
|
|
|
* LastContinuationWithChild gets the last continuation in aFrame's chain
|
2008-01-27 00:13:19 -08:00
|
|
|
* that has a child, or the first continuation if the frame has no children.
|
|
|
|
*/
|
2013-09-25 04:42:34 -07:00
|
|
|
static nsIFrame* LastContinuationWithChild(nsIFrame* aFrame);
|
2008-01-27 00:13:19 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2012-07-30 07:20:58 -07:00
|
|
|
* GetLastSibling simply finds the last sibling of aFrame, or returns nullptr if
|
2007-03-22 10:30:00 -07:00
|
|
|
* aFrame is null.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetLastSibling(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FindSiblingViewFor locates the child of aParentView that aFrame's
|
|
|
|
* view should be inserted 'above' (i.e., before in sibling view
|
|
|
|
* order). This is the first child view of aParentView whose
|
|
|
|
* corresponding content is before aFrame's content (view siblings
|
|
|
|
* are in reverse content order).
|
|
|
|
*/
|
2013-01-03 05:23:11 -08:00
|
|
|
static nsView* FindSiblingViewFor(nsView* aParentView, nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parent of aFrame. If aFrame is the root frame for a document,
|
|
|
|
* and the document has a parent document in the same view hierarchy, then
|
|
|
|
* we try to return the subdocumentframe in the parent document.
|
2008-09-03 14:35:52 -07:00
|
|
|
* @param aExtraOffset [in/out] if non-null, then as we cross documents
|
2010-07-18 19:23:47 -07:00
|
|
|
* an extra offset may be required and it will be added to aCrossDocOffset.
|
|
|
|
* Be careful dealing with this extra offset as it is in app units of the
|
|
|
|
* parent document, which may have a different app units per dev pixel ratio
|
|
|
|
* than the child document.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2008-09-03 14:35:52 -07:00
|
|
|
static nsIFrame* GetCrossDocParentFrame(const nsIFrame* aFrame,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsPoint* aCrossDocOffset = nullptr);
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* IsProperAncestorFrame checks whether aAncestorFrame is an ancestor
|
|
|
|
* of aFrame and not equal to aFrame.
|
2012-07-30 07:20:58 -07:00
|
|
|
* @param aCommonAncestor nullptr, or a common ancestor of aFrame and
|
2007-03-22 10:30:00 -07:00
|
|
|
* aAncestorFrame. If non-null, this can bound the search and speed up
|
|
|
|
* the function
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsProperAncestorFrame(nsIFrame* aAncestorFrame, nsIFrame* aFrame,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* aCommonAncestor = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Like IsProperAncestorFrame, but looks across document boundaries.
|
2009-07-21 17:44:56 -07:00
|
|
|
*
|
|
|
|
* Just like IsAncestorFrameCrossDoc, except that it returns false when
|
|
|
|
* aFrame == aAncestorFrame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsProperAncestorFrameCrossDoc(nsIFrame* aAncestorFrame, nsIFrame* aFrame,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* aCommonAncestor = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-21 17:44:56 -07:00
|
|
|
/**
|
|
|
|
* IsAncestorFrameCrossDoc checks whether aAncestorFrame is an ancestor
|
|
|
|
* of aFrame or equal to aFrame, looking across document boundaries.
|
2012-07-30 07:20:58 -07:00
|
|
|
* @param aCommonAncestor nullptr, or a common ancestor of aFrame and
|
2009-07-21 17:44:56 -07:00
|
|
|
* aAncestorFrame. If non-null, this can bound the search and speed up
|
|
|
|
* the function.
|
|
|
|
*
|
|
|
|
* Just like IsProperAncestorFrameCrossDoc, except that it returns true when
|
|
|
|
* aFrame == aAncestorFrame.
|
|
|
|
*/
|
2012-09-12 17:32:53 -07:00
|
|
|
static bool IsAncestorFrameCrossDoc(const nsIFrame* aAncestorFrame, const nsIFrame* aFrame,
|
|
|
|
const nsIFrame* aCommonAncestor = nullptr);
|
2009-07-21 17:44:56 -07:00
|
|
|
|
2013-12-17 03:30:21 -08:00
|
|
|
/**
|
|
|
|
* Sets the fixed-pos metadata properties on aLayer.
|
|
|
|
* aAnchorRect is the basic anchor rectangle. If aFixedPosFrame is not a viewport
|
|
|
|
* frame, then we pick a corner of aAnchorRect to as the anchor point for the
|
|
|
|
* fixed-pos layer (i.e. the point to remain stable during zooming), based
|
|
|
|
* on which of the fixed-pos frame's CSS absolute positioning offset
|
|
|
|
* properties (top, left, right, bottom) are auto. aAnchorRect is in the
|
|
|
|
* coordinate space of aLayer's container layer (i.e. relative to the reference
|
|
|
|
* frame of the display item which is building aLayer's container layer).
|
|
|
|
*/
|
2013-09-26 23:02:03 -07:00
|
|
|
static void SetFixedPositionLayerData(Layer* aLayer, const nsIFrame* aViewportFrame,
|
2013-12-17 03:30:21 -08:00
|
|
|
const nsRect& aAnchorRect,
|
2013-09-26 23:02:03 -07:00
|
|
|
const nsIFrame* aFixedPosFrame,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const ContainerLayerParameters& aContainerParameters);
|
|
|
|
|
2013-12-17 03:30:21 -08:00
|
|
|
/**
|
|
|
|
* Return true if aPresContext's viewport has a displayport.
|
|
|
|
* Fills in aDisplayPort with the displayport rectangle if non-null.
|
|
|
|
*/
|
|
|
|
static bool ViewportHasDisplayPort(nsPresContext* aPresContext,
|
|
|
|
nsRect* aDisplayPort = nullptr);
|
|
|
|
|
2013-09-26 23:01:11 -07:00
|
|
|
/**
|
|
|
|
* Return true if aFrame is a fixed-pos frame and is a child of a viewport
|
|
|
|
* which has a displayport. These frames get special treatment from the compositor.
|
|
|
|
* aDisplayPort, if non-null, is set to the display port rectangle (relative to
|
|
|
|
* the viewport).
|
|
|
|
*/
|
|
|
|
static bool IsFixedPosFrameInDisplayPort(const nsIFrame* aFrame,
|
|
|
|
nsRect* aDisplayPort = nullptr);
|
|
|
|
|
2010-07-15 14:07:51 -07:00
|
|
|
/**
|
2014-02-18 01:48:18 -08:00
|
|
|
* Finds the nearest ancestor frame that is considered to have (or will have)
|
|
|
|
* "animated geometry". For example the scrolled frames of scrollframes which
|
|
|
|
* are actively being scrolled fall into this category. Frames with certain
|
|
|
|
* CSS properties that are being animated (e.g. 'left'/'top' etc) are also
|
|
|
|
* placed in this category. Frames with animated CSS transforms are not
|
|
|
|
* put in this category because they can be handled directly by
|
|
|
|
* nsDisplayTransform.
|
|
|
|
* Stop searching at aStopAtAncestor if there is no such ancestor before it
|
|
|
|
* in the ancestor chain.
|
2013-09-25 14:07:26 -07:00
|
|
|
* Frames with different active geometry roots are in different ThebesLayers,
|
|
|
|
* so that we can animate the geometry root by changing its transform (either
|
|
|
|
* on the main thread or in the compositor).
|
2014-02-18 01:48:18 -08:00
|
|
|
* This function is idempotent: a frame returned by GetAnimatedGeometryRootFor
|
|
|
|
* is always returned again if you pass it to GetAnimatedGeometryRootFor.
|
2010-07-15 14:07:51 -07:00
|
|
|
*/
|
2014-02-18 01:48:18 -08:00
|
|
|
static nsIFrame* GetAnimatedGeometryRootFor(nsIFrame* aFrame,
|
|
|
|
const nsIFrame* aStopAtAncestor = nullptr);
|
|
|
|
|
2013-09-25 14:07:26 -07:00
|
|
|
static nsIFrame* GetAnimatedGeometryRootFor(nsDisplayItem* aItem,
|
|
|
|
nsDisplayListBuilder* aBuilder);
|
2010-07-15 14:07:51 -07:00
|
|
|
|
2014-02-18 01:48:18 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* GetScrollableFrameFor returns the scrollable frame for a scrolled frame
|
|
|
|
*/
|
2012-08-16 16:40:10 -07:00
|
|
|
static nsIScrollableFrame* GetScrollableFrameFor(const nsIFrame *aScrolledFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2009-09-01 04:29:27 -07:00
|
|
|
* GetNearestScrollableFrameForDirection locates the first ancestor of
|
|
|
|
* aFrame (or aFrame itself) that is scrollable with overflow:scroll or
|
|
|
|
* overflow:auto in the given direction and where either the scrollbar for
|
|
|
|
* that direction is visible or the frame can be scrolled by some
|
|
|
|
* positive amount in that direction.
|
|
|
|
* The search extends across document boundaries.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2009-09-01 04:29:27 -07:00
|
|
|
* @param aFrame the frame to start with
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aDirection Whether it's for horizontal or vertical scrolling.
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the nearest scrollable frame or nullptr if not found
|
2009-09-01 04:29:27 -07:00
|
|
|
*/
|
|
|
|
enum Direction { eHorizontal, eVertical };
|
|
|
|
static nsIScrollableFrame* GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
|
|
|
|
Direction aDirection);
|
|
|
|
|
2013-07-30 21:01:06 -07:00
|
|
|
enum {
|
|
|
|
SCROLLABLE_SAME_DOC = 0x01,
|
|
|
|
SCROLLABLE_INCLUDE_HIDDEN = 0x02
|
|
|
|
};
|
2009-09-01 04:29:27 -07:00
|
|
|
/**
|
|
|
|
* GetNearestScrollableFrame locates the first ancestor of aFrame
|
|
|
|
* (or aFrame itself) that is scrollable with overflow:scroll or
|
|
|
|
* overflow:auto in some direction.
|
|
|
|
*
|
|
|
|
* @param aFrame the frame to start with
|
2013-07-30 21:01:06 -07:00
|
|
|
* @param aFlags if SCROLLABLE_SAME_DOC is set, do not search across
|
|
|
|
* document boundaries. If SCROLLABLE_INCLUDE_HIDDEN is set, include
|
|
|
|
* frames scrollable with overflow:hidden.
|
2012-07-30 07:20:58 -07:00
|
|
|
* @return the nearest scrollable frame or nullptr if not found
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-07-30 21:01:06 -07:00
|
|
|
static nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame,
|
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-28 17:38:22 -08:00
|
|
|
/**
|
|
|
|
* GetScrolledRect returns the range of allowable scroll offsets
|
|
|
|
* for aScrolledFrame, assuming the scrollable overflow area is
|
|
|
|
* aScrolledFrameOverflowArea and the scrollport size is aScrollPortSize.
|
|
|
|
* aDirection is either NS_STYLE_DIRECTION_LTR or NS_STYLE_DIRECTION_RTL.
|
|
|
|
*/
|
|
|
|
static nsRect GetScrolledRect(nsIFrame* aScrolledFrame,
|
|
|
|
const nsRect& aScrolledFrameOverflowArea,
|
|
|
|
const nsSize& aScrollPortSize,
|
|
|
|
uint8_t aDirection);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* HasPseudoStyle returns true if aContent (whose primary style
|
2007-03-22 10:30:00 -07:00
|
|
|
* context is aStyleContext) has the aPseudoElement pseudo-style
|
2011-10-17 07:59:28 -07:00
|
|
|
* attached to it; returns false otherwise.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* @param aContent the content node we're looking at
|
|
|
|
* @param aStyleContext aContent's style context
|
2009-12-10 23:37:40 -08:00
|
|
|
* @param aPseudoElement the id of the pseudo style we care about
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aPresContext the presentation context
|
|
|
|
* @return whether aContent has aPseudoElement style attached to it
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool HasPseudoStyle(nsIContent* aContent,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleContext* aStyleContext,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsCSSPseudoElements::Type aPseudoElement,
|
2010-08-05 15:11:23 -07:00
|
|
|
nsPresContext* aPresContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this frame is a placeholder for a float, then return the float,
|
2012-07-30 07:20:58 -07:00
|
|
|
* otherwise return nullptr. aPlaceholder must be a placeholder frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2009-11-16 13:00:07 -08:00
|
|
|
static nsIFrame* GetFloatFromPlaceholder(nsIFrame* aPlaceholder);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Combine aNewBreakType with aOrigBreakType, but limit the break types
|
|
|
|
// to NS_STYLE_CLEAR_LEFT, RIGHT, LEFT_AND_RIGHT.
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint8_t CombineBreakType(uint8_t aOrigBreakType, uint8_t aNewBreakType);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the coordinates of a given DOM mouse event, relative to a given
|
2013-10-01 20:46:03 -07:00
|
|
|
* frame. Works only for DOM events generated by WidgetGUIEvents.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aDOMEvent the event
|
|
|
|
* @param aFrame the frame to make coordinates relative to
|
|
|
|
* @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
|
|
|
|
* for some reason the coordinates for the mouse are not known (e.g.,
|
|
|
|
* the event is not a GUI event).
|
|
|
|
*/
|
|
|
|
static nsPoint GetDOMEventCoordinatesRelativeTo(nsIDOMEvent* aDOMEvent,
|
|
|
|
nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the coordinates of a given native mouse event, relative to a given
|
|
|
|
* frame.
|
|
|
|
* @param aEvent the event
|
|
|
|
* @param aFrame the frame to make coordinates relative to
|
|
|
|
* @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
|
|
|
|
* for some reason the coordinates for the mouse are not known (e.g.,
|
|
|
|
* the event is not a GUI event).
|
|
|
|
*/
|
2013-10-01 20:46:04 -07:00
|
|
|
static nsPoint GetEventCoordinatesRelativeTo(
|
|
|
|
const mozilla::WidgetEvent* aEvent,
|
|
|
|
nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-16 16:24:11 -08:00
|
|
|
/**
|
|
|
|
* Get the coordinates of a given point relative to an event and a
|
|
|
|
* given frame.
|
|
|
|
* @param aEvent the event
|
|
|
|
* @param aPoint the point to get the coordinates relative to
|
|
|
|
* @param aFrame the frame to make coordinates relative to
|
|
|
|
* @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
|
|
|
|
* for some reason the coordinates for the mouse are not known (e.g.,
|
|
|
|
* the event is not a GUI event).
|
|
|
|
*/
|
2013-10-01 20:46:04 -07:00
|
|
|
static nsPoint GetEventCoordinatesRelativeTo(
|
|
|
|
const mozilla::WidgetEvent* aEvent,
|
|
|
|
const nsIntPoint aPoint,
|
|
|
|
nsIFrame* aFrame);
|
2011-12-16 16:24:11 -08:00
|
|
|
|
2012-09-10 14:02:23 -07:00
|
|
|
/**
|
|
|
|
* Get the coordinates of a given point relative to a widget and a
|
|
|
|
* given frame.
|
|
|
|
* @param aWidget the event src widget
|
|
|
|
* @param aPoint the point to get the coordinates relative to
|
|
|
|
* @param aFrame the frame to make coordinates relative to
|
|
|
|
* @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
|
|
|
|
* for some reason the coordinates for the mouse are not known (e.g.,
|
|
|
|
* the event is not a GUI event).
|
|
|
|
*/
|
|
|
|
static nsPoint GetEventCoordinatesRelativeTo(nsIWidget* aWidget,
|
|
|
|
const nsIntPoint aPoint,
|
|
|
|
nsIFrame* aFrame);
|
|
|
|
|
2009-09-09 22:16:18 -07:00
|
|
|
/**
|
2010-03-18 22:02:53 -07:00
|
|
|
* Get the popup frame of a given native mouse event.
|
2010-07-27 06:38:03 -07:00
|
|
|
* @param aPresContext only check popups within aPresContext or a descendant
|
2010-03-18 22:02:53 -07:00
|
|
|
* @param aEvent the event.
|
|
|
|
* @return Null, if there is no popup frame at the point, otherwise,
|
|
|
|
* returns top-most popup frame at the point.
|
|
|
|
*/
|
2013-10-01 20:46:04 -07:00
|
|
|
static nsIFrame* GetPopupFrameForEventCoordinates(
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const mozilla::WidgetEvent* aEvent);
|
2010-03-18 22:02:53 -07:00
|
|
|
|
2013-02-10 22:22:18 -08:00
|
|
|
/**
|
2007-03-22 10:30:00 -07:00
|
|
|
* Translate from widget coordinates to the view's coordinates
|
|
|
|
* @param aPresContext the PresContext for the view
|
|
|
|
* @param aWidget the widget
|
|
|
|
* @param aPt the point relative to the widget
|
|
|
|
* @param aView view to which returned coordinates are relative
|
|
|
|
* @return the point in the view's coordinates
|
|
|
|
*/
|
2010-04-27 09:15:01 -07:00
|
|
|
static nsPoint TranslateWidgetToView(nsPresContext* aPresContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIWidget* aWidget, nsIntPoint aPt,
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* aView);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/**
|
|
|
|
* Given a matrix and a point, let T be the transformation matrix translating points
|
|
|
|
* in the coordinate space with origin aOrigin to the coordinate space used by the
|
|
|
|
* matrix. If M is the stored matrix, this function returns (T-1)MT, the matrix
|
|
|
|
* that's equivalent to aMatrix but in the coordinate space that treats aOrigin
|
|
|
|
* as the origin.
|
|
|
|
*
|
|
|
|
* @param aOrigin The origin to translate to.
|
|
|
|
* @param aMatrix The matrix to change the basis of.
|
|
|
|
* @return A matrix equivalent to aMatrix, but operating in the coordinate system with
|
|
|
|
* origin aOrigin.
|
|
|
|
*/
|
2011-08-02 20:04:23 -07:00
|
|
|
static gfx3DMatrix ChangeMatrixBasis(const gfxPoint3D &aOrigin, const gfx3DMatrix &aMatrix);
|
2008-09-13 02:42:11 -07:00
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
/**
|
|
|
|
* Find IDs corresponding to a scrollable content element in the child process.
|
|
|
|
* In correspondence with the shadow layer tree, you can use this to perform a
|
|
|
|
* hit test that corresponds to a specific shadow layer that you can then perform
|
|
|
|
* transformations on to do parent-side scrolling.
|
|
|
|
*
|
|
|
|
* @param aFrame The root frame of a stack context
|
|
|
|
* @param aTarget The rect to hit test relative to the frame origin
|
|
|
|
* @param aOutIDs All found IDs are added here
|
|
|
|
* @param aIgnoreRootScrollFrame a boolean to control if the display list
|
|
|
|
* builder should ignore the root scroll frame
|
|
|
|
*/
|
|
|
|
static nsresult GetRemoteContentIds(nsIFrame* aFrame,
|
|
|
|
const nsRect& aTarget,
|
|
|
|
nsTArray<ViewID> &aOutIDs,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIgnoreRootScrollFrame);
|
2011-01-13 09:45:14 -08:00
|
|
|
|
2013-07-25 19:31:41 -07:00
|
|
|
enum FrameForPointFlags {
|
|
|
|
/**
|
|
|
|
* When set, paint suppression is ignored, so we'll return non-root page
|
|
|
|
* elements even if paint suppression is stopping them from painting.
|
|
|
|
*/
|
|
|
|
IGNORE_PAINT_SUPPRESSION = 0x01,
|
|
|
|
/**
|
|
|
|
* When set, clipping due to the root scroll frame (and any other viewport-
|
|
|
|
* related clipping) is ignored.
|
|
|
|
*/
|
2013-12-17 21:37:24 -08:00
|
|
|
IGNORE_ROOT_SCROLL_FRAME = 0x02,
|
|
|
|
/**
|
|
|
|
* When set, return only content in the same document as aFrame.
|
|
|
|
*/
|
|
|
|
IGNORE_CROSS_DOC = 0x04
|
2013-07-25 19:31:41 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Given aFrame, the root frame of a stacking context, find its descendant
|
|
|
|
* frame under the point aPt that receives a mouse event at that location,
|
2012-07-30 07:20:58 -07:00
|
|
|
* or nullptr if there is no such frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aPt the point, relative to the frame origin
|
2013-07-25 19:31:41 -07:00
|
|
|
* @param aFlags some combination of FrameForPointFlags
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2007-08-29 13:38:44 -07:00
|
|
|
static nsIFrame* GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt,
|
2013-07-25 19:31:41 -07:00
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-07 17:31:26 -07:00
|
|
|
/**
|
|
|
|
* Given aFrame, the root frame of a stacking context, find all descendant
|
|
|
|
* frames under the area of a rectangle that receives a mouse event,
|
2012-07-30 07:20:58 -07:00
|
|
|
* or nullptr if there is no such frame.
|
2010-04-07 17:31:26 -07:00
|
|
|
* @param aRect the rect, relative to the frame origin
|
|
|
|
* @param aOutFrames an array to add all the frames found
|
2013-07-25 19:31:41 -07:00
|
|
|
* @param aFlags some combination of FrameForPointFlags
|
2010-04-07 17:31:26 -07:00
|
|
|
*/
|
|
|
|
static nsresult GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect,
|
|
|
|
nsTArray<nsIFrame*> &aOutFrames,
|
2013-07-25 19:31:41 -07:00
|
|
|
uint32_t aFlags = 0);
|
2010-04-07 17:31:26 -07:00
|
|
|
|
2011-12-27 19:24:18 -08:00
|
|
|
/**
|
|
|
|
* Transform aRect relative to aFrame up to the coordinate system of
|
|
|
|
* aAncestor. Computes the bounding-box of the true quadrilateral.
|
2013-07-30 09:22:46 -07:00
|
|
|
* Pass non-null aPreservesAxisAlignedRectangles and it will be set to true if
|
|
|
|
* we only need to use a 2d transform that PreservesAxisAlignedRectangles().
|
2011-12-27 19:24:18 -08:00
|
|
|
*/
|
|
|
|
static nsRect TransformFrameRectToAncestor(nsIFrame* aFrame,
|
|
|
|
const nsRect& aRect,
|
2013-07-30 09:22:46 -07:00
|
|
|
const nsIFrame* aAncestor,
|
|
|
|
bool* aPreservesAxisAlignedRectangles = nullptr);
|
2011-05-09 01:40:09 -07:00
|
|
|
|
2012-01-18 07:41:35 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the transform for aFrame relative to aAncestor. Pass null for aAncestor
|
|
|
|
* to go up to the root frame.
|
|
|
|
*/
|
2012-09-12 17:32:53 -07:00
|
|
|
static gfx3DMatrix GetTransformToAncestor(nsIFrame *aFrame, const nsIFrame *aAncestor);
|
2012-01-18 07:41:35 -08:00
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
/**
|
|
|
|
* Transforms a list of CSSPoints from aFromFrame to aToFrame, taking into
|
|
|
|
* account all relevant transformations on the frames up to (but excluding)
|
|
|
|
* their nearest common ancestor.
|
|
|
|
* If we encounter a transform that we need to invert but which is
|
|
|
|
* non-invertible, we return NONINVERTIBLE_TRANSFORM. If the frames have
|
|
|
|
* no common ancestor, we return NO_COMMON_ANCESTOR.
|
|
|
|
* If this returns TRANSFORM_SUCCEEDED, the points in aPoints are transformed
|
|
|
|
* in-place, otherwise they are untouched.
|
|
|
|
*/
|
|
|
|
enum TransformResult {
|
|
|
|
TRANSFORM_SUCCEEDED,
|
|
|
|
NO_COMMON_ANCESTOR,
|
|
|
|
NONINVERTIBLE_TRANSFORM
|
|
|
|
};
|
|
|
|
static TransformResult TransformPoints(nsIFrame* aFromFrame, nsIFrame* aToFrame,
|
|
|
|
uint32_t aPointCount, CSSPoint* aPoints);
|
|
|
|
|
2012-10-02 22:55:50 -07:00
|
|
|
/**
|
|
|
|
* Return true if a "layer transform" could be computed for aFrame,
|
|
|
|
* and optionally return the computed transform. The returned
|
|
|
|
* transform is what would be set on the layer currently if a layers
|
|
|
|
* transaction were opened at the time this helper is called.
|
|
|
|
*/
|
|
|
|
static bool GetLayerTransformForFrame(nsIFrame* aFrame,
|
|
|
|
gfx3DMatrix* aTransform);
|
|
|
|
|
2008-09-13 02:42:11 -07:00
|
|
|
/**
|
|
|
|
* Given a point in the global coordinate space, returns that point expressed
|
|
|
|
* in the coordinate system of aFrame. This effectively inverts all transforms
|
|
|
|
* between this point and the root frame.
|
|
|
|
*
|
|
|
|
* @param aFrame The frame that acts as the coordinate space container.
|
|
|
|
* @param aPoint The point, in the global space, to get in the frame-local space.
|
|
|
|
* @return aPoint, expressed in aFrame's canonical coordinate space.
|
|
|
|
*/
|
2011-12-27 19:24:18 -08:00
|
|
|
static nsPoint TransformRootPointToFrame(nsIFrame* aFrame,
|
2013-02-10 22:22:18 -08:00
|
|
|
const nsPoint &aPoint)
|
|
|
|
{
|
|
|
|
return TransformAncestorPointToFrame(aFrame, aPoint, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform aPoint relative to aAncestor down to the coordinate system of
|
|
|
|
* aFrame.
|
|
|
|
*/
|
|
|
|
static nsPoint TransformAncestorPointToFrame(nsIFrame* aFrame,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsIFrame* aAncestor);
|
2008-09-13 02:42:11 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function that, given a rectangle and a matrix, returns the smallest
|
|
|
|
* rectangle containing the image of the source rectangle.
|
|
|
|
*
|
|
|
|
* @param aBounds The rectangle to transform.
|
|
|
|
* @param aMatrix The matrix to transform it with.
|
|
|
|
* @param aFactor The number of app units per graphics unit.
|
|
|
|
* @return The smallest rect that contains the image of aBounds.
|
|
|
|
*/
|
|
|
|
static nsRect MatrixTransformRect(const nsRect &aBounds,
|
2011-07-22 15:28:51 -07:00
|
|
|
const gfx3DMatrix &aMatrix, float aFactor);
|
2008-09-13 02:42:11 -07:00
|
|
|
|
2011-02-24 14:55:23 -08:00
|
|
|
/**
|
|
|
|
* Helper function that, given a rectangle and a matrix, returns the smallest
|
|
|
|
* rectangle containing the image of the source rectangle rounded out to the nearest
|
|
|
|
* pixel value.
|
|
|
|
*
|
|
|
|
* @param aBounds The rectangle to transform.
|
|
|
|
* @param aMatrix The matrix to transform it with.
|
|
|
|
* @param aFactor The number of app units per graphics unit.
|
|
|
|
* @return The smallest rect that contains the image of aBounds.
|
|
|
|
*/
|
|
|
|
static nsRect MatrixTransformRectOut(const nsRect &aBounds,
|
2011-07-22 15:28:51 -07:00
|
|
|
const gfx3DMatrix &aMatrix, float aFactor);
|
2008-09-13 02:42:11 -07:00
|
|
|
/**
|
|
|
|
* Helper function that, given a point and a matrix, returns the image
|
|
|
|
* of that point under the matrix transform.
|
|
|
|
*
|
|
|
|
* @param aPoint The point to transform.
|
|
|
|
* @param aMatrix The matrix to transform it with.
|
|
|
|
* @param aFactor The number of app units per graphics unit.
|
|
|
|
* @return The image of the point under the transform.
|
|
|
|
*/
|
|
|
|
static nsPoint MatrixTransformPoint(const nsPoint &aPoint,
|
2011-07-22 15:28:51 -07:00
|
|
|
const gfx3DMatrix &aMatrix, float aFactor);
|
2008-09-13 02:42:11 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a graphics rectangle in graphics space, return a rectangle in
|
|
|
|
* app space that contains the graphics rectangle, rounding out as necessary.
|
|
|
|
*
|
|
|
|
* @param aRect The graphics rect to round outward.
|
|
|
|
* @param aFactor The number of app units per graphics unit.
|
|
|
|
* @return The smallest rectangle in app space that contains aRect.
|
|
|
|
*/
|
|
|
|
static nsRect RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor);
|
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
/**
|
|
|
|
* Returns a subrectangle of aContainedRect that is entirely inside the rounded
|
|
|
|
* rect. Complex cases are handled conservatively by returning a smaller
|
|
|
|
* rect than necessary.
|
|
|
|
*/
|
|
|
|
static nsRegion RoundedRectIntersectRect(const nsRect& aRoundedRect,
|
|
|
|
const nscoord aRadii[8],
|
|
|
|
const nsRect& aContainedRect);
|
|
|
|
|
2013-03-06 03:08:15 -08:00
|
|
|
/**
|
|
|
|
* Return whether any part of aTestRect is inside of the rounded
|
|
|
|
* rectangle formed by aBounds and aRadii (which are indexed by the
|
|
|
|
* NS_CORNER_* constants in nsStyleConsts.h). This is precise.
|
|
|
|
*/
|
|
|
|
static bool RoundedRectIntersectsRect(const nsRect& aRoundedRect,
|
|
|
|
const nscoord aRadii[8],
|
|
|
|
const nsRect& aTestRect);
|
|
|
|
|
2009-09-12 15:44:18 -07:00
|
|
|
enum {
|
|
|
|
PAINT_IN_TRANSFORM = 0x01,
|
2010-03-01 00:03:49 -08:00
|
|
|
PAINT_SYNC_DECODE_IMAGES = 0x02,
|
2010-07-15 14:07:52 -07:00
|
|
|
PAINT_WIDGET_LAYERS = 0x04,
|
|
|
|
PAINT_IGNORE_SUPPRESSION = 0x08,
|
2010-09-03 13:10:46 -07:00
|
|
|
PAINT_DOCUMENT_RELATIVE = 0x10,
|
2010-08-13 06:32:04 -07:00
|
|
|
PAINT_HIDE_CARET = 0x20,
|
2010-10-14 18:03:45 -07:00
|
|
|
PAINT_ALL_CONTINUATIONS = 0x40,
|
2011-01-19 00:27:54 -08:00
|
|
|
PAINT_TO_WINDOW = 0x80,
|
2012-08-13 03:10:10 -07:00
|
|
|
PAINT_EXISTING_TRANSACTION = 0x100,
|
2014-01-29 21:41:17 -08:00
|
|
|
PAINT_NO_COMPOSITE = 0x200,
|
|
|
|
PAINT_COMPRESSED = 0x400
|
2009-09-12 15:44:18 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Given aFrame, the root frame of a stacking context, paint it and its
|
2010-04-27 09:15:01 -07:00
|
|
|
* descendants to aRenderingContext.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aRenderingContext a rendering context translated so that (0,0)
|
2008-02-24 17:39:34 -08:00
|
|
|
* is the origin of aFrame; for best results, (0,0) should transform
|
2010-03-01 00:03:49 -08:00
|
|
|
* to pixel-aligned coordinates. This can be null, in which case
|
|
|
|
* aFrame must be a "display root" (root frame for a root document,
|
|
|
|
* or the root of a popup) with an associated widget and we draw using
|
|
|
|
* the layer manager for the frame's widget.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aDirtyRegion the region that must be painted, in the coordinates
|
|
|
|
* of aFrame
|
2009-07-04 02:30:59 -07:00
|
|
|
* @param aBackstop paint the dirty area with this color before drawing
|
2007-03-22 10:30:00 -07:00
|
|
|
* the actual content; pass NS_RGBA(0,0,0,0) to draw no background
|
2009-07-21 17:45:14 -07:00
|
|
|
* @param aFlags if PAINT_IN_TRANSFORM is set, then we assume
|
2009-09-12 15:44:18 -07:00
|
|
|
* this is inside a transform or SVG foreignObject. If
|
2010-03-01 00:03:49 -08:00
|
|
|
* PAINT_SYNC_DECODE_IMAGES is set, we force synchronous decode on all
|
|
|
|
* images. If PAINT_WIDGET_LAYERS is set, aFrame must be a display root,
|
|
|
|
* and we will use the frame's widget's layer manager to paint
|
|
|
|
* even if aRenderingContext is non-null. This is useful if you want
|
|
|
|
* to force rendering to use the widget's layer manager for testing
|
|
|
|
* or speed. PAINT_WIDGET_LAYERS must be set if aRenderingContext is null.
|
2010-09-03 13:10:46 -07:00
|
|
|
* If PAINT_DOCUMENT_RELATIVE is used, the visible region is interpreted
|
|
|
|
* as being relative to the document. (Normally it's relative to the CSS
|
2010-10-14 18:03:45 -07:00
|
|
|
* viewport.) PAINT_TO_WINDOW sets painting to window to true on the display
|
|
|
|
* list builder even if we can't tell that we are painting to the window.
|
2011-01-19 00:27:54 -08:00
|
|
|
* If PAINT_EXISTING_TRANSACTION is set, then BeginTransaction() has already
|
|
|
|
* been called on aFrame's widget's layer manager and should not be
|
|
|
|
* called again.
|
2014-01-29 21:41:17 -08:00
|
|
|
* If PAINT_COMPRESSED is set, the FrameLayerBuilder should be set to compressed mode
|
|
|
|
* to avoid short cut optimizations.
|
2010-04-27 09:15:01 -07:00
|
|
|
*
|
2010-03-01 00:03:49 -08:00
|
|
|
* So there are three possible behaviours:
|
|
|
|
* 1) PAINT_WIDGET_LAYERS is set and aRenderingContext is null; we paint
|
|
|
|
* by calling BeginTransaction on the widget's layer manager
|
|
|
|
* 2) PAINT_WIDGET_LAYERS is set and aRenderingContext is non-null; we
|
|
|
|
* paint by calling BeginTransactionWithTarget on the widget's layer
|
|
|
|
* maanger
|
|
|
|
* 3) PAINT_WIDGET_LAYERS is not set and aRenderingContext is non-null;
|
|
|
|
* we paint by construct a BasicLayerManager and calling
|
|
|
|
* BeginTransactionWithTarget on it. This is desirable if we're doing
|
|
|
|
* something like drawWindow in a mode where what gets rendered doesn't
|
|
|
|
* necessarily correspond to what's visible in the window; we don't
|
|
|
|
* want to mess up the widget's layer tree.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
static nsresult PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFrame,
|
2009-07-21 17:45:14 -07:00
|
|
|
const nsRegion& aDirtyRegion, nscolor aBackstop,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Uses a binary search for find where the cursor falls in the line of text
|
|
|
|
* It also keeps track of the part of the string that has already been measured
|
|
|
|
* so it doesn't have to keep measuring the same text over and over
|
|
|
|
*
|
2010-04-27 09:15:01 -07:00
|
|
|
* @param "aBaseWidth" contains the width in twips of the portion
|
2007-03-22 10:30:00 -07:00
|
|
|
* of the text that has already been measured, and aBaseInx contains
|
|
|
|
* the index of the text that has already been measured.
|
|
|
|
*
|
|
|
|
* @param aTextWidth returns the (in twips) the length of the text that falls
|
|
|
|
* before the cursor aIndex contains the index of the text where the cursor falls
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool
|
2011-04-07 18:04:40 -07:00
|
|
|
BinarySearchForPosition(nsRenderingContext* acx,
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* aText,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aBaseWidth,
|
|
|
|
int32_t aBaseInx,
|
|
|
|
int32_t aStartInx,
|
|
|
|
int32_t aEndInx,
|
|
|
|
int32_t aCursorPos,
|
|
|
|
int32_t& aIndex,
|
|
|
|
int32_t& aTextWidth);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-10 17:24:16 -07:00
|
|
|
class BoxCallback {
|
|
|
|
public:
|
|
|
|
virtual void AddBox(nsIFrame* aFrame) = 0;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Collect all CSS boxes associated with aFrame and its
|
|
|
|
* continuations, "drilling down" through outer table frames and
|
|
|
|
* some anonymous blocks since they're not real CSS boxes.
|
|
|
|
* If aFrame is null, no boxes are returned.
|
|
|
|
* SVG frames return a single box, themselves.
|
|
|
|
*/
|
|
|
|
static void GetAllInFlowBoxes(nsIFrame* aFrame, BoxCallback* aCallback);
|
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
/**
|
|
|
|
* Find the first frame descendant of aFrame (including aFrame) which is
|
|
|
|
* not an anonymous frame that getBoxQuads/getClientRects should ignore.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetFirstNonAnonymousFrame(nsIFrame* aFrame);
|
|
|
|
|
2008-02-27 01:26:15 -08:00
|
|
|
class RectCallback {
|
|
|
|
public:
|
|
|
|
virtual void AddRect(const nsRect& aRect) = 0;
|
|
|
|
};
|
2009-09-24 14:01:48 -07:00
|
|
|
|
|
|
|
struct RectAccumulator : public RectCallback {
|
2011-12-27 19:24:29 -08:00
|
|
|
nsRect mResultRect;
|
|
|
|
nsRect mFirstRect;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSeenFirstRect;
|
2009-09-24 14:01:48 -07:00
|
|
|
|
|
|
|
RectAccumulator();
|
|
|
|
|
|
|
|
virtual void AddRect(const nsRect& aRect);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RectListBuilder : public RectCallback {
|
2013-09-20 03:21:03 -07:00
|
|
|
DOMRectList* mRectList;
|
2009-09-24 14:01:48 -07:00
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
RectListBuilder(DOMRectList* aList);
|
2013-03-17 00:55:16 -07:00
|
|
|
virtual void AddRect(const nsRect& aRect);
|
2009-09-24 14:01:48 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static nsIFrame* GetContainingBlockForClientRect(nsIFrame* aFrame);
|
|
|
|
|
2011-12-27 19:24:29 -08:00
|
|
|
enum {
|
2013-12-03 11:13:16 -08:00
|
|
|
RECTS_ACCOUNT_FOR_TRANSFORMS = 0x01,
|
|
|
|
// Two bits for specifying which box type to use.
|
|
|
|
// With neither bit set (default), use the border box.
|
|
|
|
RECTS_USE_CONTENT_BOX = 0x02,
|
|
|
|
RECTS_USE_PADDING_BOX = 0x04,
|
|
|
|
RECTS_USE_MARGIN_BOX = 0x06, // both bits set
|
|
|
|
RECTS_WHICH_BOX_MASK = 0x06 // bitmask for these two bits
|
2011-12-27 19:24:29 -08:00
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2013-12-03 11:13:16 -08:00
|
|
|
* Collect all CSS boxes (content, padding, border, or margin) associated
|
|
|
|
* with aFrame and its continuations, "drilling down" through outer table
|
|
|
|
* frames and some anonymous blocks since they're not real CSS boxes.
|
2008-02-27 01:26:15 -08:00
|
|
|
* The boxes are positioned relative to aRelativeTo (taking scrolling
|
|
|
|
* into account) and passed to the callback in frame-tree order.
|
|
|
|
* If aFrame is null, no boxes are returned.
|
|
|
|
* For SVG frames, returns one rectangle, the bounding box.
|
2011-12-27 19:24:29 -08:00
|
|
|
* If aFlags includes RECTS_ACCOUNT_FOR_TRANSFORMS, then when converting
|
|
|
|
* the boxes into aRelativeTo coordinates, transforms (including CSS
|
|
|
|
* and SVG transforms) are taken into account.
|
2013-12-03 11:13:16 -08:00
|
|
|
* If aFlags includes one of RECTS_USE_CONTENT_BOX, RECTS_USE_PADDING_BOX,
|
|
|
|
* or RECTS_USE_MARGIN_BOX, the corresponding type of box is used.
|
|
|
|
* Otherwise (by default), the border box is used.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2008-02-27 01:26:15 -08:00
|
|
|
static void GetAllInFlowRects(nsIFrame* aFrame, nsIFrame* aRelativeTo,
|
2012-08-22 08:56:38 -07:00
|
|
|
RectCallback* aCallback, uint32_t aFlags = 0);
|
2008-02-27 01:26:15 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the union of all rects returned by GetAllInFlowRects. If
|
|
|
|
* the union is empty, returns the first rect.
|
2011-12-27 19:24:29 -08:00
|
|
|
* If aFlags includes RECTS_ACCOUNT_FOR_TRANSFORMS, then when converting
|
|
|
|
* the boxes into aRelativeTo coordinates, transforms (including CSS
|
|
|
|
* and SVG transforms) are taken into account.
|
2013-12-03 11:13:16 -08:00
|
|
|
* If aFlags includes one of RECTS_USE_CONTENT_BOX, RECTS_USE_PADDING_BOX,
|
|
|
|
* or RECTS_USE_MARGIN_BOX, the corresponding type of box is used.
|
|
|
|
* Otherwise (by default), the border box is used.
|
2008-02-27 01:26:15 -08:00
|
|
|
*/
|
2011-12-27 19:24:29 -08:00
|
|
|
static nsRect GetAllInFlowRectsUnion(nsIFrame* aFrame, nsIFrame* aRelativeTo,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = 0);
|
2012-06-21 06:35:17 -07:00
|
|
|
|
2011-01-02 17:48:09 -08:00
|
|
|
enum {
|
|
|
|
EXCLUDE_BLUR_SHADOWS = 0x01
|
|
|
|
};
|
2008-06-12 15:02:32 -07:00
|
|
|
/**
|
|
|
|
* Takes a text-shadow array from the style properties of a given nsIFrame and
|
|
|
|
* computes the union of those shadows along with the given initial rect.
|
|
|
|
* If there are no shadows, the initial rect is returned.
|
|
|
|
*/
|
|
|
|
static nsRect GetTextShadowRectsUnion(const nsRect& aTextAndDecorationsRect,
|
2011-01-02 17:48:09 -08:00
|
|
|
nsIFrame* aFrame,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = 0);
|
2008-06-12 15:02:32 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the font metrics corresponding to the frame's style data.
|
|
|
|
* @param aFrame the frame
|
|
|
|
* @param aFontMetrics the font metrics result
|
2011-11-23 18:48:23 -08:00
|
|
|
* @param aSizeInflation number to multiply font size by
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return success or failure code
|
|
|
|
*/
|
2010-08-31 11:54:44 -07:00
|
|
|
static nsresult GetFontMetricsForFrame(const nsIFrame* aFrame,
|
2011-11-23 18:48:23 -08:00
|
|
|
nsFontMetrics** aFontMetrics,
|
|
|
|
float aSizeInflation = 1.0f);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-08-07 12:07:43 -07:00
|
|
|
/**
|
|
|
|
* Get the font metrics corresponding to the given style data.
|
|
|
|
* @param aStyleContext the style data
|
|
|
|
* @param aFontMetrics the font metrics result
|
2011-11-23 18:48:23 -08:00
|
|
|
* @param aSizeInflation number to multiply font size by
|
2007-08-07 12:07:43 -07:00
|
|
|
* @return success or failure code
|
|
|
|
*/
|
|
|
|
static nsresult GetFontMetricsForStyleContext(nsStyleContext* aStyleContext,
|
2011-11-23 18:48:23 -08:00
|
|
|
nsFontMetrics** aFontMetrics,
|
|
|
|
float aSizeInflation = 1.0f);
|
2007-08-07 12:07:43 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Find the immediate child of aParent whose frame subtree contains
|
|
|
|
* aDescendantFrame. Returns null if aDescendantFrame is not a descendant
|
|
|
|
* of aParent.
|
|
|
|
*/
|
|
|
|
static nsIFrame* FindChildContainingDescendant(nsIFrame* aParent, nsIFrame* aDescendantFrame);
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Find the nearest ancestor that's a block
|
|
|
|
*/
|
|
|
|
static nsBlockFrame* FindNearestBlockAncestor(nsIFrame* aFrame);
|
2007-12-20 19:28:18 -08:00
|
|
|
|
2008-11-25 14:15:41 -08:00
|
|
|
/**
|
|
|
|
* Find the nearest ancestor that's not for generated content. Will return
|
|
|
|
* aFrame if aFrame is not for generated content.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetNonGeneratedAncestor(nsIFrame* aFrame);
|
|
|
|
|
2007-12-20 19:28:18 -08:00
|
|
|
/**
|
|
|
|
* Cast aFrame to an nsBlockFrame* or return null if it's not
|
|
|
|
* an nsBlockFrame.
|
|
|
|
*/
|
|
|
|
static nsBlockFrame* GetAsBlock(nsIFrame* aFrame);
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2011-05-11 21:04:30 -07:00
|
|
|
/*
|
|
|
|
* Whether the frame is an nsBlockFrame which is not a wrapper block.
|
|
|
|
*/
|
2013-09-30 14:26:04 -07:00
|
|
|
static bool IsNonWrapperBlock(nsIFrame* aFrame);
|
2011-05-11 21:04:30 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* If aFrame is an out of flow frame, return its placeholder, otherwise
|
|
|
|
* return its parent.
|
|
|
|
*/
|
2012-06-10 16:44:50 -07:00
|
|
|
static nsIFrame* GetParentOrPlaceholderFor(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If aFrame is an out of flow frame, return its placeholder, otherwise
|
|
|
|
* return its (possibly cross-doc) parent.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetParentOrPlaceholderForCrossDoc(nsIFrame* aFrame);
|
2012-06-08 05:22:51 -07:00
|
|
|
|
2007-03-25 20:27:53 -07:00
|
|
|
/**
|
2014-02-06 17:45:33 -08:00
|
|
|
* Get a frame's next-in-flow, or, if it doesn't have one, its
|
|
|
|
* block-in-inline-split sibling.
|
2007-03-25 20:27:53 -07:00
|
|
|
*/
|
|
|
|
static nsIFrame*
|
2014-02-06 17:45:31 -08:00
|
|
|
GetNextContinuationOrIBSplitSibling(nsIFrame *aFrame);
|
2007-03-25 20:27:53 -07:00
|
|
|
|
2008-09-10 17:24:16 -07:00
|
|
|
/**
|
2014-02-06 17:45:33 -08:00
|
|
|
* Get the first frame in the continuation-plus-ib-split-sibling chain
|
2008-09-10 17:24:16 -07:00
|
|
|
* containing aFrame.
|
|
|
|
*/
|
|
|
|
static nsIFrame*
|
2014-02-06 17:45:31 -08:00
|
|
|
FirstContinuationOrIBSplitSibling(nsIFrame *aFrame);
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2013-09-25 12:28:08 -07:00
|
|
|
/**
|
2014-02-06 17:45:31 -08:00
|
|
|
* Is FirstContinuationOrIBSplitSibling(aFrame) going to return
|
2013-09-25 12:28:08 -07:00
|
|
|
* aFrame?
|
|
|
|
*/
|
|
|
|
static bool
|
2014-02-06 17:45:31 -08:00
|
|
|
IsFirstContinuationOrIBSplitSibling(nsIFrame *aFrame);
|
2013-09-25 12:28:08 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Check whether aFrame is a part of the scrollbar or scrollcorner of
|
|
|
|
* the root content.
|
|
|
|
* @param aFrame the checking frame
|
|
|
|
* @return if TRUE, the frame is a part of the scrollbar or scrollcorner of
|
|
|
|
* the root content.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsViewportScrollbarFrame(nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the contribution of aFrame to its containing block's intrinsic
|
|
|
|
* width. This considers the child's intrinsic width, its 'width',
|
|
|
|
* 'min-width', and 'max-width' properties, and its padding, border,
|
|
|
|
* and margin.
|
|
|
|
*/
|
|
|
|
enum IntrinsicWidthType { MIN_WIDTH, PREF_WIDTH };
|
2013-10-22 15:46:40 -07:00
|
|
|
enum {
|
|
|
|
IGNORE_PADDING = 0x01
|
|
|
|
};
|
2011-04-07 18:04:40 -07:00
|
|
|
static nscoord IntrinsicForContainer(nsRenderingContext* aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aFrame,
|
2013-10-22 15:46:40 -07:00
|
|
|
IntrinsicWidthType aType,
|
|
|
|
uint32_t aFlags = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-03 16:11:00 -07:00
|
|
|
/*
|
|
|
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
2013-04-11 07:49:53 -07:00
|
|
|
* containing block size.
|
|
|
|
* @param aPercentBasis The width or height of the containing block
|
|
|
|
* (whichever the client wants to use for resolving percentages).
|
2007-05-03 16:11:00 -07:00
|
|
|
*/
|
2013-04-11 07:49:53 -07:00
|
|
|
static nscoord ComputeCBDependentValue(nscoord aPercentBasis,
|
|
|
|
const nsStyleCoord& aCoord);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-03 16:11:00 -07:00
|
|
|
/*
|
|
|
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
|
|
|
* containing block width, and enumerated values are for width,
|
|
|
|
* min-width, or max-width. Returns the content-box width value based
|
|
|
|
* on aContentEdgeToBoxSizing and aBoxSizingToMarginEdge (which are
|
|
|
|
* also used for the enumerated values for width. This function does
|
|
|
|
* not handle 'auto'. It ensures that the result is nonnegative.
|
|
|
|
*
|
|
|
|
* @param aRenderingContext Rendering context for font measurement/metrics.
|
|
|
|
* @param aFrame Frame whose (min-/max-/)width is being computed
|
|
|
|
* @param aContainingBlockWidth Width of aFrame's containing block.
|
|
|
|
* @param aContentEdgeToBoxSizing The sum of any left/right padding and
|
2014-02-06 11:32:05 -08:00
|
|
|
* border that goes inside the rect chosen by box-sizing.
|
2007-05-03 16:11:00 -07:00
|
|
|
* @param aBoxSizingToMarginEdge The sum of any left/right padding, border,
|
2014-02-06 11:32:05 -08:00
|
|
|
* and margin that goes outside the rect chosen by box-sizing.
|
2007-05-03 16:11:00 -07:00
|
|
|
* @param aCoord The width value to compute.
|
|
|
|
*/
|
|
|
|
static nscoord ComputeWidthValue(
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2007-05-03 16:11:00 -07:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContentEdgeToBoxSizing,
|
|
|
|
nscoord aBoxSizingToMarginEdge,
|
|
|
|
const nsStyleCoord& aCoord);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert nsStyleCoord to nscoord when percentages depend on the
|
|
|
|
* containing block height.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
static nscoord ComputeHeightDependentValue(
|
|
|
|
nscoord aContainingBlockHeight,
|
|
|
|
const nsStyleCoord& aCoord);
|
|
|
|
|
2010-08-25 03:17:55 -07:00
|
|
|
/*
|
|
|
|
* Likewise, but for 'height', 'min-height', or 'max-height'.
|
|
|
|
*/
|
|
|
|
static nscoord ComputeHeightValue(nscoord aContainingBlockHeight,
|
2012-08-08 08:58:26 -07:00
|
|
|
nscoord aContentEdgeToBoxSizingBoxEdge,
|
2010-08-25 03:17:55 -07:00
|
|
|
const nsStyleCoord& aCoord)
|
|
|
|
{
|
2013-09-30 14:26:04 -07:00
|
|
|
MOZ_ASSERT(aContainingBlockHeight != nscoord_MAX || !aCoord.HasPercent(),
|
2012-08-08 08:58:26 -07:00
|
|
|
"caller must deal with %% of unconstrained height");
|
|
|
|
MOZ_ASSERT(aCoord.IsCoordPercentCalcUnit());
|
|
|
|
|
2010-08-25 03:17:55 -07:00
|
|
|
nscoord result =
|
2012-08-08 08:58:26 -07:00
|
|
|
nsRuleNode::ComputeCoordPercentCalc(aCoord, aContainingBlockHeight);
|
|
|
|
// Clamp calc(), and the subtraction for box-sizing.
|
2013-01-15 04:22:03 -08:00
|
|
|
return std::max(0, result - aContentEdgeToBoxSizingBoxEdge);
|
2010-08-25 03:17:55 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsAutoHeight(const nsStyleCoord &aCoord, nscoord aCBHeight)
|
2010-08-25 03:17:56 -07:00
|
|
|
{
|
|
|
|
nsStyleUnit unit = aCoord.GetUnit();
|
|
|
|
return unit == eStyleUnit_Auto || // only for 'height'
|
|
|
|
unit == eStyleUnit_None || // only for 'max-height'
|
2013-09-30 14:26:04 -07:00
|
|
|
(aCBHeight == nscoord_MAX && aCoord.HasPercent());
|
2010-08-25 03:17:56 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsPaddingZero(const nsStyleCoord &aCoord)
|
2010-09-09 08:21:46 -07:00
|
|
|
{
|
|
|
|
return (aCoord.GetUnit() == eStyleUnit_Coord &&
|
|
|
|
aCoord.GetCoordValue() == 0) ||
|
|
|
|
(aCoord.GetUnit() == eStyleUnit_Percent &&
|
2011-04-08 10:59:52 -07:00
|
|
|
aCoord.GetPercentValue() == 0.0f) ||
|
2010-09-09 08:21:46 -07:00
|
|
|
(aCoord.IsCalcUnit() &&
|
|
|
|
// clamp negative calc() to 0
|
|
|
|
nsRuleNode::ComputeCoordPercentCalc(aCoord, nscoord_MAX) <= 0 &&
|
|
|
|
nsRuleNode::ComputeCoordPercentCalc(aCoord, 0) <= 0);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsMarginZero(const nsStyleCoord &aCoord)
|
2010-08-31 09:05:12 -07:00
|
|
|
{
|
|
|
|
return (aCoord.GetUnit() == eStyleUnit_Coord &&
|
|
|
|
aCoord.GetCoordValue() == 0) ||
|
|
|
|
(aCoord.GetUnit() == eStyleUnit_Percent &&
|
2011-04-08 10:59:52 -07:00
|
|
|
aCoord.GetPercentValue() == 0.0f) ||
|
2010-08-31 09:05:12 -07:00
|
|
|
(aCoord.IsCalcUnit() &&
|
|
|
|
nsRuleNode::ComputeCoordPercentCalc(aCoord, nscoord_MAX) == 0 &&
|
|
|
|
nsRuleNode::ComputeCoordPercentCalc(aCoord, 0) == 0);
|
|
|
|
}
|
|
|
|
|
2007-11-18 04:09:03 -08:00
|
|
|
/*
|
|
|
|
* Calculate the used values for 'width' and 'height' for a replaced element.
|
|
|
|
*
|
|
|
|
* http://www.w3.org/TR/CSS21/visudet.html#min-max-widths
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
static nsSize ComputeSizeWithIntrinsicDimensions(
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aRenderingContext, nsIFrame* aFrame,
|
2013-09-30 14:26:04 -07:00
|
|
|
const mozilla::IntrinsicSize& aIntrinsicSize,
|
2007-11-18 04:09:03 -08:00
|
|
|
nsSize aIntrinsicRatio, nsSize aCBSize,
|
2007-05-03 16:11:00 -07:00
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-05 12:24:24 -07:00
|
|
|
/*
|
|
|
|
* Calculate the used values for 'width' and 'height' when width
|
|
|
|
* and height are 'auto'. The tentWidth and tentHeight arguments should be
|
|
|
|
* the result of applying the rules for computing intrinsic sizes and ratios.
|
|
|
|
* as specified by CSS 2.1 sections 10.3.2 and 10.6.2
|
|
|
|
*/
|
|
|
|
static nsSize ComputeAutoSizeWithIntrinsicDimensions(nscoord minWidth, nscoord minHeight,
|
|
|
|
nscoord maxWidth, nscoord maxHeight,
|
|
|
|
nscoord tentWidth, nscoord tentHeight);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Implement nsIFrame::GetPrefWidth in terms of nsIFrame::AddInlinePrefWidth
|
|
|
|
static nscoord PrefWidthFromInline(nsIFrame* aFrame,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aRenderingContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Implement nsIFrame::GetMinWidth in terms of nsIFrame::AddInlineMinWidth
|
|
|
|
static nscoord MinWidthFromInline(nsIFrame* aFrame,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aRenderingContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-09 08:14:36 -07:00
|
|
|
// Get a suitable foreground color for painting aProperty for aFrame.
|
|
|
|
static nscolor GetColor(nsIFrame* aFrame, nsCSSProperty aProperty);
|
2011-06-22 11:11:48 -07:00
|
|
|
|
2011-07-03 22:47:59 -07:00
|
|
|
// Get a baseline y position in app units that is snapped to device pixels.
|
|
|
|
static gfxFloat GetSnappedBaselineY(nsIFrame* aFrame, gfxContext* aContext,
|
|
|
|
nscoord aY, nscoord aAscent);
|
|
|
|
|
2013-11-18 07:24:16 -08:00
|
|
|
static void DrawString(const nsIFrame* aFrame,
|
|
|
|
nsRenderingContext* aContext,
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* aString,
|
2013-11-18 07:24:16 -08:00
|
|
|
int32_t aLength,
|
|
|
|
nsPoint aPoint,
|
|
|
|
nsStyleContext* aStyleContext = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static nscoord GetStringWidth(const nsIFrame* aFrame,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aContext,
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* aString,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aLength);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-30 23:43:11 -07:00
|
|
|
/**
|
|
|
|
* Helper function for drawing text-shadow. The callback's job
|
|
|
|
* is to draw whatever needs to be blurred onto the given context.
|
|
|
|
*/
|
|
|
|
typedef void (* TextShadowCallback)(nsRenderingContext* aCtx,
|
|
|
|
nsPoint aShadowOffset,
|
|
|
|
const nscolor& aShadowColor,
|
|
|
|
void* aData);
|
|
|
|
|
|
|
|
static void PaintTextShadow(const nsIFrame* aFrame,
|
|
|
|
nsRenderingContext* aContext,
|
|
|
|
const nsRect& aTextRect,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nscolor& aForegroundColor,
|
|
|
|
TextShadowCallback aCallback,
|
|
|
|
void* aCallbackData);
|
|
|
|
|
2009-05-18 15:13:12 -07:00
|
|
|
/**
|
|
|
|
* Gets the baseline to vertically center text from a font within a
|
|
|
|
* line of specified height.
|
|
|
|
*
|
|
|
|
* Returns the baseline position relative to the top of the line.
|
|
|
|
*/
|
2011-04-07 18:05:49 -07:00
|
|
|
static nscoord GetCenteredFontBaseline(nsFontMetrics* aFontMetrics,
|
2009-05-18 15:13:12 -07:00
|
|
|
nscoord aLineHeight);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Derive a baseline of |aFrame| (measured from its top border edge)
|
|
|
|
* from its first in-flow line box (not descending into anything with
|
|
|
|
* 'overflow' not 'visible', potentially including aFrame itself).
|
|
|
|
*
|
|
|
|
* Returns true if a baseline was found (and fills in aResult).
|
|
|
|
* Otherwise returns false.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool GetFirstLineBaseline(const nsIFrame* aFrame, nscoord* aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-08 13:52:36 -07:00
|
|
|
/**
|
|
|
|
* Just like GetFirstLineBaseline, except also returns the top and
|
|
|
|
* bottom of the line with the baseline.
|
|
|
|
*
|
|
|
|
* Returns true if a line was found (and fills in aResult).
|
|
|
|
* Otherwise returns false.
|
|
|
|
*/
|
|
|
|
struct LinePosition {
|
|
|
|
nscoord mTop, mBaseline, mBottom;
|
|
|
|
|
|
|
|
LinePosition operator+(nscoord aOffset) const {
|
|
|
|
LinePosition result;
|
|
|
|
result.mTop = mTop + aOffset;
|
|
|
|
result.mBaseline = mBaseline + aOffset;
|
|
|
|
result.mBottom = mBottom + aOffset;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool GetFirstLinePosition(const nsIFrame* aFrame,
|
2012-10-17 14:01:55 -07:00
|
|
|
LinePosition* aResult);
|
2009-04-08 13:52:36 -07:00
|
|
|
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Derive a baseline of |aFrame| (measured from its top border edge)
|
|
|
|
* from its last in-flow line box (not descending into anything with
|
|
|
|
* 'overflow' not 'visible', potentially including aFrame itself).
|
|
|
|
*
|
|
|
|
* Returns true if a baseline was found (and fills in aResult).
|
|
|
|
* Otherwise returns false.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool GetLastLineBaseline(const nsIFrame* aFrame, nscoord* aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-18 00:40:35 -07:00
|
|
|
/**
|
|
|
|
* Returns a y coordinate relative to this frame's origin that represents
|
|
|
|
* the logical bottom of the frame or its visible content, whichever is lower.
|
|
|
|
* Relative positioning is ignored and margins and glyph bounds are not
|
|
|
|
* considered.
|
|
|
|
* This value will be >= mRect.height() and <= overflowRect.YMost() unless
|
|
|
|
* relative positioning is applied.
|
|
|
|
*/
|
|
|
|
static nscoord CalculateContentBottom(nsIFrame* aFrame);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Gets the closest frame (the frame passed in or one of its parents) that
|
|
|
|
* qualifies as a "layer"; used in DOM0 methods that depends upon that
|
|
|
|
* definition. This is the nearest frame that is either positioned or scrolled
|
2010-06-05 13:29:49 -07:00
|
|
|
* (the child of a scroll frame).
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
static nsIFrame* GetClosestLayer(nsIFrame* aFrame);
|
|
|
|
|
2009-04-05 02:52:14 -07:00
|
|
|
/**
|
|
|
|
* Gets the graphics filter for the frame
|
|
|
|
*/
|
2010-10-11 13:07:59 -07:00
|
|
|
static GraphicsFilter GetGraphicsFilterForFrame(nsIFrame* aFrame);
|
2009-04-05 02:52:14 -07:00
|
|
|
|
2009-01-29 23:33:57 -08:00
|
|
|
/* N.B. The only difference between variants of the Draw*Image
|
|
|
|
* functions below is the type of the aImage argument.
|
|
|
|
*/
|
|
|
|
|
2011-01-13 02:40:12 -08:00
|
|
|
/**
|
|
|
|
* Draw a background image. The image's dimensions are as specified in aDest;
|
|
|
|
* the image itself is not consulted to determine a size.
|
|
|
|
* See https://wiki.mozilla.org/Gecko:Image_Snapping_and_Rendering
|
|
|
|
* @param aRenderingContext Where to draw the image, set up with an
|
|
|
|
* appropriate scale and transform for drawing in
|
|
|
|
* app units.
|
|
|
|
* @param aImage The image.
|
|
|
|
* @param aImageSize The unscaled size of the image being drawn.
|
|
|
|
* (This might be the image's size if no scaling
|
|
|
|
* occurs, or it might be the image's size if
|
|
|
|
* the image is a vector image being rendered at
|
|
|
|
* that size.)
|
|
|
|
* @param aDest The position and scaled area where one copy of
|
|
|
|
* the image should be drawn.
|
|
|
|
* @param aFill The area to be filled with copies of the
|
|
|
|
* image.
|
|
|
|
* @param aAnchor A point in aFill which we will ensure is
|
|
|
|
* pixel-aligned in the output.
|
|
|
|
* @param aDirty Pixels outside this area may be skipped.
|
|
|
|
* @param aImageFlags Image flags of the imgIContainer::FLAG_* variety
|
|
|
|
*/
|
|
|
|
static nsresult DrawBackgroundImage(nsRenderingContext* aRenderingContext,
|
|
|
|
imgIContainer* aImage,
|
|
|
|
const nsIntSize& aImageSize,
|
|
|
|
GraphicsFilter aGraphicsFilter,
|
|
|
|
const nsRect& aDest,
|
|
|
|
const nsRect& aFill,
|
|
|
|
const nsPoint& aAnchor,
|
|
|
|
const nsRect& aDirty,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aImageFlags);
|
2011-01-13 02:40:12 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2008-11-04 14:01:21 -08:00
|
|
|
* Draw an image.
|
|
|
|
* See https://wiki.mozilla.org/Gecko:Image_Snapping_and_Rendering
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aRenderingContext Where to draw the image, set up with an
|
|
|
|
* appropriate scale and transform for drawing in
|
2008-11-04 14:01:21 -08:00
|
|
|
* app units.
|
2007-08-22 04:13:46 -07:00
|
|
|
* @param aImage The image.
|
2008-11-04 14:01:21 -08:00
|
|
|
* @param aDest Where one copy of the image should mapped to.
|
|
|
|
* @param aFill The area to be filled with copies of the
|
|
|
|
* image.
|
|
|
|
* @param aAnchor A point in aFill which we will ensure is
|
|
|
|
* pixel-aligned in the output.
|
|
|
|
* @param aDirty Pixels outside this area may be skipped.
|
2009-09-12 15:44:18 -07:00
|
|
|
* @param aImageFlags Image flags of the imgIContainer::FLAG_* variety
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
static nsresult DrawImage(nsRenderingContext* aRenderingContext,
|
2008-11-04 14:01:21 -08:00
|
|
|
imgIContainer* aImage,
|
2010-10-11 13:07:59 -07:00
|
|
|
GraphicsFilter aGraphicsFilter,
|
2008-11-04 14:01:21 -08:00
|
|
|
const nsRect& aDest,
|
|
|
|
const nsRect& aFill,
|
|
|
|
const nsPoint& aAnchor,
|
2009-09-12 15:44:18 -07:00
|
|
|
const nsRect& aDirty,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aImageFlags);
|
2008-11-04 14:01:21 -08:00
|
|
|
|
2010-09-07 15:20:35 -07:00
|
|
|
/**
|
|
|
|
* Convert an nsRect to a gfxRect.
|
|
|
|
*/
|
|
|
|
static gfxRect RectToGfxRect(const nsRect& aRect,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aAppUnitsPerDevPixel);
|
2010-09-07 15:20:35 -07:00
|
|
|
|
2010-08-13 06:30:37 -07:00
|
|
|
/**
|
|
|
|
* Draw a drawable using the pixel snapping algorithm.
|
|
|
|
* See https://wiki.mozilla.org/Gecko:Image_Snapping_and_Rendering
|
|
|
|
* @param aRenderingContext Where to draw the image, set up with an
|
|
|
|
* appropriate scale and transform for drawing in
|
|
|
|
* app units.
|
|
|
|
* @param aDrawable The drawable we want to draw.
|
|
|
|
* @param aFilter The graphics filter we should draw with.
|
|
|
|
* @param aDest Where one copy of the image should mapped to.
|
|
|
|
* @param aFill The area to be filled with copies of the
|
|
|
|
* image.
|
|
|
|
* @param aAnchor A point in aFill which we will ensure is
|
|
|
|
* pixel-aligned in the output.
|
|
|
|
* @param aDirty Pixels outside this area may be skipped.
|
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
static void DrawPixelSnapped(nsRenderingContext* aRenderingContext,
|
2010-08-13 06:30:37 -07:00
|
|
|
gfxDrawable* aDrawable,
|
2010-10-11 13:07:59 -07:00
|
|
|
GraphicsFilter aFilter,
|
2010-08-13 06:30:37 -07:00
|
|
|
const nsRect& aDest,
|
|
|
|
const nsRect& aFill,
|
|
|
|
const nsPoint& aAnchor,
|
|
|
|
const nsRect& aDirty);
|
|
|
|
|
2008-11-04 14:01:21 -08:00
|
|
|
/**
|
|
|
|
* Draw a whole image without scaling or tiling.
|
|
|
|
*
|
|
|
|
* @param aRenderingContext Where to draw the image, set up with an
|
|
|
|
* appropriate scale and transform for drawing in
|
|
|
|
* app units.
|
|
|
|
* @param aImage The image.
|
|
|
|
* @param aDest The top-left where the image should be drawn
|
2010-10-11 13:08:07 -07:00
|
|
|
* @param aDirty If non-null, then pixels outside this area may
|
|
|
|
* be skipped.
|
2009-09-12 15:44:18 -07:00
|
|
|
* @param aImageFlags Image flags of the imgIContainer::FLAG_* variety
|
2008-11-04 14:01:21 -08:00
|
|
|
* @param aSourceArea If non-null, this area is extracted from
|
|
|
|
* the image and drawn at aDest. It's
|
|
|
|
* in appunits. For best results it should
|
|
|
|
* be aligned with image pixels.
|
|
|
|
*/
|
2011-04-07 18:04:40 -07:00
|
|
|
static nsresult DrawSingleUnscaledImage(nsRenderingContext* aRenderingContext,
|
2008-11-04 14:01:21 -08:00
|
|
|
imgIContainer* aImage,
|
2010-10-11 13:08:07 -07:00
|
|
|
GraphicsFilter aGraphicsFilter,
|
2008-11-04 14:01:21 -08:00
|
|
|
const nsPoint& aDest,
|
2010-10-11 13:08:07 -07:00
|
|
|
const nsRect* aDirty,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aImageFlags,
|
2012-07-30 07:20:58 -07:00
|
|
|
const nsRect* aSourceArea = nullptr);
|
2008-11-04 14:01:21 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a whole image without tiling.
|
|
|
|
*
|
|
|
|
* @param aRenderingContext Where to draw the image, set up with an
|
|
|
|
* appropriate scale and transform for drawing in
|
|
|
|
* app units.
|
|
|
|
* @param aImage The image.
|
|
|
|
* @param aDest The area that the image should fill
|
|
|
|
* @param aDirty Pixels outside this area may be skipped.
|
2013-02-28 12:22:43 -08:00
|
|
|
* @param aSVGContext If non-null, SVG-related rendering context
|
|
|
|
* such as overridden attributes on the image
|
|
|
|
* document's root <svg> node. Ignored for
|
|
|
|
* raster images.
|
|
|
|
* @param aImageFlags Image flags of the imgIContainer::FLAG_*
|
|
|
|
* variety.
|
2008-11-04 14:01:21 -08:00
|
|
|
* @param aSourceArea If non-null, this area is extracted from
|
|
|
|
* the image and drawn in aDest. It's
|
|
|
|
* in appunits. For best results it should
|
|
|
|
* be aligned with image pixels.
|
|
|
|
*/
|
2013-02-28 12:22:43 -08:00
|
|
|
static nsresult DrawSingleImage(nsRenderingContext* aRenderingContext,
|
|
|
|
imgIContainer* aImage,
|
|
|
|
GraphicsFilter aGraphicsFilter,
|
|
|
|
const nsRect& aDest,
|
|
|
|
const nsRect& aDirty,
|
|
|
|
const mozilla::SVGImageContext* aSVGContext,
|
|
|
|
uint32_t aImageFlags,
|
|
|
|
const nsRect* aSourceArea = nullptr);
|
2008-11-04 14:01:21 -08:00
|
|
|
|
2010-09-08 13:40:39 -07:00
|
|
|
/**
|
|
|
|
* Given an imgIContainer, this method attempts to obtain an intrinsic
|
|
|
|
* px-valued height & width for it. If the imgIContainer has a non-pixel
|
|
|
|
* value for either height or width, this method tries to generate a pixel
|
2011-01-13 02:40:12 -08:00
|
|
|
* value for that dimension using the intrinsic ratio (if available). The
|
|
|
|
* intrinsic ratio will be assigned to aIntrinsicRatio; if there's no
|
|
|
|
* intrinsic ratio then (0, 0) will be assigned.
|
2010-09-08 13:40:39 -07:00
|
|
|
*
|
|
|
|
* This method will always set aGotWidth and aGotHeight to indicate whether
|
|
|
|
* we were able to successfully obtain (or compute) a value for each
|
|
|
|
* dimension.
|
|
|
|
*
|
|
|
|
* NOTE: This method is similar to ComputeSizeWithIntrinsicDimensions. The
|
|
|
|
* difference is that this one is simpler and is suited to places where we
|
|
|
|
* have less information about the frame tree.
|
|
|
|
*/
|
|
|
|
static void ComputeSizeForDrawing(imgIContainer* aImage,
|
|
|
|
nsIntSize& aImageSize,
|
2011-01-13 02:40:12 -08:00
|
|
|
nsSize& aIntrinsicRatio,
|
|
|
|
bool& aGotWidth,
|
|
|
|
bool& aGotHeight);
|
2010-09-08 13:40:39 -07:00
|
|
|
|
2008-11-04 14:01:21 -08:00
|
|
|
/**
|
|
|
|
* Given a source area of an image (in appunits) and a destination area
|
|
|
|
* that we want to map that source area too, computes the area that
|
|
|
|
* would be covered by the whole image. This is useful for passing to
|
|
|
|
* the aDest parameter of DrawImage, when we want to draw a subimage
|
|
|
|
* of an overall image.
|
|
|
|
*/
|
|
|
|
static nsRect GetWholeImageDestination(const nsIntSize& aWholeImageSize,
|
|
|
|
const nsRect& aImageSourceArea,
|
|
|
|
const nsRect& aDestArea);
|
2007-05-04 23:09:50 -07:00
|
|
|
|
2013-08-28 15:39:07 -07:00
|
|
|
/**
|
|
|
|
* Given an image container and an orientation, returns an image container
|
|
|
|
* that contains the same image, reoriented appropriately. May return the
|
|
|
|
* original image container if no changes are needed.
|
|
|
|
*
|
|
|
|
* @param aContainer The image container to apply the orientation to.
|
|
|
|
* @param aOrientation The desired orientation.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<imgIContainer>
|
|
|
|
OrientImage(imgIContainer* aContainer,
|
|
|
|
const nsStyleImageOrientation& aOrientation);
|
|
|
|
|
2007-05-04 23:09:50 -07:00
|
|
|
/**
|
2008-09-30 22:50:52 -07:00
|
|
|
* Determine if any corner radius is of nonzero size
|
|
|
|
* @param aCorners the |nsStyleCorners| object to check
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true unless all the coordinates are 0%, 0 or null.
|
2008-09-30 22:50:52 -07:00
|
|
|
*
|
|
|
|
* A corner radius with one dimension zero and one nonzero is
|
|
|
|
* treated as a nonzero-radius corner, even though it will end up
|
|
|
|
* being rendered like a zero-radius corner. This is because such
|
|
|
|
* corners are not expected to appear outside of test cases, and it's
|
|
|
|
* simpler to implement the test this way.
|
2007-05-10 08:46:42 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool HasNonZeroCorner(const nsStyleCorners& aCorners);
|
2007-05-10 08:46:42 -07:00
|
|
|
|
2009-05-07 18:52:22 -07:00
|
|
|
/**
|
|
|
|
* Determine if there is any corner radius on corners adjacent to the
|
|
|
|
* given side.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool HasNonZeroCornerOnSide(const nsStyleCorners& aCorners,
|
2010-04-27 09:15:02 -07:00
|
|
|
mozilla::css::Side aSide);
|
2009-05-07 18:52:22 -07:00
|
|
|
|
2007-05-10 08:46:42 -07:00
|
|
|
/**
|
|
|
|
* Determine if a widget is likely to require transparency or translucency.
|
2009-08-13 15:08:13 -07:00
|
|
|
* @param aBackgroundFrame The frame that the background is set on. For
|
|
|
|
* <window>s, this will be the canvas frame.
|
|
|
|
* @param aCSSRootFrame The frame that holds CSS properties affecting
|
|
|
|
* the widget's transparency. For menupopups,
|
|
|
|
* aBackgroundFrame and aCSSRootFrame will be the
|
|
|
|
* same.
|
2007-05-10 08:46:42 -07:00
|
|
|
* @return a value suitable for passing to SetWindowTranslucency
|
|
|
|
*/
|
2009-08-13 15:08:13 -07:00
|
|
|
static nsTransparencyMode GetFrameTransparency(nsIFrame* aBackgroundFrame,
|
|
|
|
nsIFrame* aCSSRootFrame);
|
2007-07-26 02:47:43 -07:00
|
|
|
|
2010-01-11 13:45:18 -08:00
|
|
|
/**
|
|
|
|
* A frame is a popup if it has its own floating window. Menus, panels
|
|
|
|
* and combobox dropdowns are popups.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsPopup(nsIFrame* aFrame);
|
2010-01-11 13:45:18 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the nearest "display root". This is the nearest enclosing
|
|
|
|
* popup frame or the root prescontext's root frame.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetDisplayRootFrame(nsIFrame* aFrame);
|
|
|
|
|
2014-03-04 20:13:21 -08:00
|
|
|
/**
|
|
|
|
* Get the reference frame that would be used when constructing a
|
|
|
|
* display item for this frame. (Note, however, that
|
|
|
|
* nsDisplayTransform use the reference frame appropriate for their
|
2014-03-04 20:13:21 -08:00
|
|
|
* GetTransformRootFrame(), rather than using their own frame as a
|
|
|
|
* reference frame.)
|
2014-03-04 20:13:21 -08:00
|
|
|
*
|
|
|
|
* This duplicates some of the logic of GetDisplayRootFrame above and
|
|
|
|
* of nsDisplayListBuilder::FindReferenceFrameFor.
|
|
|
|
*
|
|
|
|
* If you have an nsDisplayListBuilder, you should get the reference
|
|
|
|
* frame from it instead of calling this.
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetReferenceFrame(nsIFrame* aFrame);
|
|
|
|
|
2014-03-04 20:13:21 -08:00
|
|
|
/**
|
|
|
|
* Get the parent of this frame, except if that parent is part of a
|
|
|
|
* preserve-3d hierarchy, get the parent of the root of the
|
|
|
|
* preserve-3d hierarchy.
|
|
|
|
*
|
|
|
|
* (This is used as the starting point for reference frame computation
|
|
|
|
* for nsDisplayTransform display items.)
|
|
|
|
*/
|
|
|
|
static nsIFrame* GetTransformRootFrame(nsIFrame* aFrame);
|
|
|
|
|
2007-07-26 02:47:43 -07:00
|
|
|
/**
|
|
|
|
* Get textrun construction flags determined by a given style; in particular
|
|
|
|
* some combination of:
|
|
|
|
* -- TEXT_DISABLE_OPTIONAL_LIGATURES if letter-spacing is in use
|
|
|
|
* -- TEXT_OPTIMIZE_SPEED if the text-rendering CSS property and font size
|
|
|
|
* and prefs indicate we should be optimizing for speed over quality
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t GetTextRunFlagsForStyle(nsStyleContext* aStyleContext,
|
2012-08-02 04:38:47 -07:00
|
|
|
const nsStyleFont* aStyleFont,
|
2014-02-05 02:16:23 -08:00
|
|
|
const nsStyleText* aStyleText,
|
2012-08-02 04:38:47 -07:00
|
|
|
nscoord aLetterSpacing);
|
2008-01-29 20:53:46 -08:00
|
|
|
|
2008-02-08 01:36:32 -08:00
|
|
|
/**
|
|
|
|
* Takes two rectangles whose origins must be the same, and computes
|
|
|
|
* the difference between their union and their intersection as two
|
|
|
|
* rectangles. (This difference is a superset of the difference
|
|
|
|
* between the two rectangles.)
|
|
|
|
*/
|
|
|
|
static void GetRectDifferenceStrips(const nsRect& aR1, const nsRect& aR2,
|
|
|
|
nsRect* aHStrip, nsRect* aVStrip);
|
|
|
|
|
2008-07-26 09:14:49 -07:00
|
|
|
/**
|
|
|
|
* Get a device context that can be used to get up-to-date device
|
2012-03-14 11:14:53 -07:00
|
|
|
* dimensions for the given window. For some reason, this is more
|
2008-07-26 09:14:49 -07:00
|
|
|
* complicated than it ought to be in multi-monitor situations.
|
|
|
|
*/
|
2011-04-16 18:22:44 -07:00
|
|
|
static nsDeviceContext*
|
2012-03-14 11:14:53 -07:00
|
|
|
GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow);
|
2008-07-26 09:14:49 -07:00
|
|
|
|
2008-11-25 13:27:54 -08:00
|
|
|
/**
|
|
|
|
* Some frames with 'position: fixed' (nsStylePosition::mDisplay ==
|
|
|
|
* NS_STYLE_POSITION_FIXED) are not really fixed positioned, since
|
|
|
|
* they're inside an element with -moz-transform. This function says
|
|
|
|
* whether such an element is a real fixed-pos element.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsReallyFixedPos(nsIFrame* aFrame);
|
2008-11-25 13:27:54 -08:00
|
|
|
|
2009-06-25 13:30:56 -07:00
|
|
|
/**
|
|
|
|
* Obtain a gfxASurface from the given DOM element, if possible.
|
|
|
|
* This obtains the most natural surface from the element; that
|
|
|
|
* is, the one that can be obtained with the fewest conversions.
|
|
|
|
*
|
|
|
|
* The flags below can modify the behaviour of this function. The
|
|
|
|
* result is returned as a SurfaceFromElementResult struct, also
|
|
|
|
* defined below.
|
|
|
|
*
|
|
|
|
* Currently, this will do:
|
|
|
|
* - HTML Canvas elements: will return the underlying canvas surface
|
|
|
|
* - HTML Video elements: will return the current video frame
|
|
|
|
* - Image elements: will return the image
|
|
|
|
*
|
|
|
|
* The above results are modified by the below flags (copying,
|
|
|
|
* forcing image surface, etc.).
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
/* When creating a new surface, create an image surface */
|
2013-11-26 17:05:02 -08:00
|
|
|
SFE_WANT_IMAGE_SURFACE = 1 << 0,
|
2009-09-12 15:44:18 -07:00
|
|
|
/* Whether to extract the first frame (as opposed to the
|
|
|
|
current frame) in the case that the element is an image. */
|
2013-11-26 17:05:02 -08:00
|
|
|
SFE_WANT_FIRST_FRAME = 1 << 1,
|
2011-01-12 17:45:13 -08:00
|
|
|
/* Whether we should skip colorspace/gamma conversion */
|
2013-11-26 17:05:02 -08:00
|
|
|
SFE_NO_COLORSPACE_CONVERSION = 1 << 2,
|
2011-01-12 17:45:13 -08:00
|
|
|
/* Whether we should skip premultiplication -- the resulting
|
|
|
|
image will always be an image surface, and must not be given to
|
|
|
|
Thebes for compositing! */
|
2014-01-12 16:29:48 -08:00
|
|
|
SFE_NO_PREMULTIPLY_ALPHA = 1 << 3,
|
|
|
|
/* Whether we should skip getting a surface for vector images and
|
|
|
|
return a DirectDrawInfo containing an imgIContainer instead. */
|
|
|
|
SFE_NO_RASTERIZING_VECTORS = 1 << 4
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DirectDrawInfo {
|
|
|
|
/* imgIContainer to directly draw to a context */
|
|
|
|
nsCOMPtr<imgIContainer> mImgContainer;
|
|
|
|
/* which frame to draw */
|
|
|
|
uint32_t mWhichFrame;
|
|
|
|
/* imgIContainer flags to use when drawing */
|
|
|
|
uint32_t mDrawingFlags;
|
2009-06-25 13:30:56 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SurfaceFromElementResult {
|
2013-09-30 14:26:04 -07:00
|
|
|
SurfaceFromElementResult();
|
2010-06-18 09:23:05 -07:00
|
|
|
|
2013-10-08 11:47:21 -07:00
|
|
|
/* mSurface will contain the resulting surface, or will be nullptr on error */
|
2009-06-25 13:30:56 -07:00
|
|
|
nsRefPtr<gfxASurface> mSurface;
|
2013-12-11 13:05:27 -08:00
|
|
|
mozilla::RefPtr<SourceSurface> mSourceSurface;
|
2014-01-12 16:29:48 -08:00
|
|
|
/* Contains info for drawing when there is no mSourceSurface. */
|
|
|
|
DirectDrawInfo mDrawInfo;
|
2013-12-11 13:05:27 -08:00
|
|
|
|
2009-06-25 13:30:56 -07:00
|
|
|
/* The size of the surface */
|
|
|
|
gfxIntSize mSize;
|
2011-09-20 14:00:42 -07:00
|
|
|
/* The principal associated with the element whose surface was returned.
|
|
|
|
If there is a surface, this will never be null. */
|
2009-06-25 13:30:56 -07:00
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
2011-03-23 20:13:56 -07:00
|
|
|
/* The image request, if the element is an nsIImageLoadingContent */
|
|
|
|
nsCOMPtr<imgIRequest> mImageRequest;
|
2009-06-25 13:30:56 -07:00
|
|
|
/* Whether the element was "write only", that is, the bits should not be exposed to content */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsWriteOnly;
|
2010-06-18 09:23:05 -07:00
|
|
|
/* Whether the element was still loading. Some consumers need to handle
|
|
|
|
this case specially. */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsStillLoading;
|
2011-09-09 14:58:35 -07:00
|
|
|
/* Whether the element used CORS when loading. */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mCORSUsed;
|
2009-06-25 13:30:56 -07:00
|
|
|
};
|
|
|
|
|
2011-12-03 13:50:16 -08:00
|
|
|
static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::Element *aElement,
|
2013-12-11 13:05:27 -08:00
|
|
|
uint32_t aSurfaceFlags = 0,
|
|
|
|
DrawTarget *aTarget = nullptr);
|
2012-05-31 11:16:49 -07:00
|
|
|
static SurfaceFromElementResult SurfaceFromElement(nsIImageLoadingContent *aElement,
|
2013-12-11 13:05:27 -08:00
|
|
|
uint32_t aSurfaceFlags = 0,
|
|
|
|
DrawTarget *aTarget = nullptr);
|
2012-12-31 09:25:46 -08:00
|
|
|
// Need an HTMLImageElement overload, because otherwise the
|
2012-05-31 11:16:49 -07:00
|
|
|
// nsIImageLoadingContent and mozilla::dom::Element overloads are ambiguous
|
2012-12-31 09:25:46 -08:00
|
|
|
// for HTMLImageElement.
|
|
|
|
static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLImageElement *aElement,
|
2013-12-11 13:05:27 -08:00
|
|
|
uint32_t aSurfaceFlags = 0,
|
|
|
|
DrawTarget *aTarget = nullptr);
|
2013-01-03 21:16:14 -08:00
|
|
|
static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLCanvasElement *aElement,
|
2013-12-11 13:05:27 -08:00
|
|
|
uint32_t aSurfaceFlags = 0,
|
|
|
|
DrawTarget *aTarget = nullptr);
|
2013-03-19 05:27:35 -07:00
|
|
|
static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLVideoElement *aElement,
|
2013-12-11 13:05:27 -08:00
|
|
|
uint32_t aSurfaceFlags = 0,
|
|
|
|
DrawTarget *aTarget = nullptr);
|
2010-04-21 06:13:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* When the document is editable by contenteditable attribute of its root
|
|
|
|
* content or body content.
|
|
|
|
*
|
2013-10-08 11:47:21 -07:00
|
|
|
* Be aware, this returns nullptr if it's in designMode.
|
2010-04-21 06:13:08 -07:00
|
|
|
*
|
|
|
|
* For example:
|
|
|
|
*
|
|
|
|
* <html contenteditable="true"><body></body></html>
|
|
|
|
* returns the <html>.
|
|
|
|
*
|
|
|
|
* <html><body contenteditable="true"></body></html>
|
|
|
|
* <body contenteditable="true"></body>
|
|
|
|
* With these cases, this returns the <body>.
|
|
|
|
* NOTE: The latter case isn't created normally, however, it can be
|
|
|
|
* created by script with XHTML.
|
|
|
|
*
|
|
|
|
* <body><p contenteditable="true"></p></body>
|
2013-10-08 11:47:21 -07:00
|
|
|
* returns nullptr because <body> isn't editable.
|
2010-04-21 06:13:08 -07:00
|
|
|
*/
|
|
|
|
static nsIContent*
|
|
|
|
GetEditableRootContentByContentEditable(nsIDocument* aDocument);
|
2010-08-08 11:49:07 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the passed in prescontext needs the dark grey background
|
|
|
|
* that goes behind the page of a print preview presentation.
|
|
|
|
*/
|
2013-09-30 14:26:04 -07:00
|
|
|
static bool NeedsPrintPreviewBackground(nsPresContext* aPresContext);
|
2011-01-11 17:09:21 -08:00
|
|
|
|
2011-06-15 23:31:36 -07:00
|
|
|
/**
|
|
|
|
* Adds all font faces used in the frame tree starting from aFrame
|
|
|
|
* to the list aFontFaceList.
|
|
|
|
*/
|
|
|
|
static nsresult GetFontFacesForFrames(nsIFrame* aFrame,
|
|
|
|
nsFontFaceList* aFontFaceList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds all font faces used within the specified range of text in aFrame,
|
|
|
|
* and optionally its continuations, to the list in aFontFaceList.
|
2012-09-27 23:57:33 -07:00
|
|
|
* Pass 0 and INT32_MAX for aStartOffset and aEndOffset to specify the
|
2011-06-15 23:31:36 -07:00
|
|
|
* entire text is to be considered.
|
|
|
|
*/
|
|
|
|
static nsresult GetFontFacesForText(nsIFrame* aFrame,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aFollowContinuations,
|
2011-06-15 23:31:36 -07:00
|
|
|
nsFontFaceList* aFontFaceList);
|
|
|
|
|
2011-10-14 00:06:35 -07:00
|
|
|
/**
|
|
|
|
* Walks the frame tree starting at aFrame looking for textRuns.
|
2011-11-27 19:03:14 -08:00
|
|
|
* If |clear| is true, just clears the TEXT_RUN_MEMORY_ACCOUNTED flag
|
|
|
|
* on each textRun found (and |aMallocSizeOf| is not used).
|
|
|
|
* If |clear| is false, adds the storage used for each textRun to the
|
2011-10-14 00:06:35 -07:00
|
|
|
* total, and sets the TEXT_RUN_MEMORY_ACCOUNTED flag to avoid double-
|
|
|
|
* accounting. (Runs with this flag already set will be skipped.)
|
|
|
|
* Expected usage pattern is therefore to call twice:
|
2012-07-30 07:20:58 -07:00
|
|
|
* (void)SizeOfTextRunsForFrames(rootFrame, nullptr, true);
|
2011-11-27 19:03:14 -08:00
|
|
|
* total = SizeOfTextRunsForFrames(rootFrame, mallocSizeOf, false);
|
2011-10-14 00:06:35 -07:00
|
|
|
*/
|
2011-11-27 19:03:14 -08:00
|
|
|
static size_t SizeOfTextRunsForFrames(nsIFrame* aFrame,
|
2013-06-23 05:03:39 -07:00
|
|
|
mozilla::MallocSizeOf aMallocSizeOf,
|
2011-11-27 19:03:14 -08:00
|
|
|
bool clear);
|
2011-10-14 00:06:35 -07:00
|
|
|
|
2012-07-31 10:28:22 -07:00
|
|
|
/**
|
|
|
|
* Returns true if the content node has animations or transitions that can be
|
|
|
|
* performed on the compositor.
|
|
|
|
*/
|
|
|
|
static bool HasAnimationsForCompositor(nsIContent* aContent,
|
|
|
|
nsCSSProperty aProperty);
|
|
|
|
|
2013-09-04 04:30:57 -07:00
|
|
|
/**
|
|
|
|
* Returns true if the content node has animations or transitions for the
|
|
|
|
* property.
|
|
|
|
*/
|
|
|
|
static bool HasAnimations(nsIContent* aContent, nsCSSProperty aProperty);
|
|
|
|
|
2012-07-31 10:28:22 -07:00
|
|
|
/**
|
2013-05-23 00:09:26 -07:00
|
|
|
* Checks if off-main-thread animations are enabled.
|
2012-07-31 10:28:22 -07:00
|
|
|
*/
|
2013-05-22 03:31:03 -07:00
|
|
|
static bool AreAsyncAnimationsEnabled();
|
2012-07-31 10:28:22 -07:00
|
|
|
|
2012-08-06 13:33:23 -07:00
|
|
|
/**
|
|
|
|
* Checks if we should warn about animations that can't be async
|
|
|
|
*/
|
|
|
|
static bool IsAnimationLoggingEnabled();
|
|
|
|
|
2012-12-21 13:58:17 -08:00
|
|
|
/**
|
2014-02-18 06:58:01 -08:00
|
|
|
* Find a suitable scale for an element (aContent) over the course of any
|
|
|
|
* animations and transitions on the element.
|
|
|
|
* It will check the maximum and minimum scale during the animations and
|
|
|
|
* transitions and return a suitable value for performance and quality.
|
|
|
|
* Will return scale(1,1) if there is no animated scaling.
|
|
|
|
* Always return positive value.
|
|
|
|
*/
|
|
|
|
static gfxSize ComputeSuitableScaleForAnimation(nsIContent* aContent);
|
2012-12-21 13:58:17 -08:00
|
|
|
|
2012-04-24 07:28:46 -07:00
|
|
|
/**
|
|
|
|
* Checks if we should forcibly use nearest pixel filtering for the
|
|
|
|
* background.
|
|
|
|
*/
|
|
|
|
static bool UseBackgroundNearestFiltering();
|
|
|
|
|
2012-05-03 07:05:55 -07:00
|
|
|
/**
|
|
|
|
* Checks whether we want to use the GPU to scale images when
|
|
|
|
* possible.
|
|
|
|
*/
|
|
|
|
static bool GPUImageScalingEnabled();
|
|
|
|
|
2013-05-30 18:33:17 -07:00
|
|
|
/**
|
|
|
|
* Checks whether we want to layerize animated images whenever possible.
|
|
|
|
*/
|
|
|
|
static bool AnimatedImageLayersEnabled();
|
|
|
|
|
2013-07-22 15:08:33 -07:00
|
|
|
/**
|
|
|
|
* Checks if we should enable parsing for CSS Filters.
|
|
|
|
*/
|
|
|
|
static bool CSSFiltersEnabled();
|
|
|
|
|
2013-10-03 11:48:41 -07:00
|
|
|
/**
|
|
|
|
* Checks whether support for the CSS-wide "unset" value is enabled.
|
|
|
|
*/
|
|
|
|
static bool UnsetValueEnabled();
|
|
|
|
|
2013-10-27 13:56:32 -07:00
|
|
|
/**
|
|
|
|
* Checks whether support for the CSS text-align (and -moz-text-align-last)
|
|
|
|
* 'true' value is enabled.
|
|
|
|
*/
|
|
|
|
static bool IsTextAlignTrueValueEnabled();
|
|
|
|
|
2013-12-11 18:09:40 -08:00
|
|
|
/**
|
|
|
|
* Checks if CSS variables are currently enabled.
|
|
|
|
*/
|
|
|
|
static bool CSSVariablesEnabled()
|
|
|
|
{
|
|
|
|
return sCSSVariablesEnabled;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:03:49 -07:00
|
|
|
/**
|
|
|
|
* Unions the overflow areas of all non-popup children of aFrame with
|
|
|
|
* aOverflowAreas.
|
|
|
|
*/
|
|
|
|
static void UnionChildOverflow(nsIFrame* aFrame,
|
|
|
|
nsOverflowAreas& aOverflowAreas);
|
|
|
|
|
2011-11-23 18:48:23 -08:00
|
|
|
/**
|
|
|
|
* Return the font size inflation *ratio* for a given frame. This is
|
|
|
|
* the factor by which font sizes should be inflated; it is never
|
|
|
|
* smaller than 1.
|
|
|
|
*/
|
2012-05-20 22:18:28 -07:00
|
|
|
static float FontSizeInflationFor(const nsIFrame *aFrame);
|
2011-11-23 18:48:23 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform the first half of the computation of FontSizeInflationFor
|
|
|
|
* (see above).
|
|
|
|
* This includes determining whether inflation should be performed
|
|
|
|
* within this container and returning 0 if it should not be.
|
|
|
|
*
|
|
|
|
* The result is guaranteed not to vary between line participants
|
|
|
|
* (inlines, text frames) within a line.
|
|
|
|
*
|
|
|
|
* The result should not be used directly since font sizes slightly
|
|
|
|
* above the minimum should always be adjusted as done by
|
|
|
|
* FontSizeInflationInner.
|
|
|
|
*/
|
2012-05-20 22:18:28 -07:00
|
|
|
static nscoord InflationMinFontSizeFor(const nsIFrame *aFrame);
|
2011-11-23 18:48:23 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform the second half of the computation done by
|
|
|
|
* FontSizeInflationFor (see above).
|
|
|
|
*
|
|
|
|
* aMinFontSize must be the result of one of the
|
|
|
|
* InflationMinFontSizeFor methods above.
|
|
|
|
*/
|
|
|
|
static float FontSizeInflationInner(const nsIFrame *aFrame,
|
|
|
|
nscoord aMinFontSize);
|
|
|
|
|
|
|
|
static bool FontSizeInflationEnabled(nsPresContext *aPresContext);
|
|
|
|
|
2012-10-15 12:03:37 -07:00
|
|
|
/**
|
|
|
|
* See comment above "font.size.inflation.maxRatio" in
|
|
|
|
* modules/libpref/src/init/all.js .
|
|
|
|
*/
|
|
|
|
static uint32_t FontSizeInflationMaxRatio() {
|
|
|
|
return sFontSizeInflationMaxRatio;
|
|
|
|
}
|
|
|
|
|
2012-05-05 06:28:06 -07:00
|
|
|
/**
|
|
|
|
* See comment above "font.size.inflation.emPerLine" in
|
|
|
|
* modules/libpref/src/init/all.js .
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t FontSizeInflationEmPerLine() {
|
2012-05-05 06:28:06 -07:00
|
|
|
return sFontSizeInflationEmPerLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See comment above "font.size.inflation.minTwips" in
|
|
|
|
* modules/libpref/src/init/all.js .
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t FontSizeInflationMinTwips() {
|
2012-05-05 06:28:06 -07:00
|
|
|
return sFontSizeInflationMinTwips;
|
|
|
|
}
|
|
|
|
|
2012-04-16 15:32:11 -07:00
|
|
|
/**
|
|
|
|
* See comment above "font.size.inflation.lineThreshold" in
|
|
|
|
* modules/libpref/src/init/all.js .
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t FontSizeInflationLineThreshold() {
|
2012-04-16 15:32:11 -07:00
|
|
|
return sFontSizeInflationLineThreshold;
|
|
|
|
}
|
|
|
|
|
2012-11-20 11:55:14 -08:00
|
|
|
static bool FontSizeInflationForceEnabled() {
|
|
|
|
return sFontSizeInflationForceEnabled;
|
|
|
|
}
|
|
|
|
|
2012-11-28 12:16:01 -08:00
|
|
|
static bool FontSizeInflationDisabledInMasterProcess() {
|
|
|
|
return sFontSizeInflationDisabledInMasterProcess;
|
|
|
|
}
|
|
|
|
|
2012-08-11 11:33:36 -07:00
|
|
|
/**
|
|
|
|
* See comment above "font.size.inflation.mappingIntercept" in
|
|
|
|
* modules/libpref/src/init/all.js .
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t FontSizeInflationMappingIntercept() {
|
2012-08-11 11:33:36 -07:00
|
|
|
return sFontSizeInflationMappingIntercept;
|
|
|
|
}
|
|
|
|
|
2013-05-13 16:47:02 -07:00
|
|
|
/**
|
|
|
|
* Returns true if the nglayout.debug.invalidation pref is set to true.
|
|
|
|
* Note that sInvalidationDebuggingIsEnabled is declared outside this function to
|
|
|
|
* allow it to be accessed an manipulated from breakpoint conditions.
|
|
|
|
*/
|
|
|
|
static bool InvalidationDebuggingIsEnabled() {
|
2013-05-29 19:43:43 -07:00
|
|
|
return sInvalidationDebuggingIsEnabled || getenv("MOZ_DUMP_INVALIDATION") != 0;
|
2013-05-13 16:47:02 -07:00
|
|
|
}
|
|
|
|
|
2011-11-23 18:48:23 -08:00
|
|
|
static void Initialize();
|
2011-01-13 09:45:14 -08:00
|
|
|
static void Shutdown();
|
|
|
|
|
2011-11-09 13:39:16 -08:00
|
|
|
/**
|
|
|
|
* Register an imgIRequest object with a refresh driver.
|
|
|
|
*
|
|
|
|
* @param aPresContext The nsPresContext whose refresh driver we want to
|
|
|
|
* register with.
|
|
|
|
* @param aRequest A pointer to the imgIRequest object which the client wants
|
|
|
|
* to register with the refresh driver.
|
|
|
|
* @param aRequestRegistered A pointer to a boolean value which indicates
|
|
|
|
* whether the given image request is registered. If
|
|
|
|
* *aRequestRegistered is true, then this request will not be
|
|
|
|
* registered again. If the request is registered by this function,
|
|
|
|
* then *aRequestRegistered will be set to true upon the completion of
|
|
|
|
* this function.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void RegisterImageRequest(nsPresContext* aPresContext,
|
|
|
|
imgIRequest* aRequest,
|
|
|
|
bool* aRequestRegistered);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register an imgIRequest object with a refresh driver, but only if the
|
|
|
|
* request is for an image that is animated.
|
|
|
|
*
|
|
|
|
* @param aPresContext The nsPresContext whose refresh driver we want to
|
|
|
|
* register with.
|
|
|
|
* @param aRequest A pointer to the imgIRequest object which the client wants
|
|
|
|
* to register with the refresh driver.
|
|
|
|
* @param aRequestRegistered A pointer to a boolean value which indicates
|
|
|
|
* whether the given image request is registered. If
|
|
|
|
* *aRequestRegistered is true, then this request will not be
|
|
|
|
* registered again. If the request is registered by this function,
|
|
|
|
* then *aRequestRegistered will be set to true upon the completion of
|
|
|
|
* this function.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void RegisterImageRequestIfAnimated(nsPresContext* aPresContext,
|
|
|
|
imgIRequest* aRequest,
|
|
|
|
bool* aRequestRegistered);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deregister an imgIRequest object from a refresh driver.
|
|
|
|
*
|
|
|
|
* @param aPresContext The nsPresContext whose refresh driver we want to
|
|
|
|
* deregister from.
|
|
|
|
* @param aRequest A pointer to the imgIRequest object with which the client
|
|
|
|
* previously registered and now wants to deregister from the refresh
|
|
|
|
* driver.
|
|
|
|
* @param aRequestRegistered A pointer to a boolean value which indicates
|
|
|
|
* whether the given image request is registered. If
|
|
|
|
* *aRequestRegistered is false, then this request will not be
|
|
|
|
* deregistered. If the request is deregistered by this function,
|
|
|
|
* then *aRequestRegistered will be set to false upon the completion of
|
|
|
|
* this function.
|
|
|
|
*/
|
|
|
|
static void DeregisterImageRequest(nsPresContext* aPresContext,
|
|
|
|
imgIRequest* aRequest,
|
|
|
|
bool* aRequestRegistered);
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
/**
|
|
|
|
* Shim to nsCSSFrameConstructor::PostRestyleEvent. Exists so that we
|
|
|
|
* can avoid including nsCSSFrameConstructor.h and all its dependencies
|
|
|
|
* in content files.
|
|
|
|
*/
|
|
|
|
static void PostRestyleEvent(mozilla::dom::Element* aElement,
|
|
|
|
nsRestyleHint aRestyleHint,
|
|
|
|
nsChangeHint aMinChangeHint);
|
|
|
|
|
2012-08-08 04:37:14 -07:00
|
|
|
/**
|
|
|
|
* Updates a pair of x and y distances if a given point is closer to a given
|
|
|
|
* rectangle than the original distance values. If aPoint is closer to
|
|
|
|
* aRect than aClosestXDistance and aClosestYDistance indicate, then those
|
|
|
|
* two variables are updated with the distance between aPoint and aRect,
|
|
|
|
* and true is returned. If aPoint is not closer, then aClosestXDistance
|
|
|
|
* and aClosestYDistance are left unchanged, and false is returned.
|
|
|
|
*
|
|
|
|
* Distances are measured in the two dimensions separately; a closer x
|
|
|
|
* distance beats a closer y distance.
|
|
|
|
*/
|
|
|
|
template<typename PointType, typename RectType, typename CoordType>
|
|
|
|
static bool PointIsCloserToRect(PointType aPoint, const RectType& aRect,
|
|
|
|
CoordType& aClosestXDistance,
|
|
|
|
CoordType& aClosestYDistance);
|
2012-12-11 12:36:54 -08:00
|
|
|
/**
|
|
|
|
* Computes the box shadow rect for the frame, or returns an empty rect if
|
|
|
|
* there are no shadows.
|
|
|
|
*
|
|
|
|
* @param aFrame Frame to compute shadows for.
|
|
|
|
* @param aFrameSize Size of aFrame (in case it hasn't been set yet).
|
|
|
|
*/
|
|
|
|
static nsRect GetBoxShadowRectForFrame(nsIFrame* aFrame, const nsSize& aFrameSize);
|
2012-08-08 04:37:14 -07:00
|
|
|
|
2011-01-11 17:09:21 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
/**
|
|
|
|
* Assert that there are no duplicate continuations of the same frame
|
|
|
|
* within aFrameList. Optimize the tests by assuming that all frames
|
|
|
|
* in aFrameList have parent aContainer.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
AssertNoDuplicateContinuations(nsIFrame* aContainer,
|
|
|
|
const nsFrameList& aFrameList);
|
2011-01-11 17:09:22 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert that the frame tree rooted at |aSubtreeRoot| is empty, i.e.,
|
|
|
|
* that it contains no first-in-flows.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
AssertTreeOnlyEmptyNextInFlows(nsIFrame *aSubtreeRoot);
|
2011-01-11 17:09:21 -08:00
|
|
|
#endif
|
2012-04-16 15:32:11 -07:00
|
|
|
|
2013-09-14 17:05:05 -07:00
|
|
|
/**
|
|
|
|
* Determine if aImageFrame (which is an nsImageFrame, nsImageControlFrame, or
|
|
|
|
* nsSVGImageFrame) is visible or close to being visible via scrolling and
|
|
|
|
* update the presshell with this knowledge.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
UpdateImageVisibilityForFrame(nsIFrame* aImageFrame);
|
|
|
|
|
2014-03-26 18:46:23 -07:00
|
|
|
/**
|
|
|
|
* Calculate the compostion size for a frame. See FrameMetrics.h for
|
|
|
|
* defintion of composition size (or bounds).
|
|
|
|
*/
|
|
|
|
static nsSize
|
|
|
|
CalculateCompositionSizeForFrame(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the scrollable rect for a frame. See FrameMetrics.h for
|
|
|
|
* defintion of scrollable rect. aScrollableFrame is the scroll frame to calculate
|
|
|
|
* the scrollable rect for. If it's null then we calculate the scrollable rect
|
|
|
|
* as the rect of the root frame.
|
|
|
|
*/
|
|
|
|
static nsRect
|
|
|
|
CalculateScrollableRectForFrame(nsIScrollableFrame* aScrollableFrame, nsIFrame* aRootFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the expanded scrollable rect for a frame. See FrameMetrics.h for
|
|
|
|
* defintion of expanded scrollable rect.
|
|
|
|
*/
|
|
|
|
static nsRect
|
|
|
|
CalculateExpandedScrollableRect(nsIFrame* aFrame);
|
|
|
|
|
2012-04-16 15:32:11 -07:00
|
|
|
private:
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t sFontSizeInflationEmPerLine;
|
|
|
|
static uint32_t sFontSizeInflationMinTwips;
|
|
|
|
static uint32_t sFontSizeInflationLineThreshold;
|
2012-10-15 12:03:37 -07:00
|
|
|
static int32_t sFontSizeInflationMappingIntercept;
|
|
|
|
static uint32_t sFontSizeInflationMaxRatio;
|
2012-11-20 11:55:14 -08:00
|
|
|
static bool sFontSizeInflationForceEnabled;
|
2012-11-28 12:16:01 -08:00
|
|
|
static bool sFontSizeInflationDisabledInMasterProcess;
|
2013-05-13 16:47:02 -07:00
|
|
|
static bool sInvalidationDebuggingIsEnabled;
|
2013-12-11 18:09:40 -08:00
|
|
|
static bool sCSSVariablesEnabled;
|
2008-01-29 20:53:46 -08:00
|
|
|
};
|
|
|
|
|
2012-08-08 04:37:14 -07:00
|
|
|
template<typename PointType, typename RectType, typename CoordType>
|
|
|
|
/* static */ bool
|
|
|
|
nsLayoutUtils::PointIsCloserToRect(PointType aPoint, const RectType& aRect,
|
|
|
|
CoordType& aClosestXDistance,
|
|
|
|
CoordType& aClosestYDistance)
|
|
|
|
{
|
|
|
|
CoordType fromLeft = aPoint.x - aRect.x;
|
|
|
|
CoordType fromRight = aPoint.x - aRect.XMost();
|
|
|
|
|
|
|
|
CoordType xDistance;
|
|
|
|
if (fromLeft >= 0 && fromRight <= 0) {
|
|
|
|
xDistance = 0;
|
|
|
|
} else {
|
2013-01-15 04:22:03 -08:00
|
|
|
xDistance = std::min(abs(fromLeft), abs(fromRight));
|
2012-08-08 04:37:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xDistance <= aClosestXDistance) {
|
|
|
|
if (xDistance < aClosestXDistance) {
|
|
|
|
aClosestYDistance = std::numeric_limits<CoordType>::max();
|
|
|
|
}
|
|
|
|
|
|
|
|
CoordType fromTop = aPoint.y - aRect.y;
|
|
|
|
CoordType fromBottom = aPoint.y - aRect.YMost();
|
|
|
|
|
|
|
|
CoordType yDistance;
|
|
|
|
if (fromTop >= 0 && fromBottom <= 0) {
|
|
|
|
yDistance = 0;
|
|
|
|
} else {
|
2013-01-15 04:22:03 -08:00
|
|
|
yDistance = std::min(abs(fromTop), abs(fromBottom));
|
2012-08-08 04:37:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (yDistance < aClosestYDistance) {
|
|
|
|
aClosestXDistance = xDistance;
|
|
|
|
aClosestYDistance = yDistance;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-24 17:21:29 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layout {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An RAII class which will, for the duration of its lifetime,
|
|
|
|
* **if** the frame given is a container for font size inflation,
|
|
|
|
* set the current inflation container on the pres context to null
|
|
|
|
* (and then, in its destructor, restore the old value).
|
|
|
|
*/
|
2012-05-20 22:18:27 -07:00
|
|
|
class AutoMaybeDisableFontInflation {
|
2012-01-24 17:21:29 -08:00
|
|
|
public:
|
2013-09-30 14:26:04 -07:00
|
|
|
AutoMaybeDisableFontInflation(nsIFrame *aFrame);
|
|
|
|
|
|
|
|
~AutoMaybeDisableFontInflation();
|
2012-01-24 17:21:29 -08:00
|
|
|
private:
|
|
|
|
nsPresContext *mPresContext;
|
2012-05-20 22:18:27 -07:00
|
|
|
bool mOldValue;
|
2012-01-24 17:21:29 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-14 16:59:21 -07:00
|
|
|
class nsSetAttrRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsSetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName,
|
|
|
|
const nsAString& aValue);
|
2010-05-03 06:23:36 -07:00
|
|
|
nsSetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aValue);
|
2008-04-14 16:59:21 -07:00
|
|
|
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
nsCOMPtr<nsIAtom> mAttrName;
|
|
|
|
nsAutoString mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsUnsetAttrRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsUnsetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName);
|
|
|
|
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
nsCOMPtr<nsIAtom> mAttrName;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsLayoutUtils_h__
|