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

Unified Diff: Source/platform/mac/ThemeMac.mm

Issue 536973002: Revert 180822 "Specify clip rects when drawing Mac native widgets" (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2145/
Patch Set: Created 6 years, 3 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 | « Source/platform/mac/ThemeMac.h ('k') | Source/platform/scroll/ScrollbarThemeMacNonOverlayAPI.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/mac/ThemeMac.mm
===================================================================
--- Source/platform/mac/ThemeMac.mm (revision 181329)
+++ Source/platform/mac/ThemeMac.mm (working copy)
@@ -89,6 +89,13 @@
namespace blink {
+enum {
+ topMargin,
+ rightMargin,
+ bottomMargin,
+ leftMargin
+};
+
Theme* platformTheme()
{
DEFINE_STATIC_LOCAL(ThemeMac, themeMac, ());
@@ -195,49 +202,24 @@
return kThemeStateActive;
}
-// static
-IntRect ThemeMac::inflateRect(const IntRect& zoomedRect, const IntSize& zoomedSize, const int* margins, float zoomFactor)
+static IntRect inflateRect(const IntRect& zoomedRect, const IntSize& zoomedSize, const int* margins, float zoomFactor)
{
// Only do the inflation if the available width/height are too small. Otherwise try to
// fit the glow/check space into the available box's width/height.
- int widthDelta = zoomedRect.width() - (zoomedSize.width() + margins[LeftMargin] * zoomFactor + margins[RightMargin] * zoomFactor);
- int heightDelta = zoomedRect.height() - (zoomedSize.height() + margins[TopMargin] * zoomFactor + margins[BottomMargin] * zoomFactor);
+ int widthDelta = zoomedRect.width() - (zoomedSize.width() + margins[leftMargin] * zoomFactor + margins[rightMargin] * zoomFactor);
+ int heightDelta = zoomedRect.height() - (zoomedSize.height() + margins[topMargin] * zoomFactor + margins[bottomMargin] * zoomFactor);
IntRect result(zoomedRect);
if (widthDelta < 0) {
- result.setX(result.x() - margins[LeftMargin] * zoomFactor);
+ result.setX(result.x() - margins[leftMargin] * zoomFactor);
result.setWidth(result.width() - widthDelta);
}
if (heightDelta < 0) {
- result.setY(result.y() - margins[TopMargin] * zoomFactor);
+ result.setY(result.y() - margins[topMargin] * zoomFactor);
result.setHeight(result.height() - heightDelta);
}
return result;
}
-// static
-IntRect ThemeMac::inflateRectForAA(const IntRect& rect) {
- const int margin = 2;
- return IntRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin, rect.height() + 2 * margin);
-}
-
-// static
-IntRect ThemeMac::inflateRectForFocusRing(const IntRect& rect) {
-#if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
- // Just put a margin of 16 units around the rect. The UI elements that use this don't appropriately
- // scale their focus rings appropriately (e.g, paint pickers), or switch to non-native widgets when
- // scaled (e.g, check boxes and radio buttons).
- const int margin = 16;
- IntRect result;
- result.setX(rect.x() - margin);
- result.setY(rect.y() - margin);
- result.setWidth(rect.width() + 2 * margin);
- result.setHeight(rect.height() + 2 * margin);
- return result;
-#else
- return rect;
-#endif
-}
-
// Checkboxes
static const IntSize* checkboxSizes()
@@ -300,7 +282,7 @@
IntSize zoomedSize = checkboxSizes()[controlSize];
zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- IntRect inflatedRect = ThemeMac::inflateRect(zoomedRect, zoomedSize, checkboxMargins(controlSize), zoomFactor);
+ IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, checkboxMargins(controlSize), zoomFactor);
if (zoomFactor != 1.0f) {
inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
@@ -310,7 +292,7 @@
context->translate(-inflatedRect.x(), -inflatedRect.y());
}
- LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFocusRing(inflatedRect));
+ LocalCurrentGraphicsContext localContext(context);
NSView *view = ThemeMac::ensuredView(scrollView);
[checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view];
#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
@@ -382,7 +364,7 @@
IntSize zoomedSize = radioSizes()[controlSize];
zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- IntRect inflatedRect = ThemeMac::inflateRect(zoomedRect, zoomedSize, radioMargins(controlSize), zoomFactor);
+ IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, radioMargins(controlSize), zoomFactor);
if (zoomFactor != 1.0f) {
inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
@@ -392,7 +374,7 @@
context->translate(-inflatedRect.x(), -inflatedRect.y());
}
- LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFocusRing(inflatedRect));
+ LocalCurrentGraphicsContext localContext(context);
BEGIN_BLOCK_OBJC_EXCEPTIONS
NSView *view = ThemeMac::ensuredView(scrollView);
[radioCell drawWithFrame:NSRect(inflatedRect) inView:view];
@@ -474,7 +456,7 @@
}
// Now inflate it to account for the shadow.
- inflatedRect = ThemeMac::inflateRect(inflatedRect, zoomedSize, buttonMargins(controlSize), zoomFactor);
+ inflatedRect = inflateRect(inflatedRect, zoomedSize, buttonMargins(controlSize), zoomFactor);
if (zoomFactor != 1.0f) {
inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
@@ -485,7 +467,7 @@
}
}
- LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFocusRing(inflatedRect));
+ LocalCurrentGraphicsContext localContext(context);
NSView *view = ThemeMac::ensuredView(scrollView);
[buttonCell drawWithFrame:NSRect(inflatedRect) inView:view];
@@ -554,7 +536,7 @@
backgroundBounds.origin.y = bounds.origin.y + (heightDiff / 2) + 1;
}
- LocalCurrentGraphicsContext localContext(context, rect);
+ LocalCurrentGraphicsContext localContext(context);
HIThemeDrawButton(&backgroundBounds, &drawInfo, localContext.cgContext(), kHIThemeOrientationNormal, 0);
}
« no previous file with comments | « Source/platform/mac/ThemeMac.h ('k') | Source/platform/scroll/ScrollbarThemeMacNonOverlayAPI.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698