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

Side by Side Diff: ui/base/layout.cc

Issue 1025513004: Ensure that the extension icons show up in the omnibox at fractional scales. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use g_supported_scale_factors to verify if the scale passed in is supported. Created 5 years, 9 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
« extensions/browser/extension_icon_image.cc ('K') | « ui/base/layout.h ('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 #include "ui/base/layout.h" 5 #include "ui/base/layout.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return gfx::GetDPIScale(); 85 return gfx::GetDPIScale();
86 #else 86 #else
87 return GetScaleForScaleFactor(scale_factor); 87 return GetScaleForScaleFactor(scale_factor);
88 #endif 88 #endif
89 } 89 }
90 90
91 float GetScaleForScaleFactor(ScaleFactor scale_factor) { 91 float GetScaleForScaleFactor(ScaleFactor scale_factor) {
92 return kScaleFactorScales[scale_factor]; 92 return kScaleFactorScales[scale_factor];
93 } 93 }
94 94
95 bool IsSupportedScale(float scale) {
96 for (auto scale_factor_idx : *g_supported_scale_factors) {
97 if (kScaleFactorScales[scale_factor_idx] == scale)
98 return true;
99 }
100 return false;
101 }
102
95 namespace test { 103 namespace test {
96 104
97 ScopedSetSupportedScaleFactors::ScopedSetSupportedScaleFactors( 105 ScopedSetSupportedScaleFactors::ScopedSetSupportedScaleFactors(
98 const std::vector<ui::ScaleFactor>& new_scale_factors) { 106 const std::vector<ui::ScaleFactor>& new_scale_factors) {
99 if (g_supported_scale_factors) { 107 if (g_supported_scale_factors) {
100 original_scale_factors_ = 108 original_scale_factors_ =
101 new std::vector<ScaleFactor>(*g_supported_scale_factors); 109 new std::vector<ScaleFactor>(*g_supported_scale_factors);
102 } else { 110 } else {
103 original_scale_factors_ = NULL; 111 original_scale_factors_ = NULL;
104 } 112 }
(...skipping 14 matching lines...) Expand all
119 127
120 #if !defined(OS_MACOSX) 128 #if !defined(OS_MACOSX)
121 float GetScaleFactorForNativeView(gfx::NativeView view) { 129 float GetScaleFactorForNativeView(gfx::NativeView view) {
122 gfx::Screen* screen = gfx::Screen::GetScreenFor(view); 130 gfx::Screen* screen = gfx::Screen::GetScreenFor(view);
123 gfx::Display display = screen->GetDisplayNearestWindow(view); 131 gfx::Display display = screen->GetDisplayNearestWindow(view);
124 return display.device_scale_factor(); 132 return display.device_scale_factor();
125 } 133 }
126 #endif // !defined(OS_MACOSX) 134 #endif // !defined(OS_MACOSX)
127 135
128 } // namespace ui 136 } // namespace ui
OLDNEW
« extensions/browser/extension_icon_image.cc ('K') | « ui/base/layout.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698