| Index: android_webview/browser/browser_view_renderer.cc
|
| diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
|
| index 17e6cf3e091086e0f840c92a999fa2dac79e07ab..af6a4bc34a97d415e95ba3b900afe1edcbcb6877 100644
|
| --- a/android_webview/browser/browser_view_renderer.cc
|
| +++ b/android_webview/browser/browser_view_renderer.cc
|
| @@ -347,7 +347,7 @@ skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width,
|
| CompositeSW(rec_canvas);
|
| }
|
| compositor_->DidChangeRootLayerScrollOffset(
|
| - gfx::ScrollOffset(scroll_offset_dip_));
|
| + gfx::ScrollOffset(scroll_offset_css_));
|
| }
|
| return skia::AdoptRef(recorder.endRecording());
|
| }
|
| @@ -534,50 +534,46 @@ void BrowserViewRenderer::SetDipScale(float dip_scale) {
|
| gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const {
|
| DCHECK_GT(dip_scale_, 0.f);
|
| return gfx::ToCeiledVector2d(gfx::ScaleVector2d(
|
| - max_scroll_offset_dip_, dip_scale_ * page_scale_factor_));
|
| + max_scroll_offset_css_, dip_scale_ * page_scale_factor_));
|
| }
|
|
|
| void BrowserViewRenderer::ScrollTo(const gfx::Vector2d& scroll_offset) {
|
| gfx::Vector2d max_offset = max_scroll_offset();
|
| - gfx::Vector2dF scroll_offset_dip;
|
| + gfx::Vector2dF scroll_offset_css;
|
| // To preserve the invariant that scrolling to the maximum physical pixel
|
| // value also scrolls to the maximum dip pixel value we transform the physical
|
| // offset into the dip offset by using a proportion (instead of dividing by
|
| // dip_scale * page_scale_factor).
|
| if (max_offset.x()) {
|
| - scroll_offset_dip.set_x((scroll_offset.x() * max_scroll_offset_dip_.x()) /
|
| + scroll_offset_css.set_x((scroll_offset.x() * max_scroll_offset_css_.x()) /
|
| max_offset.x());
|
| }
|
| if (max_offset.y()) {
|
| - scroll_offset_dip.set_y((scroll_offset.y() * max_scroll_offset_dip_.y()) /
|
| + scroll_offset_css.set_y((scroll_offset.y() * max_scroll_offset_css_.y()) /
|
| max_offset.y());
|
| }
|
|
|
| - DCHECK_LE(0.f, scroll_offset_dip.x());
|
| - DCHECK_LE(0.f, scroll_offset_dip.y());
|
| - DCHECK(scroll_offset_dip.x() < max_scroll_offset_dip_.x() ||
|
| - scroll_offset_dip.x() - max_scroll_offset_dip_.x() < kEpsilon)
|
| - << scroll_offset_dip.x() << " " << max_scroll_offset_dip_.x();
|
| - DCHECK(scroll_offset_dip.y() < max_scroll_offset_dip_.y() ||
|
| - scroll_offset_dip.y() - max_scroll_offset_dip_.y() < kEpsilon)
|
| - << scroll_offset_dip.y() << " " << max_scroll_offset_dip_.y();
|
| + DCHECK_LE(0.f, scroll_offset_css.x());
|
| + DCHECK_LE(0.f, scroll_offset_css.y());
|
| + DCHECK(scroll_offset_css.x() < max_scroll_offset_css_.x() ||
|
| + scroll_offset_css.x() - max_scroll_offset_css_.x() < kEpsilon)
|
| + << scroll_offset_css.x() << " " << max_scroll_offset_css_.x();
|
| + DCHECK(scroll_offset_css.y() < max_scroll_offset_css_.y() ||
|
| + scroll_offset_css.y() - max_scroll_offset_css_.y() < kEpsilon)
|
| + << scroll_offset_css.y() << " " << max_scroll_offset_css_.y();
|
|
|
| - if (scroll_offset_dip_ == scroll_offset_dip)
|
| + if (scroll_offset_css_ == scroll_offset_css)
|
| return;
|
|
|
| - scroll_offset_dip_ = scroll_offset_dip;
|
| + scroll_offset_css_ = scroll_offset_css;
|
|
|
| - TRACE_EVENT_INSTANT2("android_webview",
|
| - "BrowserViewRenderer::ScrollTo",
|
| - TRACE_EVENT_SCOPE_THREAD,
|
| - "x",
|
| - scroll_offset_dip.x(),
|
| - "y",
|
| - scroll_offset_dip.y());
|
| + TRACE_EVENT_INSTANT2("android_webview", "BrowserViewRenderer::ScrollTo",
|
| + TRACE_EVENT_SCOPE_THREAD, "x", scroll_offset_css.x(),
|
| + "y", scroll_offset_css.y());
|
|
|
| if (compositor_) {
|
| compositor_->DidChangeRootLayerScrollOffset(
|
| - gfx::ScrollOffset(scroll_offset_dip_));
|
| + gfx::ScrollOffset(scroll_offset_css_));
|
| }
|
| }
|
|
|
| @@ -591,23 +587,23 @@ void BrowserViewRenderer::DidUpdateContent() {
|
| }
|
|
|
| void BrowserViewRenderer::SetTotalRootLayerScrollOffset(
|
| - const gfx::Vector2dF& scroll_offset_dip) {
|
| - if (scroll_offset_dip_ == scroll_offset_dip)
|
| + const gfx::Vector2dF& scroll_offset_css) {
|
| + if (scroll_offset_css_ == scroll_offset_css)
|
| return;
|
| - scroll_offset_dip_ = scroll_offset_dip;
|
| + scroll_offset_css_ = scroll_offset_css;
|
|
|
| gfx::Vector2d max_offset = max_scroll_offset();
|
| gfx::Vector2d scroll_offset;
|
| // For an explanation as to why this is done this way see the comment in
|
| // BrowserViewRenderer::ScrollTo.
|
| - if (max_scroll_offset_dip_.x()) {
|
| - scroll_offset.set_x((scroll_offset_dip.x() * max_offset.x()) /
|
| - max_scroll_offset_dip_.x());
|
| + if (max_scroll_offset_css_.x()) {
|
| + scroll_offset.set_x((scroll_offset_css.x() * max_offset.x()) /
|
| + max_scroll_offset_css_.x());
|
| }
|
|
|
| - if (max_scroll_offset_dip_.y()) {
|
| - scroll_offset.set_y((scroll_offset_dip.y() * max_offset.y()) /
|
| - max_scroll_offset_dip_.y());
|
| + if (max_scroll_offset_css_.y()) {
|
| + scroll_offset.set_y((scroll_offset_css.y() * max_offset.y()) /
|
| + max_scroll_offset_css_.y());
|
| }
|
|
|
| DCHECK_LE(0, scroll_offset.x());
|
| @@ -619,58 +615,56 @@ void BrowserViewRenderer::SetTotalRootLayerScrollOffset(
|
| }
|
|
|
| void BrowserViewRenderer::UpdateRootLayerState(
|
| - const gfx::Vector2dF& total_scroll_offset_dip,
|
| - const gfx::Vector2dF& max_scroll_offset_dip,
|
| - const gfx::SizeF& scrollable_size_dip,
|
| + const gfx::Vector2dF& total_scroll_offset_css,
|
| + const gfx::Vector2dF& max_scroll_offset_css,
|
| + const gfx::SizeF& scrollable_size_css,
|
| float page_scale_factor,
|
| float min_page_scale_factor,
|
| float max_page_scale_factor) {
|
| TRACE_EVENT_INSTANT1(
|
| - "android_webview",
|
| - "BrowserViewRenderer::UpdateRootLayerState",
|
| - TRACE_EVENT_SCOPE_THREAD,
|
| - "state",
|
| - RootLayerStateAsValue(total_scroll_offset_dip, scrollable_size_dip));
|
| -
|
| - DCHECK_GE(max_scroll_offset_dip.x(), 0.f);
|
| - DCHECK_GE(max_scroll_offset_dip.y(), 0.f);
|
| + "android_webview", "BrowserViewRenderer::UpdateRootLayerState",
|
| + TRACE_EVENT_SCOPE_THREAD, "state",
|
| + RootLayerStateAsValue(total_scroll_offset_css, scrollable_size_css));
|
| +
|
| + DCHECK_GE(max_scroll_offset_css.x(), 0.f);
|
| + DCHECK_GE(max_scroll_offset_css.y(), 0.f);
|
| DCHECK_GT(page_scale_factor, 0.f);
|
| // SetDipScale should have been called at least once before this is called.
|
| DCHECK_GT(dip_scale_, 0.f);
|
|
|
| - if (max_scroll_offset_dip_ != max_scroll_offset_dip ||
|
| - scrollable_size_dip_ != scrollable_size_dip ||
|
| + if (max_scroll_offset_css_ != max_scroll_offset_css ||
|
| + scrollable_size_css_ != scrollable_size_css ||
|
| page_scale_factor_ != page_scale_factor ||
|
| min_page_scale_factor_ != min_page_scale_factor ||
|
| max_page_scale_factor_ != max_page_scale_factor) {
|
| - max_scroll_offset_dip_ = max_scroll_offset_dip;
|
| - scrollable_size_dip_ = scrollable_size_dip;
|
| + max_scroll_offset_css_ = max_scroll_offset_css;
|
| + scrollable_size_css_ = scrollable_size_css;
|
| page_scale_factor_ = page_scale_factor;
|
| min_page_scale_factor_ = min_page_scale_factor;
|
| max_page_scale_factor_ = max_page_scale_factor;
|
|
|
| - client_->UpdateScrollState(max_scroll_offset(), scrollable_size_dip,
|
| + client_->UpdateScrollState(max_scroll_offset(), scrollable_size_css,
|
| page_scale_factor, min_page_scale_factor,
|
| max_page_scale_factor);
|
| }
|
| - SetTotalRootLayerScrollOffset(total_scroll_offset_dip);
|
| + SetTotalRootLayerScrollOffset(total_scroll_offset_css);
|
| }
|
|
|
| scoped_refptr<base::trace_event::ConvertableToTraceFormat>
|
| BrowserViewRenderer::RootLayerStateAsValue(
|
| - const gfx::Vector2dF& total_scroll_offset_dip,
|
| - const gfx::SizeF& scrollable_size_dip) {
|
| + const gfx::Vector2dF& total_scroll_offset_css,
|
| + const gfx::SizeF& scrollable_size_css) {
|
| scoped_refptr<base::trace_event::TracedValue> state =
|
| new base::trace_event::TracedValue();
|
|
|
| - state->SetDouble("total_scroll_offset_dip.x", total_scroll_offset_dip.x());
|
| - state->SetDouble("total_scroll_offset_dip.y", total_scroll_offset_dip.y());
|
| + state->SetDouble("total_scroll_offset_css.x", total_scroll_offset_css.x());
|
| + state->SetDouble("total_scroll_offset_css.y", total_scroll_offset_css.y());
|
|
|
| - state->SetDouble("max_scroll_offset_dip.x", max_scroll_offset_dip_.x());
|
| - state->SetDouble("max_scroll_offset_dip.y", max_scroll_offset_dip_.y());
|
| + state->SetDouble("max_scroll_offset_css.x", max_scroll_offset_css_.x());
|
| + state->SetDouble("max_scroll_offset_css.y", max_scroll_offset_css_.y());
|
|
|
| - state->SetDouble("scrollable_size_dip.width", scrollable_size_dip.width());
|
| - state->SetDouble("scrollable_size_dip.height", scrollable_size_dip.height());
|
| + state->SetDouble("scrollable_size_css.width", scrollable_size_css.width());
|
| + state->SetDouble("scrollable_size_css.height", scrollable_size_css.height());
|
|
|
| state->SetDouble("page_scale_factor", page_scale_factor_);
|
| return state;
|
| @@ -797,8 +791,8 @@ std::string BrowserViewRenderer::ToString() const {
|
| base::StringAppendF(&str,
|
| "global visible rect: %s ",
|
| last_on_draw_global_visible_rect_.ToString().c_str());
|
| - base::StringAppendF(
|
| - &str, "scroll_offset_dip: %s ", scroll_offset_dip_.ToString().c_str());
|
| + base::StringAppendF(&str, "scroll_offset_css: %s ",
|
| + scroll_offset_css_.ToString().c_str());
|
| base::StringAppendF(&str,
|
| "overscroll_rounding_error_: %s ",
|
| overscroll_rounding_error_.ToString().c_str());
|
|
|