Bug 1432944 part 11. Remove nsIDOMElement::GetAttribute. r=mccr8

MozReview-Commit-ID: 2f1vFvRdCPG
This commit is contained in:
Boris Zbarsky 2018-01-29 23:28:00 -05:00
Родитель 151487a675
Коммит e565b1fe1b
17 изменённых файлов: 100 добавлений и 90 удалений

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

@ -76,6 +76,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/EventStates.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/MouseEvents.h"
@ -789,10 +790,8 @@ Accessible::XULElmName(DocAccessible* aDocument,
nsCOMPtr<nsIDOMXULSelectControlElement> select = do_QueryInterface(aElm);
// Use label if this is not a select control element which
// uses label attribute to indicate which option is selected
if (!select) {
nsCOMPtr<nsIDOMXULElement> xulEl(do_QueryInterface(aElm));
if (xulEl)
xulEl->GetAttribute(NS_LITERAL_STRING("label"), aName);
if (!select && aElm->IsElement()) {
aElm->AsElement()->GetAttribute(NS_LITERAL_STRING("label"), aName);
}
}
}

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

@ -1116,7 +1116,7 @@ public:
void GetAttributeNames(nsTArray<nsString>& aResult);
void GetAttribute(const nsAString& aName, nsString& aReturn)
void GetAttribute(const nsAString& aName, nsAString& aReturn)
{
DOMString str;
GetAttribute(aName, str);
@ -2195,14 +2195,5 @@ _elementName::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, \
}
#define NS_FORWARD_NSIDOMELEMENT_TO_GENERIC \
typedef mozilla::dom::Element Element; \
using Element::GetAttribute; \
NS_IMETHOD GetAttribute(const nsAString& name, nsAString& _retval) final \
override \
{ \
nsString attr; \
GetAttribute(name, attr); \
_retval = attr; \
return NS_OK; \
}
typedef mozilla::dom::Element Element;
#endif // mozilla_dom_Element_h__

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

@ -542,9 +542,11 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer,
CopyUTF8toUTF16(spec, mUrlString);
}
nsCOMPtr<nsIDOMElement> imageElement(do_QueryInterface(image));
nsCOMPtr<Element> imageElement(do_QueryInterface(image));
// XXXbz Shouldn't we use the "title" attr for title? Using
// "alt" seems very wrong....
// XXXbz Also, what if this is an nsIImageLoadingContent
// that's not an <html:img>?
if (imageElement) {
imageElement->GetAttribute(NS_LITERAL_STRING("alt"), mTitleString);
}

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

@ -9899,7 +9899,8 @@ nsContentUtils::GetPresentationURL(nsIDocShell* aDocShell, nsAString& aPresentat
return;
}
topFrameElement->GetAttribute(NS_LITERAL_STRING("mozpresentation"), aPresentationUrl);
nsCOMPtr<Element> topFrameElt = do_QueryInterface(topFrameElement);
topFrameElt->GetAttribute(NS_LITERAL_STRING("mozpresentation"), aPresentationUrl);
}
/* static */ nsIDocShell*

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

@ -27,5 +27,4 @@ interface nsIDOMMozNamedAttrMap;
[uuid(6289999b-1008-4269-b42a-413ec5a9d3f4)]
interface nsIDOMElement : nsIDOMNode
{
DOMString getAttribute(in DOMString name);
};

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

