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

Side by Side Diff: Source/platform/mac/ThemeMac.mm

Issue 1184073004: Revert of 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/ThemePainterMac.mm ('k') | Source/platform/mac/WebCoreNSCellExtras.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2010, 2011, 2012 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2010, 2011, 2012 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 bool pressed = states & PressedControlState; 134 bool pressed = states & PressedControlState;
135 if (pressed != oldPressed) 135 if (pressed != oldPressed)
136 [cell setHighlighted:pressed]; 136 [cell setHighlighted:pressed];
137 137
138 // Enabled state 138 // Enabled state
139 bool oldEnabled = [cell isEnabled]; 139 bool oldEnabled = [cell isEnabled];
140 bool enabled = states & EnabledControlState; 140 bool enabled = states & EnabledControlState;
141 if (enabled != oldEnabled) 141 if (enabled != oldEnabled)
142 [cell setEnabled:enabled]; 142 [cell setEnabled:enabled];
143 143
144 if (![cell respondsToSelector:@selector(drawFocusRingMaskWithFrame:inView:)] ) { 144 #if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
145 // Focused state 145 // Focused state
146 bool oldFocused = [cell showsFirstResponder]; 146 bool oldFocused = [cell showsFirstResponder];
147 bool focused = states & FocusControlState; 147 bool focused = states & FocusControlState;
148 if (focused != oldFocused) 148 if (focused != oldFocused)
149 [cell setShowsFirstResponder:focused]; 149 [cell setShowsFirstResponder:focused];
150 } 150 #endif
151 151
152 // Checked and Indeterminate 152 // Checked and Indeterminate
153 bool oldIndeterminate = [cell state] == NSMixedState; 153 bool oldIndeterminate = [cell state] == NSMixedState;
154 bool indeterminate = (states & IndeterminateControlState); 154 bool indeterminate = (states & IndeterminateControlState);
155 bool checked = states & CheckedControlState; 155 bool checked = states & CheckedControlState;
156 bool oldChecked = [cell state] == NSOnState; 156 bool oldChecked = [cell state] == NSOnState;
157 if (oldIndeterminate != indeterminate || checked != oldChecked) 157 if (oldIndeterminate != indeterminate || checked != oldChecked)
158 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO ffState)]; 158 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO ffState)];
159 159
160 // Window inactive state does not need to be checked explicitly, since we pa int parented to 160 // Window inactive state does not need to be checked explicitly, since we pa int parented to
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 // static 209 // static
210 IntRect ThemeMac::inflateRectForAA(const IntRect& rect) { 210 IntRect ThemeMac::inflateRectForAA(const IntRect& rect) {
211 const int margin = 2; 211 const int margin = 2;
212 return IntRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin , rect.height() + 2 * margin); 212 return IntRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin , rect.height() + 2 * margin);
213 } 213 }
214 214
215 // static 215 // static
216 IntRect ThemeMac::inflateRectForFocusRing(const IntRect& rect) { 216 IntRect ThemeMac::inflateRectForFocusRing(const IntRect& rect) {
217 #if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
217 // Just put a margin of 16 units around the rect. The UI elements that use t his don't appropriately 218 // Just put a margin of 16 units around the rect. The UI elements that use t his don't appropriately
218 // scale their focus rings appropriately (e.g, paint pickers), or switch to non-native widgets when 219 // scale their focus rings appropriately (e.g, paint pickers), or switch to non-native widgets when
219 // scaled (e.g, check boxes and radio buttons). 220 // scaled (e.g, check boxes and radio buttons).
220 const int margin = 16; 221 const int margin = 16;
221 IntRect result; 222 IntRect result;
222 result.setX(rect.x() - margin); 223 result.setX(rect.x() - margin);
223 result.setY(rect.y() - margin); 224 result.setY(rect.y() - margin);
224 result.setWidth(rect.width() + 2 * margin); 225 result.setWidth(rect.width() + 2 * margin);
225 result.setHeight(rect.height() + 2 * margin); 226 result.setHeight(rect.height() + 2 * margin);
226 return result; 227 return result;
228 #else
229 return rect;
230 #endif
227 } 231 }
228 232
229 // Checkboxes 233 // Checkboxes
230 234
231 static const IntSize* checkboxSizes() 235 static const IntSize* checkboxSizes()
232 { 236 {
233 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize( 10, 10) }; 237 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize( 10, 10) };
234 return sizes; 238 return sizes;
235 } 239 }
236 240
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); 298 inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
295 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); 299 inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
296 context->translate(inflatedRect.x(), inflatedRect.y()); 300 context->translate(inflatedRect.x(), inflatedRect.y());
297 context->scale(zoomFactor, zoomFactor); 301 context->scale(zoomFactor, zoomFactor);
298 context->translate(-inflatedRect.x(), -inflatedRect.y()); 302 context->translate(-inflatedRect.x(), -inflatedRect.y());
299 } 303 }
300 304
301 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo cusRing(inflatedRect)); 305 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo cusRing(inflatedRect));
302 NSView* view = ensuredView(scrollableArea); 306 NSView* view = ensuredView(scrollableArea);
303 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view]; 307 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view];
308 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
304 if (states & FocusControlState) 309 if (states & FocusControlState)
305 [checkboxCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view ]; 310 [checkboxCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:vi ew];
311 #endif
306 [checkboxCell setControlView:nil]; 312 [checkboxCell setControlView:nil];
307 313
308 END_BLOCK_OBJC_EXCEPTIONS 314 END_BLOCK_OBJC_EXCEPTIONS
309 } 315 }
310 316
311 // Radio Buttons 317 // Radio Buttons
312 318
313 static const IntSize* radioSizes() 319 static const IntSize* radioSizes()
314 { 320 {
315 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize( 10, 10) }; 321 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize( 10, 10) };
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); 381 inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
376 context->translate(inflatedRect.x(), inflatedRect.y()); 382 context->translate(inflatedRect.x(), inflatedRect.y());
377 context->scale(zoomFactor, zoomFactor); 383 context->scale(zoomFactor, zoomFactor);
378 context->translate(-inflatedRect.x(), -inflatedRect.y()); 384 context->translate(-inflatedRect.x(), -inflatedRect.y());
379 } 385 }
380 386
381 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo cusRing(inflatedRect)); 387 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo cusRing(inflatedRect));
382 BEGIN_BLOCK_OBJC_EXCEPTIONS 388 BEGIN_BLOCK_OBJC_EXCEPTIONS
383 NSView* view = ensuredView(scrollableArea); 389 NSView* view = ensuredView(scrollableArea);
384 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view]; 390 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view];
391 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
385 if (states & FocusControlState) 392 if (states & FocusControlState)
386 [radioCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]; 393 [radioCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view] ;
394 #endif
387 [radioCell setControlView:nil]; 395 [radioCell setControlView:nil];
388 END_BLOCK_OBJC_EXCEPTIONS 396 END_BLOCK_OBJC_EXCEPTIONS
389 } 397 }
390 398
391 // Buttons 399 // Buttons
392 400
393 // Buttons really only constrain height. They respect width. 401 // Buttons really only constrain height. They respect width.
394 static const IntSize* buttonSizes() 402 static const IntSize* buttonSizes()
395 { 403 {
396 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) }; 404 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) };
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 context->translate(inflatedRect.x(), inflatedRect.y()); 474 context->translate(inflatedRect.x(), inflatedRect.y());
467 context->scale(zoomFactor, zoomFactor); 475 context->scale(zoomFactor, zoomFactor);
468 context->translate(-inflatedRect.x(), -inflatedRect.y()); 476 context->translate(-inflatedRect.x(), -inflatedRect.y());
469 } 477 }
470 } 478 }
471 479
472 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo cusRing(inflatedRect)); 480 LocalCurrentGraphicsContext localContext(context, ThemeMac::inflateRectForFo cusRing(inflatedRect));
473 NSView* view = ensuredView(scrollableArea); 481 NSView* view = ensuredView(scrollableArea);
474 482
475 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view]; 483 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view];
484 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
476 if (states & FocusControlState) 485 if (states & FocusControlState)
477 [buttonCell cr_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view]; 486 [buttonCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view ];
487 #endif
478 [buttonCell setControlView:nil]; 488 [buttonCell setControlView:nil];
479 489
480 END_BLOCK_OBJC_EXCEPTIONS 490 END_BLOCK_OBJC_EXCEPTIONS
481 } 491 }
482 492
483 // Stepper 493 // Stepper
484 494
485 static const IntSize* stepperSizes() 495 static const IntSize* stepperSizes()
486 { 496 {
487 static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize( 13, 15) }; 497 static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize( 13, 15) };
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 break; 712 break;
703 case InnerSpinButtonPart: 713 case InnerSpinButtonPart:
704 paintStepper(states, context, zoomedRect, zoomFactor, scrollableArea ); 714 paintStepper(states, context, zoomedRect, zoomFactor, scrollableArea );
705 break; 715 break;
706 default: 716 default:
707 break; 717 break;
708 } 718 }
709 } 719 }
710 720
711 } 721 }
OLDNEW
« no previous file with comments | « Source/core/paint/ThemePainterMac.mm ('k') | Source/platform/mac/WebCoreNSCellExtras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698