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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 mMinPageScaleFactor = minPageScaleFactor; | 65 mMinPageScaleFactor = minPageScaleFactor; |
64 mMaxPageScaleFactor = maxPageScaleFactor; | 66 mMaxPageScaleFactor = maxPageScaleFactor; |
65 mContentOffsetYPix = contentOffsetYPix; | 67 mContentOffsetYPix = contentOffsetYPix; |
66 | 68 |
67 updateContentSizeCss(contentWidthCss, contentHeightCss); | 69 updateContentSizeCss(contentWidthCss, contentHeightCss); |
68 mLastFrameViewportWidthCss = viewportWidthCss; | 70 mLastFrameViewportWidthCss = viewportWidthCss; |
69 mLastFrameViewportHeightCss = viewportHeightCss; | 71 mLastFrameViewportHeightCss = viewportHeightCss; |
70 } | 72 } |
71 | 73 |
72 /** | 74 /** |
| 75 * Sets several fields for unit test. (used by {@link CursorAnchorInfoSource
Test}). |
| 76 * @param deviceScaleFactor Device scale factor (maps DIP pixels to physical
pixels). |
| 77 * @param pageScaleFactor Page scale factor (maps CSS pixels to DIP pixels). |
| 78 * @param scrollXCss Horizontal scroll offset in CSS pixels. |
| 79 * @param scrollYCss Vertical scroll offset in CSS pixels. |
| 80 * @param contentOffsetYPix Physical on-screen Y offset amount below the top
controls. |
| 81 */ |
| 82 @VisibleForTesting |
| 83 public void setFrameInfoForTest( |
| 84 float deviceScaleFactor, float pageScaleFactor, |
| 85 float scrollXCss, float scrollYCss, |
| 86 float contentOffsetYPix) { |
| 87 reset(); |
| 88 mDeviceScaleFactor = deviceScaleFactor; |
| 89 mPageScaleFactor = pageScaleFactor; |
| 90 mScrollXCss = scrollXCss; |
| 91 mScrollYCss = scrollYCss; |
| 92 mContentOffsetYPix = contentOffsetYPix; |
| 93 } |
| 94 |
| 95 /** |
73 * Handles conversion of a point from window-relative-local-dip or screen-pi
x | 96 * Handles conversion of a point from window-relative-local-dip or screen-pi
x |
74 * to document-absolute-CSS space and vice versa. | 97 * to document-absolute-CSS space and vice versa. |
75 */ | 98 */ |
76 public class NormalizedPoint { | 99 public class NormalizedPoint { |
77 private float mXAbsoluteCss, mYAbsoluteCss; | 100 private float mXAbsoluteCss, mYAbsoluteCss; |
78 | 101 |
79 private NormalizedPoint() { | 102 private NormalizedPoint() { |
80 } | 103 } |
81 | 104 |
82 /** | 105 /** |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 return pix / (mDeviceScaleFactor * mPageScaleFactor); | 386 return pix / (mDeviceScaleFactor * mPageScaleFactor); |
364 } | 387 } |
365 | 388 |
366 /** | 389 /** |
367 * @return Local CSS converted to physical coordinates. | 390 * @return Local CSS converted to physical coordinates. |
368 */ | 391 */ |
369 public float fromLocalCssToPix(float css) { | 392 public float fromLocalCssToPix(float css) { |
370 return css * mPageScaleFactor * mDeviceScaleFactor; | 393 return css * mPageScaleFactor * mDeviceScaleFactor; |
371 } | 394 } |
372 } | 395 } |
OLD | NEW |