| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 m_client->setMouseOverURL(WebURL()); | 533 m_client->setMouseOverURL(WebURL()); |
| 534 PageWidgetEventHandler::handleMouseLeave(mainFrame, event); | 534 PageWidgetEventHandler::handleMouseLeave(mainFrame, event); |
| 535 } | 535 } |
| 536 | 536 |
| 537 void WebViewImpl::handleMouseDown(Frame& mainFrame, const WebMouseEvent& event) | 537 void WebViewImpl::handleMouseDown(Frame& mainFrame, const WebMouseEvent& event) |
| 538 { | 538 { |
| 539 // If there is a popup open, close it as the user is clicking on the page (o
utside of the | 539 // If there is a popup open, close it as the user is clicking on the page (o
utside of the |
| 540 // popup). We also save it so we can prevent a click on an element from imme
diately | 540 // popup). We also save it so we can prevent a click on an element from imme
diately |
| 541 // reopening the same popup. | 541 // reopening the same popup. |
| 542 RefPtr<WebCore::PopupContainer> selectPopup; | 542 RefPtr<WebCore::PopupContainer> selectPopup; |
| 543 #if ENABLE(PAGE_POPUP) | |
| 544 RefPtr<WebPagePopupImpl> pagePopup; | 543 RefPtr<WebPagePopupImpl> pagePopup; |
| 545 #endif | |
| 546 if (event.button == WebMouseEvent::ButtonLeft) { | 544 if (event.button == WebMouseEvent::ButtonLeft) { |
| 547 selectPopup = m_selectPopup; | 545 selectPopup = m_selectPopup; |
| 548 #if ENABLE(PAGE_POPUP) | |
| 549 pagePopup = m_pagePopup; | 546 pagePopup = m_pagePopup; |
| 550 #endif | |
| 551 hidePopups(); | 547 hidePopups(); |
| 552 ASSERT(!m_selectPopup); | 548 ASSERT(!m_selectPopup); |
| 553 #if ENABLE(PAGE_POPUP) | |
| 554 ASSERT(!m_pagePopup); | 549 ASSERT(!m_pagePopup); |
| 555 #endif | |
| 556 } | 550 } |
| 557 | 551 |
| 558 m_lastMouseDownPoint = WebPoint(event.x, event.y); | 552 m_lastMouseDownPoint = WebPoint(event.x, event.y); |
| 559 | 553 |
| 560 if (event.button == WebMouseEvent::ButtonLeft) { | 554 if (event.button == WebMouseEvent::ButtonLeft) { |
| 561 IntPoint point(event.x, event.y); | 555 IntPoint point(event.x, event.y); |
| 562 point = m_page->mainFrame()->view()->windowToContents(point); | 556 point = m_page->mainFrame()->view()->windowToContents(point); |
| 563 HitTestResult result(m_page->mainFrame()->eventHandler()->hitTestResultA
tPoint(point)); | 557 HitTestResult result(m_page->mainFrame()->eventHandler()->hitTestResultA
tPoint(point)); |
| 564 Node* hitNode = result.innerNonSharedNode(); | 558 Node* hitNode = result.innerNonSharedNode(); |
| 565 | 559 |
| 566 // Take capture on a mouse down on a plugin so we can send it mouse even
ts. | 560 // Take capture on a mouse down on a plugin so we can send it mouse even
ts. |
| 567 if (hitNode && hitNode->renderer() && hitNode->renderer()->isEmbeddedObj
ect()) { | 561 if (hitNode && hitNode->renderer() && hitNode->renderer()->isEmbeddedObj
ect()) { |
| 568 m_mouseCaptureNode = hitNode; | 562 m_mouseCaptureNode = hitNode; |
| 569 TRACE_EVENT_ASYNC_BEGIN0("webkit", "capturing mouse", this); | 563 TRACE_EVENT_ASYNC_BEGIN0("webkit", "capturing mouse", this); |
| 570 } | 564 } |
| 571 } | 565 } |
| 572 | 566 |
| 573 PageWidgetEventHandler::handleMouseDown(mainFrame, event); | 567 PageWidgetEventHandler::handleMouseDown(mainFrame, event); |
| 574 | 568 |
| 575 if (m_selectPopup && m_selectPopup == selectPopup) { | 569 if (m_selectPopup && m_selectPopup == selectPopup) { |
| 576 // That click triggered a select popup which is the same as the one that | 570 // That click triggered a select popup which is the same as the one that |
| 577 // was showing before the click. It means the user clicked the select | 571 // was showing before the click. It means the user clicked the select |
| 578 // while the popup was showing, and as a result we first closed then | 572 // while the popup was showing, and as a result we first closed then |
| 579 // immediately reopened the select popup. It needs to be closed. | 573 // immediately reopened the select popup. It needs to be closed. |
| 580 hideSelectPopup(); | 574 hideSelectPopup(); |
| 581 } | 575 } |
| 582 | 576 |
| 583 #if ENABLE(PAGE_POPUP) | |
| 584 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.ge
t())) { | 577 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopup.ge
t())) { |
| 585 // That click triggered a page popup that is the same as the one we just
closed. | 578 // That click triggered a page popup that is the same as the one we just
closed. |
| 586 // It needs to be closed. | 579 // It needs to be closed. |
| 587 closePagePopup(m_pagePopup.get()); | 580 closePagePopup(m_pagePopup.get()); |
| 588 } | 581 } |
| 589 #endif | |
| 590 | 582 |
| 591 // Dispatch the contextmenu event regardless of if the click was swallowed. | 583 // Dispatch the contextmenu event regardless of if the click was swallowed. |
| 592 // On Windows, we handle it on mouse up, not down. | 584 // On Windows, we handle it on mouse up, not down. |
| 593 #if OS(DARWIN) | 585 #if OS(DARWIN) |
| 594 if (event.button == WebMouseEvent::ButtonRight | 586 if (event.button == WebMouseEvent::ButtonRight |
| 595 || (event.button == WebMouseEvent::ButtonLeft | 587 || (event.button == WebMouseEvent::ButtonLeft |
| 596 && event.modifiers & WebMouseEvent::ControlKey)) | 588 && event.modifiers & WebMouseEvent::ControlKey)) |
| 597 mouseContextMenu(event); | 589 mouseContextMenu(event); |
| 598 #elif OS(UNIX) | 590 #elif OS(UNIX) |
| 599 if (event.button == WebMouseEvent::ButtonRight) | 591 if (event.button == WebMouseEvent::ButtonRight) |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by | 932 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by |
| 941 // Webkit. A keyDown event is typically associated with a keyPress(char) | 933 // Webkit. A keyDown event is typically associated with a keyPress(char) |
| 942 // event and a keyUp event. We reset this flag here as this is a new keyDown | 934 // event and a keyUp event. We reset this flag here as this is a new keyDown |
| 943 // event. | 935 // event. |
| 944 m_suppressNextKeypressEvent = false; | 936 m_suppressNextKeypressEvent = false; |
| 945 | 937 |
| 946 // If there is a select popup, it should be the one processing the event, | 938 // If there is a select popup, it should be the one processing the event, |
| 947 // not the page. | 939 // not the page. |
| 948 if (m_selectPopup) | 940 if (m_selectPopup) |
| 949 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); | 941 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); |
| 950 #if ENABLE(PAGE_POPUP) | |
| 951 if (m_pagePopup) { | 942 if (m_pagePopup) { |
| 952 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 943 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 953 // We need to ignore the next Char event after this otherwise pressing | 944 // We need to ignore the next Char event after this otherwise pressing |
| 954 // enter when selecting an item in the popup will go to the page. | 945 // enter when selecting an item in the popup will go to the page. |
| 955 if (WebInputEvent::RawKeyDown == event.type) | 946 if (WebInputEvent::RawKeyDown == event.type) |
| 956 m_suppressNextKeypressEvent = true; | 947 m_suppressNextKeypressEvent = true; |
| 957 return true; | 948 return true; |
| 958 } | 949 } |
| 959 #endif | |
| 960 | 950 |
| 961 // Give Autocomplete a chance to consume the key events it is interested in. | 951 // Give Autocomplete a chance to consume the key events it is interested in. |
| 962 if (autocompleteHandleKeyEvent(event)) | 952 if (autocompleteHandleKeyEvent(event)) |
| 963 return true; | 953 return true; |
| 964 | 954 |
| 965 RefPtr<Frame> frame = focusedWebCoreFrame(); | 955 RefPtr<Frame> frame = focusedWebCoreFrame(); |
| 966 if (!frame) | 956 if (!frame) |
| 967 return false; | 957 return false; |
| 968 | 958 |
| 969 EventHandler* handler = frame->eventHandler(); | 959 EventHandler* handler = frame->eventHandler(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 // handled by Webkit. A keyDown event is typically associated with a | 1052 // handled by Webkit. A keyDown event is typically associated with a |
| 1063 // keyPress(char) event and a keyUp event. We reset this flag here as it | 1053 // keyPress(char) event and a keyUp event. We reset this flag here as it |
| 1064 // only applies to the current keyPress event. | 1054 // only applies to the current keyPress event. |
| 1065 bool suppress = m_suppressNextKeypressEvent; | 1055 bool suppress = m_suppressNextKeypressEvent; |
| 1066 m_suppressNextKeypressEvent = false; | 1056 m_suppressNextKeypressEvent = false; |
| 1067 | 1057 |
| 1068 // If there is a select popup, it should be the one processing the event, | 1058 // If there is a select popup, it should be the one processing the event, |
| 1069 // not the page. | 1059 // not the page. |
| 1070 if (m_selectPopup) | 1060 if (m_selectPopup) |
| 1071 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); | 1061 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)
); |
| 1072 #if ENABLE(PAGE_POPUP) | |
| 1073 if (m_pagePopup) | 1062 if (m_pagePopup) |
| 1074 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 1063 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 1075 #endif | |
| 1076 | 1064 |
| 1077 Frame* frame = focusedWebCoreFrame(); | 1065 Frame* frame = focusedWebCoreFrame(); |
| 1078 if (!frame) | 1066 if (!frame) |
| 1079 return suppress; | 1067 return suppress; |
| 1080 | 1068 |
| 1081 EventHandler* handler = frame->eventHandler(); | 1069 EventHandler* handler = frame->eventHandler(); |
| 1082 if (!handler) | 1070 if (!handler) |
| 1083 return suppress || keyEventDefault(event); | 1071 return suppress || keyEventDefault(event); |
| 1084 | 1072 |
| 1085 PlatformKeyboardEventBuilder evt(event); | 1073 PlatformKeyboardEventBuilder evt(event); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 } | 1502 } |
| 1515 | 1503 |
| 1516 void WebViewImpl::popupClosed(WebCore::PopupContainer* popupContainer) | 1504 void WebViewImpl::popupClosed(WebCore::PopupContainer* popupContainer) |
| 1517 { | 1505 { |
| 1518 if (popupContainer->popupType() == WebCore::PopupContainer::Select) { | 1506 if (popupContainer->popupType() == WebCore::PopupContainer::Select) { |
| 1519 ASSERT(m_selectPopup); | 1507 ASSERT(m_selectPopup); |
| 1520 m_selectPopup = 0; | 1508 m_selectPopup = 0; |
| 1521 } | 1509 } |
| 1522 } | 1510 } |
| 1523 | 1511 |
| 1524 #if ENABLE(PAGE_POPUP) | |
| 1525 PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or
iginBoundsInRootView) | 1512 PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or
iginBoundsInRootView) |
| 1526 { | 1513 { |
| 1527 ASSERT(client); | 1514 ASSERT(client); |
| 1528 if (hasOpenedPopup()) | 1515 if (hasOpenedPopup()) |
| 1529 hidePopups(); | 1516 hidePopups(); |
| 1530 ASSERT(!m_pagePopup); | 1517 ASSERT(!m_pagePopup); |
| 1531 | 1518 |
| 1532 WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage); | 1519 WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage); |
| 1533 ASSERT(popupWidget); | 1520 ASSERT(popupWidget); |
| 1534 m_pagePopup = static_cast<WebPagePopupImpl*>(popupWidget); | 1521 m_pagePopup = static_cast<WebPagePopupImpl*>(popupWidget); |
| 1535 if (!m_pagePopup->initialize(this, client, originBoundsInRootView)) { | 1522 if (!m_pagePopup->initialize(this, client, originBoundsInRootView)) { |
| 1536 m_pagePopup->closePopup(); | 1523 m_pagePopup->closePopup(); |
| 1537 m_pagePopup = 0; | 1524 m_pagePopup = 0; |
| 1538 } | 1525 } |
| 1539 return m_pagePopup.get(); | 1526 return m_pagePopup.get(); |
| 1540 } | 1527 } |
| 1541 | 1528 |
| 1542 void WebViewImpl::closePagePopup(PagePopup* popup) | 1529 void WebViewImpl::closePagePopup(PagePopup* popup) |
| 1543 { | 1530 { |
| 1544 ASSERT(popup); | 1531 ASSERT(popup); |
| 1545 WebPagePopupImpl* popupImpl = static_cast<WebPagePopupImpl*>(popup); | 1532 WebPagePopupImpl* popupImpl = static_cast<WebPagePopupImpl*>(popup); |
| 1546 ASSERT(m_pagePopup.get() == popupImpl); | 1533 ASSERT(m_pagePopup.get() == popupImpl); |
| 1547 if (m_pagePopup.get() != popupImpl) | 1534 if (m_pagePopup.get() != popupImpl) |
| 1548 return; | 1535 return; |
| 1549 m_pagePopup->closePopup(); | 1536 m_pagePopup->closePopup(); |
| 1550 m_pagePopup = 0; | 1537 m_pagePopup = 0; |
| 1551 } | 1538 } |
| 1552 #endif | |
| 1553 | 1539 |
| 1554 void WebViewImpl::hideAutofillPopup() | 1540 void WebViewImpl::hideAutofillPopup() |
| 1555 { | 1541 { |
| 1556 if (m_autofillPopupShowing) { | 1542 if (m_autofillPopupShowing) { |
| 1557 m_autofillPopup->hidePopup(); | 1543 m_autofillPopup->hidePopup(); |
| 1558 m_autofillPopupShowing = false; | 1544 m_autofillPopupShowing = false; |
| 1559 } | 1545 } |
| 1560 } | 1546 } |
| 1561 | 1547 |
| 1562 WebHelperPluginImpl* WebViewImpl::createHelperPlugin(const String& pluginType, c
onst WebDocument& hostDocument) | 1548 WebHelperPluginImpl* WebViewImpl::createHelperPlugin(const String& pluginType, c
onst WebDocument& hostDocument) |
| (...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3506 } else { | 3492 } else { |
| 3507 m_autofillPopupShowing = true; | 3493 m_autofillPopupShowing = true; |
| 3508 m_autofillPopup->showInRect(focusedNode->pixelSnappedBoundingBox(), focu
sedNode->ownerDocument()->view(), 0); | 3494 m_autofillPopup->showInRect(focusedNode->pixelSnappedBoundingBox(), focu
sedNode->ownerDocument()->view(), 0); |
| 3509 } | 3495 } |
| 3510 } | 3496 } |
| 3511 | 3497 |
| 3512 void WebViewImpl::hidePopups() | 3498 void WebViewImpl::hidePopups() |
| 3513 { | 3499 { |
| 3514 hideSelectPopup(); | 3500 hideSelectPopup(); |
| 3515 hideAutofillPopup(); | 3501 hideAutofillPopup(); |
| 3516 #if ENABLE(PAGE_POPUP) | |
| 3517 if (m_pagePopup) | 3502 if (m_pagePopup) |
| 3518 closePagePopup(m_pagePopup.get()); | 3503 closePagePopup(m_pagePopup.get()); |
| 3519 #endif | |
| 3520 } | 3504 } |
| 3521 | 3505 |
| 3522 void WebViewImpl::performCustomContextMenuAction(unsigned action) | 3506 void WebViewImpl::performCustomContextMenuAction(unsigned action) |
| 3523 { | 3507 { |
| 3524 if (!m_page) | 3508 if (!m_page) |
| 3525 return; | 3509 return; |
| 3526 ContextMenu* menu = m_page->contextMenuController()->contextMenu(); | 3510 ContextMenu* menu = m_page->contextMenuController()->contextMenu(); |
| 3527 if (!menu) | 3511 if (!menu) |
| 3528 return; | 3512 return; |
| 3529 const ContextMenuItem* item = menu->itemWithAction(static_cast<ContextMenuAc
tion>(ContextMenuItemBaseCustomTag + action)); | 3513 const ContextMenuItem* item = menu->itemWithAction(static_cast<ContextMenuAc
tion>(ContextMenuItemBaseCustomTag + action)); |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4210 } | 4194 } |
| 4211 | 4195 |
| 4212 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4196 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 4213 { | 4197 { |
| 4214 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); | 4198 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); |
| 4215 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom | 4199 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom |
| 4216 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); | 4200 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); |
| 4217 } | 4201 } |
| 4218 | 4202 |
| 4219 } // namespace WebKit | 4203 } // namespace WebKit |
| OLD | NEW |