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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 262093014: Test that OmniboxViewViews has opaque background. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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/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/command_line.h" 10 #include "base/command_line.h"
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 1404
1405 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1405 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1406 InstantServiceFactory::GetForProfile(profile())->OnOmniboxStartMarginChanged( 1406 InstantServiceFactory::GetForProfile(profile())->OnOmniboxStartMarginChanged(
1407 bounds().x()); 1407 bounds().x());
1408 1408
1409 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view(); 1409 OmniboxPopupView* popup = omnibox_view_->model()->popup_model()->view();
1410 if (popup->IsOpen()) 1410 if (popup->IsOpen())
1411 popup->UpdatePopupAppearance(); 1411 popup->UpdatePopupAppearance();
1412 } 1412 }
1413 1413
1414 void LocationBarView::OnFocus() { 1414 void LocationBarView::OnFocus() {
Peter Kasting 2014/05/06 21:28:33 Is it possible to remove this function entirely an
Daniel Erat 2014/05/07 18:43:02 seems to work for chrome os and linux. dominic, wo
1415 // Focus the view widget first which implements accessibility for
1416 // Chrome OS. It is noop on Win. This should be removed once
1417 // Chrome OS migrates to aura, which uses Views' textfield that receives
1418 // focus. See crbug.com/106428.
1419 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, false);
1420
1421 // Then focus the native location view which implements accessibility for
1422 // Windows.
1423 omnibox_view_->SetFocus(); 1415 omnibox_view_->SetFocus();
1424 } 1416 }
1425 1417
1426 void LocationBarView::OnPaint(gfx::Canvas* canvas) { 1418 void LocationBarView::OnPaint(gfx::Canvas* canvas) {
1427 View::OnPaint(canvas); 1419 View::OnPaint(canvas);
1428 1420
1429 // Fill the location bar background color behind the border. Parts of the 1421 // Fill the location bar background color behind the border. Parts of the
1430 // border images are meant to rest atop the toolbar background and parts atop 1422 // border images are meant to rest atop the toolbar background and parts atop
1431 // the omnibox background, so we can't just blindly fill our entire bounds. 1423 // the omnibox background, so we can't just blindly fill our entire bounds.
1432 gfx::Rect bounds(GetContentsBounds()); 1424 gfx::Rect bounds(GetContentsBounds());
1433 bounds.Inset(GetHorizontalEdgeThickness(), vertical_edge_thickness()); 1425 bounds.Inset(GetHorizontalEdgeThickness(), vertical_edge_thickness());
1434 SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND)); 1426 SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND));
1435 if (is_popup_mode_) { 1427 if (is_popup_mode_) {
1436 canvas->FillRect(bounds, color); 1428 canvas->FillRect(bounds, color);
1437 } else { 1429 } else {
1438 SkPaint paint; 1430 SkPaint paint;
1439 paint.setStyle(SkPaint::kFill_Style); 1431 paint.setStyle(SkPaint::kFill_Style);
1440 paint.setColor(color); 1432 paint.setColor(color);
1441 const int kBorderCornerRadius = 2; 1433 const int kBorderCornerRadius = 2;
1442 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); 1434 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint);
1443 } 1435 }
1444 1436
1445 // The border itself will be drawn in PaintChildren() since it includes an 1437 // The border itself will be drawn in PaintChildren() since it includes an
1446 // inner shadow which should be drawn over the contents. 1438 // inner shadow which should be drawn over the contents.
1447 } 1439 }
1448 1440
1449 void LocationBarView::PaintChildren(gfx::Canvas* canvas) { 1441 void LocationBarView::PaintChildren(gfx::Canvas* canvas) {
1450 // Paint all the children except for the origin chip and the search button, 1442 // Paint all the children except for the origin chip and the search button,
1451 // which will be painted after the border. 1443 // which will be painted after the border.
1452 for (int i = 0, count = child_count(); i < count; ++i) 1444 for (int i = 0, count = child_count(); i < count; ++i) {
1453 if (!child_at(i)->layer() && 1445 if (!child_at(i)->layer() &&
1454 (child_at(i) != origin_chip_view_) && 1446 (child_at(i) != origin_chip_view_) &&
1455 (child_at(i) != search_button_)) 1447 (child_at(i) != search_button_))
1456 child_at(i)->Paint(canvas); 1448 child_at(i)->Paint(canvas);
1449 }
1457 1450
1458 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need 1451 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need
1459 // the focus rect to appear on top of children we paint here rather than 1452 // the focus rect to appear on top of children we paint here rather than
1460 // OnPaint(). 1453 // OnPaint().
1461 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. 1454 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color.
1462 if (show_focus_rect_ && HasFocus()) 1455 if (show_focus_rect_ && HasFocus())
1463 canvas->DrawFocusRect(omnibox_view_->bounds()); 1456 canvas->DrawFocusRect(omnibox_view_->bounds());
1464 1457
1465 // Maximized popup windows don't draw the horizontal edges. We implement this 1458 // Maximized popup windows don't draw the horizontal edges. We implement this
1466 // by simply expanding the paint area outside the view by the edge thickness. 1459 // by simply expanding the paint area outside the view by the edge thickness.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1646 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1654 const SearchModel::State& new_state) { 1647 const SearchModel::State& new_state) {
1655 const bool visible = !GetToolbarModel()->input_in_progress() && 1648 const bool visible = !GetToolbarModel()->input_in_progress() &&
1656 new_state.voice_search_supported; 1649 new_state.voice_search_supported;
1657 if (mic_search_view_->visible() != visible) { 1650 if (mic_search_view_->visible() != visible) {
1658 mic_search_view_->SetVisible(visible); 1651 mic_search_view_->SetVisible(visible);
1659 Layout(); 1652 Layout();
1660 } 1653 }
1661 } 1654 }
1662 1655
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698