Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1090)

Unified Diff: third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.mm

Issue 1956583002: Clamp Mac theme painting to reasonable large bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Increase max dirty pixel size to 10K. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.mm
diff --git a/third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.mm b/third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.mm
index cb50058ead46f319891930a36e83fdad78b86378..e029f205cb5dba48c2033cfb9da567596a81073a 100644
--- a/third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.mm
+++ b/third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.mm
@@ -27,18 +27,22 @@
namespace blink {
LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphicsContext, const IntRect& dirtyRect)
- : LocalCurrentGraphicsContext(graphicsContext.canvas(), graphicsContext.deviceScaleFactor(), nullptr, dirtyRect)
+ : LocalCurrentGraphicsContext(graphicsContext.canvas(), graphicsContext.deviceScaleFactor(), dirtyRect)
{
}
-LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphicsContext, const IntRect* interestRect,
- const IntRect& dirtyRect)
- : LocalCurrentGraphicsContext(graphicsContext.canvas(), graphicsContext.deviceScaleFactor(), interestRect, dirtyRect)
+static IntRect clampRect(int size, const IntRect& rect)
{
+ IntRect clampedRect(rect);
+ clampedRect.setSize(IntSize(
+ std::min(size, clampedRect.width()),
+ std::min(size, clampedRect.height())));
+ return clampedRect;
}
-LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(SkCanvas* canvas, float deviceScaleFactor, const IntRect* interestRect,
- const IntRect& dirtyRect)
+static const int kMaxDirtyPixelSize = 10000;
chrishtr 2016/05/09 21:42:20 kMaxDirtyRectPixelSize?
wkorman 2016/05/09 22:14:24 Done.
+
+LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(SkCanvas* canvas, float deviceScaleFactor, const IntRect& dirtyRect)
: m_didSetGraphicsContext(false)
, m_inflatedDirtyRect(ThemeMac::inflateRectForAA(dirtyRect))
, m_skiaBitLocker(canvas,
@@ -48,12 +52,11 @@ LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(SkCanvas* canvas, float
m_savedCanvas = canvas;
canvas->save();
- bool clipToInterest = interestRect && !interestRect->contains(m_inflatedDirtyRect);
- if (clipToInterest) {
- IntRect clippedBounds(m_inflatedDirtyRect);
- clippedBounds.intersect(*interestRect);
- canvas->clipRect(clippedBounds, SkRegion::kIntersect_Op);
- }
+ // Constrain the maximum size of what we paint to something reasonable. This accordingly
+ // means we will not paint the entirety of truly huge native form elements, which is
+ // deemed an acceptable tradeoff for this simple approach to manage such an edge case.
+ if (dirtyRect.width() > kMaxDirtyPixelSize || dirtyRect.height() > kMaxDirtyPixelSize)
+ canvas->clipRect(clampRect(kMaxDirtyPixelSize, dirtyRect), SkRegion::kIntersect_Op);
CGContextRef cgContext = this->cgContext();
if (cgContext == [[NSGraphicsContext currentContext] graphicsPort]) {

Powered by Google App Engine
This is Rietveld 408576698