OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #include "web/WebLocalFrameImpl.h" | 67 #include "web/WebLocalFrameImpl.h" |
68 #include "web/WebPluginContainerImpl.h" | 68 #include "web/WebPluginContainerImpl.h" |
69 #include "web/WebRemoteFrameImpl.h" | 69 #include "web/WebRemoteFrameImpl.h" |
70 #include "web/WebViewFrameWidget.h" | 70 #include "web/WebViewFrameWidget.h" |
71 #include "wtf/AutoReset.h" | 71 #include "wtf/AutoReset.h" |
72 #include "wtf/PtrUtil.h" | 72 #include "wtf/PtrUtil.h" |
73 #include <memory> | 73 #include <memory> |
74 | 74 |
75 namespace blink { | 75 namespace blink { |
76 | 76 |
77 // WebFrameWidget --------------------------------------------------------------
-- | 77 // WebFrameWidget ------------------------------------------------------------ |
78 | 78 |
79 WebFrameWidget* WebFrameWidget::create(WebWidgetClient* client, | 79 WebFrameWidget* WebFrameWidget::create(WebWidgetClient* client, |
80 WebLocalFrame* localRoot) { | 80 WebLocalFrame* localRoot) { |
81 // Pass the WebFrameWidget's self-reference to the caller. | 81 // Pass the WebFrameWidget's self-reference to the caller. |
82 return WebFrameWidgetImpl::create(client, localRoot); | 82 return WebFrameWidgetImpl::create(client, localRoot); |
83 } | 83 } |
84 | 84 |
85 WebFrameWidget* WebFrameWidget::create(WebWidgetClient* client, | 85 WebFrameWidget* WebFrameWidget::create(WebWidgetClient* client, |
86 WebView* webView, | 86 WebView* webView, |
87 WebLocalFrame* mainFrame) { | 87 WebLocalFrame* mainFrame) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 FrameView* view = m_localRoot->frameView(); | 165 FrameView* view = m_localRoot->frameView(); |
166 if (!view) | 166 if (!view) |
167 return; | 167 return; |
168 | 168 |
169 m_size = newSize; | 169 m_size = newSize; |
170 | 170 |
171 updateMainFrameLayoutSize(); | 171 updateMainFrameLayoutSize(); |
172 | 172 |
173 view->resize(m_size); | 173 view->resize(m_size); |
174 | 174 |
175 // FIXME: In WebViewImpl this layout was a precursor to setting the minimum sc
ale limit. | 175 // FIXME: In WebViewImpl this layout was a precursor to setting the minimum |
176 // It is not clear if this is necessary for frame-level widget resize. | 176 // scale limit. It is not clear if this is necessary for frame-level widget |
| 177 // resize. |
177 if (view->needsLayout()) | 178 if (view->needsLayout()) |
178 view->layout(); | 179 view->layout(); |
179 | 180 |
180 // FIXME: Investigate whether this is needed; comment from eseidel suggests th
at this function | 181 // FIXME: Investigate whether this is needed; comment from eseidel suggests |
181 // is flawed. | 182 // that this function is flawed. |
182 sendResizeEventAndRepaint(); | 183 sendResizeEventAndRepaint(); |
183 } | 184 } |
184 | 185 |
185 void WebFrameWidgetImpl::sendResizeEventAndRepaint() { | 186 void WebFrameWidgetImpl::sendResizeEventAndRepaint() { |
186 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent | 187 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent |
187 // as part of layout. Layout is also responsible for sending invalidations | 188 // as part of layout. Layout is also responsible for sending invalidations |
188 // to the embedder. This method and all callers may be wrong. -- eseidel. | 189 // to the embedder. This method and all callers may be wrong. -- eseidel. |
189 if (m_localRoot->frameView()) { | 190 if (m_localRoot->frameView()) { |
190 // Enqueues the resize event. | 191 // Enqueues the resize event. |
191 m_localRoot->frame()->document()->enqueueResizeEvent(); | 192 m_localRoot->frame()->document()->enqueueResizeEvent(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 313 |
313 WebInputEventResult WebFrameWidgetImpl::handleInputEvent( | 314 WebInputEventResult WebFrameWidgetImpl::handleInputEvent( |
314 const WebInputEvent& inputEvent) { | 315 const WebInputEvent& inputEvent) { |
315 TRACE_EVENT1("input", "WebFrameWidgetImpl::handleInputEvent", "type", | 316 TRACE_EVENT1("input", "WebFrameWidgetImpl::handleInputEvent", "type", |
316 WebInputEvent::GetName(inputEvent.type)); | 317 WebInputEvent::GetName(inputEvent.type)); |
317 | 318 |
318 // Don't handle events once we've started shutting down. | 319 // Don't handle events once we've started shutting down. |
319 if (!page()) | 320 if (!page()) |
320 return WebInputEventResult::NotHandled; | 321 return WebInputEventResult::NotHandled; |
321 | 322 |
322 // Report the event to be NOT processed by WebKit, so that the browser can han
dle it appropriately. | 323 // Report the event to be NOT processed by WebKit, so that the browser can |
| 324 // handle it appropriately. |
323 if (m_ignoreInputEvents) | 325 if (m_ignoreInputEvents) |
324 return WebInputEventResult::NotHandled; | 326 return WebInputEventResult::NotHandled; |
325 | 327 |
326 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available. | 328 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available. |
327 | 329 |
328 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, | 330 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, |
329 &inputEvent); | 331 &inputEvent); |
330 | 332 |
331 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) { | 333 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) { |
332 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); | 334 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 374 |
373 return PageWidgetDelegate::handleInputEvent(*this, inputEvent, | 375 return PageWidgetDelegate::handleInputEvent(*this, inputEvent, |
374 m_localRoot->frame()); | 376 m_localRoot->frame()); |
375 } | 377 } |
376 | 378 |
377 void WebFrameWidgetImpl::setCursorVisibilityState(bool isVisible) { | 379 void WebFrameWidgetImpl::setCursorVisibilityState(bool isVisible) { |
378 page()->setIsCursorVisible(isVisible); | 380 page()->setIsCursorVisible(isVisible); |
379 } | 381 } |
380 | 382 |
381 bool WebFrameWidgetImpl::hasTouchEventHandlersAt(const WebPoint& point) { | 383 bool WebFrameWidgetImpl::hasTouchEventHandlersAt(const WebPoint& point) { |
382 // FIXME: Implement this. Note that the point must be divided by pageScaleFact
or. | 384 // FIXME: Implement this. Note that the point must be divided by |
| 385 // pageScaleFactor. |
383 return true; | 386 return true; |
384 } | 387 } |
385 | 388 |
386 void WebFrameWidgetImpl::setBaseBackgroundColor(WebColor color) { | 389 void WebFrameWidgetImpl::setBaseBackgroundColor(WebColor color) { |
387 if (m_baseBackgroundColor == color) | 390 if (m_baseBackgroundColor == color) |
388 return; | 391 return; |
389 | 392 |
390 m_baseBackgroundColor = color; | 393 m_baseBackgroundColor = color; |
391 | 394 |
392 m_localRoot->frameView()->setBaseBackgroundColor(color); | 395 m_localRoot->frameView()->setBaseBackgroundColor(color); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); | 457 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); |
455 if (focusedFrame) { | 458 if (focusedFrame) { |
456 // Finish an ongoing composition to delete the composition node. | 459 // Finish an ongoing composition to delete the composition node. |
457 if (focusedFrame->inputMethodController().hasComposition()) { | 460 if (focusedFrame->inputMethodController().hasComposition()) { |
458 WebAutofillClient* autofillClient = | 461 WebAutofillClient* autofillClient = |
459 WebLocalFrameImpl::fromFrame(focusedFrame)->autofillClient(); | 462 WebLocalFrameImpl::fromFrame(focusedFrame)->autofillClient(); |
460 | 463 |
461 if (autofillClient) | 464 if (autofillClient) |
462 autofillClient->setIgnoreTextChanges(true); | 465 autofillClient->setIgnoreTextChanges(true); |
463 | 466 |
464 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesh
eets | 467 // TODO(xiaochengh): The use of |
465 // needs to be audited. See http://crbug.com/590369 for more details. | 468 // updateStyleAndLayoutIgnorePendingStylesheets needs to be audited. |
| 469 // See http://crbug.com/590369 for more details. |
466 focusedFrame->document() | 470 focusedFrame->document() |
467 ->updateStyleAndLayoutIgnorePendingStylesheets(); | 471 ->updateStyleAndLayoutIgnorePendingStylesheets(); |
468 | 472 |
469 focusedFrame->inputMethodController().finishComposingText( | 473 focusedFrame->inputMethodController().finishComposingText( |
470 InputMethodController::KeepSelection); | 474 InputMethodController::KeepSelection); |
471 | 475 |
472 if (autofillClient) | 476 if (autofillClient) |
473 autofillClient->setIgnoreTextChanges(false); | 477 autofillClient->setIgnoreTextChanges(false); |
474 } | 478 } |
475 m_imeAcceptEvents = false; | 479 m_imeAcceptEvents = false; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 info.inputMode = inputModeOfFocusedElement(); | 617 info.inputMode = inputModeOfFocusedElement(); |
614 | 618 |
615 info.type = textInputType(); | 619 info.type = textInputType(); |
616 info.flags = textInputFlags(); | 620 info.flags = textInputFlags(); |
617 if (info.type == WebTextInputTypeNone) | 621 if (info.type == WebTextInputTypeNone) |
618 return info; | 622 return info; |
619 | 623 |
620 if (!focused->editor().canEdit()) | 624 if (!focused->editor().canEdit()) |
621 return info; | 625 return info; |
622 | 626 |
623 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets n
eeds to be audited. | 627 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
624 // see http://crbug.com/590369 for more details. | 628 // needs to be audited. see http://crbug.com/590369 for more details. |
625 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 629 focused->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
626 | 630 |
627 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 631 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
628 focused->document()->lifecycle()); | 632 focused->document()->lifecycle()); |
629 | 633 |
630 // Emits an object replacement character for each replaced element so that | 634 // Emits an object replacement character for each replaced element so that |
631 // it is exposed to IME and thus could be deleted by IME on android. | 635 // it is exposed to IME and thus could be deleted by IME on android. |
632 info.value = plainText(EphemeralRange::rangeOfContents(*element), | 636 info.value = plainText(EphemeralRange::rangeOfContents(*element), |
633 TextIteratorEmitsObjectReplacementCharacter); | 637 TextIteratorEmitsObjectReplacementCharacter); |
634 | 638 |
(...skipping 27 matching lines...) Expand all Loading... |
662 WebTextInputType WebFrameWidgetImpl::textInputType() { | 666 WebTextInputType WebFrameWidgetImpl::textInputType() { |
663 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); | 667 LocalFrame* focusedFrame = focusedLocalFrameInWidget(); |
664 if (!focusedFrame) | 668 if (!focusedFrame) |
665 return WebTextInputTypeNone; | 669 return WebTextInputTypeNone; |
666 | 670 |
667 if (!focusedFrame->selection().isAvailable()) { | 671 if (!focusedFrame->selection().isAvailable()) { |
668 // "mouse-capture-inside-shadow.html" reaches here. | 672 // "mouse-capture-inside-shadow.html" reaches here. |
669 return WebTextInputTypeNone; | 673 return WebTextInputTypeNone; |
670 } | 674 } |
671 | 675 |
672 // It's important to preserve the equivalence of textInputInfo().type and text
InputType(), | 676 // It's important to preserve the equivalence of textInputInfo().type and |
673 // so perform the same rootEditableElement() existence check here for consiste
ncy. | 677 // textInputType(), so perform the same rootEditableElement() existence check |
| 678 // here for consistency. |
674 if (!focusedFrame->selection().selection().rootEditableElement()) | 679 if (!focusedFrame->selection().selection().rootEditableElement()) |
675 return WebTextInputTypeNone; | 680 return WebTextInputTypeNone; |
676 | 681 |
677 Document* document = focusedFrame->document(); | 682 Document* document = focusedFrame->document(); |
678 if (!document) | 683 if (!document) |
679 return WebTextInputTypeNone; | 684 return WebTextInputTypeNone; |
680 | 685 |
681 Element* element = document->focusedElement(); | 686 Element* element = document->focusedElement(); |
682 if (!element) | 687 if (!element) |
683 return WebTextInputTypeNone; | 688 return WebTextInputTypeNone; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 const EphemeralRange selectedRange = | 764 const EphemeralRange selectedRange = |
760 selection.selection().toNormalizedEphemeralRange(); | 765 selection.selection().toNormalizedEphemeralRange(); |
761 if (selectedRange.isNull()) | 766 if (selectedRange.isNull()) |
762 return false; | 767 return false; |
763 anchor = localFrame->editor().firstRectForRange( | 768 anchor = localFrame->editor().firstRectForRange( |
764 EphemeralRange(selectedRange.startPosition())); | 769 EphemeralRange(selectedRange.startPosition())); |
765 focus = localFrame->editor().firstRectForRange( | 770 focus = localFrame->editor().firstRectForRange( |
766 EphemeralRange(selectedRange.endPosition())); | 771 EphemeralRange(selectedRange.endPosition())); |
767 } | 772 } |
768 | 773 |
769 // FIXME: This doesn't apply page scale. This should probably be contents to v
iewport. crbug.com/459293. | 774 // FIXME: This doesn't apply page scale. This should probably be contents to |
| 775 // viewport. crbug.com/459293. |
770 IntRect scaledAnchor(localFrame->view()->contentsToRootFrame(anchor)); | 776 IntRect scaledAnchor(localFrame->view()->contentsToRootFrame(anchor)); |
771 IntRect scaledFocus(localFrame->view()->contentsToRootFrame(focus)); | 777 IntRect scaledFocus(localFrame->view()->contentsToRootFrame(focus)); |
772 | 778 |
773 anchor = scaledAnchor; | 779 anchor = scaledAnchor; |
774 focus = scaledFocus; | 780 focus = scaledFocus; |
775 | 781 |
776 if (!selection.selection().isBaseFirst()) | 782 if (!selection.selection().isBaseFirst()) |
777 std::swap(anchor, focus); | 783 std::swap(anchor, focus); |
778 return true; | 784 return true; |
779 } | 785 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 } | 1079 } |
1074 | 1080 |
1075 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 1081 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
1076 return WebInputEventResult::NotHandled; | 1082 return WebInputEventResult::NotHandled; |
1077 | 1083 |
1078 LocalFrame* frame = toLocalFrame(focusedFrame); | 1084 LocalFrame* frame = toLocalFrame(focusedFrame); |
1079 | 1085 |
1080 WebInputEventResult result = frame->eventHandler().keyEvent(event); | 1086 WebInputEventResult result = frame->eventHandler().keyEvent(event); |
1081 if (result != WebInputEventResult::NotHandled) { | 1087 if (result != WebInputEventResult::NotHandled) { |
1082 if (WebInputEvent::RawKeyDown == event.type) { | 1088 if (WebInputEvent::RawKeyDown == event.type) { |
1083 // Suppress the next keypress event unless the focused node is a plugin no
de. | 1089 // Suppress the next keypress event unless the focused node is a plugin |
1084 // (Flash needs these keypress events to handle non-US keyboards.) | 1090 // node. (Flash needs these keypress events to handle non-US keyboards.) |
1085 Element* element = focusedElement(); | 1091 Element* element = focusedElement(); |
1086 if (!element || !element->layoutObject() || | 1092 if (!element || !element->layoutObject() || |
1087 !element->layoutObject()->isEmbeddedObject()) | 1093 !element->layoutObject()->isEmbeddedObject()) |
1088 m_suppressNextKeypressEvent = true; | 1094 m_suppressNextKeypressEvent = true; |
1089 } | 1095 } |
1090 return result; | 1096 return result; |
1091 } | 1097 } |
1092 | 1098 |
1093 #if !OS(MACOSX) | 1099 #if !OS(MACOSX) |
1094 const WebInputEvent::Type contextMenuKeyTriggeringEventType = | 1100 const WebInputEvent::Type contextMenuKeyTriggeringEventType = |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 m_layerTreeView = m_client->layerTreeView(); | 1308 m_layerTreeView = m_client->layerTreeView(); |
1303 } | 1309 } |
1304 | 1310 |
1305 if (WebDevToolsAgentImpl* devTools = m_localRoot->devToolsAgentImpl()) | 1311 if (WebDevToolsAgentImpl* devTools = m_localRoot->devToolsAgentImpl()) |
1306 devTools->layerTreeViewChanged(m_layerTreeView); | 1312 devTools->layerTreeViewChanged(m_layerTreeView); |
1307 | 1313 |
1308 page()->settings().setAcceleratedCompositingEnabled(m_layerTreeView); | 1314 page()->settings().setAcceleratedCompositingEnabled(m_layerTreeView); |
1309 if (m_layerTreeView) | 1315 if (m_layerTreeView) |
1310 page()->layerTreeViewInitialized(*m_layerTreeView); | 1316 page()->layerTreeViewInitialized(*m_layerTreeView); |
1311 | 1317 |
1312 // FIXME: only unittests, click to play, Android priting, and printing (for he
aders and footers) | 1318 // FIXME: only unittests, click to play, Android priting, and printing (for |
1313 // make this assert necessary. We should make them not hit this code and then
delete allowsBrokenNullLayerTreeView. | 1319 // headers and footers) make this assert necessary. We should make them not |
| 1320 // hit this code and then delete allowsBrokenNullLayerTreeView. |
1314 DCHECK(m_layerTreeView || !m_client || | 1321 DCHECK(m_layerTreeView || !m_client || |
1315 m_client->allowsBrokenNullLayerTreeView()); | 1322 m_client->allowsBrokenNullLayerTreeView()); |
1316 } | 1323 } |
1317 | 1324 |
1318 void WebFrameWidgetImpl::setIsAcceleratedCompositingActive(bool active) { | 1325 void WebFrameWidgetImpl::setIsAcceleratedCompositingActive(bool active) { |
1319 // In the middle of shutting down; don't try to spin back up a compositor. | 1326 // In the middle of shutting down; don't try to spin back up a compositor. |
1320 // FIXME: compositing startup/shutdown should be refactored so that it | 1327 // FIXME: compositing startup/shutdown should be refactored so that it |
1321 // turns on explicitly rather than lazily, which causes this awkwardness. | 1328 // turns on explicitly rather than lazily, which causes this awkwardness. |
1322 if (m_layerTreeViewClosed) | 1329 if (m_layerTreeViewClosed) |
1323 return; | 1330 return; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 return flags; | 1521 return flags; |
1515 } | 1522 } |
1516 | 1523 |
1517 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { | 1524 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { |
1518 if (!m_imeAcceptEvents) | 1525 if (!m_imeAcceptEvents) |
1519 return nullptr; | 1526 return nullptr; |
1520 return focusedLocalFrameInWidget(); | 1527 return focusedLocalFrameInWidget(); |
1521 } | 1528 } |
1522 | 1529 |
1523 } // namespace blink | 1530 } // namespace blink |
OLD | NEW |