mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Backed out changeset 83a7ad25941e (bug 1412437) for robocop testAccessibleCarets bustage
CLOSED TREE MozReview-Commit-ID: Lg1GSdLDyin
This commit is contained in:
parent
6841cb2510
commit
4700232b13
@ -15,7 +15,7 @@
|
||||
|
||||
#include "nsContentList.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
@ -345,7 +345,7 @@ HTMLTextFieldAccessible::Value(nsString& aValue)
|
||||
if (NativeState() & states::PROTECTED) // Don't return password text!
|
||||
return;
|
||||
|
||||
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromContent(mContent);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent));
|
||||
if (textArea) {
|
||||
textArea->GetValue(aValue);
|
||||
return;
|
||||
|
@ -65,7 +65,7 @@ function test() {
|
||||
if (node instanceof Ci.nsIDOMHTMLInputElement)
|
||||
return aValue == (node.type == "checkbox" || node.type == "radio" ?
|
||||
node.checked : node.value);
|
||||
if (ChromeUtils.getClassName(node) === "HTMLTextAreaElement")
|
||||
if (node instanceof Ci.nsIDOMHTMLTextAreaElement)
|
||||
return aValue == node.value;
|
||||
if (!node.multiple)
|
||||
return aValue == node.selectedIndex;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
|
@ -172,7 +172,6 @@
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/HTMLIFrameElement.h"
|
||||
#include "mozilla/dom/HTMLImageElement.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include "mozilla/dom/MediaSource.h"
|
||||
#include "mozilla/dom/FlyWebService.h"
|
||||
|
||||
@ -231,6 +230,7 @@
|
||||
#include "mozilla/ExtensionPolicyService.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsDOMCaretPosition.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsViewportInfo.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsITextControlElement.h"
|
||||
@ -10951,7 +10951,7 @@ nsIDocument::CaretPositionFromPoint(float aX, float aY)
|
||||
if (nodeIsAnonymous) {
|
||||
node = ptFrame->GetContent();
|
||||
nsIContent* nonanon = node->FindFirstNonChromeOnlyAccessContent();
|
||||
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromContent(nonanon);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(nonanon);
|
||||
nsITextControlFrame* textFrame = do_QueryFrame(nonanon->GetPrimaryFrame());
|
||||
nsNumberControlFrame* numberFrame = do_QueryFrame(nonanon->GetPrimaryFrame());
|
||||
if (textFrame || numberFrame) {
|
||||
|
@ -19,12 +19,12 @@
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsIController.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULElement.h"
|
||||
@ -234,8 +234,8 @@ nsWindowRoot::GetControllers(bool aForVisibleWindow,
|
||||
}
|
||||
#endif
|
||||
|
||||
HTMLTextAreaElement* htmlTextArea =
|
||||
HTMLTextAreaElement::FromContent(focusedContent);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> htmlTextArea =
|
||||
do_QueryInterface(focusedContent);
|
||||
if (htmlTextArea)
|
||||
return htmlTextArea->GetControllers(aResult);
|
||||
|
||||
|
@ -86,6 +86,7 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLTextAreaElement,
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLTextAreaElement,
|
||||
nsGenericHTMLFormElementWithState,
|
||||
nsIDOMHTMLTextAreaElement,
|
||||
nsITextControlElement,
|
||||
nsIDOMNSEditableElement,
|
||||
nsIMutationObserver,
|
||||
@ -120,9 +121,16 @@ HTMLTextAreaElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
||||
{
|
||||
return nsGenericHTMLFormElementWithState::GetForm(aForm);
|
||||
}
|
||||
|
||||
|
||||
// nsIContent
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::Select()
|
||||
{
|
||||
// XXX Bug? We have to give the input focus before contents can be
|
||||
@ -130,7 +138,7 @@ HTMLTextAreaElement::Select()
|
||||
|
||||
FocusTristate state = FocusState();
|
||||
if (state == eUnfocusable) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
@ -140,7 +148,7 @@ HTMLTextAreaElement::Select()
|
||||
if (fm)
|
||||
fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL);
|
||||
SelectAll(presContext);
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
@ -164,6 +172,8 @@ HTMLTextAreaElement::Select()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -193,19 +203,33 @@ HTMLTextAreaElement::IsHTMLFocusable(bool aWithMouse,
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, Autofocus, autofocus)
|
||||
NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(HTMLTextAreaElement, Cols, cols, DEFAULT_COLS)
|
||||
NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, Disabled, disabled)
|
||||
NS_IMPL_NON_NEGATIVE_INT_ATTR(HTMLTextAreaElement, MaxLength, maxlength)
|
||||
NS_IMPL_NON_NEGATIVE_INT_ATTR(HTMLTextAreaElement, MinLength, minlength)
|
||||
NS_IMPL_STRING_ATTR(HTMLTextAreaElement, Name, name)
|
||||
NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, ReadOnly, readonly)
|
||||
NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, Required, required)
|
||||
NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(HTMLTextAreaElement, Rows, rows, DEFAULT_ROWS_TEXTAREA)
|
||||
NS_IMPL_STRING_ATTR(HTMLTextAreaElement, Wrap, wrap)
|
||||
NS_IMPL_STRING_ATTR(HTMLTextAreaElement, Placeholder, placeholder)
|
||||
|
||||
int32_t
|
||||
HTMLTextAreaElement::TabIndexDefault()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetType(nsAString& aType)
|
||||
{
|
||||
aType.AssignLiteral("textarea");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetValue(nsAString& aValue)
|
||||
{
|
||||
nsAutoString value;
|
||||
@ -215,6 +239,7 @@ HTMLTextAreaElement::GetValue(nsAString& aValue)
|
||||
nsContentUtils::PlatformToDOMLineBreaks(value);
|
||||
|
||||
aValue = value;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -346,8 +371,8 @@ HTMLTextAreaElement::SetValueInternal(const nsAString& aValue,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::SetValue(const nsAString& aValue, ErrorResult& aError)
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetValue(const nsAString& aValue)
|
||||
{
|
||||
// If the value has been set by a script, we basically want to keep the
|
||||
// current change event state. If the element is ready to fire a change
|
||||
@ -364,14 +389,13 @@ HTMLTextAreaElement::SetValue(const nsAString& aValue, ErrorResult& aError)
|
||||
nsTextEditorState::eSetValue_ByContent |
|
||||
nsTextEditorState::eSetValue_Notify |
|
||||
nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aError.Throw(rv);
|
||||
return;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mFocusedValue.Equals(currentValue)) {
|
||||
GetValueInternal(mFocusedValue, true);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -400,12 +424,21 @@ HTMLTextAreaElement::SetValueChanged(bool aValueChanged)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::GetDefaultValue(nsAString& aDefaultValue, ErrorResult& aError)
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetDefaultValue(nsAString& aDefaultValue)
|
||||
{
|
||||
if (!nsContentUtils::GetNodeTextContent(this, false, aDefaultValue, fallible)) {
|
||||
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetDefaultValue(const nsAString& aDefaultValue)
|
||||
{
|
||||
ErrorResult error;
|
||||
SetDefaultValue(aDefaultValue, error);
|
||||
return error.StealNSResult();
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +702,7 @@ HTMLTextAreaElement::GetControllers(ErrorResult& aError)
|
||||
return mControllers;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetControllers(nsIControllers** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
@ -689,6 +722,15 @@ HTMLTextAreaElement::GetTextLength()
|
||||
return val.Length();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetTextLength(int32_t *aTextLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTextLength);
|
||||
*aTextLength = GetTextLength();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Nullable<uint32_t>
|
||||
HTMLTextAreaElement::GetSelectionStart(ErrorResult& aError)
|
||||
{
|
||||
@ -784,8 +826,7 @@ nsresult
|
||||
HTMLTextAreaElement::Reset()
|
||||
{
|
||||
nsAutoString resetVal;
|
||||
IgnoredErrorResult res;
|
||||
GetDefaultValue(resetVal, res);
|
||||
GetDefaultValue(resetVal);
|
||||
SetValueChanged(false);
|
||||
|
||||
nsresult rv = SetValueInternal(resetVal,
|
||||
@ -880,14 +921,12 @@ HTMLTextAreaElement::RestoreState(nsPresState* aState)
|
||||
if (state) {
|
||||
nsAutoString data;
|
||||
state->GetData(data);
|
||||
ErrorResult rv;
|
||||
SetValue(data, rv);
|
||||
ENSURE_SUCCESS(rv, false);
|
||||
nsresult rv = SetValue(data);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
}
|
||||
|
||||
if (aState->IsDisabledSet() && !aState->GetDisabled()) {
|
||||
IgnoredErrorResult rv;
|
||||
SetDisabled(false, rv);
|
||||
SetDisabled(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1081,9 +1120,7 @@ HTMLTextAreaElement::CopyInnerTo(Element* aDest, bool aPreallocateChildren)
|
||||
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
||||
nsAutoString value;
|
||||
GetValueInternal(value, true);
|
||||
ErrorResult ret;
|
||||
static_cast<HTMLTextAreaElement*>(aDest)->SetValue(value, ret);
|
||||
return ret.StealNSResult();
|
||||
return static_cast<HTMLTextAreaElement*>(aDest)->SetValue(value);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1120,14 +1157,16 @@ HTMLTextAreaElement::IsTooLong()
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t maxLength = MaxLength();
|
||||
int32_t maxLength = -1;
|
||||
GetMaxLength(&maxLength);
|
||||
|
||||
// Maxlength of -1 means parsing error.
|
||||
if (maxLength == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t textLength = GetTextLength();
|
||||
int32_t textLength = -1;
|
||||
GetTextLength(&textLength);
|
||||
|
||||
return textLength > maxLength;
|
||||
}
|
||||
@ -1141,14 +1180,16 @@ HTMLTextAreaElement::IsTooShort()
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t minLength = MinLength();
|
||||
int32_t minLength = -1;
|
||||
GetMinLength(&minLength);
|
||||
|
||||
// Minlength of -1 means parsing error.
|
||||
if (minLength == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t textLength = GetTextLength();
|
||||
int32_t textLength = -1;
|
||||
GetTextLength(&textLength);
|
||||
|
||||
return textLength && textLength < minLength;
|
||||
}
|
||||
@ -1200,11 +1241,14 @@ HTMLTextAreaElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||
case VALIDITY_STATE_TOO_LONG:
|
||||
{
|
||||
nsAutoString message;
|
||||
int32_t maxLength = MaxLength();
|
||||
int32_t textLength = GetTextLength();
|
||||
int32_t maxLength = -1;
|
||||
int32_t textLength = -1;
|
||||
nsAutoString strMaxLength;
|
||||
nsAutoString strTextLength;
|
||||
|
||||
GetMaxLength(&maxLength);
|
||||
GetTextLength(&textLength);
|
||||
|
||||
strMaxLength.AppendInt(maxLength);
|
||||
strTextLength.AppendInt(textLength);
|
||||
|
||||
@ -1218,11 +1262,14 @@ HTMLTextAreaElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||
case VALIDITY_STATE_TOO_SHORT:
|
||||
{
|
||||
nsAutoString message;
|
||||
int32_t minLength = MinLength();
|
||||
int32_t textLength = GetTextLength();
|
||||
int32_t minLength = -1;
|
||||
int32_t textLength = -1;
|
||||
nsAutoString strMinLength;
|
||||
nsAutoString strTextLength;
|
||||
|
||||
GetMinLength(&minLength);
|
||||
GetTextLength(&textLength);
|
||||
|
||||
strMinLength.AppendInt(minLength);
|
||||
strTextLength.AppendInt(textLength);
|
||||
|
||||
@ -1304,8 +1351,7 @@ HTMLTextAreaElement::GetRows()
|
||||
NS_IMETHODIMP_(void)
|
||||
HTMLTextAreaElement::GetDefaultValueFromContent(nsAString& aValue)
|
||||
{
|
||||
IgnoredErrorResult rv;
|
||||
GetDefaultValue(aValue, rv);
|
||||
GetDefaultValue(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define mozilla_dom_HTMLTextAreaElement_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsITextControlElement.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsIDOMNSEditableElement.h"
|
||||
@ -38,6 +39,7 @@ namespace dom {
|
||||
class HTMLFormSubmission;
|
||||
|
||||
class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
|
||||
public nsIDOMHTMLTextAreaElement,
|
||||
public nsITextControlElement,
|
||||
public nsIDOMNSEditableElement,
|
||||
public nsStubMutationObserver,
|
||||
@ -52,8 +54,6 @@ public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTextAreaElement, textarea)
|
||||
|
||||
virtual int32_t TabIndexDefault() override;
|
||||
|
||||
// Element
|
||||
@ -62,6 +62,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// nsIDOMHTMLTextAreaElement
|
||||
NS_DECL_NSIDOMHTMLTEXTAREAELEMENT
|
||||
|
||||
// nsIDOMNSEditableElement
|
||||
NS_IMETHOD GetEditor(nsIEditor** aEditor) override
|
||||
{
|
||||
@ -234,18 +237,12 @@ public:
|
||||
SetHTMLIntAttr(nsGkAtoms::minlength, aMinLength, aError);
|
||||
}
|
||||
}
|
||||
void GetName(nsAString& aName)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::name, aName);
|
||||
}
|
||||
// XPCOM GetName is fine
|
||||
void SetName(const nsAString& aName, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
||||
}
|
||||
void GetPlaceholder(nsAString& aPlaceholder)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::placeholder, aPlaceholder);
|
||||
}
|
||||
// XPCOM GetPlaceholder is fine
|
||||
void SetPlaceholder(const nsAString& aPlaceholder, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::placeholder, aPlaceholder, aError);
|
||||
@ -282,27 +279,22 @@ public:
|
||||
uint32_t rows = aRows ? aRows : DEFAULT_ROWS_TEXTAREA;
|
||||
SetUnsignedIntAttr(nsGkAtoms::rows, rows, DEFAULT_ROWS_TEXTAREA, aError);
|
||||
}
|
||||
void GetWrap(nsAString& aWrap)
|
||||
{
|
||||
GetHTMLAttr(nsGkAtoms::wrap, aWrap);
|
||||
}
|
||||
// XPCOM GetWrap is fine
|
||||
void SetWrap(const nsAString& aWrap, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::wrap, aWrap, aError);
|
||||
}
|
||||
void GetType(nsAString& aType);
|
||||
void GetDefaultValue(nsAString& aDefaultValue, ErrorResult& aError);
|
||||
// XPCOM GetType is fine
|
||||
// XPCOM GetDefaultValue is fine
|
||||
void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError);
|
||||
void GetValue(nsAString& aValue);
|
||||
void SetValue(const nsAString& aValue, ErrorResult& aError);
|
||||
|
||||
// XPCOM GetValue/SetValue are fine
|
||||
uint32_t GetTextLength();
|
||||
|
||||
// Override SetCustomValidity so we update our state properly when it's called
|
||||
// via bindings.
|
||||
void SetCustomValidity(const nsAString& aError);
|
||||
|
||||
void Select();
|
||||
// XPCOM Select is fine
|
||||
Nullable<uint32_t> GetSelectionStart(ErrorResult& aError);
|
||||
void SetSelectionStart(const Nullable<uint32_t>& aSelectionStart, ErrorResult& aError);
|
||||
Nullable<uint32_t> GetSelectionEnd(ErrorResult& aError);
|
||||
@ -311,9 +303,6 @@ public:
|
||||
void SetSelectionDirection(const nsAString& aDirection, ErrorResult& aError);
|
||||
void SetSelectionRange(uint32_t aSelectionStart, uint32_t aSelectionEnd, const Optional<nsAString>& aDirecton, ErrorResult& aError);
|
||||
nsIControllers* GetControllers(ErrorResult& aError);
|
||||
// XPCOM adapter function widely used throughout code, leaving it as is.
|
||||
nsresult GetControllers(nsIControllers** aResult);
|
||||
|
||||
nsIEditor* GetEditor()
|
||||
{
|
||||
return mState.GetTextEditor();
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "nsTextControlFrame.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsIControllerContext.h"
|
||||
#include "nsAttrValue.h"
|
||||
@ -42,7 +43,6 @@
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include "nsNumberControlFrame.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
@ -968,8 +968,8 @@ DoCommandCallback(Command aCommand, void* aData)
|
||||
if (input) {
|
||||
input->GetControllers(getter_AddRefs(controllers));
|
||||
} else {
|
||||
HTMLTextAreaElement* textArea =
|
||||
HTMLTextAreaElement::FromContent(content);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea =
|
||||
do_QueryInterface(content);
|
||||
|
||||
if (textArea) {
|
||||
textArea->GetControllers(getter_AddRefs(controllers));
|
||||
@ -1512,9 +1512,8 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
|
||||
if (inputElement) {
|
||||
rv = inputElement->GetControllers(getter_AddRefs(controllers));
|
||||
} else {
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
||||
HTMLTextAreaElement* textAreaElement =
|
||||
HTMLTextAreaElement::FromContentOrNull(content);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement =
|
||||
do_QueryInterface(mTextCtrlElement);
|
||||
|
||||
if (!textAreaElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -2177,9 +2176,8 @@ nsTextEditorState::UnbindFromFrame(nsTextControlFrame* aFrame)
|
||||
inputElement->GetControllers(getter_AddRefs(controllers));
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
||||
HTMLTextAreaElement* textAreaElement =
|
||||
HTMLTextAreaElement::FromContentOrNull(content);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement =
|
||||
do_QueryInterface(mTextCtrlElement);
|
||||
if (textAreaElement) {
|
||||
textAreaElement->GetControllers(getter_AddRefs(controllers));
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMHTMLScriptElement.idl',
|
||||
'nsIDOMHTMLSelectElement.idl',
|
||||
'nsIDOMHTMLSourceElement.idl',
|
||||
'nsIDOMHTMLTextAreaElement.idl',
|
||||
'nsIDOMMozBrowserFrame.idl',
|
||||
'nsIDOMTimeRanges.idl',
|
||||
'nsIDOMValidityState.idl',
|
||||
|
54
dom/interfaces/html/nsIDOMHTMLTextAreaElement.idl
Normal file
54
dom/interfaces/html/nsIDOMHTMLTextAreaElement.idl
Normal file
@ -0,0 +1,54 @@
|
||||
/* -*- 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"
|
||||
|
||||
interface nsIControllers;
|
||||
interface nsIDOMValidityState;
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLTextAreaElement interface is the interface to a
|
||||
* [X]HTML textarea 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(7a4aeb2e-fcf3-443e-b002-ca1c8ea322e9)]
|
||||
interface nsIDOMHTMLTextAreaElement : nsISupports
|
||||
{
|
||||
attribute boolean autofocus;
|
||||
attribute unsigned long cols;
|
||||
attribute boolean disabled;
|
||||
readonly attribute nsIDOMHTMLFormElement form;
|
||||
attribute long maxLength;
|
||||
attribute long minLength;
|
||||
attribute DOMString name;
|
||||
attribute DOMString placeholder;
|
||||
attribute boolean readOnly;
|
||||
attribute boolean required;
|
||||
attribute unsigned long rows;
|
||||
/**
|
||||
* Reflects the wrap content attribute. Possible values are "soft", "hard" and
|
||||
* "off". "soft" is the default.
|
||||
*/
|
||||
[Null(Stringify)]
|
||||
attribute DOMString wrap;
|
||||
|
||||
readonly attribute DOMString type;
|
||||
attribute DOMString defaultValue;
|
||||
attribute DOMString value;
|
||||
readonly attribute long textLength;
|
||||
|
||||
void select();
|
||||
|
||||
// Mozilla extensions
|
||||
// Please make sure to update the HTMLTextAreaElement Web IDL interface to
|
||||
// mirror the list of Mozilla extensions here when changing it.
|
||||
readonly attribute nsIControllers controllers;
|
||||
};
|
@ -12,7 +12,6 @@
|
||||
#include "mozilla/dom/HTMLLinkElement.h"
|
||||
#include "mozilla/dom/HTMLObjectElement.h"
|
||||
#include "mozilla/dom/HTMLSharedElement.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -32,6 +31,7 @@
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
#include "nsIDOMHTMLSourceElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMMozNamedAttrMap.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeFilter.h"
|
||||
@ -1153,7 +1153,7 @@ PersistNodeFixup::FixupNode(nsIDOMNode *aNodeIn,
|
||||
return rv;
|
||||
}
|
||||
|
||||
dom::HTMLTextAreaElement* nodeAsTextArea = dom::HTMLTextAreaElement::FromContent(content);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> nodeAsTextArea = do_QueryInterface(aNodeIn);
|
||||
if (nodeAsTextArea) {
|
||||
rv = GetNodeToFixup(aNodeIn, aNodeOut);
|
||||
if (NS_SUCCEEDED(rv) && *aNodeOut) {
|
||||
|
@ -46,9 +46,9 @@ interface HTMLTextAreaElement : HTMLElement {
|
||||
|
||||
[Constant]
|
||||
readonly attribute DOMString type;
|
||||
[CEReactions, Throws, Pure]
|
||||
[CEReactions, SetterThrows, Pure]
|
||||
attribute DOMString defaultValue;
|
||||
[CEReactions, SetterThrows, TreatNullAs=EmptyString] attribute DOMString value;
|
||||
[CEReactions, TreatNullAs=EmptyString] attribute DOMString value;
|
||||
readonly attribute unsigned long textLength;
|
||||
|
||||
readonly attribute boolean willValidate;
|
||||
@ -78,7 +78,8 @@ interface HTMLTextAreaElement : HTMLElement {
|
||||
};
|
||||
|
||||
partial interface HTMLTextAreaElement {
|
||||
// Chrome-only Mozilla extensions
|
||||
// Mirrored chrome-only Mozilla extensions to nsIDOMHTMLTextAreaElement.
|
||||
// Please make sure to update this list of nsIDOMHTMLTextAreaElement changes.
|
||||
|
||||
[Throws, ChromeOnly]
|
||||
readonly attribute XULControllers controllers;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIControllers.h"
|
||||
#include "nsXULElement.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIFormControl.h"
|
||||
@ -49,7 +50,6 @@
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/EventHandlerBinding.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/layers/KeyboardMap.h"
|
||||
#include "xpcpublic.h"
|
||||
@ -681,7 +681,7 @@ nsXBLPrototypeHandler::GetController(EventTarget* aTarget)
|
||||
}
|
||||
|
||||
if (!controllers) {
|
||||
HTMLTextAreaElement* htmlTextArea = HTMLTextAreaElement::FromContent(targetContent);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> htmlTextArea(do_QueryInterface(aTarget));
|
||||
if (htmlTextArea)
|
||||
htmlTextArea->GetControllers(getter_AddRefs(controllers));
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsCheckboxRadioFrame.h" //for registering accesskeys
|
||||
|
||||
@ -1161,20 +1162,22 @@ nsTextControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsresult
|
||||
nsTextControlFrame::GetText(nsString& aText)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
||||
if (IsSingleLineTextControl()) {
|
||||
// There will be no line breaks so we can ignore the wrap property.
|
||||
txtCtrl->GetTextEditorValue(aText, true);
|
||||
} else {
|
||||
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromContent(mContent);
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(mContent);
|
||||
if (textArea) {
|
||||
textArea->GetValue(aText);
|
||||
rv = textArea->GetValue(aText);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
nsAtom* aAttribute,
|
||||
int32_t aModType) override;
|
||||
|
||||
void GetText(nsString& aText);
|
||||
nsresult GetText(nsString& aText);
|
||||
|
||||
virtual nsresult PeekOffset(nsPeekOffsetStruct *aPos) override;
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsScrollbarFrame.h"
|
||||
#include "nsIScrollbarMediator.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsPresState.h"
|
||||
@ -39,7 +40,6 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include <stdint.h>
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
@ -4502,8 +4502,7 @@ ScrollFrameHelper::CreateAnonymousContent(
|
||||
nsITextControlFrame* textFrame = do_QueryFrame(parent);
|
||||
if (textFrame) {
|
||||
// Make sure we are not a text area.
|
||||
HTMLTextAreaElement* textAreaElement =
|
||||
HTMLTextAreaElement::FromContent(parent->GetContent());
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement(do_QueryInterface(parent->GetContent()));
|
||||
if (!textAreaElement) {
|
||||
mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = true;
|
||||
return NS_OK;
|
||||
|
@ -208,7 +208,7 @@ var ActionBarHandler = {
|
||||
|
||||
// Return focused editable text element and its window.
|
||||
if (((element instanceof Ci.nsIDOMHTMLInputElement) && element.mozIsTextField(false)) ||
|
||||
(ChromeUtils.getClassName(element) === "HTMLTextAreaElement") ||
|
||||
(element instanceof Ci.nsIDOMHTMLTextAreaElement) ||
|
||||
element.isContentEditable) {
|
||||
return [element, win];
|
||||
}
|
||||
@ -743,7 +743,7 @@ var ActionBarHandler = {
|
||||
|
||||
// Textarea can contain LF, etc.
|
||||
if (this._targetElement &&
|
||||
ChromeUtils.getClassName(this._targetElement) === "HTMLTextAreaElement") {
|
||||
this._targetElement instanceof Ci.nsIDOMHTMLTextAreaElement) {
|
||||
let flags = Ci.nsIDocumentEncoder.OutputPreformatted |
|
||||
Ci.nsIDocumentEncoder.OutputRaw;
|
||||
return selection.QueryInterface(Ci.nsISelectionPrivate).
|
||||
|
@ -46,7 +46,7 @@ function do_promiseTabChangeEvent(tabId, eventType) {
|
||||
*/
|
||||
function isInputOrTextarea(element) {
|
||||
return ((element instanceof Ci.nsIDOMHTMLInputElement) ||
|
||||
(ChromeUtils.getClassName(element) === "HTMLTextAreaElement"));
|
||||
(element instanceof Ci.nsIDOMHTMLTextAreaElement));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -500,7 +500,7 @@ this.BrowserUtils = {
|
||||
// try getting a selected text in text input.
|
||||
if (!selectionStr && focusedElement instanceof Ci.nsIDOMNSEditableElement) {
|
||||
// Don't get the selection for password fields. See bug 565717.
|
||||
if (ChromeUtils.getClassName(focusedElement) === "HTMLTextAreaElement" ||
|
||||
if (focusedElement instanceof Ci.nsIDOMHTMLTextAreaElement ||
|
||||
(focusedElement instanceof Ci.nsIDOMHTMLInputElement &&
|
||||
focusedElement.mozIsTextField(true))) {
|
||||
selectionStr = focusedElement.editor.selection.toString();
|
||||
|
@ -207,7 +207,7 @@ var FormDataInternal = {
|
||||
}
|
||||
|
||||
if (node instanceof Ci.nsIDOMHTMLInputElement ||
|
||||
ChromeUtils.getClassName(node) === "HTMLTextAreaElement" ||
|
||||
node instanceof Ci.nsIDOMHTMLTextAreaElement ||
|
||||
node instanceof Ci.nsIDOMXULTextBoxElement) {
|
||||
switch (node.type) {
|
||||
case "checkbox":
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMHTMLSourceElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMMediaList.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
@ -162,6 +163,7 @@
|
||||
#include "mozilla/dom/HTMLScriptElementBinding.h"
|
||||
#include "mozilla/dom/HTMLSelectElementBinding.h"
|
||||
#include "mozilla/dom/HTMLSourceElementBinding.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
|
||||
#include "mozilla/dom/KeyEventBinding.h"
|
||||
#include "mozilla/dom/ListBoxObjectBinding.h"
|
||||
#include "mozilla/dom/MediaListBinding.h"
|
||||
@ -317,6 +319,7 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
|
||||
DEFINE_SHIM(HTMLScriptElement),
|
||||
DEFINE_SHIM(HTMLSelectElement),
|
||||
DEFINE_SHIM(HTMLSourceElement),
|
||||
DEFINE_SHIM(HTMLTextAreaElement),
|
||||
DEFINE_SHIM(KeyEvent),
|
||||
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIListBoxObject, ListBoxObject),
|
||||
DEFINE_SHIM(MediaList),
|
||||
|
Loading…
Reference in New Issue
Block a user