mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1434318 part 8. Remove nsIDOMDocument::GetElementById. r=mystor
MozReview-Commit-ID: IzjmFqySBpB
This commit is contained in:
parent
a514705917
commit
ede65cfa38
@ -5318,19 +5318,6 @@ nsDocument::ReportEmptyGetElementByIdArg()
|
||||
nsContentUtils::ReportEmptyGetElementByIdArg(this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetElementById(const nsAString& aId, nsIDOMElement** aReturn)
|
||||
{
|
||||
Element *content = GetElementById(aId);
|
||||
if (content) {
|
||||
return CallQueryInterface(content, aReturn);
|
||||
}
|
||||
|
||||
*aReturn = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element*
|
||||
nsDocument::AddIDTargetObserver(nsAtom* aID, IDTargetObserver aObserver,
|
||||
void* aData, bool aForImage)
|
||||
|
@ -36,8 +36,6 @@ interface nsIDOMTreeWalker;
|
||||
interface nsIDOMDocument : nsIDOMNode
|
||||
{
|
||||
readonly attribute nsIDOMDOMImplementation implementation;
|
||||
// Introduced in DOM Level 2:
|
||||
nsIDOMElement getElementById(in DOMString elementId);
|
||||
// Introduced in DOM Level 3:
|
||||
readonly attribute DOMString inputEncoding;
|
||||
// Introduced in DOM Level 3:
|
||||
|
@ -552,22 +552,20 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
nsCOMPtr<nsIContent> content(this);
|
||||
|
||||
if (IsXULElement(nsGkAtoms::label)) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
|
||||
nsAutoString control;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::control, control);
|
||||
if (!control.IsEmpty()) {
|
||||
//XXXsmaug Should we use ShadowRoot::GetElementById in case
|
||||
// content is in Shadow DOM?
|
||||
nsCOMPtr<nsIDOMDocument> domDocument =
|
||||
do_QueryInterface(content->GetUncomposedDoc());
|
||||
if (domDocument)
|
||||
domDocument->GetElementById(control, getter_AddRefs(element));
|
||||
if (control.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// here we'll either change |content| to the element referenced by
|
||||
// |element|, or clear it.
|
||||
content = do_QueryInterface(element);
|
||||
|
||||
//XXXsmaug Should we use ShadowRoot::GetElementById in case
|
||||
// content is in Shadow DOM?
|
||||
nsCOMPtr<nsIDocument> document = content->GetUncomposedDoc();
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
content = document->GetElementById(control);
|
||||
if (!content) {
|
||||
return false;
|
||||
}
|
||||
@ -1295,12 +1293,10 @@ nsXULElement::DispatchXULCommand(const EventChainVisitor& aVisitor,
|
||||
nsAutoString& aCommand)
|
||||
{
|
||||
// XXX sXBL/XBL2 issue! Owner or current document?
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(GetUncomposedDoc()));
|
||||
NS_ENSURE_STATE(domDoc);
|
||||
nsCOMPtr<nsIDOMElement> commandElt;
|
||||
domDoc->GetElementById(aCommand, getter_AddRefs(commandElt));
|
||||
nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
|
||||
if (commandContent) {
|
||||
nsCOMPtr<nsIDocument> doc = GetUncomposedDoc();
|
||||
NS_ENSURE_STATE(doc);
|
||||
RefPtr<Element> commandElt = doc->GetElementById(aCommand);
|
||||
if (commandElt) {
|
||||
// Create a new command event to dispatch to the element
|
||||
// pointed to by the command attribute. The new event's
|
||||
// sourceEvent will be the original command event that we're
|
||||
@ -1310,7 +1306,7 @@ nsXULElement::DispatchXULCommand(const EventChainVisitor& aVisitor,
|
||||
while (domEvent) {
|
||||
Event* event = domEvent->InternalDOMEvent();
|
||||
NS_ENSURE_STATE(!SameCOMIdentity(event->GetOriginalTarget(),
|
||||
commandContent));
|
||||
commandElt));
|
||||
nsCOMPtr<nsIDOMXULCommandEvent> commandEvent =
|
||||
do_QueryInterface(domEvent);
|
||||
if (commandEvent) {
|
||||
@ -1322,7 +1318,7 @@ nsXULElement::DispatchXULCommand(const EventChainVisitor& aVisitor,
|
||||
}
|
||||
WidgetInputEvent* orig = aVisitor.mEvent->AsInputEvent();
|
||||
nsContentUtils::DispatchXULCommand(
|
||||
commandContent,
|
||||
commandElt,
|
||||
orig->IsTrusted(),
|
||||
aVisitor.mDOMEvent,
|
||||
nullptr,
|
||||
|
@ -19,6 +19,7 @@ class nsMenuBarX;
|
||||
class nsMenuX;
|
||||
class nsIWidget;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -134,7 +135,7 @@ protected:
|
||||
void ConstructFallbackNativeMenus();
|
||||
nsresult InsertMenuAtIndex(nsMenuX* aMenu, uint32_t aIndex);
|
||||
void RemoveMenuAtIndex(uint32_t aIndex);
|
||||
void HideItem(nsIDOMDocument* inDoc, const nsAString & inID, nsIContent** outHiddenNode);
|
||||
void HideItem(nsIDocument* inDoc, const nsAString & inID, nsIContent** outHiddenNode);
|
||||
void AquifyMenuBar();
|
||||
NSMenuItem* CreateNativeAppMenuItem(nsMenuX* inMenu, const nsAString& nodeID, SEL action,
|
||||
int tag, NativeMenuItemTarget* target);
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsToolkitCompsCID.h"
|
||||
@ -480,14 +478,12 @@ char nsMenuBarX::GetLocalizedAccelKey(const char *shortcutID)
|
||||
if (!sLastGeckoMenuBarPainted)
|
||||
return 0;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(sLastGeckoMenuBarPainted->mContent->OwnerDoc()));
|
||||
if (!domDoc)
|
||||
nsCOMPtr<nsIDocument> doc = sLastGeckoMenuBarPainted->mContent->OwnerDoc();
|
||||
if (!doc)
|
||||
return 0;
|
||||
|
||||
NS_ConvertASCIItoUTF16 shortcutIDStr((const char *)shortcutID);
|
||||
nsCOMPtr<nsIDOMElement> shortcutElement;
|
||||
domDoc->GetElementById(shortcutIDStr, getter_AddRefs(shortcutElement));
|
||||
nsCOMPtr<Element> shortcutContent = do_QueryInterface(shortcutElement);
|
||||
NS_ConvertASCIItoUTF16 shortcutIDStr(shortcutID);
|
||||
nsCOMPtr<Element> shortcutContent = doc->GetElementById(shortcutIDStr);
|
||||
if (!shortcutContent)
|
||||
return 0;
|
||||
|
||||
@ -540,11 +536,9 @@ bool nsMenuBarX::PerformKeyEquivalent(NSEvent* theEvent)
|
||||
// Hide the item in the menu by setting the 'hidden' attribute. Returns it in |outHiddenNode| so
|
||||
// the caller can hang onto it if they so choose. It is acceptable to pass nsull
|
||||
// for |outHiddenNode| if the caller doesn't care about the hidden node.
|
||||
void nsMenuBarX::HideItem(nsIDOMDocument* inDoc, const nsAString & inID, nsIContent** outHiddenNode)
|
||||
void nsMenuBarX::HideItem(nsIDocument* inDoc, const nsAString & inID, nsIContent** outHiddenNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> menuItem;
|
||||
inDoc->GetElementById(inID, getter_AddRefs(menuItem));
|
||||
nsCOMPtr<Element> menuElement(do_QueryInterface(menuItem));
|
||||
nsCOMPtr<Element> menuElement = inDoc->GetElementById(inID);
|
||||
if (menuElement) {
|
||||
menuElement->SetAttr(kNameSpaceID_None, nsGkAtoms::hidden, NS_LITERAL_STRING("true"), false);
|
||||
if (outHiddenNode) {
|
||||
@ -557,7 +551,7 @@ void nsMenuBarX::HideItem(nsIDOMDocument* inDoc, const nsAString & inID, nsICont
|
||||
// Do what is necessary to conform to the Aqua guidelines for menus.
|
||||
void nsMenuBarX::AquifyMenuBar()
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mContent->GetComposedDoc()));
|
||||
nsCOMPtr<nsIDocument> domDoc = mContent->GetComposedDoc();
|
||||
if (domDoc) {
|
||||
// remove the "About..." item and its separator
|
||||
HideItem(domDoc, NS_LITERAL_STRING("aboutSeparator"), nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user