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

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

Issue 1142303005: Remove legacy SELECT popup code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 #include "public/web/WebWindowFeatures.h" 144 #include "public/web/WebWindowFeatures.h"
145 #include "web/CompositionUnderlineVectorBuilder.h" 145 #include "web/CompositionUnderlineVectorBuilder.h"
146 #include "web/ContextFeaturesClientImpl.h" 146 #include "web/ContextFeaturesClientImpl.h"
147 #include "web/DatabaseClientImpl.h" 147 #include "web/DatabaseClientImpl.h"
148 #include "web/DevToolsEmulator.h" 148 #include "web/DevToolsEmulator.h"
149 #include "web/FullscreenController.h" 149 #include "web/FullscreenController.h"
150 #include "web/GraphicsLayerFactoryChromium.h" 150 #include "web/GraphicsLayerFactoryChromium.h"
151 #include "web/InspectorOverlayImpl.h" 151 #include "web/InspectorOverlayImpl.h"
152 #include "web/LinkHighlight.h" 152 #include "web/LinkHighlight.h"
153 #include "web/NavigatorContentUtilsClientImpl.h" 153 #include "web/NavigatorContentUtilsClientImpl.h"
154 #include "web/PopupContainer.h"
155 #include "web/PrerendererClientImpl.h" 154 #include "web/PrerendererClientImpl.h"
156 #include "web/ResizeViewportAnchor.h" 155 #include "web/ResizeViewportAnchor.h"
157 #include "web/RotationViewportAnchor.h" 156 #include "web/RotationViewportAnchor.h"
158 #include "web/SpeechRecognitionClientProxy.h" 157 #include "web/SpeechRecognitionClientProxy.h"
159 #include "web/StorageQuotaClientImpl.h" 158 #include "web/StorageQuotaClientImpl.h"
160 #include "web/ValidationMessageClientImpl.h" 159 #include "web/ValidationMessageClientImpl.h"
161 #include "web/ViewportAnchor.h" 160 #include "web/ViewportAnchor.h"
162 #include "web/WebDevToolsAgentImpl.h" 161 #include "web/WebDevToolsAgentImpl.h"
163 #include "web/WebInputEventConversion.h" 162 #include "web/WebInputEventConversion.h"
164 #include "web/WebLocalFrameImpl.h" 163 #include "web/WebLocalFrameImpl.h"
165 #include "web/WebPagePopupImpl.h" 164 #include "web/WebPagePopupImpl.h"
166 #include "web/WebPluginContainerImpl.h" 165 #include "web/WebPluginContainerImpl.h"
167 #include "web/WebPopupMenuImpl.h"
168 #include "web/WebRemoteFrameImpl.h" 166 #include "web/WebRemoteFrameImpl.h"
169 #include "web/WebSettingsImpl.h" 167 #include "web/WebSettingsImpl.h"
170 #include "web/WorkerGlobalScopeProxyProviderImpl.h" 168 #include "web/WorkerGlobalScopeProxyProviderImpl.h"
171 #include "web/painting/ContinuousPainter.h" 169 #include "web/painting/ContinuousPainter.h"
172 #include "wtf/CurrentTime.h" 170 #include "wtf/CurrentTime.h"
173 #include "wtf/RefPtr.h" 171 #include "wtf/RefPtr.h"
174 #include "wtf/TemporaryChange.h" 172 #include "wtf/TemporaryChange.h"
175 173
176 #if USE(DEFAULT_RENDER_THEME) 174 #if USE(DEFAULT_RENDER_THEME)
177 #include "core/layout/LayoutThemeDefault.h" 175 #include "core/layout/LayoutThemeDefault.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } 495 }
498 496
499 void WebViewImpl::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& e vent) 497 void WebViewImpl::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& e vent)
500 { 498 {
501 m_client->setMouseOverURL(WebURL()); 499 m_client->setMouseOverURL(WebURL());
502 PageWidgetEventHandler::handleMouseLeave(mainFrame, event); 500 PageWidgetEventHandler::handleMouseLeave(mainFrame, event);
503 } 501 }
504 502
505 void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev ent) 503 void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev ent)
506 { 504 {
507 // If there is a popup open, close it as the user is clicking on the page (o utside of the 505 // If there is a popup open, close it as the user is clicking on the page
508 // popup). We also save it so we can prevent a click on an element from imme diately 506 // (outside of the popup). We also save it so we can prevent a click on an
509 // reopening the same popup. 507 // element from immediately reopening the same popup.
510 RefPtrWillBeRawPtr<PopupContainer> selectPopup = nullptr;
511 RefPtr<WebPagePopupImpl> pagePopup; 508 RefPtr<WebPagePopupImpl> pagePopup;
512 if (event.button == WebMouseEvent::ButtonLeft) { 509 if (event.button == WebMouseEvent::ButtonLeft) {
513 selectPopup = m_selectPopup;
514 pagePopup = m_pagePopup; 510 pagePopup = m_pagePopup;
515 hidePopups(); 511 hidePopups();
516 ASSERT(!m_selectPopup);
517 ASSERT(!m_pagePopup); 512 ASSERT(!m_pagePopup);
518 } 513 }
519 514
520 m_lastMouseDownPoint = WebPoint(event.x, event.y); 515 m_lastMouseDownPoint = WebPoint(event.x, event.y);
521 516
522 // Take capture on a mouse down on a plugin so we can send it mouse events. 517 // Take capture on a mouse down on a plugin so we can send it mouse events.
523 // If the hit node is a plugin but a scrollbar is over it don't start mouse 518 // If the hit node is a plugin but a scrollbar is over it don't start mouse
524 // capture because it will interfere with the scrollbar receiving events. 519 // capture because it will interfere with the scrollbar receiving events.
525 IntPoint point(event.x, event.y); 520 IntPoint point(event.x, event.y);
526 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame()) { 521 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame()) {
527 point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToContents( point); 522 point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToContents( point);
528 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point)); 523 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point));
529 result.setToShadowHostIfInUserAgentShadowRoot(); 524 result.setToShadowHostIfInUserAgentShadowRoot();
530 Node* hitNode = result.innerNodeOrImageMapImage(); 525 Node* hitNode = result.innerNodeOrImageMapImage();
531 526
532 if (!result.scrollbar() && hitNode && hitNode->layoutObject() && hitNode ->layoutObject()->isEmbeddedObject()) { 527 if (!result.scrollbar() && hitNode && hitNode->layoutObject() && hitNode ->layoutObject()->isEmbeddedObject()) {
533 m_mouseCaptureNode = hitNode; 528 m_mouseCaptureNode = hitNode;
534 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); 529 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this);
535 } 530 }
536 } 531 }
537 532
538 PageWidgetEventHandler::handleMouseDown(mainFrame, event); 533 PageWidgetEventHandler::handleMouseDown(mainFrame, event);
539 534
540 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode) 535 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode)
541 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG estureToken(); 536 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG estureToken();
542 537
543 if (m_selectPopup && m_selectPopup == selectPopup) {
544 // That click triggered a select popup which is the same as the one that
545 // was showing before the click. It means the user clicked the select
546 // while the popup was showing, and as a result we first closed then
547 // immediately reopened the select popup. It needs to be closed.
548 hideSelectPopup();
549 }
550
551 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.ge t())) { 538 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.ge t())) {
552 // That click triggered a page popup that is the same as the one we just closed. 539 // That click triggered a page popup that is the same as the one we just closed.
553 // It needs to be closed. 540 // It needs to be closed.
554 cancelPagePopup(); 541 cancelPagePopup();
555 } 542 }
556 543
557 // Dispatch the contextmenu event regardless of if the click was swallowed. 544 // Dispatch the contextmenu event regardless of if the click was swallowed.
558 if (!page()->settings().showContextMenuOnMouseUp()) { 545 if (!page()->settings().showContextMenuOnMouseUp()) {
559 #if OS(MACOSX) 546 #if OS(MACOSX)
560 if (event.button == WebMouseEvent::ButtonRight 547 if (event.button == WebMouseEvent::ButtonRight
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 752 }
766 753
767 switch (event.type) { 754 switch (event.type) {
768 case WebInputEvent::GestureTap: { 755 case WebInputEvent::GestureTap: {
769 m_client->cancelScheduledContentIntents(); 756 m_client->cancelScheduledContentIntents();
770 if (detectContentOnTouch(targetedEvent)) { 757 if (detectContentOnTouch(targetedEvent)) {
771 eventSwallowed = true; 758 eventSwallowed = true;
772 break; 759 break;
773 } 760 }
774 761
775 RefPtrWillBeRawPtr<PopupContainer> selectPopup = nullptr;
776 selectPopup = m_selectPopup;
777 hideSelectPopup();
778 ASSERT(!m_selectPopup);
779
780 // Don't trigger a disambiguation popup on sites designed for mobile dev ices. 762 // Don't trigger a disambiguation popup on sites designed for mobile dev ices.
781 // Instead, assume that the page has been designed with big enough butto ns and links. 763 // Instead, assume that the page has been designed with big enough butto ns and links.
782 // Don't trigger a disambiguation popup when screencasting, since it's i mplemented outside of 764 // Don't trigger a disambiguation popup when screencasting, since it's i mplemented outside of
783 // compositor pipeline and is not being screencasted itself. This leads to bad user experience. 765 // compositor pipeline and is not being screencasted itself. This leads to bad user experience.
784 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); 766 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl();
785 bool screencastEnabled = devTools && devTools->screencastEnabled(); 767 bool screencastEnabled = devTools && devTools->screencastEnabled();
786 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !s creencastEnabled) { 768 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !s creencastEnabled) {
787 IntRect boundingBox(page()->frameHost().pinchViewport().viewportToRo otFrame(IntRect( 769 IntRect boundingBox(page()->frameHost().pinchViewport().viewportToRo otFrame(IntRect(
788 event.x - event.data.tap.width / 2, 770 event.x - event.data.tap.width / 2,
789 event.y - event.data.tap.height / 2, 771 event.y - event.data.tap.height / 2,
(...skipping 16 matching lines...) Expand all
806 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 788 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
807 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); 789 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
808 eventSwallowed = true; 790 eventSwallowed = true;
809 eventCancelled = true; 791 eventCancelled = true;
810 break; 792 break;
811 } 793 }
812 } 794 }
813 } 795 }
814 796
815 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(targetedEvent); 797 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(targetedEvent);
816
817 if (m_selectPopup && m_selectPopup == selectPopup) {
818 // That tap triggered a select popup which is the same as the one th at
819 // was showing before the tap. It means the user tapped the select
820 // while the popup was showing, and as a result we first closed then
821 // immediately reopened the select popup. It needs to be closed.
822 hideSelectPopup();
823 }
824
825 break; 798 break;
826 } 799 }
827 case WebInputEvent::GestureTwoFingerTap: 800 case WebInputEvent::GestureTwoFingerTap:
828 case WebInputEvent::GestureLongPress: 801 case WebInputEvent::GestureLongPress:
829 case WebInputEvent::GestureLongTap: { 802 case WebInputEvent::GestureLongTap: {
830 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 803 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
831 break; 804 break;
832 805
833 m_client->cancelScheduledContentIntents(); 806 m_client->cancelScheduledContentIntents();
834 m_page->contextMenuController().clearContextMenu(); 807 m_page->contextMenuController().clearContextMenu();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 endActiveFlingAnimation(); 998 endActiveFlingAnimation();
1026 999
1027 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1000 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1028 // member. 1001 // member.
1029 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by 1002 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
1030 // Webkit. A keyDown event is typically associated with a keyPress(char) 1003 // Webkit. A keyDown event is typically associated with a keyPress(char)
1031 // event and a keyUp event. We reset this flag here as this is a new keyDown 1004 // event and a keyUp event. We reset this flag here as this is a new keyDown
1032 // event. 1005 // event.
1033 m_suppressNextKeypressEvent = false; 1006 m_suppressNextKeypressEvent = false;
1034 1007
1035 // If there is a select popup, it should be the one processing the event, 1008 // If there is a popup, it should be the one processing the event, not the
1036 // not the page. 1009 // page.
1037 if (m_selectPopup)
1038 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1039 if (m_pagePopup) { 1010 if (m_pagePopup) {
1040 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1011 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1041 // We need to ignore the next Char event after this otherwise pressing 1012 // We need to ignore the next Char event after this otherwise pressing
1042 // enter when selecting an item in the popup will go to the page. 1013 // enter when selecting an item in the popup will go to the page.
1043 if (WebInputEvent::RawKeyDown == event.type) 1014 if (WebInputEvent::RawKeyDown == event.type)
1044 m_suppressNextKeypressEvent = true; 1015 m_suppressNextKeypressEvent = true;
1045 return true; 1016 return true;
1046 } 1017 }
1047 1018
1048 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); 1019 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 ASSERT(event.type == WebInputEvent::Char); 1076 ASSERT(event.type == WebInputEvent::Char);
1106 1077
1107 // Please refer to the comments explaining the m_suppressNextKeypressEvent 1078 // Please refer to the comments explaining the m_suppressNextKeypressEvent
1108 // member. The m_suppressNextKeypressEvent is set if the KeyDown is 1079 // member. The m_suppressNextKeypressEvent is set if the KeyDown is
1109 // handled by Webkit. A keyDown event is typically associated with a 1080 // handled by Webkit. A keyDown event is typically associated with a
1110 // keyPress(char) event and a keyUp event. We reset this flag here as it 1081 // keyPress(char) event and a keyUp event. We reset this flag here as it
1111 // only applies to the current keyPress event. 1082 // only applies to the current keyPress event.
1112 bool suppress = m_suppressNextKeypressEvent; 1083 bool suppress = m_suppressNextKeypressEvent;
1113 m_suppressNextKeypressEvent = false; 1084 m_suppressNextKeypressEvent = false;
1114 1085
1115 // If there is a select popup, it should be the one processing the event, 1086 // If there is a popup, it should be the one processing the event, not the
1116 // not the page. 1087 // page.
1117 if (m_selectPopup)
1118 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event) );
1119 if (m_pagePopup) 1088 if (m_pagePopup)
1120 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 1089 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
1121 1090
1122 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); 1091 LocalFrame* frame = toLocalFrame(focusedCoreFrame());
1123 if (!frame) 1092 if (!frame)
1124 return suppress; 1093 return suppress;
1125 1094
1126 EventHandler& handler = frame->eventHandler(); 1095 EventHandler& handler = frame->eventHandler();
1127 1096
1128 PlatformKeyboardEventBuilder evt(event); 1097 PlatformKeyboardEventBuilder evt(event);
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 *scrollDirection = ScrollDown; 1585 *scrollDirection = ScrollDown;
1617 *scrollGranularity = ScrollByPage; 1586 *scrollGranularity = ScrollByPage;
1618 break; 1587 break;
1619 default: 1588 default:
1620 return false; 1589 return false;
1621 } 1590 }
1622 1591
1623 return true; 1592 return true;
1624 } 1593 }
1625 1594
1626 void WebViewImpl::hideSelectPopup()
1627 {
1628 if (m_selectPopup)
1629 m_selectPopup->hidePopup();
1630 }
1631
1632 void WebViewImpl::popupOpened(PopupContainer* popupContainer)
1633 {
1634 ASSERT(!m_selectPopup);
1635 m_selectPopup = popupContainer;
1636 enablePopupMouseWheelEventListener();
1637 }
1638
1639 void WebViewImpl::popupClosed(PopupContainer* popupContainer)
1640 {
1641 ASSERT(m_selectPopup);
1642 m_selectPopup = nullptr;
1643 disablePopupMouseWheelEventListener();
1644 }
1645
1646 PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client) 1595 PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client)
1647 { 1596 {
1648 ASSERT(client); 1597 ASSERT(client);
1649 if (hasOpenedPopup()) 1598 if (hasOpenedPopup())
1650 hidePopups(); 1599 hidePopups();
1651 ASSERT(!m_pagePopup); 1600 ASSERT(!m_pagePopup);
1652 1601
1653 WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage); 1602 WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage);
1654 ASSERT(popupWidget); 1603 ASSERT(popupWidget);
1655 m_pagePopup = toWebPagePopupImpl(popupWidget); 1604 m_pagePopup = toWebPagePopupImpl(popupWidget);
(...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after
3807 3756
3808 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s tartPosition, endPosition); 3757 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s tartPosition, endPosition);
3809 if (!range) 3758 if (!range)
3810 return; 3759 return;
3811 3760
3812 clipHtml = createMarkup(range.get(), AnnotateForInterchange, ConvertBlocksTo Inlines::NotConvert, ResolveNonLocalURLs); 3761 clipHtml = createMarkup(range.get(), AnnotateForInterchange, ConvertBlocksTo Inlines::NotConvert, ResolveNonLocalURLs);
3813 } 3762 }
3814 3763
3815 void WebViewImpl::hidePopups() 3764 void WebViewImpl::hidePopups()
3816 { 3765 {
3817 hideSelectPopup();
3818 cancelPagePopup(); 3766 cancelPagePopup();
3819 } 3767 }
3820 3768
3821 void WebViewImpl::setIsTransparent(bool isTransparent) 3769 void WebViewImpl::setIsTransparent(bool isTransparent)
3822 { 3770 {
3823 // Set any existing frames to be transparent. 3771 // Set any existing frames to be transparent.
3824 Frame* frame = m_page->mainFrame(); 3772 Frame* frame = m_page->mainFrame();
3825 while (frame) { 3773 while (frame) {
3826 if (frame->isLocalFrame()) 3774 if (frame->isLocalFrame())
3827 toLocalFrame(frame)->view()->setTransparent(isTransparent); 3775 toLocalFrame(frame)->view()->setTransparent(isTransparent);
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
4457 { 4405 {
4458 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4406 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4459 } 4407 }
4460 4408
4461 void WebViewImpl::forceNextDrawingBufferCreationToFail() 4409 void WebViewImpl::forceNextDrawingBufferCreationToFail()
4462 { 4410 {
4463 DrawingBuffer::forceNextDrawingBufferCreationToFail(); 4411 DrawingBuffer::forceNextDrawingBufferCreationToFail();
4464 } 4412 }
4465 4413
4466 } // namespace blink 4414 } // 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