Bug 1415716 - Remove nsIDOMHTMLOptionElement; r=bz

MozReview-Commit-ID: JGxQxeFBQlO

--HG--
extra : rebase_source : 86c8b72862e84f17920d45b375c0db704ebe2eb3
This commit is contained in:
Kyle Machulis 2017-11-08 17:43:09 -08:00
Родитель 21292875e7
Коммит dacb51138d
11 изменённых файлов: 64 добавлений и 174 удалений

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

@ -49,19 +49,10 @@ HTMLOptionElement::~HTMLOptionElement()
{
}
NS_IMPL_ISUPPORTS_INHERITED(HTMLOptionElement, nsGenericHTMLElement,
nsIDOMHTMLOptionElement)
NS_IMPL_ISUPPORTS_INHERITED0(HTMLOptionElement, nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLOptionElement)
NS_IMETHODIMP
HTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
{
NS_IF_ADDREF(*aForm = GetForm());
return NS_OK;
}
mozilla::dom::HTMLFormElement*
HTMLOptionElement::GetForm()
{
@ -115,15 +106,7 @@ HTMLOptionElement::UpdateDisabledState(bool aNotify)
}
}
NS_IMETHODIMP
HTMLOptionElement::GetSelected(bool* aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
*aValue = Selected();
return NS_OK;
}
NS_IMETHODIMP
void
HTMLOptionElement::SetSelected(bool aValue)
{
// Note: The select content obj maintains all the PresState
@ -141,21 +124,6 @@ HTMLOptionElement::SetSelected(bool aValue)
} else {
SetSelectedInternal(aValue, true);
}
return NS_OK;
}
NS_IMPL_BOOL_ATTR(HTMLOptionElement, DefaultSelected, selected)
// GetText returns a whitespace compressed .textContent value.
NS_IMPL_STRING_ATTR_WITH_FALLBACK(HTMLOptionElement, Label, label, GetText)
NS_IMPL_STRING_ATTR_WITH_FALLBACK(HTMLOptionElement, Value, value, GetText)
NS_IMPL_BOOL_ATTR(HTMLOptionElement, Disabled, disabled)
NS_IMETHODIMP
HTMLOptionElement::GetIndex(int32_t* aIndex)
{
*aIndex = Index();
return NS_OK;
}
int32_t
@ -179,18 +147,6 @@ HTMLOptionElement::Index()
return index;
}
bool
HTMLOptionElement::Selected() const
{
return mIsSelected;
}
bool
HTMLOptionElement::DefaultSelected() const
{
return HasAttr(kNameSpaceID_None, nsGkAtoms::selected);
}
nsChangeHint
HTMLOptionElement::GetAttributeChangeHint(const nsAtom* aAttribute,
int32_t aModType) const
@ -288,7 +244,7 @@ HTMLOptionElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
aValue, aOldValue, aSubjectPrincipal, aNotify);
}
NS_IMETHODIMP
void
HTMLOptionElement::GetText(nsAString& aText)
{
nsAutoString text;
@ -310,14 +266,12 @@ HTMLOptionElement::GetText(nsAString& aText)
// XXX No CompressWhitespace for nsAString. Sad.
text.CompressWhitespace(true, true);
aText = text;
return NS_OK;
}
NS_IMETHODIMP
HTMLOptionElement::SetText(const nsAString& aText)
void
HTMLOptionElement::SetText(const nsAString& aText, ErrorResult& aRv)
{
return nsContentUtils::SetNodeTextContent(this, aText, true);
aRv = nsContentUtils::SetNodeTextContent(this, aText, true);
}
nsresult
@ -435,11 +389,7 @@ HTMLOptionElement::Option(const GlobalObject& aGlobal,
}
}
option->SetSelected(aSelected, aError);
if (aError.Failed()) {
return nullptr;
}
option->SetSelected(aSelected);
option->SetSelectedChanged(false);
return option.forget();

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

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h"
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLOptionElement.h"
#include "mozilla/dom/HTMLFormElement.h"
namespace mozilla {
@ -17,8 +16,7 @@ namespace dom {
class HTMLSelectElement;
class HTMLOptionElement final : public nsGenericHTMLElement,
public nsIDOMHTMLOptionElement
class HTMLOptionElement final : public nsGenericHTMLElement
{
public:
explicit HTMLOptionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
@ -36,13 +34,15 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMHTMLOptionElement
using mozilla::dom::Element::SetText;
using mozilla::dom::Element::GetText;
NS_DECL_NSIDOMHTMLOPTIONELEMENT
bool Selected() const;
bool DefaultSelected() const;
bool Selected() const
{
return mIsSelected;
}
void SetSelected(bool aValue);
void SetSelectedChanged(bool aValue)
{
@ -106,35 +106,39 @@ public:
HTMLFormElement* GetForm();
// The XPCOM GetLabel is OK for us
void GetLabel(DOMString& aLabel)
{
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::label, aLabel)) {
GetText(aLabel);
}
}
void SetLabel(const nsAString& aLabel, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
}
// The XPCOM DefaultSelected is OK for us
bool DefaultSelected() const
{
return HasAttr(kNameSpaceID_None, nsGkAtoms::selected);
}
void SetDefaultSelected(bool aValue, ErrorResult& aRv)
{
SetHTMLBoolAttr(nsGkAtoms::selected, aValue, aRv);
}
// The XPCOM Selected is OK for us
void SetSelected(bool aValue, ErrorResult& aRv)
void GetValue(nsAString& aValue)
{
aRv = SetSelected(aValue);
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::value, aValue)) {
GetText(aValue);
}
}
// The XPCOM GetValue is OK for us
void SetValue(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
}
// The XPCOM GetText is OK for us
void SetText(const nsAString& aValue, ErrorResult& aRv)
{
aRv = SetText(aValue);
}
void GetText(nsAString& aText);
void SetText(const nsAString& aText, ErrorResult& aRv);
int32_t Index();

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

