2001-12-12 07:59:31 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2012-03-26 11:58:59 +00:00
|
|
|
// Main header first:
|
2006-06-15 19:10:28 +00:00
|
|
|
#include "nsSVGOuterSVGFrame.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
|
2012-03-26 11:58:59 +00:00
|
|
|
// Keep others in (case-insensitive) order:
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "nsIDocument.h"
|
2011-07-15 10:31:34 +00:00
|
|
|
#include "nsIDOMWindow.h"
|
2007-11-18 12:09:03 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2012-03-26 11:58:59 +00:00
|
|
|
#include "nsIObjectLoadingContent.h"
|
|
|
|
#include "nsRenderingContext.h"
|
2012-06-30 11:20:46 +00:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2012-07-17 17:03:51 +00:00
|
|
|
#include "nsSVGForeignObjectFrame.h"
|
2013-01-09 23:02:45 +00:00
|
|
|
#include "mozilla/dom/SVGSVGElement.h"
|
2013-01-08 03:22:41 +00:00
|
|
|
#include "mozilla/dom/SVGViewElement.h"
|
2012-08-29 05:39:33 +00:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2013-03-04 09:56:02 +00:00
|
|
|
using namespace mozilla;
|
2013-01-09 23:02:45 +00:00
|
|
|
using namespace mozilla::dom;
|
2010-08-24 07:05:56 +00:00
|
|
|
|
2006-09-28 08:00:20 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation helpers
|
|
|
|
|
2012-07-17 17:03:51 +00:00
|
|
|
void
|
|
|
|
nsSVGOuterSVGFrame::RegisterForeignObject(nsSVGForeignObjectFrame* aFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFrame, "Who on earth is calling us?!");
|
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
if (!mForeignObjectHash) {
|
|
|
|
mForeignObjectHash = new nsTHashtable<nsPtrHashKey<nsSVGForeignObjectFrame> >();
|
2012-07-17 17:03:51 +00:00
|
|
|
}
|
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
NS_ASSERTION(!mForeignObjectHash->GetEntry(aFrame),
|
2012-07-17 17:03:51 +00:00
|
|
|
"nsSVGForeignObjectFrame already registered!");
|
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
mForeignObjectHash->PutEntry(aFrame);
|
2012-07-17 17:03:51 +00:00
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
NS_ASSERTION(mForeignObjectHash->GetEntry(aFrame),
|
2012-07-17 17:03:51 +00:00
|
|
|
"Failed to register nsSVGForeignObjectFrame!");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGOuterSVGFrame::UnregisterForeignObject(nsSVGForeignObjectFrame* aFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFrame, "Who on earth is calling us?!");
|
2013-09-02 08:41:57 +00:00
|
|
|
NS_ASSERTION(mForeignObjectHash && mForeignObjectHash->GetEntry(aFrame),
|
2012-07-17 17:03:51 +00:00
|
|
|
"nsSVGForeignObjectFrame not in registry!");
|
2013-09-02 08:41:57 +00:00
|
|
|
return mForeignObjectHash->RemoveEntry(aFrame);
|
2012-07-17 17:03:51 +00:00
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
nsContainerFrame*
|
2009-01-19 18:31:34 +00:00
|
|
|
NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2005-11-11 02:36:29 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsSVGOuterSVGFrame(aContext);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGOuterSVGFrame)
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsSVGOuterSVGFrame::nsSVGOuterSVGFrame(nsStyleContext* aContext)
|
2008-01-09 22:53:59 +00:00
|
|
|
: nsSVGOuterSVGFrameBase(aContext)
|
2012-08-30 08:55:22 +00:00
|
|
|
, mFullZoom(aContext->PresContext()->GetFullZoom())
|
2011-10-17 14:59:28 +00:00
|
|
|
, mViewportInitialized(false)
|
|
|
|
, mIsRootContent(false)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2012-05-17 04:05:09 +00:00
|
|
|
// Outer-<svg> has CSS layout, so remove this bit:
|
|
|
|
RemoveStateBits(NS_FRAME_SVG_LAYOUT);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2014-05-24 22:20:40 +00:00
|
|
|
nsSVGOuterSVGFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2013-01-08 03:22:41 +00:00
|
|
|
NS_ASSERTION(aContent->IsSVG(nsGkAtoms::svg),
|
|
|
|
"Content is not an SVG 'svg' element!");
|
2009-01-19 18:31:34 +00:00
|
|
|
|
2012-04-16 22:32:12 +00:00
|
|
|
AddStateBits(NS_STATE_IS_OUTER_SVG |
|
|
|
|
NS_FRAME_FONT_INFLATION_CONTAINER |
|
|
|
|
NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
2008-06-22 15:59:48 +00:00
|
|
|
|
2010-12-06 20:57:18 +00:00
|
|
|
// Check for conditional processing attributes here rather than in
|
|
|
|
// nsCSSFrameConstructor::FindSVGData because we want to avoid
|
|
|
|
// simply giving failing outer <svg> elements an nsSVGContainerFrame.
|
2012-03-20 12:15:53 +00:00
|
|
|
// We don't create other SVG frames if PassesConditionalProcessingTests
|
|
|
|
// returns false, but since we do create nsSVGOuterSVGFrame frames we
|
2013-07-12 07:13:07 +00:00
|
|
|
// prevent them from painting by [ab]use NS_FRAME_IS_NONDISPLAY. The
|
2012-03-20 12:15:53 +00:00
|
|
|
// frame will be recreated via an nsChangeHint_ReconstructFrame restyle if
|
|
|
|
// the value returned by PassesConditionalProcessingTests changes.
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *svg = static_cast<SVGSVGElement*>(aContent);
|
2011-12-31 09:44:03 +00:00
|
|
|
if (!svg->PassesConditionalProcessingTests()) {
|
2013-07-12 07:13:07 +00:00
|
|
|
AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2010-12-06 20:57:18 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
nsSVGOuterSVGFrameBase::Init(aContent, aParent, aPrevInFlow);
|
2007-08-30 17:01:37 +00:00
|
|
|
|
2005-08-25 21:31:09 +00:00
|
|
|
nsIDocument* doc = mContent->GetCurrentDoc();
|
2006-09-28 08:00:20 +00:00
|
|
|
if (doc) {
|
|
|
|
// we only care about our content's zoom and pan values if it's the root element
|
2010-04-30 13:12:05 +00:00
|
|
|
if (doc->GetRootElement() == mContent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsRootContent = true;
|
2006-09-28 08:00:20 +00:00
|
|
|
}
|
2005-08-25 21:31:09 +00:00
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2009-01-12 19:20:59 +00:00
|
|
|
// nsQueryFrame methods
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGOuterSVGFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsISVGSVGFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGOuterSVGFrameBase)
|
2001-12-12 07:59:31 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// reflowing
|
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsSVGOuterSVGFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2007-11-18 12:09:03 +00:00
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
|
|
|
result = nscoord(0);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsSVGOuterSVGFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2007-11-18 12:09:03 +00:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *svg = static_cast<SVGSVGElement*>(mContent);
|
2013-01-09 23:02:47 +00:00
|
|
|
nsSVGLength2 &width = svg->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
|
2007-11-18 12:09:03 +00:00
|
|
|
|
2008-01-25 09:27:03 +00:00
|
|
|
if (width.IsPercentage()) {
|
2008-02-08 21:50:24 +00:00
|
|
|
// It looks like our containing block's width may depend on our width. In
|
|
|
|
// that case our behavior is undefined according to CSS 2.1 section 10.3.2,
|
|
|
|
// so return zero.
|
|
|
|
result = nscoord(0);
|
2007-11-18 12:09:03 +00:00
|
|
|
} else {
|
|
|
|
result = nsPresContext::CSSPixelsToAppUnits(width.GetAnimValue(svg));
|
2008-01-25 08:54:59 +00:00
|
|
|
if (result < 0) {
|
|
|
|
result = nscoord(0);
|
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
return result;
|
|
|
|
}
|
2007-06-14 20:51:42 +00:00
|
|
|
|
2013-09-30 21:26:04 +00:00
|
|
|
/* virtual */ IntrinsicSize
|
2007-11-18 12:09:03 +00:00
|
|
|
nsSVGOuterSVGFrame::GetIntrinsicSize()
|
|
|
|
{
|
|
|
|
// XXXjwatt Note that here we want to return the CSS width/height if they're
|
|
|
|
// specified and we're embedded inside an nsIObjectLoadingContent.
|
|
|
|
|
|
|
|
IntrinsicSize intrinsicSize;
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
|
2013-01-09 23:02:47 +00:00
|
|
|
nsSVGLength2 &width = content->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
|
|
|
|
nsSVGLength2 &height = content->mLengthAttributes[SVGSVGElement::ATTR_HEIGHT];
|
2007-11-18 12:09:03 +00:00
|
|
|
|
2011-06-13 01:52:32 +00:00
|
|
|
if (!width.IsPercentage()) {
|
2007-11-18 12:09:03 +00:00
|
|
|
nscoord val = nsPresContext::CSSPixelsToAppUnits(width.GetAnimValue(content));
|
|
|
|
if (val < 0) val = 0;
|
|
|
|
intrinsicSize.width.SetCoordValue(val);
|
|
|
|
}
|
2007-06-14 20:51:42 +00:00
|
|
|
|
2011-06-13 01:52:32 +00:00
|
|
|
if (!height.IsPercentage()) {
|
2007-11-18 12:09:03 +00:00
|
|
|
nscoord val = nsPresContext::CSSPixelsToAppUnits(height.GetAnimValue(content));
|
|
|
|
if (val < 0) val = 0;
|
|
|
|
intrinsicSize.height.SetCoordValue(val);
|
|
|
|
}
|
2007-06-14 20:51:42 +00:00
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
return intrinsicSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
|
|
|
nsSVGOuterSVGFrame::GetIntrinsicRatio()
|
|
|
|
{
|
|
|
|
// We only have an intrinsic size/ratio if our width and height attributes
|
|
|
|
// are both specified and set to non-percentage values, or we have a viewBox
|
|
|
|
// rect: http://www.w3.org/TR/SVGMobile12/coords.html#IntrinsicSizing
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
|
2013-01-09 23:02:47 +00:00
|
|
|
nsSVGLength2 &width = content->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
|
|
|
|
nsSVGLength2 &height = content->mLengthAttributes[SVGSVGElement::ATTR_HEIGHT];
|
2007-11-18 12:09:03 +00:00
|
|
|
|
2008-01-25 09:27:03 +00:00
|
|
|
if (!width.IsPercentage() && !height.IsPercentage()) {
|
2011-06-13 21:48:50 +00:00
|
|
|
nsSize ratio(NSToCoordRoundWithClamp(width.GetAnimValue(content)),
|
|
|
|
NSToCoordRoundWithClamp(height.GetAnimValue(content)));
|
2008-01-25 08:54:59 +00:00
|
|
|
if (ratio.width < 0) {
|
|
|
|
ratio.width = 0;
|
|
|
|
}
|
|
|
|
if (ratio.height < 0) {
|
|
|
|
ratio.height = 0;
|
|
|
|
}
|
|
|
|
return ratio;
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGViewElement* viewElement = content->GetCurrentViewElement();
|
2012-09-09 11:44:03 +00:00
|
|
|
const nsSVGViewBoxRect* viewbox = nullptr;
|
|
|
|
|
|
|
|
// The logic here should match HasViewBox().
|
2013-02-26 16:58:06 +00:00
|
|
|
if (viewElement && viewElement->mViewBox.HasRect()) {
|
2012-09-09 11:44:03 +00:00
|
|
|
viewbox = &viewElement->mViewBox.GetAnimValue();
|
2013-02-26 16:58:06 +00:00
|
|
|
} else if (content->mViewBox.HasRect()) {
|
2012-09-09 11:44:03 +00:00
|
|
|
viewbox = &content->mViewBox.GetAnimValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewbox) {
|
|
|
|
float viewBoxWidth = viewbox->width;
|
|
|
|
float viewBoxHeight = viewbox->height;
|
2009-02-03 14:42:24 +00:00
|
|
|
|
2008-02-21 17:43:25 +00:00
|
|
|
if (viewBoxWidth < 0.0f) {
|
|
|
|
viewBoxWidth = 0.0f;
|
|
|
|
}
|
|
|
|
if (viewBoxHeight < 0.0f) {
|
|
|
|
viewBoxHeight = 0.0f;
|
|
|
|
}
|
2011-06-13 21:48:50 +00:00
|
|
|
return nsSize(NSToCoordRoundWithClamp(viewBoxWidth),
|
|
|
|
NSToCoordRoundWithClamp(viewBoxHeight));
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsSVGOuterSVGFrameBase::GetIntrinsicRatio();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsSVGOuterSVGFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
2007-11-18 12:09:03 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
2007-11-18 12:09:03 +00:00
|
|
|
{
|
2012-05-03 16:05:24 +00:00
|
|
|
if (IsRootOfImage() || IsRootOfReplacedElementSubDoc()) {
|
|
|
|
// The embedding element has sized itself using the CSS replaced element
|
|
|
|
// sizing rules, using our intrinsic dimensions as necessary. The SVG spec
|
|
|
|
// says that the width and height of embedded SVG is overridden by the
|
|
|
|
// width and height of the embedding element, so we just need to size to
|
|
|
|
// the viewport that the embedding element has established for us.
|
|
|
|
return aCBSize;
|
|
|
|
}
|
2011-02-09 20:13:18 +00:00
|
|
|
|
2012-05-03 16:05:24 +00:00
|
|
|
nsSize cbSize = aCBSize;
|
2011-06-13 01:52:32 +00:00
|
|
|
IntrinsicSize intrinsicSize = GetIntrinsicSize();
|
|
|
|
|
|
|
|
if (!mContent->GetParent()) {
|
2012-05-03 16:05:24 +00:00
|
|
|
// We're the root of the outermost browsing context, so we need to scale
|
|
|
|
// cbSize by the full-zoom so that SVGs with percentage width/height zoom:
|
|
|
|
|
|
|
|
NS_ASSERTION(aCBSize.width != NS_AUTOHEIGHT &&
|
|
|
|
aCBSize.height != NS_AUTOHEIGHT,
|
|
|
|
"root should not have auto-width/height containing block");
|
|
|
|
cbSize.width *= PresContext()->GetFullZoom();
|
|
|
|
cbSize.height *= PresContext()->GetFullZoom();
|
|
|
|
|
|
|
|
// We also need to honour the width and height attributes' default values
|
|
|
|
// of 100% when we're the root of a browsing context. (GetIntrinsicSize()
|
|
|
|
// doesn't report these since there's no such thing as a percentage
|
|
|
|
// intrinsic size. Also note that explicit percentage values are mapped
|
|
|
|
// into style, so the following isn't for them.)
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement* content = static_cast<SVGSVGElement*>(mContent);
|
2012-05-03 16:05:24 +00:00
|
|
|
|
|
|
|
nsSVGLength2 &width =
|
2013-01-09 23:02:47 +00:00
|
|
|
content->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
|
2012-05-03 16:05:24 +00:00
|
|
|
if (width.IsPercentage()) {
|
|
|
|
NS_ABORT_IF_FALSE(intrinsicSize.width.GetUnit() == eStyleUnit_None,
|
|
|
|
"GetIntrinsicSize should have reported no "
|
|
|
|
"intrinsic width");
|
|
|
|
float val = width.GetAnimValInSpecifiedUnits() / 100.0f;
|
|
|
|
if (val < 0.0f) val = 0.0f;
|
|
|
|
intrinsicSize.width.SetCoordValue(val * cbSize.width);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGLength2 &height =
|
2013-01-09 23:02:47 +00:00
|
|
|
content->mLengthAttributes[SVGSVGElement::ATTR_HEIGHT];
|
2012-05-03 16:05:24 +00:00
|
|
|
NS_ASSERTION(aCBSize.height != NS_AUTOHEIGHT,
|
|
|
|
"root should not have auto-height containing block");
|
|
|
|
if (height.IsPercentage()) {
|
|
|
|
NS_ABORT_IF_FALSE(intrinsicSize.height.GetUnit() == eStyleUnit_None,
|
|
|
|
"GetIntrinsicSize should have reported no "
|
|
|
|
"intrinsic height");
|
|
|
|
float val = height.GetAnimValInSpecifiedUnits() / 100.0f;
|
|
|
|
if (val < 0.0f) val = 0.0f;
|
|
|
|
intrinsicSize.height.SetCoordValue(val * cbSize.height);
|
2011-06-13 01:52:32 +00:00
|
|
|
}
|
2012-05-03 16:05:24 +00:00
|
|
|
NS_ABORT_IF_FALSE(intrinsicSize.height.GetUnit() == eStyleUnit_Coord &&
|
|
|
|
intrinsicSize.width.GetUnit() == eStyleUnit_Coord,
|
|
|
|
"We should have just handled the only situation where"
|
|
|
|
"we lack an intrinsic height or width.");
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
2007-06-14 20:51:42 +00:00
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
|
|
|
|
aRenderingContext, this,
|
2012-05-03 16:05:24 +00:00
|
|
|
intrinsicSize, GetIntrinsicRatio(), cbSize,
|
2007-11-18 12:09:03 +00:00
|
|
|
aMargin, aBorder, aPadding);
|
|
|
|
}
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
2007-11-18 12:09:03 +00:00
|
|
|
nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsSVGOuterSVGFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsSVGOuterSVGFrame::Reflow: availSize=%d,%d",
|
2013-12-27 17:59:21 +00:00
|
|
|
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
|
2007-02-07 07:46:44 +00:00
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
|
2007-02-07 07:46:44 +00:00
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Width() = aReflowState.ComputedWidth() +
|
2013-12-27 17:59:21 +00:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Height() = aReflowState.ComputedHeight() +
|
2013-12-27 17:59:21 +00:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
NS_ASSERTION(!GetPrevInFlow(), "SVG can't currently be broken across pages.");
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *svgElem = static_cast<SVGSVGElement*>(mContent);
|
2012-07-20 18:12:29 +00:00
|
|
|
|
|
|
|
nsSVGOuterSVGAnonChildFrame *anonKid =
|
|
|
|
static_cast<nsSVGOuterSVGAnonChildFrame*>(GetFirstPrincipalChild());
|
|
|
|
|
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
// Initialize
|
2012-12-18 02:25:16 +00:00
|
|
|
svgElem->UpdateHasChildrenOnlyTransform();
|
2012-07-20 18:12:29 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
// If our SVG viewport has changed, update our content and notify.
|
|
|
|
// http://www.w3.org/TR/SVG11/coords.html#ViewportSpace
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
svgFloatSize newViewportSize(
|
|
|
|
nsPresContext::AppUnitsToFloatCSSPixels(aReflowState.ComputedWidth()),
|
|
|
|
nsPresContext::AppUnitsToFloatCSSPixels(aReflowState.ComputedHeight()));
|
|
|
|
|
2012-12-18 02:21:09 +00:00
|
|
|
svgFloatSize oldViewportSize = svgElem->GetViewportSize();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t changeBits = 0;
|
2012-12-18 02:21:09 +00:00
|
|
|
if (newViewportSize != oldViewportSize) {
|
2013-05-08 17:11:42 +00:00
|
|
|
// When our viewport size changes, we may need to update the overflow rects
|
|
|
|
// of our child frames. This is the case if:
|
|
|
|
//
|
|
|
|
// * We have a real/synthetic viewBox (a children-only transform), since
|
|
|
|
// the viewBox transform will change as the viewport dimensions change.
|
|
|
|
//
|
|
|
|
// * We do not have a real/synthetic viewBox, but the last time we
|
|
|
|
// reflowed (or the last time UpdateOverflow() was called) we did.
|
|
|
|
//
|
|
|
|
// We only handle the former case here, in which case we mark all our child
|
|
|
|
// frames as dirty so that we reflow them below and update their overflow
|
|
|
|
// rects.
|
|
|
|
//
|
|
|
|
// In the latter case, updating of overflow rects is handled for removal of
|
|
|
|
// real viewBox (the viewBox attribute) in AttributeChanged. Synthetic
|
|
|
|
// viewBox "removal" (e.g. a document references the same SVG via both an
|
|
|
|
// <svg:image> and then as a CSS background image (a synthetic viewBox is
|
|
|
|
// used when painting the former, but not when painting the latter)) is
|
|
|
|
// handled in SVGSVGElement::FlushImageTransformInvalidation.
|
|
|
|
//
|
2013-07-10 23:20:54 +00:00
|
|
|
if (svgElem->HasViewBoxOrSyntheticViewBox()) {
|
2012-12-18 02:21:09 +00:00
|
|
|
nsIFrame* anonChild = GetFirstPrincipalChild();
|
|
|
|
anonChild->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
for (nsIFrame* child = anonChild->GetFirstPrincipalChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
child->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
|
|
|
}
|
2012-05-03 16:05:53 +00:00
|
|
|
changeBits |= COORD_CONTEXT_CHANGED;
|
2007-11-18 12:09:03 +00:00
|
|
|
svgElem->SetViewportSize(newViewportSize);
|
2012-05-03 16:05:53 +00:00
|
|
|
}
|
|
|
|
if (mFullZoom != PresContext()->GetFullZoom()) {
|
2012-05-17 04:05:09 +00:00
|
|
|
changeBits |= FULL_ZOOM_CHANGED;
|
2007-12-04 04:40:52 +00:00
|
|
|
mFullZoom = PresContext()->GetFullZoom();
|
2012-05-03 16:05:53 +00:00
|
|
|
}
|
|
|
|
if (changeBits) {
|
|
|
|
NotifyViewportOrTransformChanged(changeBits);
|
2007-06-14 20:51:42 +00:00
|
|
|
}
|
2012-12-18 02:25:16 +00:00
|
|
|
mViewportInitialized = true;
|
2006-04-14 15:09:39 +00:00
|
|
|
|
2013-07-29 23:47:30 +00:00
|
|
|
// Now that we've marked the necessary children as dirty, call
|
|
|
|
// ReflowSVG() or ReflowSVGNonDisplayText() on them, depending
|
|
|
|
// on whether we are non-display.
|
|
|
|
mCallingReflowSVG = true;
|
|
|
|
if (GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
|
|
|
|
ReflowSVGNonDisplayText(this);
|
|
|
|
} else {
|
2012-07-09 01:04:56 +00:00
|
|
|
// Update the mRects and visual overflow rects of all our descendants,
|
|
|
|
// including our anonymous wrapper kid:
|
2013-02-11 06:22:16 +00:00
|
|
|
anonKid->AddStateBits(mState & NS_FRAME_IS_DIRTY);
|
2012-07-22 00:01:44 +00:00
|
|
|
anonKid->ReflowSVG();
|
2012-07-09 01:04:56 +00:00
|
|
|
NS_ABORT_IF_FALSE(!anonKid->GetNextSibling(),
|
|
|
|
"We should have one anonymous child frame wrapping our real children");
|
|
|
|
}
|
2013-07-29 23:47:30 +00:00
|
|
|
mCallingReflowSVG = false;
|
2012-03-20 12:15:53 +00:00
|
|
|
|
2012-07-09 01:04:56 +00:00
|
|
|
// Set our anonymous kid's offset from our border box:
|
|
|
|
anonKid->SetPosition(GetContentRectRelativeToSelf().TopLeft());
|
|
|
|
|
2013-05-24 13:51:50 +00:00
|
|
|
// Including our size in our overflow rects regardless of the value of
|
|
|
|
// 'background', 'border', etc. makes sure that we usually (when we clip to
|
|
|
|
// our content area) don't have to keep changing our overflow rects as our
|
|
|
|
// descendants move about (see perf comment below). Including our size in our
|
|
|
|
// scrollable overflow rect also makes sure that we scroll if we're too big
|
|
|
|
// for our viewport.
|
|
|
|
//
|
|
|
|
// <svg> never allows scrolling to anything outside its mRect (only panning),
|
|
|
|
// so we must always keep our scrollable overflow set to our size.
|
|
|
|
//
|
|
|
|
// With regards to visual overflow, we always clip root-<svg> (see our
|
|
|
|
// BuildDisplayList method) regardless of the value of the 'overflow'
|
|
|
|
// property since that is per-spec, even for the initial 'visible' value. For
|
|
|
|
// that reason there's no point in adding descendant visual overflow to our
|
|
|
|
// own when this frame is for a root-<svg>. That said, there's also a very
|
|
|
|
// good performance reason for us wanting to avoid doing so. If we did, then
|
|
|
|
// the frame's overflow would often change as descendants that are partially
|
|
|
|
// or fully outside its rect moved (think animation on/off screen), and that
|
|
|
|
// would cause us to do a full NS_FRAME_IS_DIRTY reflow and repaint of the
|
|
|
|
// entire document tree each such move (see bug 875175).
|
|
|
|
//
|
|
|
|
// So it's only non-root outer-<svg> that has the visual overflow of its
|
|
|
|
// descendants added to its own. (Note that the default user-agent style
|
|
|
|
// sheet makes 'hidden' the default value for :not(root(svg)), so usually
|
|
|
|
// FinishAndStoreOverflow will still clip this back to the frame's rect.)
|
|
|
|
//
|
|
|
|
// WARNING!! Keep UpdateBounds below in sync with whatever we do for our
|
|
|
|
// overflow rects here! (Again, see bug 875175.)
|
|
|
|
//
|
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
|
|
|
if (!mIsRootContent) {
|
|
|
|
aDesiredSize.mOverflowAreas.VisualOverflow().UnionRect(
|
|
|
|
aDesiredSize.mOverflowAreas.VisualOverflow(),
|
|
|
|
anonKid->GetVisualOverflowRect() + anonKid->GetPosition());
|
|
|
|
}
|
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
|
|
|
|
2012-05-13 19:30:44 +00:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsSVGOuterSVGFrame::Reflow: size=%d,%d",
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Width(), aDesiredSize.Height()));
|
2012-05-13 19:30:44 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:53 +00:00
|
|
|
void
|
2012-05-13 19:30:44 +00:00
|
|
|
nsSVGOuterSVGFrame::DidReflow(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus)
|
|
|
|
{
|
2014-05-13 00:47:53 +00:00
|
|
|
nsSVGOuterSVGFrameBase::DidReflow(aPresContext,aReflowState,aStatus);
|
2012-03-20 12:15:53 +00:00
|
|
|
|
|
|
|
// Make sure elements styled by :hover get updated if script/animation moves
|
|
|
|
// them under or out from under the pointer:
|
|
|
|
PresContext()->PresShell()->SynthesizeMouseMove(false);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2013-05-24 13:51:50 +00:00
|
|
|
/* virtual */ bool
|
|
|
|
nsSVGOuterSVGFrame::UpdateOverflow()
|
|
|
|
{
|
|
|
|
// See the comments in Reflow above.
|
|
|
|
|
|
|
|
// WARNING!! Keep this in sync with Reflow above!
|
|
|
|
|
|
|
|
nsRect rect(nsPoint(0, 0), GetSize());
|
|
|
|
nsOverflowAreas overflowAreas(rect, rect);
|
|
|
|
|
|
|
|
if (!mIsRootContent) {
|
|
|
|
nsIFrame *anonKid = GetFirstPrincipalChild();
|
|
|
|
overflowAreas.VisualOverflow().UnionRect(
|
|
|
|
overflowAreas.VisualOverflow(),
|
|
|
|
anonKid->GetVisualOverflowRect() + anonKid->GetPosition());
|
|
|
|
}
|
|
|
|
|
|
|
|
return FinishAndStoreOverflow(overflowAreas, GetSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// container methods
|
|
|
|
|
2012-07-20 18:12:29 +00:00
|
|
|
/**
|
|
|
|
* Used to paint/hit-test SVG when SVG display lists are disabled.
|
|
|
|
*/
|
2012-06-28 19:51:20 +00:00
|
|
|
class nsDisplayOuterSVG : public nsDisplayItem {
|
2006-01-26 02:29:17 +00:00
|
|
|
public:
|
2012-06-28 19:51:20 +00:00
|
|
|
nsDisplayOuterSVG(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsSVGOuterSVGFrame* aFrame) :
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayItem(aBuilder, aFrame) {
|
2012-06-28 19:51:20 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayOuterSVG);
|
2006-01-29 18:48:58 +00:00
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
2012-06-28 19:51:20 +00:00
|
|
|
virtual ~nsDisplayOuterSVG() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayOuterSVG);
|
2006-01-29 18:48:58 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 00:31:26 +00:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2014-02-24 14:41:56 +00:00
|
|
|
HitTestState* aState,
|
|
|
|
nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 14:41:56 +00:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2012-08-29 05:39:33 +00:00
|
|
|
|
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2014-02-24 14:41:56 +00:00
|
|
|
nsRegion* aInvalidRegion) MOZ_OVERRIDE;
|
2012-08-29 05:39:33 +00:00
|
|
|
|
2012-06-28 19:51:20 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("SVGOuterSVG", TYPE_SVG_OUTER_SVG)
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
|
|
|
|
2010-04-08 00:31:26 +00:00
|
|
|
void
|
2012-06-28 19:51:20 +00:00
|
|
|
nsDisplayOuterSVG::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2010-05-12 21:41:47 +00:00
|
|
|
nsSVGOuterSVGFrame *outerSVGFrame = static_cast<nsSVGOuterSVGFrame*>(mFrame);
|
2010-08-13 10:01:58 +00:00
|
|
|
nsRect rectAtOrigin = aRect - ToReferenceFrame();
|
2010-05-12 21:41:47 +00:00
|
|
|
nsRect thisRect(nsPoint(0,0), outerSVGFrame->GetSize());
|
2010-04-08 00:31:26 +00:00
|
|
|
if (!thisRect.Intersects(rectAtOrigin))
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsPoint rectCenter(rectAtOrigin.x + rectAtOrigin.width / 2,
|
|
|
|
rectAtOrigin.y + rectAtOrigin.height / 2);
|
|
|
|
|
2012-07-09 01:04:56 +00:00
|
|
|
nsSVGOuterSVGAnonChildFrame *anonKid =
|
|
|
|
static_cast<nsSVGOuterSVGAnonChildFrame*>(
|
|
|
|
outerSVGFrame->GetFirstPrincipalChild());
|
2010-05-12 21:41:47 +00:00
|
|
|
nsIFrame* frame = nsSVGUtils::HitTestChildren(
|
2012-07-09 01:04:56 +00:00
|
|
|
anonKid, rectCenter + outerSVGFrame->GetPosition() -
|
|
|
|
outerSVGFrame->GetContentRect().TopLeft());
|
2010-04-08 00:31:26 +00:00
|
|
|
if (frame) {
|
|
|
|
aOutFrames->AppendElement(frame);
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-28 19:51:20 +00:00
|
|
|
nsDisplayOuterSVG::Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRenderingContext* aContext)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2012-03-02 23:38:36 +00:00
|
|
|
#if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)
|
|
|
|
PRTime start = PR_Now();
|
|
|
|
#endif
|
|
|
|
|
2012-07-05 15:18:03 +00:00
|
|
|
// Create an SVGAutoRenderState so we can call SetPaintingToWindow on
|
|
|
|
// it, but do so without changing the render mode:
|
|
|
|
SVGAutoRenderState state(aContext, SVGAutoRenderState::GetRenderMode(aContext));
|
|
|
|
|
|
|
|
if (aBuilder->IsPaintingToWindow()) {
|
|
|
|
state.SetPaintingToWindow(true);
|
|
|
|
}
|
|
|
|
|
2012-06-28 19:51:31 +00:00
|
|
|
nsRect viewportRect =
|
2012-07-05 15:18:03 +00:00
|
|
|
mFrame->GetContentRectRelativeToSelf() + ToReferenceFrame();
|
|
|
|
|
2012-06-28 19:51:31 +00:00
|
|
|
nsRect clipRect = mVisibleRect.Intersect(viewportRect);
|
|
|
|
|
2012-07-05 15:18:03 +00:00
|
|
|
nsIntRect contentAreaDirtyRect =
|
|
|
|
(clipRect - viewportRect.TopLeft()).
|
|
|
|
ToOutsidePixels(mFrame->PresContext()->AppUnitsPerDevPixel());
|
|
|
|
|
2012-07-05 15:18:03 +00:00
|
|
|
aContext->PushState();
|
2012-06-28 19:51:31 +00:00
|
|
|
aContext->Translate(viewportRect.TopLeft());
|
2012-07-05 15:18:03 +00:00
|
|
|
nsSVGUtils::PaintFrameWithEffects(aContext, &contentAreaDirtyRect, mFrame);
|
2012-03-02 23:38:36 +00:00
|
|
|
aContext->PopState();
|
|
|
|
|
2012-07-05 15:18:03 +00:00
|
|
|
NS_ASSERTION(!aContext->ThebesContext()->HasError(), "Cairo in error state");
|
|
|
|
|
2012-03-02 23:38:36 +00:00
|
|
|
#if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)
|
|
|
|
PRTime end = PR_Now();
|
|
|
|
printf("SVG Paint Timing: %f ms\n", (end-start)/1000.0);
|
|
|
|
#endif
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2012-08-29 05:39:33 +00:00
|
|
|
static PLDHashOperator CheckForeignObjectInvalidatedArea(nsPtrHashKey<nsSVGForeignObjectFrame>* aEntry, void* aData)
|
|
|
|
{
|
|
|
|
nsRegion* region = static_cast<nsRegion*>(aData);
|
|
|
|
region->Or(*region, aEntry->GetKey()->GetInvalidRegion());
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRegion
|
|
|
|
nsSVGOuterSVGFrame::FindInvalidatedForeignObjectFrameChildren(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsRegion result;
|
2013-09-02 08:41:57 +00:00
|
|
|
if (mForeignObjectHash && mForeignObjectHash->Count()) {
|
|
|
|
mForeignObjectHash->EnumerateEntries(CheckForeignObjectInvalidatedArea, &result);
|
2012-08-29 05:39:33 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplayOuterSVG::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion* aInvalidRegion)
|
|
|
|
{
|
|
|
|
nsSVGOuterSVGFrame *frame = static_cast<nsSVGOuterSVGFrame*>(mFrame);
|
|
|
|
frame->InvalidateSVG(frame->FindInvalidatedForeignObjectFrameChildren(frame));
|
|
|
|
|
|
|
|
nsRegion result = frame->GetInvalidRegion();
|
|
|
|
result.MoveBy(ToReferenceFrame());
|
|
|
|
frame->ClearInvalidRegion();
|
|
|
|
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
aInvalidRegion->Or(*aInvalidRegion, result);
|
|
|
|
}
|
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
// helper
|
2011-09-29 06:19:26 +00:00
|
|
|
static inline bool
|
2007-11-18 12:09:03 +00:00
|
|
|
DependsOnIntrinsicSize(const nsIFrame* aEmbeddingFrame)
|
|
|
|
{
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStylePosition *pos = aEmbeddingFrame->StylePosition();
|
2010-08-11 19:32:53 +00:00
|
|
|
const nsStyleCoord &width = pos->mWidth;
|
|
|
|
const nsStyleCoord &height = pos->mHeight;
|
2007-11-18 12:09:03 +00:00
|
|
|
|
|
|
|
// XXX it would be nice to know if the size of aEmbeddingFrame's containing
|
|
|
|
// block depends on aEmbeddingFrame, then we'd know if we can return false
|
|
|
|
// for eStyleUnit_Percent too.
|
2010-08-25 10:17:55 +00:00
|
|
|
return !width.ConvertsToLength() ||
|
|
|
|
!height.ConvertsToLength();
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGOuterSVGFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-11-18 12:09:03 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aModType)
|
2007-03-09 16:27:01 +00:00
|
|
|
{
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
2013-07-12 07:13:07 +00:00
|
|
|
!(GetStateBits() & (NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_NONDISPLAY))) {
|
2011-09-30 08:25:01 +00:00
|
|
|
if (aAttribute == nsGkAtoms::viewBox ||
|
|
|
|
aAttribute == nsGkAtoms::preserveAspectRatio ||
|
|
|
|
aAttribute == nsGkAtoms::transform) {
|
|
|
|
|
|
|
|
// make sure our cached transform matrix gets (lazily) updated
|
2012-07-30 14:20:58 +00:00
|
|
|
mCanvasTM = nullptr;
|
2011-09-30 08:25:01 +00:00
|
|
|
|
2012-07-09 01:04:56 +00:00
|
|
|
nsSVGUtils::NotifyChildrenOfSVGChange(GetFirstPrincipalChild(),
|
|
|
|
aAttribute == nsGkAtoms::viewBox ?
|
2011-09-30 08:25:01 +00:00
|
|
|
TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED : TRANSFORM_CHANGED);
|
|
|
|
|
2013-05-23 07:04:21 +00:00
|
|
|
if (aAttribute != nsGkAtoms::transform) {
|
|
|
|
static_cast<SVGSVGElement*>(mContent)->ChildrenOnlyTransformChanged();
|
|
|
|
}
|
2012-05-17 04:05:09 +00:00
|
|
|
|
2011-09-30 08:25:01 +00:00
|
|
|
} else if (aAttribute == nsGkAtoms::width ||
|
|
|
|
aAttribute == nsGkAtoms::height) {
|
|
|
|
|
2012-05-17 04:05:09 +00:00
|
|
|
// Don't call ChildrenOnlyTransformChanged() here, since we call it
|
|
|
|
// under Reflow if the width/height actually changed.
|
|
|
|
|
2012-05-10 11:47:34 +00:00
|
|
|
nsIFrame* embeddingFrame;
|
|
|
|
if (IsRootOfReplacedElementSubDoc(&embeddingFrame) && embeddingFrame) {
|
|
|
|
if (DependsOnIntrinsicSize(embeddingFrame)) {
|
|
|
|
// Tell embeddingFrame's presShell it needs to be reflowed (which takes
|
|
|
|
// care of reflowing us too).
|
|
|
|
embeddingFrame->PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(embeddingFrame, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
2011-09-30 08:25:01 +00:00
|
|
|
}
|
2012-05-10 11:47:34 +00:00
|
|
|
// else our width and height is overridden - don't reflow anything
|
|
|
|
} else {
|
|
|
|
// We are not embedded by reference, so our 'width' and 'height'
|
|
|
|
// attributes are not overridden - we need to reflow.
|
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
2007-03-09 16:27:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// painting
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsSVGOuterSVGFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2013-07-12 07:13:07 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
|
2013-02-14 11:12:27 +00:00
|
|
|
return;
|
2012-06-28 19:51:31 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:08:08 +00:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2007-11-18 12:09:03 +00:00
|
|
|
|
2013-05-24 16:56:26 +00:00
|
|
|
// Per-spec, we always clip root-<svg> even when 'overflow' has its initial
|
|
|
|
// value of 'visible'. See also the "visual overflow" comments in Reflow.
|
|
|
|
DisplayListClipState::AutoSaveRestore autoSR(aBuilder);
|
|
|
|
if (mIsRootContent ||
|
|
|
|
StyleDisplay()->IsScrollableOverflow()) {
|
|
|
|
autoSR.ClipContainingBlockDescendantsToContentBox(aBuilder, this);
|
|
|
|
}
|
2012-06-12 10:25:26 +00:00
|
|
|
|
2012-07-20 18:12:29 +00:00
|
|
|
if ((aBuilder->IsForEventDelivery() &&
|
|
|
|
NS_SVGDisplayListHitTestingEnabled()) ||
|
|
|
|
NS_SVGDisplayListPaintingEnabled()) {
|
2013-03-04 09:56:02 +00:00
|
|
|
nsDisplayList *contentList = aLists.Content();
|
|
|
|
nsDisplayListSet set(contentList, contentList, contentList,
|
|
|
|
contentList, contentList, contentList);
|
2013-02-14 11:08:08 +00:00
|
|
|
BuildDisplayListForNonBlockChildren(aBuilder, aDirtyRect, set);
|
2012-07-20 18:12:29 +00:00
|
|
|
} else {
|
2013-03-04 09:56:02 +00:00
|
|
|
aLists.Content()->AppendNewToTop(
|
2013-02-14 11:08:08 +00:00
|
|
|
new (aBuilder) nsDisplayOuterSVG(aBuilder, this));
|
2012-07-20 18:12:29 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2008-02-22 10:50:32 +00:00
|
|
|
nsSplittableType
|
|
|
|
nsSVGOuterSVGFrame::GetSplittableType() const
|
|
|
|
{
|
|
|
|
return NS_FRAME_NOT_SPLITTABLE;
|
|
|
|
}
|
|
|
|
|
2005-04-01 19:56:08 +00:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGOuterSVGFrame::GetType() const
|
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::svgOuterSVGFrame;
|
2005-04-01 19:56:08 +00:00
|
|
|
}
|
|
|
|
|
2004-08-05 09:01:13 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGSVGFrame methods:
|
|
|
|
|
2012-02-04 13:58:46 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsSVGOuterSVGFrame::NotifyViewportOrTransformChanged(uint32_t aFlags)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
{
|
2012-05-03 16:05:53 +00:00
|
|
|
NS_ABORT_IF_FALSE(aFlags &&
|
2012-05-17 04:05:09 +00:00
|
|
|
!(aFlags & ~(COORD_CONTEXT_CHANGED | TRANSFORM_CHANGED |
|
|
|
|
FULL_ZOOM_CHANGED)),
|
2012-05-03 16:05:53 +00:00
|
|
|
"Unexpected aFlags value");
|
|
|
|
|
|
|
|
// No point in doing anything when were not init'ed yet:
|
2008-01-25 09:27:03 +00:00
|
|
|
if (!mViewportInitialized) {
|
2012-02-04 13:58:46 +00:00
|
|
|
return;
|
2008-01-25 09:27:03 +00:00
|
|
|
}
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
2012-05-03 16:05:53 +00:00
|
|
|
if (aFlags & COORD_CONTEXT_CHANGED) {
|
2013-02-26 16:58:06 +00:00
|
|
|
if (content->HasViewBoxRect()) {
|
2012-05-03 16:05:53 +00:00
|
|
|
// Percentage lengths on children resolve against the viewBox rect so we
|
|
|
|
// don't need to notify them of the viewport change, but the viewBox
|
|
|
|
// transform will have changed, so we need to notify them of that instead.
|
|
|
|
aFlags = TRANSFORM_CHANGED;
|
|
|
|
}
|
2012-12-18 02:21:09 +00:00
|
|
|
else if (content->ShouldSynthesizeViewBox()) {
|
|
|
|
// In the case of a synthesized viewBox, the synthetic viewBox's rect
|
|
|
|
// changes as the viewport changes. As a result we need to maintain the
|
|
|
|
// COORD_CONTEXT_CHANGED flag.
|
|
|
|
aFlags |= TRANSFORM_CHANGED;
|
|
|
|
}
|
2012-05-03 16:05:53 +00:00
|
|
|
else if (mCanvasTM && mCanvasTM->IsSingular()) {
|
|
|
|
// A width/height of zero will result in us having a singular mCanvasTM
|
|
|
|
// even when we don't have a viewBox. So we also want to recompute our
|
|
|
|
// mCanvasTM for this width/height change even though we don't have a
|
|
|
|
// viewBox.
|
|
|
|
aFlags |= TRANSFORM_CHANGED;
|
|
|
|
}
|
|
|
|
}
|
2008-01-25 09:27:03 +00:00
|
|
|
|
2012-05-17 04:05:09 +00:00
|
|
|
bool haveNonFulLZoomTransformChange = (aFlags & TRANSFORM_CHANGED);
|
|
|
|
|
|
|
|
if (aFlags & FULL_ZOOM_CHANGED) {
|
|
|
|
// Convert FULL_ZOOM_CHANGED to TRANSFORM_CHANGED:
|
|
|
|
aFlags = (aFlags & ~FULL_ZOOM_CHANGED) | TRANSFORM_CHANGED;
|
|
|
|
}
|
|
|
|
|
2012-05-03 16:05:53 +00:00
|
|
|
if (aFlags & TRANSFORM_CHANGED) {
|
|
|
|
// Make sure our canvas transform matrix gets (lazily) recalculated:
|
2012-07-30 14:20:58 +00:00
|
|
|
mCanvasTM = nullptr;
|
2012-05-17 04:05:09 +00:00
|
|
|
|
|
|
|
if (haveNonFulLZoomTransformChange &&
|
2013-07-12 07:13:07 +00:00
|
|
|
!(mState & NS_FRAME_IS_NONDISPLAY)) {
|
2012-09-06 14:11:28 +00:00
|
|
|
uint32_t flags = (mState & NS_FRAME_IN_REFLOW) ?
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement::eDuringReflow : 0;
|
2012-08-31 14:30:18 +00:00
|
|
|
content->ChildrenOnlyTransformChanged(flags);
|
2012-05-17 04:05:09 +00:00
|
|
|
}
|
2007-06-14 20:51:42 +00:00
|
|
|
}
|
|
|
|
|
2012-07-09 01:04:56 +00:00
|
|
|
nsSVGUtils::NotifyChildrenOfSVGChange(GetFirstPrincipalChild(), aFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGChildFrame methods:
|
|
|
|
|
2014-02-19 22:34:31 +00:00
|
|
|
nsresult
|
2012-07-09 01:04:56 +00:00
|
|
|
nsSVGOuterSVGFrame::PaintSVG(nsRenderingContext* aContext,
|
2013-09-11 07:27:45 +00:00
|
|
|
const nsIntRect *aDirtyRect,
|
|
|
|
nsIFrame* aTransformRoot)
|
2012-07-09 01:04:56 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(GetFirstPrincipalChild()->GetType() ==
|
|
|
|
nsGkAtoms::svgOuterSVGAnonChildFrame &&
|
|
|
|
!GetFirstPrincipalChild()->GetNextSibling(),
|
|
|
|
"We should have a single, anonymous, child");
|
|
|
|
nsSVGOuterSVGAnonChildFrame *anonKid =
|
|
|
|
static_cast<nsSVGOuterSVGAnonChildFrame*>(GetFirstPrincipalChild());
|
2013-09-11 07:27:45 +00:00
|
|
|
return anonKid->PaintSVG(aContext, aDirtyRect, aTransformRoot);
|
2012-07-09 01:04:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SVGBBox
|
2013-12-30 06:50:07 +00:00
|
|
|
nsSVGOuterSVGFrame::GetBBoxContribution(const gfx::Matrix &aToBBoxUserspace,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
2012-07-09 01:04:56 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(GetFirstPrincipalChild()->GetType() ==
|
|
|
|
nsGkAtoms::svgOuterSVGAnonChildFrame &&
|
|
|
|
!GetFirstPrincipalChild()->GetNextSibling(),
|
|
|
|
"We should have a single, anonymous, child");
|
|
|
|
// We must defer to our child so that we don't include our
|
|
|
|
// content->PrependLocalTransformsTo() transforms.
|
|
|
|
nsSVGOuterSVGAnonChildFrame *anonKid =
|
|
|
|
static_cast<nsSVGOuterSVGAnonChildFrame*>(GetFirstPrincipalChild());
|
|
|
|
return anonKid->GetBBoxContribution(aToBBoxUserspace, aFlags);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
//----------------------------------------------------------------------
|
2006-06-01 15:31:15 +00:00
|
|
|
// nsSVGContainerFrame methods:
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxMatrix
|
2013-09-11 07:27:45 +00:00
|
|
|
nsSVGOuterSVGFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
|
2004-08-05 09:01:13 +00:00
|
|
|
{
|
2013-09-11 07:27:45 +00:00
|
|
|
if (!(GetStateBits() & NS_FRAME_IS_NONDISPLAY) && !aTransformRoot) {
|
2012-06-30 11:20:46 +00:00
|
|
|
if ((aFor == FOR_PAINTING && NS_SVGDisplayListPaintingEnabled()) ||
|
|
|
|
(aFor == FOR_HIT_TESTING && NS_SVGDisplayListHitTestingEnabled())) {
|
|
|
|
return nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(this);
|
|
|
|
}
|
|
|
|
}
|
2004-08-05 09:01:13 +00:00
|
|
|
if (!mCanvasTM) {
|
2013-09-11 07:27:45 +00:00
|
|
|
NS_ASSERTION(!aTransformRoot, "transform root will be ignored here");
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
|
2007-12-04 04:40:52 +00:00
|
|
|
|
|
|
|
float devPxPerCSSPx =
|
2009-07-23 08:35:59 +00:00
|
|
|
1.0f / PresContext()->AppUnitsToFloatCSSPixels(
|
2007-12-04 04:40:52 +00:00
|
|
|
PresContext()->AppUnitsPerDevPixel());
|
2004-12-02 23:13:13 +00:00
|
|
|
|
2013-12-26 20:13:57 +00:00
|
|
|
gfxMatrix tm = content->PrependLocalTransformsTo(
|
|
|
|
gfxMatrix().Scale(devPxPerCSSPx, devPxPerCSSPx));
|
|
|
|
mCanvasTM = new gfxMatrix(tm);
|
2004-08-05 09:01:13 +00:00
|
|
|
}
|
2011-09-25 21:04:32 +00:00
|
|
|
return *mCanvasTM;
|
2004-08-05 09:01:13 +00:00
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation helpers
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-02-09 20:13:18 +00:00
|
|
|
nsSVGOuterSVGFrame::IsRootOfReplacedElementSubDoc(nsIFrame **aEmbeddingFrame)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
{
|
2010-09-08 20:40:39 +00:00
|
|
|
if (!mContent->GetParent()) {
|
2007-11-18 12:09:03 +00:00
|
|
|
// Our content is the document element
|
2014-01-10 02:03:47 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = PresContext()->GetDocShell();
|
|
|
|
nsCOMPtr<nsIDOMWindow> window;
|
|
|
|
if (docShell) {
|
|
|
|
window = docShell->GetWindow();
|
|
|
|
}
|
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
if (window) {
|
|
|
|
nsCOMPtr<nsIDOMElement> frameElement;
|
|
|
|
window->GetFrameElement(getter_AddRefs(frameElement));
|
|
|
|
nsCOMPtr<nsIObjectLoadingContent> olc = do_QueryInterface(frameElement);
|
|
|
|
if (olc) {
|
|
|
|
// Our document is inside an HTML 'object', 'embed' or 'applet' element
|
|
|
|
if (aEmbeddingFrame) {
|
|
|
|
nsCOMPtr<nsIContent> element = do_QueryInterface(frameElement);
|
2012-11-14 22:10:08 +00:00
|
|
|
*aEmbeddingFrame = element->GetPrimaryFrame();
|
2007-11-18 12:09:03 +00:00
|
|
|
NS_ASSERTION(*aEmbeddingFrame, "Yikes, no embedding frame!");
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aEmbeddingFrame) {
|
2012-07-30 14:20:58 +00:00
|
|
|
*aEmbeddingFrame = nullptr;
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2007-11-18 12:09:03 +00:00
|
|
|
}
|
2010-09-08 20:40:39 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-09-08 20:40:39 +00:00
|
|
|
nsSVGOuterSVGFrame::IsRootOfImage()
|
|
|
|
{
|
|
|
|
if (!mContent->GetParent()) {
|
|
|
|
// Our content is the document element
|
|
|
|
nsIDocument* doc = mContent->GetCurrentDoc();
|
|
|
|
if (doc && doc->IsBeingUsedAsImage()) {
|
|
|
|
// Our document is being used as an image
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2010-09-08 20:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-09-08 20:40:39 +00:00
|
|
|
}
|
2012-03-19 08:34:19 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
nsSVGOuterSVGFrame::VerticalScrollbarNotNeeded() const
|
|
|
|
{
|
2013-01-09 23:02:45 +00:00
|
|
|
nsSVGLength2 &height = static_cast<SVGSVGElement*>(mContent)->
|
2013-01-09 23:02:47 +00:00
|
|
|
mLengthAttributes[SVGSVGElement::ATTR_HEIGHT];
|
2012-03-19 08:34:19 +00:00
|
|
|
return height.IsPercentage() && height.GetBaseValInSpecifiedUnits() <= 100;
|
|
|
|
}
|
2012-07-09 01:04:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation of nsSVGOuterSVGAnonChildFrame
|
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
nsContainerFrame*
|
2012-07-09 01:04:56 +00:00
|
|
|
NS_NewSVGOuterSVGAnonChildFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGOuterSVGAnonChildFrame(aContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGOuterSVGAnonChildFrame)
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2014-05-24 22:20:40 +00:00
|
|
|
nsSVGOuterSVGAnonChildFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2012-07-09 01:04:56 +00:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(aParent->GetType() == nsGkAtoms::svgOuterSVGFrame,
|
|
|
|
"Unexpected parent");
|
2013-03-20 01:47:48 +00:00
|
|
|
nsSVGOuterSVGAnonChildFrameBase::Init(aContent, aParent, aPrevInFlow);
|
2012-07-09 01:04:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIAtom *
|
|
|
|
nsSVGOuterSVGAnonChildFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::svgOuterSVGAnonChildFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-12-29 23:35:53 +00:00
|
|
|
nsSVGOuterSVGAnonChildFrame::HasChildrenOnlyTransform(gfx::Matrix *aTransform) const
|
2012-07-09 01:04:56 +00:00
|
|
|
{
|
|
|
|
// We must claim our nsSVGOuterSVGFrame's children-only transforms as our own
|
|
|
|
// so that the children we are used to wrap are transformed properly.
|
|
|
|
|
2013-01-09 23:02:45 +00:00
|
|
|
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
|
2012-07-09 01:04:56 +00:00
|
|
|
|
|
|
|
bool hasTransform = content->HasChildrenOnlyTransform();
|
|
|
|
|
|
|
|
if (hasTransform && aTransform) {
|
|
|
|
// Outer-<svg> doesn't use x/y, so we can pass eChildToUserSpace here.
|
2013-12-26 20:13:57 +00:00
|
|
|
gfxMatrix identity;
|
2013-12-29 23:35:53 +00:00
|
|
|
*aTransform = gfx::ToMatrix(
|
2013-12-26 20:13:57 +00:00
|
|
|
content->PrependLocalTransformsTo(identity,
|
2013-12-29 23:35:53 +00:00
|
|
|
nsSVGElement::eChildToUserSpace));
|
2012-07-09 01:04:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return hasTransform;
|
|
|
|
}
|