hit_test_completion_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
page_scale_factor_(1.0),
+ x_delta_(0.0),
+ y_delta_(0.0),
is_initialized_(false) {}
void EWebView::Initialize() {
}
bool EWebView::GetScrollPosition(int* x, int* y) const {
- DCHECK(x);
- DCHECK(y);
+ if (!rwhv()) {
+ LOG(ERROR) << "rwhv() returns nullptr";
+ return false;
+ }
if (scroll_detector_->IsScrollOffsetChanged()) {
- *x = previous_scroll_position_.x();
- *y = previous_scroll_position_.y();
+ if (x)
+ *x = previous_scroll_position_.x();
+ if (y)
+ *y = previous_scroll_position_.y();
} else {
- const gfx::Vector2d scroll_position =
+ const gfx::Vector2d scroll_position_dip =
scroll_detector_->GetLastScrollPosition();
- *x = scroll_position.x();
- *y = scroll_position.y();
+ const float device_scale_factor = display::Screen::GetScreen()
+ ->GetPrimaryDisplay()
+ .device_scale_factor();
+ if (x) {
+ *x = gfx::ToRoundedInt((scroll_position_dip.x() - x_delta_) *
+ device_scale_factor);
+ }
+ if (y) {
+ *y = gfx::ToRoundedInt((scroll_position_dip.y() - y_delta_) *
+ device_scale_factor);
+ }
}
return true;
}
-void EWebView::SetScroll(int x, int y) {
- RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
- if (!render_view_host)
+void EWebView::ChangeScroll(int& x, int& y) {
+ if (!rwhv()) {
+ LOG(ERROR) << "rwhv() returns nullptr";
return;
+ }
+
+ int max_x = 0;
+ int max_y = 0;
+ GetScrollSize(&max_x, &max_y);
+ previous_scroll_position_.set_x(std::min(std::max(x, 0), max_x));
+ previous_scroll_position_.set_y(std::min(std::max(y, 0), max_y));
- int maxX, maxY;
- GetScrollSize(&maxX, &maxY);
- previous_scroll_position_.set_x(std::min(std::max(x, 0), maxX));
- previous_scroll_position_.set_y(std::min(std::max(y, 0), maxY));
+ const float device_scale_factor = display::Screen::GetScreen()
+ ->GetPrimaryDisplay()
+ .device_scale_factor();
+ int x_input = x;
+ int y_input = y;
+
+ x = gfx::ToCeiledInt(x / device_scale_factor);
+ y = gfx::ToCeiledInt(y / device_scale_factor);
+
+ x_delta_ = x - (x_input / device_scale_factor);
+ y_delta_ = y - (y_input / device_scale_factor);
scroll_detector_->SetScrollOffsetChanged();
+}
+
+void EWebView::SetScroll(int x, int y) {
+ RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
+ if (!render_view_host)
+ return;
+ ChangeScroll(x, y);
render_view_host->Send(
new EwkViewMsg_SetScroll(render_view_host->GetRoutingID(), x, y));
}
void UpdateWebkitPreferencesEfl(content::RenderViewHost*);
+ void ChangeScroll(int& x, int& y);
+
scoped_refptr<WebViewEvasEventHandler> evas_event_handler_;
scoped_refptr<Ewk_Context> context_;
scoped_refptr<Ewk_Context> old_context_;
Hit_Test_Params hit_test_params_;
base::WaitableEvent hit_test_completion_;
double page_scale_factor_;
- double min_page_scale_factor_;
- double max_page_scale_factor_;
+ double x_delta_;
+ double y_delta_;
WebViewCallback<Ewk_View_Geolocation_Permission_Callback,
_Ewk_Geolocation_Permission_Request*>