@ -17,8 +17,6 @@
#include "nsGenericHTMLElement.h"
#include "nsTArray.h"
class nsIDOMHTMLOptionElement;
namespace mozilla {
namespace dom {

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

@ -513,7 +513,7 @@ HTMLSelectElement::GetFirstOptionIndex(nsIContent* aOptions)
int32_t listIndex = -1;
HTMLOptionElement* optElement = HTMLOptionElement::FromContent(aOptions);
if (optElement) {
GetOptionIndex(optElement, 0, true, &listIndex);
mOptions->GetOptionIndex(optElement->AsElement(), 0, true, &listIndex);
return listIndex;
}
@ -711,15 +711,6 @@ HTMLSelectElement::SetSelectedIndexInternal(int32_t aIndex, bool aNotify)
return rv;
}
NS_IMETHODIMP
HTMLSelectElement::GetOptionIndex(nsIDOMHTMLOptionElement* aOption,
int32_t aStartIndex, bool aForward,
int32_t* aIndex)
{
nsCOMPtr<nsINode> option = do_QueryInterface(aOption);
return mOptions->GetOptionIndex(option->AsElement(), aStartIndex, aForward, aIndex);
}
bool
HTMLSelectElement::IsOptionSelectedByIndex(int32_t aIndex)
{
@ -1032,8 +1023,7 @@ HTMLSelectElement::GetValue(DOMString& aValue)
return;
}
DebugOnly<nsresult> rv = option->GetValue(aValue);
MOZ_ASSERT(NS_SUCCEEDED(rv));
option->GetValue(aValue);
}
void
@ -1479,8 +1469,8 @@ HTMLSelectElement::RestoreStateTo(SelectState* aNewSelected)
HTMLOptionElement* option = Item(i);
if (option) {
nsAutoString value;
nsresult rv = option->GetValue(value);
if (NS_SUCCEEDED(rv) && aNewSelected->ContainsOption(i, value)) {
option->GetValue(value);
if (aNewSelected->ContainsOption(i, value)) {
SetOptionsSelectedByIndex(i, i, IS_SELECTED | SET_DISABLED | NOTIFY);
}
}
@ -1579,7 +1569,7 @@ HTMLSelectElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission)
}
nsString value;
MOZ_ALWAYS_SUCCEEDS(option->GetValue(value));
option->GetValue(value);
if (keyGenProcessor) {
nsString tmp(value);
@ -1659,7 +1649,7 @@ HTMLSelectElement::IsValueMissing() const
// Check for a placeholder label option, don't count it as a valid value.
if (i == 0 && !Multiple() && Size() <= 1 && option->GetParent() == this) {
nsAutoString value;
MOZ_ALWAYS_SUCCEEDS(option->GetValue(value));
option->GetValue(value);
if (value.IsEmpty()) {
continue;
}

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

@ -360,19 +360,6 @@ public:
int32_t aEndIndex,
uint32_t aOptionsMask);
/**
* Finds the index of a given option element
*
* @param aOption the option to get the index of
* @param aStartIndex the index to start looking at
* @param aForward TRUE to look forward, FALSE to look backward
* @return the option index
*/
NS_IMETHOD GetOptionIndex(nsIDOMHTMLOptionElement* aOption,
int32_t aStartIndex,
bool aForward,
int32_t* aIndex);
/**
* Called when an attribute is about to be changed
*/

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

@ -16,7 +16,6 @@ XPIDL_SOURCES += [
'nsIDOMHTMLHtmlElement.idl',
'nsIDOMHTMLInputElement.idl',
'nsIDOMHTMLMediaElement.idl',
'nsIDOMHTMLOptionElement.idl',
'nsIDOMHTMLScriptElement.idl',
'nsIDOMMozBrowserFrame.idl',
'nsIDOMTimeRanges.idl',

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

@ -1,31 +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 nsIDOMHTMLOptionElement interface is the interface to a [X]HTML
* option 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(c2b3e9ff-6b36-4158-ace3-05a9c5b8e1c1)]
interface nsIDOMHTMLOptionElement : nsISupports
{
attribute boolean disabled;
readonly attribute nsIDOMHTMLFormElement form;
attribute DOMString label;
attribute boolean defaultSelected;
attribute boolean selected;
attribute DOMString value;
attribute DOMString text;
readonly attribute long index;
};

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

@ -11,6 +11,7 @@
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLLinkElement.h"
#include "mozilla/dom/HTMLObjectElement.h"
#include "mozilla/dom/HTMLOptionElement.h"
#include "mozilla/dom/HTMLSharedElement.h"
#include "mozilla/dom/HTMLTextAreaElement.h"
#include "mozilla/dom/TabParent.h"
@ -29,7 +30,6 @@
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLMediaElement.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMHTMLScriptElement.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsIDOMNode.h"
@ -1166,14 +1166,15 @@ PersistNodeFixup::FixupNode(nsIDOMNode *aNodeIn,
return rv;
}
nsCOMPtr<nsIDOMHTMLOptionElement> nodeAsOption = do_QueryInterface(aNodeIn);
dom::HTMLOptionElement* nodeAsOption = dom::HTMLOptionElement::FromContent(content);
if (nodeAsOption) {
rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut) {
nsCOMPtr<nsIDOMHTMLOptionElement> outElt = do_QueryInterface(*aNodeOut);
bool selected;
nodeAsOption->GetSelected(&selected);
outElt->SetDefaultSelected(selected);
nsCOMPtr<nsIContent> outContent = do_QueryInterface(*aNodeOut);
dom::HTMLOptionElement* outElt = dom::HTMLOptionElement::FromContent(outContent);
bool selected = nodeAsOption->Selected();
IgnoredErrorResult ignored;
outElt->SetDefaultSelected(selected, ignored);
}
return rv;
}

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

