2001-12-12 10:59:31 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 10:59:31 +03:00
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Main header first:
|
2006-02-21 03:33:27 +03:00
|
|
|
#include "nsSVGForeignObjectFrame.h"
|
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Keep others in (case-insensitive) order:
|
2016-07-22 14:07:39 +03:00
|
|
|
#include "DrawResult.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "gfxContext.h"
|
2016-07-22 14:07:39 +03:00
|
|
|
#include "nsDisplayList.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-02-21 03:33:27 +03:00
|
|
|
#include "nsRegion.h"
|
2012-03-20 16:15:55 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-03-20 16:15:53 +04:00
|
|
|
#include "nsSVGEffects.h"
|
2013-01-06 10:25:55 +04:00
|
|
|
#include "mozilla/dom/SVGForeignObjectElement.h"
|
2012-06-30 15:20:46 +04:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2012-03-26 15:58:59 +04:00
|
|
|
#include "nsSVGOuterSVGFrame.h"
|
|
|
|
#include "nsSVGUtils.h"
|
2012-04-17 02:32:12 +04:00
|
|
|
#include "mozilla/AutoRestore.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2013-01-06 10:25:55 +04:00
|
|
|
using namespace mozilla::dom;
|
2016-07-22 14:07:39 +03:00
|
|
|
using namespace mozilla::image;
|
2001-12-12 10:59:31 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2007-06-22 03:01:10 +04:00
|
|
|
NS_NewSVGForeignObjectFrame(nsIPresShell *aPresShell,
|
|
|
|
nsStyleContext *aContext)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsSVGForeignObjectFrame(aContext);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGForeignObjectFrame)
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsSVGForeignObjectFrame::nsSVGForeignObjectFrame(nsStyleContext* aContext)
|
2016-04-18 10:05:48 +03:00
|
|
|
: nsContainerFrame(aContext)
|
|
|
|
, mInReflow(false)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2012-05-17 08:05:09 +04:00
|
|
|
AddStateBits(NS_FRAME_REFLOW_ROOT | NS_FRAME_MAY_BE_TRANSFORMED |
|
|
|
|
NS_FRAME_SVG_LAYOUT);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2009-01-09 19:35:24 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
2008-11-05 22:25:30 +03:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGForeignObjectFrame)
|
2017-02-09 21:24:31 +03:00
|
|
|
NS_QUERYFRAME_ENTRY(nsSVGDisplayableFrame)
|
2016-04-18 10:05:48 +03:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2009-01-12 22:20:59 +03:00
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsSVGForeignObjectFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2007-11-20 12:10:18 +03:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::foreignObject),
|
2013-01-08 07:22:41 +04:00
|
|
|
"Content is not an SVG foreignObject!");
|
2009-01-19 21:31:34 +03:00
|
|
|
|
2016-04-18 10:05:48 +03:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2013-07-12 11:13:07 +04:00
|
|
|
AddStateBits(aParent->GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD);
|
2012-04-17 02:32:12 +04:00
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_CONTAINER |
|
|
|
|
NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
2013-07-12 11:13:07 +04:00
|
|
|
if (!(mState & NS_FRAME_IS_NONDISPLAY)) {
|
2012-07-17 21:03:51 +04:00
|
|
|
nsSVGUtils::GetOuterSVGFrame(this)->RegisterForeignObject(this);
|
|
|
|
}
|
2007-11-20 12:10:18 +03:00
|
|
|
}
|
|
|
|
|
2012-07-17 21:03:51 +04:00
|
|
|
void nsSVGForeignObjectFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|
|
|
{
|
|
|
|
// Only unregister if we registered in the first place:
|
2013-07-12 11:13:07 +04:00
|
|
|
if (!(mState & NS_FRAME_IS_NONDISPLAY)) {
|
2012-07-17 21:03:51 +04:00
|
|
|
nsSVGUtils::GetOuterSVGFrame(this)->UnregisterForeignObject(this);
|
|
|
|
}
|
2016-04-18 10:05:48 +03:00
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
2012-07-17 21:03:51 +04:00
|
|
|
}
|
|
|
|
|
2006-06-07 03:13:15 +04:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGForeignObjectFrame::GetType() const
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::svgForeignObjectFrame;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGForeignObjectFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-06-22 03:01:10 +04:00
|
|
|
nsIAtom *aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2006-03-02 23:22:19 +03:00
|
|
|
{
|
2006-06-15 07:23:56 +04:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None) {
|
|
|
|
if (aAttribute == nsGkAtoms::width ||
|
|
|
|
aAttribute == nsGkAtoms::height) {
|
2014-11-06 12:30:11 +03:00
|
|
|
nsLayoutUtils::PostRestyleEvent(
|
|
|
|
mContent->AsElement(), nsRestyleHint(0),
|
|
|
|
nsChangeHint_InvalidateRenderingObservers);
|
2012-11-28 13:42:13 +04:00
|
|
|
nsSVGUtils::ScheduleReflowSVG(this);
|
2007-11-20 12:10:18 +03:00
|
|
|
// XXXjwatt: why mark intrinsic widths dirty? can't we just use eResize?
|
2007-05-05 15:11:07 +04:00
|
|
|
RequestReflow(nsIPresShell::eStyleChange);
|
2006-06-15 07:23:56 +04:00
|
|
|
} else if (aAttribute == nsGkAtoms::x ||
|
2013-04-25 13:18:42 +04:00
|
|
|
aAttribute == nsGkAtoms::y) {
|
|
|
|
// make sure our cached transform matrix gets (lazily) updated
|
|
|
|
mCanvasTM = nullptr;
|
2014-11-06 12:30:11 +03:00
|
|
|
nsLayoutUtils::PostRestyleEvent(
|
|
|
|
mContent->AsElement(), nsRestyleHint(0),
|
|
|
|
nsChangeHint_InvalidateRenderingObservers);
|
2013-04-25 13:18:42 +04:00
|
|
|
nsSVGUtils::ScheduleReflowSVG(this);
|
|
|
|
} else if (aAttribute == nsGkAtoms::transform) {
|
2013-05-23 11:04:21 +04:00
|
|
|
// We don't invalidate for transform changes (the layers code does that).
|
|
|
|
// Also note that SVGTransformableElement::GetAttributeChangeHint will
|
|
|
|
// return nsChangeHint_UpdateOverflow for "transform" attribute changes
|
|
|
|
// and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
|
2012-07-30 18:20:58 +04:00
|
|
|
mCanvasTM = nullptr;
|
2012-03-20 16:15:53 +04:00
|
|
|
} else if (aAttribute == nsGkAtoms::viewBox ||
|
|
|
|
aAttribute == nsGkAtoms::preserveAspectRatio) {
|
2014-11-06 12:30:11 +03:00
|
|
|
nsLayoutUtils::PostRestyleEvent(
|
|
|
|
mContent->AsElement(), nsRestyleHint(0),
|
|
|
|
nsChangeHint_InvalidateRenderingObservers);
|
2006-06-15 07:23:56 +04:00
|
|
|
}
|
|
|
|
}
|
2006-03-02 23:22:19 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2007-01-26 09:58:31 +03:00
|
|
|
nsSVGForeignObjectFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2007-01-26 09:58:31 +03:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!(GetStateBits() & NS_FRAME_IS_NONDISPLAY),
|
|
|
|
"Should not have been called");
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
// Only InvalidateAndScheduleBoundsUpdate marks us with NS_FRAME_IS_DIRTY,
|
|
|
|
// so if that bit is still set we still have a resize pending. If we hit
|
|
|
|
// this assertion, then we should get the presShell to skip reflow roots
|
|
|
|
// that have a dirty parent since a reflow is going to come via the
|
|
|
|
// reflow root's parent anyway.
|
|
|
|
NS_ASSERTION(!(GetStateBits() & NS_FRAME_IS_DIRTY),
|
|
|
|
"Reflowing while a resize is pending is wasteful");
|
|
|
|
|
2012-07-22 04:01:44 +04:00
|
|
|
// ReflowSVG makes sure mRect is up to date before we're called.
|
2007-06-22 03:01:10 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(!aReflowInput.mParentReflowInput,
|
2007-01-26 09:58:31 +03:00
|
|
|
"should only get reflow from being reflow root");
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(aReflowInput.ComputedWidth() == GetSize().width &&
|
|
|
|
aReflowInput.ComputedHeight() == GetSize().height,
|
2009-07-27 12:47:02 +04:00
|
|
|
"reflow roots should be reflowed at existing size and "
|
2007-01-26 09:58:31 +03:00
|
|
|
"svg.css should ensure we have no padding/border/margin");
|
|
|
|
|
|
|
|
DoReflow();
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
|
|
|
LogicalSize finalSize(wm, aReflowInput.ComputedISize(),
|
|
|
|
aReflowInput.ComputedBSize());
|
2014-07-24 12:30:07 +04:00
|
|
|
aDesiredSize.SetSize(wm, finalSize);
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2017-02-14 12:55:48 +03:00
|
|
|
aStatus.Reset();
|
2007-01-26 09:58:31 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2012-07-20 22:12:29 +04:00
|
|
|
nsSVGForeignObjectFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!static_cast<const nsSVGElement*>(mContent)->HasValidDimensions()) {
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2012-07-20 22:12:29 +04:00
|
|
|
}
|
2016-05-24 07:23:22 +03:00
|
|
|
DisplayOutline(aBuilder, aLists);
|
2013-02-14 15:08:08 +04:00
|
|
|
BuildDisplayListForNonBlockChildren(aBuilder, aDirtyRect, aLists);
|
2012-07-20 22:12:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-12-30 10:50:17 +04:00
|
|
|
nsSVGForeignObjectFrame::IsSVGTransformed(Matrix *aOwnTransform,
|
|
|
|
Matrix *aFromParentTransform) const
|
2012-07-20 22:12:29 +04:00
|
|
|
{
|
|
|
|
bool foundTransform = false;
|
|
|
|
|
|
|
|
// Check if our parent has children-only transforms:
|
|
|
|
nsIFrame *parent = GetParent();
|
|
|
|
if (parent &&
|
|
|
|
parent->IsFrameOfType(nsIFrame::eSVG | nsIFrame::eSVGContainer)) {
|
|
|
|
foundTransform = static_cast<nsSVGContainerFrame*>(parent)->
|
|
|
|
HasChildrenOnlyTransform(aFromParentTransform);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement *content = static_cast<nsSVGElement*>(mContent);
|
2013-04-15 02:56:34 +04:00
|
|
|
nsSVGAnimatedTransformList* transformList =
|
2013-04-14 11:17:36 +04:00
|
|
|
content->GetAnimatedTransformList();
|
2013-04-18 00:28:59 +04:00
|
|
|
if ((transformList && transformList->HasTransform()) ||
|
|
|
|
content->GetAnimateMotionTransform()) {
|
2012-07-20 22:12:29 +04:00
|
|
|
if (aOwnTransform) {
|
2015-12-03 01:36:23 +03:00
|
|
|
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(
|
|
|
|
gfxMatrix(),
|
|
|
|
eUserSpaceToParent));
|
2012-07-20 22:12:29 +04:00
|
|
|
}
|
|
|
|
foundTransform = true;
|
|
|
|
}
|
|
|
|
return foundTransform;
|
|
|
|
}
|
|
|
|
|
2016-07-14 07:47:06 +03:00
|
|
|
DrawResult
|
2014-10-31 23:08:54 +03:00
|
|
|
nsSVGForeignObjectFrame::PaintSVG(gfxContext& aContext,
|
2014-08-29 23:42:07 +04:00
|
|
|
const gfxMatrix& aTransform,
|
|
|
|
const nsIntRect* aDirtyRect)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2012-07-20 22:12:29 +04:00
|
|
|
NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() ||
|
2013-07-12 11:13:07 +04:00
|
|
|
(mState & NS_FRAME_IS_NONDISPLAY),
|
2012-07-20 22:12:29 +04:00
|
|
|
"If display lists are enabled, only painting of non-display "
|
|
|
|
"SVG should take this code path");
|
|
|
|
|
2007-06-25 12:31:31 +04:00
|
|
|
if (IsDisabled())
|
2016-07-14 07:47:06 +03:00
|
|
|
return DrawResult::SUCCESS;
|
2007-06-25 12:31:31 +04:00
|
|
|
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* kid = PrincipalChildList().FirstChild();
|
2006-06-07 03:13:15 +04:00
|
|
|
if (!kid)
|
2016-07-14 07:47:06 +03:00
|
|
|
return DrawResult::SUCCESS;
|
2006-03-21 18:49:20 +03:00
|
|
|
|
2014-08-29 23:42:07 +04:00
|
|
|
if (aTransform.IsSingular()) {
|
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 15:39:26 +03:00
|
|
|
NS_WARNING("Can't render foreignObject element!");
|
2017-03-17 23:53:24 +03:00
|
|
|
return DrawResult::BAD_ARGS;
|
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 15:39:26 +03:00
|
|
|
}
|
2006-11-27 20:30:57 +03:00
|
|
|
|
2012-02-10 16:33:46 +04:00
|
|
|
nsRect kidDirtyRect = kid->GetVisualOverflowRect();
|
|
|
|
|
2008-12-06 18:22:01 +03:00
|
|
|
/* Check if we need to draw anything. */
|
2012-01-01 19:47:27 +04:00
|
|
|
if (aDirtyRect) {
|
2012-07-20 22:12:29 +04:00
|
|
|
NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() ||
|
2013-07-12 11:13:07 +04:00
|
|
|
(mState & NS_FRAME_IS_NONDISPLAY),
|
2012-07-20 22:12:29 +04:00
|
|
|
"Display lists handle dirty rect intersection test");
|
2012-02-10 16:33:46 +04:00
|
|
|
// Transform the dirty rect into app units in our userspace.
|
2014-08-29 23:42:07 +04:00
|
|
|
gfxMatrix invmatrix = aTransform;
|
2014-07-11 11:06:39 +04:00
|
|
|
DebugOnly<bool> ok = invmatrix.Invert();
|
|
|
|
NS_ASSERTION(ok, "inverse of non-singular matrix should be non-singular");
|
2012-02-10 16:33:46 +04:00
|
|
|
|
|
|
|
gfxRect transDirtyRect = gfxRect(aDirtyRect->x, aDirtyRect->y,
|
|
|
|
aDirtyRect->width, aDirtyRect->height);
|
|
|
|
transDirtyRect = invmatrix.TransformBounds(transDirtyRect);
|
|
|
|
|
|
|
|
kidDirtyRect.IntersectRect(kidDirtyRect,
|
|
|
|
nsLayoutUtils::RoundGfxRectToAppRect(transDirtyRect,
|
|
|
|
PresContext()->AppUnitsPerCSSPixel()));
|
|
|
|
|
|
|
|
// XXX after bug 614732 is fixed, we will compare mRect with aDirtyRect,
|
|
|
|
// not with kidDirtyRect. I.e.
|
2012-08-22 19:56:38 +04:00
|
|
|
// int32_t appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel();
|
2012-02-10 16:33:46 +04:00
|
|
|
// mRect.ToOutsidePixels(appUnitsPerDevPx).Intersects(*aDirtyRect)
|
|
|
|
if (kidDirtyRect.IsEmpty())
|
2016-07-14 07:47:06 +03:00
|
|
|
return DrawResult::SUCCESS;
|
2012-01-01 19:47:27 +04:00
|
|
|
}
|
2008-12-06 18:22:01 +03:00
|
|
|
|
2014-10-31 23:08:54 +03:00
|
|
|
aContext.Save();
|
2007-04-30 13:02:38 +04:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
if (StyleDisplay()->IsScrollableOverflow()) {
|
2007-05-23 12:39:00 +04:00
|
|
|
float x, y, width, height;
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsSVGElement*>(mContent)->
|
2012-07-30 18:20:58 +04:00
|
|
|
GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
|
2007-04-30 13:02:38 +04:00
|
|
|
|
2009-06-18 00:51:40 +04:00
|
|
|
gfxRect clipRect =
|
2009-06-18 15:31:25 +04:00
|
|
|
nsSVGUtils::GetClipRectForFrame(this, 0.0f, 0.0f, width, height);
|
2014-10-31 23:08:54 +03:00
|
|
|
nsSVGUtils::SetClipRect(&aContext, aTransform, clipRect);
|
2007-04-30 13:02:38 +04:00
|
|
|
}
|
|
|
|
|
2012-06-30 15:20:46 +04:00
|
|
|
// SVG paints in CSS px, but normally frames paint in dev pixels. Here we
|
2014-08-29 23:42:07 +04:00
|
|
|
// multiply a CSS-px-to-dev-pixel factor onto aTransform so our children
|
|
|
|
// paint correctly.
|
2012-06-30 15:20:46 +04:00
|
|
|
float cssPxPerDevPx = PresContext()->
|
|
|
|
AppUnitsToFloatCSSPixels(PresContext()->AppUnitsPerDevPixel());
|
2014-08-29 23:42:07 +04:00
|
|
|
gfxMatrix canvasTMForChildren = aTransform;
|
2012-06-30 15:20:46 +04:00
|
|
|
canvasTMForChildren.Scale(cssPxPerDevPx, cssPxPerDevPx);
|
|
|
|
|
2014-10-31 23:08:54 +03:00
|
|
|
aContext.Multiply(canvasTMForChildren);
|
2006-11-27 20:30:57 +03:00
|
|
|
|
2016-04-27 07:01:54 +03:00
|
|
|
using PaintFrameFlags = nsLayoutUtils::PaintFrameFlags;
|
|
|
|
PaintFrameFlags flags = PaintFrameFlags::PAINT_IN_TRANSFORM;
|
2014-10-31 23:08:54 +03:00
|
|
|
if (SVGAutoRenderState::IsPaintingToWindow(aContext.GetDrawTarget())) {
|
2016-04-27 07:01:54 +03:00
|
|
|
flags |= PaintFrameFlags::PAINT_TO_WINDOW;
|
2010-10-15 05:03:45 +04:00
|
|
|
}
|
2014-10-31 23:08:54 +03:00
|
|
|
nsRenderingContext rendCtx(&aContext);
|
|
|
|
nsresult rv = nsLayoutUtils::PaintFrame(&rendCtx, kid, nsRegion(kidDirtyRect),
|
2016-07-14 07:47:06 +03:00
|
|
|
NS_RGBA(0,0,0,0),
|
|
|
|
nsDisplayListBuilderMode::PAINTING,
|
|
|
|
flags);
|
2016-07-13 09:37:24 +03:00
|
|
|
|
2014-10-31 23:08:54 +03:00
|
|
|
aContext.Restore();
|
2006-11-27 20:30:57 +03:00
|
|
|
|
2016-07-14 07:47:06 +03:00
|
|
|
return NS_FAILED(rv) ? DrawResult::BAD_ARGS : DrawResult::SUCCESS;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2014-02-20 02:34:31 +04:00
|
|
|
nsIFrame*
|
2014-08-07 11:09:31 +04:00
|
|
|
nsSVGForeignObjectFrame::GetFrameForPoint(const gfxPoint& aPoint)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2012-07-20 22:12:29 +04:00
|
|
|
NS_ASSERTION(!NS_SVGDisplayListHitTestingEnabled() ||
|
2013-07-12 11:13:07 +04:00
|
|
|
(mState & NS_FRAME_IS_NONDISPLAY),
|
2012-07-20 22:12:29 +04:00
|
|
|
"If display lists are enabled, only hit-testing of a "
|
|
|
|
"clipPath's contents should take this code path");
|
|
|
|
|
2013-07-12 11:13:07 +04:00
|
|
|
if (IsDisabled() || (GetStateBits() & NS_FRAME_IS_NONDISPLAY))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2007-06-25 12:31:31 +04:00
|
|
|
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* kid = PrincipalChildList().FirstChild();
|
2009-06-18 15:31:25 +04:00
|
|
|
if (!kid)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-06-18 15:31:25 +04:00
|
|
|
|
|
|
|
float x, y, width, height;
|
|
|
|
static_cast<nsSVGElement*>(mContent)->
|
2012-07-30 18:20:58 +04:00
|
|
|
GetAnimatedLengthValues(&x, &y, &width, &height, nullptr);
|
2009-06-18 15:31:25 +04:00
|
|
|
|
2014-08-07 11:09:31 +04:00
|
|
|
if (!gfxRect(x, y, width, height).Contains(aPoint) ||
|
|
|
|
!nsSVGUtils::HitTestClip(this, aPoint)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2014-07-11 11:06:39 +04:00
|
|
|
}
|
|
|
|
|
2014-08-07 11:09:31 +04:00
|
|
|
// Convert the point to app units relative to the top-left corner of the
|
|
|
|
// viewport that's established by the foreignObject element:
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2014-08-07 11:09:31 +04:00
|
|
|
gfxPoint pt = (aPoint + gfxPoint(x, y)) * nsPresContext::AppUnitsPerCSSPixel();
|
2009-06-18 15:31:25 +04:00
|
|
|
nsPoint point = nsPoint(NSToIntRound(pt.x), NSToIntRound(pt.y));
|
|
|
|
|
2014-08-07 11:09:31 +04:00
|
|
|
return nsLayoutUtils::GetFrameForPoint(kid, point);
|
2006-02-21 03:33:27 +03:00
|
|
|
}
|
|
|
|
|
2014-02-20 02:34:31 +04:00
|
|
|
nsRect
|
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 15:39:26 +03:00
|
|
|
nsSVGForeignObjectFrame::GetCoveredRegion()
|
|
|
|
{
|
2012-07-23 15:00:40 +04:00
|
|
|
float x, y, w, h;
|
2013-01-06 10:25:55 +04:00
|
|
|
static_cast<SVGForeignObjectElement*>(mContent)->
|
2012-07-30 18:20:58 +04:00
|
|
|
GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
2012-07-23 15:00:40 +04:00
|
|
|
if (w < 0.0f) w = 0.0f;
|
|
|
|
if (h < 0.0f) h = 0.0f;
|
|
|
|
// GetCanvasTM includes the x,y translation
|
2013-02-11 10:22:18 +04:00
|
|
|
return nsSVGUtils::ToCanvasBounds(gfxRect(0.0, 0.0, w, h),
|
2014-09-08 15:28:50 +04:00
|
|
|
GetCanvasTM(),
|
2013-02-11 10:22:18 +04:00
|
|
|
PresContext());
|
2006-06-09 22:08:33 +04:00
|
|
|
}
|
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
void
|
2012-07-22 04:01:44 +04:00
|
|
|
nsSVGForeignObjectFrame::ReflowSVG()
|
2006-06-09 22:08:33 +04:00
|
|
|
{
|
2012-07-22 04:01:44 +04:00
|
|
|
NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this),
|
|
|
|
"This call is probably a wasteful mistake");
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!(GetStateBits() & NS_FRAME_IS_NONDISPLAY),
|
|
|
|
"ReflowSVG mechanism not designed for this");
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2012-07-22 04:01:44 +04:00
|
|
|
if (!nsSVGUtils::NeedsReflowSVG(this)) {
|
2012-03-20 16:15:53 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We update mRect before the DoReflow call so that DoReflow uses the
|
|
|
|
// correct dimensions:
|
2007-01-16 14:12:08 +03:00
|
|
|
|
2007-06-22 03:01:10 +04:00
|
|
|
float x, y, w, h;
|
2013-01-06 10:25:55 +04:00
|
|
|
static_cast<SVGForeignObjectElement*>(mContent)->
|
2012-07-30 18:20:58 +04:00
|
|
|
GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
2006-06-09 22:08:33 +04:00
|
|
|
|
2007-06-25 12:31:31 +04:00
|
|
|
// If mRect's width or height are negative, reflow blows up! We must clamp!
|
|
|
|
if (w < 0.0f) w = 0.0f;
|
|
|
|
if (h < 0.0f) h = 0.0f;
|
|
|
|
|
2012-02-10 16:33:46 +04:00
|
|
|
mRect = nsLayoutUtils::RoundGfxRectToAppRect(
|
2012-05-16 14:04:31 +04:00
|
|
|
gfxRect(x, y, w, h),
|
2012-02-17 10:07:51 +04:00
|
|
|
PresContext()->AppUnitsPerCSSPixel());
|
2012-02-10 16:33:46 +04:00
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
// Fully mark our kid dirty so that it gets resized if necessary
|
|
|
|
// (NS_FRAME_HAS_DIRTY_CHILDREN isn't enough in that case):
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* kid = PrincipalChildList().FirstChild();
|
2012-03-20 16:15:53 +04:00
|
|
|
kid->AddStateBits(NS_FRAME_IS_DIRTY);
|
2009-04-22 03:53:52 +04:00
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
// Make sure to not allow interrupts if we're not being reflown as a root:
|
2009-04-22 03:53:52 +04:00
|
|
|
nsPresContext::InterruptPreventer noInterrupts(PresContext());
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2006-06-15 07:23:56 +04:00
|
|
|
DoReflow();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2012-05-17 08:05:09 +04:00
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
// Make sure we have our filter property (if any) before calling
|
|
|
|
// FinishAndStoreOverflow (subsequent filter changes are handled off
|
|
|
|
// nsChangeHint_UpdateEffects):
|
|
|
|
nsSVGEffects::UpdateEffects(this);
|
|
|
|
}
|
|
|
|
|
Bug 997735 - Invalidate when reflowing SVG containers. r=roc
Without this patch, when changing the x/y attributes of svg:use, innerSVG and foreignObject, we were relying on the transform changes of the children to trigger the right invalidations. However, changes to those attributes can also change the filter region. And there's a difference between moving children in a fixed filter region and moving the filter region along with the children: In the first case, we wouldn't need to invalidate anything outside the old filter region, because those parts of the children would be clipped away anyway. But when the filter region changes, we need to invalidate both the old and the new filter region. Also, when the filter has primitives without inputs, e.g. flood or turbulence, the filtered frame needs to be invalidate even if it has no children.
2014-04-23 13:48:07 +04:00
|
|
|
// If we have a filter, we need to invalidate ourselves because filter
|
|
|
|
// output can change even if none of our descendants need repainting.
|
2016-04-12 08:52:43 +03:00
|
|
|
if (StyleEffects()->HasFilters()) {
|
Bug 997735 - Invalidate when reflowing SVG containers. r=roc
Without this patch, when changing the x/y attributes of svg:use, innerSVG and foreignObject, we were relying on the transform changes of the children to trigger the right invalidations. However, changes to those attributes can also change the filter region. And there's a difference between moving children in a fixed filter region and moving the filter region along with the children: In the first case, we wouldn't need to invalidate anything outside the old filter region, because those parts of the children would be clipped away anyway. But when the filter region changes, we need to invalidate both the old and the new filter region. Also, when the filter has primitives without inputs, e.g. flood or turbulence, the filtered frame needs to be invalidate even if it has no children.
2014-04-23 13:48:07 +04:00
|
|
|
InvalidateFrame();
|
|
|
|
}
|
|
|
|
|
2012-05-17 08:05:09 +04:00
|
|
|
// TODO: once we support |overflow:visible| on foreignObject, then we will
|
|
|
|
// need to take account of our descendants here.
|
|
|
|
nsRect overflow = nsRect(nsPoint(0,0), mRect.Size());
|
|
|
|
nsOverflowAreas overflowAreas(overflow, overflow);
|
|
|
|
FinishAndStoreOverflow(overflowAreas, mRect.Size());
|
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
// Now unset the various reflow bits:
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
mState &= ~(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2008-01-25 12:27:03 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGForeignObjectFrame::NotifySVGChanged(uint32_t aFlags)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
2012-03-11 19:53:36 +04:00
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
bool needNewBounds = false; // i.e. mRect or visual overflow rect
|
|
|
|
bool needReflow = false;
|
|
|
|
bool needNewCanvasTM = false;
|
2008-01-25 12:27:03 +03:00
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
if (aFlags & COORD_CONTEXT_CHANGED) {
|
2013-01-06 10:25:55 +04:00
|
|
|
SVGForeignObjectElement *fO =
|
|
|
|
static_cast<SVGForeignObjectElement*>(mContent);
|
2012-02-01 20:25:44 +04:00
|
|
|
// Coordinate context changes affect mCanvasTM if we have a
|
|
|
|
// percentage 'x' or 'y'
|
2013-01-06 10:25:55 +04:00
|
|
|
if (fO->mLengthAttributes[SVGForeignObjectElement::ATTR_X].IsPercentage() ||
|
|
|
|
fO->mLengthAttributes[SVGForeignObjectElement::ATTR_Y].IsPercentage()) {
|
2012-03-20 16:15:53 +04:00
|
|
|
needNewBounds = true;
|
|
|
|
needNewCanvasTM = true;
|
2012-02-01 20:25:44 +04:00
|
|
|
}
|
|
|
|
// Our coordinate context's width/height has changed. If we have a
|
|
|
|
// percentage width/height our dimensions will change so we must reflow.
|
2013-01-06 10:25:55 +04:00
|
|
|
if (fO->mLengthAttributes[SVGForeignObjectElement::ATTR_WIDTH].IsPercentage() ||
|
|
|
|
fO->mLengthAttributes[SVGForeignObjectElement::ATTR_HEIGHT].IsPercentage()) {
|
2012-03-20 16:15:53 +04:00
|
|
|
needNewBounds = true;
|
|
|
|
needReflow = true;
|
2008-01-25 12:27:03 +03:00
|
|
|
}
|
2007-11-20 12:10:18 +03:00
|
|
|
}
|
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
if (aFlags & TRANSFORM_CHANGED) {
|
2012-06-23 20:36:46 +04:00
|
|
|
if (mCanvasTM && mCanvasTM->IsSingular()) {
|
|
|
|
needNewBounds = true; // old bounds are bogus
|
|
|
|
}
|
2012-03-20 16:15:53 +04:00
|
|
|
needNewCanvasTM = true;
|
|
|
|
// In an ideal world we would reflow when our CTM changes. This is because
|
|
|
|
// glyph metrics do not necessarily scale uniformly with change in scale
|
|
|
|
// and, as a result, CTM changes may require text to break at different
|
|
|
|
// points. The problem would be how to keep performance acceptable when
|
|
|
|
// e.g. the transform of an ancestor is animated.
|
|
|
|
// We also seem to get some sort of infinite loop post bug 421584 if we
|
|
|
|
// reflow.
|
|
|
|
}
|
|
|
|
|
2012-06-23 20:36:46 +04:00
|
|
|
if (needNewBounds) {
|
|
|
|
// Ancestor changes can't affect how we render from the perspective of
|
|
|
|
// any rendering observers that we may have, so we don't need to
|
|
|
|
// invalidate them. We also don't need to invalidate ourself, since our
|
|
|
|
// changed ancestor will have invalidated its entire area, which includes
|
|
|
|
// our area.
|
2012-07-22 04:01:44 +04:00
|
|
|
nsSVGUtils::ScheduleReflowSVG(this);
|
2012-03-20 16:15:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we're called while the PresShell is handling reflow events then we
|
|
|
|
// must have been called as a result of the NotifyViewportChange() call in
|
|
|
|
// our nsSVGOuterSVGFrame's Reflow() method. We must not call RequestReflow
|
|
|
|
// at this point (i.e. during reflow) because it could confuse the
|
|
|
|
// PresShell and prevent it from reflowing us properly in future. Besides
|
|
|
|
// that, nsSVGOuterSVGFrame::DidReflow will take care of reflowing us
|
|
|
|
// synchronously, so there's no need.
|
|
|
|
if (needReflow && !PresContext()->PresShell()->IsReflowLocked()) {
|
|
|
|
RequestReflow(nsIPresShell::eResize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needNewCanvasTM) {
|
|
|
|
// Do this after calling InvalidateAndScheduleBoundsUpdate in case we
|
|
|
|
// change the code and it needs to use it.
|
2012-07-30 18:20:58 +04:00
|
|
|
mCanvasTM = nullptr;
|
2008-01-25 12:27:03 +03:00
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2012-04-16 12:23:48 +04:00
|
|
|
SVGBBox
|
2013-12-30 10:50:07 +04:00
|
|
|
nsSVGForeignObjectFrame::GetBBoxContribution(const Matrix &aToBBoxUserspace,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags)
|
2006-02-21 03:33:27 +03:00
|
|
|
{
|
2013-01-06 10:25:55 +04:00
|
|
|
SVGForeignObjectElement *content =
|
|
|
|
static_cast<SVGForeignObjectElement*>(mContent);
|
2007-01-16 14:12:08 +03:00
|
|
|
|
2006-02-21 03:33:27 +03:00
|
|
|
float x, y, w, h;
|
2012-07-30 18:20:58 +04:00
|
|
|
content->GetAnimatedLengthValues(&x, &y, &w, &h, nullptr);
|
2007-06-22 03:01:10 +04:00
|
|
|
|
2007-06-25 12:31:31 +04:00
|
|
|
if (w < 0.0f) w = 0.0f;
|
|
|
|
if (h < 0.0f) h = 0.0f;
|
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
if (aToBBoxUserspace.IsSingular()) {
|
|
|
|
// XXX ReportToConsole
|
2012-04-16 12:23:48 +04:00
|
|
|
return SVGBBox();
|
2009-04-29 08:31:34 +04:00
|
|
|
}
|
2013-12-30 10:50:07 +04:00
|
|
|
return aToBBoxUserspace.TransformBounds(gfx::Rect(0.0, 0.0, w, h));
|
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 15:39:26 +03:00
|
|
|
}
|
2001-12-12 10:59:31 +03: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 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2009-04-29 08:31:34 +04:00
|
|
|
gfxMatrix
|
2014-09-08 15:28:50 +04:00
|
|
|
nsSVGForeignObjectFrame::GetCanvasTM()
|
2004-08-05 13:01:13 +04:00
|
|
|
{
|
|
|
|
if (!mCanvasTM) {
|
2014-05-25 02:20:41 +04:00
|
|
|
NS_ASSERTION(GetParent(), "null parent");
|
2004-08-05 13:01:13 +04:00
|
|
|
|
2014-05-25 02:20:41 +04:00
|
|
|
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(GetParent());
|
2013-01-06 10:25:55 +04:00
|
|
|
SVGForeignObjectElement *content =
|
|
|
|
static_cast<SVGForeignObjectElement*>(mContent);
|
2009-04-29 08:31:34 +04:00
|
|
|
|
2014-09-08 15:28:50 +04:00
|
|
|
gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM());
|
2009-04-29 08:31:34 +04:00
|
|
|
|
2013-12-27 00:13:57 +04:00
|
|
|
mCanvasTM = new gfxMatrix(tm);
|
2009-04-29 08:31:34 +04:00
|
|
|
}
|
2011-09-26 01:04:32 +04:00
|
|
|
return *mCanvasTM;
|
2004-08-05 13:01:13 +04:00
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation helpers
|
|
|
|
|
2007-05-05 15:11:07 +04:00
|
|
|
void nsSVGForeignObjectFrame::RequestReflow(nsIPresShell::IntrinsicDirty aType)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2007-05-05 15:11:07 +04:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW)
|
2012-07-22 04:01:44 +04:00
|
|
|
// If we haven't had a ReflowSVG() yet, nothing to do.
|
2007-05-05 15:11:07 +04:00
|
|
|
return;
|
|
|
|
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* kid = PrincipalChildList().FirstChild();
|
2006-06-15 07:23:56 +04:00
|
|
|
if (!kid)
|
|
|
|
return;
|
2007-05-05 15:11:07 +04:00
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(kid, aType, NS_FRAME_IS_DIRTY);
|
2006-06-15 07:23:56 +04: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 15:39:26 +03:00
|
|
|
|
2006-06-09 22:08:33 +04:00
|
|
|
void
|
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 15:39:26 +03:00
|
|
|
nsSVGForeignObjectFrame::DoReflow()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
2011-02-18 03:33:30 +03:00
|
|
|
// Skip reflow if we're zero-sized, unless this is our first reflow.
|
|
|
|
if (IsDisabled() &&
|
|
|
|
!(GetStateBits() & NS_FRAME_FIRST_REFLOW))
|
2007-06-25 12:31:31 +04:00
|
|
|
return;
|
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext *presContext = PresContext();
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* kid = PrincipalChildList().FirstChild();
|
2006-06-07 03:13:15 +04:00
|
|
|
if (!kid)
|
2006-06-09 22:08:33 +04:00
|
|
|
return;
|
2001-12-12 10:59:31 +03:00
|
|
|
|
|
|
|
// initiate a synchronous reflow here and now:
|
2014-10-31 23:08:49 +03:00
|
|
|
nsRenderingContext renderingContext(
|
|
|
|
presContext->PresShell()->CreateReferenceRenderingContext());
|
2007-02-07 10:46:44 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mInReflow = true;
|
2006-06-15 07:23:56 +04:00
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = kid->GetWritingMode();
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput reflowInput(presContext, kid,
|
2014-10-31 23:08:49 +03:00
|
|
|
&renderingContext,
|
2015-04-01 18:50:11 +03:00
|
|
|
LogicalSize(wm, ISize(wm),
|
2014-07-24 12:28:46 +04:00
|
|
|
NS_UNCONSTRAINEDSIZE));
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOutput desiredSize(reflowInput);
|
2001-12-12 10:59:31 +03:00
|
|
|
nsReflowStatus status;
|
2007-01-25 05:01:07 +03:00
|
|
|
|
2012-03-20 16:15:53 +04:00
|
|
|
// We don't use mRect.height above because that tells the child to do
|
2007-01-25 05:01:07 +03:00
|
|
|
// page/column breaking at that height.
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(reflowInput.ComputedPhysicalBorderPadding() == nsMargin(0, 0, 0, 0) &&
|
|
|
|
reflowInput.ComputedPhysicalMargin() == nsMargin(0, 0, 0, 0),
|
2012-02-07 03:52:01 +04:00
|
|
|
"style system should ensure that :-moz-svg-foreign-content "
|
2007-01-25 05:01:07 +03:00
|
|
|
"does not get styled");
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(reflowInput.ComputedISize() == ISize(wm),
|
2007-01-25 05:01:07 +03:00
|
|
|
"reflow state made child wrong size");
|
2016-07-21 13:36:39 +03:00
|
|
|
reflowInput.SetComputedBSize(BSize(wm));
|
2012-03-20 16:15:53 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowChild(kid, presContext, desiredSize, reflowInput, 0, 0,
|
2006-06-07 03:13:15 +04:00
|
|
|
NS_FRAME_NO_MOVE_FRAME, status);
|
2013-12-27 21:59:52 +04:00
|
|
|
NS_ASSERTION(mRect.width == desiredSize.Width() &&
|
|
|
|
mRect.height == desiredSize.Height(), "unexpected size");
|
2016-07-21 13:36:39 +03:00
|
|
|
FinishReflowChild(kid, presContext, desiredSize, &reflowInput, 0, 0,
|
2006-06-07 03:13:15 +04:00
|
|
|
NS_FRAME_NO_MOVE_FRAME);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mInReflow = false;
|
2006-06-15 07:23:56 +04:00
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2012-08-29 09:39:33 +04:00
|
|
|
nsRect
|
|
|
|
nsSVGForeignObjectFrame::GetInvalidRegion()
|
|
|
|
{
|
2014-08-13 16:36:41 +04:00
|
|
|
MOZ_ASSERT(!NS_SVGDisplayListPaintingEnabled(),
|
|
|
|
"Only called by nsDisplayOuterSVG code");
|
|
|
|
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* kid = PrincipalChildList().FirstChild();
|
2012-08-29 09:39:33 +04:00
|
|
|
if (kid->HasInvalidFrameInSubtree()) {
|
|
|
|
gfxRect r(mRect.x, mRect.y, mRect.width, mRect.height);
|
|
|
|
r.Scale(1.0 / nsPresContext::AppUnitsPerCSSPixel());
|
2014-09-08 15:28:50 +04:00
|
|
|
nsRect rect = nsSVGUtils::ToCanvasBounds(r, GetCanvasTM(), PresContext());
|
2012-08-29 09:39:33 +04:00
|
|
|
rect = nsSVGUtils::GetPostFilterVisualOverflowRect(this, rect);
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
return nsRect();
|
|
|
|
}
|
|
|
|
|
2017-03-15 21:00:43 +03:00
|
|
|
void
|
|
|
|
nsSVGForeignObjectFrame::DoUpdateStyleOfOwnedAnonBoxes(
|
|
|
|
ServoStyleSet& aStyleSet,
|
|
|
|
nsStyleChangeList& aChangeList,
|
|
|
|
nsChangeHint aHintForThisFrame)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(PrincipalChildList().FirstChild(), "Must have our anon box");
|
|
|
|
UpdateStyleOfChildAnonBox(PrincipalChildList().FirstChild(),
|
|
|
|
aStyleSet, aChangeList, aHintForThisFrame);
|
|
|
|
}
|