Commit 95f066e0 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Reland "Added material refresh layout provider. Updated material design controller."

This is a reland of 7a462a5d

Original change's description:
> Added material refresh layout provider. Updated material design controller.
> 
> Added IsMaterialRefreshMode() function to ChromeLayoutProvider.
> 
> Bug: 822000
> Change-Id: I379d7603838cdec60b3f94fc0e163e9907995b61
> Reviewed-on: https://chromium-review.googlesource.com/988052
> Commit-Queue: Allen Bauer <kylixrd@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Peter Kasting <pkasting@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#548413}

Bug: 822000
Change-Id: I10e27e8294308d01415664adccfac7c4a7206b38
Reviewed-on: https://chromium-review.googlesource.com/999335Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548871}
parent a714b0b2
......@@ -2871,6 +2871,8 @@ split_static_library("ui") {
"views/harmony/harmony_layout_provider.h",
"views/harmony/harmony_typography_provider.cc",
"views/harmony/harmony_typography_provider.h",
"views/harmony/material_refresh_layout_provider.cc",
"views/harmony/material_refresh_layout_provider.h",
"views/harmony/textfield_layout.cc",
"views/harmony/textfield_layout.h",
"views/hover_button.cc",
......
......@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "chrome/browser/ui/views/harmony/chrome_typography.h"
#include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
#include "chrome/browser/ui/views/harmony/material_refresh_layout_provider.h"
#include "ui/base/material_design/material_design_controller.h"
namespace {
......@@ -37,6 +38,9 @@ ChromeLayoutProvider* ChromeLayoutProvider::Get() {
// static
std::unique_ptr<views::LayoutProvider>
ChromeLayoutProvider::CreateLayoutProvider() {
if (ui::MaterialDesignController::GetMode() ==
ui::MaterialDesignController::MATERIAL_REFRESH)
return std::make_unique<MaterialRefreshLayoutProvider>();
return ui::MaterialDesignController::IsSecondaryUiMaterial()
? std::make_unique<HarmonyLayoutProvider>()
: std::make_unique<ChromeLayoutProvider>();
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/harmony/material_refresh_layout_provider.h"
int MaterialRefreshLayoutProvider::GetCornerRadiusMetric(
ChromeEmphasisMetric emphasis_metric,
const gfx::Rect& bounds) const {
switch (emphasis_metric) {
case EMPHASIS_LOW:
return 4;
case EMPHASIS_MEDIUM:
return 8;
case EMPHASIS_HIGH:
return std::min(bounds.width(), bounds.height()) / 2;
default:
NOTREACHED();
return 0;
}
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_HARMONY_MATERIAL_REFRESH_LAYOUT_PROVIDER_H_
#define CHROME_BROWSER_UI_VIEWS_HARMONY_MATERIAL_REFRESH_LAYOUT_PROVIDER_H_
#include "base/macros.h"
#include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
class MaterialRefreshLayoutProvider : public HarmonyLayoutProvider {
public:
MaterialRefreshLayoutProvider() = default;
~MaterialRefreshLayoutProvider() override = default;
int GetCornerRadiusMetric(
ChromeEmphasisMetric emphasis_metric,
const gfx::Rect& bounds = gfx::Rect()) const override;
};
#endif // CHROME_BROWSER_UI_VIEWS_HARMONY_MATERIAL_REFRESH_LAYOUT_PROVIDER_H_
......@@ -120,7 +120,8 @@ MaterialDesignController::Mode MaterialDesignController::GetMode() {
// static
bool MaterialDesignController::IsSecondaryUiMaterial() {
return base::FeatureList::IsEnabled(features::kSecondaryUiMd);
return base::FeatureList::IsEnabled(features::kSecondaryUiMd) ||
GetMode() == MATERIAL_REFRESH;
}
// static
......
......@@ -9,10 +9,13 @@
#include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/test/views_test_base.h"
namespace views {
TEST(ProgressBarTest, Accessibility) {
using ProgressBarTest = ViewsTestBase;
TEST_F(ProgressBarTest, Accessibility) {
ProgressBar bar;
bar.SetValue(0.62);
......@@ -26,7 +29,7 @@ TEST(ProgressBarTest, Accessibility) {
}
// Test that default colors can be overridden. Used by Chromecast.
TEST(ProgressBarTest, OverrideDefaultColors) {
TEST_F(ProgressBarTest, OverrideDefaultColors) {
ProgressBar bar;
EXPECT_NE(SK_ColorRED, bar.GetForegroundColor());
EXPECT_NE(SK_ColorGREEN, bar.GetBackgroundColor());
......
This diff is collapsed.
......@@ -32,7 +32,10 @@ base::string16 DefaultTabTitle() {
class TabbedPaneTest : public ViewsTestBase {
public:
TabbedPaneTest() {
TabbedPaneTest() = default;
void SetUp() override {
ViewsTestBase::SetUp();
tabbed_pane_ = std::make_unique<TabbedPane>();
tabbed_pane_->set_owned_by_client();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment