OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "web/FrameletClientImpl.h" |
| 6 |
| 7 #include "core/events/GestureEvent.h" |
| 8 #include "core/events/KeyboardEvent.h" |
| 9 #include "core/events/MouseEvent.h" |
| 10 #include "core/events/TouchEvent.h" |
| 11 #include "core/events/WheelEvent.h" |
| 12 #include "core/frame/FrameletView.h" |
| 13 #include "core/layout/LayoutPart.h" |
| 14 #include "public/web/WebFrameletClient.h" |
| 15 #include "web/WebFrameletImpl.h" |
| 16 #include "web/WebInputEventConversion.h" |
| 17 |
| 18 namespace blink { |
| 19 |
| 20 FrameletClientImpl::FrameletClientImpl(WebFrameletImpl* webFrame) |
| 21 : m_webFramelet(webFrame) |
| 22 { |
| 23 } |
| 24 |
| 25 PassOwnPtrWillBeRawPtr<FrameletClientImpl> FrameletClientImpl::create(WebFramele
tImpl* webFramelet) |
| 26 { |
| 27 return adoptPtrWillBeNoop(new FrameletClientImpl(webFramelet)); |
| 28 } |
| 29 |
| 30 DEFINE_TRACE(FrameletClientImpl) |
| 31 { |
| 32 visitor->trace(m_webFramelet); |
| 33 FrameletClient::trace(visitor); |
| 34 } |
| 35 |
| 36 void FrameletClientImpl::didAttach() |
| 37 { |
| 38 m_webFramelet->client()->didAttach(m_webFramelet); |
| 39 } |
| 40 |
| 41 void FrameletClientImpl::didDetach() |
| 42 { |
| 43 m_webFramelet->client()->didDetach(); |
| 44 } |
| 45 |
| 46 // FIXME: Remove this code once we have input routing in the browser |
| 47 // process. See http://crbug.com/339659. |
| 48 void FrameletClientImpl::forwardInputEvent(Event* event) |
| 49 { |
| 50 // See https://crbug.com/520705. |
| 51 // FIXME: We should eventually do direct routing of input. |
| 52 if (!m_webFramelet->framelet()->ownerLayoutObject()) |
| 53 return; |
| 54 |
| 55 OwnPtr<WebInputEvent> webEvent; |
| 56 if (event->isKeyboardEvent()) |
| 57 webEvent = adoptPtr(new WebKeyboardEventBuilder(*static_cast<KeyboardEve
nt*>(event))); |
| 58 else if (event->isMouseEvent()) |
| 59 webEvent = adoptPtr(new WebMouseEventBuilder(m_webFramelet->framelet()->
view(), m_webFramelet->framelet()->ownerLayoutObject(), *static_cast<MouseEvent*
>(event))); |
| 60 else if (event->isWheelEvent()) |
| 61 webEvent = adoptPtr(new WebMouseWheelEventBuilder(m_webFramelet->framele
t()->view(), m_webFramelet->framelet()->ownerLayoutObject(), *static_cast<WheelE
vent*>(event))); |
| 62 else if (event->isGestureEvent()) |
| 63 webEvent = adoptPtr(new WebGestureEventBuilder(m_webFramelet->framelet()
->ownerLayoutObject(), *static_cast<GestureEvent*>(event))); |
| 64 else if (event->isTouchEvent()) |
| 65 webEvent = adoptPtr(new WebTouchEventBuilder(m_webFramelet->framelet()->
ownerLayoutObject(), *static_cast<TouchEvent*>(event))); |
| 66 |
| 67 // Other or internal Blink events should not be forwarded. |
| 68 if (!webEvent || webEvent->type == WebInputEvent::Undefined) |
| 69 return; |
| 70 |
| 71 m_webFramelet->client()->forwardInputEvent(webEvent.get()); |
| 72 } |
| 73 |
| 74 void FrameletClientImpl::frameRectsChanged(const IntRect& frameRect) |
| 75 { |
| 76 m_webFramelet->client()->frameRectsChanged(frameRect); |
| 77 } |
| 78 |
| 79 void FrameletClientImpl::updateFocus(bool focused, WebFocusType type) |
| 80 { |
| 81 m_webFramelet->client()->updateFocus(focused, type); |
| 82 } |
| 83 |
| 84 void FrameletClientImpl::updateVisibility(bool visible) |
| 85 { |
| 86 m_webFramelet->client()->updateVisibility(visible); |
| 87 } |
| 88 |
| 89 } // namespace blink |
OLD | NEW |