Skip to content

Commit

Permalink
Merge inbound to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ncsoregi committed May 15, 2018
2 parents fd8a6b0 + 980d923 commit 00dd116
Show file tree
Hide file tree
Showing 82 changed files with 1,563 additions and 1,599 deletions.
35 changes: 26 additions & 9 deletions browser/app/LauncherProcessWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,31 @@ ShowError(DWORD aError = ::GetLastError())
::LocalFree(rawMsgBuf);
}

static wchar_t gAbsPath[MAX_PATH];
static bool
SetArgv0ToFullBinaryPath(wchar_t* aArgv[])
{
DWORD bufLen = MAX_PATH;
mozilla::UniquePtr<wchar_t[]> buf;

while (true) {
buf = mozilla::MakeUnique<wchar_t[]>(bufLen);
DWORD retLen = ::GetModuleFileNameW(nullptr, buf.get(), bufLen);
if (!retLen) {
return false;
}

if (retLen == bufLen && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
bufLen *= 2;
continue;
}

break;
}

// We intentionally leak buf into argv[0]
aArgv[0] = buf.release();
return true;
}

namespace mozilla {

Expand Down Expand Up @@ -112,18 +136,11 @@ LauncherMain(int argc, wchar_t* argv[])
}
}

// Convert argv[0] to an absolute path if necessary
DWORD absPathLen = ::SearchPathW(nullptr, argv[0], L".exe",
ArrayLength(gAbsPath), gAbsPath, nullptr);
if (!absPathLen) {
if (!SetArgv0ToFullBinaryPath(argv)) {
ShowError();
return 1;
}

if (absPathLen < ArrayLength(gAbsPath)) {
argv[0] = gAbsPath;
}

// If we're elevated, we should relaunch ourselves as a normal user
Maybe<bool> isElevated = IsElevated();
if (!isElevated) {
Expand Down
1 change: 1 addition & 0 deletions browser/base/content/test/tabs/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ skip-if = !e10s # Pref and test only relevant for e10s.
[browser_newwindow_tabstrip_overflow.js]
[browser_opened_file_tab_navigated_to_web.js]
[browser_new_tab_insert_position.js]
skip-if = (debug && os == 'linux' && bits == 32) #Bug 1455882, disabled on Linux32 for almost permafailing
support-files = file_new_tab_page.html
[browser_overflowScroll.js]
[browser_pinnedTabs.js]
Expand Down
43 changes: 43 additions & 0 deletions dom/base/DocumentOrShadowRoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,48 @@ DocumentOrShadowRoot::ElementsFromPointHelper(float aX, float aY,
}
}

Element*
DocumentOrShadowRoot::AddIDTargetObserver(nsAtom* aID,
IDTargetObserver aObserver,
void* aData, bool aForImage)
{
nsDependentAtomString id(aID);

if (!CheckGetElementByIdArg(id)) {
return nullptr;
}

nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aID);
NS_ENSURE_TRUE(entry, nullptr);

entry->AddContentChangeCallback(aObserver, aData, aForImage);
return aForImage ? entry->GetImageIdElement() : entry->GetIdElement();
}

void
DocumentOrShadowRoot::RemoveIDTargetObserver(nsAtom* aID,
IDTargetObserver aObserver,
void* aData, bool aForImage)
{
nsDependentAtomString id(aID);

if (!CheckGetElementByIdArg(id)) {
return;
}

nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aID);
if (!entry) {
return;
}

entry->RemoveContentChangeCallback(aObserver, aData, aForImage);
}

void
DocumentOrShadowRoot::ReportEmptyGetElementByIdArg()
{
nsContentUtils::ReportEmptyGetElementByIdArg(AsNode().OwnerDoc());
}

}
}
48 changes: 48 additions & 0 deletions dom/base/DocumentOrShadowRoot.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,54 @@ class DocumentOrShadowRoot
void ElementsFromPointHelper(float aX, float aY, uint32_t aFlags,
nsTArray<RefPtr<mozilla::dom::Element>>& aElements);

/**
* This gets fired when the element that an id refers to changes.
* This fires at difficult times. It is generally not safe to do anything
* which could modify the DOM in any way. Use
* nsContentUtils::AddScriptRunner.
* @return true to keep the callback in the callback set, false
* to remove it.
*/
typedef bool (* IDTargetObserver)(Element* aOldElement,
Element* aNewelement, void* aData);

/**
* Add an IDTargetObserver for a specific ID. The IDTargetObserver
* will be fired whenever the content associated with the ID changes
* in the future. If aForImage is true, mozSetImageElement can override
* what content is associated with the ID. In that case the IDTargetObserver
* will be notified at those times when the result of LookupImageElement
* changes.
* At most one (aObserver, aData, aForImage) triple can be
* registered for each ID.
* @return the content currently associated with the ID.
*/
Element* AddIDTargetObserver(nsAtom* aID, IDTargetObserver aObserver,
void* aData, bool aForImage);

