| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 // WebView ---------------------------------------------------------------- | 332 // WebView ---------------------------------------------------------------- |
| 333 | 333 |
| 334 /*static*/ | 334 /*static*/ |
| 335 WebView* WebView::Create(WebViewDelegate* delegate) { | 335 WebView* WebView::Create(WebViewDelegate* delegate) { |
| 336 WebViewImpl* instance = new WebViewImpl(delegate); | 336 WebViewImpl* instance = new WebViewImpl(delegate); |
| 337 instance->AddRef(); | 337 instance->AddRef(); |
| 338 return instance; | 338 return instance; |
| 339 } | 339 } |
| 340 | 340 |
| 341 void WebViewImpl::InitializeMainFrame(WebFrameClient* frame_client) { | 341 void WebViewImpl::initializeMainFrame(WebFrameClient* frame_client) { |
| 342 // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame | 342 // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame |
| 343 // and releases that reference once the corresponding Frame is destroyed. | 343 // and releases that reference once the corresponding Frame is destroyed. |
| 344 scoped_refptr<WebFrameImpl> main_frame = new WebFrameImpl(frame_client); | 344 scoped_refptr<WebFrameImpl> main_frame = new WebFrameImpl(frame_client); |
| 345 | 345 |
| 346 main_frame->InitMainFrame(this); | 346 main_frame->InitMainFrame(this); |
| 347 | 347 |
| 348 if (delegate_) { | 348 if (delegate_) { |
| 349 WebDevToolsAgentDelegate* tools_delegate = | 349 WebDevToolsAgentDelegate* tools_delegate = |
| 350 delegate_->GetWebDevToolsAgentDelegate(); | 350 delegate_->GetWebDevToolsAgentDelegate(); |
| 351 if (tools_delegate) | 351 if (tools_delegate) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 363 WebCore::Page::visitedStateChanged( | 363 WebCore::Page::visitedStateChanged( |
| 364 WebCore::PageGroup::pageGroup(kPageGroupName), link_hash); | 364 WebCore::PageGroup::pageGroup(kPageGroupName), link_hash); |
| 365 } | 365 } |
| 366 | 366 |
| 367 // static | 367 // static |
| 368 void WebView::ResetVisitedLinkState() { | 368 void WebView::ResetVisitedLinkState() { |
| 369 WebCore::Page::allVisitedStateChanged( | 369 WebCore::Page::allVisitedStateChanged( |
| 370 WebCore::PageGroup::pageGroup(kPageGroupName)); | 370 WebCore::PageGroup::pageGroup(kPageGroupName)); |
| 371 } | 371 } |
| 372 | 372 |
| 373 | |
| 374 WebViewImpl::WebViewImpl(WebViewDelegate* delegate) | 373 WebViewImpl::WebViewImpl(WebViewDelegate* delegate) |
| 375 : delegate_(delegate), | 374 : delegate_(delegate), |
| 376 ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)), | 375 ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)), |
| 377 ALLOW_THIS_IN_INITIALIZER_LIST(chrome_client_impl_(this)), | 376 ALLOW_THIS_IN_INITIALIZER_LIST(chrome_client_impl_(this)), |
| 378 ALLOW_THIS_IN_INITIALIZER_LIST(context_menu_client_impl_(this)), | 377 ALLOW_THIS_IN_INITIALIZER_LIST(context_menu_client_impl_(this)), |
| 379 ALLOW_THIS_IN_INITIALIZER_LIST(drag_client_impl_(this)), | 378 ALLOW_THIS_IN_INITIALIZER_LIST(drag_client_impl_(this)), |
| 380 ALLOW_THIS_IN_INITIALIZER_LIST(editor_client_impl_(this)), | 379 ALLOW_THIS_IN_INITIALIZER_LIST(editor_client_impl_(this)), |
| 381 ALLOW_THIS_IN_INITIALIZER_LIST(inspector_client_impl_(this)), | 380 ALLOW_THIS_IN_INITIALIZER_LIST(inspector_client_impl_(this)), |
| 382 observed_new_navigation_(false), | 381 observed_new_navigation_(false), |
| 383 #ifndef NDEBUG | 382 #ifndef NDEBUG |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 417 } |
| 419 | 418 |
| 420 WebViewImpl::~WebViewImpl() { | 419 WebViewImpl::~WebViewImpl() { |
| 421 DCHECK(page_ == NULL); | 420 DCHECK(page_ == NULL); |
| 422 } | 421 } |
| 423 | 422 |
| 424 RenderTheme* WebViewImpl::theme() const { | 423 RenderTheme* WebViewImpl::theme() const { |
| 425 return page_.get() ? page_->theme() : RenderTheme::defaultTheme().get(); | 424 return page_.get() ? page_->theme() : RenderTheme::defaultTheme().get(); |
| 426 } | 425 } |
| 427 | 426 |
| 428 void WebViewImpl::SetTabKeyCyclesThroughElements(bool value) { | 427 bool WebViewImpl::tabKeyCyclesThroughElements() const { |
| 428 ASSERT(page_.get()); |
| 429 return page_->tabKeyCyclesThroughElements(); |
| 430 } |
| 431 |
| 432 void WebViewImpl::setTabKeyCyclesThroughElements(bool value) { |
| 429 if (page_ != NULL) { | 433 if (page_ != NULL) { |
| 430 page_->setTabKeyCyclesThroughElements(value); | 434 page_->setTabKeyCyclesThroughElements(value); |
| 431 } | 435 } |
| 432 } | 436 } |
| 433 | 437 |
| 434 void WebViewImpl::MouseMove(const WebMouseEvent& event) { | 438 void WebViewImpl::MouseMove(const WebMouseEvent& event) { |
| 435 if (!main_frame() || !main_frame()->frameview()) | 439 if (!main_frame() || !main_frame()->frameview()) |
| 436 return; | 440 return; |
| 437 | 441 |
| 438 last_mouse_position_ = WebPoint(event.x, event.y); | 442 last_mouse_position_ = WebPoint(event.x, event.y); |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 return main_frame(); | 1299 return main_frame(); |
| 1296 } | 1300 } |
| 1297 | 1301 |
| 1298 WebFrame* WebViewImpl::findFrameByName( | 1302 WebFrame* WebViewImpl::findFrameByName( |
| 1299 const WebString& name, WebFrame* relative_to_frame) { | 1303 const WebString& name, WebFrame* relative_to_frame) { |
| 1300 String name_str = webkit_glue::WebStringToString(name); | 1304 String name_str = webkit_glue::WebStringToString(name); |
| 1301 if (!relative_to_frame) | 1305 if (!relative_to_frame) |
| 1302 relative_to_frame = mainFrame(); | 1306 relative_to_frame = mainFrame(); |
| 1303 Frame* frame = static_cast<WebFrameImpl*>(relative_to_frame)->frame(); | 1307 Frame* frame = static_cast<WebFrameImpl*>(relative_to_frame)->frame(); |
| 1304 frame = frame->tree()->find(name_str); | 1308 frame = frame->tree()->find(name_str); |
| 1305 return frame ? WebFrameImpl::FromFrame(frame) : NULL; | 1309 return WebFrameImpl::FromFrame(frame); |
| 1306 } | 1310 } |
| 1307 | 1311 |
| 1308 WebFrame* WebViewImpl::focusedFrame() { | 1312 WebFrame* WebViewImpl::focusedFrame() { |
| 1309 Frame* frame = GetFocusedWebCoreFrame(); | 1313 return WebFrameImpl::FromFrame(GetFocusedWebCoreFrame()); |
| 1310 return frame ? WebFrameImpl::FromFrame(frame) : NULL; | |
| 1311 } | 1314 } |
| 1312 | 1315 |
| 1313 void WebViewImpl::setFocusedFrame(WebFrame* frame) { | 1316 void WebViewImpl::setFocusedFrame(WebFrame* frame) { |
| 1314 if (!frame) { | 1317 if (!frame) { |
| 1315 // Clears the focused frame if any. | 1318 // Clears the focused frame if any. |
| 1316 Frame* frame = GetFocusedWebCoreFrame(); | 1319 Frame* frame = GetFocusedWebCoreFrame(); |
| 1317 if (frame) | 1320 if (frame) |
| 1318 frame->selection()->setFocused(false); | 1321 frame->selection()->setFocused(false); |
| 1319 return; | 1322 return; |
| 1320 } | 1323 } |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 page_->inspectorController()->inspect(result.innerNonSharedNode()); | 1603 page_->inspectorController()->inspect(result.innerNonSharedNode()); |
| 1601 } | 1604 } |
| 1602 } | 1605 } |
| 1603 | 1606 |
| 1604 // WebView -------------------------------------------------------------------- | 1607 // WebView -------------------------------------------------------------------- |
| 1605 | 1608 |
| 1606 WebViewDelegate* WebViewImpl::GetDelegate() { | 1609 WebViewDelegate* WebViewImpl::GetDelegate() { |
| 1607 return delegate_; | 1610 return delegate_; |
| 1608 } | 1611 } |
| 1609 | 1612 |
| 1610 WebFrame* WebViewImpl::GetPreviousFrameBefore(WebFrame* frame, bool wrap) { | |
| 1611 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); | |
| 1612 WebCore::Frame* previous = | |
| 1613 frame_impl->frame()->tree()->traversePreviousWithWrap(wrap); | |
| 1614 return previous ? WebFrameImpl::FromFrame(previous) : NULL; | |
| 1615 } | |
| 1616 | |
| 1617 WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) { | |
| 1618 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); | |
| 1619 WebCore::Frame* next = | |
| 1620 frame_impl->frame()->tree()->traverseNextWithWrap(wrap); | |
| 1621 return next ? WebFrameImpl::FromFrame(next) : NULL; | |
| 1622 } | |
| 1623 | |
| 1624 // TODO(darin): these navigation methods should be killed | |
| 1625 | |
| 1626 void WebViewImpl::StopLoading() { | |
| 1627 main_frame()->stopLoading(); | |
| 1628 } | |
| 1629 | |
| 1630 void WebViewImpl::SetBackForwardListSize(int size) { | |
| 1631 page_->backForwardList()->setCapacity(size); | |
| 1632 } | |
| 1633 | |
| 1634 const std::wstring& WebViewImpl::GetInspectorSettings() const { | 1613 const std::wstring& WebViewImpl::GetInspectorSettings() const { |
| 1635 return inspector_settings_; | 1614 return inspector_settings_; |
| 1636 } | 1615 } |
| 1637 | 1616 |
| 1638 void WebViewImpl::SetInspectorSettings(const std::wstring& settings) { | 1617 void WebViewImpl::SetInspectorSettings(const std::wstring& settings) { |
| 1639 inspector_settings_ = settings; | 1618 inspector_settings_ = settings; |
| 1640 } | 1619 } |
| 1641 | 1620 |
| 1642 void WebViewImpl::ShowJavaScriptConsole() { | 1621 bool WebViewImpl::setDropEffect(bool accept) { |
| 1643 page_->inspectorController()->showPanel(InspectorController::ConsolePanel); | |
| 1644 } | |
| 1645 | |
| 1646 bool WebViewImpl::SetDropEffect(bool accept) { | |
| 1647 if (drag_target_dispatch_) { | 1622 if (drag_target_dispatch_) { |
| 1648 drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE; | 1623 drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE; |
| 1649 return true; | 1624 return true; |
| 1650 } else { | 1625 } else { |
| 1651 return false; | 1626 return false; |
| 1652 } | 1627 } |
| 1653 } | 1628 } |
| 1654 | 1629 |
| 1655 void WebViewImpl::AutofillSuggestionsForNode( | 1630 void WebViewImpl::AutofillSuggestionsForNode( |
| 1656 int64 node_id, | 1631 int64 node_id, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 } | 1689 } |
| 1715 | 1690 |
| 1716 WebDevToolsAgent* WebViewImpl::GetWebDevToolsAgent() { | 1691 WebDevToolsAgent* WebViewImpl::GetWebDevToolsAgent() { |
| 1717 return GetWebDevToolsAgentImpl(); | 1692 return GetWebDevToolsAgentImpl(); |
| 1718 } | 1693 } |
| 1719 | 1694 |
| 1720 WebDevToolsAgentImpl* WebViewImpl::GetWebDevToolsAgentImpl() { | 1695 WebDevToolsAgentImpl* WebViewImpl::GetWebDevToolsAgentImpl() { |
| 1721 return devtools_agent_.get(); | 1696 return devtools_agent_.get(); |
| 1722 } | 1697 } |
| 1723 | 1698 |
| 1724 void WebViewImpl::SetIsTransparent(bool is_transparent) { | 1699 void WebViewImpl::setIsTransparent(bool is_transparent) { |
| 1725 // Set any existing frames to be transparent. | 1700 // Set any existing frames to be transparent. |
| 1726 WebCore::Frame* frame = page_->mainFrame(); | 1701 WebCore::Frame* frame = page_->mainFrame(); |
| 1727 while (frame) { | 1702 while (frame) { |
| 1728 frame->view()->setTransparent(is_transparent); | 1703 frame->view()->setTransparent(is_transparent); |
| 1729 frame = frame->tree()->traverseNext(); | 1704 frame = frame->tree()->traverseNext(); |
| 1730 } | 1705 } |
| 1731 | 1706 |
| 1732 // Future frames check this to know whether to be transparent. | 1707 // Future frames check this to know whether to be transparent. |
| 1733 is_transparent_ = is_transparent; | 1708 is_transparent_ = is_transparent; |
| 1734 } | 1709 } |
| 1735 | 1710 |
| 1736 bool WebViewImpl::GetIsTransparent() const { | 1711 bool WebViewImpl::isTransparent() const { |
| 1737 return is_transparent_; | 1712 return is_transparent_; |
| 1738 } | 1713 } |
| 1739 | 1714 |
| 1740 void WebViewImpl::MediaPlayerActionAt(int x, | 1715 void WebViewImpl::MediaPlayerActionAt(int x, |
| 1741 int y, | 1716 int y, |
| 1742 const MediaPlayerAction& action) { | 1717 const MediaPlayerAction& action) { |
| 1743 HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); | 1718 HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); |
| 1744 | 1719 |
| 1745 WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode(); | 1720 WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode(); |
| 1746 if (node->hasTagName(WebCore::HTMLNames::videoTag) || | 1721 if (node->hasTagName(WebCore::HTMLNames::videoTag) || |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1761 } | 1736 } |
| 1762 if (action.command & MediaPlayerAction::LOOP) { | 1737 if (action.command & MediaPlayerAction::LOOP) { |
| 1763 media_element->setLoop(true); | 1738 media_element->setLoop(true); |
| 1764 } | 1739 } |
| 1765 if (action.command & MediaPlayerAction::NO_LOOP) { | 1740 if (action.command & MediaPlayerAction::NO_LOOP) { |
| 1766 media_element->setLoop(false); | 1741 media_element->setLoop(false); |
| 1767 } | 1742 } |
| 1768 } | 1743 } |
| 1769 } | 1744 } |
| 1770 | 1745 |
| 1771 void WebViewImpl::SetActive(bool active) { | 1746 void WebViewImpl::setIsActive(bool active) { |
| 1772 if (page() && page()->focusController()) | 1747 if (page() && page()->focusController()) |
| 1773 page()->focusController()->setActive(active); | 1748 page()->focusController()->setActive(active); |
| 1774 } | 1749 } |
| 1775 | 1750 |
| 1776 bool WebViewImpl::IsActive() { | 1751 bool WebViewImpl::isActive() const { |
| 1777 return (page() && page()->focusController()) | 1752 return (page() && page()->focusController()) |
| 1778 ? page()->focusController()->isActive() | 1753 ? page()->focusController()->isActive() |
| 1779 : false; | 1754 : false; |
| 1780 } | 1755 } |
| 1781 | 1756 |
| 1782 void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { | 1757 void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { |
| 1783 if (is_new_navigation) | 1758 if (is_new_navigation) |
| 1784 *is_new_navigation = observed_new_navigation_; | 1759 *is_new_navigation = observed_new_navigation_; |
| 1785 | 1760 |
| 1786 #ifndef NDEBUG | 1761 #ifndef NDEBUG |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 } | 1865 } |
| 1891 | 1866 |
| 1892 void WebViewImpl::SetSpellingPanelVisibility(bool is_visible) { | 1867 void WebViewImpl::SetSpellingPanelVisibility(bool is_visible) { |
| 1893 spelling_panel_is_visible_ = is_visible; | 1868 spelling_panel_is_visible_ = is_visible; |
| 1894 } | 1869 } |
| 1895 | 1870 |
| 1896 bool WebViewImpl::GetSpellingPanelVisibility() { | 1871 bool WebViewImpl::GetSpellingPanelVisibility() { |
| 1897 return spelling_panel_is_visible_; | 1872 return spelling_panel_is_visible_; |
| 1898 } | 1873 } |
| 1899 | 1874 |
| 1900 void WebViewImpl::SetTabsToLinks(bool enable) { | 1875 void WebViewImpl::setTabsToLinks(bool enable) { |
| 1901 tabs_to_links_ = enable; | 1876 tabs_to_links_ = enable; |
| 1902 } | 1877 } |
| 1903 | 1878 |
| 1904 bool WebViewImpl::GetTabsToLinks() const { | 1879 bool WebViewImpl::tabsToLinks() const { |
| 1905 return tabs_to_links_; | 1880 return tabs_to_links_; |
| 1906 } | 1881 } |
| OLD | NEW |