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

Side by Side Diff: Source/core/platform/ScrollbarThemeGtkOrAura.cpp

Issue 41733004: Roll up patch for running layout tests under Aura. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: move useMockTheme() into a helper function Created 7 years, 1 month 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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/rendering/RenderThemeChromiumDefault.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer 11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
13 * distribution. 13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its 14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from 15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission. 16 * this software without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT{
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,{
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/platform/ScrollbarThemeGtkOrAura.h" 32 #include "core/platform/ScrollbarThemeGtkOrAura.h"
33 33
34 #include "RuntimeEnabledFeatures.h" 34 #include "RuntimeEnabledFeatures.h"
35 #include "core/platform/ScrollbarThemeOverlay.h" 35 #include "core/platform/ScrollbarThemeOverlay.h"
36 #include "core/platform/graphics/GraphicsContext.h" 36 #include "core/platform/graphics/GraphicsContext.h"
37 #include "platform/LayoutTestSupport.h"
37 #include "platform/PlatformMouseEvent.h" 38 #include "platform/PlatformMouseEvent.h"
38 #include "platform/scroll/ScrollbarThemeClient.h" 39 #include "platform/scroll/ScrollbarThemeClient.h"
39 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
40 #include "public/platform/WebRect.h" 41 #include "public/platform/WebRect.h"
41 #include "public/platform/default/WebThemeEngine.h" 42 #include "public/platform/default/WebThemeEngine.h"
42 43
43 namespace WebCore { 44 namespace WebCore {
44 45
46 static bool useMockTheme()
47 {
48 #if defined(USE_AURA)
49 return isRunningLayoutTest();
50 #endif
51 return false;
52 }
53
45 ScrollbarTheme* ScrollbarTheme::nativeTheme() 54 ScrollbarTheme* ScrollbarTheme::nativeTheme()
46 { 55 {
47 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) { 56 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) {
48 DEFINE_STATIC_LOCAL(ScrollbarThemeOverlay, theme, (10, 0, ScrollbarTheme Overlay::AllowHitTest, Color(128, 128, 128, 192))); 57 DEFINE_STATIC_LOCAL(ScrollbarThemeOverlay, theme, (10, 0, ScrollbarTheme Overlay::AllowHitTest, Color(128, 128, 128, 192)));
49 return &theme; 58 return &theme;
50 } 59 }
51 60
52 DEFINE_STATIC_LOCAL(ScrollbarThemeGtkOrAura, theme, ()); 61 DEFINE_STATIC_LOCAL(ScrollbarThemeGtkOrAura, theme, ());
53 return &theme; 62 return &theme;
54 } 63 }
55 64
56 int ScrollbarThemeGtkOrAura::scrollbarThickness(ScrollbarControlSize controlSize ) 65 int ScrollbarThemeGtkOrAura::scrollbarThickness(ScrollbarControlSize controlSize )
57 { 66 {
58 // Horiz and Vert scrollbars are the same thickness. 67 // Horiz and Vert scrollbars are the same thickness.
59 IntSize scrollbarSize = blink::Platform::current()->themeEngine()->getSize(b link::WebThemeEngine::PartScrollbarVerticalTrack); 68 IntSize scrollbarSize = blink::Platform::current()->themeEngine()->getSize(b link::WebThemeEngine::PartScrollbarVerticalTrack);
60 return scrollbarSize.width(); 69 return scrollbarSize.width();
61 } 70 }
62 71
63 void ScrollbarThemeGtkOrAura::paintTrackPiece(GraphicsContext* gc, ScrollbarThem eClient* scrollbar, const IntRect& rect, ScrollbarPart partType) 72 void ScrollbarThemeGtkOrAura::paintTrackPiece(GraphicsContext* gc, ScrollbarThem eClient* scrollbar, const IntRect& rect, ScrollbarPart partType)
64 { 73 {
65 blink::WebThemeEngine::State state = scrollbar->hoveredPart() == partType ? blink::WebThemeEngine::StateHover : blink::WebThemeEngine::StateNormal; 74 blink::WebThemeEngine::State state = scrollbar->hoveredPart() == partType ? blink::WebThemeEngine::StateHover : blink::WebThemeEngine::StateNormal;
75
76 if (useMockTheme() && !scrollbar->enabled())
77 state = blink::WebThemeEngine::StateDisabled;
78
66 IntRect alignRect = trackRect(scrollbar, false); 79 IntRect alignRect = trackRect(scrollbar, false);
67 blink::WebThemeEngine::ExtraParams extraParams; 80 blink::WebThemeEngine::ExtraParams extraParams;
68 blink::WebCanvas* canvas = gc->canvas(); 81 blink::WebCanvas* canvas = gc->canvas();
82 extraParams.scrollbarTrack.isBack = (partType == BackTrackPart);
69 extraParams.scrollbarTrack.trackX = alignRect.x(); 83 extraParams.scrollbarTrack.trackX = alignRect.x();
70 extraParams.scrollbarTrack.trackY = alignRect.y(); 84 extraParams.scrollbarTrack.trackY = alignRect.y();
71 extraParams.scrollbarTrack.trackWidth = alignRect.width(); 85 extraParams.scrollbarTrack.trackWidth = alignRect.width();
72 extraParams.scrollbarTrack.trackHeight = alignRect.height(); 86 extraParams.scrollbarTrack.trackHeight = alignRect.height();
73 blink::Platform::current()->themeEngine()->paint(canvas, scrollbar->orientat ion() == HorizontalScrollbar ? blink::WebThemeEngine::PartScrollbarHorizontalTra ck : blink::WebThemeEngine::PartScrollbarVerticalTrack, state, blink::WebRect(re ct), &extraParams); 87 blink::Platform::current()->themeEngine()->paint(canvas, scrollbar->orientat ion() == HorizontalScrollbar ? blink::WebThemeEngine::PartScrollbarHorizontalTra ck : blink::WebThemeEngine::PartScrollbarVerticalTrack, state, blink::WebRect(re ct), &extraParams);
74 } 88 }
75 89
76 void ScrollbarThemeGtkOrAura::paintButton(GraphicsContext* gc, ScrollbarThemeCli ent* scrollbar, const IntRect& rect, ScrollbarPart part) 90 void ScrollbarThemeGtkOrAura::paintButton(GraphicsContext* gc, ScrollbarThemeCli ent* scrollbar, const IntRect& rect, ScrollbarPart part)
77 { 91 {
78 blink::WebThemeEngine::Part paintPart; 92 blink::WebThemeEngine::Part paintPart;
79 blink::WebThemeEngine::State state = blink::WebThemeEngine::StateNormal; 93 blink::WebThemeEngine::State state = blink::WebThemeEngine::StateNormal;
80 blink::WebCanvas* canvas = gc->canvas(); 94 blink::WebCanvas* canvas = gc->canvas();
81 bool checkMin = false; 95 bool checkMin = false;
82 bool checkMax = false; 96 bool checkMax = false;
97
83 if (scrollbar->orientation() == HorizontalScrollbar) { 98 if (scrollbar->orientation() == HorizontalScrollbar) {
84 if (part == BackButtonStartPart) { 99 if (part == BackButtonStartPart) {
85 paintPart = blink::WebThemeEngine::PartScrollbarLeftArrow; 100 paintPart = blink::WebThemeEngine::PartScrollbarLeftArrow;
86 checkMin = true; 101 checkMin = true;
102 } else if (useMockTheme() && part != ForwardButtonEndPart) {
103 return;
87 } else { 104 } else {
88 paintPart = blink::WebThemeEngine::PartScrollbarRightArrow; 105 paintPart = blink::WebThemeEngine::PartScrollbarRightArrow;
89 checkMax = true; 106 checkMax = true;
90 } 107 }
91 } else { 108 } else {
92 if (part == BackButtonStartPart) { 109 if (part == BackButtonStartPart) {
93 paintPart = blink::WebThemeEngine::PartScrollbarUpArrow; 110 paintPart = blink::WebThemeEngine::PartScrollbarUpArrow;
94 checkMin = true; 111 checkMin = true;
112 } else if (useMockTheme() && part != ForwardButtonEndPart) {
113 return;
95 } else { 114 } else {
96 paintPart = blink::WebThemeEngine::PartScrollbarDownArrow; 115 paintPart = blink::WebThemeEngine::PartScrollbarDownArrow;
97 checkMax = true; 116 checkMax = true;
98 } 117 }
99 } 118 }
100 if ((checkMin && (scrollbar->currentPos() <= 0)) 119 if (useMockTheme() && !scrollbar->enabled()) {
101 || (checkMax && scrollbar->currentPos() == scrollbar->maximum())) { 120 state = blink::WebThemeEngine::StateDisabled;
121 } else if (!useMockTheme() && ((checkMin && (scrollbar->currentPos() <= 0))
122 || (checkMax && scrollbar->currentPos() == scrollbar->maximum()))) {
102 state = blink::WebThemeEngine::StateDisabled; 123 state = blink::WebThemeEngine::StateDisabled;
103 } else { 124 } else {
104 if (part == scrollbar->pressedPart()) 125 if (part == scrollbar->pressedPart())
105 state = blink::WebThemeEngine::StatePressed; 126 state = blink::WebThemeEngine::StatePressed;
106 else if (part == scrollbar->hoveredPart()) 127 else if (part == scrollbar->hoveredPart())
107 state = blink::WebThemeEngine::StateHover; 128 state = blink::WebThemeEngine::StateHover;
108 } 129 }
109 blink::Platform::current()->themeEngine()->paint(canvas, paintPart, state, b link::WebRect(rect), 0); 130 blink::Platform::current()->themeEngine()->paint(canvas, paintPart, state, b link::WebRect(rect), 0);
110 } 131 }
111 132
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (scrollbar->orientation() == VerticalScrollbar) { 165 if (scrollbar->orientation() == VerticalScrollbar) {
145 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink: :WebThemeEngine::PartScrollbarVerticalThumb); 166 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink: :WebThemeEngine::PartScrollbarVerticalThumb);
146 return size.height(); 167 return size.height();
147 } 168 }
148 169
149 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web ThemeEngine::PartScrollbarHorizontalThumb); 170 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web ThemeEngine::PartScrollbarHorizontalThumb);
150 return size.width(); 171 return size.width();
151 } 172 }
152 173
153 } // namespace WebCore 174 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/core/rendering/RenderThemeChromiumDefault.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698