| 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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 page_->inspectorController()->inspect(result.innerNonSharedNode()); | 1604 page_->inspectorController()->inspect(result.innerNonSharedNode()); |
| 1601 } | 1605 } |
| 1602 } | 1606 } |
| 1603 | 1607 |
| 1604 // WebView -------------------------------------------------------------------- | 1608 // WebView -------------------------------------------------------------------- |
| 1605 | 1609 |
| 1606 WebViewDelegate* WebViewImpl::GetDelegate() { | 1610 WebViewDelegate* WebViewImpl::GetDelegate() { |
| 1607 return delegate_; | 1611 return delegate_; |
| 1608 } | 1612 } |
| 1609 | 1613 |
| 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 { | 1614 const std::wstring& WebViewImpl::GetInspectorSettings() const { |
| 1635 return inspector_settings_; | 1615 return inspector_settings_; |
| 1636 } | 1616 } |
| 1637 | 1617 |
| 1638 void WebViewImpl::SetInspectorSettings(const std::wstring& settings) { | 1618 void WebViewImpl::SetInspectorSettings(const std::wstring& settings) { |
| 1639 inspector_settings_ = settings; | 1619 inspector_settings_ = settings; |
| 1640 } | 1620 } |
| 1641 | 1621 |
| 1642 void WebViewImpl::ShowJavaScriptConsole() { | 1622 bool WebViewImpl::setDropEffect(bool accept) { |
| 1643 page_->inspectorController()->showPanel(InspectorController::ConsolePanel); | |
| 1644 } | |
| 1645 | |
| 1646 bool WebViewImpl::SetDropEffect(bool accept) { | |
| 1647 if (drag_target_dispatch_) { | 1623 if (drag_target_dispatch_) { |
| 1648 drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE; | 1624 drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE; |
| 1649 return true; | 1625 return true; |
| 1650 } else { | 1626 } else { |
| 1651 return false; | 1627 return false; |
| 1652 } | 1628 } |
| 1653 } | 1629 } |
| 1654 | 1630 |
| 1655 void WebViewImpl::AutofillSuggestionsForNode( | 1631 void WebViewImpl::AutofillSuggestionsForNode( |
| 1656 int64 node_id, | 1632 int64 node_id, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 } | 1690 } |
| 1715 | 1691 |
| 1716 WebDevToolsAgent* WebViewImpl::GetWebDevToolsAgent() { | 1692 WebDevToolsAgent* WebViewImpl::GetWebDevToolsAgent() { |
| 1717 return GetWebDevToolsAgentImpl(); | 1693 return GetWebDevToolsAgentImpl(); |
| 1718 } | 1694 } |
| 1719 | 1695 |
| 1720 WebDevToolsAgentImpl* WebViewImpl::GetWebDevToolsAgentImpl() { | 1696 WebDevToolsAgentImpl* WebViewImpl::GetWebDevToolsAgentImpl() { |
| 1721 return devtools_agent_.get(); | 1697 return devtools_agent_.get(); |
| 1722 } | 1698 } |
| 1723 | 1699 |
| 1724 void WebViewImpl::SetIsTransparent(bool is_transparent) { | 1700 void WebViewImpl::setIsTransparent(bool is_transparent) { |
| 1725 // Set any existing frames to be transparent. | 1701 // Set any existing frames to be transparent. |
| 1726 WebCore::Frame* frame = page_->mainFrame(); | 1702 WebCore::Frame* frame = page_->mainFrame(); |
| 1727 while (frame) { | 1703 while (frame) { |
| 1728 frame->view()->setTransparent(is_transparent); | 1704 frame->view()->setTransparent(is_transparent); |
| 1729 frame = frame->tree()->traverseNext(); | 1705 frame = frame->tree()->traverseNext(); |
| 1730 } | 1706 } |
| 1731 | 1707 |
| 1732 // Future frames check this to know whether to be transparent. | 1708 // Future frames check this to know whether to be transparent. |
| 1733 is_transparent_ = is_transparent; | 1709 is_transparent_ = is_transparent; |
| 1734 } | 1710 } |
| 1735 | 1711 |
| 1736 bool WebViewImpl::GetIsTransparent() const { | 1712 bool WebViewImpl::isTransparent() const { |
| 1737 return is_transparent_; | 1713 return is_transparent_; |
| 1738 } | 1714 } |
| 1739 | 1715 |
| 1740 void WebViewImpl::MediaPlayerActionAt(int x, | 1716 void WebViewImpl::MediaPlayerActionAt(int x, |
| 1741 int y, | 1717 int y, |
| 1742 const MediaPlayerAction& action) { | 1718 const MediaPlayerAction& action) { |
| 1743 HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); | 1719 HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); |
| 1744 | 1720 |
| 1745 WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode(); | 1721 WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode(); |
| 1746 if (node->hasTagName(WebCore::HTMLNames::videoTag) || | 1722 if (node->hasTagName(WebCore::HTMLNames::videoTag) || |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1761 } | 1737 } |
| 1762 if (action.command & MediaPlayerAction::LOOP) { | 1738 if (action.command & MediaPlayerAction::LOOP) { |
| 1763 media_element->setLoop(true); | 1739 media_element->setLoop(true); |
| 1764 } | 1740 } |
| 1765 if (action.command & MediaPlayerAction::NO_LOOP) { | 1741 if (action.command & MediaPlayerAction::NO_LOOP) { |
| 1766 media_element->setLoop(false); | 1742 media_element->setLoop(false); |
| 1767 } | 1743 } |
| 1768 } | 1744 } |
| 1769 } | 1745 } |
| 1770 | 1746 |
| 1771 void WebViewImpl::SetActive(bool active) { | 1747 void WebViewImpl::setIsActive(bool active) { |
| 1772 if (page() && page()->focusController()) | 1748 if (page() && page()->focusController()) |
| 1773 page()->focusController()->setActive(active); | 1749 page()->focusController()->setActive(active); |
| 1774 } | 1750 } |
| 1775 | 1751 |
| 1776 bool WebViewImpl::IsActive() { | 1752 bool WebViewImpl::isActive() const { |
| 1777 return (page() && page()->focusController()) | 1753 return (page() && page()->focusController()) |
| 1778 ? page()->focusController()->isActive() | 1754 ? page()->focusController()->isActive() |
| 1779 : false; | 1755 : false; |
| 1780 } | 1756 } |
| 1781 | 1757 |
| 1782 void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { | 1758 void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { |
| 1783 if (is_new_navigation) | 1759 if (is_new_navigation) |
| 1784 *is_new_navigation = observed_new_navigation_; | 1760 *is_new_navigation = observed_new_navigation_; |
| 1785 | 1761 |
| 1786 #ifndef NDEBUG | 1762 #ifndef NDEBUG |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 } | 1866 } |
| 1891 | 1867 |
| 1892 void WebViewImpl::SetSpellingPanelVisibility(bool is_visible) { | 1868 void WebViewImpl::SetSpellingPanelVisibility(bool is_visible) { |
| 1893 spelling_panel_is_visible_ = is_visible; | 1869 spelling_panel_is_visible_ = is_visible; |
| 1894 } | 1870 } |
| 1895 | 1871 |
| 1896 bool WebViewImpl::GetSpellingPanelVisibility() { | 1872 bool WebViewImpl::GetSpellingPanelVisibility() { |
| 1897 return spelling_panel_is_visible_; | 1873 return spelling_panel_is_visible_; |
| 1898 } | 1874 } |
| 1899 | 1875 |
| 1900 void WebViewImpl::SetTabsToLinks(bool enable) { | 1876 void WebViewImpl::setTabsToLinks(bool enable) { |
| 1901 tabs_to_links_ = enable; | 1877 tabs_to_links_ = enable; |
| 1902 } | 1878 } |
| 1903 | 1879 |
| 1904 bool WebViewImpl::GetTabsToLinks() const { | 1880 bool WebViewImpl::tabsToLinks() const { |
| 1905 return tabs_to_links_; | 1881 return tabs_to_links_; |
| 1906 } | 1882 } |
| OLD | NEW |