OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "public/platform/WebCanvas.h" | 34 #include "public/platform/WebCanvas.h" |
35 #include "public/platform/WebRect.h" | 35 #include "public/platform/WebRect.h" |
36 #include "public/platform/WebVector.h" | 36 #include "public/platform/WebVector.h" |
37 #include "public/web/WebInputEvent.h" | 37 #include "public/web/WebInputEvent.h" |
38 #include "public/web/WebPluginScrollbarClient.h" | 38 #include "public/web/WebPluginScrollbarClient.h" |
39 #include "web/ScrollbarGroup.h" | 39 #include "web/ScrollbarGroup.h" |
40 #include "web/WebInputEventConversion.h" | 40 #include "web/WebInputEventConversion.h" |
41 #include "web/WebPluginContainerImpl.h" | 41 #include "web/WebPluginContainerImpl.h" |
42 #include "web/WebViewImpl.h" | 42 #include "web/WebViewImpl.h" |
43 | 43 |
44 using namespace WebCore; | 44 using namespace blink; |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 WebPluginScrollbar* WebPluginScrollbar::createForPlugin(Orientation orientation, | 48 WebPluginScrollbar* WebPluginScrollbar::createForPlugin(Orientation orientation, |
49 WebPluginContainer* plug
inContainer, | 49 WebPluginContainer* plug
inContainer, |
50 WebPluginScrollbarClient
* client) | 50 WebPluginScrollbarClient
* client) |
51 { | 51 { |
52 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(pluginContainer); | 52 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(pluginContainer); |
53 return new WebPluginScrollbarImpl(orientation, plugin->scrollbarGroup(), cli
ent); | 53 return new WebPluginScrollbarImpl(orientation, plugin->scrollbarGroup(), cli
ent); |
54 } | 54 } |
55 | 55 |
56 int WebPluginScrollbar::defaultThickness() | 56 int WebPluginScrollbar::defaultThickness() |
57 { | 57 { |
58 return ScrollbarTheme::theme()->scrollbarThickness(); | 58 return ScrollbarTheme::theme()->scrollbarThickness(); |
59 } | 59 } |
60 | 60 |
61 WebPluginScrollbarImpl::WebPluginScrollbarImpl(Orientation orientation, | 61 WebPluginScrollbarImpl::WebPluginScrollbarImpl(Orientation orientation, |
62 ScrollbarGroup* group, | 62 ScrollbarGroup* group, |
63 WebPluginScrollbarClient* client) | 63 WebPluginScrollbarClient* client) |
64 : m_group(group) | 64 : m_group(group) |
65 , m_client(client) | 65 , m_client(client) |
66 , m_scrollOffset(0) | 66 , m_scrollOffset(0) |
67 { | 67 { |
68 m_scrollbar = Scrollbar::create( | 68 m_scrollbar = Scrollbar::create( |
69 static_cast<ScrollableArea*>(m_group), | 69 static_cast<ScrollableArea*>(m_group), |
70 static_cast<WebCore::ScrollbarOrientation>(orientation), | 70 static_cast<blink::ScrollbarOrientation>(orientation), |
71 WebCore::RegularScrollbar); | 71 blink::RegularScrollbar); |
72 m_group->scrollbarCreated(this); | 72 m_group->scrollbarCreated(this); |
73 } | 73 } |
74 | 74 |
75 WebPluginScrollbarImpl::~WebPluginScrollbarImpl() | 75 WebPluginScrollbarImpl::~WebPluginScrollbarImpl() |
76 { | 76 { |
77 m_group->scrollbarDestroyed(this); | 77 m_group->scrollbarDestroyed(this); |
78 } | 78 } |
79 | 79 |
80 void WebPluginScrollbarImpl::setScrollOffset(int scrollOffset) | 80 void WebPluginScrollbarImpl::setScrollOffset(int scrollOffset) |
81 { | 81 { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return static_cast<WebScrollbar::ScrollbarPart>(m_scrollbar->hoveredPart()); | 176 return static_cast<WebScrollbar::ScrollbarPart>(m_scrollbar->hoveredPart()); |
177 } | 177 } |
178 | 178 |
179 WebScrollbar::ScrollbarOverlayStyle WebPluginScrollbarImpl::scrollbarOverlayStyl
e() const | 179 WebScrollbar::ScrollbarOverlayStyle WebPluginScrollbarImpl::scrollbarOverlayStyl
e() const |
180 { | 180 { |
181 return static_cast<WebScrollbar::ScrollbarOverlayStyle>(m_scrollbar->scrollb
arOverlayStyle()); | 181 return static_cast<WebScrollbar::ScrollbarOverlayStyle>(m_scrollbar->scrollb
arOverlayStyle()); |
182 } | 182 } |
183 | 183 |
184 WebScrollbar::Orientation WebPluginScrollbarImpl::orientation() const | 184 WebScrollbar::Orientation WebPluginScrollbarImpl::orientation() const |
185 { | 185 { |
186 if (m_scrollbar->orientation() == WebCore::HorizontalScrollbar) | 186 if (m_scrollbar->orientation() == blink::HorizontalScrollbar) |
187 return WebScrollbar::Horizontal; | 187 return WebScrollbar::Horizontal; |
188 return WebScrollbar::Vertical; | 188 return WebScrollbar::Vertical; |
189 } | 189 } |
190 | 190 |
191 bool WebPluginScrollbarImpl::isLeftSideVerticalScrollbar() const | 191 bool WebPluginScrollbarImpl::isLeftSideVerticalScrollbar() const |
192 { | 192 { |
193 return false; | 193 return false; |
194 } | 194 } |
195 | 195 |
196 bool WebPluginScrollbarImpl::isCustomScrollbar() const | 196 bool WebPluginScrollbarImpl::isCustomScrollbar() const |
(...skipping 20 matching lines...) Expand all Loading... |
217 | 217 |
218 void WebPluginScrollbarImpl::setDocumentSize(int size) | 218 void WebPluginScrollbarImpl::setDocumentSize(int size) |
219 { | 219 { |
220 int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar
->width() : m_scrollbar->height(); | 220 int length = m_scrollbar->orientation() == HorizontalScrollbar ? m_scrollbar
->width() : m_scrollbar->height(); |
221 m_scrollbar->setEnabled(size > length); | 221 m_scrollbar->setEnabled(size > length); |
222 m_scrollbar->setProportion(length, size); | 222 m_scrollbar->setProportion(length, size); |
223 } | 223 } |
224 | 224 |
225 void WebPluginScrollbarImpl::scroll(ScrollDirection direction, ScrollGranularity
granularity, float multiplier) | 225 void WebPluginScrollbarImpl::scroll(ScrollDirection direction, ScrollGranularity
granularity, float multiplier) |
226 { | 226 { |
227 WebCore::ScrollDirection dir; | 227 blink::ScrollDirection dir; |
228 bool horizontal = m_scrollbar->orientation() == HorizontalScrollbar; | 228 bool horizontal = m_scrollbar->orientation() == HorizontalScrollbar; |
229 if (direction == ScrollForward) | 229 if (direction == ScrollForward) |
230 dir = horizontal ? ScrollRight : ScrollDown; | 230 dir = horizontal ? ScrollRight : ScrollDown; |
231 else | 231 else |
232 dir = horizontal ? ScrollLeft : ScrollUp; | 232 dir = horizontal ? ScrollLeft : ScrollUp; |
233 | 233 |
234 m_group->scroll(dir, static_cast<WebCore::ScrollGranularity>(granularity), m
ultiplier); | 234 m_group->scroll(dir, static_cast<blink::ScrollGranularity>(granularity), mul
tiplier); |
235 } | 235 } |
236 | 236 |
237 void WebPluginScrollbarImpl::paint(WebCanvas* canvas, const WebRect& rect) | 237 void WebPluginScrollbarImpl::paint(WebCanvas* canvas, const WebRect& rect) |
238 { | 238 { |
239 GraphicsContext context(canvas); | 239 GraphicsContext context(canvas); |
240 m_scrollbar->paint(&context, rect); | 240 m_scrollbar->paint(&context, rect); |
241 } | 241 } |
242 | 242 |
243 bool WebPluginScrollbarImpl::handleInputEvent(const WebInputEvent& event) | 243 bool WebPluginScrollbarImpl::handleInputEvent(const WebInputEvent& event) |
244 { | 244 { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 288 |
289 mousedown.x -= m_scrollbar->x(); | 289 mousedown.x -= m_scrollbar->x(); |
290 mousedown.y -= m_scrollbar->y(); | 290 mousedown.y -= m_scrollbar->y(); |
291 m_scrollbar->mouseDown(PlatformMouseEventBuilder(m_scrollbar.get(), mousedow
n)); | 291 m_scrollbar->mouseDown(PlatformMouseEventBuilder(m_scrollbar.get(), mousedow
n)); |
292 return true; | 292 return true; |
293 } | 293 } |
294 | 294 |
295 bool WebPluginScrollbarImpl::onMouseUp(const WebInputEvent& event) | 295 bool WebPluginScrollbarImpl::onMouseUp(const WebInputEvent& event) |
296 { | 296 { |
297 WebMouseEvent mouseup = static_cast<const WebMouseEvent&>(event); | 297 WebMouseEvent mouseup = static_cast<const WebMouseEvent&>(event); |
298 if (m_scrollbar->pressedPart() == WebCore::NoPart) | 298 if (m_scrollbar->pressedPart() == blink::NoPart) |
299 return false; | 299 return false; |
300 | 300 |
301 m_scrollbar->mouseUp(PlatformMouseEventBuilder(m_scrollbar.get(), mouseup)); | 301 m_scrollbar->mouseUp(PlatformMouseEventBuilder(m_scrollbar.get(), mouseup)); |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 bool WebPluginScrollbarImpl::onMouseMove(const WebInputEvent& event) | 305 bool WebPluginScrollbarImpl::onMouseMove(const WebInputEvent& event) |
306 { | 306 { |
307 WebMouseEvent mousemove = static_cast<const WebMouseEvent&>(event); | 307 WebMouseEvent mousemove = static_cast<const WebMouseEvent&>(event); |
308 if (m_scrollbar->frameRect().contains(mousemove.x, mousemove.y) | 308 if (m_scrollbar->frameRect().contains(mousemove.x, mousemove.y) |
309 || m_scrollbar->pressedPart() != WebCore::NoPart) { | 309 || m_scrollbar->pressedPart() != blink::NoPart) { |
310 mousemove.x -= m_scrollbar->x(); | 310 mousemove.x -= m_scrollbar->x(); |
311 mousemove.y -= m_scrollbar->y(); | 311 mousemove.y -= m_scrollbar->y(); |
312 m_scrollbar->mouseMoved(PlatformMouseEventBuilder(m_scrollbar.get(), mou
semove)); | 312 m_scrollbar->mouseMoved(PlatformMouseEventBuilder(m_scrollbar.get(), mou
semove)); |
313 return true; | 313 return true; |
314 } | 314 } |
315 | 315 |
316 if (m_scrollbar->hoveredPart() != WebCore::NoPart && !m_scrollbar->isOverlay
Scrollbar()) | 316 if (m_scrollbar->hoveredPart() != blink::NoPart && !m_scrollbar->isOverlaySc
rollbar()) |
317 m_scrollbar->mouseExited(); | 317 m_scrollbar->mouseExited(); |
318 return false; | 318 return false; |
319 } | 319 } |
320 | 320 |
321 bool WebPluginScrollbarImpl::onMouseLeave(const WebInputEvent& event) | 321 bool WebPluginScrollbarImpl::onMouseLeave(const WebInputEvent& event) |
322 { | 322 { |
323 if (m_scrollbar->hoveredPart() != WebCore::NoPart) | 323 if (m_scrollbar->hoveredPart() != blink::NoPart) |
324 m_scrollbar->mouseExited(); | 324 m_scrollbar->mouseExited(); |
325 | 325 |
326 return false; | 326 return false; |
327 } | 327 } |
328 | 328 |
329 bool WebPluginScrollbarImpl::onMouseWheel(const WebInputEvent& event) | 329 bool WebPluginScrollbarImpl::onMouseWheel(const WebInputEvent& event) |
330 { | 330 { |
331 WebMouseWheelEvent mousewheel = static_cast<const WebMouseWheelEvent&>(event
); | 331 WebMouseWheelEvent mousewheel = static_cast<const WebMouseWheelEvent&>(event
); |
332 PlatformWheelEventBuilder platformEvent(m_scrollbar.get(), mousewheel); | 332 PlatformWheelEventBuilder platformEvent(m_scrollbar.get(), mousewheel); |
333 return m_group->handleWheelEvent(platformEvent); | 333 return m_group->handleWheelEvent(platformEvent); |
(...skipping 20 matching lines...) Expand all Loading... |
354 default: | 354 default: |
355 return false; | 355 return false; |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
359 if (keyboard.isSystemKey || (keyboard.modifiers & WebInputEvent::ShiftKe
y)) | 359 if (keyboard.isSystemKey || (keyboard.modifiers & WebInputEvent::ShiftKe
y)) |
360 return false; | 360 return false; |
361 | 361 |
362 keyCode = keyboard.windowsKeyCode; | 362 keyCode = keyboard.windowsKeyCode; |
363 } | 363 } |
364 WebCore::ScrollDirection scrollDirection; | 364 blink::ScrollDirection scrollDirection; |
365 WebCore::ScrollGranularity scrollGranularity; | 365 blink::ScrollGranularity scrollGranularity; |
366 if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranu
larity)) { | 366 if (WebViewImpl::mapKeyCodeForScroll(keyCode, &scrollDirection, &scrollGranu
larity)) { |
367 // Will return false if scroll direction wasn't compatible with this scr
ollbar. | 367 // Will return false if scroll direction wasn't compatible with this scr
ollbar. |
368 return m_group->scroll(scrollDirection, scrollGranularity); | 368 return m_group->scroll(scrollDirection, scrollGranularity); |
369 } | 369 } |
370 return false; | 370 return false; |
371 } | 371 } |
372 | 372 |
373 } // namespace blink | 373 } // namespace blink |
OLD | NEW |