| 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_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/android/sys_utils.h" | 9 #include "base/android/sys_utils.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 bool RenderWidgetHostViewAndroid::OnMessageReceived( | 212 bool RenderWidgetHostViewAndroid::OnMessageReceived( |
| 213 const IPC::Message& message) { | 213 const IPC::Message& message) { |
| 214 bool handled = true; | 214 bool handled = true; |
| 215 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) | 215 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) |
| 216 IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) | 216 IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) |
| 217 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, | 217 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, |
| 218 OnDidChangeBodyBackgroundColor) | 218 OnDidChangeBodyBackgroundColor) |
| 219 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnDidOverscroll) | |
| 220 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrame, | 219 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrame, |
| 221 OnSetNeedsBeginFrame) | 220 OnSetNeedsBeginFrame) |
| 222 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 221 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
| 223 OnTextInputStateChanged) | 222 OnTextInputStateChanged) |
| 224 IPC_MESSAGE_HANDLER(ViewHostMsg_SmartClipDataExtracted, | 223 IPC_MESSAGE_HANDLER(ViewHostMsg_SmartClipDataExtracted, |
| 225 OnSmartClipDataExtracted) | 224 OnSmartClipDataExtracted) |
| 226 IPC_MESSAGE_UNHANDLED(handled = false) | 225 IPC_MESSAGE_UNHANDLED(handled = false) |
| 227 IPC_END_MESSAGE_MAP() | 226 IPC_END_MESSAGE_MAP() |
| 228 return handled; | 227 return handled; |
| 229 } | 228 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor( | 510 void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor( |
| 512 SkColor color) { | 511 SkColor color) { |
| 513 if (cached_background_color_ == color) | 512 if (cached_background_color_ == color) |
| 514 return; | 513 return; |
| 515 | 514 |
| 516 cached_background_color_ = color; | 515 cached_background_color_ = color; |
| 517 if (content_view_core_) | 516 if (content_view_core_) |
| 518 content_view_core_->OnBackgroundColorChanged(color); | 517 content_view_core_->OnBackgroundColorChanged(color); |
| 519 } | 518 } |
| 520 | 519 |
| 521 void RenderWidgetHostViewAndroid::OnDidOverscroll( | |
| 522 const DidOverscrollParams& params) { | |
| 523 if (!content_view_core_ || !layer_ || !is_showing_) | |
| 524 return; | |
| 525 | |
| 526 const float device_scale_factor = content_view_core_->GetDpiScale(); | |
| 527 if (overscroll_effect_->OnOverscrolled( | |
| 528 content_view_core_->GetLayer(), | |
| 529 base::TimeTicks::Now(), | |
| 530 gfx::ScaleVector2d(params.accumulated_overscroll, | |
| 531 device_scale_factor), | |
| 532 gfx::ScaleVector2d(params.latest_overscroll_delta, | |
| 533 device_scale_factor), | |
| 534 gfx::ScaleVector2d(params.current_fling_velocity, | |
| 535 device_scale_factor))) { | |
| 536 SetNeedsAnimate(); | |
| 537 } | |
| 538 } | |
| 539 | |
| 540 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrame(bool enabled) { | 520 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrame(bool enabled) { |
| 541 if (enabled == needs_begin_frame_) | 521 if (enabled == needs_begin_frame_) |
| 542 return; | 522 return; |
| 543 | 523 |
| 544 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrame", | 524 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrame", |
| 545 "enabled", enabled); | 525 "enabled", enabled); |
| 546 if (content_view_core_ && enabled) | 526 if (content_view_core_ && enabled) |
| 547 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); | 527 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); |
| 548 | 528 |
| 549 needs_begin_frame_ = enabled; | 529 needs_begin_frame_ = enabled; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 | 1215 |
| 1236 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { | 1216 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { |
| 1237 if (host_) | 1217 if (host_) |
| 1238 host_->MoveCaret(point); | 1218 host_->MoveCaret(point); |
| 1239 } | 1219 } |
| 1240 | 1220 |
| 1241 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 1221 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
| 1242 return cached_background_color_; | 1222 return cached_background_color_; |
| 1243 } | 1223 } |
| 1244 | 1224 |
| 1225 void RenderWidgetHostViewAndroid::DidOverscroll( |
| 1226 const DidOverscrollParams& params) { |
| 1227 if (!content_view_core_ || !layer_ || !is_showing_) |
| 1228 return; |
| 1229 |
| 1230 const float device_scale_factor = content_view_core_->GetDpiScale(); |
| 1231 if (overscroll_effect_->OnOverscrolled( |
| 1232 content_view_core_->GetLayer(), |
| 1233 base::TimeTicks::Now(), |
| 1234 gfx::ScaleVector2d(params.accumulated_overscroll, |
| 1235 device_scale_factor), |
| 1236 gfx::ScaleVector2d(params.latest_overscroll_delta, |
| 1237 device_scale_factor), |
| 1238 gfx::ScaleVector2d(params.current_fling_velocity, |
| 1239 device_scale_factor))) { |
| 1240 SetNeedsAnimate(); |
| 1241 } |
| 1242 } |
| 1243 |
| 1245 void RenderWidgetHostViewAndroid::DidStopFlinging() { | 1244 void RenderWidgetHostViewAndroid::DidStopFlinging() { |
| 1246 if (content_view_core_) | 1245 if (content_view_core_) |
| 1247 content_view_core_->DidStopFlinging(); | 1246 content_view_core_->DidStopFlinging(); |
| 1248 } | 1247 } |
| 1249 | 1248 |
| 1250 void RenderWidgetHostViewAndroid::SetContentViewCore( | 1249 void RenderWidgetHostViewAndroid::SetContentViewCore( |
| 1251 ContentViewCoreImpl* content_view_core) { | 1250 ContentViewCoreImpl* content_view_core) { |
| 1252 RemoveLayers(); | 1251 RemoveLayers(); |
| 1253 if (observing_root_window_ && content_view_core_) { | 1252 if (observing_root_window_ && content_view_core_) { |
| 1254 content_view_core_->GetWindowAndroid()->RemoveObserver(this); | 1253 content_view_core_->GetWindowAndroid()->RemoveObserver(this); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 results->availableRect = display.work_area(); | 1451 results->availableRect = display.work_area(); |
| 1453 results->deviceScaleFactor = display.device_scale_factor(); | 1452 results->deviceScaleFactor = display.device_scale_factor(); |
| 1454 results->orientationAngle = display.RotationAsDegree(); | 1453 results->orientationAngle = display.RotationAsDegree(); |
| 1455 gfx::DeviceDisplayInfo info; | 1454 gfx::DeviceDisplayInfo info; |
| 1456 results->depth = info.GetBitsPerPixel(); | 1455 results->depth = info.GetBitsPerPixel(); |
| 1457 results->depthPerComponent = info.GetBitsPerComponent(); | 1456 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1458 results->isMonochrome = (results->depthPerComponent == 0); | 1457 results->isMonochrome = (results->depthPerComponent == 0); |
| 1459 } | 1458 } |
| 1460 | 1459 |
| 1461 } // namespace content | 1460 } // namespace content |
| OLD | NEW |