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

Unified Diff: content/child/webthemeengine_impl_default.cc

Issue 1054243002: Avoid calling the GetSystemMetrics API in the renderer process on Windows to get the scrollbar metr… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: content/child/webthemeengine_impl_default.cc
diff --git a/content/child/webthemeengine_impl_default.cc b/content/child/webthemeengine_impl_default.cc
index 4f78f1c9da21206899fe0e4d18a6d3d087657279..955161d952f9ba2b4c8821a5dcb136641d5e079f 100644
--- a/content/child/webthemeengine_impl_default.cc
+++ b/content/child/webthemeengine_impl_default.cc
@@ -15,6 +15,24 @@ using blink::WebRect;
using blink::WebThemeEngine;
namespace content {
+namespace {
+
+#if defined(OS_WIN)
+// The scrollbar metrics default to 17 dips which is the default value on
+// Windows in most cases.
+int32 g_vertical_scroll_bar_width = 17;
+
+// The height of a horizontal scroll bar in dips.
+int32 g_horizontal_scroll_bar_height = 17;
+
+// The height of the arrow bitmap on a vertical scroll bar in dips.
+int32 g_vertical_arrow_bitmap_height = 17;
+
+// The width of the arrow bitmap on a horizontal scroll bar in dips.
+int32 g_horizontal_arrow_bitmap_width = 17;
+#endif
+
+} // namespace
static ui::NativeTheme::Part NativeThemePart(
WebThemeEngine::Part part) {
@@ -162,9 +180,28 @@ static void GetNativeThemeExtraParams(
blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) {
ui::NativeTheme::ExtraParams extra;
- return ui::NativeTheme::instance()->GetPartSize(NativeThemePart(part),
- ui::NativeTheme::kNormal,
- extra);
+ ui::NativeTheme::Part native_theme_part = NativeThemePart(part);
+#if defined(OS_WIN)
+ switch (native_theme_part) {
+ case ui::NativeTheme::kScrollbarDownArrow:
+ case ui::NativeTheme::kScrollbarLeftArrow:
+ case ui::NativeTheme::kScrollbarRightArrow:
+ case ui::NativeTheme::kScrollbarUpArrow:
+ case ui::NativeTheme::kScrollbarHorizontalThumb:
+ case ui::NativeTheme::kScrollbarVerticalThumb:
+ case ui::NativeTheme::kScrollbarHorizontalTrack:
+ case ui::NativeTheme::kScrollbarVerticalTrack: {
+ return gfx::Size(g_vertical_scroll_bar_width,
+ g_vertical_scroll_bar_width);
+ }
+
+ default:
+ break;
+ }
+#endif
+ return ui::NativeTheme::instance()->GetPartSize(native_theme_part,
+ ui::NativeTheme::kNormal,
+ extra);
}
void WebThemeEngineImpl::paint(
@@ -199,4 +236,16 @@ void WebThemeEngineImpl::paintStateTransition(blink::WebCanvas* canvas,
gfx::Rect(rect));
}
+// static
+void WebThemeEngineImpl::CacheScrollBarMetrics(
+ int32 vertical_scroll_bar_width,
+ int32 horizontal_scroll_bar_height,
+ int32 vertical_arrow_bitmap_height,
+ int32 horizontal_arrow_bitmap_width) {
+ g_vertical_scroll_bar_width = vertical_scroll_bar_width;
+ g_horizontal_scroll_bar_height = horizontal_scroll_bar_height;
+ g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height;
+ g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698