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

Side by Side 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 6 years, 4 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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 bool oldPressed = [cell isHighlighted]; 160 bool oldPressed = [cell isHighlighted];
161 bool pressed = states & PressedControlState; 161 bool pressed = states & PressedControlState;
162 if (pressed != oldPressed) 162 if (pressed != oldPressed)
163 [cell setHighlighted:pressed]; 163 [cell setHighlighted:pressed];
164 164
165 // Enabled state 165 // Enabled state
166 bool oldEnabled = [cell isEnabled]; 166 bool oldEnabled = [cell isEnabled];
167 bool enabled = states & EnabledControlState; 167 bool enabled = states & EnabledControlState;
168 if (enabled != oldEnabled) 168 if (enabled != oldEnabled)
169 [cell setEnabled:enabled]; 169 [cell setEnabled:enabled];
170 170
171 #if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
172 // Focused state 171 // Focused state
173 bool oldFocused = [cell showsFirstResponder]; 172 bool oldFocused = [cell showsFirstResponder];
174 bool focused = states & FocusControlState; 173 bool focused = states & FocusControlState;
175 if (focused != oldFocused) 174 if (focused != oldFocused)
176 [cell setShowsFirstResponder:focused]; 175 [cell setShowsFirstResponder:focused];
177 #endif
178 176
179 // Checked and Indeterminate 177 // Checked and Indeterminate
180 bool oldIndeterminate = [cell state] == NSMixedState; 178 bool oldIndeterminate = [cell state] == NSMixedState;
181 bool indeterminate = (states & IndeterminateControlState); 179 bool indeterminate = (states & IndeterminateControlState);
182 bool checked = states & CheckedControlState; 180 bool checked = states & CheckedControlState;
183 bool oldChecked = [cell state] == NSOnState; 181 bool oldChecked = [cell state] == NSOnState;
184 if (oldIndeterminate != indeterminate || checked != oldChecked) 182 if (oldIndeterminate != indeterminate || checked != oldChecked)
185 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO ffState)]; 183 [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSO ffState)];
186 184
187 // Window inactive state does not need to be checked explicitly, since we pa int parented to 185 // Window inactive state does not need to be checked explicitly, since we pa int parented to
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 inflatedRect.setWidth(inflatedRect.width() / zoomFactor); 288 inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
291 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); 289 inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
292 context->translate(inflatedRect.x(), inflatedRect.y()); 290 context->translate(inflatedRect.x(), inflatedRect.y());
293 context->scale(zoomFactor, zoomFactor); 291 context->scale(zoomFactor, zoomFactor);
294 context->translate(-inflatedRect.x(), -inflatedRect.y()); 292 context->translate(-inflatedRect.x(), -inflatedRect.y());
295 } 293 }
296 294
297 LocalCurrentGraphicsContext localContext(context); 295 LocalCurrentGraphicsContext localContext(context);
298 NSView *view = ThemeMac::ensuredView(scrollView); 296 NSView *view = ThemeMac::ensuredView(scrollView);
299 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view]; 297 [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:view];
300 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
301 if (states & FocusControlState) 298 if (states & FocusControlState)
302 [checkboxCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:vi ew]; 299 [checkboxCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:vi ew];
303 #endif
304 [checkboxCell setControlView:nil]; 300 [checkboxCell setControlView:nil];
305 301
306 END_BLOCK_OBJC_EXCEPTIONS 302 END_BLOCK_OBJC_EXCEPTIONS
307 } 303 }
308 304
309 // Radio Buttons 305 // Radio Buttons
310 306
311 static const IntSize* radioSizes() 307 static const IntSize* radioSizes()
312 { 308 {
313 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize( 10, 10) }; 309 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize( 10, 10) };
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 inflatedRect.setHeight(inflatedRect.height() / zoomFactor); 367 inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
372 context->translate(inflatedRect.x(), inflatedRect.y()); 368 context->translate(inflatedRect.x(), inflatedRect.y());
373 context->scale(zoomFactor, zoomFactor); 369 context->scale(zoomFactor, zoomFactor);
374 context->translate(-inflatedRect.x(), -inflatedRect.y()); 370 context->translate(-inflatedRect.x(), -inflatedRect.y());
375 } 371 }
376 372
377 LocalCurrentGraphicsContext localContext(context); 373 LocalCurrentGraphicsContext localContext(context);
378 BEGIN_BLOCK_OBJC_EXCEPTIONS 374 BEGIN_BLOCK_OBJC_EXCEPTIONS
379 NSView *view = ThemeMac::ensuredView(scrollView); 375 NSView *view = ThemeMac::ensuredView(scrollView);
380 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view]; 376 [radioCell drawWithFrame:NSRect(inflatedRect) inView:view];
381 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
382 if (states & FocusControlState) 377 if (states & FocusControlState)
383 [radioCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view] ; 378 [radioCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view] ;
384 #endif
385 [radioCell setControlView:nil]; 379 [radioCell setControlView:nil];
386 END_BLOCK_OBJC_EXCEPTIONS 380 END_BLOCK_OBJC_EXCEPTIONS
387 } 381 }
388 382
389 // Buttons 383 // Buttons
390 384
391 // Buttons really only constrain height. They respect width. 385 // Buttons really only constrain height. They respect width.
392 static const IntSize* buttonSizes() 386 static const IntSize* buttonSizes()
393 { 387 {
394 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) }; 388 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
464 context->translate(inflatedRect.x(), inflatedRect.y()); 458 context->translate(inflatedRect.x(), inflatedRect.y());
465 context->scale(zoomFactor, zoomFactor); 459 context->scale(zoomFactor, zoomFactor);
466 context->translate(-inflatedRect.x(), -inflatedRect.y()); 460 context->translate(-inflatedRect.x(), -inflatedRect.y());
467 } 461 }
468 } 462 }
469 463
470 LocalCurrentGraphicsContext localContext(context); 464 LocalCurrentGraphicsContext localContext(context);
471 NSView *view = ThemeMac::ensuredView(scrollView); 465 NSView *view = ThemeMac::ensuredView(scrollView);
472 466
473 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view]; 467 [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view];
474 #if !BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING
475 if (states & FocusControlState) 468 if (states & FocusControlState)
476 [buttonCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view ]; 469 [buttonCell _web_drawFocusRingWithFrame:NSRect(inflatedRect) inView:view ];
477 #endif
478 [buttonCell setControlView:nil]; 470 [buttonCell setControlView:nil];
479 471
480 END_BLOCK_OBJC_EXCEPTIONS 472 END_BLOCK_OBJC_EXCEPTIONS
481 } 473 }
482 474
483 // Stepper 475 // Stepper
484 476
485 static const IntSize* stepperSizes() 477 static const IntSize* stepperSizes()
486 { 478 {
487 static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize( 13, 15) }; 479 static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize( 13, 15) };
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 break; 711 break;
720 case InnerSpinButtonPart: 712 case InnerSpinButtonPart:
721 paintStepper(states, context, zoomedRect, zoomFactor, scrollView); 713 paintStepper(states, context, zoomedRect, zoomFactor, scrollView);
722 break; 714 break;
723 default: 715 default:
724 break; 716 break;
725 } 717 }
726 } 718 }
727 719
728 } 720 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698