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

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: Integrate feedback. 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
« no previous file with comments | « third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5f76f5315d3598ff48dea4af99a62657966e5961 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 kMaxDirtyRectPixelSize = 10000;
+
+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() > kMaxDirtyRectPixelSize || dirtyRect.height() > kMaxDirtyRectPixelSize)
+ canvas->clipRect(clampRect(kMaxDirtyRectPixelSize, dirtyRect), SkRegion::kIntersect_Op);
CGContextRef cgContext = this->cgContext();
if (cgContext == [[NSGraphicsContext currentContext] graphicsPort]) {
« no previous file with comments | « third_party/WebKit/Source/platform/mac/LocalCurrentGraphicsContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698