@ -13,19 +13,18 @@
[HTMLConstructor, NamedConstructor=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)]
interface HTMLOptionElement : HTMLElement {
[CEReactions, SetterThrows]
attribute boolean disabled;
[CEReactions, SetterThrows]
attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[CEReactions, SetterThrows]
attribute DOMString label;
[CEReactions, SetterThrows]
attribute boolean defaultSelected;
[SetterThrows]
attribute boolean selected;
[CEReactions, SetterThrows]
attribute DOMString value;
[CEReactions, SetterThrows]
attribute DOMString label;
[CEReactions, SetterThrows]
attribute boolean defaultSelected;
attribute boolean selected;
[CEReactions, SetterThrows]
attribute DOMString value;
[CEReactions, SetterThrows]
attribute DOMString text;
[CEReactions, SetterThrows]
attribute DOMString text;
readonly attribute long index;
};

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

@ -10,7 +10,6 @@
#include "nsListControlFrame.h"
#include "nsCheckboxRadioFrame.h" // for COMPARE macro
#include "nsGkAtoms.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsComboboxControlFrame.h"
#include "nsIPresShell.h"
#include "nsIDOMMouseEvent.h"
@ -231,12 +230,9 @@ void nsListControlFrame::PaintFocus(DrawTarget* aDrawTarget, nsPoint aPt)
fRect += aPt;
bool lastItemIsSelected = false;
if (focusedContent) {
nsCOMPtr<nsIDOMHTMLOptionElement> domOpt =
do_QueryInterface(focusedContent);
if (domOpt) {
domOpt->GetSelected(&lastItemIsSelected);
}
HTMLOptionElement* domOpt = HTMLOptionElement::FromContentOrNull(focusedContent);
if (domOpt) {
lastItemIsSelected = domOpt->Selected();
}
// set up back stop colors and then ask L&F service for the real colors
@ -1857,7 +1853,8 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (mComboboxFrame->IsOpenInParentProcess()) {
nsCOMPtr<nsIDOMEventTarget> etarget;
aMouseEvent->GetTarget(getter_AddRefs(etarget));
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(etarget);
nsCOMPtr<nsIContent> econtent = do_QueryInterface(etarget);
HTMLOptionElement* option = HTMLOptionElement::FromContentOrNull(econtent);
if (option) {
return NS_OK;
}
@ -2453,11 +2450,11 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
}
nsAutoString text;
if (NS_FAILED(optionElement->GetText(text)) ||
!StringBeginsWith(
nsContentUtils::TrimWhitespace<
nsContentUtils::IsHTMLWhitespaceOrNBSP>(text, false),
incrementalString, nsCaseInsensitiveStringComparator())) {
optionElement->GetText(text);
if (!StringBeginsWith(
nsContentUtils::TrimWhitespace<
nsContentUtils::IsHTMLWhitespaceOrNBSP>(text, false),
incrementalString, nsCaseInsensitiveStringComparator())) {
continue;
}

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

@ -53,7 +53,6 @@
#include "nsIDOMHTMLHtmlElement.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLMediaElement.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMHTMLScriptElement.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMediaList.h"
@ -153,8 +152,6 @@
#include "mozilla/dom/HTMLHtmlElementBinding.h"
#include "mozilla/dom/HTMLInputElementBinding.h"
#include "mozilla/dom/HTMLMediaElementBinding.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
#include "mozilla/dom/HTMLOptionElementBinding.h"
#include "mozilla/dom/HTMLScriptElementBinding.h"
#include "mozilla/dom/KeyEventBinding.h"
#include "mozilla/dom/ListBoxObjectBinding.h"
@ -306,7 +303,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
DEFINE_SHIM(HTMLHtmlElement),
DEFINE_SHIM(HTMLInputElement),
DEFINE_SHIM(HTMLMediaElement),
DEFINE_SHIM(HTMLOptionElement),
DEFINE_SHIM(HTMLScriptElement),
DEFINE_SHIM(KeyEvent),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIListBoxObject, ListBoxObject),