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

Side by Side Diff: third_party/WebKit/Source/core/frame/VisualViewport.cpp

Issue 1905693003: Update visual viewport API to take browser zoom into account. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/viewport/viewport-dimensions-under-browser-zoom.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 setLocation(m_offset + delta); 204 setLocation(m_offset + delta);
205 } 205 }
206 206
207 void VisualViewport::setScale(float scale) 207 void VisualViewport::setScale(float scale)
208 { 208 {
209 setScaleAndLocation(scale, m_offset); 209 setScaleAndLocation(scale, m_offset);
210 } 210 }
211 211
212 double VisualViewport::scrollLeft() 212 double VisualViewport::scrollLeft()
213 { 213 {
214 if (!mainFrame())
215 return 0;
216
214 updateLayoutIgnorePendingStylesheets(); 217 updateLayoutIgnorePendingStylesheets();
215 218
216 return visibleRect().x(); 219 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF actor());
bokan 2016/04/21 13:03:32 ComputedStyle.h is a strange place for this functi
ymalik 2016/04/24 02:25:30 I'll make those changes in a follow up CL if you d
217 } 220 }
218 221
219 double VisualViewport::scrollTop() 222 double VisualViewport::scrollTop()
220 { 223 {
224 if (!mainFrame())
225 return 0;
226
221 updateLayoutIgnorePendingStylesheets(); 227 updateLayoutIgnorePendingStylesheets();
222 228
223 return visibleRect().y(); 229 return adjustScrollForAbsoluteZoom(visibleRect().y(), mainFrame()->pageZoomF actor());
224 } 230 }
225 231
226 void VisualViewport::setScrollLeft(double x) 232 void VisualViewport::setScrollLeft(double x)
227 { 233 {
234 if (!mainFrame())
235 return;
236
228 updateLayoutIgnorePendingStylesheets(); 237 updateLayoutIgnorePendingStylesheets();
229 238
230 setLocation(FloatPoint(x, visibleRect().y())); 239 setLocation(FloatPoint(x * mainFrame()->pageZoomFactor(), visibleRect().y()) );
bokan 2016/04/21 13:03:32 use location().y() rather than visibleRect.
ymalik 2016/04/24 02:25:30 Done.
231 } 240 }
232 241
233 void VisualViewport::setScrollTop(double y) 242 void VisualViewport::setScrollTop(double y)
234 { 243 {
244 if (!mainFrame())
245 return;
246
235 updateLayoutIgnorePendingStylesheets(); 247 updateLayoutIgnorePendingStylesheets();
236 248
237 setLocation(FloatPoint(visibleRect().x(), y)); 249 setLocation(FloatPoint(visibleRect().x(), y * mainFrame()->pageZoomFactor()) );
238 } 250 }
239 251
240 double VisualViewport::clientWidth() 252 double VisualViewport::clientWidth()
241 { 253 {
254 if (!mainFrame())
255 return 0;
256
242 updateLayoutIgnorePendingStylesheets(); 257 updateLayoutIgnorePendingStylesheets();
243 258
244 return visibleRect().width(); 259 return adjustScrollForAbsoluteZoom(visibleRect().width(), mainFrame()->pageZ oomFactor());
bokan 2016/04/21 13:03:32 visibleSize().width() rather than visibleRect
ymalik 2016/04/24 02:25:30 Done.
245 } 260 }
246 261
247 double VisualViewport::clientHeight() 262 double VisualViewport::clientHeight()
248 { 263 {
264 if (!mainFrame())
265 return 0;
266
249 updateLayoutIgnorePendingStylesheets(); 267 updateLayoutIgnorePendingStylesheets();
250 268
251 return visibleRect().height(); 269 return adjustScrollForAbsoluteZoom(visibleRect().height(), mainFrame()->page ZoomFactor());
252 } 270 }
253 271
254 double VisualViewport::pageScale() 272 double VisualViewport::pageScale()
255 { 273 {
256 updateLayoutIgnorePendingStylesheets(); 274 updateLayoutIgnorePendingStylesheets();
257 275
258 return m_scale; 276 return m_scale;
259 } 277 }
260 278
261 void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location ) 279 void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location )
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } else if (graphicsLayer == m_rootTransformLayer) { 832 } else if (graphicsLayer == m_rootTransformLayer) {
815 name = "Root Transform Layer"; 833 name = "Root Transform Layer";
816 } else { 834 } else {
817 ASSERT_NOT_REACHED(); 835 ASSERT_NOT_REACHED();
818 } 836 }
819 837
820 return name; 838 return name;
821 } 839 }
822 840
823 } // namespace blink 841 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/viewport/viewport-dimensions-under-browser-zoom.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698