mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1106905 - Modify mobile desktop mode implementation to use a desktop viewport. r=kats
This commit is contained in:
parent
2e29ef1a61
commit
46662b3fb2
@ -2375,6 +2375,18 @@ nsDOMWindowUtils::IsInModalState(bool *retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::SetDesktopModeViewport(bool aDesktopMode)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
|
||||
NS_ENSURE_STATE(window);
|
||||
|
||||
static_cast<nsGlobalWindow*>(window.get())->SetDesktopModeViewport(aDesktopMode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetOuterWindowID(uint64_t *aWindowID)
|
||||
{
|
||||
|
@ -7895,6 +7895,15 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
|
||||
|
||||
CSSToScreenScale defaultScale = layoutDeviceScale
|
||||
* LayoutDeviceToScreenScale(1.0);
|
||||
// Get requested Desktopmode
|
||||
nsPIDOMWindow* win = GetWindow();
|
||||
if (win && win->IsDesktopModeViewport())
|
||||
{
|
||||
return nsViewportInfo(aDisplaySize,
|
||||
defaultScale,
|
||||
/*allowZoom*/false,
|
||||
/*allowDoubleTapZoom*/ true);
|
||||
}
|
||||
|
||||
if (!Preferences::GetBool("dom.meta-viewport.enabled", false)) {
|
||||
return nsViewportInfo(aDisplaySize,
|
||||
|
@ -580,7 +580,8 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
|
||||
mIsModalContentWindow(false),
|
||||
mIsActive(false), mIsBackground(false),
|
||||
mAudioMuted(false), mAudioVolume(1.0),
|
||||
mInnerWindow(nullptr), mOuterWindow(aOuterWindow),
|
||||
mDesktopModeViewport(false), mInnerWindow(nullptr),
|
||||
mOuterWindow(aOuterWindow),
|
||||
// Make sure no actual window ends up with mWindowID == 0
|
||||
mWindowID(NextWindowID()), mHasNotifiedGlobalCreated(false),
|
||||
mMarkedCCGeneration(0)
|
||||
|
@ -96,6 +96,17 @@ public:
|
||||
}
|
||||
|
||||
// Outer windows only.
|
||||
void SetDesktopModeViewport(bool aDesktopModeViewport)
|
||||
{
|
||||
MOZ_ASSERT(IsOuterWindow());
|
||||
mDesktopModeViewport = aDesktopModeViewport;
|
||||
}
|
||||
bool IsDesktopModeViewport() const
|
||||
{
|
||||
MOZ_ASSERT(IsOuterWindow());
|
||||
return mDesktopModeViewport;
|
||||
}
|
||||
|
||||
virtual void SetIsBackground(bool aIsBackground)
|
||||
{
|
||||
MOZ_ASSERT(IsOuterWindow());
|
||||
@ -783,6 +794,9 @@ protected:
|
||||
bool mAudioMuted;
|
||||
float mAudioVolume;
|
||||
|
||||
// current desktop mode flag.
|
||||
bool mDesktopModeViewport;
|
||||
|
||||
// And these are the references between inner and outer windows.
|
||||
nsPIDOMWindow* MOZ_NON_OWNING_REF mInnerWindow;
|
||||
nsCOMPtr<nsPIDOMWindow> mOuterWindow;
|
||||
|
@ -50,7 +50,7 @@ interface nsITranslationNodeList;
|
||||
interface nsIJSRAIIHelper;
|
||||
interface nsIContentPermissionRequest;
|
||||
|
||||
[scriptable, uuid(6eaf87a1-b252-4c4e-a2fc-318120680335)]
|
||||
[scriptable, uuid(aa7a399f-7178-4006-9e37-d3959afed2ee)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -1275,6 +1275,11 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
*/
|
||||
[noscript] boolean isInModalState();
|
||||
|
||||
/**
|
||||
* Request set internal desktopMode flag change.
|
||||
*/
|
||||
void setDesktopModeViewport(in boolean aDesktopModeViewport);
|
||||
|
||||
/**
|
||||
* Suspend/resume timeouts on this window and its descendant windows.
|
||||
*/
|
||||
|
@ -3570,6 +3570,11 @@ Tab.prototype = {
|
||||
* Reloads the tab with the desktop mode setting.
|
||||
*/
|
||||
reloadWithMode: function (aDesktopMode) {
|
||||
// notify desktopmode for PIDOMWindow
|
||||
let win = this.browser.contentWindow;
|
||||
let dwi = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
dwi.setDesktopModeViewport(aDesktopMode);
|
||||
|
||||
// Set desktop mode for tab and send change to Java
|
||||
if (this.desktopMode != aDesktopMode) {
|
||||
this.desktopMode = aDesktopMode;
|
||||
@ -6323,6 +6328,19 @@ var ViewportHandler = {
|
||||
* Returns the ViewportMetadata object.
|
||||
*/
|
||||
getViewportMetadata: function getViewportMetadata(aWindow) {
|
||||
let tab = BrowserApp.getTabForWindow(aWindow);
|
||||
if (tab.desktopMode) {
|
||||
return new ViewportMetadata({
|
||||
minZoom: kViewportMinScale,
|
||||
maxZoom: kViewportMaxScale,
|
||||
width: kDefaultCSSViewportWidth,
|
||||
height: kDefaultCSSViewportHeight,
|
||||
allowZoom: true,
|
||||
allowDoubleTapZoom: true,
|
||||
isSpecified: false
|
||||
});
|
||||
}
|
||||
|
||||
let windowUtils = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
// viewport details found here
|
||||
|
Loading…
Reference in New Issue
Block a user