From 445883e2e946ba7432549a8efcfa37044459ed5a Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 25 Sep 2017 13:11:24 -0400 Subject: [PATCH 01/34] Bug 1400701 - Don't use text nodes under elements to determine the directionality of the ancestors; r=smaug --- dom/base/DirectionalityUtils.cpp | 12 +----------- dom/base/crashtests/1400701.html | 15 +++++++++++++++ dom/base/crashtests/crashtests.list | 1 + 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 dom/base/crashtests/1400701.html diff --git a/dom/base/DirectionalityUtils.cpp b/dom/base/DirectionalityUtils.cpp index 69f1fecf746c..6df783e1a0cb 100644 --- a/dom/base/DirectionalityUtils.cpp +++ b/dom/base/DirectionalityUtils.cpp @@ -244,16 +244,6 @@ DoesNotParticipateInAutoDirection(const Element* aElement) aElement->IsInAnonymousSubtree()); } -static inline bool -IsBdiWithoutDirAuto(const Element* aElement) -{ - // We are testing for bdi elements without explicit dir="auto", so we can't - // use the HasDirAuto() flag, since that will return true for bdi element with - // no dir attribute or an invalid dir attribute - return (aElement->IsHTMLElement(nsGkAtoms::bdi) && - (!aElement->HasValidDir() || aElement->HasFixedDir())); -} - /** * Returns true if aElement is one of the element whose text content should not * affect the direction of ancestors with dir=auto (though it may affect its own @@ -263,7 +253,7 @@ static bool DoesNotAffectDirectionOfAncestors(const Element* aElement) { return (DoesNotParticipateInAutoDirection(aElement) || - IsBdiWithoutDirAuto(aElement) || + aElement->IsHTMLElement(nsGkAtoms::bdi) || aElement->HasFixedDir()); } diff --git a/dom/base/crashtests/1400701.html b/dom/base/crashtests/1400701.html new file mode 100644 index 000000000000..fe1eef5d50f5 --- /dev/null +++ b/dom/base/crashtests/1400701.html @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/dom/base/crashtests/crashtests.list b/dom/base/crashtests/crashtests.list index 93c67d5e73ef..5df309d6b763 100644 --- a/dom/base/crashtests/crashtests.list +++ b/dom/base/crashtests/crashtests.list @@ -224,3 +224,4 @@ load 1383478.html load 1383780.html pref(clipboard.autocopy,true) load 1385272-1.html load 1393806.html +load 1400701.html From 9be401bdd6c8718748f76518a13fc175636a8f17 Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Fri, 22 Sep 2017 12:55:58 -0700 Subject: [PATCH 02/34] Bug 1389650 - Change nsIDOMHTMLAnchorElement instanceof checks to getClassName; r=bz MozReview-Commit-ID: Il2Ig98BHYP --- browser/modules/PluginContent.jsm | 9 ++++----- dom/browser-element/BrowserElementChildPreload.js | 4 ++-- dom/ipc/remote-test.js | 2 +- mobile/android/chrome/content/browser.js | 8 ++++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/browser/modules/PluginContent.jsm b/browser/modules/PluginContent.jsm index 678369d7e3ec..4a74650ebadd 100644 --- a/browser/modules/PluginContent.jsm +++ b/browser/modules/PluginContent.jsm @@ -175,7 +175,7 @@ PluginContent.prototype = { }, _getPluginInfo(pluginElement) { - if (pluginElement instanceof Ci.nsIDOMHTMLAnchorElement) { + if (ChromeUtils.getClassName(pluginElement) === "HTMLAnchorElement") { // Anchor elements are our place holders, and we only have them for Flash let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); return { @@ -649,7 +649,7 @@ PluginContent.prototype = { let doc = plugin.ownerDocument; let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); let permissionString; - if (plugin instanceof Ci.nsIDOMHTMLAnchorElement) { + if (ChromeUtils.getClassName(plugin) === "HTMLAnchorElement") { // We only have replacement content for Flash installs permissionString = pluginHost.getPermissionStringForType(FLASH_MIME_TYPE); } else { @@ -681,10 +681,9 @@ PluginContent.prototype = { onOverlayClick(event) { let document = event.target.ownerDocument; let plugin = document.getBindingParent(event.target); - let contentWindow = plugin.ownerGlobal.top; let overlay = this.getPluginUI(plugin, "main"); // Have to check that the target is not the link to update the plugin - if (!(event.originalTarget instanceof contentWindow.HTMLAnchorElement) && + if (!(ChromeUtils.getClassName(event.originalTarget) === "HTMLAnchorElement") && (event.originalTarget.getAttribute("anonid") != "closeIcon") && !overlay.hasAttribute("dismissed") && event.button == 0 && @@ -730,7 +729,7 @@ PluginContent.prototype = { } if (pluginInfo.permissionString == pluginHost.getPermissionStringForType(plugin.actualType)) { let overlay = this.getPluginUI(plugin, "main"); - if (plugin instanceof Ci.nsIDOMHTMLAnchorElement) { + if (ChromeUtils.getClassName(plugin) === "HTMLAnchorElement") { placeHolderFound = true; } else { pluginFound = true; diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index fc796ea71535..5c24b2b5827c 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -666,7 +666,7 @@ BrowserElementChild.prototype = { _ClickHandler: function(e) { let isHTMLLink = node => - ((node instanceof Ci.nsIDOMHTMLAnchorElement && node.href) || + ((ChromeUtils.getClassName(node) === "HTMLAnchorElement" && node.href) || (node instanceof Ci.nsIDOMHTMLAreaElement && node.href) || node instanceof Ci.nsIDOMHTMLLinkElement); @@ -855,7 +855,7 @@ BrowserElementChild.prototype = { _getSystemCtxMenuData: function(elem) { let documentURI = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI.spec; - if ((elem instanceof Ci.nsIDOMHTMLAnchorElement && elem.href) || + if ((ChromeUtils.getClassName(elem) === "HTMLAnchorElement" && elem.href) || (elem instanceof Ci.nsIDOMHTMLAreaElement && elem.href)) { return {uri: elem.href, documentURI: documentURI, diff --git a/dom/ipc/remote-test.js b/dom/ipc/remote-test.js index dd21415cd740..58e2e74b2b95 100644 --- a/dom/ipc/remote-test.js +++ b/dom/ipc/remote-test.js @@ -26,7 +26,7 @@ var dshell = content.QueryInterface(Ci.nsIInterfaceRequestor) addEventListener("click", function(e) { dump(e.target + "\n"); - if (e.target instanceof Components.interfaces.nsIDOMHTMLAnchorElement && + if (ChromeUtils.getClassName(e.target) === "HTMLAnchorElement" && dshell == docShell) { var retval = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor). getInterface(Components.interfaces.nsIContentFrameMessageManager). diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index db27d2da945a..09956f92cc4c 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -2735,7 +2735,7 @@ var NativeWindow = { */ _getContextType: function(element) { // For anchor nodes, we try to use the scheme to pick a string - if (element instanceof Ci.nsIDOMHTMLAnchorElement) { + if (ChromeUtils.getClassName(element) === "HTMLAnchorElement") { let uri = this.makeURI(this._getLinkURL(element)); try { return Strings.browser.GetStringFromName("browser.menu.context." + uri.scheme); @@ -2820,7 +2820,7 @@ var NativeWindow = { // Returns a url associated with a node _getUrl: function(node) { - if ((node instanceof Ci.nsIDOMHTMLAnchorElement && node.href) || + if ((ChromeUtils.getClassName(node) === "HTMLAnchorElement" && node.href) || (node instanceof Ci.nsIDOMHTMLAreaElement && node.href)) { return this._getLinkURL(node); } else if (node instanceof Ci.nsIImageLoadingContent && node.currentURI) { @@ -3051,7 +3051,7 @@ var NativeWindow = { _getLink: function(aElement) { if (aElement.nodeType == Ci.nsIDOMNode.ELEMENT_NODE && - ((aElement instanceof Ci.nsIDOMHTMLAnchorElement && aElement.href) || + ((ChromeUtils.getClassName(aElement) === "HTMLAnchorElement" && aElement.href) || (aElement instanceof Ci.nsIDOMHTMLAreaElement && aElement.href) || aElement instanceof Ci.nsIDOMHTMLLinkElement || aElement.getAttributeNS(kXLinkNamespace, "type") == "simple")) { @@ -4775,7 +4775,7 @@ var BrowserEventHandler = { _getLinkURI: function(aElement) { if (aElement.nodeType == Ci.nsIDOMNode.ELEMENT_NODE && - ((aElement instanceof Ci.nsIDOMHTMLAnchorElement && aElement.href) || + ((ChromeUtils.getClassName(aElement) === "HTMLAnchorElement" && aElement.href) || (aElement instanceof Ci.nsIDOMHTMLAreaElement && aElement.href))) { try { return Services.io.newURI(aElement.href); From a3876f104a66172389f5ca28ad6372cbc568e796 Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Fri, 22 Sep 2017 14:56:51 -0700 Subject: [PATCH 03/34] Bug 1389650 - Remove nsIDOMHTMLAnchorElement; r=bz Removes the XPCOM interface for nsIDOMHTMLAnchorElement, replacing it with binding class usage. MozReview-Commit-ID: 7v0bKlY7Fax --- docshell/base/nsContextMenuInfo.cpp | 44 +++++----- docshell/base/nsDocShell.cpp | 3 +- dom/base/nsContentAreaDragDrop.cpp | 15 ++-- dom/html/HTMLAnchorElement.cpp | 85 ++++--------------- dom/html/HTMLAnchorElement.h | 38 +++++---- dom/html/HTMLAreaElement.h | 1 + dom/html/HTMLLinkElement.h | 2 +- dom/interfaces/html/moz.build | 1 - .../html/nsIDOMHTMLAnchorElement.idl | 55 ------------ .../WebBrowserPersistLocalDocument.cpp | 4 +- dom/webidl/HTMLAnchorElement.webidl | 2 +- editor/libeditor/HTMLEditUtils.cpp | 20 +++-- editor/libeditor/HTMLEditor.cpp | 9 +- editor/libeditor/HTMLEditorDataTransfer.cpp | 1 - layout/generic/nsImageFrame.cpp | 4 +- layout/printing/nsPrintEngine.cpp | 1 - xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp | 2 - 17 files changed, 87 insertions(+), 200 deletions(-) delete mode 100644 dom/interfaces/html/nsIDOMHTMLAnchorElement.idl diff --git a/docshell/base/nsContextMenuInfo.cpp b/docshell/base/nsContextMenuInfo.cpp index 2197540b41b6..4bca372ddf5b 100644 --- a/docshell/base/nsContextMenuInfo.cpp +++ b/docshell/base/nsContextMenuInfo.cpp @@ -12,10 +12,7 @@ #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMHTMLHtmlElement.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLImageElement.h" -#include "nsIDOMHTMLAreaElement.h" -#include "nsIDOMHTMLLinkElement.h" #include "nsIDOMWindow.h" #include "nsICSSDeclaration.h" #include "nsIDOMCSSValue.h" @@ -27,7 +24,13 @@ #include "nsIContentSecurityPolicy.h" #include "nsIContentPolicy.h" #include "imgRequestProxy.h" +#include "mozilla/dom/HTMLAnchorElement.h" +#include "mozilla/dom/HTMLAreaElement.h" +#include "mozilla/dom/HTMLLinkElement.h" +using mozilla::dom::HTMLAnchorElement; +using mozilla::dom::HTMLAreaElement; +using mozilla::dom::HTMLLinkElement; using mozilla::dom::Element; using mozilla::ErrorResult; @@ -63,30 +66,24 @@ nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef) NS_ENSURE_STATE(mAssociatedLink); aHRef.Truncate(0); - nsCOMPtr content(do_QueryInterface(mAssociatedLink)); - nsAutoString localName; - if (content) { - content->GetLocalName(localName); - } - - nsCOMPtr linkContent; - ToLowerCase(localName); - if (localName.EqualsLiteral("a") || - localName.EqualsLiteral("area") || - localName.EqualsLiteral("link")) { - bool hasAttr; - content->HasAttribute(NS_LITERAL_STRING("href"), &hasAttr); + nsCOMPtr content(do_QueryInterface(mAssociatedLink)); + nsCOMPtr linkContent; + if (content && + content->IsAnyOfHTMLElements(nsGkAtoms::a, + nsGkAtoms::area, + nsGkAtoms::link)) { + bool hasAttr = content->HasAttr(kNameSpaceID_None, nsGkAtoms::href); if (hasAttr) { linkContent = content; - nsCOMPtr anchor(do_QueryInterface(linkContent)); + RefPtr anchor = HTMLAnchorElement::FromContent(linkContent); if (anchor) { anchor->GetHref(aHRef); } else { - nsCOMPtr area(do_QueryInterface(linkContent)); + RefPtr area = HTMLAreaElement::FromContent(linkContent); if (area) { area->GetHref(aHRef); } else { - nsCOMPtr link(do_QueryInterface(linkContent)); + RefPtr link = HTMLLinkElement::FromContent(linkContent); if (link) { link->GetHref(aHRef); } @@ -101,15 +98,12 @@ nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef) if (!content) { break; } - content->GetLocalName(localName); - ToLowerCase(localName); - if (localName.EqualsLiteral("a")) { + if (content->IsHTMLElement(nsGkAtoms::a)) { bool hasAttr; - content->HasAttribute(NS_LITERAL_STRING("href"), &hasAttr); + hasAttr = content->HasAttr(kNameSpaceID_None, nsGkAtoms::href); if (hasAttr) { linkContent = content; - nsCOMPtr anchor( - do_QueryInterface(linkContent)); + RefPtr anchor = HTMLAnchorElement::FromContent(linkContent); if (anchor) { anchor->GetHref(aHRef); } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 28976c0b8f47..cc346561b582 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -135,7 +135,6 @@ #include "nsStreamUtils.h" #include "nsIController.h" #include "nsPICommandUpdater.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsIWebBrowserChrome3.h" #include "nsITabChild.h" #include "nsISiteSecurityService.h" @@ -14423,7 +14422,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent, // If this is an anchor element, grab its type property to use as a hint nsAutoString typeHint; - nsCOMPtr anchor(do_QueryInterface(aContent)); + RefPtr anchor = HTMLAnchorElement::FromContent(aContent); if (anchor) { anchor->GetType(typeHint); NS_ConvertUTF16toUTF8 utf8Hint(typeHint); diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index dcf1d3dde73b..ed7f61db1a50 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -25,7 +25,6 @@ #include "nsIDOMRange.h" #include "nsIFormControl.h" #include "nsIDOMHTMLAreaElement.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsITransferable.h" #include "nsComponentManagerUtils.h" #include "nsXPCOM.h" @@ -57,6 +56,7 @@ #include "TabParent.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLAreaElement.h" +#include "mozilla/dom/HTMLAnchorElement.h" #include "nsVariant.h" using namespace mozilla::dom; @@ -474,9 +474,7 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer, draggedNode = mTarget; } - nsCOMPtr area; // client-side image map nsCOMPtr image; - nsCOMPtr link; nsCOMPtr selectedImageOrLinkNode; GetDraggableSelectionData(selection, mSelectionTargetNode, @@ -501,19 +499,16 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer, *aCanDrag = false; return NS_OK; } - - area = do_QueryInterface(draggedNode); image = do_QueryInterface(draggedNode); - link = do_QueryInterface(draggedNode); } { // set for linked images, and links nsCOMPtr linkNode; - if (area) { + RefPtr areaElem = HTMLAreaElement::FromContentOrNull(draggedNode); + if (areaElem) { // use the alt text (or, if missing, the href) as the title - HTMLAreaElement* areaElem = static_cast(area.get()); areaElem->GetAttribute(NS_LITERAL_STRING("alt"), mTitleString); if (mTitleString.IsEmpty()) { // this can be a relative link @@ -638,9 +633,9 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer, nodeToSerialize = do_QueryInterface(draggedNode); } dragNode = nodeToSerialize; - } else if (link) { + } else if (draggedNode && draggedNode->IsHTMLElement(nsGkAtoms::a)) { // set linkNode. The code below will handle this - linkNode = do_QueryInterface(link); // XXX test this + linkNode = do_QueryInterface(draggedNode); // XXX test this GetNodeString(draggedNode, mTitleString); } else if (parentLink) { // parentLink will always be null if there's selected content diff --git a/dom/html/HTMLAnchorElement.cpp b/dom/html/HTMLAnchorElement.cpp index c411ecb7d7da..7b20e2a3ae0e 100644 --- a/dom/html/HTMLAnchorElement.cpp +++ b/dom/html/HTMLAnchorElement.cpp @@ -58,10 +58,13 @@ HTMLAnchorElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const nsGenericHTMLElement::IsInteractiveHTMLContent(aIgnoreTabindex); } -NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLAnchorElement, - nsGenericHTMLElement, - nsIDOMHTMLAnchorElement, - Link) +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLAnchorElement) + NS_INTERFACE_TABLE_INHERITED(HTMLAnchorElement, + Link) +NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLElement) + +NS_IMPL_ADDREF_INHERITED(HTMLAnchorElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLAnchorElement, Element) NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLAnchorElement) @@ -83,17 +86,6 @@ HTMLAnchorElement::WrapNode(JSContext *aCx, JS::Handle aGivenProto) return HTMLAnchorElementBinding::Wrap(aCx, this, aGivenProto); } -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Charset, charset) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Coords, coords) -NS_IMPL_URI_ATTR(HTMLAnchorElement, Href, href) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Hreflang, hreflang) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Name, name) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Rel, rel) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Rev, rev) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Shape, shape) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Type, type) -NS_IMPL_STRING_ATTR(HTMLAnchorElement, Download, download) - int32_t HTMLAnchorElement::TabIndexDefault() { @@ -268,19 +260,12 @@ HTMLAnchorElement::GetLinkTarget(nsAString& aTarget) } } -NS_IMETHODIMP +void HTMLAnchorElement::GetTarget(nsAString& aValue) { if (!GetAttr(kNameSpaceID_None, nsGkAtoms::target, aValue)) { GetBaseTarget(aValue); } - return NS_OK; -} - -NS_IMETHODIMP -HTMLAnchorElement::SetTarget(const nsAString& aValue) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::target, aValue, true); } nsDOMTokenList* @@ -292,64 +277,26 @@ HTMLAnchorElement::RelList() return mRelList; } -#define IMPL_URI_PART(_part) \ - NS_IMETHODIMP \ - HTMLAnchorElement::Get##_part(nsAString& a##_part) \ - { \ - Link::Get##_part(a##_part); \ - return NS_OK; \ - } \ - NS_IMETHODIMP \ - HTMLAnchorElement::Set##_part(const nsAString& a##_part) \ - { \ - Link::Set##_part(a##_part); \ - return NS_OK; \ - } - -IMPL_URI_PART(Protocol) -IMPL_URI_PART(Host) -IMPL_URI_PART(Hostname) -IMPL_URI_PART(Pathname) -IMPL_URI_PART(Search) -IMPL_URI_PART(Port) -IMPL_URI_PART(Hash) - -#undef IMPL_URI_PART - -NS_IMETHODIMP -HTMLAnchorElement::GetText(nsAString& aText) +void +HTMLAnchorElement::GetText(nsAString& aText, mozilla::ErrorResult& aRv) { - if(!nsContentUtils::GetNodeTextContent(this, true, aText, fallible)) { - return NS_ERROR_OUT_OF_MEMORY; + if (NS_WARN_IF(!nsContentUtils::GetNodeTextContent(this, true, aText, fallible))) { + aRv.Throw(NS_ERROR_OUT_OF_MEMORY); } - return NS_OK; } -NS_IMETHODIMP -HTMLAnchorElement::SetText(const nsAString& aText) +void +HTMLAnchorElement::SetText(const nsAString& aText, ErrorResult& aRv) { - return nsContentUtils::SetNodeTextContent(this, aText, false); + aRv = nsContentUtils::SetNodeTextContent(this, aText, false); } -NS_IMETHODIMP +void HTMLAnchorElement::ToString(nsAString& aSource) { return GetHref(aSource); } -NS_IMETHODIMP -HTMLAnchorElement::GetPing(nsAString& aValue) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::ping, aValue); - return NS_OK; -} - -NS_IMETHODIMP -HTMLAnchorElement::SetPing(const nsAString& aValue) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::ping, aValue, true); -} - already_AddRefed HTMLAnchorElement::GetHrefURI() const { diff --git a/dom/html/HTMLAnchorElement.h b/dom/html/HTMLAnchorElement.h index b6af1180c14a..e26bb14563e3 100644 --- a/dom/html/HTMLAnchorElement.h +++ b/dom/html/HTMLAnchorElement.h @@ -10,7 +10,6 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/Link.h" #include "nsGenericHTMLElement.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsDOMTokenList.h" namespace mozilla { @@ -19,7 +18,6 @@ class EventChainPreVisitor; namespace dom { class HTMLAnchorElement final : public nsGenericHTMLElement, - public nsIDOMHTMLAnchorElement, public Link { public: @@ -39,15 +37,15 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAnchorElement, nsGenericHTMLElement) + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLAnchorElement, a); + virtual int32_t TabIndexDefault() override; virtual bool Draggable() const override; // Element virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override; - // nsIDOMHTMLAnchorElement - NS_DECL_NSIDOMHTMLANCHORELEMENT - + // DOM memory reporter participant NS_DECL_ADDSIZEOFEXCLUDINGTHIS virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, @@ -84,12 +82,15 @@ public: // WebIDL API - // The XPCOM GetHref is OK for us + void GetHref(nsAString& aValue) + { + GetURIAttr(nsGkAtoms::href, nullptr, aValue); + } void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::href, aValue, rv); } - // The XPCOM GetTarget is OK for us + void GetTarget(nsAString& aValue); void SetTarget(const nsAString& aValue, mozilla::ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::target, aValue, rv); @@ -102,7 +103,10 @@ public: { SetHTMLAttr(nsGkAtoms::download, aValue, rv); } - // The XPCOM GetPing is OK for us + void GetPing(DOMString& aValue) + { + GetHTMLAttr(nsGkAtoms::ping, aValue); + } void SetPing(const nsAString& aValue, mozilla::ErrorResult& rv) { SetHTMLAttr(nsGkAtoms::ping, aValue, rv); @@ -119,9 +123,9 @@ public: { SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv); } - void GetReferrerPolicy(nsAString& aReferrer) + void GetReferrerPolicy(DOMString& aPolicy) { - GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer); + GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aPolicy); } nsDOMTokenList* RelList(); void GetHreflang(DOMString& aValue) @@ -132,6 +136,11 @@ public: { SetHTMLAttr(nsGkAtoms::hreflang, aValue, rv); } + // Needed for docshell + void GetType(nsAString& aValue) + { + GetHTMLAttr(nsGkAtoms::type, aValue); + } void GetType(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); @@ -140,11 +149,8 @@ public: { SetHTMLAttr(nsGkAtoms::type, aValue, rv); } - // The XPCOM GetText is OK for us - void SetText(const nsAString& aValue, mozilla::ErrorResult& rv) - { - rv = SetText(aValue); - } + void GetText(nsAString& aValue, mozilla::ErrorResult& rv); + void SetText(const nsAString& aValue, mozilla::ErrorResult& rv); // Link::GetOrigin is OK for us @@ -175,7 +181,6 @@ public: // Link::Link::GetHash is OK for us // Link::Link::SetHash is OK for us - // The XPCOM URI decomposition attributes are fine for us void GetCoords(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::coords, aValue); @@ -220,6 +225,7 @@ public: { GetHref(aResult); } + void ToString(nsAString& aSource); virtual void NodeInfoChanged(nsIDocument* aOldDoc) final override { diff --git a/dom/html/HTMLAreaElement.h b/dom/html/HTMLAreaElement.h index 47d1a962d37d..df811112bc2e 100644 --- a/dom/html/HTMLAreaElement.h +++ b/dom/html/HTMLAreaElement.h @@ -42,6 +42,7 @@ public: // nsIDOMHTMLAreaElement NS_DECL_NSIDOMHTMLAREAELEMENT + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLAreaElement, area); virtual nsresult GetEventTargetParent( EventChainPreVisitor& aVisitor) override; diff --git a/dom/html/HTMLLinkElement.h b/dom/html/HTMLLinkElement.h index 3ee187856812..c8ec652b68d4 100644 --- a/dom/html/HTMLLinkElement.h +++ b/dom/html/HTMLLinkElement.h @@ -35,7 +35,7 @@ public: // nsIDOMHTMLLinkElement NS_DECL_NSIDOMHTMLLINKELEMENT - + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLLinkElement, link); NS_DECL_ADDSIZEOFEXCLUDINGTHIS void LinkAdded(); diff --git a/dom/interfaces/html/moz.build b/dom/interfaces/html/moz.build index bbbe3b191b3c..f670c33357be 100644 --- a/dom/interfaces/html/moz.build +++ b/dom/interfaces/html/moz.build @@ -8,7 +8,6 @@ with Files("**"): BUG_COMPONENT = ("Core", "DOM") XPIDL_SOURCES += [ - 'nsIDOMHTMLAnchorElement.idl', 'nsIDOMHTMLAreaElement.idl', 'nsIDOMHTMLBaseElement.idl', 'nsIDOMHTMLButtonElement.idl', diff --git a/dom/interfaces/html/nsIDOMHTMLAnchorElement.idl b/dom/interfaces/html/nsIDOMHTMLAnchorElement.idl deleted file mode 100644 index 8a38cdf95108..000000000000 --- a/dom/interfaces/html/nsIDOMHTMLAnchorElement.idl +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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/. */ - -#include "nsIDOMHTMLElement.idl" - -/** - * The nsIDOMHTMLAnchorElement interface is the interface to a [X]HTML - * a element. - * - * This interface is trying to follow the DOM Level 2 HTML specification: - * http://www.w3.org/TR/DOM-Level-2-HTML/ - * - * with changes from the work-in-progress WHATWG HTML specification: - * http://www.whatwg.org/specs/web-apps/current-work/ - */ - -[uuid(339c01c8-2d41-4626-b231-eec63f0241b6)] -interface nsIDOMHTMLAnchorElement : nsISupports -{ - attribute DOMString href; - attribute DOMString target; - - attribute DOMString ping; - attribute DOMString download; - - attribute DOMString rel; - attribute DOMString hreflang; - attribute DOMString type; - - /** - * An alias for the textContent attribute. - */ - [Null(Stringify)] - attribute DOMString text; - - // URL decomposition IDL attributes - attribute DOMString protocol; - attribute DOMString host; - attribute DOMString hostname; - attribute DOMString port; - attribute DOMString pathname; - attribute DOMString search; - attribute DOMString hash; - - - attribute DOMString charset; - attribute DOMString coords; - attribute DOMString name; - attribute DOMString rev; - attribute DOMString shape; - - DOMString toString(); -}; diff --git a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp index e4a48931fc24..76bd01a67f78 100644 --- a/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp +++ b/dom/webbrowserpersist/WebBrowserPersistLocalDocument.cpp @@ -6,6 +6,7 @@ #include "WebBrowserPersistLocalDocument.h" #include "WebBrowserPersistDocumentParent.h" +#include "mozilla/dom/HTMLAnchorElement.h" #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLObjectElement.h" #include "mozilla/dom/HTMLSharedElement.h" @@ -20,7 +21,6 @@ #include "nsIDOMAttr.h" #include "nsIDOMComment.h" #include "nsIDOMDocument.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLAreaElement.h" #include "nsIDOMHTMLBaseElement.h" #include "nsIDOMHTMLCollection.h" @@ -941,7 +941,7 @@ PersistNodeFixup::FixupNode(nsIDOMNode *aNodeIn, } // Fix up href and file links in the elements - nsCOMPtr nodeAsAnchor = do_QueryInterface(aNodeIn); + RefPtr nodeAsAnchor = dom::HTMLAnchorElement::FromContent(content); if (nodeAsAnchor) { rv = GetNodeToFixup(aNodeIn, aNodeOut); if (NS_SUCCEEDED(rv) && *aNodeOut) { diff --git a/dom/webidl/HTMLAnchorElement.webidl b/dom/webidl/HTMLAnchorElement.webidl index 030da8963bc8..fe1c1a71c226 100644 --- a/dom/webidl/HTMLAnchorElement.webidl +++ b/dom/webidl/HTMLAnchorElement.webidl @@ -31,7 +31,7 @@ interface HTMLAnchorElement : HTMLElement { [CEReactions, SetterThrows] attribute DOMString type; - [CEReactions, SetterThrows] + [CEReactions, Throws] attribute DOMString text; }; diff --git a/editor/libeditor/HTMLEditUtils.cpp b/editor/libeditor/HTMLEditUtils.cpp index 39bcd8040658..108ce7c5a376 100644 --- a/editor/libeditor/HTMLEditUtils.cpp +++ b/editor/libeditor/HTMLEditUtils.cpp @@ -18,11 +18,11 @@ #include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::a, etc. #include "nsHTMLTags.h" #include "nsIAtom.h" // for nsIAtom -#include "nsIDOMHTMLAnchorElement.h" // for nsIDOMHTMLAnchorElement #include "nsIDOMNode.h" // for nsIDOMNode #include "nsNameSpaceManager.h" // for kNameSpaceID_None #include "nsLiteralString.h" // for NS_LITERAL_STRING #include "nsString.h" // for nsAutoString +#include "mozilla/dom/HTMLAnchorElement.h" namespace mozilla { @@ -336,14 +336,18 @@ HTMLEditUtils::IsLink(nsINode* aNode) { MOZ_ASSERT(aNode); - nsCOMPtr anchor = do_QueryInterface(aNode); - if (anchor) { - nsAutoString tmpText; - if (NS_SUCCEEDED(anchor->GetHref(tmpText)) && !tmpText.IsEmpty()) { - return true; - } + if (!aNode->IsContent()) { + return false; } - return false; + + RefPtr anchor = HTMLAnchorElement::FromContentOrNull(aNode->AsContent()); + if (!anchor) { + return false; + } + + nsAutoString tmpText; + anchor->GetHref(tmpText); + return !tmpText.IsEmpty(); } bool diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 691d7afb1b36..20fb377e9dcb 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -27,7 +27,6 @@ #include "nsIDocumentInlines.h" #include "nsIDOMEventTarget.h" #include "nsIDOMMouseEvent.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsISelectionController.h" #include "nsIDOMHTMLDocument.h" #include "nsILinkHandler.h" @@ -2594,19 +2593,21 @@ HTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) return NS_OK; } + // Be sure we were given an anchor element - nsCOMPtr anchor = do_QueryInterface(aAnchorElement); + nsCOMPtr content = do_QueryInterface(aAnchorElement); + RefPtr anchor = HTMLAnchorElement::FromContentOrNull(content); if (!anchor) { return NS_OK; } nsAutoString href; - nsresult rv = anchor->GetHref(href); - NS_ENSURE_SUCCESS(rv, rv); + anchor->GetHref(href); if (href.IsEmpty()) { return NS_OK; } + nsresult rv; AutoPlaceholderBatch beginBatching(this); // Set all attributes found on the supplied anchor element diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp index 42f7a0f2226d..3574a4e6974c 100644 --- a/editor/libeditor/HTMLEditorDataTransfer.cpp +++ b/editor/libeditor/HTMLEditorDataTransfer.cpp @@ -39,7 +39,6 @@ #include "nsIDOMDocument.h" #include "nsIDOMDocumentFragment.h" #include "nsIDOMElement.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLFrameElement.h" #include "nsIDOMHTMLIFrameElement.h" #include "nsIDOMHTMLImageElement.h" diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 2a4797cf9bbc..9a3801908ce6 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -43,7 +43,6 @@ #include "nsNetUtil.h" #include "nsNetCID.h" #include "nsCSSRendering.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsNameSpaceManager.h" #include #ifdef ACCESSIBILITY @@ -81,6 +80,7 @@ #include "mozilla/dom/Link.h" #include "SVGImageContext.h" +#include "mozilla/dom/HTMLAnchorElement.h" using namespace mozilla; using namespace mozilla::dom; @@ -1993,7 +1993,7 @@ nsImageFrame::GetAnchorHREFTargetAndNode(nsIURI** aHref, nsString& aTarget, } status = (*aHref != nullptr); - nsCOMPtr anchor(do_QueryInterface(content)); + RefPtr anchor = HTMLAnchorElement::FromContent(content); if (anchor) { anchor->GetTarget(aTarget); } diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 22c7c2518be1..6e5310beec9a 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -104,7 +104,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsILayoutHistoryState.h" #include "nsFrameManager.h" #include "mozilla/ReflowInput.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLAreaElement.h" #include "nsIDOMHTMLLinkElement.h" #include "nsIDOMHTMLImageElement.h" diff --git a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp index d7433bda9705..10a3261e2cb2 100644 --- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp +++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp @@ -45,7 +45,6 @@ #include "nsIDOMFormData.h" #include "nsIDOMGeoPositionError.h" #include "nsIDOMHistory.h" -#include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLAreaElement.h" #include "nsIDOMHTMLBaseElement.h" #include "nsIDOMHTMLButtonElement.h" @@ -321,7 +320,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] = DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIFrameLoader, FrameLoader), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMGeoPositionError, PositionError), DEFINE_SHIM(History), - DEFINE_SHIM(HTMLAnchorElement), DEFINE_SHIM(HTMLAreaElement), DEFINE_SHIM(HTMLBaseElement), DEFINE_SHIM(HTMLButtonElement), From 2fa17bd6be64ffcfcf349402fe6454bb9e2ed066 Mon Sep 17 00:00:00 2001 From: Chris AtLee Date: Wed, 13 Sep 2017 09:52:26 -0400 Subject: [PATCH 04/34] Bug 1378153 - Add 'a2' to aurora/devedition branding's firstrun page. r=jcristau MozReview-Commit-ID: 8OX4DTO8ofX --HG-- extra : source : 0ac518ed9fa167c2005fed16b6d20576f96d6978 extra : intermediate-source : 754d3df0517d5c374ac2b1515fab3621892c327d --- browser/branding/aurora/pref/firefox-branding.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/branding/aurora/pref/firefox-branding.js b/browser/branding/aurora/pref/firefox-branding.js index df0d1613ebed..bfd29a3c4cde 100644 --- a/browser/branding/aurora/pref/firefox-branding.js +++ b/browser/branding/aurora/pref/firefox-branding.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ pref("startup.homepage_override_url", ""); -pref("startup.homepage_welcome_url", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%/firstrun/"); +pref("startup.homepage_welcome_url", "https://www.mozilla.org/%LOCALE%/firefox/%VERSION%a2/firstrun/"); pref("startup.homepage_welcome_url.additional", ""); // The time interval between checks for a new version (in seconds) pref("app.update.interval", 28800); // 8 hours From 4ec1fd3ea99aa61b9cee700f15ceee7fa7f6ea23 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 25 Sep 2017 23:32:00 -0400 Subject: [PATCH 05/34] Bug 1253487 - Remove the explicit HTTP version from curl.js. r=jryans - it generated a string that isn't a curl option - curl is sometimes built without HTTP/2 support so insisting on a fixed version limits the use of the command line - curl built with HTTP/2 support will already by itself attempt to use HTTP/2 by default over HTTPS (similar to Firefox itself) --- devtools/client/shared/curl.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/devtools/client/shared/curl.js b/devtools/client/shared/curl.js index 73e33ebc06db..82db2a7483e1 100644 --- a/devtools/client/shared/curl.js +++ b/devtools/client/shared/curl.js @@ -106,11 +106,6 @@ const Curl = { command.push("-I"); } - // Add http version. - if (data.httpVersion && data.httpVersion != DEFAULT_HTTP_VERSION) { - command.push("--" + data.httpVersion.split("/")[1]); - } - // Add request headers. let headers = data.headers; if (multipartRequest) { From 843826e56cb31c5df951d2fe0e1bf3a0bcdb3b1a Mon Sep 17 00:00:00 2001 From: John Dai Date: Tue, 26 Sep 2017 06:00:00 -0400 Subject: [PATCH 06/34] Bug 1319342 - Clone a node should enqueue an upgrade reaction. r=smaug --- dom/base/nsNodeUtils.cpp | 28 ++++++++-- .../mochitest/webcomponents/mochitest.ini | 1 - .../test_custom_element_clone_callbacks.html | 54 ------------------- testing/web-platform/meta/MANIFEST.json | 2 +- .../custom-elements/reaction-timing.html.ini | 5 -- .../reactions/Document.html.ini | 3 -- .../upgrading/Node-cloneNode.html.ini | 14 ----- .../meta/dom/nodes/Node-cloneNode.html.ini | 14 ----- 8 files changed, 24 insertions(+), 97 deletions(-) delete mode 100644 dom/tests/mochitest/webcomponents/test_custom_element_clone_callbacks.html delete mode 100644 testing/web-platform/meta/custom-elements/reaction-timing.html.ini delete mode 100644 testing/web-platform/meta/custom-elements/upgrading/Node-cloneNode.html.ini delete mode 100644 testing/web-platform/meta/dom/nodes/Node-cloneNode.html.ini diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index 319f1c5b0fd7..1e41ced8d3f3 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -477,19 +477,37 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, return nullptr; } - if (clone->IsElement()) { + if (clone->IsElement() && CustomElementRegistry::IsCustomElementEnabled()) { // The cloned node may be a custom element that may require - // enqueing created callback and prototype swizzling. + // enqueing upgrade reaction. Element* elem = clone->AsElement(); - if (nsContentUtils::IsCustomElementName(nodeInfo->NameAtom())) { - nsContentUtils::SetupCustomElement(elem); + CustomElementDefinition* definition = nullptr; + nsCOMPtr tagAtom = nodeInfo->NameAtom(); + if (nsContentUtils::IsCustomElementName(tagAtom)) { + definition = + nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(), + nodeInfo->LocalName(), + nodeInfo->NamespaceID()); + if (definition) { + elem->SetCustomElementData(new CustomElementData(tagAtom)); + nsContentUtils::EnqueueUpgradeReaction(elem, definition); + } } else { // Check if node may be custom element by type extension. // ex.