/** * The view calls this function to indicate that the viewport changed size. It must hold the * monitor while calling it. * * <p>TODO: Refactor this to use an interface. Expose that interface only to the view and not to * the layer client. That way, the layer client won't be tempted to call this, which might result * in an infinite loop. */ void setViewportSize(int width, int height) { mViewportMetrics = mViewportMetrics.setViewportSize(width, height); if (mGeckoIsReady) { // 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 adjustViewport() { ViewportMetrics viewportMetrics = new ViewportMetrics(getLayerController().getViewportMetrics()); PointF viewportOffset = viewportMetrics.getOptimumViewportOffset(mBufferSize); viewportMetrics.setViewportOffset(viewportOffset); viewportMetrics.setViewport(viewportMetrics.getClampedViewport()); GeckoAppShell.sendEventToGecko(GeckoEvent.createViewportEvent(viewportMetrics)); if (mViewportSizeChanged) { mViewportSizeChanged = false; GeckoAppShell.viewSizeChanged(); } mLastViewportChangeTime = System.currentTimeMillis(); }