This source file includes following definitions.
- reset
- updateContentSizeCss
- setDeviceScaleFactor
- updateFrameInfo
- getXAbsoluteCss
- getYAbsoluteCss
- getXLocalDip
- getYLocalDip
- getXPix
- getYPix
- setAbsoluteCss
- setLocalDip
- setScreen
- createNormalizedPoint
- getScrollX
- getScrollY
- getScrollXPix
- getScrollYPix
- getScrollXPixInt
- getScrollYPixInt
- getContentWidthCss
- getContentHeightCss
- getContentWidthPix
- getContentHeightPix
- getContentWidthPixInt
- getContentHeightPixInt
- getLastFrameViewportWidthCss
- getLastFrameViewportHeightCss
- getLastFrameViewportWidthPix
- getLastFrameViewportHeightPix
- getLastFrameViewportWidthPixInt
- getLastFrameViewportHeightPixInt
- getContentOffsetYPix
- getPageScaleFactor
- getMinPageScaleFactor
- getMaxPageScaleFactor
- getDeviceScaleFactor
- hasFixedPageScale
- hasMobileViewport
- getMaxHorizontalScrollPix
- getMaxVerticalScrollPix
- getMaxHorizontalScrollPixInt
- getMaxVerticalScrollPixInt
- fromPixToDip
- fromDipToPix
- fromPixToLocalCss
- fromLocalCssToPix
package org.chromium.content.browser;
public class RenderCoordinates {
private float mScrollXCss;
private float mScrollYCss;
private float mContentWidthCss;
private float mContentHeightCss;
private float mLastFrameViewportWidthCss;
private float mLastFrameViewportHeightCss;
private float mPageScaleFactor = 1.0f;
private float mMinPageScaleFactor = 1.0f;
private float mMaxPageScaleFactor = 1.0f;
private float mDeviceScaleFactor;
private float mContentOffsetYPix;
void reset() {
mScrollXCss = mScrollYCss = 0;
mPageScaleFactor = 1.0f;
}
void updateContentSizeCss(float contentWidthCss, float contentHeightCss) {
mContentWidthCss = contentWidthCss;
mContentHeightCss = contentHeightCss;
}
void setDeviceScaleFactor(float deviceScaleFactor) {
mDeviceScaleFactor = deviceScaleFactor;
}
void updateFrameInfo(
float scrollXCss, float scrollYCss,
float contentWidthCss, float contentHeightCss,
float viewportWidthCss, float viewportHeightCss,
float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor,
float contentOffsetYPix) {
mScrollXCss = scrollXCss;
mScrollYCss = scrollYCss;
mPageScaleFactor = pageScaleFactor;
mMinPageScaleFactor = minPageScaleFactor;
mMaxPageScaleFactor = maxPageScaleFactor;
mContentOffsetYPix = contentOffsetYPix;
updateContentSizeCss(contentWidthCss, contentHeightCss);
mLastFrameViewportWidthCss = viewportWidthCss;
mLastFrameViewportHeightCss = viewportHeightCss;
}
public class NormalizedPoint {
private float mXAbsoluteCss, mYAbsoluteCss;
private NormalizedPoint() {
}
public float getXAbsoluteCss() { return mXAbsoluteCss; }
public float getYAbsoluteCss() { return mYAbsoluteCss; }
public float getXLocalDip() { return (mXAbsoluteCss - mScrollXCss) * mPageScaleFactor; }
public float getYLocalDip() { return (mYAbsoluteCss - mScrollYCss) * mPageScaleFactor; }
public float getXPix() { return getXLocalDip() * mDeviceScaleFactor; }
public float getYPix() { return getYLocalDip() * mDeviceScaleFactor + mContentOffsetYPix; }
public void setAbsoluteCss(float xCss, float yCss) {
mXAbsoluteCss = xCss;
mYAbsoluteCss = yCss;
}
public void setLocalDip(float xDip, float yDip) {
setAbsoluteCss(
xDip / mPageScaleFactor + mScrollXCss,
yDip / mPageScaleFactor + mScrollYCss);
}
public void setScreen(float xPix, float yPix) {
setLocalDip(xPix / mDeviceScaleFactor, yPix / mDeviceScaleFactor);
}
}
public NormalizedPoint createNormalizedPoint() {
return new NormalizedPoint();
}
public float getScrollX() { return mScrollXCss; }
public float getScrollY() { return mScrollYCss; }
public float getScrollXPix() { return fromLocalCssToPix(mScrollXCss); }
public float getScrollYPix() { return fromLocalCssToPix(mScrollYCss); }
public int getScrollXPixInt() { return (int) Math.floor(getScrollXPix()); }
public int getScrollYPixInt() { return (int) Math.floor(getScrollYPix()); }
public float getContentWidthCss() { return mContentWidthCss; }
public float getContentHeightCss() { return mContentHeightCss; }
public float getContentWidthPix() { return fromLocalCssToPix(mContentWidthCss); }
public float getContentHeightPix() { return fromLocalCssToPix(mContentHeightCss); }
public int getContentWidthPixInt() { return (int) Math.ceil(getContentWidthPix()); }
public int getContentHeightPixInt() { return (int) Math.ceil(getContentHeightPix()); }
public float getLastFrameViewportWidthCss() { return mLastFrameViewportWidthCss; }
public float getLastFrameViewportHeightCss() { return mLastFrameViewportHeightCss; }
public float getLastFrameViewportWidthPix() {
return fromLocalCssToPix(mLastFrameViewportWidthCss);
}
public float getLastFrameViewportHeightPix() {
return fromLocalCssToPix(mLastFrameViewportHeightCss);
}
public int getLastFrameViewportWidthPixInt() {
return (int) Math.ceil(getLastFrameViewportWidthPix());
}
public int getLastFrameViewportHeightPixInt() {
return (int) Math.ceil(getLastFrameViewportHeightPix());
}
public float getContentOffsetYPix() {
return mContentOffsetYPix;
}
public float getPageScaleFactor() { return mPageScaleFactor; }
public float getMinPageScaleFactor() { return mMinPageScaleFactor; }
public float getMaxPageScaleFactor() { return mMaxPageScaleFactor; }
public float getDeviceScaleFactor() { return mDeviceScaleFactor; }
public boolean hasFixedPageScale() { return mMinPageScaleFactor == mMaxPageScaleFactor; }
public boolean hasMobileViewport() {
float windowWidthDip = mPageScaleFactor * mLastFrameViewportWidthCss;
return mContentWidthCss <= windowWidthDip;
}
public float getMaxHorizontalScrollPix() {
return getContentWidthPix() - getLastFrameViewportWidthPix();
}
public float getMaxVerticalScrollPix() {
return getContentHeightPix() - getLastFrameViewportHeightPix();
}
public int getMaxHorizontalScrollPixInt() {
return (int) Math.floor(getMaxHorizontalScrollPix());
}
public int getMaxVerticalScrollPixInt() {
return (int) Math.floor(getMaxVerticalScrollPix());
}
public float fromPixToDip(float pix) {
return pix / mDeviceScaleFactor;
}
public float fromDipToPix(float dip) {
return dip * mDeviceScaleFactor;
}
public float fromPixToLocalCss(float pix) {
return pix / (mDeviceScaleFactor * mPageScaleFactor);
}
public float fromLocalCssToPix(float css) {
return css * mPageScaleFactor * mDeviceScaleFactor;
}
}