2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-26 04:58:59 -07:00
|
|
|
// Main header first:
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-03-26 04:58:59 -07:00
|
|
|
|
|
|
|
// Keep others in (case-insensitive) order:
|
2013-04-24 02:13:28 -07:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2012-05-16 21:05:09 -07:00
|
|
|
#include "nsSVGEffects.h"
|
2012-03-18 03:32:02 -07:00
|
|
|
#include "nsSVGElement.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsSVGUtils.h"
|
2013-04-14 15:56:34 -07:00
|
|
|
#include "nsSVGAnimatedTransformList.h"
|
2013-12-20 08:38:51 -08:00
|
|
|
#include "SVGTextFrame.h"
|
2013-08-19 15:55:18 -07:00
|
|
|
#include "RestyleManager.h"
|
2012-05-16 21:05:09 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-28 21:31:34 -07:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGContainerFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsSVGContainerFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGContainerFrameBase)
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGDisplayContainerFrame)
|
2009-04-24 16:17:43 -07:00
|
|
|
NS_QUERYFRAME_ENTRY(nsSVGDisplayContainerFrame)
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_ENTRY(nsISVGChildFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGContainerFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
2012-03-10 11:28:06 -08:00
|
|
|
nsIFrame *frame = new (aPresShell) nsSVGContainerFrame(aContext);
|
|
|
|
// If we were called directly, then the frame is for a <defs> or
|
|
|
|
// an unknown element type. In both cases we prevent the content
|
|
|
|
// from displaying directly.
|
2013-07-12 00:13:07 -07:00
|
|
|
frame->AddStateBits(NS_FRAME_IS_NONDISPLAY);
|
2012-03-10 11:28:06 -08:00
|
|
|
return frame;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGContainerFrame)
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGDisplayContainerFrame)
|
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsSVGContainerFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-05-28 12:36:58 -07:00
|
|
|
InsertFrames(aListID, mFrames.LastChild(), aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsSVGContainerFrame::InsertFrames(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
|
|
|
}
|
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsSVGContainerFrame::RemoveFrame(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-18 04:09:36 -07:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
bool
|
|
|
|
nsSVGContainerFrame::UpdateOverflow()
|
|
|
|
{
|
2013-07-12 00:13:07 -07:00
|
|
|
if (mState & NS_FRAME_IS_NONDISPLAY) {
|
2012-05-16 21:05:09 -07:00
|
|
|
// We don't maintain overflow rects.
|
|
|
|
// XXX It would have be better if the restyle request hadn't even happened.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return nsSVGContainerFrameBase::UpdateOverflow();
|
|
|
|
}
|
|
|
|
|
2013-07-29 16:47:30 -07:00
|
|
|
/**
|
2013-12-20 08:38:51 -08:00
|
|
|
* Traverses a frame tree, marking any SVGTextFrame frames as dirty
|
2013-07-29 16:47:30 -07:00
|
|
|
* and calling InvalidateRenderingObservers() on it.
|
|
|
|
*
|
2013-12-20 08:38:51 -08:00
|
|
|
* The reason that this helper exists is because SVGTextFrame is special.
|
2013-07-29 16:47:30 -07:00
|
|
|
* None of the other SVG frames ever need to be reflowed when they have the
|
|
|
|
* NS_FRAME_IS_NONDISPLAY bit set on them because their PaintSVG methods
|
|
|
|
* (and those of any containers that they can validly be contained within) do
|
|
|
|
* not make use of mRect or overflow rects. "em" lengths, etc., are resolved
|
|
|
|
* as those elements are painted.
|
|
|
|
*
|
2013-12-20 08:38:51 -08:00
|
|
|
* SVGTextFrame is different because its anonymous block and inline frames
|
2013-07-29 16:47:30 -07:00
|
|
|
* need to be reflowed in order to get the correct metrics when things like
|
|
|
|
* inherited font-size of an ancestor changes, or a delayed webfont loads and
|
|
|
|
* applies.
|
|
|
|
*
|
|
|
|
* We assume that any change that requires the anonymous kid of an
|
2013-12-20 08:38:51 -08:00
|
|
|
* SVGTextFrame to reflow will result in an NS_FRAME_IS_DIRTY reflow. When
|
2013-07-29 16:47:30 -07:00
|
|
|
* that reflow reaches an NS_FRAME_IS_NONDISPLAY frame it would normally
|
2013-12-20 08:38:51 -08:00
|
|
|
* stop, but this helper looks for any SVGTextFrame descendants of such
|
2013-07-29 16:47:30 -07:00
|
|
|
* frames and marks them NS_FRAME_IS_DIRTY so that the next time that they are
|
|
|
|
* painted their anonymous kid will first get the necessary reflow.
|
|
|
|
*/
|
|
|
|
/* static */ void
|
|
|
|
nsSVGContainerFrame::ReflowSVGNonDisplayText(nsIFrame* aContainer)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aContainer->GetStateBits() & NS_FRAME_IS_DIRTY,
|
|
|
|
"expected aContainer to be NS_FRAME_IS_DIRTY");
|
|
|
|
NS_ASSERTION((aContainer->GetStateBits() & NS_FRAME_IS_NONDISPLAY) ||
|
|
|
|
!aContainer->IsFrameOfType(nsIFrame::eSVG),
|
|
|
|
"it is wasteful to call ReflowSVGNonDisplayText on a container "
|
|
|
|
"frame that is not NS_FRAME_IS_NONDISPLAY");
|
|
|
|
for (nsIFrame* kid = aContainer->GetFirstPrincipalChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
|
|
|
nsIAtom* type = kid->GetType();
|
2013-12-20 08:38:51 -08:00
|
|
|
if (type == nsGkAtoms::svgTextFrame) {
|
|
|
|
static_cast<SVGTextFrame*>(kid)->ReflowSVGNonDisplayText();
|
2013-07-29 16:47:30 -07:00
|
|
|
} else {
|
|
|
|
if (kid->IsFrameOfType(nsIFrame::eSVG | nsIFrame::eSVGContainer) ||
|
|
|
|
type == nsGkAtoms::svgForeignObjectFrame ||
|
|
|
|
!kid->IsFrameOfType(nsIFrame::eSVG)) {
|
|
|
|
ReflowSVGNonDisplayText(kid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
void
|
2014-05-24 15:20:40 -07:00
|
|
|
nsSVGDisplayContainerFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-06-22 08:59:48 -07:00
|
|
|
if (!(GetStateBits() & NS_STATE_IS_OUTER_SVG)) {
|
2013-07-12 00:13:07 -07:00
|
|
|
AddStateBits(aParent->GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD);
|
2008-06-22 08:59:48 -07:00
|
|
|
}
|
2013-03-19 18:47:48 -07:00
|
|
|
nsSVGContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2012-07-20 11:12:29 -07:00
|
|
|
nsSVGDisplayContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2014-02-19 12:46:43 -08:00
|
|
|
// mContent could be a XUL element so check for an SVG element before casting
|
2012-11-16 09:59:52 -08:00
|
|
|
if (mContent->IsSVG() &&
|
|
|
|
!static_cast<const nsSVGElement*>(mContent)->HasValidDimensions()) {
|
2013-02-14 03:12:27 -08:00
|
|
|
return;
|
2012-07-20 11:12:29 -07:00
|
|
|
}
|
|
|
|
return BuildDisplayListForNonBlockChildren(aBuilder, aDirtyRect, aLists);
|
|
|
|
}
|
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsSVGDisplayContainerFrame::InsertFrames(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-07-30 10:23:32 -07:00
|
|
|
// memorize first old frame after insertion point
|
|
|
|
// XXXbz once again, this would work a lot better if the nsIFrame
|
|
|
|
// methods returned framelist iterators....
|
2013-07-12 00:13:07 -07:00
|
|
|
nsIFrame* nextFrame = aPrevFrame ?
|
2011-08-24 13:54:30 -07:00
|
|
|
aPrevFrame->GetNextSibling() : GetChildList(aListID).FirstChild();
|
2009-07-30 10:23:32 -07:00
|
|
|
nsIFrame* firstNewFrame = aFrameList.FirstChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Insert the new frames
|
2011-08-24 13:54:30 -07:00
|
|
|
nsSVGContainerFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-20 05:15:53 -07:00
|
|
|
// If we are not a non-display SVG frame and we do not have a bounds update
|
|
|
|
// pending, then we need to schedule one for our new children:
|
|
|
|
if (!(GetStateBits() &
|
|
|
|
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN |
|
2013-07-12 00:13:07 -07:00
|
|
|
NS_FRAME_IS_NONDISPLAY))) {
|
2013-07-12 00:13:07 -07:00
|
|
|
for (nsIFrame* kid = firstNewFrame; kid != nextFrame;
|
2007-10-19 04:07:08 -07:00
|
|
|
kid = kid->GetNextSibling()) {
|
2009-01-12 11:20:59 -08:00
|
|
|
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
|
2007-10-19 04:07:08 -07:00
|
|
|
if (SVGFrame) {
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(!(kid->GetStateBits() & NS_FRAME_IS_NONDISPLAY),
|
|
|
|
"Check for this explicitly in the |if|, then");
|
2012-07-15 17:42:50 -07:00
|
|
|
bool isFirstReflow = (kid->GetStateBits() & NS_FRAME_FIRST_REFLOW);
|
2012-03-20 05:15:53 -07:00
|
|
|
// Remove bits so that ScheduleBoundsUpdate will work:
|
|
|
|
kid->RemoveStateBits(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
// No need to invalidate the new kid's old bounds, so we just use
|
|
|
|
// nsSVGUtils::ScheduleBoundsUpdate.
|
2012-07-21 17:01:44 -07:00
|
|
|
nsSVGUtils::ScheduleReflowSVG(kid);
|
2012-07-15 17:42:50 -07:00
|
|
|
if (isFirstReflow) {
|
|
|
|
// Add back the NS_FRAME_FIRST_REFLOW bit:
|
|
|
|
kid->AddStateBits(NS_FRAME_FIRST_REFLOW);
|
|
|
|
}
|
2007-10-19 04:07:08 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsSVGDisplayContainerFrame::RemoveFrame(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2013-04-24 02:13:28 -07:00
|
|
|
nsSVGEffects::InvalidateRenderingObservers(aOldFrame);
|
|
|
|
|
|
|
|
// nsSVGContainerFrame::RemoveFrame doesn't call down into
|
|
|
|
// nsContainerFrame::RemoveFrame, so it doesn't call FrameNeedsReflow. We
|
|
|
|
// need to schedule a repaint and schedule an update to our overflow rects.
|
|
|
|
SchedulePaint();
|
2013-07-20 12:14:25 -07:00
|
|
|
PresContext()->RestyleManager()->PostRestyleEvent(
|
2013-04-24 02:13:28 -07:00
|
|
|
mContent->AsElement(), nsRestyleHint(0), nsChangeHint_UpdateOverflow);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
nsSVGContainerFrame::RemoveFrame(aListID, aOldFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-12 00:13:07 -07:00
|
|
|
if (!(GetStateBits() & (NS_FRAME_IS_NONDISPLAY | NS_STATE_IS_OUTER_SVG))) {
|
2008-03-19 14:27:33 -07:00
|
|
|
nsSVGUtils::NotifyAncestorsOfFilterRegionChange(this);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
bool
|
2013-12-29 15:35:53 -08:00
|
|
|
nsSVGDisplayContainerFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
|
|
|
|
gfx::Matrix *aFromParentTransform) const
|
2012-05-16 21:05:09 -07: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);
|
|
|
|
}
|
|
|
|
|
2014-02-19 12:46:43 -08:00
|
|
|
// mContent could be a XUL element so check for an SVG element before casting
|
2012-11-16 09:59:52 -08:00
|
|
|
if (mContent->IsSVG()) {
|
|
|
|
nsSVGElement *content = static_cast<nsSVGElement*>(mContent);
|
2013-04-14 15:56:34 -07:00
|
|
|
nsSVGAnimatedTransformList* transformList =
|
2013-04-14 00:17:36 -07:00
|
|
|
content->GetAnimatedTransformList();
|
|
|
|
if ((transformList && transformList->HasTransform()) ||
|
2012-11-16 09:59:52 -08:00
|
|
|
content->GetAnimateMotionTransform()) {
|
|
|
|
if (aOwnTransform) {
|
2013-12-29 15:35:53 -08:00
|
|
|
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
|
|
|
|
nsSVGElement::eUserSpaceToParent));
|
2012-11-16 09:59:52 -08:00
|
|
|
}
|
|
|
|
foundTransform = true;
|
2012-05-16 21:05:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return foundTransform;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGChildFrame methods
|
|
|
|
|
2014-02-19 14:34:31 -08:00
|
|
|
nsresult
|
2014-10-31 13:08:54 -07:00
|
|
|
nsSVGDisplayContainerFrame::PaintSVG(gfxContext& aContext,
|
2014-08-29 12:42:07 -07:00
|
|
|
const gfxMatrix& aTransform,
|
|
|
|
const nsIntRect *aDirtyRect)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-20 11:12:29 -07:00
|
|
|
NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() ||
|
2013-07-12 00:13:07 -07:00
|
|
|
(mState & NS_FRAME_IS_NONDISPLAY) ||
|
2012-09-05 21:58:47 -07:00
|
|
|
PresContext()->IsGlyph(),
|
2012-07-20 11:12:29 -07:00
|
|
|
"If display lists are enabled, only painting of non-display "
|
|
|
|
"SVG should take this code path");
|
|
|
|
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleDisplay *display = StyleDisplay();
|
2014-08-29 12:42:07 -07:00
|
|
|
if (display->mOpacity == 0.0) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
2014-08-29 12:42:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxMatrix matrix = aTransform;
|
|
|
|
if (GetContent()->IsSVG()) { // must check before cast
|
|
|
|
matrix = static_cast<const nsSVGElement*>(GetContent())->
|
|
|
|
PrependLocalTransformsTo(matrix,
|
|
|
|
nsSVGElement::eChildToUserSpace);
|
|
|
|
if (matrix.IsSingular()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2014-08-29 12:42:07 -07:00
|
|
|
gfxMatrix m = matrix;
|
|
|
|
// PaintFrameWithEffects() expects the transform that is passed to it to
|
|
|
|
// include the transform to the passed frame's user space, so add it:
|
|
|
|
const nsIContent* content = kid->GetContent();
|
|
|
|
if (content->IsSVG()) { // must check before cast
|
|
|
|
const nsSVGElement* element = static_cast<const nsSVGElement*>(content);
|
|
|
|
if (!element->HasValidDimensions()) {
|
|
|
|
continue; // nothing to paint for kid
|
|
|
|
}
|
|
|
|
m = element->
|
|
|
|
PrependLocalTransformsTo(m, nsSVGElement::eUserSpaceToParent);
|
|
|
|
if (m.IsSingular()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2014-10-31 13:08:54 -07:00
|
|
|
nsSVGUtils::PaintFrameWithEffects(kid, aContext, m, aDirtyRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-19 14:34:31 -08:00
|
|
|
nsIFrame*
|
2014-08-07 00:09:31 -07:00
|
|
|
nsSVGDisplayContainerFrame::GetFrameForPoint(const gfxPoint& aPoint)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-20 11:12:29 -07:00
|
|
|
NS_ASSERTION(!NS_SVGDisplayListHitTestingEnabled() ||
|
2013-07-12 00:13:07 -07:00
|
|
|
(mState & NS_FRAME_IS_NONDISPLAY),
|
2012-07-20 11:12:29 -07:00
|
|
|
"If display lists are enabled, only hit-testing of a "
|
|
|
|
"clipPath's contents should take this code path");
|
2008-08-25 02:23:54 -07:00
|
|
|
return nsSVGUtils::HitTestChildren(this, aPoint);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-02-19 14:34:31 -08:00
|
|
|
nsRect
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSVGDisplayContainerFrame::GetCoveredRegion()
|
|
|
|
{
|
|
|
|
return nsSVGUtils::GetCoveredRegion(mFrames);
|
|
|
|
}
|
|
|
|
|
2012-03-20 05:15:53 -07:00
|
|
|
void
|
2012-07-21 17:01:44 -07:00
|
|
|
nsSVGDisplayContainerFrame::ReflowSVG()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-21 17:01:44 -07:00
|
|
|
NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this),
|
|
|
|
"This call is probably a wasteful mistake");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(!(GetStateBits() & NS_FRAME_IS_NONDISPLAY),
|
|
|
|
"ReflowSVG mechanism not designed for this");
|
2012-03-20 05:15:53 -07:00
|
|
|
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(GetType() != nsGkAtoms::svgOuterSVGFrame,
|
|
|
|
"Do not call on outer-<svg>");
|
2012-05-16 21:05:09 -07:00
|
|
|
|
2012-07-21 17:01:44 -07:00
|
|
|
if (!nsSVGUtils::NeedsReflowSVG(this)) {
|
2012-03-20 05:15:53 -07:00
|
|
|
return;
|
|
|
|
}
|
2007-10-19 04:07:08 -07:00
|
|
|
|
2012-03-20 05:15:53 -07:00
|
|
|
// If the NS_FRAME_FIRST_REFLOW bit has been removed from our parent frame,
|
|
|
|
// then our outer-<svg> has previously had its initial reflow. In that case
|
|
|
|
// we need to make sure that that bit has been removed from ourself _before_
|
|
|
|
// recursing over our children to ensure that they know too. Otherwise, we
|
|
|
|
// need to remove it _after_ recursing over our children so that they know
|
|
|
|
// the initial reflow is currently underway.
|
|
|
|
|
2013-08-24 04:31:48 -07:00
|
|
|
bool isFirstReflow = (mState & NS_FRAME_FIRST_REFLOW);
|
|
|
|
|
2012-03-20 05:15:53 -07:00
|
|
|
bool outerSVGHasHadFirstReflow =
|
|
|
|
(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW) == 0;
|
|
|
|
|
|
|
|
if (outerSVGHasHadFirstReflow) {
|
|
|
|
mState &= ~NS_FRAME_FIRST_REFLOW; // tell our children
|
|
|
|
}
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
nsOverflowAreas overflowRects;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2009-01-12 11:20:59 -08:00
|
|
|
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (SVGFrame) {
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(!(kid->GetStateBits() & NS_FRAME_IS_NONDISPLAY),
|
|
|
|
"Check for this explicitly in the |if|, then");
|
2013-02-10 22:22:16 -08:00
|
|
|
kid->AddStateBits(mState & NS_FRAME_IS_DIRTY);
|
2012-07-21 17:01:44 -07:00
|
|
|
SVGFrame->ReflowSVG();
|
2012-05-16 21:05:09 -07:00
|
|
|
|
|
|
|
// We build up our child frame overflows here instead of using
|
|
|
|
// nsLayoutUtils::UnionChildOverflow since SVG frame's all use the same
|
|
|
|
// frame list, and we're iterating over that list now anyway.
|
|
|
|
ConsiderChildOverflow(overflowRects, kid);
|
2013-06-03 07:15:29 -07:00
|
|
|
} else {
|
|
|
|
// Inside a non-display container frame, we might have some
|
2013-12-20 08:38:51 -08:00
|
|
|
// SVGTextFrames. We need to cause those to get reflowed in
|
2013-06-03 07:15:29 -07:00
|
|
|
// case they are the target of a rendering observer.
|
2013-07-12 00:13:07 -07:00
|
|
|
NS_ASSERTION(kid->GetStateBits() & NS_FRAME_IS_NONDISPLAY,
|
|
|
|
"expected kid to be a NS_FRAME_IS_NONDISPLAY frame");
|
2013-06-03 07:15:29 -07:00
|
|
|
if (kid->GetStateBits() & NS_FRAME_IS_DIRTY) {
|
|
|
|
nsSVGContainerFrame* container = do_QueryFrame(kid);
|
|
|
|
if (container && container->GetContent()->IsSVG()) {
|
|
|
|
ReflowSVGNonDisplayText(container);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 21:05:09 -07:00
|
|
|
// <svg> can create an SVG viewport with an offset due to its
|
|
|
|
// x/y/width/height attributes, and <use> can introduce an offset with an
|
|
|
|
// empty mRect (any width/height is copied to an anonymous <svg> child).
|
|
|
|
// Other than that containers should not set mRect since all other offsets
|
|
|
|
// come from transforms, which are accounted for by nsDisplayTransform.
|
|
|
|
// Note that we rely on |overflow:visible| to allow display list items to be
|
|
|
|
// created for our children.
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(mContent->Tag() == nsGkAtoms::svg ||
|
|
|
|
(mContent->Tag() == nsGkAtoms::use &&
|
|
|
|
mRect.Size() == nsSize(0,0)) ||
|
|
|
|
mRect.IsEqualEdges(nsRect()),
|
|
|
|
"Only inner-<svg>/<use> is expected to have mRect set");
|
2012-05-16 21:05:09 -07:00
|
|
|
|
2013-08-24 04:31:48 -07:00
|
|
|
if (isFirstReflow) {
|
2012-05-16 21:05:09 -07:00
|
|
|
// Make sure we have our filter property (if any) before calling
|
|
|
|
// FinishAndStoreOverflow (subsequent filter changes are handled off
|
|
|
|
// nsChangeHint_UpdateEffects):
|
|
|
|
nsSVGEffects::UpdateEffects(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
FinishAndStoreOverflow(overflowRects, mRect.Size());
|
|
|
|
|
|
|
|
// Remove state bits after FinishAndStoreOverflow so that it doesn't
|
|
|
|
// invalidate on first reflow:
|
2007-03-22 10:30:00 -07:00
|
|
|
mState &= ~(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
|
|
|
|
2008-01-25 01:27:03 -08:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSVGDisplayContainerFrame::NotifySVGChanged(uint32_t aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
2008-01-25 01:27:03 -08:00
|
|
|
|
|
|
|
nsSVGUtils::NotifyChildrenOfSVGChange(this, aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-04-16 01:23:48 -07:00
|
|
|
SVGBBox
|
2011-09-30 02:25:37 -07:00
|
|
|
nsSVGDisplayContainerFrame::GetBBoxContribution(
|
2013-12-29 22:50:07 -08:00
|
|
|
const Matrix &aToBBoxUserspace,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-04-16 01:23:48 -07:00
|
|
|
SVGBBox bboxUnion;
|
2009-04-28 21:31:34 -07:00
|
|
|
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
2014-02-19 12:46:43 -08:00
|
|
|
nsIContent *content = kid->GetContent();
|
2009-04-28 21:31:34 -07:00
|
|
|
nsISVGChildFrame* svgKid = do_QueryFrame(kid);
|
2014-02-19 12:46:43 -08:00
|
|
|
// content could be a XUL element so check for an SVG element before casting
|
|
|
|
if (svgKid && (!content->IsSVG() ||
|
|
|
|
static_cast<const nsSVGElement*>(content)->HasValidDimensions())) {
|
|
|
|
|
2013-12-29 22:50:07 -08:00
|
|
|
gfxMatrix transform = gfx::ThebesMatrix(aToBBoxUserspace);
|
2012-03-15 04:42:54 -07:00
|
|
|
if (content->IsSVG()) {
|
2013-12-26 12:13:57 -08:00
|
|
|
transform = static_cast<nsSVGElement*>(content)->
|
2013-12-29 22:50:07 -08:00
|
|
|
PrependLocalTransformsTo(transform);
|
2009-04-28 21:31:34 -07:00
|
|
|
}
|
2012-01-23 09:42:32 -08:00
|
|
|
// We need to include zero width/height vertical/horizontal lines, so we have
|
2012-04-16 01:23:48 -07:00
|
|
|
// to use UnionEdges.
|
2013-12-29 22:50:07 -08:00
|
|
|
bboxUnion.UnionEdges(svgKid->GetBBoxContribution(gfx::ToMatrix(transform), aFlags));
|
2009-04-28 21:31:34 -07:00
|
|
|
}
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
return bboxUnion;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|