Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 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 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2163 &inputEvent); | 2163 &inputEvent); |
| 2164 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); | 2164 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); |
| 2165 | 2165 |
| 2166 bool isPointerLocked = false; | 2166 bool isPointerLocked = false; |
| 2167 if (WebFrameWidgetBase* widget = mainFrameImpl()->frameWidget()) { | 2167 if (WebFrameWidgetBase* widget = mainFrameImpl()->frameWidget()) { |
| 2168 if (WebWidgetClient* client = widget->client()) | 2168 if (WebWidgetClient* client = widget->client()) |
| 2169 isPointerLocked = client->isPointerLocked(); | 2169 isPointerLocked = client->isPointerLocked(); |
| 2170 } | 2170 } |
| 2171 | 2171 |
| 2172 if (isPointerLocked && WebInputEvent::isMouseEventType(inputEvent.type())) { | 2172 if (isPointerLocked && WebInputEvent::isMouseEventType(inputEvent.type())) { |
| 2173 pointerLockMouseEvent(inputEvent); | 2173 mainFrameImpl()->frameWidget()->pointerLockMouseEvent(inputEvent); |
| 2174 return WebInputEventResult::HandledSystem; | 2174 return WebInputEventResult::HandledSystem; |
| 2175 } | 2175 } |
| 2176 | 2176 |
| 2177 if (m_mouseCaptureNode && | 2177 if (m_mouseCaptureNode && |
| 2178 WebInputEvent::isMouseEventType(inputEvent.type())) { | 2178 WebInputEvent::isMouseEventType(inputEvent.type())) { |
| 2179 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type()); | 2179 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type()); |
| 2180 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. | 2180 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. |
| 2181 Node* node = m_mouseCaptureNode; | 2181 Node* node = m_mouseCaptureNode; |
| 2182 | 2182 |
| 2183 // Not all platforms call mouseCaptureLost() directly. | 2183 // Not all platforms call mouseCaptureLost() directly. |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2516 page()->willCloseLayerTreeView(*m_layerTreeView, nullptr); | 2516 page()->willCloseLayerTreeView(*m_layerTreeView, nullptr); |
| 2517 | 2517 |
| 2518 setRootLayer(nullptr); | 2518 setRootLayer(nullptr); |
| 2519 m_animationHost = nullptr; | 2519 m_animationHost = nullptr; |
| 2520 | 2520 |
| 2521 m_mutator = nullptr; | 2521 m_mutator = nullptr; |
| 2522 m_layerTreeView = nullptr; | 2522 m_layerTreeView = nullptr; |
| 2523 } | 2523 } |
| 2524 | 2524 |
| 2525 void WebViewImpl::didAcquirePointerLock() { | 2525 void WebViewImpl::didAcquirePointerLock() { |
| 2526 if (page()) | 2526 mainFrameImpl()->frameWidget()->didAcquirePointerLock(); |
| 2527 page()->pointerLockController().didAcquirePointerLock(); | |
| 2528 } | 2527 } |
| 2529 | 2528 |
| 2530 void WebViewImpl::didNotAcquirePointerLock() { | 2529 void WebViewImpl::didNotAcquirePointerLock() { |
| 2531 if (page()) | 2530 mainFrameImpl()->frameWidget()->didNotAcquirePointerLock(); |
| 2532 page()->pointerLockController().didNotAcquirePointerLock(); | |
| 2533 } | 2531 } |
| 2534 | 2532 |
| 2535 void WebViewImpl::didLosePointerLock() { | 2533 void WebViewImpl::didLosePointerLock() { |
| 2536 m_pointerLockGestureToken.clear(); | 2534 mainFrameImpl()->frameWidget()->didLosePointerLock(); |
|
dcheng
2017/02/13 23:21:28
Can we remove these from being exposed via WebView
lfg
2017/02/14 15:42:49
Not until more work is done; in particular, the Re
dcheng
2017/02/14 19:20:28
Is this something the content side patches that yo
lfg
2017/02/14 19:29:03
No, unfortunately not. This is due to the design o
dcheng
2017/02/14 23:46:10
I assume we have a long-term bug for cleaning this
| |
| 2537 if (page()) | |
| 2538 page()->pointerLockController().didLosePointerLock(); | |
| 2539 } | 2535 } |
| 2540 | 2536 |
| 2541 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as | 2537 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as |
| 2542 // well. This code needs to be refactored (http://crbug.com/629721). | 2538 // well. This code needs to be refactored (http://crbug.com/629721). |
| 2543 bool WebViewImpl::getCompositionCharacterBounds(WebVector<WebRect>& bounds) { | 2539 bool WebViewImpl::getCompositionCharacterBounds(WebVector<WebRect>& bounds) { |
| 2544 WebRange range = compositionRange(); | 2540 WebRange range = compositionRange(); |
| 2545 if (range.isEmpty()) | 2541 if (range.isEmpty()) |
| 2546 return false; | 2542 return false; |
| 2547 | 2543 |
| 2548 WebLocalFrame* frame = focusedFrame(); | 2544 WebLocalFrame* frame = focusedFrame(); |
| (...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4078 | 4074 |
| 4079 void WebViewImpl::setCompositorVisibility(bool isVisible) { | 4075 void WebViewImpl::setCompositorVisibility(bool isVisible) { |
| 4080 if (!isVisible) | 4076 if (!isVisible) |
| 4081 m_overrideCompositorVisibility = true; | 4077 m_overrideCompositorVisibility = true; |
| 4082 else | 4078 else |
| 4083 m_overrideCompositorVisibility = false; | 4079 m_overrideCompositorVisibility = false; |
| 4084 if (m_layerTreeView) | 4080 if (m_layerTreeView) |
| 4085 m_layerTreeView->setVisible(isVisible); | 4081 m_layerTreeView->setVisible(isVisible); |
| 4086 } | 4082 } |
| 4087 | 4083 |
| 4088 void WebViewImpl::pointerLockMouseEvent(const WebInputEvent& event) { | |
| 4089 std::unique_ptr<UserGestureIndicator> gestureIndicator; | |
| 4090 AtomicString eventType; | |
| 4091 switch (event.type()) { | |
| 4092 case WebInputEvent::MouseDown: | |
| 4093 eventType = EventTypeNames::mousedown; | |
| 4094 if (!page() || !page()->pointerLockController().element()) | |
| 4095 break; | |
| 4096 gestureIndicator = WTF::wrapUnique( | |
| 4097 new UserGestureIndicator(DocumentUserGestureToken::create( | |
| 4098 &page()->pointerLockController().element()->document(), | |
| 4099 UserGestureToken::NewGesture))); | |
| 4100 m_pointerLockGestureToken = gestureIndicator->currentToken(); | |
| 4101 break; | |
| 4102 case WebInputEvent::MouseUp: | |
| 4103 eventType = EventTypeNames::mouseup; | |
| 4104 gestureIndicator = WTF::wrapUnique( | |
| 4105 new UserGestureIndicator(m_pointerLockGestureToken.release())); | |
| 4106 break; | |
| 4107 case WebInputEvent::MouseMove: | |
| 4108 eventType = EventTypeNames::mousemove; | |
| 4109 break; | |
| 4110 default: | |
| 4111 NOTREACHED(); | |
| 4112 } | |
| 4113 | |
| 4114 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); | |
| 4115 | |
| 4116 if (page()) { | |
| 4117 WebMouseEvent transformedEvent = | |
| 4118 TransformWebMouseEvent(mainFrameImpl()->frameView(), mouseEvent); | |
| 4119 page()->pointerLockController().dispatchLockedMouseEvent(transformedEvent, | |
| 4120 eventType); | |
| 4121 } | |
| 4122 } | |
| 4123 | |
| 4124 void WebViewImpl::forceNextWebGLContextCreationToFail() { | 4084 void WebViewImpl::forceNextWebGLContextCreationToFail() { |
| 4125 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4085 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
| 4126 } | 4086 } |
| 4127 | 4087 |
| 4128 void WebViewImpl::forceNextDrawingBufferCreationToFail() { | 4088 void WebViewImpl::forceNextDrawingBufferCreationToFail() { |
| 4129 DrawingBuffer::forceNextDrawingBufferCreationToFail(); | 4089 DrawingBuffer::forceNextDrawingBufferCreationToFail(); |
| 4130 } | 4090 } |
| 4131 | 4091 |
| 4132 CompositorMutatorImpl& WebViewImpl::mutator() { | 4092 CompositorMutatorImpl& WebViewImpl::mutator() { |
| 4133 if (!m_mutator) { | 4093 if (!m_mutator) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4176 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) | 4136 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) |
| 4177 return nullptr; | 4137 return nullptr; |
| 4178 return focusedFrame; | 4138 return focusedFrame; |
| 4179 } | 4139 } |
| 4180 | 4140 |
| 4181 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { | 4141 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { |
| 4182 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4142 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
| 4183 } | 4143 } |
| 4184 | 4144 |
| 4185 } // namespace blink | 4145 } // namespace blink |
| OLD | NEW |