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

Unified Diff: content/renderer/render_widget.cc

Issue 2394073002: RenderWidget::windowRect and viewRect should apply device emulation transform. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 167a3f64e66a66e4a1f7647e3b313da6c68f5a8e..d98b36750f20b4794ecf0aa6e07c9378b65a594e 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1336,21 +1336,53 @@ void RenderWidget::Close() {
}
}
+void RenderWidget::ApplyWindowEmulation(WebRect* window_rect) const {
+ DCHECK(window_rect);
+ float scale = popup_origin_scale_for_emulation_;
+ window_rect->x =
+ popup_view_origin_for_emulation_.x() +
+ (window_rect->x - popup_screen_origin_for_emulation_.x()) / scale;
+ window_rect->y =
+ popup_view_origin_for_emulation_.y() +
+ (window_rect->y - popup_screen_origin_for_emulation_.y()) / scale;
+}
+
+void RenderWidget::RemoveWindowEmulation(WebRect* window_rect) const {
+ DCHECK(window_rect);
+ float scale = popup_origin_scale_for_emulation_;
+ window_rect->x =
+ popup_screen_origin_for_emulation_.x() +
+ (window_rect->x - popup_view_origin_for_emulation_.x()) * scale;
+ window_rect->y =
+ popup_screen_origin_for_emulation_.y() +
+ (window_rect->y - popup_view_origin_for_emulation_.y()) * scale;
+}
+
WebRect RenderWidget::windowRect() {
+ WebRect rect;
if (pending_window_rect_count_) {
// NOTE(mbelshe): If there is a pending_window_rect_, then getting
// the RootWindowRect is probably going to return wrong results since the
// browser may not have processed the Move yet. There isn't really anything
// good to do in this case, and it shouldn't happen - since this size is
// only really needed for windowToScreen, which is only used for Popups.
- return pending_window_rect_;
+ rect = pending_window_rect_;
+ } else {
+ rect = window_screen_rect_;
}
- return window_screen_rect_;
+ if (popup_origin_scale_for_emulation_)
dgozman 2016/10/05 22:40:20 Let's maybe call the method unconditionally and ea
bokan 2016/10/05 22:49:42 Done but added |IfNeeded| to the method name to ma
+ ApplyWindowEmulation(&rect);
+
+ return rect;
}
WebRect RenderWidget::viewRect() {
- return view_screen_rect_;
+ WebRect rect = view_screen_rect_;
+ if (popup_origin_scale_for_emulation_)
+ ApplyWindowEmulation(&rect);
dgozman 2016/10/05 22:40:20 ScreenRectToEmulated? It's easier to understand co
bokan 2016/10/05 22:49:42 Done.
+
+ return rect;
}
void RenderWidget::setToolTipText(const blink::WebString& text,
@@ -1360,13 +1392,8 @@ void RenderWidget::setToolTipText(const blink::WebString& text,
void RenderWidget::setWindowRect(const WebRect& rect_in_screen) {
WebRect window_rect = rect_in_screen;
- if (popup_origin_scale_for_emulation_) {
- float scale = popup_origin_scale_for_emulation_;
- window_rect.x = popup_screen_origin_for_emulation_.x() +
- (window_rect.x - popup_view_origin_for_emulation_.x()) * scale;
- window_rect.y = popup_screen_origin_for_emulation_.y() +
- (window_rect.y - popup_view_origin_for_emulation_.y()) * scale;
- }
+ if (popup_origin_scale_for_emulation_)
+ RemoveWindowEmulation(&window_rect);
dgozman 2016/10/05 22:40:20 EmulatedRectToScreen
bokan 2016/10/05 22:49:42 Done.
if (!resizing_mode_selector_->is_synchronous_mode()) {
if (did_show_) {
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698