mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-24 16:17:29 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
db9b04cc44
12 changed files with 250 additions and 3 deletions
144
dom/base/VisualViewport.cpp
Normal file
144
dom/base/VisualViewport.cpp
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* 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 "VisualViewport.h"
|
||||||
|
#include "nsIScrollableFrame.h"
|
||||||
|
#include "nsIDocShell.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
|
VisualViewport::VisualViewport(nsPIDOMWindowInner* aWindow)
|
||||||
|
: DOMEventTargetHelper(aWindow)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VisualViewport::VisualViewport(nsIGlobalObject* aGlobal)
|
||||||
|
: DOMEventTargetHelper(aGlobal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VisualViewport::~VisualViewport()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* virtual */
|
||||||
|
JSObject*
|
||||||
|
VisualViewport::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||||
|
{
|
||||||
|
return VisualViewportBinding::Wrap(aCx, this, aGivenProto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXXMC: We are effectively getting the size from the root scrollframe of the content
|
||||||
|
* and the scale from our DPP resolution.
|
||||||
|
* Since we are only on desktop, by definition have full view size (no "notch" or
|
||||||
|
* other mobile "don't touch" areas), we are hard-coding:
|
||||||
|
* - VisualViewportOffset = (0,0)
|
||||||
|
* - PageLeft/PageTop = 0.0
|
||||||
|
* - OffsetLeft/OffsetTop = 0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
CSSSize
|
||||||
|
VisualViewport::VisualViewportSize() const
|
||||||
|
{
|
||||||
|
CSSSize size = CSSSize(0,0);
|
||||||
|
|
||||||
|
nsIPresShell* presShell = GetPresShell();
|
||||||
|
if (presShell) {
|
||||||
|
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
|
||||||
|
if (sf) {
|
||||||
|
size = CSSRect::FromAppUnits(sf->GetScrollPortRect().Size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
VisualViewport::Width() const
|
||||||
|
{
|
||||||
|
CSSSize size = VisualViewportSize();
|
||||||
|
return size.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
VisualViewport::Height() const
|
||||||
|
{
|
||||||
|
CSSSize size = VisualViewportSize();
|
||||||
|
return size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
VisualViewport::Scale() const
|
||||||
|
{
|
||||||
|
double scale = 1;
|
||||||
|
nsIPresShell* presShell = GetPresShell();
|
||||||
|
if (presShell) {
|
||||||
|
scale = presShell->GetResolution();
|
||||||
|
}
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSSPoint
|
||||||
|
VisualViewport::VisualViewportOffset() const
|
||||||
|
{
|
||||||
|
CSSPoint offset = CSSPoint(0,0);
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSSPoint
|
||||||
|
VisualViewport::LayoutViewportOffset() const
|
||||||
|
{
|
||||||
|
CSSPoint offset = CSSPoint(0,0);
|
||||||
|
|
||||||
|
nsIPresShell* presShell = GetPresShell();
|
||||||
|
if (presShell) {
|
||||||
|
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
|
||||||
|
if (sf) {
|
||||||
|
offset = CSSPoint::FromAppUnits(sf->GetScrollPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
VisualViewport::PageLeft() const
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
VisualViewport::PageTop() const
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
VisualViewport::OffsetLeft() const
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
VisualViewport::OffsetTop() const
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIPresShell*
|
||||||
|
VisualViewport::GetPresShell() const
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
|
||||||
|
if (!window) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIDocShell* docShell = window->GetDocShell();
|
||||||
|
if (!docShell) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return docShell->GetPresShell();
|
||||||
|
}
|
||||||
49
dom/base/VisualViewport.h
Normal file
49
dom/base/VisualViewport.h
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef mozilla_dom_VisualViewport_h
|
||||||
|
#define mozilla_dom_VisualViewport_h
|
||||||
|
|
||||||
|
#include "mozilla/DOMEventTargetHelper.h"
|
||||||
|
#include "mozilla/dom/VisualViewportBinding.h"
|
||||||
|
#include "Units.h"
|
||||||
|
#include "nsIPresShell.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
/* Visual Viewport API spec: https://wicg.github.io/visual-viewport/#the-visualviewport-interface */
|
||||||
|
class VisualViewport final: public mozilla::DOMEventTargetHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit VisualViewport(nsPIDOMWindowInner* aWindow);
|
||||||
|
explicit VisualViewport(nsIGlobalObject* aGlobal);
|
||||||
|
|
||||||
|
double OffsetLeft() const;
|
||||||
|
double OffsetTop() const;
|
||||||
|
double PageLeft() const;
|
||||||
|
double PageTop() const;
|
||||||
|
double Width() const;
|
||||||
|
double Height() const;
|
||||||
|
double Scale() const;
|
||||||
|
|
||||||
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual ~VisualViewport();
|
||||||
|
|
||||||
|
CSSSize VisualViewportSize() const;
|
||||||
|
CSSPoint VisualViewportOffset() const;
|
||||||
|
CSSPoint LayoutViewportOffset() const;
|
||||||
|
nsIPresShell* GetPresShell() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_dom_VisualViewport_h
|
||||||
|
|
@ -217,6 +217,7 @@ EXPORTS.mozilla.dom += [
|
||||||
'Timeout.h',
|
'Timeout.h',
|
||||||
'TimeoutHandler.h',
|
'TimeoutHandler.h',
|
||||||
'TreeWalker.h',
|
'TreeWalker.h',
|
||||||
|
'VisualViewport.h',
|
||||||
'WebKitCSSMatrix.h',
|
'WebKitCSSMatrix.h',
|
||||||
'WebSocket.h',
|
'WebSocket.h',
|
||||||
'WindowOrientationObserver.h',
|
'WindowOrientationObserver.h',
|
||||||
|
|
@ -365,6 +366,7 @@ UNIFIED_SOURCES += [
|
||||||
'TimeoutHandler.cpp',
|
'TimeoutHandler.cpp',
|
||||||
'TimerClamping.cpp',
|
'TimerClamping.cpp',
|
||||||
'TreeWalker.cpp',
|
'TreeWalker.cpp',
|
||||||
|
'VisualViewport.cpp',
|
||||||
'WebKitCSSMatrix.cpp',
|
'WebKitCSSMatrix.cpp',
|
||||||
'WebSocket.cpp',
|
'WebSocket.cpp',
|
||||||
'WindowNamedPropertiesHandler.cpp',
|
'WindowNamedPropertiesHandler.cpp',
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "mozilla/dom/StorageEventBinding.h"
|
#include "mozilla/dom/StorageEventBinding.h"
|
||||||
#include "mozilla/dom/Timeout.h"
|
#include "mozilla/dom/Timeout.h"
|
||||||
#include "mozilla/dom/TimeoutHandler.h"
|
#include "mozilla/dom/TimeoutHandler.h"
|
||||||
|
#include "mozilla/dom/VisualViewport.h"
|
||||||
#include "mozilla/IntegerPrintfMacros.h"
|
#include "mozilla/IntegerPrintfMacros.h"
|
||||||
#include "nsDOMOfflineResourceList.h"
|
#include "nsDOMOfflineResourceList.h"
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
|
|
@ -4161,6 +4162,16 @@ nsGlobalWindow::GetNavigator()
|
||||||
return navigator;
|
return navigator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VisualViewport*
|
||||||
|
nsGlobalWindow::VisualViewport()
|
||||||
|
{
|
||||||
|
if (!mVisualViewport) {
|
||||||
|
mVisualViewport = new mozilla::dom::VisualViewport(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mVisualViewport;
|
||||||
|
}
|
||||||
|
|
||||||
nsScreen*
|
nsScreen*
|
||||||
nsGlobalWindow::GetScreen(ErrorResult& aError)
|
nsGlobalWindow::GetScreen(ErrorResult& aError)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ class SpeechSynthesis;
|
||||||
class TabGroup;
|
class TabGroup;
|
||||||
class Timeout;
|
class Timeout;
|
||||||
class U2F;
|
class U2F;
|
||||||
|
class VisualViewport;
|
||||||
class WakeLock;
|
class WakeLock;
|
||||||
struct WindowPostMessageOptions;
|
struct WindowPostMessageOptions;
|
||||||
class Worklet;
|
class Worklet;
|
||||||
|
|
@ -974,6 +975,7 @@ public:
|
||||||
already_AddRefed<nsICSSDeclaration>
|
already_AddRefed<nsICSSDeclaration>
|
||||||
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
||||||
mozilla::ErrorResult& aError) override;
|
mozilla::ErrorResult& aError) override;
|
||||||
|
mozilla::dom::VisualViewport* VisualViewport();
|
||||||
already_AddRefed<mozilla::dom::MediaQueryList> MatchMediaOuter(const nsAString& aQuery);
|
already_AddRefed<mozilla::dom::MediaQueryList> MatchMediaOuter(const nsAString& aQuery);
|
||||||
already_AddRefed<mozilla::dom::MediaQueryList> MatchMedia(const nsAString& aQuery,
|
already_AddRefed<mozilla::dom::MediaQueryList> MatchMedia(const nsAString& aQuery,
|
||||||
mozilla::ErrorResult& aError);
|
mozilla::ErrorResult& aError);
|
||||||
|
|
@ -1854,6 +1856,8 @@ protected:
|
||||||
RefPtr<nsHistory> mHistory;
|
RefPtr<nsHistory> mHistory;
|
||||||
RefPtr<mozilla::dom::CustomElementRegistry> mCustomElements;
|
RefPtr<mozilla::dom::CustomElementRegistry> mCustomElements;
|
||||||
|
|
||||||
|
RefPtr<mozilla::dom::VisualViewport> mVisualViewport;
|
||||||
|
|
||||||
// These member variables are used on both inner and the outer windows.
|
// These member variables are used on both inner and the outer windows.
|
||||||
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1162,6 +1162,10 @@ DOMInterfaces = {
|
||||||
'wrapperCache': False,
|
'wrapperCache': False,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'VisualViewport': {
|
||||||
|
'nativeType': 'mozilla::dom::VisualViewport',
|
||||||
|
},
|
||||||
|
|
||||||
'VTTCue': {
|
'VTTCue': {
|
||||||
'nativeType': 'mozilla::dom::TextTrackCue'
|
'nativeType': 'mozilla::dom::TextTrackCue'
|
||||||
},
|
},
|
||||||
|
|
|
||||||
21
dom/webidl/VisualViewport.webidl
Normal file
21
dom/webidl/VisualViewport.webidl
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
/* -*- Mode: IDL; 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/.
|
||||||
|
*
|
||||||
|
* The origin of this IDL file is:
|
||||||
|
* https://wicg.github.io/visual-viewport/#the-visualviewport-interface
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface VisualViewport : EventTarget {
|
||||||
|
readonly attribute double offsetLeft;
|
||||||
|
readonly attribute double offsetTop;
|
||||||
|
|
||||||
|
readonly attribute double pageLeft;
|
||||||
|
readonly attribute double pageTop;
|
||||||
|
|
||||||
|
readonly attribute double width;
|
||||||
|
readonly attribute double height;
|
||||||
|
|
||||||
|
readonly attribute double scale;
|
||||||
|
};
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
* http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
|
* http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
|
||||||
* https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object
|
* https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object
|
||||||
* https://w3c.github.io/requestidlecallback/
|
* https://w3c.github.io/requestidlecallback/
|
||||||
|
* https://wicg.github.io/visual-viewport/#the-visualviewport-interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface ApplicationCache;
|
interface ApplicationCache;
|
||||||
|
|
@ -492,3 +493,8 @@ partial interface Window {
|
||||||
dictionary WindowPostMessageOptions : StructuredSerializeOptions {
|
dictionary WindowPostMessageOptions : StructuredSerializeOptions {
|
||||||
USVString targetOrigin = "/";
|
USVString targetOrigin = "/";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
partial interface Window {
|
||||||
|
[SameObject, Pref="dom.visualviewport.enabled", Replaceable]
|
||||||
|
readonly attribute VisualViewport visualViewport;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -565,6 +565,7 @@ WEBIDL_FILES = [
|
||||||
'VideoStreamTrack.webidl',
|
'VideoStreamTrack.webidl',
|
||||||
'VideoTrack.webidl',
|
'VideoTrack.webidl',
|
||||||
'VideoTrackList.webidl',
|
'VideoTrackList.webidl',
|
||||||
|
'VisualViewport.webidl',
|
||||||
'VTTCue.webidl',
|
'VTTCue.webidl',
|
||||||
'VTTRegion.webidl',
|
'VTTRegion.webidl',
|
||||||
'WaveShaperNode.webidl',
|
'WaveShaperNode.webidl',
|
||||||
|
|
|
||||||
|
|
@ -317,6 +317,7 @@ private:
|
||||||
|
|
||||||
DECL_GFX_PREF(Live, "dom.ipc.plugins.asyncdrawing.enabled", PluginAsyncDrawingEnabled, bool, false);
|
DECL_GFX_PREF(Live, "dom.ipc.plugins.asyncdrawing.enabled", PluginAsyncDrawingEnabled, bool, false);
|
||||||
DECL_GFX_PREF(Live, "dom.meta-viewport.enabled", MetaViewportEnabled, bool, false);
|
DECL_GFX_PREF(Live, "dom.meta-viewport.enabled", MetaViewportEnabled, bool, false);
|
||||||
|
DECL_GFX_PREF(Live, "dom.visualviewport.enabled", VisualViewportEnabled, bool, false);
|
||||||
DECL_GFX_PREF(Once, "dom.vr.enabled", VREnabled, bool, false);
|
DECL_GFX_PREF(Once, "dom.vr.enabled", VREnabled, bool, false);
|
||||||
DECL_GFX_PREF(Once, "dom.vr.oculus.enabled", VROculusEnabled, bool, true);
|
DECL_GFX_PREF(Once, "dom.vr.oculus.enabled", VROculusEnabled, bool, true);
|
||||||
DECL_GFX_PREF(Once, "dom.vr.openvr.enabled", VROpenVREnabled, bool, false);
|
DECL_GFX_PREF(Once, "dom.vr.openvr.enabled", VROpenVREnabled, bool, false);
|
||||||
|
|
|
||||||
|
|
@ -653,9 +653,10 @@ CascadeRuleEnumFunc(css::Rule* aRule, void* aData)
|
||||||
} else if (css::Rule::IMPORT_RULE == type &&
|
} else if (css::Rule::IMPORT_RULE == type &&
|
||||||
nsCSSRuleUtils::LoadImportedSheetsInOrderEnabled()) {
|
nsCSSRuleUtils::LoadImportedSheetsInOrderEnabled()) {
|
||||||
css::ImportRule* importRule = static_cast<css::ImportRule*>(aRule);
|
css::ImportRule* importRule = static_cast<css::ImportRule*>(aRule);
|
||||||
nsCSSRuleProcessor::CascadeSheet(
|
StyleSheet* sheet = importRule->GetStyleSheet();
|
||||||
importRule->GetStyleSheet()->AsConcrete(),
|
if (sheet) {
|
||||||
layer);
|
nsCSSRuleProcessor::CascadeSheet(sheet->AsConcrete(), layer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5054,6 +5054,9 @@ pref("intl.allow-insecure-text-input", false);
|
||||||
// Enable meta-viewport support in remote APZ-enabled frames.
|
// Enable meta-viewport support in remote APZ-enabled frames.
|
||||||
pref("dom.meta-viewport.enabled", false);
|
pref("dom.meta-viewport.enabled", false);
|
||||||
|
|
||||||
|
// Enable the Visual Viewport API?
|
||||||
|
pref("dom.visualviewport.enabled", true);
|
||||||
|
|
||||||
// Disable <meta http-equiv=set-cookie> support. See m-c bug 1457503 / UXP #1102.
|
// Disable <meta http-equiv=set-cookie> support. See m-c bug 1457503 / UXP #1102.
|
||||||
pref("dom.meta-set-cookie.enabled", false);
|
pref("dom.meta-set-cookie.enabled", false);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue