| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 Google Inc. All Rights Reserved. | 2 * Copyright 2007 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * ***** BEGIN LICENSE BLOCK ***** | 6 * ***** BEGIN LICENSE BLOCK ***** |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 new_navigation_loader_(NULL), | 356 new_navigation_loader_(NULL), |
| 357 #endif | 357 #endif |
| 358 zoom_level_(0), | 358 zoom_level_(0), |
| 359 context_menu_allowed_(false), | 359 context_menu_allowed_(false), |
| 360 doing_drag_and_drop_(false), | 360 doing_drag_and_drop_(false), |
| 361 suppress_next_keypress_event_(false), | 361 suppress_next_keypress_event_(false), |
| 362 window_open_disposition_(IGNORE_ACTION), | 362 window_open_disposition_(IGNORE_ACTION), |
| 363 ime_accept_events_(true), | 363 ime_accept_events_(true), |
| 364 drag_target_dispatch_(false), | 364 drag_target_dispatch_(false), |
| 365 drag_identity_(0), | 365 drag_identity_(0), |
| 366 drop_effect_(DROP_EFFECT_DEFAULT), |
| 367 drop_accept_(false), |
| 366 autocomplete_popup_showing_(false) { | 368 autocomplete_popup_showing_(false) { |
| 367 // WebKit/win/WebView.cpp does the same thing, except they call the | 369 // WebKit/win/WebView.cpp does the same thing, except they call the |
| 368 // KJS specific wrapper around this method. We need to have threading | 370 // KJS specific wrapper around this method. We need to have threading |
| 369 // initialized because CollatorICU requires it. | 371 // initialized because CollatorICU requires it. |
| 370 WTF::initializeThreading(); | 372 WTF::initializeThreading(); |
| 371 | 373 |
| 372 // set to impossible point so we always get the first mouse pos | 374 // set to impossible point so we always get the first mouse pos |
| 373 last_mouse_position_ = WebPoint(-1, -1); | 375 last_mouse_position_ = WebPoint(-1, -1); |
| 374 | 376 |
| 375 // the page will take ownership of the various clients | 377 // the page will take ownership of the various clients |
| (...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 | 1639 |
| 1638 current_drag_data_ = | 1640 current_drag_data_ = |
| 1639 webkit_glue::WebDragDataToChromiumDataObject(web_drag_data); | 1641 webkit_glue::WebDragDataToChromiumDataObject(web_drag_data); |
| 1640 drag_identity_ = identity; | 1642 drag_identity_ = identity; |
| 1641 | 1643 |
| 1642 DragData drag_data( | 1644 DragData drag_data( |
| 1643 current_drag_data_.get(), | 1645 current_drag_data_.get(), |
| 1644 webkit_glue::WebPointToIntPoint(client_point), | 1646 webkit_glue::WebPointToIntPoint(client_point), |
| 1645 webkit_glue::WebPointToIntPoint(screen_point), | 1647 webkit_glue::WebPointToIntPoint(screen_point), |
| 1646 kDropTargetOperation); | 1648 kDropTargetOperation); |
| 1649 |
| 1650 drop_effect_ = DROP_EFFECT_DEFAULT; |
| 1647 drag_target_dispatch_ = true; | 1651 drag_target_dispatch_ = true; |
| 1648 DragOperation effect = page_->dragController()->dragEntered(&drag_data); | 1652 DragOperation effect = page_->dragController()->dragEntered(&drag_data); |
| 1649 drag_target_dispatch_ = false; | 1653 drag_target_dispatch_ = false; |
| 1650 | 1654 |
| 1651 return effect != DragOperationNone; | 1655 if (drop_effect_ != DROP_EFFECT_DEFAULT) |
| 1656 return drop_accept_ = (drop_effect_ != DROP_EFFECT_NONE); |
| 1657 return drop_accept_ = (effect != DragOperationNone); |
| 1652 } | 1658 } |
| 1653 | 1659 |
| 1654 bool WebViewImpl::DragTargetDragOver( | 1660 bool WebViewImpl::DragTargetDragOver( |
| 1655 const WebPoint& client_point, | 1661 const WebPoint& client_point, |
| 1656 const WebPoint& screen_point) { | 1662 const WebPoint& screen_point) { |
| 1657 DCHECK(current_drag_data_.get()); | 1663 DCHECK(current_drag_data_.get()); |
| 1658 | 1664 |
| 1659 DragData drag_data( | 1665 DragData drag_data( |
| 1660 current_drag_data_.get(), | 1666 current_drag_data_.get(), |
| 1661 webkit_glue::WebPointToIntPoint(client_point), | 1667 webkit_glue::WebPointToIntPoint(client_point), |
| 1662 webkit_glue::WebPointToIntPoint(screen_point), | 1668 webkit_glue::WebPointToIntPoint(screen_point), |
| 1663 kDropTargetOperation); | 1669 kDropTargetOperation); |
| 1670 |
| 1671 drop_effect_ = DROP_EFFECT_DEFAULT; |
| 1664 drag_target_dispatch_ = true; | 1672 drag_target_dispatch_ = true; |
| 1665 DragOperation effect = page_->dragController()->dragUpdated(&drag_data); | 1673 DragOperation effect = page_->dragController()->dragUpdated(&drag_data); |
| 1666 drag_target_dispatch_ = false; | 1674 drag_target_dispatch_ = false; |
| 1667 | 1675 |
| 1668 return effect != DragOperationNone; | 1676 if (drop_effect_ != DROP_EFFECT_DEFAULT) |
| 1677 return drop_accept_ = (drop_effect_ != DROP_EFFECT_NONE); |
| 1678 return drop_accept_ = (effect != DragOperationNone); |
| 1669 } | 1679 } |
| 1670 | 1680 |
| 1671 void WebViewImpl::DragTargetDragLeave() { | 1681 void WebViewImpl::DragTargetDragLeave() { |
| 1672 DCHECK(current_drag_data_.get()); | 1682 DCHECK(current_drag_data_.get()); |
| 1673 | 1683 |
| 1674 DragData drag_data( | 1684 DragData drag_data( |
| 1675 current_drag_data_.get(), | 1685 current_drag_data_.get(), |
| 1676 IntPoint(), | 1686 IntPoint(), |
| 1677 IntPoint(), | 1687 IntPoint(), |
| 1678 kDropTargetOperation); | 1688 kDropTargetOperation); |
| 1689 |
| 1679 drag_target_dispatch_ = true; | 1690 drag_target_dispatch_ = true; |
| 1680 page_->dragController()->dragExited(&drag_data); | 1691 page_->dragController()->dragExited(&drag_data); |
| 1681 drag_target_dispatch_ = false; | 1692 drag_target_dispatch_ = false; |
| 1682 | 1693 |
| 1683 current_drag_data_ = NULL; | 1694 current_drag_data_ = NULL; |
| 1695 drop_effect_ = DROP_EFFECT_DEFAULT; |
| 1696 drop_accept_ = false; |
| 1684 drag_identity_ = 0; | 1697 drag_identity_ = 0; |
| 1685 } | 1698 } |
| 1686 | 1699 |
| 1687 void WebViewImpl::DragTargetDrop( | 1700 void WebViewImpl::DragTargetDrop( |
| 1688 const WebPoint& client_point, | 1701 const WebPoint& client_point, |
| 1689 const WebPoint& screen_point) { | 1702 const WebPoint& screen_point) { |
| 1690 DCHECK(current_drag_data_.get()); | 1703 DCHECK(current_drag_data_.get()); |
| 1691 | 1704 |
| 1705 // If this webview transitions from the "drop accepting" state to the "not |
| 1706 // accepting" state, then our IPC message reply indicating that may be in- |
| 1707 // flight, or else delayed by javascript processing in this webview. If a |
| 1708 // drop happens before our IPC reply has reached the browser process, then |
| 1709 // the browser forwards the drop to this webview. So only allow a drop to |
| 1710 // proceed if our webview drop_accept_ state is true. |
| 1711 |
| 1712 if (!drop_accept_) { // IPC RACE CONDITION: do not allow this drop. |
| 1713 DragTargetDragLeave(); |
| 1714 return; |
| 1715 } |
| 1716 |
| 1692 DragData drag_data( | 1717 DragData drag_data( |
| 1693 current_drag_data_.get(), | 1718 current_drag_data_.get(), |
| 1694 webkit_glue::WebPointToIntPoint(client_point), | 1719 webkit_glue::WebPointToIntPoint(client_point), |
| 1695 webkit_glue::WebPointToIntPoint(screen_point), | 1720 webkit_glue::WebPointToIntPoint(screen_point), |
| 1696 kDropTargetOperation); | 1721 kDropTargetOperation); |
| 1722 |
| 1697 drag_target_dispatch_ = true; | 1723 drag_target_dispatch_ = true; |
| 1698 page_->dragController()->performDrag(&drag_data); | 1724 page_->dragController()->performDrag(&drag_data); |
| 1699 drag_target_dispatch_ = false; | 1725 drag_target_dispatch_ = false; |
| 1700 | 1726 |
| 1701 current_drag_data_ = NULL; | 1727 current_drag_data_ = NULL; |
| 1728 drop_effect_ = DROP_EFFECT_DEFAULT; |
| 1729 drop_accept_ = false; |
| 1702 drag_identity_ = 0; | 1730 drag_identity_ = 0; |
| 1703 } | 1731 } |
| 1704 | 1732 |
| 1705 int32 WebViewImpl::GetDragIdentity() { | 1733 int32 WebViewImpl::GetDragIdentity() { |
| 1706 if (drag_target_dispatch_) | 1734 if (drag_target_dispatch_) |
| 1707 return drag_identity_; | 1735 return drag_identity_; |
| 1708 return 0; | 1736 return 0; |
| 1709 } | 1737 } |
| 1710 | 1738 |
| 1739 bool WebViewImpl::SetDropEffect(bool accept) { |
| 1740 if (drag_target_dispatch_) { |
| 1741 drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE; |
| 1742 return true; |
| 1743 } else { |
| 1744 return false; |
| 1745 } |
| 1746 } |
| 1747 |
| 1711 SearchableFormData* WebViewImpl::CreateSearchableFormDataForFocusedNode() { | 1748 SearchableFormData* WebViewImpl::CreateSearchableFormDataForFocusedNode() { |
| 1712 if (!page_.get()) | 1749 if (!page_.get()) |
| 1713 return NULL; | 1750 return NULL; |
| 1714 | 1751 |
| 1715 if (RefPtr<Frame> focused = page_->focusController()->focusedFrame()) { | 1752 if (RefPtr<Frame> focused = page_->focusController()->focusedFrame()) { |
| 1716 RefPtr<Document> document = focused->document(); | 1753 RefPtr<Document> document = focused->document(); |
| 1717 if (document.get()) { | 1754 if (document.get()) { |
| 1718 RefPtr<Node> focused_node = document->focusedNode(); | 1755 RefPtr<Node> focused_node = document->focusedNode(); |
| 1719 if (focused_node.get() && | 1756 if (focused_node.get() && |
| 1720 focused_node->nodeType() == Node::ELEMENT_NODE) { | 1757 focused_node->nodeType() == Node::ELEMENT_NODE) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 | 1934 |
| 1898 return document->focusedNode(); | 1935 return document->focusedNode(); |
| 1899 } | 1936 } |
| 1900 | 1937 |
| 1901 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { | 1938 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { |
| 1902 IntPoint doc_point( | 1939 IntPoint doc_point( |
| 1903 page_->mainFrame()->view()->windowToContents(pos)); | 1940 page_->mainFrame()->view()->windowToContents(pos)); |
| 1904 return page_->mainFrame()->eventHandler()-> | 1941 return page_->mainFrame()->eventHandler()-> |
| 1905 hitTestResultAtPoint(doc_point, false); | 1942 hitTestResultAtPoint(doc_point, false); |
| 1906 } | 1943 } |
| OLD | NEW |