| OLD | NEW |
| 1 // Copyright (c) 2007-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2007-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 MSVC_PUSH_WARNING_LEVEL(0); | 9 MSVC_PUSH_WARNING_LEVEL(0); |
| 10 #include "CSSStyleSelector.h" | 10 #include "CSSStyleSelector.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #include "TypingCommand.h" | 56 #include "TypingCommand.h" |
| 57 MSVC_POP_WARNING(); | 57 MSVC_POP_WARNING(); |
| 58 #undef LOG | 58 #undef LOG |
| 59 | 59 |
| 60 #include "base/gfx/rect.h" | 60 #include "base/gfx/rect.h" |
| 61 #include "base/keyboard_codes.h" | 61 #include "base/keyboard_codes.h" |
| 62 #include "base/logging.h" | 62 #include "base/logging.h" |
| 63 #include "base/message_loop.h" | 63 #include "base/message_loop.h" |
| 64 #include "webkit/api/public/WebDragData.h" | 64 #include "webkit/api/public/WebDragData.h" |
| 65 #include "webkit/api/public/WebInputEvent.h" | 65 #include "webkit/api/public/WebInputEvent.h" |
| 66 #include "webkit/api/public/WebMediaPlayerAction.h" |
| 66 #include "webkit/api/public/WebPoint.h" | 67 #include "webkit/api/public/WebPoint.h" |
| 67 #include "webkit/api/public/WebRect.h" | 68 #include "webkit/api/public/WebRect.h" |
| 68 #include "webkit/api/public/WebString.h" | 69 #include "webkit/api/public/WebString.h" |
| 69 #include "webkit/api/src/WebInputEventConversion.h" | 70 #include "webkit/api/src/WebInputEventConversion.h" |
| 70 #include "webkit/api/src/WebSettingsImpl.h" | 71 #include "webkit/api/src/WebSettingsImpl.h" |
| 71 #include "webkit/glue/dom_operations.h" | 72 #include "webkit/glue/dom_operations.h" |
| 72 #include "webkit/glue/glue_serialize.h" | 73 #include "webkit/glue/glue_serialize.h" |
| 73 #include "webkit/glue/glue_util.h" | 74 #include "webkit/glue/glue_util.h" |
| 74 #include "webkit/glue/image_resource_fetcher.h" | 75 #include "webkit/glue/image_resource_fetcher.h" |
| 75 #include "webkit/glue/media_player_action.h" | |
| 76 #include "webkit/glue/searchable_form_data.h" | 76 #include "webkit/glue/searchable_form_data.h" |
| 77 #include "webkit/glue/webdevtoolsagent_impl.h" | 77 #include "webkit/glue/webdevtoolsagent_impl.h" |
| 78 #include "webkit/glue/webkit_glue.h" | 78 #include "webkit/glue/webkit_glue.h" |
| 79 #include "webkit/glue/webpopupmenu_impl.h" | 79 #include "webkit/glue/webpopupmenu_impl.h" |
| 80 #include "webkit/glue/webdevtoolsagent.h" | 80 #include "webkit/glue/webdevtoolsagent.h" |
| 81 #include "webkit/glue/webdevtoolsclient.h" | 81 #include "webkit/glue/webdevtoolsclient.h" |
| 82 #include "webkit/glue/webview_delegate.h" | 82 #include "webkit/glue/webview_delegate.h" |
| 83 #include "webkit/glue/webview_impl.h" | 83 #include "webkit/glue/webview_impl.h" |
| 84 | 84 |
| 85 // Get rid of WTF's pow define so we can use std::pow. | 85 // Get rid of WTF's pow define so we can use std::pow. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 using WebKit::WebCompositionCommandDiscard; | 97 using WebKit::WebCompositionCommandDiscard; |
| 98 using WebKit::WebDragData; | 98 using WebKit::WebDragData; |
| 99 using WebKit::WebDragOperation; | 99 using WebKit::WebDragOperation; |
| 100 using WebKit::WebDragOperationCopy; | 100 using WebKit::WebDragOperationCopy; |
| 101 using WebKit::WebDragOperationNone; | 101 using WebKit::WebDragOperationNone; |
| 102 using WebKit::WebDragOperationsMask; | 102 using WebKit::WebDragOperationsMask; |
| 103 using WebKit::WebFrame; | 103 using WebKit::WebFrame; |
| 104 using WebKit::WebFrameClient; | 104 using WebKit::WebFrameClient; |
| 105 using WebKit::WebInputEvent; | 105 using WebKit::WebInputEvent; |
| 106 using WebKit::WebKeyboardEvent; | 106 using WebKit::WebKeyboardEvent; |
| 107 using WebKit::WebMediaPlayerAction; |
| 107 using WebKit::WebMouseEvent; | 108 using WebKit::WebMouseEvent; |
| 108 using WebKit::WebMouseWheelEvent; | 109 using WebKit::WebMouseWheelEvent; |
| 109 using WebKit::WebNavigationPolicy; | 110 using WebKit::WebNavigationPolicy; |
| 110 using WebKit::WebPoint; | 111 using WebKit::WebPoint; |
| 111 using WebKit::WebRect; | 112 using WebKit::WebRect; |
| 112 using WebKit::WebSettings; | 113 using WebKit::WebSettings; |
| 113 using WebKit::WebSettingsImpl; | 114 using WebKit::WebSettingsImpl; |
| 114 using WebKit::WebSize; | 115 using WebKit::WebSize; |
| 115 using WebKit::WebString; | 116 using WebKit::WebString; |
| 116 using WebKit::WebTextDirection; | 117 using WebKit::WebTextDirection; |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 | 1411 |
| 1411 void WebViewImpl::zoomDefault() { | 1412 void WebViewImpl::zoomDefault() { |
| 1412 // We don't change the zoom mode (text only vs. full page) here. We just want | 1413 // We don't change the zoom mode (text only vs. full page) here. We just want |
| 1413 // to reset whatever is already set. | 1414 // to reset whatever is already set. |
| 1414 zoom_level_ = 0; | 1415 zoom_level_ = 0; |
| 1415 main_frame()->frame()->setZoomFactor( | 1416 main_frame()->frame()->setZoomFactor( |
| 1416 1.0f, | 1417 1.0f, |
| 1417 main_frame()->frame()->isZoomFactorTextOnly()); | 1418 main_frame()->frame()->isZoomFactorTextOnly()); |
| 1418 } | 1419 } |
| 1419 | 1420 |
| 1421 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, |
| 1422 const WebPoint& location) { |
| 1423 HitTestResult result = |
| 1424 HitTestResultForWindowPos(webkit_glue::WebPointToIntPoint(location)); |
| 1425 WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode(); |
| 1426 if (!node->hasTagName(WebCore::HTMLNames::videoTag) && |
| 1427 !node->hasTagName(WebCore::HTMLNames::audioTag)) |
| 1428 return; |
| 1429 |
| 1430 WTF::RefPtr<WebCore::HTMLMediaElement> media_element = |
| 1431 static_pointer_cast<WebCore::HTMLMediaElement>(node); |
| 1432 switch (action.type) { |
| 1433 case WebMediaPlayerAction::Play: |
| 1434 if (action.enable) { |
| 1435 media_element->play(); |
| 1436 } else { |
| 1437 media_element->pause(); |
| 1438 } |
| 1439 break; |
| 1440 case WebMediaPlayerAction::Mute: |
| 1441 media_element->setMuted(action.enable); |
| 1442 break; |
| 1443 case WebMediaPlayerAction::Loop: |
| 1444 media_element->setLoop(action.enable); |
| 1445 break; |
| 1446 default: |
| 1447 ASSERT_NOT_REACHED(); |
| 1448 } |
| 1449 } |
| 1450 |
| 1420 void WebViewImpl::copyImageAt(const WebPoint& point) { | 1451 void WebViewImpl::copyImageAt(const WebPoint& point) { |
| 1421 if (!page_.get()) | 1452 if (!page_.get()) |
| 1422 return; | 1453 return; |
| 1423 | 1454 |
| 1424 HitTestResult result = | 1455 HitTestResult result = |
| 1425 HitTestResultForWindowPos(webkit_glue::WebPointToIntPoint(point)); | 1456 HitTestResultForWindowPos(webkit_glue::WebPointToIntPoint(point)); |
| 1426 | 1457 |
| 1427 if (result.absoluteImageURL().isEmpty()) { | 1458 if (result.absoluteImageURL().isEmpty()) { |
| 1428 // There isn't actually an image at these coordinates. Might be because | 1459 // There isn't actually an image at these coordinates. Might be because |
| 1429 // the window scrolled while the context menu was open or because the page | 1460 // the window scrolled while the context menu was open or because the page |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 } | 1740 } |
| 1710 | 1741 |
| 1711 // Future frames check this to know whether to be transparent. | 1742 // Future frames check this to know whether to be transparent. |
| 1712 is_transparent_ = is_transparent; | 1743 is_transparent_ = is_transparent; |
| 1713 } | 1744 } |
| 1714 | 1745 |
| 1715 bool WebViewImpl::isTransparent() const { | 1746 bool WebViewImpl::isTransparent() const { |
| 1716 return is_transparent_; | 1747 return is_transparent_; |
| 1717 } | 1748 } |
| 1718 | 1749 |
| 1719 void WebViewImpl::MediaPlayerActionAt(int x, | |
| 1720 int y, | |
| 1721 const MediaPlayerAction& action) { | |
| 1722 HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); | |
| 1723 | |
| 1724 WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode(); | |
| 1725 if (node->hasTagName(WebCore::HTMLNames::videoTag) || | |
| 1726 node->hasTagName(WebCore::HTMLNames::audioTag)) { | |
| 1727 WTF::RefPtr<WebCore::HTMLMediaElement> media_element = | |
| 1728 static_pointer_cast<WebCore::HTMLMediaElement>(node); | |
| 1729 if (action.command & MediaPlayerAction::PLAY) { | |
| 1730 media_element->play(); | |
| 1731 } | |
| 1732 if (action.command & MediaPlayerAction::PAUSE) { | |
| 1733 media_element->pause(); | |
| 1734 } | |
| 1735 if (action.command & MediaPlayerAction::MUTE) { | |
| 1736 media_element->setMuted(true); | |
| 1737 } | |
| 1738 if (action.command & MediaPlayerAction::UNMUTE) { | |
| 1739 media_element->setMuted(false); | |
| 1740 } | |
| 1741 if (action.command & MediaPlayerAction::LOOP) { | |
| 1742 media_element->setLoop(true); | |
| 1743 } | |
| 1744 if (action.command & MediaPlayerAction::NO_LOOP) { | |
| 1745 media_element->setLoop(false); | |
| 1746 } | |
| 1747 } | |
| 1748 } | |
| 1749 | |
| 1750 void WebViewImpl::setIsActive(bool active) { | 1750 void WebViewImpl::setIsActive(bool active) { |
| 1751 if (page() && page()->focusController()) | 1751 if (page() && page()->focusController()) |
| 1752 page()->focusController()->setActive(active); | 1752 page()->focusController()->setActive(active); |
| 1753 } | 1753 } |
| 1754 | 1754 |
| 1755 bool WebViewImpl::isActive() const { | 1755 bool WebViewImpl::isActive() const { |
| 1756 return (page() && page()->focusController()) | 1756 return (page() && page()->focusController()) |
| 1757 ? page()->focusController()->isActive() | 1757 ? page()->focusController()->isActive() |
| 1758 : false; | 1758 : false; |
| 1759 } | 1759 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 hitTestResultAtPoint(doc_point, false); | 1898 hitTestResultAtPoint(doc_point, false); |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 void WebViewImpl::setTabsToLinks(bool enable) { | 1901 void WebViewImpl::setTabsToLinks(bool enable) { |
| 1902 tabs_to_links_ = enable; | 1902 tabs_to_links_ = enable; |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 bool WebViewImpl::tabsToLinks() const { | 1905 bool WebViewImpl::tabsToLinks() const { |
| 1906 return tabs_to_links_; | 1906 return tabs_to_links_; |
| 1907 } | 1907 } |
| OLD | NEW |