mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 922942 - Avoid crashes with PointInFill. r=Bas
--HG-- extra : rebase_source : cf209258a71342590c3d3488912d85df86a14b8b
This commit is contained in:
parent
0604fa2aa9
commit
60bb7765a1
@ -241,6 +241,9 @@ PathCG::GetBounds(const Matrix &aTransform) const
|
||||
{
|
||||
//XXX: are these bounds tight enough
|
||||
Rect bounds = CGRectToRect(CGPathGetBoundingBox(mPath));
|
||||
if (!bounds.IsFinite()) {
|
||||
return Rect();
|
||||
}
|
||||
//XXX: curretnly this returns the bounds of the transformed bounds
|
||||
// this is strictly looser than the bounds of the transformed path
|
||||
return aTransform.TransformBounds(bounds);
|
||||
@ -266,6 +269,10 @@ PathCG::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
|
||||
|
||||
CGContextRestoreGState(cg);
|
||||
|
||||
if (!bounds.IsFinite()) {
|
||||
return Rect();
|
||||
}
|
||||
|
||||
return aTransform.TransformBounds(bounds);
|
||||
}
|
||||
|
||||
|
@ -332,35 +332,37 @@ PathD2D::StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
|
||||
Rect
|
||||
PathD2D::GetBounds(const Matrix &aTransform) const
|
||||
{
|
||||
D2D1_RECT_F bounds;
|
||||
D2D1_RECT_F d2dBounds;
|
||||
|
||||
HRESULT hr = mGeometry->GetBounds(D2DMatrix(aTransform), &bounds);
|
||||
HRESULT hr = mGeometry->GetBounds(D2DMatrix(aTransform), &d2dBounds);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
Rect bounds = ToRect(d2dBounds);
|
||||
if (FAILED(hr) || !bounds.IsFinite()) {
|
||||
gfxWarning() << "Failed to get stroked bounds for path. Code: " << hr;
|
||||
bounds.bottom = bounds.left = bounds.right = bounds.top = 0;
|
||||
return Rect();
|
||||
}
|
||||
|
||||
return ToRect(bounds);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
Rect
|
||||
PathD2D::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
|
||||
const Matrix &aTransform) const
|
||||
{
|
||||
D2D1_RECT_F bounds;
|
||||
D2D1_RECT_F d2dBounds;
|
||||
|
||||
RefPtr<ID2D1StrokeStyle> strokeStyle = CreateStrokeStyleForOptions(aStrokeOptions);
|
||||
HRESULT hr =
|
||||
mGeometry->GetWidenedBounds(aStrokeOptions.mLineWidth, strokeStyle,
|
||||
D2DMatrix(aTransform), &bounds);
|
||||
D2DMatrix(aTransform), &d2dBounds);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
Rect bounds = ToRect(d2dBounds);
|
||||
if (FAILED(hr) || !bounds.IsFinite()) {
|
||||
gfxWarning() << "Failed to get stroked bounds for path. Code: " << hr;
|
||||
bounds.bottom = bounds.left = bounds.right = bounds.top = 0;
|
||||
return Rect();
|
||||
}
|
||||
|
||||
return ToRect(bounds);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1713,7 +1713,8 @@ gfxContext::PointInFill(const gfxPoint& pt)
|
||||
if (mCairo) {
|
||||
return cairo_in_fill(mCairo, pt.x, pt.y);
|
||||
} else {
|
||||
return mPath->ContainsPoint(ToPoint(pt), mTransform);
|
||||
EnsurePath();
|
||||
return mPath->ContainsPoint(ToPoint(pt), Matrix());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1723,9 +1724,10 @@ gfxContext::PointInStroke(const gfxPoint& pt)
|
||||
if (mCairo) {
|
||||
return cairo_in_stroke(mCairo, pt.x, pt.y);
|
||||
} else {
|
||||
EnsurePath();
|
||||
return mPath->StrokeContainsPoint(CurrentState().strokeOptions,
|
||||
ToPoint(pt),
|
||||
mTransform);
|
||||
Matrix());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1737,6 +1739,7 @@ gfxContext::GetUserPathExtent()
|
||||
cairo_path_extents(mCairo, &xmin, &ymin, &xmax, &ymax);
|
||||
return gfxRect(xmin, ymin, xmax - xmin, ymax - ymin);
|
||||
} else {
|
||||
EnsurePath();
|
||||
return ThebesRect(mPath->GetBounds());
|
||||
}
|
||||
}
|
||||
@ -1749,6 +1752,7 @@ gfxContext::GetUserFillExtent()
|
||||
cairo_fill_extents(mCairo, &xmin, &ymin, &xmax, &ymax);
|
||||
return gfxRect(xmin, ymin, xmax - xmin, ymax - ymin);
|
||||
} else {
|
||||
EnsurePath();
|
||||
return ThebesRect(mPath->GetBounds());
|
||||
}
|
||||
}
|
||||
@ -1761,6 +1765,7 @@ gfxContext::GetUserStrokeExtent()
|
||||
cairo_stroke_extents(mCairo, &xmin, &ymin, &xmax, &ymax);
|
||||
return gfxRect(xmin, ymin, xmax - xmin, ymax - ymin);
|
||||
} else {
|
||||
EnsurePath();
|
||||
return ThebesRect(mPath->GetStrokedBounds(CurrentState().strokeOptions, mTransform));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user