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

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..e510e5f93dac47c6eccb753002748434261d11f1 100644
--- a/content/child/webthemeengine_impl_default.cc
+++ b/content/child/webthemeengine_impl_default.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "content/child/webthemeengine_impl_default.h"
+#include "content/public/common/renderer_preferences.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/platform/WebRect.h"
@@ -160,11 +161,39 @@ static void GetNativeThemeExtraParams(
}
}
+int32 WebThemeEngineImpl::vertical_scroll_bar_width_ = 0;
+int32 WebThemeEngineImpl::horizontal_scroll_bar_height_ = 0;
brucedawson 2015/04/03 17:00:24 I can't see anywhere where this variable (or the t
ananta 2015/04/03 19:17:03 Caching them on an if needed basis.
+int32 WebThemeEngineImpl::vertical_arrow_bitmap_height_ = 0;
+int32 WebThemeEngineImpl::horizontal_arrow_bitmap_width_ = 0;
+
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: {
+ // If we have the scrollbar width cached return it.
+ if (WebThemeEngineImpl::vertical_scroll_bar_width_) {
brucedawson 2015/04/03 17:00:24 When would we not have the scrollbar width cached?
ananta 2015/04/03 19:17:04 Removed the check. The metrics default to 17
+ return gfx::Size(WebThemeEngineImpl::vertical_scroll_bar_width_,
+ WebThemeEngineImpl::vertical_scroll_bar_width_);
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+#endif
+ return ui::NativeTheme::instance()->GetPartSize(native_theme_part,
+ ui::NativeTheme::kNormal,
+ extra);
}
void WebThemeEngineImpl::paint(
@@ -199,4 +228,28 @@ void WebThemeEngineImpl::paintStateTransition(blink::WebCanvas* canvas,
gfx::Rect(rect));
}
+// static
+void WebThemeEngineImpl::SetVerticalScrollbarWidth(
+ int32 vertical_scroll_bar_width) {
+ vertical_scroll_bar_width_ = vertical_scroll_bar_width;
+}
+
+// static
+void WebThemeEngineImpl::SetHorizontalScrollbarHeight(
+ int32 horizontal_scroll_bar_height) {
+ horizontal_scroll_bar_height_ = horizontal_scroll_bar_height;
+}
+
+// static
+void WebThemeEngineImpl::SetVerticalArrowBitmapHeight(
+ int32 vertical_arrow_bitmap_height) {
+ vertical_arrow_bitmap_height_ = vertical_arrow_bitmap_height;
+}
+
+// static
+void WebThemeEngineImpl::SetHorizontalArrowBitmapWidth(
+ int32 horizontal_arrow_bitmap_width) {
+ horizontal_arrow_bitmap_width_ = horizontal_arrow_bitmap_width;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698