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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 { | 273 { |
274 if (!*m_userGestureObserved && UserGestureIndicator::processedUserGestureSin
ceLoad()) { | 274 if (!*m_userGestureObserved && UserGestureIndicator::processedUserGestureSin
ceLoad()) { |
275 *m_userGestureObserved = true; | 275 *m_userGestureObserved = true; |
276 if (m_client) | 276 if (m_client) |
277 m_client->firstUserGestureObserved(); | 277 m_client->firstUserGestureObserved(); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 class EmptyEventListener final : public EventListener { | 281 class EmptyEventListener final : public EventListener { |
282 public: | 282 public: |
283 static RawPtr<EmptyEventListener> create() | 283 static EmptyEventListener* create() |
284 { | 284 { |
285 return new EmptyEventListener(); | 285 return new EmptyEventListener(); |
286 } | 286 } |
287 | 287 |
288 bool operator==(const EventListener& other) const override | 288 bool operator==(const EventListener& other) const override |
289 { | 289 { |
290 return this == &other; | 290 return this == &other; |
291 } | 291 } |
292 | 292 |
293 private: | 293 private: |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 // page. | 1087 // page. |
1088 if (m_pagePopup) { | 1088 if (m_pagePopup) { |
1089 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 1089 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
1090 // We need to ignore the next Char event after this otherwise pressing | 1090 // We need to ignore the next Char event after this otherwise pressing |
1091 // enter when selecting an item in the popup will go to the page. | 1091 // enter when selecting an item in the popup will go to the page. |
1092 if (WebInputEvent::RawKeyDown == event.type) | 1092 if (WebInputEvent::RawKeyDown == event.type) |
1093 m_suppressNextKeypressEvent = true; | 1093 m_suppressNextKeypressEvent = true; |
1094 return WebInputEventResult::HandledSystem; | 1094 return WebInputEventResult::HandledSystem; |
1095 } | 1095 } |
1096 | 1096 |
1097 RawPtr<Frame> focusedFrame = focusedCoreFrame(); | 1097 Frame* focusedFrame = focusedCoreFrame(); |
1098 if (focusedFrame && focusedFrame->isRemoteFrame()) { | 1098 if (focusedFrame && focusedFrame->isRemoteFrame()) { |
1099 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr
ame(focusedFrame.get())); | 1099 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr
ame(focusedFrame)); |
1100 webFrame->client()->forwardInputEvent(&event); | 1100 webFrame->client()->forwardInputEvent(&event); |
1101 return WebInputEventResult::HandledSystem; | 1101 return WebInputEventResult::HandledSystem; |
1102 } | 1102 } |
1103 | 1103 |
1104 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 1104 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
1105 return WebInputEventResult::NotHandled; | 1105 return WebInputEventResult::NotHandled; |
1106 | 1106 |
1107 LocalFrame* frame = toLocalFrame(focusedFrame.get()); | 1107 LocalFrame* frame = toLocalFrame(focusedFrame); |
1108 | 1108 |
1109 PlatformKeyboardEventBuilder evt(event); | 1109 PlatformKeyboardEventBuilder evt(event); |
1110 | 1110 |
1111 WebInputEventResult result = frame->eventHandler().keyEvent(evt); | 1111 WebInputEventResult result = frame->eventHandler().keyEvent(evt); |
1112 if (result != WebInputEventResult::NotHandled) { | 1112 if (result != WebInputEventResult::NotHandled) { |
1113 if (WebInputEvent::RawKeyDown == event.type) { | 1113 if (WebInputEvent::RawKeyDown == event.type) { |
1114 // Suppress the next keypress event unless the focused node is a plu
gin node. | 1114 // Suppress the next keypress event unless the focused node is a plu
gin node. |
1115 // (Flash needs these keypress events to handle non-US keyboards.) | 1115 // (Flash needs these keypress events to handle non-US keyboards.) |
1116 Element* element = focusedElement(); | 1116 Element* element = focusedElement(); |
1117 if (element && element->layoutObject() && element->layoutObject()->i
sEmbeddedObject()) { | 1117 if (element && element->layoutObject() && element->layoutObject()->i
sEmbeddedObject()) { |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 { | 1541 { |
1542 ContextMenuAllowedScope scope; | 1542 ContextMenuAllowedScope scope; |
1543 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); | 1543 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); |
1544 if (!focusedFrame->isLocalFrame()) | 1544 if (!focusedFrame->isLocalFrame()) |
1545 return WebInputEventResult::NotHandled; | 1545 return WebInputEventResult::NotHandled; |
1546 return toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEventFo
rKey(nullptr); | 1546 return toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEventFo
rKey(nullptr); |
1547 } | 1547 } |
1548 } | 1548 } |
1549 #endif | 1549 #endif |
1550 | 1550 |
1551 void WebViewImpl::showContextMenuAtPoint(float x, float y, RawPtr<ContextMenuPro
vider> menuProvider) | 1551 void WebViewImpl::showContextMenuAtPoint(float x, float y, ContextMenuProvider*
menuProvider) |
1552 { | 1552 { |
1553 if (!page()->mainFrame()->isLocalFrame()) | 1553 if (!page()->mainFrame()->isLocalFrame()) |
1554 return; | 1554 return; |
1555 { | 1555 { |
1556 ContextMenuAllowedScope scope; | 1556 ContextMenuAllowedScope scope; |
1557 page()->contextMenuController().clearContextMenu(); | 1557 page()->contextMenuController().clearContextMenu(); |
1558 page()->contextMenuController().showContextMenuAtPoint(page()->deprecate
dLocalMainFrame(), x, y, menuProvider); | 1558 page()->contextMenuController().showContextMenuAtPoint(page()->deprecate
dLocalMainFrame(), x, y, menuProvider); |
1559 } | 1559 } |
1560 } | 1560 } |
1561 | 1561 |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); | 2167 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); |
2168 | 2168 |
2169 if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) { | 2169 if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) { |
2170 pointerLockMouseEvent(inputEvent); | 2170 pointerLockMouseEvent(inputEvent); |
2171 return WebInputEventResult::HandledSystem; | 2171 return WebInputEventResult::HandledSystem; |
2172 } | 2172 } |
2173 | 2173 |
2174 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type))
{ | 2174 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type))
{ |
2175 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); | 2175 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); |
2176 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. | 2176 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. |
2177 RawPtr<Node> node = m_mouseCaptureNode; | 2177 Node* node = m_mouseCaptureNode; |
2178 | 2178 |
2179 // Not all platforms call mouseCaptureLost() directly. | 2179 // Not all platforms call mouseCaptureLost() directly. |
2180 if (inputEvent.type == WebInputEvent::MouseUp) | 2180 if (inputEvent.type == WebInputEvent::MouseUp) |
2181 mouseCaptureLost(); | 2181 mouseCaptureLost(); |
2182 | 2182 |
2183 OwnPtr<UserGestureIndicator> gestureIndicator; | 2183 OwnPtr<UserGestureIndicator> gestureIndicator; |
2184 | 2184 |
2185 AtomicString eventType; | 2185 AtomicString eventType; |
2186 switch (inputEvent.type) { | 2186 switch (inputEvent.type) { |
2187 case WebInputEvent::MouseMove: | 2187 case WebInputEvent::MouseMove: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 { | 2243 { |
2244 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); | 2244 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); |
2245 m_mouseCaptureNode = nullptr; | 2245 m_mouseCaptureNode = nullptr; |
2246 } | 2246 } |
2247 | 2247 |
2248 void WebViewImpl::setFocus(bool enable) | 2248 void WebViewImpl::setFocus(bool enable) |
2249 { | 2249 { |
2250 m_page->focusController().setFocused(enable); | 2250 m_page->focusController().setFocused(enable); |
2251 if (enable) { | 2251 if (enable) { |
2252 m_page->focusController().setActive(true); | 2252 m_page->focusController().setActive(true); |
2253 RawPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame
(); | 2253 LocalFrame* focusedFrame = m_page->focusController().focusedFrame(); |
2254 if (focusedFrame) { | 2254 if (focusedFrame) { |
2255 Element* element = focusedFrame->document()->focusedElement(); | 2255 Element* element = focusedFrame->document()->focusedElement(); |
2256 if (element && focusedFrame->selection().selection().isNone()) { | 2256 if (element && focusedFrame->selection().selection().isNone()) { |
2257 // If the selection was cleared while the WebView was not | 2257 // If the selection was cleared while the WebView was not |
2258 // focused, then the focus element shows with a focus ring but | 2258 // focused, then the focus element shows with a focus ring but |
2259 // no caret and does respond to keyboard inputs. | 2259 // no caret and does respond to keyboard inputs. |
2260 if (element->isTextFormControl()) { | 2260 if (element->isTextFormControl()) { |
2261 element->updateFocusAppearance(SelectionBehaviorOnFocus::Res
tore); | 2261 element->updateFocusAppearance(SelectionBehaviorOnFocus::Res
tore); |
2262 } else if (element->isContentEditable()) { | 2262 } else if (element->isContentEditable()) { |
2263 // updateFocusAppearance() selects all the text of | 2263 // updateFocusAppearance() selects all the text of |
(...skipping 11 matching lines...) Expand all Loading... |
2275 | 2275 |
2276 // Clear focus on the currently focused frame if any. | 2276 // Clear focus on the currently focused frame if any. |
2277 if (!m_page) | 2277 if (!m_page) |
2278 return; | 2278 return; |
2279 | 2279 |
2280 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF
rame() | 2280 LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalF
rame() |
2281 ? m_page->deprecatedLocalMainFrame() : nullptr; | 2281 ? m_page->deprecatedLocalMainFrame() : nullptr; |
2282 if (!frame) | 2282 if (!frame) |
2283 return; | 2283 return; |
2284 | 2284 |
2285 RawPtr<LocalFrame> focusedFrame = m_page->focusController().focusedFrame
(); | 2285 LocalFrame* focusedFrame = m_page->focusController().focusedFrame(); |
2286 if (focusedFrame) { | 2286 if (focusedFrame) { |
2287 // Finish an ongoing composition to delete the composition node. | 2287 // Finish an ongoing composition to delete the composition node. |
2288 if (focusedFrame->inputMethodController().hasComposition()) { | 2288 if (focusedFrame->inputMethodController().hasComposition()) { |
2289 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame
(focusedFrame.get())->autofillClient(); | 2289 WebAutofillClient* autofillClient = WebLocalFrameImpl::fromFrame
(focusedFrame)->autofillClient(); |
2290 | 2290 |
2291 if (autofillClient) | 2291 if (autofillClient) |
2292 autofillClient->setIgnoreTextChanges(true); | 2292 autofillClient->setIgnoreTextChanges(true); |
2293 | 2293 |
2294 focusedFrame->inputMethodController().confirmComposition(); | 2294 focusedFrame->inputMethodController().confirmComposition(); |
2295 | 2295 |
2296 if (autofillClient) | 2296 if (autofillClient) |
2297 autofillClient->setIgnoreTextChanges(false); | 2297 autofillClient->setIgnoreTextChanges(false); |
2298 } | 2298 } |
2299 m_imeAcceptEvents = false; | 2299 m_imeAcceptEvents = false; |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 Frame* frame = page()->focusController().focusedOrMainFrame(); | 2896 Frame* frame = page()->focusController().focusedOrMainFrame(); |
2897 if (frame->isLocalFrame()) { | 2897 if (frame->isLocalFrame()) { |
2898 if (Document* document = toLocalFrame(frame)->document()) | 2898 if (Document* document = toLocalFrame(frame)->document()) |
2899 document->clearFocusedElement(); | 2899 document->clearFocusedElement(); |
2900 } | 2900 } |
2901 page()->focusController().setInitialFocus(reverse ? WebFocusTypeBackward : W
ebFocusTypeForward); | 2901 page()->focusController().setInitialFocus(reverse ? WebFocusTypeBackward : W
ebFocusTypeForward); |
2902 } | 2902 } |
2903 | 2903 |
2904 void WebViewImpl::clearFocusedElement() | 2904 void WebViewImpl::clearFocusedElement() |
2905 { | 2905 { |
2906 RawPtr<Frame> frame = focusedCoreFrame(); | 2906 Frame* frame = focusedCoreFrame(); |
2907 if (!frame || !frame->isLocalFrame()) | 2907 if (!frame || !frame->isLocalFrame()) |
2908 return; | 2908 return; |
2909 | 2909 |
2910 LocalFrame* localFrame = toLocalFrame(frame.get()); | 2910 LocalFrame* localFrame = toLocalFrame(frame); |
2911 | 2911 |
2912 RawPtr<Document> document = localFrame->document(); | 2912 Document* document = localFrame->document(); |
2913 if (!document) | 2913 if (!document) |
2914 return; | 2914 return; |
2915 | 2915 |
2916 RawPtr<Element> oldFocusedElement = document->focusedElement(); | 2916 Element* oldFocusedElement = document->focusedElement(); |
2917 document->clearFocusedElement(); | 2917 document->clearFocusedElement(); |
2918 if (!oldFocusedElement) | 2918 if (!oldFocusedElement) |
2919 return; | 2919 return; |
2920 | 2920 |
2921 // If a text field has focus, we need to make sure the selection controller | 2921 // If a text field has focus, we need to make sure the selection controller |
2922 // knows to remove selection from it. Otherwise, the text field is still | 2922 // knows to remove selection from it. Otherwise, the text field is still |
2923 // processing keyboard events even though focus has been moved to the page a
nd | 2923 // processing keyboard events even though focus has been moved to the page a
nd |
2924 // keystrokes get eaten as a result. | 2924 // keystrokes get eaten as a result. |
2925 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC
ontrol()) | 2925 if (oldFocusedElement->isContentEditable() || oldFocusedElement->isTextFormC
ontrol()) |
2926 localFrame->selection().clear(); | 2926 localFrame->selection().clear(); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3400 } | 3400 } |
3401 | 3401 |
3402 updateMainFrameLayoutSize(); | 3402 updateMainFrameLayoutSize(); |
3403 } | 3403 } |
3404 | 3404 |
3405 void WebViewImpl::updateMainFrameLayoutSize() | 3405 void WebViewImpl::updateMainFrameLayoutSize() |
3406 { | 3406 { |
3407 if (m_shouldAutoResize || !mainFrameImpl()) | 3407 if (m_shouldAutoResize || !mainFrameImpl()) |
3408 return; | 3408 return; |
3409 | 3409 |
3410 RawPtr<FrameView> view = mainFrameImpl()->frameView(); | 3410 FrameView* view = mainFrameImpl()->frameView(); |
3411 if (!view) | 3411 if (!view) |
3412 return; | 3412 return; |
3413 | 3413 |
3414 WebSize layoutSize = m_size; | 3414 WebSize layoutSize = m_size; |
3415 | 3415 |
3416 if (settings()->viewportEnabled()) | 3416 if (settings()->viewportEnabled()) |
3417 layoutSize = pageScaleConstraintsSet().layoutSize(); | 3417 layoutSize = pageScaleConstraintsSet().layoutSize(); |
3418 | 3418 |
3419 if (page()->settings().forceZeroLayoutHeight()) | 3419 if (page()->settings().forceZeroLayoutHeight()) |
3420 layoutSize.height = 0; | 3420 layoutSize.height = 0; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 scrollableArea->setScrollPosition(DoublePoint::zero(), ProgrammaticS
croll); | 3485 scrollableArea->setScrollPosition(DoublePoint::zero(), ProgrammaticS
croll); |
3486 } | 3486 } |
3487 | 3487 |
3488 pageScaleConstraintsSet().setNeedsReset(true); | 3488 pageScaleConstraintsSet().setNeedsReset(true); |
3489 } | 3489 } |
3490 | 3490 |
3491 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, | 3491 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, |
3492 const WebPoint& location) | 3492 const WebPoint& location) |
3493 { | 3493 { |
3494 HitTestResult result = hitTestResultForViewportPos(location); | 3494 HitTestResult result = hitTestResultForViewportPos(location); |
3495 RawPtr<Node> node = result.innerNode(); | 3495 Node* node = result.innerNode(); |
3496 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) | 3496 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) |
3497 return; | 3497 return; |
3498 | 3498 |
3499 RawPtr<HTMLMediaElement> mediaElement = static_pointer_cast<HTMLMediaElement
>(node); | 3499 HTMLMediaElement* mediaElement = toHTMLMediaElement(node); |
3500 switch (action.type) { | 3500 switch (action.type) { |
3501 case WebMediaPlayerAction::Play: | 3501 case WebMediaPlayerAction::Play: |
3502 if (action.enable) | 3502 if (action.enable) |
3503 mediaElement->play(); | 3503 mediaElement->play(); |
3504 else | 3504 else |
3505 mediaElement->pause(); | 3505 mediaElement->pause(); |
3506 break; | 3506 break; |
3507 case WebMediaPlayerAction::Mute: | 3507 case WebMediaPlayerAction::Mute: |
3508 mediaElement->setMuted(action.enable); | 3508 mediaElement->setMuted(action.enable); |
3509 break; | 3509 break; |
3510 case WebMediaPlayerAction::Loop: | 3510 case WebMediaPlayerAction::Loop: |
3511 mediaElement->setLoop(action.enable); | 3511 mediaElement->setLoop(action.enable); |
3512 break; | 3512 break; |
3513 case WebMediaPlayerAction::Controls: | 3513 case WebMediaPlayerAction::Controls: |
3514 mediaElement->setBooleanAttribute(HTMLNames::controlsAttr, action.enable
); | 3514 mediaElement->setBooleanAttribute(HTMLNames::controlsAttr, action.enable
); |
3515 break; | 3515 break; |
3516 default: | 3516 default: |
3517 ASSERT_NOT_REACHED(); | 3517 ASSERT_NOT_REACHED(); |
3518 } | 3518 } |
3519 } | 3519 } |
3520 | 3520 |
3521 void WebViewImpl::performPluginAction(const WebPluginAction& action, | 3521 void WebViewImpl::performPluginAction(const WebPluginAction& action, |
3522 const WebPoint& location) | 3522 const WebPoint& location) |
3523 { | 3523 { |
3524 // FIXME: Location is probably in viewport coordinates | 3524 // FIXME: Location is probably in viewport coordinates |
3525 HitTestResult result = hitTestResultForRootFramePos(location); | 3525 HitTestResult result = hitTestResultForRootFramePos(location); |
3526 RawPtr<Node> node = result.innerNode(); | 3526 Node* node = result.innerNode(); |
3527 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) | 3527 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) |
3528 return; | 3528 return; |
3529 | 3529 |
3530 LayoutObject* object = node->layoutObject(); | 3530 LayoutObject* object = node->layoutObject(); |
3531 if (object && object->isLayoutPart()) { | 3531 if (object && object->isLayoutPart()) { |
3532 Widget* widget = toLayoutPart(object)->widget(); | 3532 Widget* widget = toLayoutPart(object)->widget(); |
3533 if (widget && widget->isPluginContainer()) { | 3533 if (widget && widget->isPluginContainer()) { |
3534 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); | 3534 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); |
3535 switch (action.type) { | 3535 switch (action.type) { |
3536 case WebPluginAction::Rotate90Clockwise: | 3536 case WebPluginAction::Rotate90Clockwise: |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4594 { | 4594 { |
4595 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4595 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
4596 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4596 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4597 if (!page()) | 4597 if (!page()) |
4598 return 1; | 4598 return 1; |
4599 | 4599 |
4600 return page()->deviceScaleFactor(); | 4600 return page()->deviceScaleFactor(); |
4601 } | 4601 } |
4602 | 4602 |
4603 } // namespace blink | 4603 } // namespace blink |
OLD | NEW |