Merge mozilla-inbound to mozilla-central. a=merge

This commit is contained in:
Cosmin Sabou 2018-10-16 19:24:57 +03:00
Родитель e1e432ca29 634aca703e
Коммит 884e6b7585
46 изменённых файлов: 569 добавлений и 222 удалений

Просмотреть файл

@ -1203,6 +1203,12 @@ BrowserPageActions.addSearchEngine = {
// share URL
BrowserPageActions.shareURL = {
onCommand(event, buttonNode) {
let browser = gBrowser.selectedBrowser;
let currentURI = gURLBar.makeURIReadable(browser.currentURI).displaySpec;
this._windowsUIUtils.shareUrl(currentURI, browser.contentTitle);
},
onShowingInPanel(buttonNode) {
this._cached = false;
},
@ -1264,7 +1270,7 @@ BrowserPageActions.shareURL = {
};
// Attach sharingService here so tests can override the implementation
XPCOMUtils.defineLazyServiceGetter(BrowserPageActions.shareURL,
"_sharingService",
"@mozilla.org/widget/macsharingservice;1",
"nsIMacSharingService");
XPCOMUtils.defineLazyServiceGetters(BrowserPageActions.shareURL, {
_sharingService: ["@mozilla.org/widget/macsharingservice;1", "nsIMacSharingService"],
_windowsUIUtils: ["@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"],
});

Просмотреть файл

@ -19,6 +19,8 @@ add_task(async function() {
let setHomepageDialogPromise = BrowserTestUtils.domWindowOpened();
EventUtils.synthesizeDrop(dragSrcElement, homeButton, dragData, "copy", window);
// Ensure dnd suppression is cleared.
EventUtils.synthesizeMouseAtCenter(homeButton, { type: "mouseup" }, window);
let setHomepageDialog = await setHomepageDialogPromise;
ok(true, "dialog appeared in response to home button drop");
@ -68,6 +70,8 @@ add_task(async function() {
// principal, e.g. javascript:
expectUncaughtException();
EventUtils.synthesizeDrop(dragSrcElement, homeButton, [[{type: "text/plain", data: "javascript:8888"}]], "copy", window);
// Ensure dnd suppression is cleared.
EventUtils.synthesizeMouseAtCenter(homeButton, { type: "mouseup" }, window);
});
});
}

Просмотреть файл

@ -174,6 +174,8 @@ async function dragAndDrop(tab1, tab2, copy, destWindow = window) {
let originalTPos = tab1._tPos;
EventUtils.synthesizeDrop(tab1, tab2, null, copy ? "copy" : "move", window, destWindow, event);
// Ensure dnd suppression is cleared.
EventUtils.synthesizeMouseAtCenter(tab2, { type: "mouseup" }, destWindow);
if (!copy && destWindow == window) {
await BrowserTestUtils.waitForCondition(() => tab1._tPos != originalTPos,
"Waiting for tab position to be updated");

Просмотреть файл

@ -57,6 +57,10 @@ support-files =
subsuite = clipboard
[browser_page_action_menu_share_mac.js]
skip-if = os != "mac" # Mac only feature
[browser_page_action_menu_share_win.js]
support-files =
browser_page_action_menu_share_win.html
skip-if = os != "win" # Windows only feature
[browser_pasteAndGo.js]
subsuite = clipboard
[browser_populateAfterPushState.js]

Просмотреть файл

@ -0,0 +1,2 @@
<!doctype html>
<title>Windows Sharing</title>

Просмотреть файл

@ -0,0 +1,49 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* global sinon */
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
const TEST_URL = getRootDirectory(gTestPath) + "browser_page_action_menu_share_win.html";
// Keep track of site details we are sharing
let sharedUrl, sharedTitle;
let stub = sinon.stub(BrowserPageActions.shareURL, "_windowsUIUtils").get(() => {
return {
shareUrl(url, title) {
sharedUrl = url;
sharedTitle = title;
},
};
});
registerCleanupFunction(async function() {
stub.restore();
delete window.sinon;
});
add_task(async function shareURL() {
if (!AppConstants.isPlatformAndVersionAtLeast("win", "6.4")) {
Assert.ok(true, "We only expose share on windows 10 and above");
return;
}
await BrowserTestUtils.withNewTab(TEST_URL, async () => {
// Open the panel.
await promisePageActionPanelOpen();
// Click Share URL.
let shareURLButton = document.getElementById("pageAction-panel-shareURL");
let hiddenPromise = promisePageActionPanelHidden();
EventUtils.synthesizeMouseAtCenter(shareURLButton, {});
await hiddenPromise;
Assert.equal(sharedUrl, TEST_URL, "Shared correct URL");
Assert.equal(sharedTitle, "Windows Sharing", "Shared with the correct title");
});
});

Просмотреть файл

@ -23,7 +23,7 @@ var gCUITestUtils = new CustomizableUITestUtils(window);
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
registerCleanupFunction(() => Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck"));
var {synthesizeDragStart, synthesizeDrop} = EventUtils;
var {synthesizeDragStart, synthesizeDrop, synthesizeMouseAtCenter} = EventUtils;
const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -189,6 +189,8 @@ function simulateItemDrag(aToDrag, aTarget, aEvent = {}) {
ev._domDispatchOnly = true;
synthesizeDrop(aToDrag.parentNode, aTarget, null, null,
aToDrag.ownerGlobal, aTarget.ownerGlobal, ev);
// Ensure dnd suppression is cleared.
synthesizeMouseAtCenter(aTarget, { type: "mouseup" }, aTarget.ownerGlobal);
}
function endCustomizing(aWindow = window) {

Просмотреть файл

@ -1185,6 +1185,21 @@ if (AppConstants.platform == "macosx") {
});
}
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.4")) {
gBuiltInActions.push(
// Share URL
{
id: "shareURL",
title: "shareURL-title",
onBeforePlacedInWindow(buttonNode) {
browserPageActions(buttonNode).shareURL.onBeforePlacedInWindow(buttonNode);
},
onCommand(event, buttonNode) {
browserPageActions(buttonNode).shareURL.onCommand(event, buttonNode);
},
});
}
/**
* Gets a BrowserPageActions object in a browser window.
*

Просмотреть файл

@ -597,6 +597,10 @@ html|*.urlbar-input:-moz-lwtheme::placeholder,
color: GrayText;
}
#pageAction-panel-shareURL {
list-style-image: url("chrome://browser/skin/share.svg");
}
%include ../shared/urlbarSearchSuggestionsNotification.inc.css
#search-container {

Просмотреть файл

@ -38,6 +38,7 @@ browser.jar:
* skin/classic/browser/preferences/in-content/preferences.css (preferences/in-content/preferences.css)
* skin/classic/browser/preferences/in-content/dialog.css (preferences/in-content/dialog.css)
skin/classic/browser/preferences/applications.css (preferences/applications.css)
skin/classic/browser/share.svg (share.svg)
skin/classic/browser/tabbrowser/tabDragIndicator.png (tabbrowser/tabDragIndicator.png)
skin/classic/browser/window-controls/close.svg (window-controls/close.svg)
skin/classic/browser/window-controls/close-highcontrast.svg (window-controls/close-highcontrast.svg)

Просмотреть файл

@ -0,0 +1,7 @@
<!-- 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/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path fill="context-fill" d="M 15.707 4.293 l -4 -4 a 1 1 0 0 0 -1.414 1.414 L 12.585 4 H 11 a 7.008 7.008 0 0 0 -7 7 a 1 1 0 0 0 2 0 a 5.006 5.006 0 0 1 5 -5 h 1.585 l -2.293 2.293 a 1 1 0 1 0 1.414 1.414 l 4 -4 a 1 1 0 0 0 0.001 -1.414 Z" />
<path fill="context-fill" d="M 13 11 a 1 1 0 0 0 -1 1 v 1 a 1 1 0 0 1 -1 1 H 3 a 1 1 0 0 1 -1 -1 V 6 a 1 1 0 0 1 1 -1 h 1 a 1 1 0 0 0 0 -2 H 3 a 3 3 0 0 0 -3 3 v 7 a 3 3 0 0 0 3 3 h 8 a 3 3 0 0 0 3 -3 v -1 a 1 1 0 0 0 -1 -1 Z" />
</svg>

После

Ширина:  |  Высота:  |  Размер: 781 B

Просмотреть файл

@ -149,7 +149,7 @@ public:
void AssertIsOnTargetThread() const
{
MOZ_ASSERT(IsTargetThread());
MOZ_DIAGNOSTIC_ASSERT(IsTargetThread());
}
bool IsTargetThread() const

Просмотреть файл

@ -29,6 +29,7 @@
#include "mozilla/Atomics.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/CondVar.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/PContent.h"
#include "mozilla/dom/asmjscache/AsmJSCache.h"
#include "mozilla/dom/cache/QuotaClient.h"
@ -5414,6 +5415,8 @@ QuotaManager::EnsureTemporaryStorageIsInitialized()
return NS_OK;
}
TimeStamp startTime = TimeStamp::Now();
nsresult rv = InitializeRepository(PERSISTENCE_TYPE_DEFAULT);
if (NS_WARN_IF(NS_FAILED(rv))) {
// We have to cleanup partially initialized quota.
@ -5430,6 +5433,10 @@ QuotaManager::EnsureTemporaryStorageIsInitialized()
return rv;
}
Telemetry::AccumulateTimeDelta(Telemetry::QM_REPOSITORIES_INITIALIZATION_TIME,
startTime,
TimeStamp::Now());
if (gFixedLimitKB >= 0) {
mTemporaryStorageLimit = static_cast<uint64_t>(gFixedLimitKB) * 1024;
} else {

Просмотреть файл

@ -56,9 +56,8 @@ ModuleScript::UnlinkModuleRecord()
{
// Remove module's back reference to this object request if present.
if (mModuleRecord) {
MOZ_ASSERT(JS::GetModuleHostDefinedField(mModuleRecord).toPrivate() ==
this);
JS::SetModuleHostDefinedField(mModuleRecord, JS::UndefinedValue());
MOZ_ASSERT(JS::GetModulePrivate(mModuleRecord).toPrivate() == this);
JS::SetModulePrivate(mModuleRecord, JS::UndefinedValue());
mModuleRecord = nullptr;
}
}
@ -81,7 +80,7 @@ ModuleScript::SetModuleRecord(JS::Handle<JSObject*> aModuleRecord)
// Make module's host defined field point to this module script object.
// This is cleared in the UnlinkModuleRecord().
JS::SetModuleHostDefinedField(mModuleRecord, JS::PrivateValue(this));
JS::SetModulePrivate(mModuleRecord, JS::PrivateValue(this));
HoldJSObjects(this);
}

Просмотреть файл

@ -759,13 +759,13 @@ ScriptLoader::StartFetchingModuleAndDependencies(ModuleLoadRequest* aParent,
// 8.1.3.8.1 HostResolveImportedModule(referencingModule, specifier)
JSObject*
HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule,
HostResolveImportedModule(JSContext* aCx,
JS::Handle<JS::Value> aReferencingPrivate,
JS::Handle<JSString*> aSpecifier)
{
// Let referencing module script be referencingModule.[[HostDefined]].
JS::Value value = JS::GetModuleHostDefinedField(aModule);
auto script = static_cast<ModuleScript*>(value.toPrivate());
MOZ_ASSERT(script->ModuleRecord() == aModule);
auto script = static_cast<ModuleScript*>(aReferencingPrivate.toPrivate());
MOZ_ASSERT(JS::GetModulePrivate(script->ModuleRecord()) == aReferencingPrivate);
// Let url be the result of resolving a module specifier given referencing
// module script and specifier.
@ -792,19 +792,12 @@ HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule,
}
bool
HostPopulateImportMeta(JSContext* aCx, JS::Handle<JSObject*> aModule,
HostPopulateImportMeta(JSContext* aCx,
JS::Handle<JS::Value> aReferencingPrivate,
JS::Handle<JSObject*> aMetaObject)
{
MOZ_DIAGNOSTIC_ASSERT(aModule);
JS::Value value = JS::GetModuleHostDefinedField(aModule);
if (value.isUndefined()) {
JS_ReportErrorASCII(aCx, "Module script not found");
return false;
}
auto script = static_cast<ModuleScript*>(value.toPrivate());
MOZ_DIAGNOSTIC_ASSERT(script->ModuleRecord() == aModule);
auto script = static_cast<ModuleScript*>(aReferencingPrivate.toPrivate());
MOZ_ASSERT(JS::GetModulePrivate(script->ModuleRecord()) == aReferencingPrivate);
nsAutoCString url;
MOZ_DIAGNOSTIC_ASSERT(script->BaseURL());

Просмотреть файл

@ -521,8 +521,9 @@ private:
ModuleScript* GetFetchedModule(nsIURI* aURL) const;
friend JSObject*
HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule,
JS::Handle<JSString*> aSpecifier);
HostResolveImportedModule(JSContext* aCx,
JS::Handle<JS::Value> aReferencingPrivate,
JS::Handle<JSString*> aSpecifier);
// Returns wether we should save the bytecode of this script after the
// execution of the script.

Просмотреть файл

@ -51,6 +51,7 @@ NS_IMPL_ISUPPORTS_INHERITED(SVGFEImageElement, SVGFEImageElementBase,
SVGFEImageElement::SVGFEImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
: SVGFEImageElementBase(std::move(aNodeInfo))
, mImageAnimationMode(0)
{
// We start out broken
AddStatesSilently(NS_EVENT_STATE_BROKEN);
@ -338,6 +339,37 @@ SVGFEImageElement::GetStringInfo()
ArrayLength(sStringInfo));
}
//----------------------------------------------------------------------
// nsIImageLoadingContent methods
NS_IMETHODIMP_(void)
SVGFEImageElement::FrameCreated(nsIFrame* aFrame)
{
nsImageLoadingContent::FrameCreated(aFrame);
uint64_t mode = aFrame->PresContext()->ImageAnimationMode();
if (mode == mImageAnimationMode) {
return;
}
mImageAnimationMode = mode;
if (mPendingRequest) {
nsCOMPtr<imgIContainer> container;
mPendingRequest->GetImage(getter_AddRefs(container));
if (container) {
container->SetAnimationMode(mode);
}
}
if (mCurrentRequest) {
nsCOMPtr<imgIContainer> container;
mCurrentRequest->GetImage(getter_AddRefs(container));
if (container) {
container->SetAnimationMode(mode);
}
}
}
//----------------------------------------------------------------------
// imgINotificationObserver methods
@ -352,6 +384,7 @@ SVGFEImageElement::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect*
aRequest->GetImage(getter_AddRefs(container));
MOZ_ASSERT(container, "who sent the notification then?");
container->StartDecoding(imgIContainer::FLAG_NONE);
container->SetAnimationMode(mImageAnimationMode);
}
if (aType == imgINotificationObserver::LOAD_COMPLETE ||

Просмотреть файл

@ -69,6 +69,9 @@ public:
NS_IMETHOD Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData) override;
// Override for nsIImageLoadingContent.
NS_IMETHOD_(void) FrameCreated(nsIFrame* aFrame) override;
void MaybeLoadSVGImage();
// WebIDL
@ -92,6 +95,7 @@ protected:
static StringInfo sStringInfo[3];
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
uint16_t mImageAnimationMode;
};
} // namespace dom

Просмотреть файл

@ -873,6 +873,12 @@ ModuleObject::namespace_()
return &value.toObject().as<ModuleNamespaceObject>();
}
ScriptSourceObject*
ModuleObject::scriptSourceObject() const
{
return &getReservedSlot(ScriptSourceObjectSlot).toObject().as<ScriptSourceObject>();
}
FunctionDeclarationVector*
ModuleObject::functionDeclarations()
{
@ -887,8 +893,10 @@ ModuleObject::functionDeclarations()
void
ModuleObject::init(HandleScript script)
{
MOZ_ASSERT(script);
initReservedSlot(ScriptSlot, PrivateGCThingValue(script));
initReservedSlot(StatusSlot, Int32Value(MODULE_STATUS_UNINSTANTIATED));
initReservedSlot(ScriptSourceObjectSlot, ObjectValue(script->scriptSourceUnwrap()));
}
void
@ -1055,18 +1063,6 @@ ModuleObject::setMetaObject(JSObject* obj)
setReservedSlot(MetaObjectSlot, ObjectValue(*obj));
}
Value
ModuleObject::hostDefinedField() const
{
return getReservedSlot(HostDefinedSlot);
}
void
ModuleObject::setHostDefinedField(const JS::Value& value)
{
setReservedSlot(HostDefinedSlot, value);
}
Scope*
ModuleObject::enclosingScope() const
{
@ -1800,7 +1796,8 @@ js::GetOrCreateModuleMetaObject(JSContext* cx, HandleObject moduleArg)
return nullptr;
}
if (!func(cx, module, metaObject)) {
RootedValue modulePrivate(cx, JS::GetModulePrivate(module));
if (!func(cx, modulePrivate, metaObject)) {
return nullptr;
}

Просмотреть файл

@ -260,7 +260,7 @@ class ModuleObject : public NativeObject
StatusSlot,
EvaluationErrorSlot,
MetaObjectSlot,
HostDefinedSlot,
ScriptSourceObjectSlot,
RequestedModulesSlot,
ImportEntriesSlot,
LocalExportEntriesSlot,
@ -312,7 +312,7 @@ class ModuleObject : public NativeObject
bool hadEvaluationError() const;
Value evaluationError() const;
JSObject* metaObject() const;
Value hostDefinedField() const;
ScriptSourceObject* scriptSourceObject() const;
ArrayObject& requestedModules() const;
ArrayObject& importEntries() const;
ArrayObject& localExportEntries() const;
@ -328,8 +328,6 @@ class ModuleObject : public NativeObject
void setMetaObject(JSObject* obj);
void setHostDefinedField(const JS::Value& value);
// For BytecodeEmitter.
bool noteFunctionDeclaration(JSContext* cx, HandleAtom name, HandleFunction fun);

Просмотреть файл

@ -2361,6 +2361,7 @@ GetPropIRGenerator::tryAttachGenericElement(HandleObject obj, ObjOperandId objId
NativeObject* nobj = &obj->as<NativeObject>();
TestMatchingNativeReceiver(writer, nobj, objId);
}
writer.guardIndexGreaterThanDenseInitLength(objId, indexId);
writer.callNativeGetElementResult(objId, indexId);
writer.typeMonitorResult();

Просмотреть файл

@ -222,6 +222,7 @@ extern const char* const CacheKindNames[];
_(GuardHasGetterSetter) \
_(GuardGroupHasUnanalyzedNewScript) \
_(GuardIndexIsNonNegative) \
_(GuardIndexGreaterThanDenseInitLength) \
_(GuardTagNotEqual) \
_(GuardXrayExpandoShapeAndDefaultProto) \
_(GuardFunctionPrototype) \
@ -806,6 +807,10 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter
void guardIndexIsNonNegative(Int32OperandId index) {
writeOpWithOperandId(CacheOp::GuardIndexIsNonNegative, index);
}
void guardIndexGreaterThanDenseInitLength(ObjOperandId obj, Int32OperandId index) {
writeOpWithOperandId(CacheOp::GuardIndexGreaterThanDenseInitLength, obj);
writeOperandId(index);
}
void guardTagNotEqual(ValueTagOperandId lhs, ValueTagOperandId rhs) {
writeOpWithOperandId(CacheOp::GuardTagNotEqual, lhs);
writeOperandId(rhs);

Просмотреть файл

@ -2820,6 +2820,32 @@ CacheIRCompiler::emitGuardIndexIsNonNegative()
return true;
}
bool
CacheIRCompiler::emitGuardIndexGreaterThanDenseInitLength()
{
Register obj = allocator.useRegister(masm, reader.objOperandId());
Register index = allocator.useRegister(masm, reader.int32OperandId());
AutoScratchRegister scratch(allocator, masm);
AutoScratchRegister scratch2(allocator, masm);
FailurePath* failure;
if (!addFailurePath(&failure)) {
return false;
}
// Load obj->elements.
masm.loadPtr(Address(obj, NativeObject::offsetOfElements()), scratch);
// Ensure index >= capacity.
Label outOfBounds;
Address capacity(scratch, ObjectElements::offsetOfInitializedLength());
masm.spectreBoundsCheck32(index, capacity, scratch2, &outOfBounds);
masm.jump(failure->label());
masm.bind(&outOfBounds);
return true;
}
bool
CacheIRCompiler::emitGuardTagNotEqual()
{

Просмотреть файл

@ -46,6 +46,7 @@ namespace jit {
_(GuardAndGetNumberFromString) \
_(GuardAndGetIndexFromString) \
_(GuardIndexIsNonNegative) \
_(GuardIndexGreaterThanDenseInitLength) \
_(GuardTagNotEqual) \
_(GuardXrayExpandoShapeAndDefaultProto)\
_(GuardNoAllocationMetadataBuilder) \

Просмотреть файл

@ -156,20 +156,29 @@ CacheIRSpewer::valueProperty(const char* name, const Value& v)
}
} else if (v.isObject()) {
JSObject& object = v.toObject();
bool indexed = object.isNative() && object.as<NativeObject>().isIndexed();
j.formatProperty("value", "%p (shape: %p)%s", &object, object.maybeShape(),
indexed ? " indexed" : "");
if (indexed) {
NativeObject& native = object.as<NativeObject>();
j.beginObjectProperty("indexed");
j.formatProperty("value", "%p (shape: %p)", &object, object.maybeShape());
if (NativeObject* nobj = object.isNative() ? &object.as<NativeObject>() : nullptr) {
j.beginListProperty("flags");
{
j.property("denseInitializedLength",native.getDenseInitializedLength());
j.property("denseCapacity",native.getDenseCapacity());
j.property("denseElementsAreSealed", native.denseElementsAreSealed());
j.property("denseElementsAreCopyOnWrite", native.denseElementsAreCopyOnWrite());
j.property("denseElementsAreFrozen", native.denseElementsAreFrozen());
if (nobj->isIndexed()) {
j.value("indexed");
}
if (nobj->inDictionaryMode()) {
j.value("dictionaryMode");
}
}
j.endList();
if (nobj->isIndexed()) {
j.beginObjectProperty("indexed");
{
j.property("denseInitializedLength", nobj->getDenseInitializedLength());
j.property("denseCapacity", nobj->getDenseCapacity());
j.property("denseElementsAreSealed", nobj->denseElementsAreSealed());
j.property("denseElementsAreCopyOnWrite", nobj->denseElementsAreCopyOnWrite());
j.property("denseElementsAreFrozen", nobj->denseElementsAreFrozen());
}
j.endObject();
}
j.endObject();
}
}

Просмотреть файл

@ -4152,15 +4152,27 @@ JS::CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options,
}
JS_PUBLIC_API(void)
JS::SetModuleHostDefinedField(JSObject* module, const JS::Value& value)
JS::SetModulePrivate(JSObject* module, const JS::Value& value)
{
module->as<ModuleObject>().setHostDefinedField(value);
module->as<ModuleObject>().scriptSourceObject()->setPrivate(value);
}
JS_PUBLIC_API(JS::Value)
JS::GetModuleHostDefinedField(JSObject* module)
JS::GetModulePrivate(JSObject* module)
{
return module->as<ModuleObject>().hostDefinedField();
return module->as<ModuleObject>().scriptSourceObject()->getPrivate();
}
JS_PUBLIC_API(void)
JS::SetScriptPrivate(JSScript* script, const JS::Value& value)
{
script->scriptSourceUnwrap().setPrivate(value);
}
JS_PUBLIC_API(JS::Value)
JS::GetScriptPrivate(JSScript* script)
{
return script->scriptSourceUnwrap().getPrivate();
}
JS_PUBLIC_API(bool)

Просмотреть файл

@ -3021,7 +3021,7 @@ JS_DecompileFunction(JSContext* cx, JS::Handle<JSFunction*> fun);
namespace JS {
using ModuleResolveHook = JSObject* (*)(JSContext*, HandleObject, HandleString);
using ModuleResolveHook = JSObject* (*)(JSContext*, HandleValue, HandleString);
/**
* Get the HostResolveImportedModule hook for the runtime.
@ -3035,7 +3035,7 @@ GetModuleResolveHook(JSRuntime* rt);
extern JS_PUBLIC_API(void)
SetModuleResolveHook(JSRuntime* rt, ModuleResolveHook func);
using ModuleMetadataHook = bool (*)(JSContext*, HandleObject, HandleObject);
using ModuleMetadataHook = bool (*)(JSContext*, HandleValue, HandleObject);
/**
* Get the hook for populating the import.meta metadata object.
@ -3059,17 +3059,30 @@ CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf, JS::MutableHandleObject moduleRecord);
/**
* Set the [[HostDefined]] field of a source text module record to the given
* value.
* Set a private value associated with a source text module record.
*/
extern JS_PUBLIC_API(void)
SetModuleHostDefinedField(JSObject* module, const JS::Value& value);
SetModulePrivate(JSObject* module, const JS::Value& value);
/**
* Get the [[HostDefined]] field of a source text module record.
* Get the private value associated with a source text module record.
*/
extern JS_PUBLIC_API(JS::Value)
GetModuleHostDefinedField(JSObject* module);
GetModulePrivate(JSObject* module);
/**
* Set a private value associated with a script. Note that this value is shared
* by all nested scripts compiled from a single source file.
*/
extern JS_PUBLIC_API(void)
SetScriptPrivate(JSScript* script, const JS::Value& value);
/**
* Get the private value associated with a script. Note that this value is
* shared by all nested scripts compiled from a single source file.
*/
extern JS_PUBLIC_API(JS::Value)
GetScriptPrivate(JSScript* script);
/*
* Perform the ModuleInstantiate operation on the given source text module

Просмотреть файл

@ -4,7 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global getModuleLoadPath setModuleLoadHook setModuleResolveHook setModuleMetadataHook */
/* global parseModule os */
/* global getModulePrivate setModulePrivate parseModule os */
// A basic synchronous module loader for testing the shell.
{
@ -19,6 +19,7 @@ const StringPrototypeIndexOf = String.prototype.indexOf;
const StringPrototypeLastIndexOf = String.prototype.lastIndexOf;
const StringPrototypeStartsWith = String.prototype.startsWith;
const StringPrototypeSubstring = String.prototype.substring;
const ErrorClass = Error;
const ReflectLoader = new class {
constructor() {
@ -27,35 +28,39 @@ const ReflectLoader = new class {
this.loadPath = getModuleLoadPath();
}
resolve(name, module) {
resolve(name, referencingInfo) {
if (os.path.isAbsolute(name))
return name;
let loadPath = this.loadPath;
if (module) {
// Treat |name| as a relative path if it starts with either "./"
// or "../".
let isRelative = ReflectApply(StringPrototypeStartsWith, name, ["./"])
|| ReflectApply(StringPrototypeStartsWith, name, ["../"])
#ifdef XP_WIN
|| ReflectApply(StringPrototypeStartsWith, name, [".\\"])
|| ReflectApply(StringPrototypeStartsWith, name, ["..\\"])
#endif
;
// If |name| is a relative path and |module|'s path is available,
// load |name| relative to the referring module.
if (isRelative && ReflectApply(MapPrototypeHas, this.modulePaths, [module])) {
let modulePath = ReflectApply(MapPrototypeGet, this.modulePaths, [module]);
let sepIndex = ReflectApply(StringPrototypeLastIndexOf, modulePath, ["/"]);
// Treat |name| as a relative path if it starts with either "./"
// or "../".
let isRelative = ReflectApply(StringPrototypeStartsWith, name, ["./"])
|| ReflectApply(StringPrototypeStartsWith, name, ["../"])
#ifdef XP_WIN
let otherSepIndex = ReflectApply(StringPrototypeLastIndexOf, modulePath, ["\\"]);
if (otherSepIndex > sepIndex)
sepIndex = otherSepIndex;
|| ReflectApply(StringPrototypeStartsWith, name, [".\\"])
|| ReflectApply(StringPrototypeStartsWith, name, ["..\\"])
#endif
if (sepIndex >= 0)
loadPath = ReflectApply(StringPrototypeSubstring, modulePath, [0, sepIndex]);
;
// If |name| is a relative path and the referencing module's path is
// available, load |name| relative to the that path.
if (isRelative) {
if (!referencingInfo) {
throw new ErrorClass("No referencing module for relative import");
}
let path = referencingInfo.path;
let sepIndex = ReflectApply(StringPrototypeLastIndexOf, path, ["/"]);
#ifdef XP_WIN
let otherSepIndex = ReflectApply(StringPrototypeLastIndexOf, path, ["\\"]);
if (otherSepIndex > sepIndex)
sepIndex = otherSepIndex;
#endif
if (sepIndex >= 0)
loadPath = ReflectApply(StringPrototypeSubstring, path, [0, sepIndex]);
}
return os.path.join(loadPath, name);
@ -155,8 +160,9 @@ const ReflectLoader = new class {
let source = this.fetch(path);
let module = parseModule(source, path);
let moduleInfo = { path: normalized };
setModulePrivate(module, moduleInfo);
ReflectApply(MapPrototypeSet, this.registry, [normalized, module]);
ReflectApply(MapPrototypeSet, this.modulePaths, [module, path]);
return module;
}
@ -175,12 +181,12 @@ const ReflectLoader = new class {
return this.loadAndExecute(path);
}
populateImportMeta(module, metaObject) {
// For the shell, use the script's filename as the base URL.
populateImportMeta(moduleInfo, metaObject) {
// For the shell, use the module's normalized path as the base URL.
let path;
if (ReflectApply(MapPrototypeHas, this.modulePaths, [module])) {
path = ReflectApply(MapPrototypeGet, this.modulePaths, [module]);
if (moduleInfo) {
path = moduleInfo.path;
} else {
path = "(unknown)";
}

Просмотреть файл

@ -4723,7 +4723,7 @@ SetModuleResolveHook(JSContext* cx, unsigned argc, Value* vp)
}
static JSObject*
CallModuleResolveHook(JSContext* cx, HandleObject module, HandleString specifier)
CallModuleResolveHook(JSContext* cx, HandleValue referencingPrivate, HandleString specifier)
{
Handle<GlobalObject*> global = cx->global();
RootedValue hookValue(cx, global->getReservedSlot(GlobalAppSlotModuleResolveHook));
@ -4734,7 +4734,7 @@ CallModuleResolveHook(JSContext* cx, HandleObject module, HandleString specifier
MOZ_ASSERT(hookValue.toObject().is<JSFunction>());
JS::AutoValueArray<2> args(cx);
args[0].setObject(*module);
args[0].set(referencingPrivate);
args[1].setString(specifier);
RootedValue result(cx);
@ -4774,7 +4774,7 @@ SetModuleMetadataHook(JSContext* cx, unsigned argc, Value* vp)
}
static bool
CallModuleMetadataHook(JSContext* cx, HandleObject module, HandleObject metaObject)
CallModuleMetadataHook(JSContext* cx, HandleValue modulePrivate, HandleObject metaObject)
{
Handle<GlobalObject*> global = cx->global();
RootedValue hookValue(cx, global->getReservedSlot(GlobalAppSlotModuleMetadataHook));
@ -4785,13 +4785,60 @@ CallModuleMetadataHook(JSContext* cx, HandleObject module, HandleObject metaObje
MOZ_ASSERT(hookValue.toObject().is<JSFunction>());
JS::AutoValueArray<2> args(cx);
args[0].setObject(*module);
args[0].set(modulePrivate);
args[1].setObject(*metaObject);
RootedValue dummy(cx);
return JS_CallFunctionValue(cx, nullptr, hookValue, args, &dummy);
}
static bool
ReportArgumentTypeError(JSContext* cx, HandleValue value, const char* expected)
{
const char* typeName = InformalValueTypeName(value);
JS_ReportErrorASCII(cx, "Expected %s, got %s", expected, typeName);
return false;
}
static bool
ShellSetModulePrivate(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 2) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
"setModulePrivate", "0", "s");
return false;
}
if (!args[0].isObject() || !args[0].toObject().is<ModuleObject>()) {
return ReportArgumentTypeError(cx, args[0], "module object");
}
JS::SetModulePrivate(&args[0].toObject(), args[1]);
args.rval().setUndefined();
return true;
}
static bool
ShellGetModulePrivate(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() != 1) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
"getModulePrivate", "0", "s");
return false;
}
if (!args[0].isObject() || !args[0].toObject().is<ModuleObject>()) {
return ReportArgumentTypeError(cx, args[0], "module object");
}
args.rval().set(JS::GetModulePrivate(&args[0].toObject()));
return true;
}
static bool
GetModuleLoadPath(JSContext* cx, unsigned argc, Value* vp)
{
@ -8011,6 +8058,14 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
" This hook is used to create the metadata object returned by import.meta for\n"
" a module. It should be implemented by the module loader."),
JS_FN_HELP("setModulePrivate", ShellSetModulePrivate, 2, 0,
"setModulePrivate(scriptObject, privateValue)",
" Associate a private value with a module object.\n"),
JS_FN_HELP("getModulePrivate", ShellGetModulePrivate, 2, 0,
"getModulePrivate(scriptObject)",
" Get the private value associated with a module object.\n"),
JS_FN_HELP("getModuleLoadPath", GetModuleLoadPath, 0, 0,
"getModuleLoadPath()",
" Return any --module-load-path argument passed to the shell. Used by the\n"

Просмотреть файл

@ -1221,12 +1221,22 @@ class ScriptSourceObject : public NativeObject
return value.toGCThing()->as<JSScript>();
}
void setPrivate(const Value& value) {
setReservedSlot(PRIVATE_SLOT, value);
}
Value getPrivate() const {
return getReservedSlot(PRIVATE_SLOT);
}
private:
static const uint32_t SOURCE_SLOT = 0;
static const uint32_t ELEMENT_SLOT = 1;
static const uint32_t ELEMENT_PROPERTY_SLOT = 2;
static const uint32_t INTRODUCTION_SCRIPT_SLOT = 3;
static const uint32_t RESERVED_SLOTS = 4;
enum {
SOURCE_SLOT = 0,
ELEMENT_SLOT,
ELEMENT_PROPERTY_SLOT,
INTRODUCTION_SCRIPT_SLOT,
PRIVATE_SLOT,
RESERVED_SLOTS
};
};
enum class GeneratorKind : bool { NotGenerator, Generator };

Просмотреть файл

@ -2190,7 +2190,8 @@ intrinsic_HostResolveImportedModule(JSContext* cx, unsigned argc, Value* vp)
}
RootedObject result(cx);
result = moduleResolveHook(cx, module, specifier);
RootedValue referencingPrivate(cx, JS::GetModulePrivate(module));
result = moduleResolveHook(cx, referencingPrivate, specifier);
if (!result) {
return false;
}

Просмотреть файл

@ -569,7 +569,12 @@ nsSVGImageListener::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
// Called once the resource's dimensions have been obtained.
aRequest->GetImage(getter_AddRefs(mFrame->mImageContainer));
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
if (image) {
image->SetAnimationMode(mFrame->PresContext()->ImageAnimationMode());
mFrame->mImageContainer = image.forget();
}
mFrame->InvalidateFrame();
nsLayoutUtils::PostRestyleEvent(
mFrame->GetContent()->AsElement(), nsRestyleHint(0),

Просмотреть файл

@ -851,6 +851,8 @@ nsImageBoxFrame::OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage)
// 'cleaned up' by the Request when it is destroyed, but only then.
aRequest->IncrementAnimationConsumers();
aImage->SetAnimationMode(PresContext()->ImageAnimationMode());
nscoord w, h;
aImage->GetWidth(&w);
aImage->GetHeight(&h);

Просмотреть файл

@ -37,6 +37,15 @@ nsTreeImageListener::Notify(imgIRequest *aRequest, int32_t aType, const nsIntRec
// corresponding call to Decrement for this. This Increment will be
// 'cleaned up' by the Request when it is destroyed, but only then.
aRequest->IncrementAnimationConsumers();
if (mTreeFrame) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
if (image) {
nsPresContext* presContext = mTreeFrame->PresContext();
image->SetAnimationMode(presContext->ImageAnimationMode());
}
}
}
if (aType == imgINotificationObserver::FRAME_UPDATE) {

Просмотреть файл

@ -1,41 +0,0 @@
# HG changeset patch
# User Tom Ritter <tom@mozilla.com>
# Date 1526498300 18000
# Wed May 16 14:18:20 2018 -0500
# Node ID dd3f4940aeb0c4e00e8bcf1c238f2355ad793489
# Parent cf646c80b9545db7ab548f88a482378734ee2f78
Bug 1462100 Cast to void* to avoid conversion errors on MinGW, which does not do the automatic conversion like msvc r?bobowen
MozReview-Commit-ID: 8fO9Nu9gaxh
diff --git a/security/sandbox/chromium/sandbox/win/src/interception.h b/security/sandbox/chromium/sandbox/win/src/interception.h
--- a/security/sandbox/chromium/sandbox/win/src/interception.h
+++ b/security/sandbox/chromium/sandbox/win/src/interception.h
@@ -264,25 +264,25 @@ class InterceptionManager {
#define MAKE_SERVICE_NAME(service) &Target##service##64
#else
#define MAKE_SERVICE_NAME(service) &Target##service
#endif
#define ADD_NT_INTERCEPTION(service, id, num_params) \
AddToPatchedFunctions(kNtdllName, #service, \
sandbox::INTERCEPTION_SERVICE_CALL, \
- MAKE_SERVICE_NAME(service), id)
+ (void*)MAKE_SERVICE_NAME(service), id)
#define INTERCEPT_NT(manager, service, id, num_params) \
manager->ADD_NT_INTERCEPTION(service, id, num_params)
// When intercepting the EAT it is important that the patched version of the
// function not call any functions imported from system libraries unless
// |TargetServices::InitCalled()| returns true, because it is only then that
// we are guaranteed that our IAT has been initialized.
#define INTERCEPT_EAT(manager, dll, function, id, num_params) \
manager->AddToPatchedFunctions(dll, #function, sandbox::INTERCEPTION_EAT, \
- MAKE_SERVICE_NAME(function), id)
+ (void*)MAKE_SERVICE_NAME(function), id)
#endif // SANDBOX_EXPORTS
} // namespace sandbox
#endif // SANDBOX_SRC_INTERCEPTION_H_

Просмотреть файл

@ -17,5 +17,4 @@ mingw_copy_s.patch
mingw_operator_new.patch
mingw_cast_getprocaddress.patch
mingw_capitalization.patch
mingw_noexports_casts.patch
mingw_offsetof.patch

Просмотреть файл

@ -269,7 +269,7 @@ class InterceptionManager {
#define ADD_NT_INTERCEPTION(service, id, num_params) \
AddToPatchedFunctions(kNtdllName, #service, \
sandbox::INTERCEPTION_SERVICE_CALL, \
(void*)MAKE_SERVICE_NAME(service), id)
MAKE_SERVICE_NAME(service), id)
#define INTERCEPT_NT(manager, service, id, num_params) \
manager->ADD_NT_INTERCEPTION(service, id, num_params)
@ -280,7 +280,7 @@ class InterceptionManager {
// we are guaranteed that our IAT has been initialized.
#define INTERCEPT_EAT(manager, dll, function, id, num_params) \
manager->AddToPatchedFunctions(dll, #function, sandbox::INTERCEPTION_EAT, \
(void*)MAKE_SERVICE_NAME(function), id)
MAKE_SERVICE_NAME(function), id)
#endif // SANDBOX_EXPORTS
} // namespace sandbox

Просмотреть файл

@ -2335,8 +2335,6 @@ function synthesizeDropAfterDragOver(aResult, aDataTransfer, aDestElement, aDest
sendDragEvent(event, aDestElement, aDestWindow);
}
synthesizeMouseAtCenter(aDestElement, { type: "mouseup" }, aDestWindow);
return effect;
}
@ -2465,7 +2463,6 @@ async function synthesizePlainDragAndDrop(aParams)
await new Promise(r => setTimeout(r, 0));
synthesizeMouseAtCenter(destElement, { type: "mouseup" }, destWindow);
} finally {
ds.endDragSession(true, 0);
}

