2001-12-12 07:59:31 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2004-04-18 14:30:37 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2001-12-12 07:59:31 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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
|
2001-12-12 07:59:31 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-12-12 07:59:31 +00:00
|
|
|
* Crocodile Clips Ltd..
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2004-04-18 14:30:37 +00:00
|
|
|
* Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
|
2001-12-12 07:59:31 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of 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"),
|
2001-12-12 07:59:31 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-12-12 07:59:31 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2006-06-15 19:10:28 +00:00
|
|
|
#include "nsSVGOuterSVGFrame.h"
|
|
|
|
#include "nsIDOMSVGSVGElement.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 12:39:26 +00:00
|
|
|
#include "nsISVGRenderer.h"
|
2006-06-15 19:10:28 +00:00
|
|
|
#include "nsSVGSVGElement.h"
|
2006-09-28 08:00:20 +00:00
|
|
|
#include "nsSVGTextFrame.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 12:39:26 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2006-06-15 19:10:28 +00:00
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsReflowPath.h"
|
2004-12-05 22:12:43 +00:00
|
|
|
#include "nsSVGRect.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2006-06-15 19:10:28 +00:00
|
|
|
#include "nsISVGRendererCanvas.h"
|
2006-09-28 08:00:20 +00:00
|
|
|
#include "nsStubMutationObserver.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2006-06-15 19:10:28 +00:00
|
|
|
#if defined(DEBUG) && defined(SVG_DEBUG_PRINTING)
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsTransform2D.h"
|
2005-04-01 19:56:08 +00:00
|
|
|
#endif
|
|
|
|
|
2006-09-28 08:00:20 +00:00
|
|
|
class nsSVGMutationObserver : public nsStubMutationObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// nsIMutationObserver interface
|
|
|
|
void AttributeChanged(nsIDocument *aDocument,
|
|
|
|
nsIContent *aContent,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom *aAttribute,
|
|
|
|
PRInt32 aModType);
|
|
|
|
|
|
|
|
// nsISupports interface:
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
|
|
|
private:
|
|
|
|
NS_IMETHOD_(nsrefcnt) AddRef() { return 1; }
|
|
|
|
NS_IMETHOD_(nsrefcnt) Release() { return 1; }
|
|
|
|
|
|
|
|
static void UpdateTextFragmentTrees(nsIFrame *aFrame);
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGMutationObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
static nsSVGMutationObserver sSVGMutationObserver;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIMutationObserver methods
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGMutationObserver::AttributeChanged(nsIDocument *aDocument,
|
|
|
|
nsIContent *aContent,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom *aAttribute,
|
|
|
|
PRInt32 aModType)
|
|
|
|
{
|
|
|
|
if (aNameSpaceID != kNameSpaceID_XML || aAttribute != nsGkAtoms::space) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 count = aDocument->GetNumberOfShells();
|
|
|
|
for (PRUint32 i = 0; i < count; ++i) {
|
|
|
|
nsIFrame *frame = aDocument->GetShellAt(i)->GetPrimaryFrameFor(aContent);
|
|
|
|
if (!frame) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// is the content a child of a text element
|
|
|
|
nsISVGTextContentMetrics* metrics;
|
|
|
|
CallQueryInterface(frame, &metrics);
|
|
|
|
if (metrics) {
|
|
|
|
nsSVGTextFrame* textFrame = NS_STATIC_CAST(nsSVGTextContainerFrame*,
|
|
|
|
frame)->GetTextFrame();
|
|
|
|
|
|
|
|
if (!textFrame->IsGlyphFragmentTreeSuspended())
|
|
|
|
textFrame->UpdateFragmentTree();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// if not, are there text elements amongst its descendents
|
|
|
|
UpdateTextFragmentTrees(frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation helpers
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGMutationObserver::UpdateTextFragmentTrees(nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
nsIFrame* kid = aFrame->GetFirstChild(nsnull);
|
|
|
|
while (kid) {
|
|
|
|
if (kid->GetType() == nsLayoutAtoms::svgTextFrame) {
|
|
|
|
nsSVGTextFrame* textFrame = NS_STATIC_CAST(nsSVGTextFrame*, kid);
|
|
|
|
if (!textFrame->IsGlyphFragmentTreeSuspended()) {
|
|
|
|
textFrame->UpdateFragmentTree();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
UpdateTextFragmentTrees(kid);
|
|
|
|
}
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2005-11-11 02:36:29 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewSVGOuterSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleContext* aContext)
|
2005-11-11 02:36:29 +00:00
|
|
|
{
|
2001-12-12 07:59:31 +00:00
|
|
|
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(aContent);
|
|
|
|
if (!svgElement) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("warning: trying to construct an SVGOuterSVGFrame for a content element that doesn't support the right interfaces\n");
|
|
|
|
#endif
|
2005-11-11 02:36:29 +00:00
|
|
|
return nsnull;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsSVGOuterSVGFrame(aContext);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsSVGOuterSVGFrame::nsSVGOuterSVGFrame(nsStyleContext* aContext)
|
|
|
|
: nsSVGOuterSVGFrameBase(aContext),
|
|
|
|
mRedrawSuspendCount(0),
|
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
|
|
|
mNeedsReflow(PR_FALSE),
|
|
|
|
mViewportInitialized(PR_FALSE)
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:00:20 +00:00
|
|
|
nsSVGOuterSVGFrame::~nsSVGOuterSVGFrame()
|
|
|
|
{
|
2006-09-29 09:16:31 +00:00
|
|
|
// XXX XBL2/sXBL issue
|
2006-09-28 08:00:20 +00:00
|
|
|
nsIDocument *doc = mContent->GetOwnerDoc();
|
|
|
|
if (doc) {
|
|
|
|
doc->RemoveMutationObserver(&sSVGMutationObserver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-01 15:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGOuterSVGFrame::InitSVG()
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2006-03-01 10:59:36 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
mRenderer = do_CreateInstance(NS_SVG_RENDERER_CAIRO_CONTRACTID, &rv);
|
|
|
|
NS_ASSERTION(mRenderer, "could not get SVG renderer");
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2004-08-05 09:01:13 +00:00
|
|
|
|
|
|
|
// we are an *outer* svg element, so this frame will become the
|
|
|
|
// coordinate context for our content element:
|
|
|
|
float mmPerPx = GetTwipsPerPx() / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
|
|
|
|
SetCoordCtxMMPerPx(mmPerPx, mmPerPx);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISVGSVGElement> SVGElement = do_QueryInterface(mContent);
|
|
|
|
NS_ASSERTION(SVGElement, "wrong content element");
|
|
|
|
SVGElement->SetParentCoordCtxProvider(this);
|
|
|
|
|
2006-09-29 09:16:31 +00:00
|
|
|
// XXX XBL2/sXBL issue
|
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
|
|
|
|
if (doc->GetRootContent() == mContent) {
|
|
|
|
SVGElement->GetZoomAndPanEnum(getter_AddRefs(mZoomAndPan));
|
|
|
|
SVGElement->GetCurrentTranslate(getter_AddRefs(mCurrentTranslate));
|
|
|
|
SVGElement->GetCurrentScaleNumber(getter_AddRefs(mCurrentScale));
|
|
|
|
}
|
|
|
|
doc->AddMutationObserver(&sSVGMutationObserver);
|
2005-08-25 21:31:09 +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
|
|
|
SuspendRedraw();
|
2006-02-13 21:22:41 +00:00
|
|
|
|
|
|
|
AddStateBits(NS_STATE_IS_OUTER_SVG);
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSVGOuterSVGFrame)
|
2004-08-05 09:01:13 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISVGSVGFrame)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsSVGCoordCtxProvider)
|
2001-12-12 07:59:31 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGOuterSVGFrameBase)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// reflowing
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
|
2001-12-12 07:59:31 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
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
|
|
|
#if defined(DEBUG) && defined(SVG_DEBUG_PRINTING)
|
|
|
|
{
|
|
|
|
printf("nsSVGOuterSVGFrame(%p)::Reflow()[\n",this);
|
2004-07-29 19:41:39 +00:00
|
|
|
float twipsPerScPx = aPresContext->ScaledPixelsToTwips();
|
|
|
|
float twipsPerPx = aPresContext->PixelsToTwips();
|
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
|
|
|
printf("tw/sc(px)=%f tw/px=%f\n", twipsPerScPx, twipsPerPx);
|
|
|
|
printf("]\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-02-28 11:27:29 +00:00
|
|
|
if (aReflowState.reason == eReflowReason_Incremental &&
|
|
|
|
!aReflowState.path->mReflowCommand) {
|
|
|
|
// We're not the target of the incremental reflow, so just bail.
|
|
|
|
// This means that something happened to one of our descendants
|
|
|
|
// (excluding those inside svg:foreignObject, since
|
|
|
|
// nsSVGForeignObjectFrame is a reflow root).
|
|
|
|
|
|
|
|
// XXXldb If this incremental reflow was the result of a style
|
|
|
|
// change to something that *contains* a foreignObject, then we're
|
|
|
|
// dropping the change completely on the floor!
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SVG CR 20001102: When the SVG content is embedded inline within
|
|
|
|
// a containing document, and that document is styled using CSS,
|
|
|
|
// then if there are CSS positioning properties specified on the
|
|
|
|
// outermost 'svg' element that are sufficient to establish the
|
|
|
|
// width of the viewport, then these positioning properties
|
|
|
|
// establish the viewport's width; otherwise, the width attribute
|
|
|
|
// on the outermost 'svg' element establishes the viewport's width.
|
|
|
|
// Similarly, if there are CSS positioning properties specified on
|
|
|
|
// the outermost 'svg' element that are sufficient to establish the
|
|
|
|
// height of the viewport, then these positioning properties
|
|
|
|
// establish the viewport's height; otherwise, the height attribute
|
|
|
|
// on the outermost 'svg' element establishes the viewport's
|
|
|
|
// height.
|
|
|
|
#ifdef DEBUG
|
|
|
|
// printf("--- nsSVGOuterSVGFrame(%p)::Reflow(frame:%p,reason:%d) ---\n",this,aReflowState.frame,aReflowState.reason);
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
nsCOMPtr<nsISVGSVGElement> SVGElement = do_QueryInterface(mContent);
|
2001-12-12 07:59:31 +00:00
|
|
|
NS_ENSURE_TRUE(SVGElement, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
float pxPerTwips = GetPxPerTwips();
|
|
|
|
float twipsPerPx = GetTwipsPerPx();
|
|
|
|
|
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
|
|
|
// The width/height attribs given on the <svg>-element might be
|
|
|
|
// percentage values of the parent viewport. We will set the parent
|
2004-08-05 09:01:13 +00:00
|
|
|
// coordinate context dimensions to the available space.
|
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
|
|
|
|
|
|
|
nsRect maxRect, preferredRect;
|
|
|
|
CalculateAvailableSpace(&maxRect, &preferredRect, aPresContext, aReflowState);
|
|
|
|
float preferredWidth = preferredRect.width * pxPerTwips;
|
|
|
|
float preferredHeight = preferredRect.height * pxPerTwips;
|
|
|
|
|
|
|
|
SuspendRedraw();
|
|
|
|
|
2004-08-05 09:01:13 +00:00
|
|
|
nsCOMPtr<nsIDOMSVGRect> r;
|
2004-12-05 22:12:43 +00:00
|
|
|
NS_NewSVGRect(getter_AddRefs(r), 0, 0, preferredWidth, preferredHeight);
|
2004-08-05 09:01:13 +00:00
|
|
|
SetCoordCtxRect(r);
|
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
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// some debug stuff:
|
|
|
|
// {
|
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
|
|
|
// nsRect r=aPresContext->GetVisibleArea();
|
2001-12-12 07:59:31 +00:00
|
|
|
// printf("******* aw: %d, ah: %d visiw: %d, visih: %d\n",
|
|
|
|
// aReflowState.availableWidth,
|
|
|
|
// aReflowState.availableHeight,
|
|
|
|
// r.width, r.height);
|
|
|
|
// printf("******* cw: %d, ch: %d \n cmaxw: %d, cmaxh: %d\n",
|
|
|
|
// aReflowState.mComputedWidth,
|
|
|
|
// aReflowState.mComputedHeight,
|
|
|
|
// aReflowState.mComputedMaxWidth,
|
|
|
|
// aReflowState.mComputedMaxHeight);
|
|
|
|
|
|
|
|
// if (aReflowState.parentReflowState) {
|
|
|
|
// printf("******* parent aw: %d, parent ah: %d \n",
|
|
|
|
// aReflowState.parentReflowState->availableWidth,
|
|
|
|
// aReflowState.parentReflowState->availableHeight);
|
|
|
|
// printf("******* parent cw: %d, parent ch: %d \n parent cmaxw: %d, parent cmaxh: %d\n",
|
|
|
|
// aReflowState.parentReflowState->mComputedWidth,
|
|
|
|
// aReflowState.parentReflowState->mComputedHeight,
|
|
|
|
// aReflowState.parentReflowState->mComputedMaxWidth,
|
|
|
|
// aReflowState.parentReflowState->mComputedMaxHeight);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
#endif
|
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
|
|
|
|
2004-08-05 09:01:13 +00:00
|
|
|
// now that the parent coord ctx dimensions have been set, the
|
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
|
|
|
// width/height attributes will be valid.
|
|
|
|
// Let's work out our desired dimensions.
|
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
nsSVGSVGElement *svg = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
|
|
|
|
svg->SetParentCoordCtxProvider(this);
|
|
|
|
float width =
|
|
|
|
svg->mLengthAttributes[nsSVGSVGElement::WIDTH].GetAnimValue(this);
|
|
|
|
float height =
|
|
|
|
svg->mLengthAttributes[nsSVGSVGElement::HEIGHT].GetAnimValue(this);
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2006-04-14 15:09:39 +00:00
|
|
|
aDesiredSize.width = (int)(width*twipsPerPx);
|
|
|
|
aDesiredSize.height = (int)(height*twipsPerPx);
|
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
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
|
|
|
|
// XXX add in CSS borders ??
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
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-04-14 15:09:39 +00:00
|
|
|
// tell our element that the viewbox to viewport transform needs refreshing,
|
|
|
|
// and set us up to draw
|
|
|
|
svg->InvalidateViewBoxToViewport();
|
|
|
|
NotifyViewportChange();
|
|
|
|
|
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
|
|
|
UnsuspendRedraw();
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSVGOuterSVGFrame::DidReflow(nsPresContext* aPresContext,
|
2001-12-12 07:59:31 +00:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus)
|
|
|
|
{
|
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
|
|
|
nsresult rv = nsSVGOuterSVGFrameBase::DidReflow(aPresContext,aReflowState,aStatus);
|
|
|
|
|
|
|
|
if (!mViewportInitialized) {
|
|
|
|
// it is now
|
|
|
|
mViewportInitialized = PR_TRUE;
|
|
|
|
|
|
|
|
// call InitialUpdate() on all frames:
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
2006-08-02 08:42:26 +00:00
|
|
|
nsISVGChildFrame* SVGFrame = nsnull;
|
|
|
|
CallQueryInterface(kid, &SVGFrame);
|
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
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->InitialUpdate();
|
|
|
|
}
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
UnsuspendRedraw();
|
|
|
|
}
|
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
|
|
|
return rv;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// container methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsSVGOuterSVGFrame::InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
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
|
|
|
SuspendRedraw();
|
2006-06-01 15:31:15 +00:00
|
|
|
nsSVGOuterSVGFrameBase::InsertFrames(aListName, aPrevFrame, aFrameList);
|
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
|
|
|
UnsuspendRedraw();
|
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
|
|
|
return NS_OK;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
class nsDisplaySVG : public nsDisplayItem {
|
|
|
|
public:
|
2006-03-14 20:43:18 +00:00
|
|
|
nsDisplaySVG(nsSVGOuterSVGFrame* aFrame) : nsDisplayItem(aFrame) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplaySVG);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplaySVG() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplaySVG);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
virtual nsIFrame* HitTest(nsDisplayListBuilder* aBuilder, nsPoint aPt);
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
NS_DISPLAY_DECL_NAME("SVGEventReceiver")
|
|
|
|
};
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsDisplaySVG::HitTest(nsDisplayListBuilder* aBuilder, nsPoint aPt)
|
|
|
|
{
|
2006-03-14 20:43:18 +00:00
|
|
|
return NS_STATIC_CAST(nsSVGOuterSVGFrame*, mFrame)->
|
|
|
|
GetFrameForPoint(aPt - aBuilder->ToReferenceFrame(mFrame));
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplaySVG::Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect)
|
|
|
|
{
|
2006-03-14 20:43:18 +00:00
|
|
|
NS_STATIC_CAST(nsSVGOuterSVGFrame*, mFrame)->
|
|
|
|
Paint(*aCtx, aDirtyRect, aBuilder->ToReferenceFrame(mFrame));
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2005-09-26 12:28:21 +00:00
|
|
|
nsIFrame*
|
2006-01-26 02:29:17 +00:00
|
|
|
nsSVGOuterSVGFrame::GetFrameForPoint(const nsPoint& aPoint)
|
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
|
|
|
// XXX This algorithm is really bad. Because we only have a
|
|
|
|
// singly-linked list we have to test each and every SVG element for
|
|
|
|
// a hit. What we really want is a double-linked list.
|
|
|
|
|
2005-09-26 12:28:21 +00:00
|
|
|
float x = GetPxPerTwips() * aPoint.x;
|
|
|
|
float y = GetPxPerTwips() * aPoint.y;
|
|
|
|
|
|
|
|
nsRect thisRect(nsPoint(0,0), GetSize());
|
|
|
|
if (!thisRect.Contains(aPoint) || !mRenderer) {
|
|
|
|
return nsnull;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2006-03-21 15:49:20 +00:00
|
|
|
nsIFrame* hit;
|
|
|
|
nsSVGUtils::HitTestChildren(this, x, y, &hit);
|
2005-09-26 12:28:21 +00:00
|
|
|
|
2006-03-21 15:49:20 +00:00
|
|
|
return hit;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// painting
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
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
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
// XXX Not sure why this nsSVGOuterSVGFrame::Paint doesn't paint its
|
|
|
|
// background or respect CSS visiblity
|
|
|
|
return aLists.Content()->AppendNewToTop(new (aBuilder) nsDisplaySVG(this));
|
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void
|
|
|
|
nsSVGOuterSVGFrame::Paint(nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
|
|
|
{
|
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
|
|
|
#if defined(DEBUG) && defined(SVG_DEBUG_PRINTING)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDeviceContext> dx;
|
|
|
|
aRenderingContext.GetDeviceContext(*getter_AddRefs(dx));
|
|
|
|
float zoom,tzoom,scale;
|
|
|
|
dx->GetZoom(zoom);
|
|
|
|
dx->GetTextZoom(tzoom);
|
|
|
|
dx->GetCanonicalPixelScale(scale);
|
|
|
|
printf("nsSVGOuterSVGFrame(%p)::Paint()[ z=%f tz=%f ps=%f\n",this,zoom,tzoom,scale);
|
|
|
|
printf("dirtyrect= %d, %d, %d, %d\n", aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
|
|
|
nsTransform2D* xform;
|
|
|
|
aRenderingContext.GetCurrentTransform(xform);
|
|
|
|
printf("translation=(%f,%f)\n", xform->GetXTranslation(), xform->GetYTranslation());
|
|
|
|
float sx=1.0f,sy=1.0f;
|
|
|
|
xform->TransformNoXLate(&sx,&sy);
|
|
|
|
printf("scale=(%f,%f)\n", sx, sy);
|
2004-07-29 19:41:39 +00:00
|
|
|
float twipsPerScPx = aPresContext->ScaledPixelsToTwips();
|
|
|
|
float twipsPerPx = aPresContext->PixelsToTwips();
|
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
|
|
|
printf("tw/sc(px)=%f tw/px=%f\n", twipsPerScPx, twipsPerPx);
|
|
|
|
int fontsc;
|
2006-01-26 02:29:17 +00:00
|
|
|
GetPresContext()->GetFontScaler(&fontsc);
|
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
|
|
|
printf("font scale=%d\n",fontsc);
|
|
|
|
printf("]\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// initialize Mozilla rendering context
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsRect clipRect;
|
|
|
|
clipRect.IntersectRect(aDirtyRect, nsRect(aPt, GetSize()));
|
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
|
|
|
|
aRenderingContext.Translate(aPt.x, aPt.y);
|
|
|
|
nsRect dirtyRect = clipRect - aPt;
|
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
|
|
|
|
|
|
|
#if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)
|
|
|
|
PRTime start = PR_Now();
|
|
|
|
#endif
|
|
|
|
|
2005-02-18 16:30:12 +00:00
|
|
|
// If we don't have a renderer due to the component failing
|
|
|
|
// to load (gdi+ or cairo not available), indicate to the user
|
|
|
|
// what's going on by drawing a red "X" at the appropriate spot.
|
|
|
|
if (!mRenderer) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
2006-01-26 02:29:17 +00:00
|
|
|
aRenderingContext.DrawLine(0, 0, mRect.width, mRect.height);
|
|
|
|
aRenderingContext.DrawLine(mRect.width, 0, 0, mRect.height);
|
2005-02-18 16:30:12 +00:00
|
|
|
aRenderingContext.PopState();
|
2006-01-26 02:29:17 +00:00
|
|
|
return;
|
2005-02-18 16:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 19:19:42 +00:00
|
|
|
dirtyRect.ScaleRoundOut(GetPxPerTwips());
|
|
|
|
|
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
|
|
|
nsCOMPtr<nsISVGRendererCanvas> canvas;
|
2006-06-30 19:19:42 +00:00
|
|
|
mRenderer->CreateCanvas(&aRenderingContext, GetPresContext(), dirtyRect,
|
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
|
|
|
getter_AddRefs(canvas));
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
// paint children:
|
2003-07-08 11:00:00 +00:00
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2006-06-30 19:19:42 +00:00
|
|
|
nsSVGUtils::PaintChildWithEffects(canvas, &dirtyRect, kid);
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
2006-06-30 19:19:42 +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
|
|
|
canvas->Flush();
|
|
|
|
|
|
|
|
canvas = nsnull;
|
|
|
|
|
|
|
|
#if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)
|
|
|
|
PRTime end = PR_Now();
|
|
|
|
printf("SVG Paint Timing: %f ms\n", (end-start)/1000.0);
|
|
|
|
#endif
|
|
|
|
|
2004-04-18 13:13:35 +00:00
|
|
|
aRenderingContext.PopState();
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 19:56:08 +00:00
|
|
|
nsIAtom *
|
|
|
|
nsSVGOuterSVGFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsLayoutAtoms::svgOuterSVGFrame;
|
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
2006-06-15 19:10:28 +00:00
|
|
|
// nsSVGOuterSVGFrame methods:
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2006-06-15 19:45:26 +00:00
|
|
|
nsresult
|
2006-06-09 18:08:33 +00:00
|
|
|
nsSVGOuterSVGFrame::InvalidateRect(nsRect aRect)
|
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
|
|
|
// just ignore invalidates if painting is suppressed by the shell
|
|
|
|
PRBool suppressed = PR_FALSE;
|
2005-02-08 00:59:52 +00:00
|
|
|
GetPresContext()->PresShell()->IsPaintingSuppressed(&suppressed);
|
2006-06-09 18:08:33 +00:00
|
|
|
if (suppressed)
|
|
|
|
return NS_OK;
|
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
|
|
|
|
2003-07-08 11:00:00 +00:00
|
|
|
nsIView* view = GetClosestView();
|
2001-12-12 07:59:31 +00:00
|
|
|
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
|
|
|
|
|
2003-07-08 11:00:00 +00:00
|
|
|
nsIViewManager* vm = view->GetViewManager();
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2006-06-09 18:08:33 +00:00
|
|
|
aRect.ScaleRoundOut(GetTwipsPerPx());
|
|
|
|
vm->UpdateView(view, aRect, NS_VMREFRESH_NO_SYNC);
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-15 19:45:26 +00:00
|
|
|
nsresult
|
2004-08-05 09:01:13 +00:00
|
|
|
nsSVGOuterSVGFrame::IsRedrawSuspended(PRBool* isSuspended)
|
|
|
|
{
|
|
|
|
*isSuspended = (mRedrawSuspendCount>0) || !mViewportInitialized;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-15 19:45:26 +00:00
|
|
|
nsresult
|
2004-08-05 09:01:13 +00:00
|
|
|
nsSVGOuterSVGFrame::GetRenderer(nsISVGRenderer**renderer)
|
|
|
|
{
|
|
|
|
*renderer = mRenderer;
|
|
|
|
NS_IF_ADDREF(*renderer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISVGSVGFrame methods:
|
|
|
|
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
NS_IMETHODIMP
|
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
|
|
|
nsSVGOuterSVGFrame::SuspendRedraw()
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2005-02-18 16:30:12 +00:00
|
|
|
if (!mRenderer)
|
|
|
|
return NS_OK;
|
|
|
|
|
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
|
|
|
#ifdef DEBUG
|
|
|
|
//printf("suspend redraw (count=%d)\n", mRedrawSuspendCount);
|
|
|
|
#endif
|
|
|
|
if (++mRedrawSuspendCount != 1)
|
|
|
|
return NS_OK;
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2003-07-08 11:00:00 +00:00
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
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
|
|
|
nsISVGChildFrame* SVGFrame=nsnull;
|
2005-08-24 01:03:42 +00:00
|
|
|
CallQueryInterface(kid, &SVGFrame);
|
2001-12-12 07:59:31 +00:00
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->NotifyRedrawSuspended();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
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
|
|
|
nsSVGOuterSVGFrame::UnsuspendRedraw()
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2005-02-18 16:30:12 +00:00
|
|
|
if (!mRenderer)
|
|
|
|
return NS_OK;
|
|
|
|
|
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
|
|
|
#ifdef DEBUG
|
|
|
|
// printf("unsuspend redraw (count=%d)\n", mRedrawSuspendCount);
|
|
|
|
#endif
|
|
|
|
if (--mRedrawSuspendCount > 0)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
NS_ASSERTION(mRedrawSuspendCount >=0, "unbalanced suspend count!");
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
// If we need to reflow, do so before we update any of our
|
|
|
|
// children. Reflows are likely to affect the display of children:
|
|
|
|
if (mNeedsReflow)
|
|
|
|
InitiateReflow();
|
|
|
|
|
2003-07-08 11:00:00 +00:00
|
|
|
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
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
|
|
|
nsISVGChildFrame* SVGFrame=nsnull;
|
2005-08-24 01:03:42 +00:00
|
|
|
CallQueryInterface(kid, &SVGFrame);
|
2001-12-12 07:59:31 +00:00
|
|
|
if (SVGFrame) {
|
|
|
|
SVGFrame->NotifyRedrawUnsuspended();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSVGOuterSVGFrame::NotifyViewportChange()
|
|
|
|
{
|
2005-02-18 16:30:12 +00:00
|
|
|
if (!mRenderer)
|
|
|
|
return NS_OK;
|
|
|
|
|
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
|
|
|
// no point in doing anything when were not init'ed yet:
|
|
|
|
if (!mViewportInitialized) return NS_OK;
|
|
|
|
|
2004-08-05 09:01:13 +00:00
|
|
|
// make sure canvas transform matrix gets (lazily) recalculated:
|
|
|
|
mCanvasTM = nsnull;
|
|
|
|
|
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
|
|
|
// inform children
|
|
|
|
SuspendRedraw();
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
2006-08-02 08:42:26 +00:00
|
|
|
nsISVGChildFrame* SVGFrame = nsnull;
|
|
|
|
CallQueryInterface(kid, &SVGFrame);
|
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
|
|
|
if (SVGFrame)
|
2005-09-06 22:30:40 +00:00
|
|
|
SVGFrame->NotifyCanvasTMChanged(PR_FALSE);
|
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
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
UnsuspendRedraw();
|
2001-12-12 07:59:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2004-08-05 09:01:13 +00:00
|
|
|
already_AddRefed<nsIDOMSVGMatrix>
|
|
|
|
nsSVGOuterSVGFrame::GetCanvasTM()
|
|
|
|
{
|
|
|
|
if (!mCanvasTM) {
|
2006-04-26 21:02:25 +00:00
|
|
|
nsSVGSVGElement *svgElement = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
|
2004-08-05 09:01:13 +00:00
|
|
|
svgElement->GetViewboxToViewportTransform(getter_AddRefs(mCanvasTM));
|
2004-12-02 23:13:13 +00:00
|
|
|
|
2005-08-25 21:31:09 +00:00
|
|
|
if (mZoomAndPan) {
|
|
|
|
// our content is the document element so we must premultiply the values
|
|
|
|
// of it's currentScale and currentTranslate properties
|
|
|
|
PRUint16 val;
|
|
|
|
mZoomAndPan->GetIntegerValue(val);
|
|
|
|
if (val == nsIDOMSVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY) {
|
|
|
|
nsCOMPtr<nsIDOMSVGMatrix> zoomPanMatrix;
|
|
|
|
nsCOMPtr<nsIDOMSVGMatrix> temp;
|
|
|
|
float scale, x, y;
|
|
|
|
mCurrentScale->GetValue(&scale);
|
|
|
|
mCurrentTranslate->GetX(&x);
|
|
|
|
mCurrentTranslate->GetY(&y);
|
|
|
|
svgElement->CreateSVGMatrix(getter_AddRefs(zoomPanMatrix));
|
|
|
|
zoomPanMatrix->Translate(x, y, getter_AddRefs(temp));
|
|
|
|
temp->Scale(scale, getter_AddRefs(zoomPanMatrix));
|
|
|
|
zoomPanMatrix->Multiply(mCanvasTM, getter_AddRefs(temp));
|
|
|
|
temp.swap(mCanvasTM);
|
|
|
|
}
|
2004-12-02 23:13:13 +00:00
|
|
|
}
|
2004-08-05 09:01:13 +00:00
|
|
|
}
|
|
|
|
nsIDOMSVGMatrix* retval = mCanvasTM.get();
|
|
|
|
NS_IF_ADDREF(retval);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsSVGCoordCtxProvider>
|
|
|
|
nsSVGOuterSVGFrame::GetCoordContextProvider()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mContent, "null parent");
|
|
|
|
|
|
|
|
// Our <svg> content element is the CoordContextProvider for our children:
|
|
|
|
nsSVGCoordCtxProvider *provider;
|
2005-08-24 00:05:39 +00:00
|
|
|
CallQueryInterface(mContent, &provider);
|
2004-08-05 09:01:13 +00:00
|
|
|
|
|
|
|
return provider;
|
|
|
|
}
|
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
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation helpers
|
|
|
|
|
|
|
|
float nsSVGOuterSVGFrame::GetPxPerTwips()
|
|
|
|
{
|
|
|
|
float val = GetTwipsPerPx();
|
|
|
|
|
|
|
|
NS_ASSERTION(val!=0.0f, "invalid px/twips");
|
|
|
|
if (val == 0.0) val = 1e-20f;
|
|
|
|
|
|
|
|
return 1.0f/val;
|
|
|
|
}
|
|
|
|
|
|
|
|
float nsSVGOuterSVGFrame::GetTwipsPerPx()
|
|
|
|
{
|
2004-07-29 19:41:39 +00:00
|
|
|
return GetPresContext()->ScaledPixelsToTwips();
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsSVGOuterSVGFrame::InitiateReflow()
|
|
|
|
{
|
|
|
|
mNeedsReflow = PR_FALSE;
|
|
|
|
|
|
|
|
// Generate a reflow command to reflow ourselves
|
2005-02-08 00:59:52 +00:00
|
|
|
nsIPresShell* presShell = GetPresContext()->PresShell();
|
|
|
|
presShell->AppendReflowCommand(this, eReflowType_ReflowDirty, nsnull);
|
2004-05-27 22:08:42 +00:00
|
|
|
// XXXbz why is this synchronously flushing reflows, exactly? If it
|
|
|
|
// needs to, why is it not using the presshell's reflow batching
|
|
|
|
// instead of hacking its own?
|
2005-02-08 00:59:52 +00:00
|
|
|
presShell->FlushPendingNotifications(Flush_OnlyReflow);
|
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
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSVGOuterSVGFrame::CalculateAvailableSpace(nsRect *maxRect,
|
|
|
|
nsRect *preferredRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
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
|
|
|
const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
*preferredRect = aPresContext->GetVisibleArea();
|
|
|
|
|
|
|
|
if (aReflowState.availableWidth != NS_INTRINSICSIZE)
|
|
|
|
maxRect->width = aReflowState.availableWidth;
|
|
|
|
else if (aReflowState.parentReflowState &&
|
|
|
|
aReflowState.parentReflowState->mComputedWidth != NS_INTRINSICSIZE)
|
|
|
|
maxRect->width = aReflowState.parentReflowState->mComputedWidth;
|
|
|
|
else
|
|
|
|
maxRect->width = NS_MAXSIZE;
|
|
|
|
|
|
|
|
if (aReflowState.availableHeight != NS_INTRINSICSIZE)
|
|
|
|
maxRect->height = aReflowState.availableHeight;
|
|
|
|
else if (aReflowState.parentReflowState &&
|
|
|
|
aReflowState.parentReflowState->mComputedHeight != NS_INTRINSICSIZE)
|
|
|
|
maxRect->height = aReflowState.parentReflowState->mComputedHeight;
|
|
|
|
else
|
|
|
|
maxRect->height = NS_MAXSIZE;
|
|
|
|
|
|
|
|
if (preferredRect->width > maxRect->width)
|
|
|
|
preferredRect->width = maxRect->width;
|
|
|
|
if (preferredRect->height > maxRect->height)
|
|
|
|
preferredRect->height = maxRect->height;
|
|
|
|
}
|