mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 732564 - Align the rotation/resize codepath with The Grand Viewport Plan of 2012. r=Cwiiis
This commit is contained in:
parent
077a35a20b
commit
71e6b2da28
@ -76,8 +76,6 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
||||
/* The viewport that Gecko is currently displaying. */
|
||||
private ViewportMetrics mGeckoViewport;
|
||||
|
||||
private boolean mViewportSizeChanged;
|
||||
|
||||
private String mLastCheckerboardColor;
|
||||
|
||||
/* Used by robocop for testing purposes */
|
||||
@ -210,7 +208,14 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
||||
}
|
||||
|
||||
void viewportSizeChanged() {
|
||||
mViewportSizeChanged = true;
|
||||
// here we send gecko a resize message. The code in browser.js is responsible for
|
||||
// picking up on that resize event, modifying the viewport as necessary, and informing
|
||||
// us of the new viewport.
|
||||
sendResizeEventIfNecessary(true);
|
||||
// the following call also sends gecko a message, which will be processed after the resize
|
||||
// message above has updated the viewport. this message ensures that if we have just put
|
||||
// focus in a text field, we scroll the content so that the text field is in view.
|
||||
GeckoAppShell.viewSizeChanged();
|
||||
}
|
||||
|
||||
private void updateDisplayPort() {
|
||||
@ -285,10 +290,6 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
||||
|
||||
updateDisplayPort();
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createViewportEvent(viewportMetrics, mDisplayPort));
|
||||
if (mViewportSizeChanged) {
|
||||
mViewportSizeChanged = false;
|
||||
GeckoAppShell.viewSizeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/** Implementation of GeckoEventResponder/GeckoEventListener. */
|
||||
|
@ -214,49 +214,13 @@ public class LayerController implements Tabs.OnTabsChangedListener {
|
||||
* result in an infinite loop.
|
||||
*/
|
||||
public void setViewportSize(FloatSize size) {
|
||||
// Resize the viewport, and modify its zoom factor so that the page retains proportionally
|
||||
// zoomed relative to the screen.
|
||||
ViewportMetrics viewportMetrics = new ViewportMetrics(mViewportMetrics);
|
||||
float oldHeight = viewportMetrics.getSize().height;
|
||||
float oldWidth = viewportMetrics.getSize().width;
|
||||
float oldZoomFactor = viewportMetrics.getZoomFactor();
|
||||
viewportMetrics.setSize(size);
|
||||
|
||||
// if the viewport got larger (presumably because the vkb went away), and the page
|
||||
// is smaller than the new viewport size, increase the page size so that the panzoomcontroller
|
||||
// doesn't zoom in to make it fit (bug 718270). this page size change is in anticipation of
|
||||
// gecko increasing the page size to match the new viewport size, which will happen the next
|
||||
// time we get a draw update.
|
||||
if (size.width >= oldWidth && size.height >= oldHeight) {
|
||||
FloatSize pageSize = viewportMetrics.getPageSize();
|
||||
if (pageSize.width < size.width || pageSize.height < size.height) {
|
||||
viewportMetrics.setPageSize(new FloatSize(Math.max(pageSize.width, size.width),
|
||||
Math.max(pageSize.height, size.height)));
|
||||
}
|
||||
}
|
||||
|
||||
// For rotations, we want the focus point to be at the top left.
|
||||
boolean rotation = (size.width > oldWidth && size.height < oldHeight) ||
|
||||
(size.width < oldWidth && size.height > oldHeight);
|
||||
PointF newFocus;
|
||||
if (rotation) {
|
||||
newFocus = new PointF(0, 0);
|
||||
} else {
|
||||
newFocus = new PointF(size.width / 2.0f, size.height / 2.0f);
|
||||
}
|
||||
float newZoomFactor = size.width * oldZoomFactor / oldWidth;
|
||||
viewportMetrics.scaleTo(newZoomFactor, newFocus);
|
||||
mViewportMetrics = new ImmutableViewportMetrics(viewportMetrics);
|
||||
|
||||
setForceRedraw();
|
||||
|
||||
if (mLayerClient != null) {
|
||||
mLayerClient.viewportSizeChanged();
|
||||
notifyLayerClientOfGeometryChange();
|
||||
}
|
||||
|
||||
mPanZoomController.abortAnimation();
|
||||
mView.requestRender();
|
||||
}
|
||||
|
||||
/** Scrolls the viewport by the given offset. You must hold the monitor while calling this. */
|
||||
|
Loading…
Reference in New Issue
Block a user