Bug 1920357 - Ignore viewport meta tag when we're in RDM and we also force desktop viewport. r=devtools-reviewers,jdescottes
Currently DevTools doesn't do it, but it feels like the right API and is already there. This allows fixing this on the devtools side however you want :) Differential Revision: https://phabricator.services.mozilla.com/D223627
This commit is contained in:
@@ -2759,6 +2759,20 @@ void BrowsingContext::DidSet(FieldIndex<IDX_InRDMPane>, bool aOldValue) {
|
|||||||
PresContextAffectingFieldChanged();
|
PresContextAffectingFieldChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BrowsingContext::DidSet(FieldIndex<IDX_ForceDesktopViewport>,
|
||||||
|
bool aOldValue) {
|
||||||
|
MOZ_ASSERT(IsTop(), "Should only set in the top-level browsing context");
|
||||||
|
if (ForceDesktopViewport() == aOldValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PresContextAffectingFieldChanged();
|
||||||
|
if (nsIDocShell* shell = GetDocShell()) {
|
||||||
|
if (RefPtr ps = shell->GetPresShell()) {
|
||||||
|
ps->MaybeRecreateMobileViewportManager(/* aAfterInitialization= */ true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool BrowsingContext::CanSet(FieldIndex<IDX_PageAwakeRequestCount>,
|
bool BrowsingContext::CanSet(FieldIndex<IDX_PageAwakeRequestCount>,
|
||||||
uint32_t aNewValue, ContentParent* aSource) {
|
uint32_t aNewValue, ContentParent* aSource) {
|
||||||
return IsTop() && XRE_IsParentProcess() && !aSource;
|
return IsTop() && XRE_IsParentProcess() && !aSource;
|
||||||
|
|||||||
@@ -1111,6 +1111,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DidSet(FieldIndex<IDX_InRDMPane>, bool aOldValue);
|
void DidSet(FieldIndex<IDX_InRDMPane>, bool aOldValue);
|
||||||
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void DidSet(FieldIndex<IDX_ForceDesktopViewport>,
|
||||||
|
bool aOldValue);
|
||||||
|
|
||||||
void DidSet(FieldIndex<IDX_EmbedderColorSchemes>,
|
void DidSet(FieldIndex<IDX_EmbedderColorSchemes>,
|
||||||
EmbedderColorSchemes&& aOldValue);
|
EmbedderColorSchemes&& aOldValue);
|
||||||
|
|||||||
@@ -10767,11 +10767,36 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
|
|||||||
CSSToScreenScale defaultScale =
|
CSSToScreenScale defaultScale =
|
||||||
layoutDeviceScale * LayoutDeviceToScreenScale(1.0);
|
layoutDeviceScale * LayoutDeviceToScreenScale(1.0);
|
||||||
|
|
||||||
// Special behaviour for desktop mode, provided we are not on an about: page,
|
|
||||||
// or fullscreen.
|
|
||||||
const bool fullscreen = Fullscreen();
|
|
||||||
auto* bc = GetBrowsingContext();
|
auto* bc = GetBrowsingContext();
|
||||||
if (bc && bc->ForceDesktopViewport() && !IsAboutPage() && !fullscreen) {
|
const bool inRDM = bc && bc->InRDMPane();
|
||||||
|
const bool ignoreMetaTag = [&] {
|
||||||
|
if (!nsLayoutUtils::ShouldHandleMetaViewport(this)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (Fullscreen()) {
|
||||||
|
// We ignore viewport meta tag etc when in fullscreen, see bug 1696717.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (inRDM && bc->ForceDesktopViewport()) {
|
||||||
|
// We ignore meta viewport when devtools tells us to force desktop
|
||||||
|
// viewport on RDM.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (ignoreMetaTag) {
|
||||||
|
return nsViewportInfo(aDisplaySize, defaultScale,
|
||||||
|
nsLayoutUtils::AllowZoomingForDocument(this)
|
||||||
|
? nsViewportInfo::ZoomFlag::AllowZoom
|
||||||
|
: nsViewportInfo::ZoomFlag::DisallowZoom,
|
||||||
|
StaticPrefs::apz_allow_zooming_out()
|
||||||
|
? nsViewportInfo::ZoomBehaviour::Mobile
|
||||||
|
: nsViewportInfo::ZoomBehaviour::Desktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special behaviour for desktop mode, provided we are not on an about: page.
|
||||||
|
if (bc && bc->ForceDesktopViewport() && !IsAboutPage()) {
|
||||||
CSSCoord viewportWidth =
|
CSSCoord viewportWidth =
|
||||||
StaticPrefs::browser_viewport_desktopWidth() / fullZoom;
|
StaticPrefs::browser_viewport_desktopWidth() / fullZoom;
|
||||||
CSSToScreenScale scaleToFit(aDisplaySize.width / viewportWidth);
|
CSSToScreenScale scaleToFit(aDisplaySize.width / viewportWidth);
|
||||||
@@ -10784,17 +10809,6 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
|
|||||||
nsViewportInfo::AutoScaleFlag::AutoScale);
|
nsViewportInfo::AutoScaleFlag::AutoScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We ignore viewport meta tage etc when in fullscreen, see bug 1696717.
|
|
||||||
if (fullscreen || !nsLayoutUtils::ShouldHandleMetaViewport(this)) {
|
|
||||||
return nsViewportInfo(aDisplaySize, defaultScale,
|
|
||||||
nsLayoutUtils::AllowZoomingForDocument(this)
|
|
||||||
? nsViewportInfo::ZoomFlag::AllowZoom
|
|
||||||
: nsViewportInfo::ZoomFlag::DisallowZoom,
|
|
||||||
StaticPrefs::apz_allow_zooming_out()
|
|
||||||
? nsViewportInfo::ZoomBehaviour::Mobile
|
|
||||||
: nsViewportInfo::ZoomBehaviour::Desktop);
|
|
||||||
}
|
|
||||||
|
|
||||||
// In cases where the width of the CSS viewport is less than or equal to the
|
// In cases where the width of the CSS viewport is less than or equal to the
|
||||||
// width of the display (i.e. width <= device-width) then we disable
|
// width of the display (i.e. width <= device-width) then we disable
|
||||||
// double-tap-to-zoom behaviour. See bug 941995 for details.
|
// double-tap-to-zoom behaviour. See bug 941995 for details.
|
||||||
@@ -10929,15 +10943,13 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
|
|||||||
// default size has a complicated calculation, we fixup the maxWidth
|
// default size has a complicated calculation, we fixup the maxWidth
|
||||||
// value after setting it, above.
|
// value after setting it, above.
|
||||||
if (maxWidth == nsViewportInfo::kAuto && !mValidScaleFloat) {
|
if (maxWidth == nsViewportInfo::kAuto && !mValidScaleFloat) {
|
||||||
if (bc && bc->TouchEventsOverride() == TouchEventsOverride::Enabled &&
|
maxWidth = StaticPrefs::browser_viewport_desktopWidth();
|
||||||
bc->InRDMPane()) {
|
if (inRDM &&
|
||||||
|
bc->TouchEventsOverride() == TouchEventsOverride::Enabled) {
|
||||||
// If RDM and touch simulation are active, then use the simulated
|
// If RDM and touch simulation are active, then use the simulated
|
||||||
// screen width to accommodate for cases where the screen width is
|
// screen width to accommodate for cases where the screen width is
|
||||||
// larger than the desktop viewport default.
|
// larger than the desktop viewport default.
|
||||||
maxWidth = nsViewportInfo::Max(
|
maxWidth = nsViewportInfo::Max(displaySize.width, maxWidth);
|
||||||
displaySize.width, StaticPrefs::browser_viewport_desktopWidth());
|
|
||||||
} else {
|
|
||||||
maxWidth = StaticPrefs::browser_viewport_desktopWidth();
|
|
||||||
}
|
}
|
||||||
// Divide by fullZoom to stretch CSS pixel size of viewport in order
|
// Divide by fullZoom to stretch CSS pixel size of viewport in order
|
||||||
// to keep device pixel size unchanged after full zoom applied.
|
// to keep device pixel size unchanged after full zoom applied.
|
||||||
|
|||||||
Reference in New Issue
Block a user