| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 RenderWidgetHostImpl::~RenderWidgetHostImpl() { | 178 RenderWidgetHostImpl::~RenderWidgetHostImpl() { |
| 179 SetView(NULL); | 179 SetView(NULL); |
| 180 | 180 |
| 181 // Clear our current or cached backing store if either remains. | 181 // Clear our current or cached backing store if either remains. |
| 182 BackingStoreManager::RemoveBackingStore(this); | 182 BackingStoreManager::RemoveBackingStore(this); |
| 183 | 183 |
| 184 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); | 184 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); |
| 185 surface_id_ = 0; | 185 surface_id_ = 0; |
| 186 | 186 |
| 187 process_->Release(routing_id_); | 187 process_->Release(routing_id_); |
| 188 |
| 189 if (delegate_) |
| 190 delegate_->RenderWidgetDeleted(this); |
| 188 } | 191 } |
| 189 | 192 |
| 190 // static | 193 // static |
| 191 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) { | 194 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) { |
| 192 return rwh->AsRenderWidgetHostImpl(); | 195 return rwh->AsRenderWidgetHostImpl(); |
| 193 } | 196 } |
| 194 | 197 |
| 195 void RenderWidgetHostImpl::SetView(RenderWidgetHostView* view) { | 198 void RenderWidgetHostImpl::SetView(RenderWidgetHostView* view) { |
| 196 view_ = RenderWidgetHostViewPort::FromRWHV(view); | 199 view_ = RenderWidgetHostViewPort::FromRWHV(view); |
| 197 | 200 |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 // RawKeyDown event may generate multiple Char events, so we can't reset | 959 // RawKeyDown event may generate multiple Char events, so we can't reset |
| 957 // |suppress_next_char_events_| until we get a KeyUp or a RawKeyDown. | 960 // |suppress_next_char_events_| until we get a KeyUp or a RawKeyDown. |
| 958 if (key_event.type == WebKeyboardEvent::Char) | 961 if (key_event.type == WebKeyboardEvent::Char) |
| 959 return; | 962 return; |
| 960 // We get a KeyUp or a RawKeyDown event. | 963 // We get a KeyUp or a RawKeyDown event. |
| 961 suppress_next_char_events_ = false; | 964 suppress_next_char_events_ = false; |
| 962 } | 965 } |
| 963 | 966 |
| 964 bool is_keyboard_shortcut = false; | 967 bool is_keyboard_shortcut = false; |
| 965 // Only pre-handle the key event if it's not handled by the input method. | 968 // Only pre-handle the key event if it's not handled by the input method. |
| 966 // A delegate_ of NULL seems impossible but crash reports show that it | |
| 967 // can happen (see http://crbug.com/134465). This doesn't seem to happen | |
| 968 // with Chrome 22 and later, so checking the delegate_ here can be removed | |
| 969 // once Chrome 22 goes to stable.. | |
| 970 if (delegate_ && !key_event.skip_in_browser) { | 969 if (delegate_ && !key_event.skip_in_browser) { |
| 971 // We need to set |suppress_next_char_events_| to true if | 970 // We need to set |suppress_next_char_events_| to true if |
| 972 // PreHandleKeyboardEvent() returns true, but |this| may already be | 971 // PreHandleKeyboardEvent() returns true, but |this| may already be |
| 973 // destroyed at that time. So set |suppress_next_char_events_| true here, | 972 // destroyed at that time. So set |suppress_next_char_events_| true here, |
| 974 // then revert it afterwards when necessary. | 973 // then revert it afterwards when necessary. |
| 975 if (key_event.type == WebKeyboardEvent::RawKeyDown) | 974 if (key_event.type == WebKeyboardEvent::RawKeyDown) |
| 976 suppress_next_char_events_ = true; | 975 suppress_next_char_events_ = true; |
| 977 | 976 |
| 978 // Tab switching/closing accelerators aren't sent to the renderer to avoid | 977 // Tab switching/closing accelerators aren't sent to the renderer to avoid |
| 979 // a hung/malicious renderer from interfering. | 978 // a hung/malicious renderer from interfering. |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 key_queue_.pop_front(); | 1838 key_queue_.pop_front(); |
| 1840 | 1839 |
| 1841 #if defined(OS_MACOSX) | 1840 #if defined(OS_MACOSX) |
| 1842 if (!is_hidden_ && view_->PostProcessEventForPluginIme(front_item)) | 1841 if (!is_hidden_ && view_->PostProcessEventForPluginIme(front_item)) |
| 1843 return; | 1842 return; |
| 1844 #endif | 1843 #endif |
| 1845 | 1844 |
| 1846 // We only send unprocessed key event upwards if we are not hidden, | 1845 // We only send unprocessed key event upwards if we are not hidden, |
| 1847 // because the user has moved away from us and no longer expect any effect | 1846 // because the user has moved away from us and no longer expect any effect |
| 1848 // of this key event. | 1847 // of this key event. |
| 1849 if (!processed && !is_hidden_ && !front_item.skip_in_browser) { | 1848 if (delegate_ && !processed && !is_hidden_ && !front_item.skip_in_browser) { |
| 1850 delegate_->HandleKeyboardEvent(front_item); | 1849 delegate_->HandleKeyboardEvent(front_item); |
| 1851 | 1850 |
| 1852 // WARNING: This RenderWidgetHostImpl can be deallocated at this point | 1851 // WARNING: This RenderWidgetHostImpl can be deallocated at this point |
| 1853 // (i.e. in the case of Ctrl+W, where the call to | 1852 // (i.e. in the case of Ctrl+W, where the call to |
| 1854 // HandleKeyboardEvent destroys this RenderWidgetHostImpl). | 1853 // HandleKeyboardEvent destroys this RenderWidgetHostImpl). |
| 1855 } | 1854 } |
| 1856 } | 1855 } |
| 1857 } | 1856 } |
| 1858 | 1857 |
| 1859 void RenderWidgetHostImpl::ActivateDeferredPluginHandles() { | 1858 void RenderWidgetHostImpl::ActivateDeferredPluginHandles() { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 // Clear the new_auto_size_ since the empty value is used as a flag to | 2049 // Clear the new_auto_size_ since the empty value is used as a flag to |
| 2051 // indicate that no callback is in progress (i.e. without this line | 2050 // indicate that no callback is in progress (i.e. without this line |
| 2052 // DelayedAutoResized will not get called again). | 2051 // DelayedAutoResized will not get called again). |
| 2053 new_auto_size_.SetSize(0, 0); | 2052 new_auto_size_.SetSize(0, 0); |
| 2054 if (!should_auto_resize_) | 2053 if (!should_auto_resize_) |
| 2055 return; | 2054 return; |
| 2056 | 2055 |
| 2057 OnRenderAutoResized(new_size); | 2056 OnRenderAutoResized(new_size); |
| 2058 } | 2057 } |
| 2059 | 2058 |
| 2059 void RenderWidgetHostImpl::DetachDelegate() { |
| 2060 delegate_ = NULL; |
| 2061 } |
| 2062 |
| 2060 } // namespace content | 2063 } // namespace content |
| OLD | NEW |