2006-06-01 15:31:15 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Mozilla SVG project.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is IBM Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsSVGContainerFrame.h"
|
|
|
|
#include "nsSVGUtils.h"
|
2006-06-15 19:10:28 +00:00
|
|
|
#include "nsSVGOuterSVGFrame.h"
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGContainerFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsSVGContainerFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGContainerFrameBase)
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsSVGDisplayContainerFrame)
|
2009-04-24 23:17:43 +00:00
|
|
|
NS_QUERYFRAME_ENTRY(nsSVGDisplayContainerFrame)
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_ENTRY(nsISVGChildFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSVGContainerFrame)
|
2006-06-01 15:31:15 +00:00
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGContainerFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGContainerFrame)
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGDisplayContainerFrame)
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGContainerFrame::AppendFrames(nsIAtom* aListName,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
|
|
|
return InsertFrames(aListName, mFrames.LastChild(), aFrameList);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGContainerFrame::InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGContainerFrame::RemoveFrame(nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
2009-09-18 11:09:36 +00:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
|
|
|
return NS_OK;
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGContainerFrame::Init(nsIContent* aContent,
|
2007-08-30 17:01:37 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
2008-09-11 00:24:16 +00:00
|
|
|
AddStateBits(NS_STATE_SVG_NONDISPLAY_CHILD | NS_STATE_SVG_PROPAGATE_TRANSFORM);
|
2006-06-01 15:31:15 +00:00
|
|
|
nsresult rv = nsSVGContainerFrameBase::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2007-08-30 17:01:37 +00:00
|
|
|
nsSVGDisplayContainerFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
2008-09-11 00:24:16 +00:00
|
|
|
AddStateBits(NS_STATE_SVG_PROPAGATE_TRANSFORM);
|
2008-06-22 15:59:48 +00:00
|
|
|
if (!(GetStateBits() & NS_STATE_IS_OUTER_SVG)) {
|
|
|
|
AddStateBits(aParent->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD);
|
|
|
|
}
|
2007-08-30 17:01:37 +00:00
|
|
|
nsresult rv = nsSVGContainerFrameBase::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
return rv;
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGDisplayContainerFrame::InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
2009-07-30 17:23:32 +00:00
|
|
|
// memorize first old frame after insertion point
|
|
|
|
// XXXbz once again, this would work a lot better if the nsIFrame
|
|
|
|
// methods returned framelist iterators....
|
|
|
|
nsIFrame* firstOldFrame = aPrevFrame ?
|
|
|
|
aPrevFrame->GetNextSibling() : GetChildList(aListName).FirstChild();
|
|
|
|
nsIFrame* firstNewFrame = aFrameList.FirstChild();
|
2006-06-01 15:31:15 +00:00
|
|
|
|
|
|
|
// Insert the new frames
|
|
|
|
nsSVGContainerFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
|
|
|
|
|
2007-10-19 11:07:08 +00:00
|
|
|
// Call InitialUpdate on the new frames ONLY if our nsSVGOuterSVGFrame has had
|
|
|
|
// its initial reflow (our NS_FRAME_FIRST_REFLOW bit is clear) - bug 399863.
|
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2009-07-30 17:23:32 +00:00
|
|
|
for (nsIFrame* kid = firstNewFrame; kid != firstOldFrame;
|
2007-10-19 11:07:08 +00:00
|
|
|
kid = kid->GetNextSibling()) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
|
2007-10-19 11:07:08 +00:00
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->InitialUpdate();
|
|
|
|
}
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-19 11:07:08 +00:00
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGDisplayContainerFrame::RemoveFrame(nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2008-12-04 18:17:45 +00:00
|
|
|
nsSVGUtils::InvalidateCoveredRegion(aOldFrame);
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2006-07-06 15:45:44 +00:00
|
|
|
nsresult rv = nsSVGContainerFrame::RemoveFrame(aListName, aOldFrame);
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2008-04-08 12:51:19 +00:00
|
|
|
if (!(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
|
2008-03-19 21:27:33 +00:00
|
|
|
nsSVGUtils::NotifyAncestorsOfFilterRegionChange(this);
|
|
|
|
}
|
2006-06-01 15:31:15 +00:00
|
|
|
|
2006-07-06 15:45:44 +00:00
|
|
|
return rv;
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGChildFrame methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-11-27 17:30:57 +00:00
|
|
|
nsSVGDisplayContainerFrame::PaintSVG(nsSVGRenderState* aContext,
|
2008-10-20 08:42:03 +00:00
|
|
|
const nsIntRect *aDirtyRect)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *display = mStyleContext->GetStyleDisplay();
|
|
|
|
if (display->mOpacity == 0.0)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2008-10-20 08:42:03 +00:00
|
|
|
nsSVGUtils::PaintFrameWithEffects(aContext, aDirtyRect, kid);
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-08-25 09:23:54 +00:00
|
|
|
NS_IMETHODIMP_(nsIFrame*)
|
|
|
|
nsSVGDisplayContainerFrame::GetFrameForPoint(const nsPoint &aPoint)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
2008-08-25 09:23:54 +00:00
|
|
|
return nsSVGUtils::HitTestChildren(this, aPoint);
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 18:08:33 +00:00
|
|
|
NS_IMETHODIMP_(nsRect)
|
2006-06-01 15:31:15 +00:00
|
|
|
nsSVGDisplayContainerFrame::GetCoveredRegion()
|
|
|
|
{
|
|
|
|
return nsSVGUtils::GetCoveredRegion(mFrames);
|
|
|
|
}
|
|
|
|
|
2006-06-09 18:08:33 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGDisplayContainerFrame::UpdateCoveredRegion()
|
|
|
|
{
|
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
|
2006-06-09 18:08:33 +00:00
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->UpdateCoveredRegion();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGDisplayContainerFrame::InitialUpdate()
|
|
|
|
{
|
2007-10-19 11:07:08 +00:00
|
|
|
NS_ASSERTION(GetStateBits() & NS_FRAME_FIRST_REFLOW,
|
|
|
|
"Yikes! We've been called already! Hopefully we weren't called "
|
|
|
|
"before our nsSVGOuterSVGFrame's initial Reflow()!!!");
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
|
2006-06-01 15:31:15 +00:00
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->InitialUpdate();
|
|
|
|
}
|
|
|
|
}
|
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 05:38:33 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(!(mState & NS_FRAME_IN_REFLOW),
|
|
|
|
"We don't actually participate in reflow");
|
|
|
|
|
|
|
|
// Do unset the various reflow bits, though.
|
|
|
|
mState &= ~(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-01-25 09:27:03 +00:00
|
|
|
void
|
|
|
|
nsSVGDisplayContainerFrame::NotifySVGChanged(PRUint32 aFlags)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
2008-01-25 09:27:03 +00:00
|
|
|
NS_ASSERTION(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
|
|
|
|
"Invalidation logic may need adjusting");
|
|
|
|
|
|
|
|
nsSVGUtils::NotifyChildrenOfSVGChange(this, aFlags);
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGDisplayContainerFrame::NotifyRedrawSuspended()
|
|
|
|
{
|
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
|
2006-06-01 15:31:15 +00:00
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->NotifyRedrawSuspended();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGDisplayContainerFrame::NotifyRedrawUnsuspended()
|
|
|
|
{
|
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
|
2006-06-01 15:31:15 +00:00
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->NotifyRedrawUnsuspended();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxRect
|
|
|
|
nsSVGDisplayContainerFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace)
|
2006-06-01 15:31:15 +00:00
|
|
|
{
|
2009-04-29 04:31:34 +00:00
|
|
|
gfxRect bboxUnion(0.0, 0.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
|
|
|
nsISVGChildFrame* svgKid = do_QueryFrame(kid);
|
|
|
|
if (svgKid) {
|
|
|
|
gfxMatrix transform = aToBBoxUserspace;
|
|
|
|
// nsSVGGlyphFrame's mContent is a nsTextNode!
|
|
|
|
if (kid->GetType() != nsGkAtoms::svgGlyphFrame) {
|
2009-06-17 21:29:55 +00:00
|
|
|
nsIContent *content = kid->GetContent();
|
2009-08-24 20:02:07 +00:00
|
|
|
if (content->IsSVG()) {
|
2009-06-17 21:29:55 +00:00
|
|
|
transform = static_cast<nsSVGElement*>(content)->
|
|
|
|
PrependLocalTransformTo(aToBBoxUserspace);
|
|
|
|
}
|
2009-04-29 04:31:34 +00:00
|
|
|
}
|
|
|
|
bboxUnion = bboxUnion.Union(svgKid->GetBBoxContribution(transform));
|
|
|
|
}
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
return bboxUnion;
|
2006-06-01 15:31:15 +00:00
|
|
|
}
|
2008-09-11 00:24:16 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGDisplayContainerFrame::SetMatrixPropagation(PRBool aPropagate)
|
|
|
|
{
|
|
|
|
if (aPropagate) {
|
|
|
|
AddStateBits(NS_STATE_SVG_PROPAGATE_TRANSFORM);
|
|
|
|
} else {
|
|
|
|
RemoveStateBits(NS_STATE_SVG_PROPAGATE_TRANSFORM);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsSVGDisplayContainerFrame::GetMatrixPropagation()
|
|
|
|
{
|
|
|
|
return (GetStateBits() & NS_STATE_SVG_PROPAGATE_TRANSFORM) != 0;
|
|
|
|
}
|