| 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_view_base.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/browser/accessibility/browser_accessibility_manager.h" | 9 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" | 11 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 13 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 14 #include "content/browser/renderer_host/render_widget_host_impl.h" | 14 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" |
| 16 #include "content/browser/renderer_host/text_input_manager.h" |
| 16 #include "content/common/content_switches_internal.h" | 17 #include "content/common/content_switches_internal.h" |
| 17 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 18 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 18 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
| 19 #include "ui/display/screen.h" | 20 #include "ui/display/screen.h" |
| 20 #include "ui/gfx/geometry/point_conversions.h" | 21 #include "ui/gfx/geometry/point_conversions.h" |
| 21 #include "ui/gfx/geometry/size_conversions.h" | 22 #include "ui/gfx/geometry/size_conversions.h" |
| 22 #include "ui/gfx/geometry/size_f.h" | 23 #include "ui/gfx/geometry/size_f.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // How many microseconds apart input events should be flushed. | 29 // How many microseconds apart input events should be flushed. |
| 29 const int kFlushInputRateInUs = 16666; | 30 const int kFlushInputRateInUs = 16666; |
| 30 | 31 |
| 31 } | 32 } |
| 32 | 33 |
| 33 RenderWidgetHostViewBase::RenderWidgetHostViewBase() | 34 RenderWidgetHostViewBase::RenderWidgetHostViewBase() |
| 34 : popup_type_(blink::WebPopupTypeNone), | 35 : popup_type_(blink::WebPopupTypeNone), |
| 35 background_color_(SK_ColorWHITE), | 36 background_color_(SK_ColorWHITE), |
| 36 mouse_locked_(false), | 37 mouse_locked_(false), |
| 37 showing_context_menu_(false), | 38 showing_context_menu_(false), |
| 38 selection_text_offset_(0), | 39 selection_text_offset_(0), |
| 39 selection_range_(gfx::Range::InvalidRange()), | 40 selection_range_(gfx::Range::InvalidRange()), |
| 40 current_device_scale_factor_(0), | 41 current_device_scale_factor_(0), |
| 41 current_display_rotation_(display::Display::ROTATE_0), | 42 current_display_rotation_(display::Display::ROTATE_0), |
| 42 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), | 43 pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), |
| 44 text_input_manager_(nullptr), |
| 43 renderer_frame_number_(0), | 45 renderer_frame_number_(0), |
| 44 weak_factory_(this) {} | 46 weak_factory_(this) {} |
| 45 | 47 |
| 46 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { | 48 RenderWidgetHostViewBase::~RenderWidgetHostViewBase() { |
| 47 DCHECK(!mouse_locked_); | 49 DCHECK(!mouse_locked_); |
| 48 // We call this here to guarantee that observers are notified before we go | 50 // We call this here to guarantee that observers are notified before we go |
| 49 // away. However, some subclasses may wish to call this earlier in their | 51 // away. However, some subclasses may wish to call this earlier in their |
| 50 // shutdown process, e.g. to force removal from | 52 // shutdown process, e.g. to force removal from |
| 51 // RenderWidgetHostInputEventRouter's surface map before relinquishing a | 53 // RenderWidgetHostInputEventRouter's surface map before relinquishing a |
| 52 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling | 54 // host pointer, as in RenderWidgetHostViewGuest. There is no harm in calling |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 262 |
| 261 void RenderWidgetHostViewBase::FlushInput() { | 263 void RenderWidgetHostViewBase::FlushInput() { |
| 262 RenderWidgetHostImpl* impl = NULL; | 264 RenderWidgetHostImpl* impl = NULL; |
| 263 if (GetRenderWidgetHost()) | 265 if (GetRenderWidgetHost()) |
| 264 impl = RenderWidgetHostImpl::From(GetRenderWidgetHost()); | 266 impl = RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 265 if (!impl) | 267 if (!impl) |
| 266 return; | 268 return; |
| 267 impl->FlushInput(); | 269 impl->FlushInput(); |
| 268 } | 270 } |
| 269 | 271 |
| 272 void RenderWidgetHostViewBase::OnTextInputManagerDestroyed( |
| 273 TextInputManager* text_input_manager) { |
| 274 DCHECK(text_input_manager_ == text_input_manager); |
| 275 |
| 276 text_input_manager_->Unregister(this); |
| 277 text_input_manager_ = nullptr; |
| 278 } |
| 279 |
| 270 void RenderWidgetHostViewBase::OnTextSurroundingSelectionResponse( | 280 void RenderWidgetHostViewBase::OnTextSurroundingSelectionResponse( |
| 271 const base::string16& content, | 281 const base::string16& content, |
| 272 size_t start_offset, | 282 size_t start_offset, |
| 273 size_t end_offset) { | 283 size_t end_offset) { |
| 274 NOTIMPLEMENTED(); | 284 NOTIMPLEMENTED(); |
| 275 } | 285 } |
| 276 | 286 |
| 277 void RenderWidgetHostViewBase::ShowDisambiguationPopup( | 287 void RenderWidgetHostViewBase::ShowDisambiguationPopup( |
| 278 const gfx::Rect& rect_pixels, | 288 const gfx::Rect& rect_pixels, |
| 279 const SkBitmap& zoomed_bitmap) { | 289 const SkBitmap& zoomed_bitmap) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 gfx::ToRoundedPoint(point))); | 385 gfx::ToRoundedPoint(point))); |
| 376 } | 386 } |
| 377 | 387 |
| 378 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( | 388 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( |
| 379 const gfx::Point& point, | 389 const gfx::Point& point, |
| 380 cc::SurfaceId original_surface, | 390 cc::SurfaceId original_surface, |
| 381 gfx::Point* transformed_point) { | 391 gfx::Point* transformed_point) { |
| 382 *transformed_point = point; | 392 *transformed_point = point; |
| 383 } | 393 } |
| 384 | 394 |
| 395 void RenderWidgetHostViewBase::TextInputStateChanged( |
| 396 const TextInputState& text_input_state) { |
| 397 if (GetTextInputManager()) |
| 398 GetTextInputManager()->UpdateTextInputState(this, text_input_state); |
| 399 } |
| 400 |
| 401 TextInputManager* RenderWidgetHostViewBase::GetTextInputManager() { |
| 402 if (text_input_manager_) |
| 403 return text_input_manager_; |
| 404 |
| 405 RenderWidgetHostImpl* host = |
| 406 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 407 if (host && host->delegate()) |
| 408 text_input_manager_ = host->delegate()->GetTextInputManager(); |
| 409 |
| 410 if (text_input_manager_) |
| 411 text_input_manager_->Register(this); |
| 412 |
| 413 return text_input_manager_; |
| 414 } |
| 415 |
| 385 void RenderWidgetHostViewBase::AddObserver( | 416 void RenderWidgetHostViewBase::AddObserver( |
| 386 RenderWidgetHostViewBaseObserver* observer) { | 417 RenderWidgetHostViewBaseObserver* observer) { |
| 387 observers_.AddObserver(observer); | 418 observers_.AddObserver(observer); |
| 388 } | 419 } |
| 389 | 420 |
| 390 void RenderWidgetHostViewBase::RemoveObserver( | 421 void RenderWidgetHostViewBase::RemoveObserver( |
| 391 RenderWidgetHostViewBaseObserver* observer) { | 422 RenderWidgetHostViewBaseObserver* observer) { |
| 392 observers_.RemoveObserver(observer); | 423 observers_.RemoveObserver(observer); |
| 393 } | 424 } |
| 394 | 425 |
| 395 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { | 426 bool RenderWidgetHostViewBase::IsChildFrameForTesting() const { |
| 396 return false; | 427 return false; |
| 397 } | 428 } |
| 398 | 429 |
| 399 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { | 430 cc::SurfaceId RenderWidgetHostViewBase::SurfaceIdForTesting() const { |
| 400 return cc::SurfaceId(); | 431 return cc::SurfaceId(); |
| 401 } | 432 } |
| 402 | 433 |
| 403 } // namespace content | 434 } // namespace content |
| OLD | NEW |