OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
| 7 import org.chromium.base.VisibleForTesting; |
| 8 |
7 /** | 9 /** |
8 * Cached copy of all positions and scales (CSS-to-DIP-to-physical pixels) | 10 * Cached copy of all positions and scales (CSS-to-DIP-to-physical pixels) |
9 * reported from the renderer. | 11 * reported from the renderer. |
10 * Provides wrappers and a utility class to help with coordinate transforms on t
he client side. | 12 * Provides wrappers and a utility class to help with coordinate transforms on t
he client side. |
11 * Provides the internally-visible set of update methods (called from ContentVie
wCore). | 13 * Provides the internally-visible set of update methods (called from ContentVie
wCore). |
12 * | 14 * |
13 * Unless stated otherwise, all coordinates are in CSS (document) coordinate spa
ce. | 15 * Unless stated otherwise, all coordinates are in CSS (document) coordinate spa
ce. |
14 */ | 16 */ |
15 public class RenderCoordinates { | 17 public class RenderCoordinates { |
16 | 18 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 mContentOffsetYPix = contentOffsetYPix; | 70 mContentOffsetYPix = contentOffsetYPix; |
69 | 71 |
70 updateContentSizeCss(contentWidthCss, contentHeightCss); | 72 updateContentSizeCss(contentWidthCss, contentHeightCss); |
71 mLastFrameViewportWidthCss = viewportWidthCss; | 73 mLastFrameViewportWidthCss = viewportWidthCss; |
72 mLastFrameViewportHeightCss = viewportHeightCss; | 74 mLastFrameViewportHeightCss = viewportHeightCss; |
73 | 75 |
74 mHasFrameInfo = true; | 76 mHasFrameInfo = true; |
75 } | 77 } |
76 | 78 |
77 /** | 79 /** |
| 80 * Sets several fields for unit test. (used by {@link CursorAnchorInfoContro
llerTest}). |
| 81 * @param deviceScaleFactor Device scale factor (maps DIP pixels to physical
pixels). |
| 82 * @param contentOffsetYPix Physical on-screen Y offset amount below the top
controls. |
| 83 */ |
| 84 @VisibleForTesting |
| 85 public void setFrameInfoForTest(float deviceScaleFactor, float contentOffset
YPix) { |
| 86 reset(); |
| 87 mDeviceScaleFactor = deviceScaleFactor; |
| 88 mContentOffsetYPix = contentOffsetYPix; |
| 89 } |
| 90 |
| 91 /** |
78 * Handles conversion of a point from window-relative-local-dip or screen-pi
x | 92 * Handles conversion of a point from window-relative-local-dip or screen-pi
x |
79 * to document-absolute-CSS space and vice versa. | 93 * to document-absolute-CSS space and vice versa. |
80 */ | 94 */ |
81 public class NormalizedPoint { | 95 public class NormalizedPoint { |
82 private float mXAbsoluteCss, mYAbsoluteCss; | 96 private float mXAbsoluteCss, mYAbsoluteCss; |
83 | 97 |
84 private NormalizedPoint() { | 98 private NormalizedPoint() { |
85 } | 99 } |
86 | 100 |
87 /** | 101 /** |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 return pix / (mDeviceScaleFactor * mPageScaleFactor); | 389 return pix / (mDeviceScaleFactor * mPageScaleFactor); |
376 } | 390 } |
377 | 391 |
378 /** | 392 /** |
379 * @return Local CSS converted to physical coordinates. | 393 * @return Local CSS converted to physical coordinates. |
380 */ | 394 */ |
381 public float fromLocalCssToPix(float css) { | 395 public float fromLocalCssToPix(float css) { |
382 return css * mPageScaleFactor * mDeviceScaleFactor; | 396 return css * mPageScaleFactor * mDeviceScaleFactor; |
383 } | 397 } |
384 } | 398 } |
OLD | NEW |