Merge ~santoshbit2007/oxide/+git/chromium:scrollbar_master_main into ~oxide-developers/oxide/+git/chromium:master

Proposed by Santosh
Status: Needs review
Proposed branch: ~santoshbit2007/oxide/+git/chromium:scrollbar_master_main
Merge into: ~oxide-developers/oxide/+git/chromium:master
Diff against target: 197 lines (+112/-5)
5 files modified
third_party/WebKit/Source/platform/BUILD.gn (+7/-0)
third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp (+5/-3)
third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.cpp (+75/-0)
third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.h (+23/-0)
ui/native_theme/native_theme_aura.cc (+2/-2)
Reviewer Review Type Date Requested Status
Chris Coulson verification also Pending
Review via email: mp+312113@code.launchpad.net

Description of the change

Styling the aura based scrollbar according to ui guidelines.

To post a comment you must log in.

Unmerged commits

d89af07... by Santosh

Change desktop style scrollbar to match UI guidelines

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn
2index 264b1a4..6f93d0a 100644
3--- a/third_party/WebKit/Source/platform/BUILD.gn
4+++ b/third_party/WebKit/Source/platform/BUILD.gn
5@@ -1543,6 +1543,13 @@ component("platform") {
6 ]
7 }
8
9+ if (use_default_render_theme && is_oxide) {
10+ sources += [
11+ "scroll/ScrollbarThemeAuraOverride.cpp",
12+ "scroll/ScrollbarThemeAuraOverride.h",
13+ ]
14+ }
15+
16 if (current_cpu == "arm") {
17 deps += [ ":blink_arm_neon" ]
18 }
19diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp
20index ce7f749..9c2786f 100644
21--- a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp
22+++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAura.cpp
23@@ -38,6 +38,7 @@
24 #include "platform/scroll/ScrollableArea.h"
25 #include "platform/scroll/Scrollbar.h"
26 #include "platform/scroll/ScrollbarThemeOverlay.h"
27+#include "platform/scroll/ScrollbarThemeAuraOverride.h"
28 #include "public/platform/Platform.h"
29 #include "public/platform/WebRect.h"
30 #include "public/platform/WebThemeEngine.h"
31@@ -88,7 +89,7 @@ PartPaintingParams buttonPartPaintingParams(
32 bool checkMax = false;
33
34 if (scrollbar.orientation() == HorizontalScrollbar) {
35- if (part == BackButtonStartPart) {
36+ if (part == BackButtonEndPart) {
37 paintPart = WebThemeEngine::PartScrollbarLeftArrow;
38 checkMin = true;
39 } else if (useMockTheme() && part != ForwardButtonEndPart) {
40@@ -98,7 +99,7 @@ PartPaintingParams buttonPartPaintingParams(
41 checkMax = true;
42 }
43 } else {
44- if (part == BackButtonStartPart) {
45+ if (part == BackButtonEndPart) {
46 paintPart = WebThemeEngine::PartScrollbarUpArrow;
47 checkMin = true;
48 } else if (useMockTheme() && part != ForwardButtonEndPart) {
49@@ -142,7 +143,7 @@ ScrollbarTheme& ScrollbarTheme::nativeTheme() {
50 return theme;
51 }
52
53- DEFINE_STATIC_LOCAL(ScrollbarThemeAura, theme, ());
54+ DEFINE_STATIC_LOCAL(ScrollbarThemeAuraOverride, theme, ());
55 return theme;
56 }
57
58@@ -237,6 +238,7 @@ void ScrollbarThemeAura::paintTrackPiece(GraphicsContext& gc,
59 const Scrollbar& scrollbar,
60 const IntRect& rect,
61 ScrollbarPart partType) {
62+
63 DisplayItem::Type displayItemType = trackPiecePartToDisplayItemType(partType);
64 if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar,
65 displayItemType))
66diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.cpp b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.cpp
67new file mode 100644
68index 0000000..c78deb5
69--- /dev/null
70+++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.cpp
71@@ -0,0 +1,75 @@
72+#include "platform/scroll/ScrollbarThemeAuraOverride.h"
73+
74+#include "platform/scroll/ScrollTypes.h"
75+#include "public/platform/Platform.h"
76+#include "public/platform/WebRect.h"
77+#include "public/platform/WebThemeEngine.h"
78+
79+namespace blink {
80+
81+IntRect ScrollbarThemeAuraOverride::backButtonRect(
82+ const ScrollbarThemeClient& scrollbar,
83+ ScrollbarPart part,
84+ bool) {
85+ // Windows and Linux just have single arrows.
86+ if (part == BackButtonStartPart) {
87+ return IntRect();
88+ }
89+
90+ IntSize size = buttonSize(scrollbar);
91+ int x, y;
92+ if (scrollbar.orientation() == HorizontalScrollbar) {
93+ x = scrollbar.x() + scrollbar.width() - 2 * size.width();
94+ y = scrollbar.y();
95+ } else {
96+ x = scrollbar.x();
97+ y = scrollbar.y() + scrollbar.height() - 2 * size.height();
98+ }
99+ return IntRect(x, y, size.width(), size.height());
100+}
101+
102+IntRect ScrollbarThemeAuraOverride::trackRect(
103+ const ScrollbarThemeClient& scrollbar,
104+ bool) {
105+ // The track occupies all space between the two buttons.
106+ IntSize bs = buttonSize(scrollbar);
107+ if (scrollbar.orientation() == HorizontalScrollbar) {
108+ if (scrollbar.width() <= 2 * bs.width()) {
109+ return IntRect();
110+ }
111+ return IntRect(scrollbar.x(), scrollbar.y(),
112+ scrollbar.width() - 2 * bs.width(), scrollbar.height());
113+ }
114+ if (scrollbar.height() <= 2 * bs.height()) {
115+ return IntRect();
116+ }
117+ return IntRect(scrollbar.x(), scrollbar.y(), scrollbar.width(),
118+ scrollbar.height() - 2 * bs.height());
119+}
120+
121+IntSize ScrollbarThemeAuraOverride::buttonSize(
122+ const ScrollbarThemeClient& scrollbar) {
123+ WebThemeEngine::Part part = WebThemeEngine::PartScrollbarLeftArrow;
124+ if (scrollbar.orientation() == VerticalScrollbar) {
125+ part = WebThemeEngine::PartScrollbarDownArrow;
126+ }
127+ WebThemeEngine* themeEngine = Platform::current()->themeEngine();
128+ if (themeEngine->getSize(part).isEmpty()) {
129+ return IntSize(0, 0);
130+ }
131+
132+ if (scrollbar.orientation() == VerticalScrollbar) {
133+ int squareSize = scrollbar.width();
134+ return IntSize(squareSize, scrollbar.height() < 2 * squareSize
135+ ? scrollbar.height() / 2
136+ : squareSize);
137+ }
138+
139+ // Horizontal Scrollbar
140+ int squareSize = scrollbar.height();
141+ return IntSize(
142+ scrollbar.width() < 2 * squareSize ? scrollbar.width() / 2 : squareSize,
143+ squareSize);
144+}
145+
146+} // blink
147diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.h b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.h
148new file mode 100644
149index 0000000..7222077
150--- /dev/null
151+++ b/third_party/WebKit/Source/platform/scroll/ScrollbarThemeAuraOverride.h
152@@ -0,0 +1,23 @@
153+
154+#ifndef ScrollbarThemeAuraOverride_h
155+#define ScrollbarThemeAuraOverride_h
156+
157+#include "platform/scroll/ScrollbarThemeAura.h"
158+
159+namespace blink {
160+
161+class ScrollbarThemeAuraOverride : public ScrollbarThemeAura {
162+ protected:
163+ IntRect trackRect(const ScrollbarThemeClient&,
164+ bool painting = false) override;
165+ IntRect backButtonRect(const ScrollbarThemeClient&,
166+ ScrollbarPart,
167+ bool painting = false) override;
168+
169+ private:
170+ IntSize buttonSize(const ScrollbarThemeClient&);
171+};
172+
173+} // namespace blink
174+
175+#endif
176diff --git a/ui/native_theme/native_theme_aura.cc b/ui/native_theme/native_theme_aura.cc
177index 1d67f96..004e0f2 100644
178--- a/ui/native_theme/native_theme_aura.cc
179+++ b/ui/native_theme/native_theme_aura.cc
180@@ -231,7 +231,7 @@ void NativeThemeAura::PaintScrollbarThumb(
181 } else {
182 // If there are no scrollbuttons then provide some padding so that the thumb
183 // doesn't touch the top of the track.
184- const int kThumbPadding = 2;
185+ const int kThumbPadding = 4;
186 const int extra_padding =
187 (scrollbar_button_length() == 0) ? kThumbPadding : 0;
188 if (part == NativeTheme::kScrollbarVerticalThumb)
189@@ -244,7 +244,7 @@ void NativeThemeAura::PaintScrollbarThumb(
190
191 SkPaint paint;
192 paint.setColor(SkColorSetA(thumb_color, thumb_alpha));
193- canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint);
194+ canvas->drawRoundRect(gfx::RectToSkRect(thumb_rect), 25, 25, paint);
195 }
196
197 void NativeThemeAura::PaintScrollbarCorner(SkCanvas* canvas,

Subscribers

People subscribed via source and target branches

to all changes: