OLD | NEW |
---|---|
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/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 #if !defined(OS_CHROMEOS) | 96 #if !defined(OS_CHROMEOS) |
97 #include "chrome/browser/ui/views/first_run_bubble.h" | 97 #include "chrome/browser/ui/views/first_run_bubble.h" |
98 #endif | 98 #endif |
99 | 99 |
100 using content::WebContents; | 100 using content::WebContents; |
101 using views::View; | 101 using views::View; |
102 | 102 |
103 namespace { | 103 namespace { |
104 | 104 |
105 // The border color for MD windows, as well as non-MD popup windows. | 105 // The border color for MD windows, as well as non-MD popup windows. |
106 const SkColor kBorderColor = SkColorSetA(SK_ColorBLACK, 0x4D); | 106 const SkColor kBorderColor = SkColorSetA(SK_ColorBLACK, 0x4D); |
Evan Stade
2016/05/20 00:56:41
I'm going to look at whether we can align this wit
| |
107 | 107 |
108 int GetEditLeadingInternalSpace() { | 108 int GetEditLeadingInternalSpace() { |
109 // The textfield has 1 px of whitespace before the text in the RTL case only. | 109 // The textfield has 1 px of whitespace before the text in the RTL case only. |
110 return base::i18n::IsRTL() ? 1 : 0; | 110 return base::i18n::IsRTL() ? 1 : 0; |
111 } | 111 } |
112 | 112 |
113 } // namespace | 113 } // namespace |
114 | 114 |
115 | 115 |
116 // LocationBarView ----------------------------------------------------------- | 116 // LocationBarView ----------------------------------------------------------- |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1251 return kViewClassName; | 1251 return kViewClassName; |
1252 } | 1252 } |
1253 | 1253 |
1254 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1254 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
1255 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); | 1255 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); |
1256 if (popup->IsOpen()) | 1256 if (popup->IsOpen()) |
1257 popup->UpdatePopupAppearance(); | 1257 popup->UpdatePopupAppearance(); |
1258 } | 1258 } |
1259 | 1259 |
1260 void LocationBarView::OnFocus() { | 1260 void LocationBarView::OnFocus() { |
1261 // Explicitly focus the omnibox so a focus ring will be displayed around it on | |
1262 // Windows. | |
1263 omnibox_view_->SetFocus(); | 1261 omnibox_view_->SetFocus(); |
1264 } | 1262 } |
1265 | 1263 |
1264 void LocationBarView::OnBlur() { | |
1265 SchedulePaint(); | |
sky
2016/05/20 16:08:00
Is this only necessary if modematerial and show_fo
Evan Stade
2016/05/20 18:02:00
hmm, turns out this didn't actually work (although
| |
1266 } | |
1267 | |
1266 void LocationBarView::OnPaint(gfx::Canvas* canvas) { | 1268 void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
1267 View::OnPaint(canvas); | 1269 View::OnPaint(canvas); |
1268 | 1270 |
1269 if (ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) | 1271 if (ui::MaterialDesignController::IsModeMaterial()) { |
1270 return; // The background and border are painted by our Background. | 1272 if (show_focus_rect_ && HasFocus()) { |
1273 SkPaint paint; | |
1274 paint.setAntiAlias(true); | |
1275 paint.setColor(GetNativeTheme()->GetSystemColor( | |
1276 ui::NativeTheme::NativeTheme::kColorId_FocusedBorderColor)); | |
1277 paint.setStyle(SkPaint::kStroke_Style); | |
1278 paint.setStrokeWidth(1); | |
1279 gfx::RectF focus_rect(GetLocalBounds()); | |
1280 focus_rect.Inset(gfx::InsetsF(0.5f)); | |
1281 canvas->DrawRoundRect(focus_rect, 2.5f, paint); | |
1282 } | |
1283 if (!is_popup_mode_) | |
1284 return; // The background and border are painted by our Background. | |
1285 } | |
1271 | 1286 |
1272 // Fill the location bar background color behind the border. Parts of the | 1287 // Fill the location bar background color behind the border. Parts of the |
1273 // border images are meant to rest atop the toolbar background and parts atop | 1288 // border images are meant to rest atop the toolbar background and parts atop |
1274 // the omnibox background, so we can't just blindly fill our entire bounds. | 1289 // the omnibox background, so we can't just blindly fill our entire bounds. |
1275 gfx::Rect bounds(GetContentsBounds()); | 1290 gfx::Rect bounds(GetContentsBounds()); |
1276 bounds.Inset(GetHorizontalEdgeThickness(), | 1291 bounds.Inset(GetHorizontalEdgeThickness(), |
1277 is_popup_mode_ ? 0 : GetVerticalEdgeThickness()); | 1292 is_popup_mode_ ? 0 : GetVerticalEdgeThickness()); |
1278 SkColor background_color(GetColor(BACKGROUND)); | 1293 SkColor background_color(GetColor(BACKGROUND)); |
1279 if (!is_popup_mode_) { | 1294 if (!is_popup_mode_) { |
1280 SkPaint paint; | 1295 SkPaint paint; |
(...skipping 14 matching lines...) Expand all Loading... | |
1295 | 1310 |
1296 void LocationBarView::PaintChildren(const ui::PaintContext& context) { | 1311 void LocationBarView::PaintChildren(const ui::PaintContext& context) { |
1297 View::PaintChildren(context); | 1312 View::PaintChildren(context); |
1298 | 1313 |
1299 ui::PaintRecorder recorder(context, size()); | 1314 ui::PaintRecorder recorder(context, size()); |
1300 | 1315 |
1301 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need | 1316 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need |
1302 // the focus rect to appear on top of children we paint here rather than | 1317 // the focus rect to appear on top of children we paint here rather than |
1303 // OnPaint(). | 1318 // OnPaint(). |
1304 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. | 1319 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. |
1305 if (show_focus_rect_ && HasFocus()) | 1320 if (!ui::MaterialDesignController::IsModeMaterial() && show_focus_rect_ && |
1321 HasFocus()) { | |
1306 recorder.canvas()->DrawFocusRect(omnibox_view_->bounds()); | 1322 recorder.canvas()->DrawFocusRect(omnibox_view_->bounds()); |
1323 } | |
1307 | 1324 |
1308 if (!ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) { | 1325 if (!ui::MaterialDesignController::IsModeMaterial() && !is_popup_mode_) { |
1309 views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(), | 1326 views::Painter::PaintPainterAt(recorder.canvas(), border_painter_.get(), |
1310 GetContentsBounds()); | 1327 GetContentsBounds()); |
1311 } | 1328 } |
1312 } | 1329 } |
1313 | 1330 |
1314 //////////////////////////////////////////////////////////////////////////////// | 1331 //////////////////////////////////////////////////////////////////////////////// |
1315 // LocationBarView, private views::DragController implementation: | 1332 // LocationBarView, private views::DragController implementation: |
1316 | 1333 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1384 // LocationBarView, private TemplateURLServiceObserver implementation: | 1401 // LocationBarView, private TemplateURLServiceObserver implementation: |
1385 | 1402 |
1386 void LocationBarView::OnTemplateURLServiceChanged() { | 1403 void LocationBarView::OnTemplateURLServiceChanged() { |
1387 template_url_service_->RemoveObserver(this); | 1404 template_url_service_->RemoveObserver(this); |
1388 template_url_service_ = nullptr; | 1405 template_url_service_ = nullptr; |
1389 // If the browser is no longer active, let's not show the info bubble, as this | 1406 // If the browser is no longer active, let's not show the info bubble, as this |
1390 // would make the browser the active window again. | 1407 // would make the browser the active window again. |
1391 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1408 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
1392 ShowFirstRunBubble(); | 1409 ShowFirstRunBubble(); |
1393 } | 1410 } |
OLD | NEW |