зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492326, use Element helper methods in dom/layout instead of QueryInterface to get interface implementations that might be implemented by custom elements, r=paolo
This commit is contained in:
Родитель
9397165b4e
Коммит
ef24d6e37e
|
@ -337,7 +337,8 @@ Element* nsFocusManager::GetRedirectedFocus(nsIContent* aContent) {
|
|||
return aContent->OwnerDoc()->GetAnonymousElementByAttribute(
|
||||
aContent, nsGkAtoms::anonid, NS_LITERAL_STRING("input"));
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMXULMenuListElement> menulist = do_QueryInterface(aContent);
|
||||
nsCOMPtr<nsIDOMXULMenuListElement> menulist =
|
||||
aContent->AsElement()->AsXULMenuList();
|
||||
if (menulist) {
|
||||
RefPtr<Element> inputField;
|
||||
menulist->GetInputField(getter_AddRefs(inputField));
|
||||
|
|
|
@ -6799,8 +6799,7 @@ void nsGlobalWindowInner::NotifyDefaultButtonLoaded(Element& aDefaultButton,
|
|||
ErrorResult& aError) {
|
||||
#ifdef MOZ_XUL
|
||||
// Don't snap to a disabled button.
|
||||
nsCOMPtr<nsIDOMXULControlElement> xulControl =
|
||||
do_QueryInterface(&aDefaultButton);
|
||||
nsCOMPtr<nsIDOMXULControlElement> xulControl = aDefaultButton.AsXULControl();
|
||||
if (!xulControl) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
|
|
|
@ -162,10 +162,6 @@
|
|||
#include "nsIXULWindow.h"
|
||||
#include "nsITimedChannel.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsIDOMXULControlElement.h"
|
||||
#include "nsMenuPopupFrame.h"
|
||||
#endif
|
||||
#include "mozilla/dom/CustomEvent.h"
|
||||
#include "nsIJARChannel.h"
|
||||
#include "nsIScreenManager.h"
|
||||
|
|
|
@ -945,7 +945,8 @@ static bool IsAccessKeyTarget(nsIContent* aContent, nsIFrame* aFrame,
|
|||
if (!aFrame->IsVisibleConsideringAncestors()) return false;
|
||||
|
||||
// XUL controls can be activated.
|
||||
nsCOMPtr<nsIDOMXULControlElement> control(do_QueryInterface(aContent));
|
||||
nsCOMPtr<nsIDOMXULControlElement> control =
|
||||
aContent->AsElement()->AsXULControl();
|
||||
if (control) return true;
|
||||
|
||||
// HTML area, label and legend elements are never focusable, so
|
||||
|
@ -3017,15 +3018,15 @@ nsresult EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
// an anonymous node of the targeted element.
|
||||
suppressBlur = (ui->mUserFocus == StyleUserFocus::Ignore);
|
||||
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aEvent->mTarget);
|
||||
if (!suppressBlur) {
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aEvent->mTarget);
|
||||
suppressBlur =
|
||||
element && element->State().HasState(NS_EVENT_STATE_DISABLED);
|
||||
}
|
||||
|
||||
if (!suppressBlur) {
|
||||
if (!suppressBlur && element) {
|
||||
nsCOMPtr<nsIDOMXULControlElement> xulControl =
|
||||
do_QueryInterface(aEvent->mTarget);
|
||||
element->AsXULControl();
|
||||
if (xulControl) {
|
||||
bool disabled;
|
||||
xulControl->GetDisabled(&disabled);
|
||||
|
|
|
@ -437,7 +437,7 @@ bool nsXULElement::IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) {
|
|||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIDOMXULControlElement> xulControl = do_QueryObject(this);
|
||||
nsCOMPtr<nsIDOMXULControlElement> xulControl = AsXULControl();
|
||||
if (xulControl) {
|
||||
// a disabled element cannot be focused and is not part of the tab order
|
||||
bool disabled;
|
||||
|
@ -543,8 +543,8 @@ bool nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
|||
nsCOMPtr<Element> elementToFocus;
|
||||
// for radio buttons, focus the radiogroup instead
|
||||
if (content->IsXULElement(nsGkAtoms::radio)) {
|
||||
nsCOMPtr<nsIDOMXULSelectControlItemElement> controlItem(
|
||||
do_QueryInterface(content));
|
||||
nsCOMPtr<nsIDOMXULSelectControlItemElement> controlItem =
|
||||
content->AsXULSelectControlItem();
|
||||
if (controlItem) {
|
||||
bool disabled;
|
||||
controlItem->GetDisabled(&disabled);
|
||||
|
|
|
@ -7899,7 +7899,7 @@ void PresShell::GetCurrentItemAndPositionForElement(
|
|||
// as is.
|
||||
nsCOMPtr<Element> item;
|
||||
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelect =
|
||||
do_QueryInterface(aFocusedElement);
|
||||
aFocusedElement->AsXULMultiSelectControl();
|
||||
if (multiSelect) {
|
||||
checkLineHeight = false;
|
||||
|
||||
|
@ -7946,10 +7946,10 @@ void PresShell::GetCurrentItemAndPositionForElement(
|
|||
} else {
|
||||
// don't check menulists as the selected item will be inside a popup.
|
||||
nsCOMPtr<nsIDOMXULMenuListElement> menulist =
|
||||
do_QueryInterface(aFocusedElement);
|
||||
aFocusedElement->AsXULMenuList();
|
||||
if (!menulist) {
|
||||
nsCOMPtr<nsIDOMXULSelectControlElement> select =
|
||||
do_QueryInterface(aFocusedElement);
|
||||
aFocusedElement->AsXULSelectControl();
|
||||
if (select) {
|
||||
checkLineHeight = false;
|
||||
select->GetSelectedItem(getter_AddRefs(item));
|
||||
|
|
|
@ -123,8 +123,9 @@ nsresult nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
break;
|
||||
}
|
||||
if (NS_VK_RETURN == keyEvent->mKeyCode) {
|
||||
nsCOMPtr<nsIDOMXULButtonElement> buttonEl(do_QueryInterface(mContent));
|
||||
if (buttonEl) {
|
||||
RefPtr<nsIDOMXULButtonElement> button =
|
||||
mContent->AsElement()->AsXULButton();
|
||||
if (button) {
|
||||
MouseClicked(aEvent);
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
|
|
@ -1107,11 +1107,14 @@ nsPoint nsMenuPopupFrame::AdjustPositionForAnchorAlign(nsRect& anchorRect,
|
|||
nsIFrame* nsMenuPopupFrame::GetSelectedItemForAlignment() {
|
||||
// This method adjusts a menulist's popup such that the selected item is under
|
||||
// the cursor, aligned with the menulist label.
|
||||
nsCOMPtr<nsIDOMXULSelectControlElement> select =
|
||||
do_QueryInterface(mAnchorContent);
|
||||
nsCOMPtr<nsIDOMXULSelectControlElement> select;
|
||||
if (mAnchorContent) {
|
||||
select = mAnchorContent->AsElement()->AsXULSelectControl();
|
||||
}
|
||||
|
||||
if (!select) {
|
||||
// If there isn't an anchor, then try just getting the parent of the popup.
|
||||
select = do_QueryInterface(mContent->GetParent());
|
||||
select = mContent->GetParent()->AsElement()->AsXULSelectControl();
|
||||
if (!select) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче