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

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

Issue 368003002: Check if drawFocusRingMaskWithFrame:inView: exists when drawing focus ring (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/mac/WebCoreNSCellExtras.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/mac/ThemeMac.mm
diff --git a/Source/platform/mac/ThemeMac.mm b/Source/platform/mac/ThemeMac.mm
index 2d068d08799863c90625f9bf37b8e86b16dc6eda..d282d3f3a44298ea9d61e6fe7d72a3341a394e4d 100644
--- a/Source/platform/mac/ThemeMac.mm
+++ b/Source/platform/mac/ThemeMac.mm
@@ -141,13 +141,13 @@ static void updateStates(NSCell* cell, ControlStates states)
if (enabled != oldEnabled)
[cell setEnabled:enabled];
-#if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
- // Focused state
- bool oldFocused = [cell showsFirstResponder];
- bool focused = states & FocusControlState;
- if (focused != oldFocused)
- [cell setShowsFirstResponder:focused];
-#endif
+ if (ThemeMac::drawWithFrameDrawsFocusRing()) {
+ // Focused state
+ bool oldFocused = [cell showsFirstResponder];
+ bool focused = states & FocusControlState;
+ if (focused != oldFocused)
+ [cell setShowsFirstResponder:focused];
+ }
// Checked and Indeterminate
bool oldIndeterminate = [cell state] == NSMixedState;
@@ -214,20 +214,20 @@ IntRect ThemeMac::inflateRectForAA(const IntRect& rect) {
// 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
+ if (ThemeMac::drawWithFrameDrawsFocusRing()) {
+ // 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;
+ }
}
// Checkboxes
@@ -305,10 +305,8 @@ static void paintCheckbox(ControlStates states, GraphicsContext* context, const
LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFocusRing(inflatedRect));
NSView* view = ensuredView(scrollableArea);
[checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view];
-#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
- if (states & FocusControlState)
- [checkboxCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
-#endif
+ if (!ThemeMac::drawWithFrameDrawsFocusRing() && states & FocusControlState)
+ [checkboxCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
[checkboxCell setControlView:nil];
END_BLOCK_OBJC_EXCEPTIONS
@@ -388,10 +386,8 @@ static void paintRadio(ControlStates states, GraphicsContext* context, const Int
BEGIN_BLOCK_OBJC_EXCEPTIONS
NSView* view = ensuredView(scrollableArea);
[radioCell drawWithFrame:NSRect(inflatedRect) inView:view];
-#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
- if (states & FocusControlState)
- [radioCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
-#endif
+ if (!ThemeMac::drawWithFrameDrawsFocusRing() && states & FocusControlState)
+ [radioCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
[radioCell setControlView:nil];
END_BLOCK_OBJC_EXCEPTIONS
}
@@ -481,10 +477,8 @@ static void paintButton(ControlPart part, ControlStates states, GraphicsContext*
NSView* view = ensuredView(scrollableArea);
[buttonCell drawWithFrame:NSRect(inflatedRect) inView:view];
-#if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
- if (states & FocusControlState)
- [buttonCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
-#endif
+ if (!ThemeMac::drawWithFrameDrawsFocusRing() && states & FocusControlState)
+ [buttonCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view];
[buttonCell setControlView:nil];
END_BLOCK_OBJC_EXCEPTIONS
@@ -718,4 +712,14 @@ void ThemeMac::paint(ControlPart part, ControlStates states, GraphicsContext* co
}
}
+#ifndef NSAppKitVersionNumber10_9
+#define NSAppKitVersionNumber10_9 1265
+#endif
+
+bool ThemeMac::drawWithFrameDrawsFocusRing()
+{
+ // drawWithFrame has changed in 10.10 Yosemite and it does not draw the focus ring.
+ return floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_9;
+}
+
}
« no previous file with comments | « Source/platform/mac/ThemeMac.h ('k') | Source/platform/mac/WebCoreNSCellExtras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698