Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 803943002: Remove old PopupContainer/PopupListBox popup menu Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/web.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 #include "public/web/WebTextInputInfo.h" 139 #include "public/web/WebTextInputInfo.h"
140 #include "public/web/WebViewClient.h" 140 #include "public/web/WebViewClient.h"
141 #include "public/web/WebWindowFeatures.h" 141 #include "public/web/WebWindowFeatures.h"
142 #include "web/CompositionUnderlineVectorBuilder.h" 142 #include "web/CompositionUnderlineVectorBuilder.h"
143 #include "web/ContextFeaturesClientImpl.h" 143 #include "web/ContextFeaturesClientImpl.h"
144 #include "web/DatabaseClientImpl.h" 144 #include "web/DatabaseClientImpl.h"
145 #include "web/FullscreenController.h" 145 #include "web/FullscreenController.h"
146 #include "web/GraphicsLayerFactoryChromium.h" 146 #include "web/GraphicsLayerFactoryChromium.h"
147 #include "web/LinkHighlight.h" 147 #include "web/LinkHighlight.h"
148 #include "web/NavigatorContentUtilsClientImpl.h" 148 #include "web/NavigatorContentUtilsClientImpl.h"
149 #include "web/PopupContainer.h"
150 #include "web/PrerendererClientImpl.h" 149 #include "web/PrerendererClientImpl.h"
151 #include "web/StorageQuotaClientImpl.h" 150 #include "web/StorageQuotaClientImpl.h"
152 #include "web/ValidationMessageClientImpl.h" 151 #include "web/ValidationMessageClientImpl.h"
153 #include "web/ViewportAnchor.h" 152 #include "web/ViewportAnchor.h"
154 #include "web/WebDevToolsAgentImpl.h" 153 #include "web/WebDevToolsAgentImpl.h"
155 #include "web/WebDevToolsAgentPrivate.h" 154 #include "web/WebDevToolsAgentPrivate.h"
156 #include "web/WebInputEventConversion.h" 155 #include "web/WebInputEventConversion.h"
157 #include "web/WebLocalFrameImpl.h" 156 #include "web/WebLocalFrameImpl.h"
158 #include "web/WebPagePopupImpl.h" 157 #include "web/WebPagePopupImpl.h"
159 #include "web/WebPluginContainerImpl.h" 158 #include "web/WebPluginContainerImpl.h"
160 #include "web/WebPopupMenuImpl.h"
161 #include "web/WebRemoteFrameImpl.h" 159 #include "web/WebRemoteFrameImpl.h"
162 #include "web/WebSettingsImpl.h" 160 #include "web/WebSettingsImpl.h"
163 #include "web/WorkerGlobalScopeProxyProviderImpl.h" 161 #include "web/WorkerGlobalScopeProxyProviderImpl.h"
164 #include "web/painting/ContinuousPainter.h" 162 #include "web/painting/ContinuousPainter.h"
165 #include "wtf/CurrentTime.h" 163 #include "wtf/CurrentTime.h"
166 #include "wtf/RefPtr.h" 164 #include "wtf/RefPtr.h"
167 #include "wtf/TemporaryChange.h" 165 #include "wtf/TemporaryChange.h"
168 166
169 #if USE(DEFAULT_RENDER_THEME) 167 #if USE(DEFAULT_RENDER_THEME)
170 #include "core/rendering/RenderThemeChromiumDefault.h" 168 #include "core/rendering/RenderThemeChromiumDefault.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 { 478 {
481 m_client->setMouseOverURL(WebURL()); 479 m_client->setMouseOverURL(WebURL());
482 PageWidgetEventHandler::handleMouseLeave(mainFrame, event); 480 PageWidgetEventHandler::handleMouseLeave(mainFrame, event);
483 } 481 }
484 482
485 void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev ent) 483 void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev ent)
486 { 484 {
487 // If there is a popup open, close it as the user is clicking on the page (o utside of the 485 // If there is a popup open, close it as the user is clicking on the page (o utside of the
488 // popup). We also save it so we can prevent a click on an element from imme diately 486 // popup). We also save it so we can prevent a click on an element from imme diately
489 // reopening the same popup. 487 // reopening the same popup.
490 RefPtrWillBeRawPtr<PopupContainer> selectPopup = nullptr;
491 RefPtr<WebPagePopupImpl> pagePopup; 488 RefPtr<WebPagePopupImpl> pagePopup;
492 if (event.button == WebMouseEvent::ButtonLeft) { 489 if (event.button == WebMouseEvent::ButtonLeft) {
493 selectPopup = m_selectPopup;
494 pagePopup = m_pagePopup; 490 pagePopup = m_pagePopup;
495 hidePopups(); 491 hidePopups();
496 ASSERT(!m_selectPopup);
497 ASSERT(!m_pagePopup); 492 ASSERT(!m_pagePopup);
498 } 493 }
499 494
500 m_lastMouseDownPoint = WebPoint(event.x, event.y); 495 m_lastMouseDownPoint = WebPoint(event.x, event.y);
501 496
502 // Take capture on a mouse down on a plugin so we can send it mouse events. 497 // Take capture on a mouse down on a plugin so we can send it mouse events.
503 // If the hit node is a plugin but a scrollbar is over it don't start mouse 498 // If the hit node is a plugin but a scrollbar is over it don't start mouse
504 // capture because it will interfere with the scrollbar receiving events. 499 // capture because it will interfere with the scrollbar receiving events.
505 IntPoint point(event.x, event.y); 500 IntPoint point(event.x, event.y);
506 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame()) { 501 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame()) {
507 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi nt); 502 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi nt);
508 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point)); 503 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point));
509 result.setToShadowHostIfInUserAgentShadowRoot(); 504 result.setToShadowHostIfInUserAgentShadowRoot();
510 Node* hitNode = result.innerNonSharedNode(); 505 Node* hitNode = result.innerNonSharedNode();
511 506
512 if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->re nderer()->isEmbeddedObject()) { 507 if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->re nderer()->isEmbeddedObject()) {
513 m_mouseCaptureNode = hitNode; 508 m_mouseCaptureNode = hitNode;
514 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); 509 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this);
515 } 510 }
516 } 511 }
517 512
518 PageWidgetEventHandler::handleMouseDown(mainFrame, event); 513 PageWidgetEventHandler::handleMouseDown(mainFrame, event);
519 514
520 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode) 515 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode)
521 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG estureToken(); 516 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG estureToken();
522 517
523 if (m_selectPopup && m_selectPopup == selectPopup) {
524 // That click triggered a select popup which is the same as the one that
525 // was showing before the click. It means the user clicked the select
526 // while the popup was showing, and as a result we first closed then
527 // immediately reopened the select popup. It needs to be closed.
528 hideSelectPopup();
529 }
530
531 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.ge t())) { 518 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.ge t())) {
532 // That click triggered a page popup that is the same as the one we just closed. 519 // That click triggered a page popup that is the same as the one we just closed.
533 // It needs to be closed. 520 // It needs to be closed.
534 closePagePopup(m_pagePopup.get()); 521 closePagePopup(m_pagePopup.get());
535 } 522 }
536 523
537 // Dispatch the contextmenu event regardless of if the click was swallowed. 524 // Dispatch the contextmenu event regardless of if the click was swallowed.
538 if (!page()->settings().showContextMenuOnMouseUp()) { 525 if (!page()->settings().showContextMenuOnMouseUp()) {
539 #if OS(MACOSX) 526 #if OS(MACOSX)
540 if (event.button == WebMouseEvent::ButtonRight 527 if (event.button == WebMouseEvent::ButtonRight
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 715 }
729 716
730 switch (event.type) { 717 switch (event.type) {
731 case WebInputEvent::GestureTap: { 718 case WebInputEvent::GestureTap: {
732 m_client->cancelScheduledContentIntents(); 719 m_client->cancelScheduledContentIntents();
733 if (detectContentOnTouch(targetedEvent)) { 720 if (detectContentOnTouch(targetedEvent)) {
734 eventSwallowed = true; 721 eventSwallowed = true;
735 break; 722 break;
736 } 723 }
737 724
738 RefPtrWillBeRawPtr<PopupContainer> selectPopup = nullptr;
739 selectPopup = m_selectPopup;
740 hideSelectPopup();
741 ASSERT(!m_selectPopup);
742
743 // Don't trigger a disambiguation popup on sites designed for mobile dev ices. 725 // Don't trigger a disambiguation popup on sites designed for mobile dev ices.
744 // Instead, assume that the page has been designed with big enough butto ns and links. 726 // Instead, assume that the page has been designed with big enough butto ns and links.
745 // Don't trigger a disambiguation popup when screencasting, since it's i mplemented outside of 727 // Don't trigger a disambiguation popup when screencasting, since it's i mplemented outside of
746 // compositor pipeline and is not being screencasted itself. This leads to bad user experience. 728 // compositor pipeline and is not being screencasted itself. This leads to bad user experience.
747 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !p age()->inspectorController().screencastEnabled()) { 729 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !p age()->inspectorController().screencastEnabled()) {
748 WebGestureEvent scaledEvent = event; 730 WebGestureEvent scaledEvent = event;
749 scaledEvent.x = event.x / pageScaleFactor(); 731 scaledEvent.x = event.x / pageScaleFactor();
750 scaledEvent.y = event.y / pageScaleFactor(); 732 scaledEvent.y = event.y / pageScaleFactor();
751 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor( ); 733 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor( );
752 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto r(); 734 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto r();
(...skipping 21 matching lines...) Expand all
774 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 756 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
775 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); 757 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
776 eventSwallowed = true; 758 eventSwallowed = true;
777 eventCancelled = true; 759 eventCancelled = true;
778 break; 760 break;
779 } 761 }
780 } 762 }
781 763
782 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(targetedEvent); 764 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(targetedEvent);
783 765
784 if (m_selectPopup && m_selectPopup == selectPopup) {
785 // That tap triggered a select popup which is the same as the one th at
786 // was showing before the tap. It means the user tapped the select
787 // while the popup was showing, and as a result we first closed then
788 // immediately reopened the select popup. It needs to be closed.
789 hideSelectPopup();
790 }
791
792 break; 766 break;
793 } 767 }
794 case WebInputEvent::GestureTwoFingerTap: 768 case WebInputEvent::GestureTwoFingerTap:
795 case WebInputEvent::GestureLongPress: 769 case WebInputEvent::GestureLongPress:
796 case WebInputEvent::GestureLongTap: { 770 case WebInputEvent::GestureLongTap: {
797 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 771 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
798 break; 772 break;
799 773
800 m_client->cancelScheduledContentIntents(); 774 m_client->cancelScheduledContentIntents();
801 m_page->contextMenuController().clearContextMenu(); 775 m_page->contextMenuController().clearContextMenu();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 endActiveFlingAnimation(); 939 endActiveFlingAnimation();
966 940
967 // Please refer to the comments explaining the m_suppressNextKeypressEvent 941 // Please refer to the comments explaining the m_suppressNextKeypressEvent
968 // member. 942 // member.
969 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by 943 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
970 // Webkit. A keyDown event is typically associated with a keyPress(char) 944 // Webkit. A keyDown event is typically associated with a keyPress(char)
971 // event and a keyUp event. We reset this flag here as this is a new keyDown 945 // event and a keyUp event. We reset this flag here as this is a new keyDown
972 // event. 946 // event.
973 m_suppressNextKeypressEvent = false; 947 m_suppressNextKeypressEvent = false;
974 948
975 // If there is a select popup, it should be the one processing the event, 949 // If there is a popup, it should be the one processing the event,
976 // not the page. 950 // not the page.
977 if (m_selectPopup)
978 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
979 if (m_pagePopup) { 951 if (m_pagePopup) {
980 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 952 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
981 // We need to ignore the next Char event after this otherwise pressing 953 // We need to ignore the next Char event after this otherwise pressing
982 // enter when selecting an item in the popup will go to the page. 954 // enter when selecting an item in the popup will go to the page.
983 if (WebInputEvent::RawKeyDown == event.type) 955 if (WebInputEvent::RawKeyDown == event.type)
984 m_suppressNextKeypressEvent = true; 956 m_suppressNextKeypressEvent = true;
985 return true; 957 return true;
986 } 958 }
987 959
988 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); 960 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 ASSERT(event.type == WebInputEvent::Char); 1006 ASSERT(event.type == WebInputEvent::Char);
1035 1007
1036 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1008 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1037 // member. The m_suppressNextKeypressEvent is set if the KeyDown is 1009 // member. The m_suppressNextKeypressEvent is set if the KeyDown is
1038 // handled by Webkit. A keyDown event is typically associated with a 1010 // handled by Webkit. A keyDown event is typically associated with a
1039 // keyPress(char) event and a keyUp event. We reset this flag here as it 1011 // keyPress(char) event and a keyUp event. We reset this flag here as it
1040 // only applies to the current keyPress event. 1012 // only applies to the current keyPress event.
1041 bool suppress = m_suppressNextKeypressEvent; 1013 bool suppress = m_suppressNextKeypressEvent;
1042 m_suppressNextKeypressEvent = false; 1014 m_suppressNextKeypressEvent = false;
1043 1015
1044 // If there is a select popup, it should be the one processing the event, 1016 // If there is a popup, it should be the one processing the event,
1045 // not the page. 1017 // not the page.
1046 if (m_selectPopup)
1047 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1048 if (m_pagePopup) 1018 if (m_pagePopup)
1049 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1019 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1050 1020
1051 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); 1021 LocalFrame* frame = toLocalFrame(focusedCoreFrame());
1052 if (!frame) 1022 if (!frame)
1053 return suppress; 1023 return suppress;
1054 1024
1055 EventHandler& handler = frame->eventHandler(); 1025 EventHandler& handler = frame->eventHandler();
1056 1026
1057 PlatformKeyboardEventBuilder evt(event); 1027 PlatformKeyboardEventBuilder evt(event);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 *scrollDirection = ScrollDown; 1498 *scrollDirection = ScrollDown;
1529 *scrollGranularity = ScrollByPage; 1499 *scrollGranularity = ScrollByPage;
1530 break; 1500 break;
1531 default: 1501 default:
1532 return false; 1502 return false;
1533 } 1503 }
1534 1504
1535 return true; 1505 return true;
1536 } 1506 }
1537 1507
1538 void WebViewImpl::hideSelectPopup()
1539 {
1540 if (m_selectPopup)
1541 m_selectPopup->hidePopup();
1542 }
1543
1544 void WebViewImpl::popupOpened(PopupContainer* popupContainer)
1545 {
1546 ASSERT(!m_selectPopup);
1547 m_selectPopup = popupContainer;
1548 ASSERT(mainFrameImpl()->frame()->document());
1549 Document& document = *mainFrameImpl()->frame()->document();
1550 page()->frameHost().eventHandlerRegistry().didAddEventHandler(document, Even tHandlerRegistry::WheelEvent);
1551 }
1552
1553 void WebViewImpl::popupClosed(PopupContainer* popupContainer)
1554 {
1555 ASSERT(m_selectPopup);
1556 m_selectPopup = nullptr;
1557 ASSERT(mainFrameImpl()->frame()->document());
1558 Document& document = *mainFrameImpl()->frame()->document();
1559 // Remove the handler we added in |popupOpened| conditionally, because the
1560 // Document may have already removed it, for instance, due to a navigation.
1561 EventHandlerRegistry* registry = &document.frameHost()->eventHandlerRegistry ();
1562 if (registry->eventHandlerTargets(EventHandlerRegistry::WheelEvent)->contain s(&document))
1563 registry->didRemoveEventHandler(document, EventHandlerRegistry::WheelEve nt);
1564 }
1565
1566 PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or iginBoundsInRootView) 1508 PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or iginBoundsInRootView)
1567 { 1509 {
1568 ASSERT(client); 1510 ASSERT(client);
1569 if (hasOpenedPopup()) 1511 if (hasOpenedPopup())
1570 hidePopups(); 1512 hidePopups();
1571 ASSERT(!m_pagePopup); 1513 ASSERT(!m_pagePopup);
1572 1514
1573 WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage); 1515 WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage);
1574 ASSERT(popupWidget); 1516 ASSERT(popupWidget);
1575 m_pagePopup = toWebPagePopupImpl(popupWidget); 1517 m_pagePopup = toWebPagePopupImpl(popupWidget);
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3827 3769
3828 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s tartPosition, endPosition); 3770 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s tartPosition, endPosition);
3829 if (!range) 3771 if (!range)
3830 return; 3772 return;
3831 3773
3832 clipHtml = createMarkup(range.get(), 0, AnnotateForInterchange, false, Resol veNonLocalURLs); 3774 clipHtml = createMarkup(range.get(), 0, AnnotateForInterchange, false, Resol veNonLocalURLs);
3833 } 3775 }
3834 3776
3835 void WebViewImpl::hidePopups() 3777 void WebViewImpl::hidePopups()
3836 { 3778 {
3837 hideSelectPopup();
3838 if (m_pagePopup) 3779 if (m_pagePopup)
3839 closePagePopup(m_pagePopup.get()); 3780 closePagePopup(m_pagePopup.get());
3840 } 3781 }
3841 3782
3842 void WebViewImpl::setIsTransparent(bool isTransparent) 3783 void WebViewImpl::setIsTransparent(bool isTransparent)
3843 { 3784 {
3844 // Set any existing frames to be transparent. 3785 // Set any existing frames to be transparent.
3845 Frame* frame = m_page->mainFrame(); 3786 Frame* frame = m_page->mainFrame();
3846 while (frame) { 3787 while (frame) {
3847 if (frame->isLocalFrame()) 3788 if (frame->isLocalFrame())
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
4545 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4486 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4546 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4487 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4547 } 4488 }
4548 4489
4549 void WebViewImpl::forceNextWebGLContextCreationToFail() 4490 void WebViewImpl::forceNextWebGLContextCreationToFail()
4550 { 4491 {
4551 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4492 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4552 } 4493 }
4553 4494
4554 } // namespace blink 4495 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/web.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698