mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
5e324904fd
- Bug 1252212. Make the RIL WorkerRun implemetations not leave exceptions on the JSContext. r=khuey (a96b929707) - Bug 1267893 part 4 - Make setting the start time set 'did seek' to true; r=hiro (581d057f37) - Bug 1263063 - Part 6: Use TimingParams::EndTime() instead of re-calculation ComputedTiming each time. r=dholbert (1c70d3dd80) - Bug 1244637 - implement AnimationEffectTiming fill. r=hiro (83f10328cf) - Bug 1244642 - Implement AnimationEffectTiming.direction r=hiro (5fb010e6f4) - Bug 1267937 - Part 1: Clear mProgressOnLastCompose once we are not in effect. r=birtles (ccc5ee4594) - Bug 1267937 - Part 2: A reftest which checks mProgressOnLastCompose is surely cleared in before phase. r=birtles (850fb3a6b1) - Bug 1259733 - use forward declarations for nsIDocument in a few places; r=dholbert (1cc3af25b0) - Bug 1232906 - Use channel.asyncOpen2 within dom/apps/AppsUtils.jsm (r=sicking) (f8fe88724f) - Bug 1250464 - Remove workaround to get path from AppsUtils.jsm. r=myk (e1c76d7a13) - Bug 1263158 - Check if key is present in manifest object before using it. r=fabrice (44fe2c0468) - Bug 1230091 - ReferenceError on using not defined aApp variable in OfflineCacheInstaller.jsm, r=fabrice (8c6ab3d45c) - Bug 1228974 - correct the group ID in Offline Cache Installer, r=fabrice (f30de7eb6c) - var-let (364b37d086) - Bug 1267718 - Add a nsPIDOMWindow::GetScriptableParentOrNull method. r=bz (2cf8533883) - Bug 1268953. The load events we fire on iframe/frame/object (in the document case) should not be cancelable. r=smaug (ec36a6e8c8) - Bug 1266194 - Implement boolean or EventListenerOptions as 3rd param to addEventListener, r=smaug (069c30d74f) - Bug 944616 - "Blob URLs don't allow query or fragment parts". r=bz (85923ee174) - minor (bd5daf4059) - Bug 1167395 - Mark CharacterDataChangeInfo::Details as MOZ_STACK_CLASS, and mark mNextSibling as MOZ_NON_OWNING_REF. r=smaug (83eb176677) - Bug 1192855 - Check validity in advance for nsRange::InsertNode; r=hsivonen (485bd59ff4) - Bug 1214495 - Bonus fix. r=bz (bf6a4b33ec) - Bug 1266889 - Plugin block list blocks SWF network requests, but does not prevent plugin instantiation. r=francois (be7237639a) - Bug 1183891 - Remove warning if invalid node type is passed to nsRange::SetStart. r=smaug (8ce58952af) - Bug 1183893 - Remove warning if invalid node type is passed to nsRange::SetEnd. r=smaug (8675f2e21f) - Bug 1163105 - Make nsReferencedElement work with referencing elements that are not in their document's DOM tree. r=roc (83bc0fc078) - Bug 1172144 - Improve the size check of nsTextFragment::Append, r=ehsan (e6d47af1b1) - Bug 1151366 - remove nsGkAtoms::mozdonotsend from treesanitizer. r=ehsan (9237c22bdb) - Bug 1158500 - make writing-mode a mapped CSS property. r=cam (8d50bfb287) - bit of 1131348 (f2b234976b) - Bug 1245533 - nsXHTMLContentSerializer::CheckElementEnd - small compilation issue, r=smaug (85d8a50ddb) - align tests (cfb773549f) - Bug 1248836 - HID Features Implementation, r=jocelyn (0cb4482faf) - Bug 1239979: Close sockets when deinitializing Bluetooth profile managers, r=btian (c8c449767b) - Bug 1238991: Don't connect Bluetooth OPP manager before service channel is known, r=btian (9ad0d9ff7e) - Bug 1239979: Get pointers to Bluetooth managers during each shutdown, r=shuang (71959acf40) - Bug 1229697 - Cancel bond when user inputs empty pincode for pairing, r=shuang (e70ee96e6b) - Bug 1252787 - Patch : Add HID profile when device is remote, r=shawnjohnjr (bbadf5f42b) - Bug 1236724: Check the maximum length of each array in IPC; f=jhector, r=btian (e961ee7756) - align tests (17b6369dfa) - Bug 1268688 - Start browser API for frames swapping to HTML. r=bz (4a17ea38c7) - Bug 1265427 - nsDOMCameraControl needs an mOwnedStream to be consistent towards its VideoStreamTrack r=me (e008b0e4c1) - Bug 1154665 - Part 1. Provide gps processing data to avoid setParameters fail. r=aosmond (0564b157d3) - Bug 1154665 - Part 2. Testcase against gps parameter. r=aosmond (c52efbcd07) - Bug 1239752 - Create ImageBitmap from ImageData should preserve alpha. r=roc (1ec8ccd266) - Bug 1266432: Use CopySurface in ImageBitmap::PrepareForDrawing even when using D2D 1.1. r=kaku (c27dcf42f2) - Bug 1265598: Deal with the possibility of a write map failing. r=kaku r=milan (1916e69db1) - Bug 1266390: Preserver mIsPremultipliedAlpha when creating an ImageBitmap from an existing ImageBitmap. r=kaku (385ad1f750) - Bug 1267100 - add makeCurrent() for WebGLContext::GetFramebufferAttachmentParameter(). r=jgilbert (d7f957610b) - Bug 1266262 - Remove nearly-unused GLContext::mGLFormats. - r=jrmuizel (039e2a851f) - Bug 1186688 - Remove cached state check for DrawBuffer maximums, since it's invalid with min-cap mode. - r=jrmuizel (dc92031951) - Bug 1193526 - Add generated files. r=jgilbert (c3f54b6cef) - Bug 1264214 - WebGL check the conflict name when LinkProgram. r=jgilbert (1f268acc58) - Bug 842818 - Inline CloneData() and clean up ImportKeyTask::SetKeyData() r=rbarnes (299a32176c) - Bug 1137987 - Remove nonstandard let block from dom/downloads/tests. r=aus (94e98d64ff) - Bug 1211454 - Avoid requesting a zero-terminated string in TextEncoder when zero-termination is not needed. r=emk. (2d52f98e86) - Bug 1259669 Rename WidgetCommandEvent::command to WidgetCommandEvent::mCommand r=masayuki (744c283978) - Bug 1264380 - Get Composed Document of Shadow DOM Element Properly. r=wchen (0b4404ef19) - Bug 1188539 - Remove the deprecated TouchList::identifiedTouch method; r=jst (926c24d74d) - Bug 918706 - Return NS_ERROR_DOM_SYNTAX_ERR if method is invalid, r=khuey (f209944a0c) - Bug 1265610 - test_postMessages.html and some dom/filesystem tests requires 'dom.input.dirpicker' to be true, r=smaug (7092cef989) - Bug 1265610 - Fixing a JS error in the tests, CLOSED TREE r=me (d203807a1e) - Bug 1137151: Marked destructors of refcounted FM-radio classes as protected, r=pzhang (5b2ad86c5e) - Bug 1206174 - Improve code readability of FMRadioService r=alwu (bfcf897714) - Bug 1254298 - Bypass Gamepad Service Shutdown Timer on e10s; r=ted r=cleu (c40fcae327) - Bug 1156957 - Make gamepad mochitests work on e10s; r=ted (f0a1be1440) - Bug 1248794 - Clean up observer on WindowsGamepadService shutdown; r=ted r=smaug sec-approval=abillings (06660cc3fc) - Bug 1237896 - [Gamepad] Button Event cannot be correctly triggered after reconnect. r=qdot (fa21602600) - Bug 1249833 - Typo in nsGeolocation.h. r=jdm (42dad72688) - Bug 1255198 - [Telemetry] Add geolocation Telemetry probes to record fulfilled requests according to document.isVisible. r=jdm, data-review=bsmedberg (5e4f5db476) - Bug 1218080 - Don't send the url to the parent process when opening new windows, because it is not actually used. r=smaug (fca00714f6) - Bug 1256061 - Hold a strong reference to a request when we call a method on it. r=jdm (7ed037ef37) - Bug 1263001 - Don't Notify() an unlinked nsGeolocationRequest. r=jdm (0693c4688f) - missing bit of Bug 1242668 - Hold more references. r=sotaro (ba173e46f1) - Bug 1267246 - Remove bogus assertion. r=nical (c8ccfb73c8) - Bug 1265638 - Reset some properties when the backend of SharedSurface is switching from Basic to layer-accelerated backend. r=jgilbert (a6cf6598b7) - Bug 1266484 - Fix crash in libsystem_kernel.dylib@0x16db6 when using Pinboard bookmarklet. r=gabor (1a96a797c6) - Bug 1253959 - per comment 10, #ifdef code that causes ReadMetadata() to fail on Windows XP debug. r=cpearce. (ab2e19f621) - Bug 1256038: Remove special NotifyDataArrived handling in the DirectShow reader. r=cpearce (441a26dd97) - Bug 1284198 - Don't USE_CLOCK_API on macOS. r=terrence (659cecb516) - Bug 956899 - Add comments to ConditionVariable and handle some edge cases gracefully; r=froydnj (be45b6b271) - Bug 1268822 - rename mozilla::gmp::Runnable/SyncRunnable in order not to confuse NS_LOG_ADDREF/NS_LOG_RELEASE. r=rjesup. (18aec0cd35)
345 lines
13 KiB
C++
345 lines
13 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "MobileViewportManager.h"
|
|
|
|
#include "gfxPrefs.h"
|
|
#include "LayersLogging.h"
|
|
#include "nsIDOMEvent.h"
|
|
#include "nsIFrame.h"
|
|
#include "nsLayoutUtils.h"
|
|
#include "nsPresShell.h"
|
|
#include "nsViewManager.h"
|
|
#include "nsViewportInfo.h"
|
|
#include "UnitTransforms.h"
|
|
#include "nsIDocument.h"
|
|
|
|
#define MVM_LOG(...)
|
|
// #define MVM_LOG(...) printf_stderr("MVM: " __VA_ARGS__)
|
|
|
|
NS_IMPL_ISUPPORTS(MobileViewportManager, nsIDOMEventListener, nsIObserver)
|
|
|
|
static const nsLiteralString DOM_META_ADDED = NS_LITERAL_STRING("DOMMetaAdded");
|
|
static const nsLiteralString DOM_META_CHANGED = NS_LITERAL_STRING("DOMMetaChanged");
|
|
static const nsLiteralString FULL_ZOOM_CHANGE = NS_LITERAL_STRING("FullZoomChange");
|
|
static const nsLiteralCString BEFORE_FIRST_PAINT = NS_LITERAL_CSTRING("before-first-paint");
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::layers;
|
|
|
|
MobileViewportManager::MobileViewportManager(nsIPresShell* aPresShell,
|
|
nsIDocument* aDocument)
|
|
: mDocument(aDocument)
|
|
, mPresShell(aPresShell)
|
|
, mIsFirstPaint(false)
|
|
, mPainted(false)
|
|
{
|
|
MOZ_ASSERT(mPresShell);
|
|
MOZ_ASSERT(mDocument);
|
|
|
|
MVM_LOG("%p: creating with presShell %p document %p\n", this, mPresShell, aDocument);
|
|
|
|
if (nsCOMPtr<nsPIDOMWindow> window = mDocument->GetWindow()) {
|
|
mEventTarget = window->GetChromeEventHandler();
|
|
}
|
|
if (mEventTarget) {
|
|
mEventTarget->AddEventListener(DOM_META_ADDED, this, false);
|
|
mEventTarget->AddEventListener(DOM_META_CHANGED, this, false);
|
|
mEventTarget->AddEventListener(FULL_ZOOM_CHANGE, this, false);
|
|
}
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
|
if (observerService) {
|
|
observerService->AddObserver(this, BEFORE_FIRST_PAINT.Data(), false);
|
|
}
|
|
}
|
|
|
|
MobileViewportManager::~MobileViewportManager()
|
|
{
|
|
}
|
|
|
|
void
|
|
MobileViewportManager::Destroy()
|
|
{
|
|
MVM_LOG("%p: destroying\n", this);
|
|
|
|
if (mEventTarget) {
|
|
mEventTarget->RemoveEventListener(DOM_META_ADDED, this, false);
|
|
mEventTarget->RemoveEventListener(DOM_META_CHANGED, this, false);
|
|
mEventTarget->RemoveEventListener(FULL_ZOOM_CHANGE, this, false);
|
|
mEventTarget = nullptr;
|
|
}
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
|
if (observerService) {
|
|
observerService->RemoveObserver(this, BEFORE_FIRST_PAINT.Data());
|
|
}
|
|
|
|
mDocument = nullptr;
|
|
mPresShell = nullptr;
|
|
}
|
|
|
|
void
|
|
MobileViewportManager::RequestReflow()
|
|
{
|
|
MVM_LOG("%p: got a reflow request\n", this);
|
|
RefreshViewportSize(false);
|
|
}
|
|
|
|
void
|
|
MobileViewportManager::ResolutionUpdated()
|
|
{
|
|
MVM_LOG("%p: resolution updated\n", this);
|
|
RefreshSPCSPS();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
MobileViewportManager::HandleEvent(nsIDOMEvent* event)
|
|
{
|
|
nsAutoString type;
|
|
event->GetType(type);
|
|
|
|
if (type.Equals(DOM_META_ADDED)) {
|
|
MVM_LOG("%p: got a dom-meta-added event\n", this);
|
|
RefreshViewportSize(mPainted);
|
|
} else if (type.Equals(DOM_META_CHANGED)) {
|
|
MVM_LOG("%p: got a dom-meta-changed event\n", this);
|
|
RefreshViewportSize(mPainted);
|
|
} else if (type.Equals(FULL_ZOOM_CHANGE)) {
|
|
MVM_LOG("%p: got a full-zoom-change event\n", this);
|
|
RefreshViewportSize(false);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
MobileViewportManager::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
|
|
{
|
|
if (SameCOMIdentity(aSubject, mDocument) && BEFORE_FIRST_PAINT.EqualsASCII(aTopic)) {
|
|
MVM_LOG("%p: got a before-first-paint event\n", this);
|
|
mIsFirstPaint = true;
|
|
mPainted = true;
|
|
RefreshViewportSize(false);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
CSSToScreenScale
|
|
MobileViewportManager::UpdateResolution(const nsViewportInfo& aViewportInfo,
|
|
const ScreenIntSize& aDisplaySize,
|
|
const CSSSize& aViewport,
|
|
const Maybe<float>& aDisplayWidthChangeRatio)
|
|
{
|
|
CSSToLayoutDeviceScale cssToDev =
|
|
mPresShell->GetPresContext()->CSSToDevPixelScale();
|
|
LayoutDeviceToLayerScale res(mPresShell->GetResolution());
|
|
|
|
if (mIsFirstPaint) {
|
|
CSSToScreenScale defaultZoom = aViewportInfo.GetDefaultZoom();
|
|
MVM_LOG("%p: default zoom from viewport is %f\n", this, defaultZoom.scale);
|
|
if (!aViewportInfo.IsDefaultZoomValid()) {
|
|
defaultZoom = MaxScaleRatio(ScreenSize(aDisplaySize), aViewport);
|
|
MVM_LOG("%p: Intrinsic computed zoom is %f\n", this, defaultZoom.scale);
|
|
if (defaultZoom < aViewportInfo.GetMinZoom()) {
|
|
defaultZoom = aViewportInfo.GetMinZoom();
|
|
MVM_LOG("%p: Clamped to %f\n", this, defaultZoom.scale);
|
|
}
|
|
if (defaultZoom > aViewportInfo.GetMaxZoom()) {
|
|
defaultZoom = aViewportInfo.GetMaxZoom();
|
|
MVM_LOG("%p: Clamped to %f\n", this, defaultZoom.scale);
|
|
}
|
|
}
|
|
MOZ_ASSERT(aViewportInfo.GetMinZoom() <= defaultZoom &&
|
|
defaultZoom <= aViewportInfo.GetMaxZoom());
|
|
|
|
CSSToParentLayerScale zoom = ViewTargetAs<ParentLayerPixel>(defaultZoom,
|
|
PixelCastJustification::ScreenIsParentLayerForRoot);
|
|
|
|
LayoutDeviceToLayerScale resolution = zoom / cssToDev * ParentLayerToLayerScale(1);
|
|
MVM_LOG("%p: setting resolution %f\n", this, resolution.scale);
|
|
mPresShell->SetResolutionAndScaleTo(resolution.scale);
|
|
|
|
return defaultZoom;
|
|
}
|
|
|
|
// If this is not a first paint, then in some cases we want to update the pre-
|
|
// existing resolution so as to maintain how much actual content is visible
|
|
// within the display width. Note that "actual content" may be different with
|
|
// respect to CSS pixels because of the CSS viewport size changing.
|
|
//
|
|
// aDisplayWidthChangeRatio is non-empty if:
|
|
// (a) The meta-viewport tag information changes, and so the CSS viewport
|
|
// might change as a result. If this happens after the content has been
|
|
// painted, we want to adjust the zoom to compensate. OR
|
|
// (b) The display size changed from a nonzero value to another nonzero value.
|
|
// This covers the case where e.g. the device was rotated, and again we
|
|
// want to adjust the zoom to compensate.
|
|
// Note in particular that aDisplayWidthChangeRatio will be None if all that
|
|
// happened was a change in the full-zoom. In this case, we still want to
|
|
// compute a new CSS viewport, but we don't want to update the resolution.
|
|
//
|
|
// Given the above, the algorithm below accounts for all types of changes I
|
|
// can conceive of:
|
|
// 1. screen size changes, CSS viewport does not (pages with no meta viewport
|
|
// or a fixed size viewport)
|
|
// 2. screen size changes, CSS viewport also does (pages with a device-width
|
|
// viewport)
|
|
// 3. screen size remains constant, but CSS viewport changes (meta viewport
|
|
// tag is added or removed)
|
|
// 4. neither screen size nor CSS viewport changes
|
|
if (aDisplayWidthChangeRatio) {
|
|
float cssViewportChangeRatio = (mMobileViewportSize.width == 0)
|
|
? 1.0f : aViewport.width / mMobileViewportSize.width;
|
|
LayoutDeviceToLayerScale newRes(res.scale * aDisplayWidthChangeRatio.value()
|
|
/ cssViewportChangeRatio);
|
|
MVM_LOG("%p: Old resolution was %f, changed by %f/%f to %f\n", this, res.scale,
|
|
aDisplayWidthChangeRatio.value(), cssViewportChangeRatio, newRes.scale);
|
|
mPresShell->SetResolutionAndScaleTo(newRes.scale);
|
|
res = newRes;
|
|
}
|
|
|
|
return ViewTargetAs<ScreenPixel>(cssToDev * res / ParentLayerToLayerScale(1),
|
|
PixelCastJustification::ScreenIsParentLayerForRoot);
|
|
}
|
|
|
|
void
|
|
MobileViewportManager::UpdateSPCSPS(const ScreenIntSize& aDisplaySize,
|
|
const CSSToScreenScale& aZoom)
|
|
{
|
|
ScreenSize compositionSize(aDisplaySize);
|
|
ScreenMargin scrollbars =
|
|
LayoutDeviceMargin::FromAppUnits(
|
|
nsLayoutUtils::ScrollbarAreaToExcludeFromCompositionBoundsFor(
|
|
mPresShell->GetRootScrollFrame()),
|
|
mPresShell->GetPresContext()->AppUnitsPerDevPixel())
|
|
// Scrollbars are not subject to resolution scaling, so LD pixels =
|
|
// Screen pixels for them.
|
|
* LayoutDeviceToScreenScale(1.0f);
|
|
|
|
compositionSize.width -= scrollbars.LeftRight();
|
|
compositionSize.height -= scrollbars.TopBottom();
|
|
CSSSize compSize = compositionSize / aZoom;
|
|
MVM_LOG("%p: Setting SPCSPS %s\n", this, Stringify(compSize).c_str());
|
|
nsLayoutUtils::SetScrollPositionClampingScrollPortSize(mPresShell, compSize);
|
|
}
|
|
|
|
void
|
|
MobileViewportManager::UpdateDisplayPortMargins()
|
|
{
|
|
if (nsIFrame* root = mPresShell->GetRootScrollFrame()) {
|
|
bool hasDisplayPort = nsLayoutUtils::HasDisplayPort(root->GetContent());
|
|
bool hasResolution = mPresShell->ScaleToResolution() &&
|
|
mPresShell->GetResolution() != 1.0f;
|
|
if (!hasDisplayPort && !hasResolution) {
|
|
// We only want to update the displayport if there is one already, or
|
|
// add one if there's a resolution on the document (see bug 1225508
|
|
// comment 1).
|
|
return;
|
|
}
|
|
nsIScrollableFrame* scrollable = do_QueryFrame(root);
|
|
nsLayoutUtils::CalculateAndSetDisplayPortMargins(scrollable,
|
|
nsLayoutUtils::RepaintMode::DoNotRepaint);
|
|
}
|
|
}
|
|
|
|
void
|
|
MobileViewportManager::RefreshSPCSPS()
|
|
{
|
|
// This function is a subset of RefreshViewportSize, and only updates the
|
|
// SPCSPS.
|
|
|
|
if (!gfxPrefs::APZAllowZooming()) {
|
|
return;
|
|
}
|
|
|
|
ScreenIntSize displaySize = ViewAs<ScreenPixel>(
|
|
mDisplaySize, PixelCastJustification::LayoutDeviceIsScreenForBounds);
|
|
|
|
CSSToLayoutDeviceScale cssToDev =
|
|
mPresShell->GetPresContext()->CSSToDevPixelScale();
|
|
LayoutDeviceToLayerScale res(mPresShell->GetResolution());
|
|
CSSToScreenScale zoom = ViewTargetAs<ScreenPixel>(cssToDev * res / ParentLayerToLayerScale(1),
|
|
PixelCastJustification::ScreenIsParentLayerForRoot);
|
|
|
|
UpdateSPCSPS(displaySize, zoom);
|
|
}
|
|
|
|
void
|
|
MobileViewportManager::RefreshViewportSize(bool aForceAdjustResolution)
|
|
{
|
|
// This function gets called by the various triggers that may result in a
|
|
// change of the CSS viewport. In some of these cases (e.g. the meta-viewport
|
|
// tag changes) we want to update the resolution and in others (e.g. the full
|
|
// zoom changing) we don't want to update the resolution. See the comment in
|
|
// UpdateResolution for some more detail on this. An important assumption we
|
|
// make here is that this RefreshViewportSize function will be called
|
|
// separately for each trigger that changes. For instance it should never get
|
|
// called such that both the full zoom and the meta-viewport tag have changed;
|
|
// instead it would get called twice - once after each trigger changes. This
|
|
// assumption is what allows the aForceAdjustResolution parameter to work as
|
|
// intended; if this assumption is violated then we will need to add extra
|
|
// complicated logic in UpdateResolution to ensure we only do the resolution
|
|
// update in the right scenarios.
|
|
|
|
Maybe<float> displayWidthChangeRatio;
|
|
LayoutDeviceIntSize newDisplaySize;
|
|
if (nsLayoutUtils::GetContentViewerSize(mPresShell->GetPresContext(), newDisplaySize)) {
|
|
// See the comment in UpdateResolution for why we're doing this.
|
|
if (mDisplaySize.width > 0) {
|
|
if (aForceAdjustResolution || mDisplaySize.width != newDisplaySize.width) {
|
|
displayWidthChangeRatio = Some((float)newDisplaySize.width / (float)mDisplaySize.width);
|
|
}
|
|
} else if (aForceAdjustResolution) {
|
|
displayWidthChangeRatio = Some(1.0f);
|
|
}
|
|
|
|
MVM_LOG("%p: Display width change ratio is %f\n", this, displayWidthChangeRatio.valueOr(0.0f));
|
|
mDisplaySize = newDisplaySize;
|
|
}
|
|
|
|
MVM_LOG("%p: Computing CSS viewport using %d,%d\n", this,
|
|
mDisplaySize.width, mDisplaySize.height);
|
|
if (mDisplaySize.width == 0 || mDisplaySize.height == 0) {
|
|
// We can't do anything useful here, we should just bail out
|
|
return;
|
|
}
|
|
|
|
ScreenIntSize displaySize = ViewAs<ScreenPixel>(
|
|
mDisplaySize, PixelCastJustification::LayoutDeviceIsScreenForBounds);
|
|
nsViewportInfo viewportInfo = mDocument->GetViewportInfo(displaySize);
|
|
|
|
CSSSize viewport = viewportInfo.GetSize();
|
|
MVM_LOG("%p: Computed CSS viewport %s\n", this, Stringify(viewport).c_str());
|
|
|
|
if (!mIsFirstPaint && mMobileViewportSize == viewport) {
|
|
// Nothing changed, so no need to do a reflow
|
|
return;
|
|
}
|
|
|
|
// If it's the first-paint or the viewport changed, we need to update
|
|
// various APZ properties (the zoom and some things that might depend on it)
|
|
MVM_LOG("%p: Updating properties because %d || %d\n", this,
|
|
mIsFirstPaint, mMobileViewportSize != viewport);
|
|
|
|
if (gfxPrefs::APZAllowZooming()) {
|
|
CSSToScreenScale zoom = UpdateResolution(viewportInfo, displaySize, viewport,
|
|
displayWidthChangeRatio);
|
|
MVM_LOG("%p: New zoom is %f\n", this, zoom.scale);
|
|
UpdateSPCSPS(displaySize, zoom);
|
|
}
|
|
if (gfxPlatform::AsyncPanZoomEnabled()) {
|
|
UpdateDisplayPortMargins();
|
|
}
|
|
|
|
// Update internal state.
|
|
mIsFirstPaint = false;
|
|
mMobileViewportSize = viewport;
|
|
|
|
// Kick off a reflow.
|
|
mPresShell->ResizeReflowIgnoreOverride(
|
|
nsPresContext::CSSPixelsToAppUnits(viewport.width),
|
|
nsPresContext::CSSPixelsToAppUnits(viewport.height));
|
|
}
|