/**
* Remove the (aObserver, aData, aForImage) triple for a specific ID, if
* registered.
*/
void RemoveIDTargetObserver(nsAtom* aID, IDTargetObserver aObserver,
void* aData, bool aForImage);

/**
* Check that aId is not empty and log a message to the console
* service if it is.
* @returns true if aId looks correct, false otherwise.
*/
inline bool CheckGetElementByIdArg(const nsAString& aId)
{
if (aId.IsEmpty()) {
ReportEmptyGetElementByIdArg();
return false;
}
return true;
}

void ReportEmptyGetElementByIdArg();

protected:
nsIContent* Retarget(nsIContent* aContent) const;

Expand Down
5 changes: 5 additions & 0 deletions dom/base/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "AnimationCommon.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/StaticPrefs.h"
#include "mozilla/dom/Animation.h"
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/Flex.h"
Expand Down Expand Up @@ -1247,6 +1248,10 @@ Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)

shadowRoot->SetIsComposedDocParticipant(IsInComposedDoc());

if (StaticPrefs::dom_webcomponents_shadowdom_report_usage()) {
OwnerDoc()->ReportShadowDOMUsage();
}

/**
* 5. Set context object’s shadow root to shadow.
*/
Expand Down
64 changes: 25 additions & 39 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@ nsIDocument::nsIDocument()
mWidthStrEmpty(false),
mParserAborted(false),
mReportedUseCounters(false),
mHasReportedShadowDOMUsage(false),
#ifdef DEBUG
mWillReparent(false),
#endif
Expand Down Expand Up @@ -5091,45 +5092,6 @@ nsDocument::BeginLoad()
NS_DOCUMENT_NOTIFY_OBSERVERS(BeginLoad, (this));
}

void
nsIDocument::ReportEmptyGetElementByIdArg()
{
nsContentUtils::ReportEmptyGetElementByIdArg(this);
}

Element*
nsIDocument::AddIDTargetObserver(nsAtom* aID, IDTargetObserver aObserver,
void* aData, bool aForImage)
{
nsDependentAtomString id(aID);

if (!CheckGetElementByIdArg(id))
return nullptr;

nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aID);
NS_ENSURE_TRUE(entry, nullptr);

entry->AddContentChangeCallback(aObserver, aData, aForImage);
return aForImage ? entry->GetImageIdElement() : entry->GetIdElement();
}

void
nsIDocument::RemoveIDTargetObserver(nsAtom* aID, IDTargetObserver aObserver,
void* aData, bool aForImage)
{
nsDependentAtomString id(aID);

if (!CheckGetElementByIdArg(id))
return;

nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aID);
if (!entry) {
return;
}

entry->RemoveContentChangeCallback(aObserver, aData, aForImage);
}

void
nsIDocument::MozSetImageElement(const nsAString& aImageElementId,
Element* aElement)
Expand Down Expand Up @@ -13259,3 +13221,27 @@ nsIDocument::ModuleScriptsEnabled()

return nsContentUtils::IsChromeDoc(this) || sEnabledForContent;
}

void
nsIDocument::ReportShadowDOMUsage()
{
if (mHasReportedShadowDOMUsage) {
return;
}

nsIDocument* topLevel = GetTopLevelContentDocument();
if (topLevel && !topLevel->mHasReportedShadowDOMUsage) {
topLevel->mHasReportedShadowDOMUsage = true;
nsString uri;
Unused << topLevel->GetDocumentURI(uri);
if (!uri.IsEmpty()) {
nsAutoString msg = NS_LITERAL_STRING("Shadow DOM used in [") + uri +
NS_LITERAL_STRING("] or in some of its subdocuments.");
nsContentUtils::ReportToConsoleNonLocalized(msg, nsIScriptError::infoFlag,
NS_LITERAL_CSTRING("DOM"),
topLevel);
}
}

mHasReportedShadowDOMUsage = true;
}
51 changes: 4 additions & 47 deletions dom/base/nsIDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,53 +799,6 @@ class nsIDocument : public nsINode,
mCharacterSetSource = aCharsetSource;
}

/**
* This gets fired when the element that an id refers to changes.
* This fires at difficult times. It is generally not safe to do anything
* which could modify the DOM in any way. Use
* nsContentUtils::AddScriptRunner.
* @return true to keep the callback in the callback set, false
* to remove it.
*/
typedef bool (* IDTargetObserver)(Element* aOldElement,
Element* aNewelement, void* aData);

