From 133e4768cdee607ebaa604748811639f49a1897d Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Fri, 10 Jun 2016 13:10:03 +0900 Subject: [PATCH] Bug 382721 - Part 6: Flush path while building long dotted/dashed border. r=jrmuizel --- layout/base/BorderConsts.h | 2 ++ layout/base/nsCSSRenderingBorders.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/layout/base/BorderConsts.h b/layout/base/BorderConsts.h index ce47dad206eb..2d129979ae7b 100644 --- a/layout/base/BorderConsts.h +++ b/layout/base/BorderConsts.h @@ -22,4 +22,6 @@ #define C_BR NS_CORNER_BOTTOM_RIGHT #define C_BL NS_CORNER_BOTTOM_LEFT +#define BORDER_SEGMENT_COUNT_MAX 100 + #endif /* mozilla_BorderConsts_h_ */ diff --git a/layout/base/nsCSSRenderingBorders.cpp b/layout/base/nsCSSRenderingBorders.cpp index 257a73c823d5..4579706d33ee 100644 --- a/layout/base/nsCSSRenderingBorders.cpp +++ b/layout/base/nsCSSRenderingBorders.cpp @@ -2103,10 +2103,19 @@ nsCSSBorderRenderer::DrawDottedSideSlow(mozilla::css::Side aSide) } RefPtr builder = mDrawTarget->CreatePathBuilder(); + size_t segmentCount = 0; for (size_t i = from; i <= to; i += 2) { + if (segmentCount > BORDER_SEGMENT_COUNT_MAX) { + RefPtr path = builder->Finish(); + mDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor))); + builder = mDrawTarget->CreatePathBuilder(); + segmentCount = 0; + } + Point P = (start * (count - i) + end * i) / count; builder->MoveTo(Point(P.x + radius, P.y)); builder->Arc(P, radius, 0.0f, Float(2.0 * M_PI)); + segmentCount++; } RefPtr path = builder->Finish(); mDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor))); @@ -2244,11 +2253,20 @@ nsCSSBorderRenderer::DrawDottedCornerSlow(mozilla::css::Side aSide, C0, R0, Cn, Rn, mBorderCornerDimensions[aCorner]); RefPtr builder = mDrawTarget->CreatePathBuilder(); + size_t segmentCount = 0; while (finder.HasMore()) { + if (segmentCount > BORDER_SEGMENT_COUNT_MAX) { + RefPtr path = builder->Finish(); + mDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor))); + builder = mDrawTarget->CreatePathBuilder(); + segmentCount = 0; + } + DottedCornerFinder::Result result = finder.Next(); builder->MoveTo(Point(result.C.x + result.r, result.C.y)); builder->Arc(result.C, result.r, 0, Float(2.0 * M_PI)); + segmentCount++; } RefPtr path = builder->Finish(); mDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor))); @@ -2279,7 +2297,15 @@ nsCSSBorderRenderer::DrawDashedCornerSlow(mozilla::css::Side aSide, mBorderCornerDimensions[aCorner]); RefPtr builder = mDrawTarget->CreatePathBuilder(); + size_t segmentCount = 0; while (finder.HasMore()) { + if (segmentCount > BORDER_SEGMENT_COUNT_MAX) { + RefPtr path = builder->Finish(); + mDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor))); + builder = mDrawTarget->CreatePathBuilder(); + segmentCount = 0; + } + DashedCornerFinder::Result result = finder.Next(); builder->MoveTo(result.outerSectionBezier.mPoints[0]); @@ -2291,6 +2317,7 @@ nsCSSBorderRenderer::DrawDashedCornerSlow(mozilla::css::Side aSide, result.innerSectionBezier.mPoints[1], result.innerSectionBezier.mPoints[0]); builder->LineTo(result.outerSectionBezier.mPoints[0]); + segmentCount++; } if (outerBezier.mPoints[0].x != innerBezier.mPoints[0].x) {