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
cristianbrindusan committed May 4, 2018
2 parents 870d5a3 + 91721cf commit 89a097b
Show file tree
Hide file tree
Showing 71 changed files with 837 additions and 1,396 deletions.
2 changes: 1 addition & 1 deletion accessible/generic/Accessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2346,7 +2346,7 @@ Accessible::GetIndexOfEmbeddedChild(Accessible* aChild)
// HyperLinkAccessible methods

bool
Accessible::IsLink()
Accessible::IsLink() const
{
// Every embedded accessible within hypertext accessible implements
// hyperlink interface.
Expand Down
2 changes: 1 addition & 1 deletion accessible/generic/Accessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ class Accessible : public nsISupports
/**
* Return true if the accessible is hyper link accessible.
*/
virtual bool IsLink();
virtual bool IsLink() const;

/**
* Return the start offset of the link within the parent accessible.
Expand Down
2 changes: 1 addition & 1 deletion accessible/html/HTMLLinkAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ HTMLLinkAccessible::DoAction(uint8_t aIndex)
// HyperLinkAccessible

bool
HTMLLinkAccessible::IsLink()
HTMLLinkAccessible::IsLink() const
{
// Expose HyperLinkAccessible unconditionally.
return true;
Expand Down
2 changes: 1 addition & 1 deletion accessible/html/HTMLLinkAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HTMLLinkAccessible : public HyperTextAccessibleWrap
virtual bool DoAction(uint8_t aIndex) override;

// HyperLinkAccessible
virtual bool IsLink() override;
virtual bool IsLink() const override;
virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;

protected:
Expand Down
2 changes: 1 addition & 1 deletion accessible/xul/XULElementAccessibles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ XULLinkAccessible::DoAction(uint8_t aIndex)
// XULLinkAccessible: HyperLinkAccessible

bool
XULLinkAccessible::IsLink()
XULLinkAccessible::IsLink() const
{
// Expose HyperLinkAccessible unconditionally.
return true;
Expand Down
2 changes: 1 addition & 1 deletion accessible/xul/XULElementAccessibles.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class XULLinkAccessible : public XULLabelAccessible
virtual bool DoAction(uint8_t aIndex) override;

// HyperLinkAccessible
virtual bool IsLink() override;
virtual bool IsLink() const override;
virtual uint32_t StartOffset() override;
virtual uint32_t EndOffset() override;
virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
Expand Down
3 changes: 0 additions & 3 deletions browser/base/content/tabbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,6 @@ window._gBrowser = {

if (!this._previewMode) {
newTab.updateLastAccessed();
newTab.removeAttribute("unread");
oldTab.updateLastAccessed();

let oldFindBar = oldTab._findBar;
Expand Down Expand Up @@ -4389,8 +4388,6 @@ class TabProgressListener {
}

gBrowser._tabAttrModified(this.mTab, ["busy"]);
if (!this.mTab.selected)
this.mTab.setAttribute("unread", "true");
}
this.mTab.removeAttribute("progress");

Expand Down
27 changes: 27 additions & 0 deletions browser/base/content/test/general/browser_contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ add_task(async function test_xul_text_link_label() {
// Below are test cases for HTML element

add_task(async function test_setup_html() {
await pushPrefs(["dom.webcomponents.shadowdom.enabled", true]);

let url = example_base + "subtst_contextmenu.html";

await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
Expand Down Expand Up @@ -131,6 +133,31 @@ add_task(async function test_link() {
);
});

add_task(async function test_link_in_shadow_dom() {
await test_contextmenu("#shadow-host",
["context-openlinkintab", true,
...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []),
// We need a blank entry here because the containers submenu is
// dynamically generated with no ids.
...(hasContainers ? ["", null] : []),
"context-openlink", true,
"context-openlinkprivate", true,
"---", null,
"context-bookmarklink", true,
"context-savelink", true,
...(hasPocket ? ["context-savelinktopocket", true] : []),
"context-copylink", true,
"context-searchselect", true,
"---", null,
"context-sendlinktodevice", true, [], null,
],
{
offsetX: 6,
offsetY: 6
}
);
});

add_task(async function test_mailto() {
await test_contextmenu("#test-mailto",
["context-copyemail", true,
Expand Down
8 changes: 8 additions & 0 deletions browser/base/content/test/general/subtst_contextmenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

<div id="test-text">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</div>
<a id="test-link" href="http://mozilla.com">Click the monkey!</a>
<div id="shadow-host"></div>
<script>
// Create the shadow DOM in case shadow DOM is enabled.
if ("ShadowRoot" in this) {
var sr = document.getElementById("shadow-host").attachShadow({mode: "closed"});
sr.innerHTML = "<a href='http://mozilla.com'>Click the monkey!</a>";
}
</script>
<a id="test-mailto" href="mailto:codemonkey@mozilla.com">Mail the monkey!</a><br>
<input id="test-input"><br>
<img id="test-image" src="ctxmenu-image.png">
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/performance/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skip-if = !e10s
run-if = debug || devedition || nightly_build # Requires startupRecorder.js, which isn't shipped everywhere by default
[browser_tabclose_grow.js]
[browser_tabclose.js]
skip-if = true # bug 1448497
skip-if = os == 'linux' # bug 1448497
[browser_tabopen.js]
[browser_tabopen_squeeze.js]
[browser_tabstrip_overflow_underflow.js]
Expand Down
33 changes: 17 additions & 16 deletions browser/modules/ContextMenu.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class ContextMenu {
let plugin = null;

try {
plugin = aEvent.target.QueryInterface(Ci.nsIObjectLoadingContent);
plugin = aEvent.composedTarget.QueryInterface(Ci.nsIObjectLoadingContent);
} catch (e) {}

if (plugin && plugin.displayedType == Ci.nsIObjectLoadingContent.TYPE_PLUGIN) {
Expand All @@ -509,7 +509,7 @@ class ContextMenu {
return;
}

let doc = aEvent.target.ownerDocument;
let doc = aEvent.composedTarget.ownerDocument;
let {
mozDocumentURIIfNotForErrorPages: docLocation,
characterSet: charSet,
Expand All @@ -519,14 +519,15 @@ class ContextMenu {
} = doc;
docLocation = docLocation && docLocation.spec;
let frameOuterWindowID = WebNavigationFrames.getFrameId(doc.defaultView);
let loginFillInfo = LoginManagerContent.getFieldContext(aEvent.target);
let loginFillInfo = LoginManagerContent.getFieldContext(aEvent.composedTarget);

// The same-origin check will be done in nsContextMenu.openLinkInTab.
let parentAllowsMixedContent = !!this.global.docShell.mixedContentChannel;

// Get referrer attribute from clicked link and parse it
let referrerAttrValue = Services.netUtils.parseAttributePolicyString(aEvent.target.
getAttribute("referrerpolicy"));
let referrerAttrValue =
Services.netUtils.parseAttributePolicyString(aEvent.composedTarget.
getAttribute("referrerpolicy"));

if (referrerAttrValue !== Ci.nsIHttpChannel.REFERRER_POLICY_UNSET) {
referrerPolicy = referrerAttrValue;
Expand All @@ -537,17 +538,17 @@ class ContextMenu {
// Media related cache info parent needs for saving
let contentType = null;
let contentDisposition = null;
if (aEvent.target.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
aEvent.target instanceof Ci.nsIImageLoadingContent &&
aEvent.target.currentURI) {
disableSetDesktopBg = this._disableSetDesktopBackground(aEvent.target);
if (aEvent.composedTarget.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
aEvent.composedTarget instanceof Ci.nsIImageLoadingContent &&
aEvent.composedTarget.currentURI) {
disableSetDesktopBg = this._disableSetDesktopBackground(aEvent.composedTarget);

try {
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
.getImgCacheForDocument(doc);
// The image cache's notion of where this image is located is
// the currentURI of the image loading content.
let props = imageCache.findEntryProperties(aEvent.target.currentURI, doc);
let props = imageCache.findEntryProperties(aEvent.composedTarget.currentURI, doc);

try {
contentType = props.get("type", Ci.nsISupportsCString).data;
Expand All @@ -562,7 +563,7 @@ class ContextMenu {
let selectionInfo = BrowserUtils.getSelectionDetails(this.content);
let loadContext = this.global.docShell.QueryInterface(Ci.nsILoadContext);
let userContextId = loadContext.originAttributes.userContextId;
let popupNodeSelectors = this._getNodeSelectors(aEvent.target);
let popupNodeSelectors = this._getNodeSelectors(aEvent.composedTarget);

this._setContext(aEvent);
let context = this.context;
Expand All @@ -581,7 +582,7 @@ class ContextMenu {
let isRemote = Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;

if (isRemote) {
editFlags = SpellCheckHelper.isEditable(aEvent.target, this.content);
editFlags = SpellCheckHelper.isEditable(aEvent.composedTarget, this.content);

if (editFlags & SpellCheckHelper.SPELLCHECKABLE) {
spellInfo = InlineSpellCheckerContent.initContextMenu(aEvent, editFlags, this.global);
Expand All @@ -591,10 +592,10 @@ class ContextMenu {
// determine what was context-clicked on. Then, update the state of the
// commands on the context menu.
this.global.docShell.contentViewer.QueryInterface(Ci.nsIContentViewerEdit)
.setCommandNode(aEvent.target);
aEvent.target.ownerGlobal.updateCommands("contentcontextmenu");
.setCommandNode(aEvent.composedTarget);
aEvent.composedTarget.ownerGlobal.updateCommands("contentcontextmenu");

customMenuItems = PageMenuChild.build(aEvent.target);
customMenuItems = PageMenuChild.build(aEvent.composedTarget);
principal = doc.nodePrincipal;
}

Expand Down Expand Up @@ -707,7 +708,7 @@ class ContextMenu {
context.screenY = aEvent.screenY;
context.mozInputSource = aEvent.mozInputSource;

const node = aEvent.target;
const node = aEvent.composedTarget;

const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

Expand Down
4 changes: 3 additions & 1 deletion devtools/client/inspector/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ Inspector.prototype = {
// Setup the toolbar only now because it may depend on the document.
await this.setupToolbar();

if (this.show3PaneTooltip) {
// Show the 3 pane onboarding tooltip only if the inspector is visisble since the
// Accessibility panel initializes the Inspector.
if (this.show3PaneTooltip && this.toolbox.currentToolId === "inspector") {
this.threePaneTooltip = new ThreePaneOnboardingTooltip(this.toolbox, this.panelDoc);
}

Expand Down
4 changes: 2 additions & 2 deletions dom/animation/AnimationTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void
AnimationTimeline::RemoveAnimation(Animation* aAnimation)
{
MOZ_ASSERT(!aAnimation->GetTimeline() || aAnimation->GetTimeline() == this);
if (aAnimation->isInList()) {
aAnimation->remove();
if (static_cast<LinkedListElement<Animation>*>(aAnimation)->isInList()) {
static_cast<LinkedListElement<Animation>*>(aAnimation)->remove();
}
mAnimations.RemoveEntry(aAnimation);
}
Expand Down
3 changes: 2 additions & 1 deletion dom/animation/DocumentTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ DocumentTimeline::WillRefresh(mozilla::TimeStamp aTime)
nsAutoAnimationMutationBatch mb(mDocument);

for (Animation* animation = mAnimationOrder.getFirst(); animation;
animation = animation->getNext()) {
animation =
static_cast<LinkedListElement<Animation>*>(animation)->getNext()) {
// Skip any animations that are longer need associated with this timeline.
if (animation->GetTimeline() != this) {
// If animation has some other timeline, it better not be also in the
Expand Down
6 changes: 4 additions & 2 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
// We own only the items in mDOMMediaQueryLists that have listeners;
// this reference is managed by their AddListener and RemoveListener
// methods.
for (auto mql : tmp->mDOMMediaQueryLists) {
for (MediaQueryList* mql = tmp->mDOMMediaQueryLists.getFirst(); mql;
mql = static_cast<LinkedListElement<MediaQueryList>*>(mql)->getNext()) {
if (mql->HasListeners()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mDOMMediaQueryLists item");
cb.NoteXPCOMChild(mql);
Expand Down Expand Up @@ -2079,7 +2080,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
// this reference is managed by their AddListener and RemoveListener
// methods.
for (MediaQueryList* mql = tmp->mDOMMediaQueryLists.getFirst(); mql;) {
MediaQueryList* next = mql->getNext();
MediaQueryList* next =
static_cast<LinkedListElement<MediaQueryList>*>(mql)->getNext();
mql->Disconnect();
mql = next;
}
Expand Down
23 changes: 12 additions & 11 deletions dom/base/nsIGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ nsIGlobalObject::~nsIGlobalObject()
{
UnlinkHostObjectURIs();
DisconnectEventTargetObjects();
MOZ_DIAGNOSTIC_ASSERT(mEventTargetObjects.IsEmpty());
MOZ_DIAGNOSTIC_ASSERT(mEventTargetObjects.isEmpty());
}

nsIPrincipal*
Expand Down Expand Up @@ -131,35 +131,37 @@ void
nsIGlobalObject::AddEventTargetObject(DOMEventTargetHelper* aObject)
{
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_ASSERT(!mEventTargetObjects.Contains(aObject));
mEventTargetObjects.PutEntry(aObject);
MOZ_ASSERT(!aObject->isInList());
mEventTargetObjects.insertBack(aObject);
}

void
nsIGlobalObject::RemoveEventTargetObject(DOMEventTargetHelper* aObject)
{
MOZ_DIAGNOSTIC_ASSERT(aObject);
MOZ_ASSERT(mEventTargetObjects.Contains(aObject));
mEventTargetObjects.RemoveEntry(aObject);
MOZ_ASSERT(aObject->isInList());
MOZ_ASSERT(aObject->GetOwnerGlobal() == this);
aObject->remove();
}

void
nsIGlobalObject::ForEachEventTargetObject(const std::function<void(DOMEventTargetHelper*, bool* aDoneOut)>& aFunc) const
{
// Protect against the function call triggering a mutation of the hash table
// Protect against the function call triggering a mutation of the list
// while we are iterating by copying the DETH references to a temporary
// list.
AutoTArray<DOMEventTargetHelper*, 64> targetList;
for (auto iter = mEventTargetObjects.ConstIter(); !iter.Done(); iter.Next()) {
targetList.AppendElement(iter.Get()->GetKey());
for (const DOMEventTargetHelper* deth = mEventTargetObjects.getFirst();
deth; deth = deth->getNext()) {
targetList.AppendElement(const_cast<DOMEventTargetHelper*>(deth));
}

// Iterate the target list and call the function on each one.
bool done = false;
for (auto target : targetList) {
// Check to see if a previous iteration's callback triggered the removal
// of this target as a side-effect. If it did, then just ignore it.
if (!mEventTargetObjects.Contains(target)) {
if (target->GetOwnerGlobal() != this) {
continue;
}
aFunc(target, &done);
Expand All @@ -177,7 +179,7 @@ nsIGlobalObject::DisconnectEventTargetObjects()

// Calling DisconnectFromOwner() should result in
// RemoveEventTargetObject() being called.
MOZ_DIAGNOSTIC_ASSERT(!mEventTargetObjects.Contains(aTarget));
MOZ_DIAGNOSTIC_ASSERT(aTarget->GetOwnerGlobal() != this);
});
}

Expand Down Expand Up @@ -215,6 +217,5 @@ size_t
nsIGlobalObject::ShallowSizeOfExcludingThis(MallocSizeOf aSizeOf) const
{
size_t rtn = mHostObjectURIs.ShallowSizeOfExcludingThis(aSizeOf);
rtn += mEventTargetObjects.ShallowSizeOfExcludingThis(aSizeOf);
return rtn;
}
7 changes: 3 additions & 4 deletions dom/base/nsIGlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef nsIGlobalObject_h__
#define nsIGlobalObject_h__

#include "mozilla/LinkedList.h"
#include "mozilla/Maybe.h"
#include "mozilla/dom/ClientInfo.h"
#include "mozilla/dom/DispatcherTrait.h"
Expand Down Expand Up @@ -41,10 +42,8 @@ class nsIGlobalObject : public nsISupports,
nsTArray<nsCString> mHostObjectURIs;

// Raw pointers to bound DETH objects. These are added by
// AddEventTargetObject(). The DETH object must call
// RemoveEventTargetObject() before its destroyed to clear
// its raw pointer here.
nsTHashtable<nsPtrHashKey<mozilla::DOMEventTargetHelper>> mEventTargetObjects;
// AddEventTargetObject().
mozilla::LinkedList<mozilla::DOMEventTargetHelper> mEventTargetObjects;

bool mIsDying;

Expand Down

0 comments on commit 89a097b

Please sign in to comment.