/**
* Add an IDTargetObserver for a specific ID. The IDTargetObserver
* will be fired whenever the content associated with the ID changes
* in the future. If aForImage is true, mozSetImageElement can override
* what content is associated with the ID. In that case the IDTargetObserver
* will be notified at those times when the result of LookupImageElement
* changes.
* At most one (aObserver, aData, aForImage) triple can be
* registered for each ID.
* @return the content currently associated with the ID.
*/
Element* AddIDTargetObserver(nsAtom* aID, IDTargetObserver aObserver,
void* aData, bool aForImage);
/**
* Remove the (aObserver, aData, aForImage) triple for a specific ID, if
* registered.
*/
void RemoveIDTargetObserver(nsAtom* aID, IDTargetObserver aObserver,
void* aData, bool aForImage);

/**
* Check that aId is not empty and log a message to the console
* service if it is.
* @returns true if aId looks correct, false otherwise.
*/
inline bool CheckGetElementByIdArg(const nsAString& aId)
{
if (aId.IsEmpty()) {
ReportEmptyGetElementByIdArg();
return false;
}
return true;
}

void ReportEmptyGetElementByIdArg();

/**
* Get the Content-Type of this document.
*/
Expand Down Expand Up @@ -3583,6 +3536,8 @@ class nsIDocument : public nsINode,
*/
nsIContent* GetContentInThisDocument(nsIFrame* aFrame) const;

void ReportShadowDOMUsage();

protected:
already_AddRefed<nsIPrincipal> MaybeDowngradePrincipal(nsIPrincipal* aPrincipal);

Expand Down Expand Up @@ -4099,6 +4054,8 @@ class nsIDocument : public nsINode,
// that we only report them once for the document.
bool mReportedUseCounters: 1;

bool mHasReportedShadowDOMUsage: 1;

#ifdef DEBUG
public:
bool mWillReparent: 1;
Expand Down
5 changes: 2 additions & 3 deletions dom/plugins/base/nsPluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2268,10 +2268,9 @@ nsPluginHost::UpdatePluginBlocklistState(nsPluginTag* aPluginTag, bool aShouldSo
return;
}
// Asynchronously get the blocklist state.
nsCOMPtr<nsISupports> result;
RefPtr<Promise> promise;
blocklist->GetPluginBlocklistState(aPluginTag, EmptyString(),
EmptyString(), getter_AddRefs(result));
RefPtr<Promise> promise = do_QueryObject(result);
EmptyString(), getter_AddRefs(promise));
MOZ_ASSERT(promise, "Should always get a promise for plugin blocklist state.");
if (promise) {
promise->AppendNativeHandler(new mozilla::plugins::BlocklistPromiseHandler(aPluginTag, aShouldSoftblock));
Expand Down
5 changes: 2 additions & 3 deletions dom/presentation/PresentationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,13 @@ PresentationService::HandleSessionRequest(nsIPresentationSessionRequest* aReques
ctrlChannel->Disconnect(NS_ERROR_DOM_OPERATION_ERR);
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsCOMPtr<nsISupports> promise;
RefPtr<Promise> promise;
rv = glue->SendRequest(url, sessionId, device, getter_AddRefs(promise));
if (NS_WARN_IF(NS_FAILED(rv))) {
ctrlChannel->Disconnect(rv);
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsCOMPtr<Promise> realPromise = do_QueryInterface(promise);
static_cast<PresentationPresentingInfo*>(info.get())->SetPromise(realPromise);
static_cast<PresentationPresentingInfo*>(info.get())->SetPromise(promise);

return NS_OK;
}
Expand Down
6 changes: 3 additions & 3 deletions dom/presentation/interfaces/nsIPresentationRequestUIGlue.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface nsIPresentationRequestUIGlue : nsISupports
*
* @return A promise that resolves to the opening frame.
*/
nsISupports sendRequest(in DOMString url,
in DOMString sessionId,
in nsIPresentationDevice device);
Promise sendRequest(in DOMString url,
in DOMString sessionId,
in nsIPresentationDevice device);
};
9 changes: 2 additions & 7 deletions dom/promise/Promise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,8 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Promise)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mPromiseObj);
NS_IMPL_CYCLE_COLLECTION_TRACE_END

NS_IMPL_CYCLE_COLLECTING_ADDREF(Promise)
NS_IMPL_CYCLE_COLLECTING_RELEASE(Promise)

NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Promise)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(Promise)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(Promise, AddRef);
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(Promise, Release);

Promise::Promise(nsIGlobalObject* aGlobal)
: mGlobal(aGlobal)
Expand Down
Loading

0 comments on commit 00dd116

Please sign in to comment.