OLD | NEW |
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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return &theme; | 49 return &theme; |
50 } | 50 } |
51 | 51 |
52 DEFINE_STATIC_LOCAL(ScrollbarThemeGtkOrAura, theme, ()); | 52 DEFINE_STATIC_LOCAL(ScrollbarThemeGtkOrAura, theme, ()); |
53 return &theme; | 53 return &theme; |
54 } | 54 } |
55 | 55 |
56 int ScrollbarThemeGtkOrAura::scrollbarThickness(ScrollbarControlSize controlSize
) | 56 int ScrollbarThemeGtkOrAura::scrollbarThickness(ScrollbarControlSize controlSize
) |
57 { | 57 { |
58 // Horiz and Vert scrollbars are the same thickness. | 58 // Horiz and Vert scrollbars are the same thickness. |
59 IntSize scrollbarSize = WebKit::Platform::current()->themeEngine()->getSize(
WebKit::WebThemeEngine::PartScrollbarVerticalTrack); | 59 IntSize scrollbarSize = blink::Platform::current()->themeEngine()->getSize(b
link::WebThemeEngine::PartScrollbarVerticalTrack); |
60 return scrollbarSize.width(); | 60 return scrollbarSize.width(); |
61 } | 61 } |
62 | 62 |
63 void ScrollbarThemeGtkOrAura::paintTrackPiece(GraphicsContext* gc, ScrollbarThem
eClient* scrollbar, const IntRect& rect, ScrollbarPart partType) | 63 void ScrollbarThemeGtkOrAura::paintTrackPiece(GraphicsContext* gc, ScrollbarThem
eClient* scrollbar, const IntRect& rect, ScrollbarPart partType) |
64 { | 64 { |
65 WebKit::WebThemeEngine::State state = scrollbar->hoveredPart() == partType ?
WebKit::WebThemeEngine::StateHover : WebKit::WebThemeEngine::StateNormal; | 65 blink::WebThemeEngine::State state = scrollbar->hoveredPart() == partType ?
blink::WebThemeEngine::StateHover : blink::WebThemeEngine::StateNormal; |
66 IntRect alignRect = trackRect(scrollbar, false); | 66 IntRect alignRect = trackRect(scrollbar, false); |
67 WebKit::WebThemeEngine::ExtraParams extraParams; | 67 blink::WebThemeEngine::ExtraParams extraParams; |
68 WebKit::WebCanvas* canvas = gc->canvas(); | 68 blink::WebCanvas* canvas = gc->canvas(); |
69 extraParams.scrollbarTrack.trackX = alignRect.x(); | 69 extraParams.scrollbarTrack.trackX = alignRect.x(); |
70 extraParams.scrollbarTrack.trackY = alignRect.y(); | 70 extraParams.scrollbarTrack.trackY = alignRect.y(); |
71 extraParams.scrollbarTrack.trackWidth = alignRect.width(); | 71 extraParams.scrollbarTrack.trackWidth = alignRect.width(); |
72 extraParams.scrollbarTrack.trackHeight = alignRect.height(); | 72 extraParams.scrollbarTrack.trackHeight = alignRect.height(); |
73 WebKit::Platform::current()->themeEngine()->paint(canvas, scrollbar->orienta
tion() == HorizontalScrollbar ? WebKit::WebThemeEngine::PartScrollbarHorizontalT
rack : WebKit::WebThemeEngine::PartScrollbarVerticalTrack, state, WebKit::WebRec
t(rect), &extraParams); | 73 blink::Platform::current()->themeEngine()->paint(canvas, scrollbar->orientat
ion() == HorizontalScrollbar ? blink::WebThemeEngine::PartScrollbarHorizontalTra
ck : blink::WebThemeEngine::PartScrollbarVerticalTrack, state, blink::WebRect(re
ct), &extraParams); |
74 } | 74 } |
75 | 75 |
76 void ScrollbarThemeGtkOrAura::paintButton(GraphicsContext* gc, ScrollbarThemeCli
ent* scrollbar, const IntRect& rect, ScrollbarPart part) | 76 void ScrollbarThemeGtkOrAura::paintButton(GraphicsContext* gc, ScrollbarThemeCli
ent* scrollbar, const IntRect& rect, ScrollbarPart part) |
77 { | 77 { |
78 WebKit::WebThemeEngine::Part paintPart; | 78 blink::WebThemeEngine::Part paintPart; |
79 WebKit::WebThemeEngine::State state = WebKit::WebThemeEngine::StateNormal; | 79 blink::WebThemeEngine::State state = blink::WebThemeEngine::StateNormal; |
80 WebKit::WebCanvas* canvas = gc->canvas(); | 80 blink::WebCanvas* canvas = gc->canvas(); |
81 bool checkMin = false; | 81 bool checkMin = false; |
82 bool checkMax = false; | 82 bool checkMax = false; |
83 if (scrollbar->orientation() == HorizontalScrollbar) { | 83 if (scrollbar->orientation() == HorizontalScrollbar) { |
84 if (part == BackButtonStartPart) { | 84 if (part == BackButtonStartPart) { |
85 paintPart = WebKit::WebThemeEngine::PartScrollbarLeftArrow; | 85 paintPart = blink::WebThemeEngine::PartScrollbarLeftArrow; |
86 checkMin = true; | 86 checkMin = true; |
87 } else { | 87 } else { |
88 paintPart = WebKit::WebThemeEngine::PartScrollbarRightArrow; | 88 paintPart = blink::WebThemeEngine::PartScrollbarRightArrow; |
89 checkMax = true; | 89 checkMax = true; |
90 } | 90 } |
91 } else { | 91 } else { |
92 if (part == BackButtonStartPart) { | 92 if (part == BackButtonStartPart) { |
93 paintPart = WebKit::WebThemeEngine::PartScrollbarUpArrow; | 93 paintPart = blink::WebThemeEngine::PartScrollbarUpArrow; |
94 checkMin = true; | 94 checkMin = true; |
95 } else { | 95 } else { |
96 paintPart = WebKit::WebThemeEngine::PartScrollbarDownArrow; | 96 paintPart = blink::WebThemeEngine::PartScrollbarDownArrow; |
97 checkMax = true; | 97 checkMax = true; |
98 } | 98 } |
99 } | 99 } |
100 if ((checkMin && (scrollbar->currentPos() <= 0)) | 100 if ((checkMin && (scrollbar->currentPos() <= 0)) |
101 || (checkMax && scrollbar->currentPos() == scrollbar->maximum())) { | 101 || (checkMax && scrollbar->currentPos() == scrollbar->maximum())) { |
102 state = WebKit::WebThemeEngine::StateDisabled; | 102 state = blink::WebThemeEngine::StateDisabled; |
103 } else { | 103 } else { |
104 if (part == scrollbar->pressedPart()) | 104 if (part == scrollbar->pressedPart()) |
105 state = WebKit::WebThemeEngine::StatePressed; | 105 state = blink::WebThemeEngine::StatePressed; |
106 else if (part == scrollbar->hoveredPart()) | 106 else if (part == scrollbar->hoveredPart()) |
107 state = WebKit::WebThemeEngine::StateHover; | 107 state = blink::WebThemeEngine::StateHover; |
108 } | 108 } |
109 WebKit::Platform::current()->themeEngine()->paint(canvas, paintPart, state,
WebKit::WebRect(rect), 0); | 109 blink::Platform::current()->themeEngine()->paint(canvas, paintPart, state, b
link::WebRect(rect), 0); |
110 } | 110 } |
111 | 111 |
112 void ScrollbarThemeGtkOrAura::paintThumb(GraphicsContext* gc, ScrollbarThemeClie
nt* scrollbar, const IntRect& rect) | 112 void ScrollbarThemeGtkOrAura::paintThumb(GraphicsContext* gc, ScrollbarThemeClie
nt* scrollbar, const IntRect& rect) |
113 { | 113 { |
114 WebKit::WebThemeEngine::State state; | 114 blink::WebThemeEngine::State state; |
115 WebKit::WebCanvas* canvas = gc->canvas(); | 115 blink::WebCanvas* canvas = gc->canvas(); |
116 if (scrollbar->pressedPart() == ThumbPart) | 116 if (scrollbar->pressedPart() == ThumbPart) |
117 state = WebKit::WebThemeEngine::StatePressed; | 117 state = blink::WebThemeEngine::StatePressed; |
118 else if (scrollbar->hoveredPart() == ThumbPart) | 118 else if (scrollbar->hoveredPart() == ThumbPart) |
119 state = WebKit::WebThemeEngine::StateHover; | 119 state = blink::WebThemeEngine::StateHover; |
120 else | 120 else |
121 state = WebKit::WebThemeEngine::StateNormal; | 121 state = blink::WebThemeEngine::StateNormal; |
122 WebKit::Platform::current()->themeEngine()->paint(canvas, scrollbar->orienta
tion() == HorizontalScrollbar ? WebKit::WebThemeEngine::PartScrollbarHorizontalT
humb : WebKit::WebThemeEngine::PartScrollbarVerticalThumb, state, WebKit::WebRec
t(rect), 0); | 122 blink::Platform::current()->themeEngine()->paint(canvas, scrollbar->orientat
ion() == HorizontalScrollbar ? blink::WebThemeEngine::PartScrollbarHorizontalThu
mb : blink::WebThemeEngine::PartScrollbarVerticalThumb, state, blink::WebRect(re
ct), 0); |
123 } | 123 } |
124 | 124 |
125 bool ScrollbarThemeGtkOrAura::shouldCenterOnThumb(ScrollbarThemeClient*, const P
latformMouseEvent& evt) | 125 bool ScrollbarThemeGtkOrAura::shouldCenterOnThumb(ScrollbarThemeClient*, const P
latformMouseEvent& evt) |
126 { | 126 { |
127 return (evt.shiftKey() && evt.button() == LeftButton) || (evt.button() == Mi
ddleButton); | 127 return (evt.shiftKey() && evt.button() == LeftButton) || (evt.button() == Mi
ddleButton); |
128 } | 128 } |
129 | 129 |
130 IntSize ScrollbarThemeGtkOrAura::buttonSize(ScrollbarThemeClient* scrollbar) | 130 IntSize ScrollbarThemeGtkOrAura::buttonSize(ScrollbarThemeClient* scrollbar) |
131 { | 131 { |
132 if (scrollbar->orientation() == VerticalScrollbar) { | 132 if (scrollbar->orientation() == VerticalScrollbar) { |
133 IntSize size = WebKit::Platform::current()->themeEngine()->getSize(WebKi
t::WebThemeEngine::PartScrollbarUpArrow); | 133 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink:
:WebThemeEngine::PartScrollbarUpArrow); |
134 return IntSize(size.width(), scrollbar->height() < 2 * size.height() ? s
crollbar->height() / 2 : size.height()); | 134 return IntSize(size.width(), scrollbar->height() < 2 * size.height() ? s
crollbar->height() / 2 : size.height()); |
135 } | 135 } |
136 | 136 |
137 // HorizontalScrollbar | 137 // HorizontalScrollbar |
138 IntSize size = WebKit::Platform::current()->themeEngine()->getSize(WebKit::W
ebThemeEngine::PartScrollbarLeftArrow); | 138 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web
ThemeEngine::PartScrollbarLeftArrow); |
139 return IntSize(scrollbar->width() < 2 * size.width() ? scrollbar->width() /
2 : size.width(), size.height()); | 139 return IntSize(scrollbar->width() < 2 * size.width() ? scrollbar->width() /
2 : size.width(), size.height()); |
140 } | 140 } |
141 | 141 |
142 int ScrollbarThemeGtkOrAura::minimumThumbLength(ScrollbarThemeClient* scrollbar) | 142 int ScrollbarThemeGtkOrAura::minimumThumbLength(ScrollbarThemeClient* scrollbar) |
143 { | 143 { |
144 if (scrollbar->orientation() == VerticalScrollbar) { | 144 if (scrollbar->orientation() == VerticalScrollbar) { |
145 IntSize size = WebKit::Platform::current()->themeEngine()->getSize(WebKi
t::WebThemeEngine::PartScrollbarVerticalThumb); | 145 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink:
:WebThemeEngine::PartScrollbarVerticalThumb); |
146 return size.height(); | 146 return size.height(); |
147 } | 147 } |
148 | 148 |
149 IntSize size = WebKit::Platform::current()->themeEngine()->getSize(WebKit::W
ebThemeEngine::PartScrollbarHorizontalThumb); | 149 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web
ThemeEngine::PartScrollbarHorizontalThumb); |
150 return size.width(); | 150 return size.width(); |
151 } | 151 } |
152 | 152 |
153 } // namespace WebCore | 153 } // namespace WebCore |
OLD | NEW |