OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut) | 644 IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut) |
645 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 645 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
646 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 646 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
647 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, | 647 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
648 OnDisassociateFromPopupCount) | 648 OnDisassociateFromPopupCount) |
649 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 649 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
650 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) | 650 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) |
651 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) | 651 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) |
652 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, | 652 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
653 OnEnablePreferredSizeChangedMode) | 653 OnEnablePreferredSizeChangedMode) |
654 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) | |
654 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, | 655 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
655 OnDisableScrollbarsForSmallWindows) | 656 OnDisableScrollbarsForSmallWindows) |
656 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) | 657 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
657 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) | 658 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
658 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) | 659 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
659 #if defined(OS_MACOSX) | 660 #if defined(OS_MACOSX) |
660 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) | 661 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
661 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) | 662 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
662 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, | 663 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
663 OnPluginImeCompositionCompleted) | 664 OnPluginImeCompositionCompleted) |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1736 void RenderViewImpl::focusPrevious() { | 1737 void RenderViewImpl::focusPrevious() { |
1737 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); | 1738 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
1738 } | 1739 } |
1739 | 1740 |
1740 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { | 1741 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
1741 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 1742 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
1742 | 1743 |
1743 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 1744 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
1744 } | 1745 } |
1745 | 1746 |
1747 void RenderViewImpl::autoSizeChanged(const WebSize& new_size) { | |
1748 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | |
darin (slow to review)
2011/11/28 16:53:55
nit: DidChangeContentsPreferredSize or ContentsPre
jennb
2011/11/28 18:02:24
Maybe move the verb right after Did, i.e. DidChang
levin
2011/11/28 18:44:56
I was re-using an existing message (which I think
| |
1749 new_size)); | |
1750 } | |
1751 | |
1752 void RenderViewImpl::didUpdateLayout() { | |
1753 // We don't always want to set up a timer, only if we've been put in that | |
1754 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | |
1755 // message. | |
1756 if (!send_preferred_size_changes_ || !webview()) | |
1757 return; | |
1758 | |
1759 if (check_preferred_size_timer_.IsRunning()) | |
1760 return; | |
1761 check_preferred_size_timer_.Start(FROM_HERE, | |
1762 TimeDelta::FromMilliseconds(0), this, | |
1763 &RenderViewImpl::CheckPreferredSize); | |
1764 } | |
1765 | |
1746 void RenderViewImpl::navigateBackForwardSoon(int offset) { | 1766 void RenderViewImpl::navigateBackForwardSoon(int offset) { |
1747 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); | 1767 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); |
1748 } | 1768 } |
1749 | 1769 |
1750 int RenderViewImpl::historyBackListCount() { | 1770 int RenderViewImpl::historyBackListCount() { |
1751 return history_list_offset_ < 0 ? 0 : history_list_offset_; | 1771 return history_list_offset_ < 0 ? 0 : history_list_offset_; |
1752 } | 1772 } |
1753 | 1773 |
1754 int RenderViewImpl::historyForwardListCount() { | 1774 int RenderViewImpl::historyForwardListCount() { |
1755 return history_list_length_ - historyBackListCount() - 1; | 1775 return history_list_length_ - historyBackListCount() - 1; |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2844 frame, context, world_id); | 2864 frame, context, world_id); |
2845 } | 2865 } |
2846 | 2866 |
2847 void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, | 2867 void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, |
2848 v8::Handle<v8::Context> context, | 2868 v8::Handle<v8::Context> context, |
2849 int world_id) { | 2869 int world_id) { |
2850 content::GetContentClient()->renderer()->WillReleaseScriptContext( | 2870 content::GetContentClient()->renderer()->WillReleaseScriptContext( |
2851 frame, context, world_id); | 2871 frame, context, world_id); |
2852 } | 2872 } |
2853 | 2873 |
2854 void RenderViewImpl::didUpdateLayout(WebFrame* frame) { | |
2855 // We don't always want to set up a timer, only if we've been put in that | |
2856 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | |
2857 // message. | |
2858 if (!send_preferred_size_changes_ || !webview()) | |
2859 return; | |
2860 | |
2861 if (check_preferred_size_timer_.IsRunning()) | |
2862 return; | |
2863 check_preferred_size_timer_.Start(FROM_HERE, | |
2864 TimeDelta::FromMilliseconds(0), this, | |
2865 &RenderViewImpl::CheckPreferredSize); | |
2866 } | |
2867 | |
2868 void RenderViewImpl::CheckPreferredSize() { | 2874 void RenderViewImpl::CheckPreferredSize() { |
2869 // We don't always want to send the change messages over IPC, only if we've | 2875 // We don't always want to send the change messages over IPC, only if we've |
2870 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2876 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
2871 // message. | 2877 // message. |
2872 if (!send_preferred_size_changes_ || !webview()) | 2878 if (!send_preferred_size_changes_ || !webview()) |
2873 return; | 2879 return; |
2874 | 2880 |
2875 gfx::Size size(webview()->mainFrame()->contentsPreferredWidth(), | 2881 gfx::Size size(webview()->mainFrame()->contentsPreferredWidth(), |
2876 webview()->mainFrame()->documentElementScrollHeight()); | 2882 webview()->mainFrame()->documentElementScrollHeight()); |
2877 | 2883 |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3813 file_chooser_completions_.front()->completion->didChooseFile(ws_file_names); | 3819 file_chooser_completions_.front()->completion->didChooseFile(ws_file_names); |
3814 file_chooser_completions_.pop_front(); | 3820 file_chooser_completions_.pop_front(); |
3815 | 3821 |
3816 // If there are more pending file chooser requests, schedule one now. | 3822 // If there are more pending file chooser requests, schedule one now. |
3817 if (!file_chooser_completions_.empty()) { | 3823 if (!file_chooser_completions_.empty()) { |
3818 Send(new ViewHostMsg_RunFileChooser(routing_id_, | 3824 Send(new ViewHostMsg_RunFileChooser(routing_id_, |
3819 file_chooser_completions_.front()->params)); | 3825 file_chooser_completions_.front()->params)); |
3820 } | 3826 } |
3821 } | 3827 } |
3822 | 3828 |
3829 void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, | |
3830 const gfx::Size& max_size) { | |
3831 DCHECK(!send_preferred_size_changes_); | |
3832 DCHECK(disable_scrollbars_size_limit_.IsEmpty()); | |
3833 if (!webview()) | |
3834 return; | |
3835 webview()->enableAutoSizeMode(true, min_size, max_size); | |
3836 } | |
3837 | |
3823 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { | 3838 void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
3824 if (send_preferred_size_changes_) | 3839 if (send_preferred_size_changes_) |
3825 return; | 3840 return; |
3826 send_preferred_size_changes_ = true; | 3841 send_preferred_size_changes_ = true; |
3827 | 3842 |
3828 // Start off with an initial preferred size notification (in case | 3843 // Start off with an initial preferred size notification (in case |
3829 // |didUpdateLayout| was already called). | 3844 // |didUpdateLayout| was already called). |
3830 if (webview()) | 3845 if (webview()) |
3831 didUpdateLayout(webview()->mainFrame()); | 3846 didUpdateLayout(); |
3832 } | 3847 } |
3833 | 3848 |
3834 void RenderViewImpl::OnDisableScrollbarsForSmallWindows( | 3849 void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
3835 const gfx::Size& disable_scrollbar_size_limit) { | 3850 const gfx::Size& disable_scrollbar_size_limit) { |
3836 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; | 3851 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
3837 } | 3852 } |
3838 | 3853 |
3839 void RenderViewImpl::OnSetRendererPrefs( | 3854 void RenderViewImpl::OnSetRendererPrefs( |
3840 const content::RendererPreferences& renderer_prefs) { | 3855 const content::RendererPreferences& renderer_prefs) { |
3841 renderer_preferences_ = renderer_prefs; | 3856 renderer_preferences_ = renderer_prefs; |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4730 return !!RenderThreadImpl::current()->compositor_thread(); | 4745 return !!RenderThreadImpl::current()->compositor_thread(); |
4731 } | 4746 } |
4732 | 4747 |
4733 void RenderViewImpl::OnJavaBridgeInit( | 4748 void RenderViewImpl::OnJavaBridgeInit( |
4734 const IPC::ChannelHandle& channel_handle) { | 4749 const IPC::ChannelHandle& channel_handle) { |
4735 DCHECK(!java_bridge_dispatcher_.get()); | 4750 DCHECK(!java_bridge_dispatcher_.get()); |
4736 #if defined(ENABLE_JAVA_BRIDGE) | 4751 #if defined(ENABLE_JAVA_BRIDGE) |
4737 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4752 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
4738 #endif | 4753 #endif |
4739 } | 4754 } |
OLD | NEW |