зеркало из https://github.com/mozilla/gecko-dev.git
Bug 932091 - Convert SVGBBox.mBBox to Moz2D. r=dholbert
This commit is contained in:
Родитель
1313974522
Коммит
1fe28e78df
|
@ -16,9 +16,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=449327
|
|||
<iframe id="svg" src="bbox-helper.svg"></iframe>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript">
|
||||
<script class="testbody" type="application/javascript">//<![CDATA[
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function fuzzyEq(a, b) {
|
||||
var epsilon = 0.0002;
|
||||
return Math.abs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
var doc = $("svg").contentDocument;
|
||||
|
@ -38,7 +44,7 @@ function run()
|
|||
var bbox2 = getBBox(id2);
|
||||
is(bbox1.x, bbox2.x, id1 + ".getBBox().x");
|
||||
is(bbox1.y, bbox2.y, id1 + ".getBBox().y");
|
||||
is(bbox1.width, bbox2.width, id1 + ".getBBox().width");
|
||||
ok(fuzzyEq(bbox1.width, bbox2.width), id1 + ".getBBox().width");
|
||||
is(bbox1.height, bbox2.height, id1 + ".getBBox().height");
|
||||
}
|
||||
function compareBBoxHeight(id1, id2) {
|
||||
|
@ -60,7 +66,8 @@ function run()
|
|||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
</script>
|
||||
|
||||
//]]></script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -520,7 +520,7 @@ nsSVGGlyphFrame::ReflowSVG()
|
|||
if ((hitTestFlags & SVG_HIT_TEST_STROKE)) {
|
||||
flags |= nsSVGUtils::eBBoxIncludeStrokeGeometry;
|
||||
}
|
||||
gfxRect extent = GetBBoxContribution(gfxMatrix(), flags);
|
||||
gfxRect extent = GetBBoxContribution(gfxMatrix(), flags).ToThebesRect();
|
||||
|
||||
if (!extent.IsEmpty()) {
|
||||
mRect = nsLayoutUtils::RoundGfxRectToAppRect(extent,
|
||||
|
|
|
@ -329,7 +329,7 @@ nsSVGPathGeometryFrame::ReflowSVG()
|
|||
if (applyScaling) {
|
||||
scaling.Scale(scaleFactors.width, scaleFactors.height);
|
||||
}
|
||||
gfxRect extent = GetBBoxContribution(scaling, flags);
|
||||
gfxRect extent = GetBBoxContribution(scaling, flags).ToThebesRect();
|
||||
if (applyScaling) {
|
||||
extent.Scale(1 / scaleFactors.width, 1 / scaleFactors.height);
|
||||
}
|
||||
|
|
|
@ -947,7 +947,7 @@ TextRenderedRun::GetFrameUserSpaceRect(nsPresContext* aContext,
|
|||
return r;
|
||||
}
|
||||
gfxMatrix m = GetTransformFromRunUserSpaceToFrameUserSpace(aContext);
|
||||
return m.TransformBounds(r);
|
||||
return m.TransformBounds(r.ToThebesRect());
|
||||
}
|
||||
|
||||
SVGBBox
|
||||
|
@ -963,7 +963,7 @@ TextRenderedRun::GetUserSpaceRect(nsPresContext* aContext,
|
|||
if (aAdditionalTransform) {
|
||||
m.Multiply(*aAdditionalTransform);
|
||||
}
|
||||
return m.TransformBounds(r);
|
||||
return m.TransformBounds(r.ToThebesRect());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3394,7 +3394,7 @@ nsSVGTextFrame2::FindCloserFrameForSelection(
|
|||
TextRenderedRun::eNoHorizontalOverflow;
|
||||
SVGBBox userRect = run.GetUserSpaceRect(presContext, flags);
|
||||
if (!userRect.IsEmpty()) {
|
||||
nsRect rect = nsSVGUtils::ToCanvasBounds(userRect,
|
||||
nsRect rect = nsSVGUtils::ToCanvasBounds(userRect.ToThebesRect(),
|
||||
GetCanvasTM(FOR_HIT_TESTING),
|
||||
presContext);
|
||||
|
||||
|
@ -3690,7 +3690,7 @@ nsSVGTextFrame2::GetFrameForPoint(const nsPoint& aPoint)
|
|||
gfxPoint pointInRunUserSpace = m.Transform(pointInOuterSVGUserUnits);
|
||||
gfxRect frameRect =
|
||||
run.GetRunUserSpaceRect(presContext, TextRenderedRun::eIncludeFill |
|
||||
TextRenderedRun::eIncludeStroke);
|
||||
TextRenderedRun::eIncludeStroke).ToThebesRect();
|
||||
|
||||
if (Inside(frameRect, pointInRunUserSpace) &&
|
||||
nsSVGUtils::HitTestClip(this, aPoint)) {
|
||||
|
@ -3750,7 +3750,7 @@ nsSVGTextFrame2::ReflowSVG()
|
|||
mRect.SetEmpty();
|
||||
} else {
|
||||
mRect =
|
||||
nsLayoutUtils::RoundGfxRectToAppRect(r, presContext->AppUnitsPerCSSPixel());
|
||||
nsLayoutUtils::RoundGfxRectToAppRect(r.ToThebesRect(), presContext->AppUnitsPerCSSPixel());
|
||||
|
||||
// Due to rounding issues when we have a transform applied, we sometimes
|
||||
// don't include an additional row of pixels. For now, just inflate our
|
||||
|
@ -5325,7 +5325,7 @@ nsSVGTextFrame2::TransformFramePointToTextChild(const gfxPoint& aPoint,
|
|||
uint32_t flags = TextRenderedRun::eIncludeFill |
|
||||
TextRenderedRun::eIncludeStroke |
|
||||
TextRenderedRun::eNoHorizontalOverflow;
|
||||
gfxRect runRect = run.GetRunUserSpaceRect(presContext, flags);
|
||||
gfxRect runRect = run.GetRunUserSpaceRect(presContext, flags).ToThebesRect();
|
||||
|
||||
gfxPoint pointInRunUserSpace =
|
||||
run.GetTransformFromRunUserSpaceToUserSpace(presContext).Invert().
|
||||
|
@ -5414,7 +5414,7 @@ nsSVGTextFrame2::TransformFrameRectToTextChild(const gfxRect& aRect,
|
|||
continue;
|
||||
}
|
||||
gfxRect runIntersectionInFrameUserSpace =
|
||||
incomingRectInFrameUserSpace.Intersect(runRectInFrameUserSpace);
|
||||
incomingRectInFrameUserSpace.Intersect(runRectInFrameUserSpace.ToThebesRect());
|
||||
|
||||
if (!runIntersectionInFrameUserSpace.IsEmpty()) {
|
||||
// Take the font size scale into account.
|
||||
|
@ -5476,7 +5476,7 @@ nsSVGTextFrame2::TransformFrameRectFromTextChild(const nsRect& aRect,
|
|||
uint32_t flags = TextRenderedRun::eIncludeFill |
|
||||
TextRenderedRun::eIncludeStroke;
|
||||
rectInFrameUserSpace.IntersectRect
|
||||
(rectInFrameUserSpace, run.GetFrameUserSpaceRect(presContext, flags));
|
||||
(rectInFrameUserSpace, run.GetFrameUserSpaceRect(presContext, flags).ToThebesRect());
|
||||
|
||||
if (!rectInFrameUserSpace.IsEmpty()) {
|
||||
// Transform it up to user space of the <text>, also taking into
|
||||
|
|
|
@ -1241,7 +1241,7 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags)
|
|||
matrix = element->PrependLocalTransformsTo(matrix,
|
||||
nsSVGElement::eChildToUserSpace);
|
||||
}
|
||||
return svg->GetBBoxContribution(matrix, aFlags);
|
||||
return svg->GetBBoxContribution(matrix, aFlags).ToThebesRect();
|
||||
}
|
||||
return nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame(aFrame);
|
||||
}
|
||||
|
@ -1857,7 +1857,7 @@ nsSVGUtils::GetSVGGlyphExtents(Element* aElement,
|
|||
*aResult = svgFrame->GetBBoxContribution(transform,
|
||||
nsSVGUtils::eBBoxIncludeFill | nsSVGUtils::eBBoxIncludeFillGeometry |
|
||||
nsSVGUtils::eBBoxIncludeStroke | nsSVGUtils::eBBoxIncludeStrokeGeometry |
|
||||
nsSVGUtils::eBBoxIncludeMarkers);
|
||||
nsSVGUtils::eBBoxIncludeMarkers).ToThebesRect();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "DrawMode.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxMatrix.h"
|
||||
#include "gfxPoint.h"
|
||||
#include "gfxRect.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsColor.h"
|
||||
|
@ -141,21 +143,20 @@ bool NS_SVGTextCSSFramesEnabled();
|
|||
* that contains an element that has no size e.g. a point at the origin.
|
||||
*/
|
||||
class SVGBBox {
|
||||
typedef mozilla::gfx::Rect Rect;
|
||||
|
||||
public:
|
||||
SVGBBox()
|
||||
: mIsEmpty(true) {}
|
||||
|
||||
SVGBBox(const gfxRect& aRect)
|
||||
SVGBBox(const Rect& aRect)
|
||||
: mBBox(aRect), mIsEmpty(false) {}
|
||||
|
||||
SVGBBox& operator=(const gfxRect& aRect) {
|
||||
mBBox = aRect;
|
||||
mIsEmpty = false;
|
||||
return *this;
|
||||
}
|
||||
SVGBBox(const gfxRect& aRect)
|
||||
: mBBox(ToRect(aRect)), mIsEmpty(false) {}
|
||||
|
||||
operator const gfxRect& () const {
|
||||
return mBBox;
|
||||
gfxRect ToThebesRect() const {
|
||||
return ThebesRect(mBBox);
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
|
@ -171,8 +172,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
gfxRect mBBox;
|
||||
bool mIsEmpty;
|
||||
Rect mBBox;
|
||||
bool mIsEmpty;
|
||||
};
|
||||
|
||||
// GRRR WINDOWS HATE HATE HATE
|
||||
|
|
Загрузка…
Ссылка в новой задаче