Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2682593002: Refactor ContentViewClient (4/6) (Closed)
Patch Set: shell vad Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 02d54e80dd4ee6e0859437b3074fea776cf05db5..9f1db2872bbd5f3fa006ee7f5a07050e31c82b76 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -400,6 +400,10 @@ void PrepareTextureCopyOutputResult(
display_compositor::GLHelper::SCALER_QUALITY_GOOD);
}
+bool FloatEquals(float a, float b) {
+ return std::abs(a - b) < FLT_EPSILON;
+}
+
} // namespace
void RenderWidgetHostViewAndroid::OnContextLost() {
@@ -435,6 +439,8 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
synchronous_compositor_client_(nullptr),
frame_evictor_(new DelegatedFrameEvictor(this)),
observing_root_window_(false),
+ prev_top_shown_pix_(0.f),
+ prev_bottom_shown_pix_(0.f),
weak_ptr_factory_(this) {
// Set the layer which will hold the content layer for this view. The content
// layer is managed by the DelegatedFrameHost.
@@ -790,8 +796,7 @@ void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) {
if (delegated_frame_host_)
delegated_frame_host_->UpdateBackgroundColor(color);
- if (content_view_core_)
- content_view_core_->OnBackgroundColorChanged(color);
+ view_.OnBackgroundColorChanged(color);
}
void RenderWidgetHostViewAndroid::SetNeedsBeginFrames(bool needs_begin_frames) {
@@ -805,8 +810,7 @@ void RenderWidgetHostViewAndroid::SetNeedsBeginFrames(bool needs_begin_frames) {
void RenderWidgetHostViewAndroid::OnStartContentIntent(
const GURL& content_url, bool is_main_frame) {
- if (content_view_core_)
- content_view_core_->StartContentIntent(content_url, is_main_frame);
+ view_.StartContentIntent(content_url, is_main_frame);
}
bool RenderWidgetHostViewAndroid::OnTouchEvent(
@@ -1274,6 +1278,28 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
frame_metadata.top_controls_height *
frame_metadata.top_controls_shown_ratio));
+ float dip_scale = ui::GetScaleFactorForNativeView(GetNativeView());
+ float top_controls_pix = frame_metadata.top_controls_height * dip_scale;
+ float top_shown_pix = top_controls_pix
+ * frame_metadata.top_controls_shown_ratio;
+ bool top_changed = !FloatEquals(top_shown_pix, prev_top_shown_pix_);
+
+ float bottom_controls_pix = frame_metadata.bottom_controls_height * dip_scale;
+ float bottom_shown_pix = bottom_controls_pix
+ * frame_metadata.bottom_controls_shown_ratio;
+ bool bottom_changed = !FloatEquals(bottom_shown_pix, prev_bottom_shown_pix_);
+
+ if (top_changed) {
+ float translate = top_shown_pix - top_controls_pix;
+ view_.OnTopControlsChanged(translate, top_shown_pix);
+ prev_top_shown_pix_ = top_shown_pix;
+ }
+ if (bottom_changed) {
+ float translate = bottom_controls_pix - bottom_shown_pix;
+ view_.OnBottomControlsChanged(translate, bottom_shown_pix);
+ prev_bottom_shown_pix_ = bottom_shown_pix;
+ }
+
// All offsets and sizes are in CSS pixels.
content_view_core_->UpdateFrameInfo(
frame_metadata.root_scroll_offset,
@@ -1284,8 +1310,6 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
frame_metadata.scrollable_viewport_size,
frame_metadata.top_controls_height,
frame_metadata.top_controls_shown_ratio,
- frame_metadata.bottom_controls_height,
- frame_metadata.bottom_controls_shown_ratio,
is_mobile_optimized,
frame_metadata.selection.start);
}

Powered by Google App Engine
This is Rietveld 408576698