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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm

Issue 1952893002: [Mac][Material Design] Fix BookmarkBubbleControllerTest.TestBubbleWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove test code, update comments. 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 18 matching lines...) Expand all
29 // Matches the clipping radius of |GradientButtonCell|. 29 // Matches the clipping radius of |GradientButtonCell|.
30 const CGFloat kCornerRadius = 3.0; 30 const CGFloat kCornerRadius = 3.0;
31 31
32 // How far to inset the left- and right-hand decorations from the field's 32 // How far to inset the left- and right-hand decorations from the field's
33 // bounds. 33 // bounds.
34 const CGFloat kLeftDecorationXOffset = 5.0; 34 const CGFloat kLeftDecorationXOffset = 5.0;
35 const CGFloat kRightDecorationXOffset = 5.0; 35 const CGFloat kRightDecorationXOffset = 5.0;
36 36
37 // The amount of padding on either side reserved for drawing 37 // The amount of padding on either side reserved for drawing
38 // decorations. [Views has |kItemPadding| == 3.] 38 // decorations. [Views has |kItemPadding| == 3.]
39 const CGFloat kDecorationHorizontalPad = 3.0; 39 CGFloat DecorationsHorizontalPad() {
40 const CGFloat kDecorationHorizontalPad = 3.0;
41 const CGFloat kMaterialDecorationHorizontalPad = 4.0;
42 return ui::MaterialDesignController::IsModeMaterial()
43 ? kMaterialDecorationHorizontalPad
44 : kDecorationHorizontalPad;
45 }
40 46
41 const ui::NinePartImageIds kPopupBorderImageIds = 47 const ui::NinePartImageIds kPopupBorderImageIds =
42 IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER_AND_SHADOW); 48 IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER_AND_SHADOW);
43 49
44 const ui::NinePartImageIds kNormalBorderImageIds = IMAGE_GRID(IDR_TEXTFIELD); 50 const ui::NinePartImageIds kNormalBorderImageIds = IMAGE_GRID(IDR_TEXTFIELD);
45 51
46 // How long to wait for mouse-up on the location icon before assuming 52 // How long to wait for mouse-up on the location icon before assuming
47 // that the user wants to drag. 53 // that the user wants to drag.
48 const NSTimeInterval kLocationIconDragTimeout = 0.25; 54 const NSTimeInterval kLocationIconDragTimeout = 0.25;
49 55
(...skipping 14 matching lines...) Expand all
64 CGFloat regular_padding, 70 CGFloat regular_padding,
65 std::vector<LocationBarDecoration*>* decorations, 71 std::vector<LocationBarDecoration*>* decorations,
66 std::vector<NSRect>* decoration_frames, 72 std::vector<NSRect>* decoration_frames,
67 NSRect* remaining_frame) { 73 NSRect* remaining_frame) {
68 DCHECK(x_edge == NSMinXEdge || x_edge == NSMaxXEdge); 74 DCHECK(x_edge == NSMinXEdge || x_edge == NSMaxXEdge);
69 DCHECK_EQ(decorations->size(), decoration_frames->size()); 75 DCHECK_EQ(decorations->size(), decoration_frames->size());
70 76
71 // The initial padding depends on whether the first visible decoration is 77 // The initial padding depends on whether the first visible decoration is
72 // a button or not. 78 // a button or not.
73 bool is_first_visible_decoration = true; 79 bool is_first_visible_decoration = true;
80 const CGFloat kDecorationHorizontalPad = DecorationsHorizontalPad();
74 81
75 for (size_t i = 0; i < all_decorations.size(); ++i) { 82 for (size_t i = 0; i < all_decorations.size(); ++i) {
76 if (all_decorations[i]->IsVisible()) { 83 if (all_decorations[i]->IsVisible()) {
77 CGFloat padding = kDecorationHorizontalPad; 84 CGFloat padding = kDecorationHorizontalPad;
78 if (is_first_visible_decoration) { 85 if (is_first_visible_decoration) {
79 padding = regular_padding; 86 padding = regular_padding;
80 is_first_visible_decoration = false; 87 is_first_visible_decoration = false;
81 } 88 }
82 89
83 NSRect padding_rect, available; 90 NSRect padding_rect, available;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame { 272 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame {
266 std::vector<LocationBarDecoration*> decorations; 273 std::vector<LocationBarDecoration*> decorations;
267 std::vector<NSRect> decorationFrames; 274 std::vector<NSRect> decorationFrames;
268 NSRect textFrame; 275 NSRect textFrame;
269 size_t left_count = 276 size_t left_count =
270 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_, 277 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_,
271 &decorations, &decorationFrames, &textFrame); 278 &decorations, &decorationFrames, &textFrame);
272 279
273 // Determine the left-most extent for the i-beam cursor. 280 // Determine the left-most extent for the i-beam cursor.
274 CGFloat minX = NSMinX(textFrame); 281 CGFloat minX = NSMinX(textFrame);
282 const CGFloat kDecorationHorizontalPad = DecorationsHorizontalPad();
275 for (size_t index = left_count; index--; ) { 283 for (size_t index = left_count; index--; ) {
276 if (decorations[index]->AcceptsMousePress()) 284 if (decorations[index]->AcceptsMousePress())
277 break; 285 break;
278 286
279 // If at leftmost decoration, expand to edge of cell. 287 // If at leftmost decoration, expand to edge of cell.
280 if (!index) { 288 if (!index) {
281 minX = NSMinX(cellFrame); 289 minX = NSMinX(cellFrame);
282 } else { 290 } else {
283 minX = NSMinX(decorationFrames[index]) - kDecorationHorizontalPad; 291 minX = NSMinX(decorationFrames[index]) - kDecorationHorizontalPad;
284 } 292 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 431
424 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 432 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
425 std::vector<LocationBarDecoration*> decorations; 433 std::vector<LocationBarDecoration*> decorations;
426 std::vector<NSRect> decorationFrames; 434 std::vector<NSRect> decorationFrames;
427 NSRect workingFrame; 435 NSRect workingFrame;
428 436
429 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_, 437 CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_,
430 &decorations, &decorationFrames, &workingFrame); 438 &decorations, &decorationFrames, &workingFrame);
431 439
432 // Draw the decorations. 440 // Draw the decorations.
441 const CGFloat kDecorationHorizontalPad = DecorationsHorizontalPad();
433 for (size_t i = 0; i < decorations.size(); ++i) { 442 for (size_t i = 0; i < decorations.size(); ++i) {
434 if (decorations[i]) { 443 if (decorations[i]) {
435 NSRect background_frame = NSInsetRect( 444 NSRect background_frame = NSInsetRect(
436 decorationFrames[i], -(kDecorationHorizontalPad + 1) / 2, 2); 445 decorationFrames[i], -(kDecorationHorizontalPad + 1) / 2, 2);
437 decorations[i]->DrawWithBackgroundInFrame( 446 decorations[i]->DrawWithBackgroundInFrame(
438 background_frame, decorationFrames[i], controlView); 447 background_frame, decorationFrames[i], controlView);
439 } 448 }
440 } 449 }
441 450
442 // NOTE: This function must closely match the logic in 451 // NOTE: This function must closely match the logic in
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 774
766 - (void)handleFocusEvent:(NSEvent*)event 775 - (void)handleFocusEvent:(NSEvent*)event
767 ofView:(AutocompleteTextField*)controlView { 776 ofView:(AutocompleteTextField*)controlView {
768 if ([controlView observer]) { 777 if ([controlView observer]) {
769 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0; 778 const bool controlDown = ([event modifierFlags] & NSControlKeyMask) != 0;
770 [controlView observer]->OnSetFocus(controlDown); 779 [controlView observer]->OnSetFocus(controlDown);
771 } 780 }
772 } 781 }
773 782
774 @end 783 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698