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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.cc

Issue 15769018: [Autofill] Determine Popup RTLness from page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android compile Created 7 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
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 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { "visaCC", IDR_AUTOFILL_CC_VISA }, 65 { "visaCC", IDR_AUTOFILL_CC_VISA },
66 }; 66 };
67 67
68 } // namespace 68 } // namespace
69 69
70 // static 70 // static
71 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetOrCreate( 71 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetOrCreate(
72 WeakPtr<AutofillPopupControllerImpl> previous, 72 WeakPtr<AutofillPopupControllerImpl> previous,
73 WeakPtr<AutofillPopupDelegate> delegate, 73 WeakPtr<AutofillPopupDelegate> delegate,
74 gfx::NativeView container_view, 74 gfx::NativeView container_view,
75 const gfx::RectF& element_bounds) { 75 const gfx::RectF& element_bounds,
76 base::i18n::TextDirection text_direction) {
76 DCHECK(!previous.get() || previous->delegate_.get() == delegate.get()); 77 DCHECK(!previous.get() || previous->delegate_.get() == delegate.get());
77 78
78 if (previous.get() && previous->container_view() == container_view && 79 if (previous.get() && previous->container_view() == container_view &&
79 previous->element_bounds() == element_bounds) { 80 previous->element_bounds() == element_bounds) {
80 previous->ClearState(); 81 previous->ClearState();
81 return previous; 82 return previous;
82 } 83 }
83 84
84 if (previous.get()) 85 if (previous.get())
85 previous->Hide(); 86 previous->Hide();
86 87
87 AutofillPopupControllerImpl* controller = 88 AutofillPopupControllerImpl* controller =
88 new AutofillPopupControllerImpl(delegate, container_view, element_bounds); 89 new AutofillPopupControllerImpl(
90 delegate, container_view, element_bounds, text_direction);
89 return controller->GetWeakPtr(); 91 return controller->GetWeakPtr();
90 } 92 }
91 93
92 AutofillPopupControllerImpl::AutofillPopupControllerImpl( 94 AutofillPopupControllerImpl::AutofillPopupControllerImpl(
93 base::WeakPtr<AutofillPopupDelegate> delegate, 95 base::WeakPtr<AutofillPopupDelegate> delegate,
94 gfx::NativeView container_view, 96 gfx::NativeView container_view,
95 const gfx::RectF& element_bounds) 97 const gfx::RectF& element_bounds,
98 base::i18n::TextDirection text_direction)
96 : view_(NULL), 99 : view_(NULL),
97 delegate_(delegate), 100 delegate_(delegate),
98 container_view_(container_view), 101 container_view_(container_view),
99 element_bounds_(element_bounds), 102 element_bounds_(element_bounds),
103 text_direction_(text_direction),
100 weak_ptr_factory_(this) { 104 weak_ptr_factory_(this) {
101 ClearState(); 105 ClearState();
102 #if !defined(OS_ANDROID) 106 #if !defined(OS_ANDROID)
103 subtext_font_ = name_font_.DeriveFont(kLabelFontSizeDelta); 107 subtext_font_ = name_font_.DeriveFont(kLabelFontSizeDelta);
104 warning_font_ = name_font_.DeriveFont(0, gfx::Font::ITALIC); 108 warning_font_ = name_font_.DeriveFont(0, gfx::Font::ITALIC);
105 #endif 109 #endif
106 } 110 }
107 111
108 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {} 112 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {}
109 113
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 293 }
290 294
291 gfx::NativeView AutofillPopupControllerImpl::container_view() const { 295 gfx::NativeView AutofillPopupControllerImpl::container_view() const {
292 return container_view_; 296 return container_view_;
293 } 297 }
294 298
295 const gfx::RectF& AutofillPopupControllerImpl::element_bounds() const { 299 const gfx::RectF& AutofillPopupControllerImpl::element_bounds() const {
296 return element_bounds_; 300 return element_bounds_;
297 } 301 }
298 302
303 bool AutofillPopupControllerImpl::IsRTL() const {
304 return text_direction_ == base::i18n::RIGHT_TO_LEFT;
305 }
306
299 const std::vector<string16>& AutofillPopupControllerImpl::names() const { 307 const std::vector<string16>& AutofillPopupControllerImpl::names() const {
300 return names_; 308 return names_;
301 } 309 }
302 310
303 const std::vector<string16>& AutofillPopupControllerImpl::subtexts() const { 311 const std::vector<string16>& AutofillPopupControllerImpl::subtexts() const {
304 return subtexts_; 312 return subtexts_;
305 } 313 }
306 314
307 const std::vector<string16>& AutofillPopupControllerImpl::icons() const { 315 const std::vector<string16>& AutofillPopupControllerImpl::icons() const {
308 return icons_; 316 return icons_;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // The popup can appear below the field. 659 // The popup can appear below the field.
652 return std::make_pair(bottom_growth_start, popup_required_height); 660 return std::make_pair(bottom_growth_start, popup_required_height);
653 } else { 661 } else {
654 // The popup must appear above the field. 662 // The popup must appear above the field.
655 return std::make_pair(top_growth_end - popup_required_height, 663 return std::make_pair(top_growth_end - popup_required_height,
656 popup_required_height); 664 popup_required_height);
657 } 665 }
658 } 666 }
659 667
660 } // namespace autofill 668 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698