@ -51,6 +51,7 @@
#include "nsIScriptElement.h"
#include "nsIEventTarget.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/Element.h"
#include "nsXULAppAPI.h"
using namespace mozilla;
@ -189,10 +190,10 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
if (!isPreload) {
if (aContentType == nsIContentPolicy::TYPE_SCRIPT ||
aContentType == nsIContentPolicy::TYPE_STYLESHEET) {
nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(aRequestContext);
if (htmlElement) {
rv = htmlElement->GetAttribute(NS_LITERAL_STRING("nonce"), nonce);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<Element> element = do_QueryInterface(aRequestContext);
if (element && element->IsHTMLElement()) {
// XXXbz What about SVG elements that can have nonce?
element->GetAttribute(NS_LITERAL_STRING("nonce"), nonce);
}
}

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

@ -360,12 +360,11 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
}
nsAutoString id;
nsCOMPtr<nsIDOMElement> element;
GetFocusedElement(getter_AddRefs(element));
nsCOMPtr<nsIDOMElement> domElement;
GetFocusedElement(getter_AddRefs(domElement));
nsCOMPtr<Element> element = do_QueryInterface(domElement);
if (element) {
nsresult rv = element->GetAttribute(NS_LITERAL_STRING("id"), id);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get element's id");
if (NS_FAILED(rv)) return rv;
element->GetAttribute(NS_LITERAL_STRING("id"), id);
}
nsCOMArray<nsIContent> updaters;

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

@ -1327,14 +1327,14 @@ EditorBase::GetAttributeValue(nsIDOMElement* aElement,
if (!aElement) {
return NS_OK;
}
nsCOMPtr<Element> element = do_QueryInterface(aElement);
nsAutoString value;
nsresult rv = aElement->GetAttribute(aAttribute, value);
NS_ENSURE_SUCCESS(rv, rv);
element->GetAttribute(aAttribute, value);
if (!DOMStringIsNull(value)) {
*aResultIsSet = true;
aResultValue = value;
}
return rv;
return NS_OK;
}
NS_IMETHODIMP

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

@ -471,7 +471,7 @@ HTMLEditor::StartResizing(nsIDOMElement* aHandle)
// the way we change the position/size of the shadow depends on
// the handle
nsAutoString locationStr;
aHandle->GetAttribute(NS_LITERAL_STRING("anonlocation"), locationStr);
mActivatedHandle->GetAttribute(NS_LITERAL_STRING("anonlocation"), locationStr);
if (locationStr.Equals(kTopLeft)) {
SetResizeIncrements(1, 1, -1, -1, preserveRatio);
} else if (locationStr.Equals(kTop)) {

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

@ -87,13 +87,14 @@ bool
TextEditUtils::HasMozAttr(nsIDOMNode* aNode)
{
MOZ_ASSERT(aNode);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
nsCOMPtr<Element> element = do_QueryInterface(aNode);
if (!element) {
return false;
}
nsAutoString typeAttrVal;
nsresult rv = element->GetAttribute(NS_LITERAL_STRING("type"), typeAttrVal);
return NS_SUCCEEDED(rv) && typeAttrVal.LowerCaseEqualsLiteral("_moz");
return element->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::type,
NS_LITERAL_STRING("_moz"),
eIgnoreCase);
}
/******************************************************************************

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

@ -36,6 +36,7 @@
#include "gfxContext.h"
#include "gfxPrefs.h"
#include "gfxUserFontSet.h"
#include "nsContentList.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
@ -3113,29 +3114,25 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
// Search for anchor in the HTML namespace with a matching name
if (!content && !htmlDoc)
{
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(mDocument);
nsCOMPtr<nsIDOMNodeList> list;
NS_NAMED_LITERAL_STRING(nameSpace, "http://www.w3.org/1999/xhtml");
// Get the list of anchor elements
rv = doc->GetElementsByTagNameNS(nameSpace, NS_LITERAL_STRING("a"), getter_AddRefs(list));
if (NS_SUCCEEDED(rv) && list) {
uint32_t i;
// Loop through the named nodes looking for the first anchor
for (i = 0; true; i++) {
nsCOMPtr<nsIDOMNode> node;
rv = list->Item(i, getter_AddRefs(node));
if (!node) { // End of list
break;
}
// Compare the name attribute
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
nsAutoString value;
if (element && NS_SUCCEEDED(element->GetAttribute(NS_LITERAL_STRING("name"), value))) {
if (value.Equals(aAnchorName)) {
content = do_QueryInterface(element);
break;
}
}
nsCOMPtr<nsINodeList> list =
mDocument->GetElementsByTagNameNS(nameSpace, NS_LITERAL_STRING("a"));
// Loop through the anchors looking for the first one with the given name.
for (uint32_t i = 0; true; i++) {
nsIContent* node = list->Item(i);
if (!node) { // End of list
break;
}
// Compare the name attribute
if (node->IsElement() &&
node->AsElement()->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::name,
aAnchorName,
eCaseMatters)) {
content = node;
break;
}
}
}

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

@ -2380,10 +2380,9 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
ds->GetChromeEventHandler(getter_AddRefs(chromeHandler));
}
if (chromeHandler) {
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(chromeHandler));
nsCOMPtr<nsIContent> content(do_QueryInterface(elt));
if (elt && content) {
nsCOMPtr<nsIURI> baseURI = content->GetBaseURI();
nsCOMPtr<Element> elt(do_QueryInterface(chromeHandler));
if (elt) {
nsCOMPtr<nsIURI> baseURI = elt->GetBaseURI();
nsAutoString sheets;
elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets);

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

@ -383,11 +383,10 @@ inDOMView::GetCellText(int32_t row, nsITreeColumn* col, nsAString& _retval)
domNode->GetNodeValue(_retval);
else {
if (StringBeginsWith(colID, NS_LITERAL_STRING("col@"))) {
nsCOMPtr<nsIDOMElement> el = do_QueryInterface(node->node);
if (el) {
if (domNode->IsElement()) {
nsAutoString attr;
colID.Right(attr, colID.Length()-4); // have to use this because Substring is crashing on me!
el->GetAttribute(attr, _retval);
domNode->AsElement()->GetAttribute(attr, _retval);
}
}
}

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

@ -13,6 +13,7 @@
#include "nsError.h"
#include "nsIXULSortService.h"
#include "nsTreeBodyFrame.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TreeContentViewBinding.h"
#include "nsServiceManagerUtils.h"
@ -247,10 +248,12 @@ void
nsTreeContentView::GetColumnProperties(nsTreeColumn& aColumn,
nsAString& aProperties)
{
nsCOMPtr<nsIDOMElement> element;
aColumn.GetElement(getter_AddRefs(element));
IgnoredErrorResult rv;
RefPtr<Element> element = aColumn.GetElement(rv);
element->GetAttribute(NS_LITERAL_STRING("properties"), aProperties);
if (element) {
element->GetAttribute(NS_LITERAL_STRING("properties"), aProperties);
}
}
NS_IMETHODIMP

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

@ -11,6 +11,27 @@
#include "mozilla/Assertions.h"
#include "mozilla/Base64.h"
#include "mozilla/Casting.h"
/* Disable the "base class should be explicitly initialized in the
copy constructor" warning that some bindings structs trigger while
including Element.h. Looks like it's an inherent part of -Wextra,
so we can't just disable it in a targeted way in moz.build. */
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wextra"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wextra"
#endif // __clang__ || __GNUC__
#include "mozilla/dom/Element.h"
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif // __clang__ || __GNUC__
#include "nsDependentString.h"
#include "nsIContent.h"
#include "nsIDOMHTMLElement.h"
@ -30,6 +51,8 @@
#include "secder.h"
#include "secdert.h"
using mozilla::dom::Element;
//These defines are taken from the PKCS#11 spec
#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000
#define CKM_DH_PKCS_KEY_PAIR_GEN 0x00000020
@ -677,24 +700,25 @@ nsKeygenFormProcessor::ExtractParams(nsIDOMHTMLElement* aElement,
nsAString& keyTypeValue,
nsAString& keyParamsValue)
{
aElement->GetAttribute(NS_LITERAL_STRING("keytype"), keyTypeValue);
nsCOMPtr<Element> element = do_QueryInterface(aElement);
element->GetAttribute(NS_LITERAL_STRING("keytype"), keyTypeValue);
if (keyTypeValue.IsEmpty()) {
// If this field is not present, we default to rsa.
keyTypeValue.AssignLiteral("rsa");
}
aElement->GetAttribute(NS_LITERAL_STRING("pqg"),
keyParamsValue);
element->GetAttribute(NS_LITERAL_STRING("pqg"),
keyParamsValue);
/* XXX We can still support the pqg attribute in the keygen
* tag for backward compatibility while introducing a more
* general attribute named keyparams.
*/
if (keyParamsValue.IsEmpty()) {
aElement->GetAttribute(NS_LITERAL_STRING("keyparams"),
keyParamsValue);
element->GetAttribute(NS_LITERAL_STRING("keyparams"),
keyParamsValue);
}
aElement->GetAttribute(NS_LITERAL_STRING("challenge"), challengeValue);
element->GetAttribute(NS_LITERAL_STRING("challenge"), challengeValue);
}
nsresult

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

@ -597,8 +597,9 @@ NSMenuItem* nsMenuBarX::CreateNativeAppMenuItem(nsMenuX* inMenu, const nsAString
return nil;
}
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc));
if (!domdoc) {
RefPtr<mozilla::dom::Element> menuItem =
doc->GetElementById(nodeID);
if (!menuItem) {
return nil;
}
@ -606,36 +607,27 @@ NSMenuItem* nsMenuBarX::CreateNativeAppMenuItem(nsMenuX* inMenu, const nsAString
nsAutoString label;
nsAutoString modifiers;
nsAutoString key;
nsCOMPtr<nsIDOMElement> menuItem;
domdoc->GetElementById(nodeID, getter_AddRefs(menuItem));
if (menuItem) {
menuItem->GetAttribute(NS_LITERAL_STRING("label"), label);
menuItem->GetAttribute(NS_LITERAL_STRING("modifiers"), modifiers);
menuItem->GetAttribute(NS_LITERAL_STRING("key"), key);
}
else {
return nil;
}
menuItem->GetAttribute(NS_LITERAL_STRING("label"), label);
menuItem->GetAttribute(NS_LITERAL_STRING("modifiers"), modifiers);
menuItem->GetAttribute(NS_LITERAL_STRING("key"), key);
// Get more information about the key equivalent. Start by
// finding the key node we need.
NSString* keyEquiv = nil;
unsigned int macKeyModifiers = 0;
if (!key.IsEmpty()) {
nsCOMPtr<nsIDOMElement> keyElement;
domdoc->GetElementById(key, getter_AddRefs(keyElement));
RefPtr<Element> keyElement = doc->GetElementById(key);
if (keyElement) {
nsCOMPtr<Element> keyContent (do_QueryInterface(keyElement));
// first grab the key equivalent character
nsAutoString keyChar(NS_LITERAL_STRING(" "));
keyContent->GetAttr(kNameSpaceID_None, nsGkAtoms::key, keyChar);
keyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::key, keyChar);
if (!keyChar.EqualsLiteral(" ")) {
keyEquiv = [[NSString stringWithCharacters:reinterpret_cast<const unichar*>(keyChar.get())
length:keyChar.Length()] lowercaseString];
}
// now grab the key equivalent modifiers
nsAutoString modifiersStr;
keyContent->GetAttr(kNameSpaceID_None, nsGkAtoms::modifiers, modifiersStr);
keyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::modifiers, modifiersStr);
uint8_t geckoModifiers = nsMenuUtilsX::GeckoModifiersForNodeAttribute(modifiersStr);
macKeyModifiers = nsMenuUtilsX::MacModifiersForGeckoModifiers(geckoModifiers);
}

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

@ -15,9 +15,12 @@
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIXULWindow.h"
#include "mozilla/dom/Element.h"
#include "nsWindowMediator.h"
using mozilla::dom::Element;
//
// static helper functions
//
@ -54,7 +57,7 @@ void GetAttribute(nsIXULWindow *inWindow, const nsAString &inAttribute,
if (inWindow && NS_SUCCEEDED(inWindow->GetDocShell(getter_AddRefs(shell)))) {
nsCOMPtr<nsIDOMNode> node(GetDOMNodeFromDocShell(shell));
if (node) {
nsCOMPtr<nsIDOMElement> webshellElement(do_QueryInterface(node));
nsCOMPtr<Element> webshellElement(do_QueryInterface(node));
if (webshellElement)
webshellElement->GetAttribute(inAttribute, outValue);
}