Просмотреть файл

@ -1,6 +1,7 @@
# META: timeout=long
import pytest
import time
from webdriver import Element
@ -47,7 +48,7 @@ def test_null_response_value(session):
def test_no_browsing_context(session, closed_window):
element = Element("foo", session)
element = Element("foo" + str(time.time()), session)
response = element_clear(session, element)
assert_error(response, "no such window")

Просмотреть файл

@ -46,8 +46,7 @@ var progressListener = {
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
// Put progress meter in undetermined mode.
// dialog.progress.setAttribute( "value", 0 );
dialog.progress.setAttribute( "mode", "undetermined" );
dialog.progress.removeAttribute("value");
}
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
@ -58,7 +57,6 @@ var progressListener = {
// Put progress meter at 100%.
dialog.progress.setAttribute( "value", 100 );
dialog.progress.setAttribute( "mode", "normal" );
var percentPrint = getString( "progressText" );
percentPrint = replaceInsert( percentPrint, 1, 100 );
dialog.progressText.setAttribute("value", percentPrint);
@ -87,7 +85,7 @@ var progressListener = {
onProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {
if (switchUI) {
dialog.tempLabel.setAttribute("hidden", "true");
dialog.progress.setAttribute("hidden", "false");
dialog.progressBox.removeAttribute("hidden");
var progressLabel = getString("progress");
if (progressLabel == "") {
@ -118,8 +116,6 @@ var progressListener = {
if ( percent > 100 )
percent = 100;
dialog.progress.removeAttribute( "mode");
// Advance progress meter.
dialog.progress.setAttribute( "value", percent );
@ -129,7 +125,7 @@ var progressListener = {
dialog.progressText.setAttribute("value", percentPrint);
} else {
// Progress meter should be barber-pole in this case.
dialog.progress.setAttribute( "mode", "undetermined" );
dialog.progress.removeAttribute("value");
// Update percentage label on progress meter.
dialog.progressText.setAttribute("value", "");
}
@ -209,11 +205,12 @@ function onLoad() {
dialog.title = document.getElementById("dialog.title");
dialog.titleLabel = document.getElementById("dialog.titleLabel");
dialog.progress = document.getElementById("dialog.progress");
dialog.progressBox = document.getElementById("dialog.progressBox");
dialog.progressText = document.getElementById("dialog.progressText");
dialog.progressLabel = document.getElementById("dialog.progressLabel");
dialog.tempLabel = document.getElementById("dialog.tempLabel");
dialog.progress.setAttribute("hidden", "true");
dialog.progressBox.setAttribute("hidden", "true");
var progressLabel = getString("preparing");
if (progressLabel == "") {

Просмотреть файл

@ -9,6 +9,7 @@
<!DOCTYPE window SYSTEM "chrome://global/locale/printProgress.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
buttons="cancel"
title="&printWindow.title;"
style="width: 36em;"
@ -47,10 +48,13 @@
</row>
<row class="thin-separator">
<hbox pack="end">
<label id="dialog.progressLabel" control="dialog.progress" value="&progress;"/>
<html:label id="dialog.progressLabel" for="dialog.progress"
style="margin-right: 1em;">&progress;</html:label>
</hbox>
<label id="dialog.tempLabel" value="&preparing;"/>
<progressmeter id="dialog.progress" mode="normal" value="0"/>
<label id="dialog.tempLabel" value="&preparing;"/>
<vbox pack="center" id="dialog.progressBox">
<html:progress id="dialog.progress" value="0" max="100"></html:progress>
</vbox>
<hbox pack="end" style="min-width: 2.5em;">
<label id="dialog.progressText"/>
</hbox>

Просмотреть файл

@ -14151,5 +14151,16 @@
"bug_numbers": [1490074],
"description": "How long the AudioContext would become audible since it was created, time unit is seconds.",
"releaseChannelCollection": "opt-out"
},
"QM_REPOSITORIES_INITIALIZATION_TIME": {
"record_in_processes": ["main"],
"expires_in_version": "68",
"bug_numbers": [1481716],
"kind": "exponential",
"high": 30000,
"n_buckets": 30,
"releaseChannelCollection": "opt-out",
"alert_emails": ["ttung@mozilla.com"],
"description": "Time (ms) for the QuotaManager to initialize repositories."
}
}

Просмотреть файл

@ -75,10 +75,6 @@ class MozProgressmeter extends MozXULElement {
this._initUI();
}
disconnectedCallback() {
this.runAnimation = false;
}
static get observedAttributes() {
return [ "mode" ];
}
@ -94,60 +90,13 @@ class MozProgressmeter extends MozXULElement {
}
_initUI() {
let isUndetermined = this.isUndetermined();
let content = isUndetermined ?
`
<stack class="progress-remainder" flex="1" style="overflow: -moz-hidden-unscrollable;">
<spacer class="progress-bar" top="0" style="margin-right: -1000px;"/>
</stack>
` :
`
<spacer class="progress-bar"/>
<spacer class="progress-remainder"/>
`;
this._stack = null;
this._spacer = null;
this._runAnimation = isUndetermined;
let content = `
<spacer class="progress-bar"/>
<spacer class="progress-remainder"/>
`;
this.textContent = "";
this.appendChild(MozXULElement.parseXULToFragment(content));
if (!isUndetermined) {
return;
}
this._stack = this.querySelector(".progress-remainder");
this._spacer = this.querySelector(".progress-bar");
this._isLTR = document.defaultView.getComputedStyle(this).direction == "ltr";
this._startTime = window.performance.now();
let nextStep = (t) => {
if (!this._runAnimation) {
return;
}
let width = this._stack.boxObject.width;
if (width) {
let elapsedTime = t - this._startTime;
// Width of chunk is 1/5 (determined by the ratio 2000:400) of the
// total width of the progress bar. The left edge of the chunk
// starts at -1 and moves all the way to 4. It covers the distance
// in 2 seconds.
let position = this._isLTR ? ((elapsedTime % 2000) / 400) - 1 :
((elapsedTime % 2000) / -400) + 4;
width = width >> 2;
this._spacer.height = this._stack.boxObject.height;
this._spacer.width = width;
this._spacer.left = width * position;
}
window.requestAnimationFrame(nextStep);
};
window.requestAnimationFrame(nextStep);
}
}

Просмотреть файл

@ -3731,12 +3731,18 @@ nsWindow::Create(nsIWidget* aParent,
Unused << gfxPlatform::GetPlatform();
bool useWebRender = gfx::gfxVars::UseWebRender() &&
AllowWebRenderForThisWindow();
AllowWebRenderForThisWindow();
bool shouldAccelerate = ComputeShouldAccelerate();
MOZ_ASSERT(shouldAccelerate | !useWebRender);
// If using WebRender on X11, we need to select a visual with a depth buffer,
// as well as an alpha channel if transparency is requested. This must be done
// before the widget is realized.
if (mIsX11Display) {
// Use GL/WebRender compatible visual only when it is necessary, since
// the visual consumes more memory.
if (mIsX11Display && shouldAccelerate) {
auto display =
GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(mShell));
auto screen = gtk_widget_get_screen(mShell);

Просмотреть файл

@ -20,5 +20,9 @@ interface nsIWindowsUIUtils : nsISupports
* Update the tablet mode state
*/
void updateTabletModeState();
};
/**
* Share URL
*/
void shareUrl(in AString shareTitle, in AString urlToShare);
};

Просмотреть файл

@ -35,6 +35,7 @@ using namespace ABI::Windows::UI::ViewManagement;
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::ApplicationModel::DataTransfer;
/* All of this is win10 stuff and we're compiling against win81 headers
* for now, so we may need to do some legwork: */
@ -90,6 +91,21 @@ public:
};
#endif
#ifndef __IDataTransferManagerInterop_INTERFACE_DEFINED__
#define __IDataTransferManagerInterop_INTERFACE_DEFINED__
typedef interface IDataTransferManagerInterop IDataTransferManagerInterop;
MIDL_INTERFACE("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")
IDataTransferManagerInterop : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE GetForWindow(HWND appWindow, REFIID riid, void **dataTransferManager) = 0;
virtual HRESULT STDMETHODCALLTYPE ShowShareUIForWindow(HWND appWindow) = 0;
};
#endif
#endif
WindowsUIUtils::WindowsUIUtils() :
@ -178,3 +194,124 @@ WindowsUIUtils::UpdateTabletModeState()
return NS_OK;
}
struct HStringDeleter
{
typedef HSTRING pointer;
void operator()(pointer aString)
{
WindowsDeleteString(aString);
}
};
typedef mozilla::UniquePtr<HSTRING, HStringDeleter> HStringUniquePtr;
NS_IMETHODIMP
WindowsUIUtils::ShareUrl(const nsAString& aUrlToShare,
const nsAString& aShareTitle)
{
#ifndef __MINGW32__
if (!IsWin10OrLater()) {
return NS_OK;
}
HSTRING rawTitle;
HRESULT hr = WindowsCreateString(PromiseFlatString(aShareTitle).get(), aShareTitle.Length(), &rawTitle);
if (FAILED(hr)) {
return NS_OK;
}
HStringUniquePtr title(rawTitle);
HSTRING rawUrl;
hr = WindowsCreateString(PromiseFlatString(aUrlToShare).get(), aUrlToShare.Length(), &rawUrl);
if (FAILED(hr)) {
return NS_OK;
}
HStringUniquePtr url(rawUrl);
ComPtr<IUriRuntimeClassFactory> uriFactory;
hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_Uri).Get(), &uriFactory);
if (FAILED(hr)) {
return NS_OK;
}
ComPtr<IUriRuntimeClass> uri;
hr = uriFactory->CreateUri(url.get(), &uri);
if (FAILED(hr)) {
return NS_OK;
}
HWND hwnd = GetForegroundWindow();
if (!hwnd) {
return NS_OK;
}
ComPtr<IDataTransferManagerInterop> dtmInterop;
hr = RoGetActivationFactory(HStringReference(
RuntimeClass_Windows_ApplicationModel_DataTransfer_DataTransferManager)
.Get(), IID_PPV_ARGS(&dtmInterop));
if (FAILED(hr)) {
return NS_OK;
}
ComPtr<IDataTransferManager> dtm;
hr = dtmInterop->GetForWindow(hwnd, IID_PPV_ARGS(&dtm));
if (FAILED(hr)) {
return NS_OK;
}
auto callback = Callback < ITypedEventHandler<DataTransferManager*, DataRequestedEventArgs* >> (
[uri = std::move(uri), title = std::move(title)](IDataTransferManager*, IDataRequestedEventArgs* pArgs) -> HRESULT
{
ComPtr<IDataRequest> spDataRequest;
HRESULT hr = pArgs->get_Request(&spDataRequest);
if (FAILED(hr)) {
return hr;
}
ComPtr<IDataPackage> spDataPackage;
hr = spDataRequest->get_Data(&spDataPackage);
if (FAILED(hr)) {
return hr;
}
ComPtr<IDataPackage2> spDataPackage2;
hr = spDataPackage->QueryInterface(IID_PPV_ARGS(&spDataPackage2));
if (FAILED(hr)) {
return hr;
}
ComPtr<IDataPackagePropertySet> spDataPackageProperties;
hr = spDataPackage->get_Properties(&spDataPackageProperties);
if (FAILED(hr)) {
return hr;
}
hr = spDataPackageProperties->put_Title(title.get());
if (FAILED(hr)) {
return hr;
}
hr = spDataPackage2->SetWebLink(uri.Get());
if (FAILED(hr)) {
return hr;
}
return S_OK;
});
EventRegistrationToken dataRequestedToken;
hr = dtm->add_DataRequested(callback.Get(), &dataRequestedToken);
if (FAILED(hr)) {
return NS_OK;
}
hr = dtmInterop->ShowShareUIForWindow(hwnd);
if (FAILED(hr)) {
return NS_OK;
}
#endif
return NS_OK;
}