зеркало из https://github.com/mozilla/gecko-dev.git
Bug 838582 - Part 2: Move HTMLTextAreaElement to Web IDL bindings; r=bzbarsky
--HG-- extra : rebase_source : f8933c4973220dc8845b9ce2f63e91b366167117
This commit is contained in:
Родитель
3673e41770
Коммит
84ff151c43
|
@ -40,7 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=816298
|
|||
var clipboard = Cc["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(SpecialPowers.Ci.nsIClipboard);
|
||||
|
||||
var textarea = SpecialPowers.wrap(document).getElementById('input');
|
||||
var textarea = SpecialPowers.wrap(document.getElementById('input'));
|
||||
|
||||
function getLoadContext() {
|
||||
return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
|
@ -78,8 +78,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=816298
|
|||
function testPasteText(expected, test) {
|
||||
textarea.value="";
|
||||
textarea.focus();
|
||||
textarea.QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement)
|
||||
.editor.paste(1);
|
||||
textarea.editor.paste(1);
|
||||
is(textarea.value, expected, test + ": textarea paste");
|
||||
}
|
||||
function testInnerHTML(id, expected) {
|
||||
|
|
|
@ -56,7 +56,7 @@ function testCopyPaste () {
|
|||
var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
|
||||
.getService(Components.interfaces.nsIClipboard);
|
||||
|
||||
var textarea = document.getElementById('input');
|
||||
var textarea = SpecialPowers.wrap(document.getElementById('input'));
|
||||
|
||||
function copySelectionToClipboard() {
|
||||
documentViewer.copySelection();
|
||||
|
@ -111,8 +111,7 @@ function testCopyPaste () {
|
|||
function testPasteText(expected) {
|
||||
textarea.value="";
|
||||
textarea.focus();
|
||||
textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement)
|
||||
.editor.paste(1);
|
||||
textarea.editor.paste(1);
|
||||
is(textarea.value, expected, "value of the textarea after the paste");
|
||||
}
|
||||
function testSelectionToString(expected) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/HTMLTextAreaElement.h"
|
||||
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "nsIControllers.h"
|
||||
|
@ -18,7 +19,6 @@
|
|||
#include "nsFormSubmission.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
|
@ -73,6 +73,8 @@ HTMLTextAreaElement::HTMLTextAreaElement(already_AddRefed<nsINodeInfo> aNodeInfo
|
|||
AddStatesSilently(NS_EVENT_STATE_ENABLED |
|
||||
NS_EVENT_STATE_OPTIONAL |
|
||||
NS_EVENT_STATE_VALID);
|
||||
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,7 +238,7 @@ HTMLTextAreaElement::GetValueInternal(nsAString& aValue, bool aIgnoreWrap) const
|
|||
NS_IMETHODIMP_(nsIEditor*)
|
||||
HTMLTextAreaElement::GetTextEditor()
|
||||
{
|
||||
return mState.GetEditor();
|
||||
return GetEditor();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsISelectionController*)
|
||||
|
@ -370,12 +372,22 @@ HTMLTextAreaElement::GetDefaultValue(nsAString& aDefaultValue)
|
|||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetDefaultValue(const nsAString& aDefaultValue)
|
||||
{
|
||||
ErrorResult error;
|
||||
SetDefaultValue(aDefaultValue, error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError)
|
||||
{
|
||||
nsresult rv = nsContentUtils::SetNodeTextContent(this, aDefaultValue, true);
|
||||
if (NS_SUCCEEDED(rv) && !mValueChanged) {
|
||||
Reset();
|
||||
}
|
||||
return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -563,45 +575,65 @@ HTMLTextAreaElement::IsDoneAddingChildren()
|
|||
|
||||
// Controllers Methods
|
||||
|
||||
nsIControllers*
|
||||
HTMLTextAreaElement::GetControllers(ErrorResult& aError)
|
||||
{
|
||||
if (!mControllers)
|
||||
{
|
||||
nsresult rv;
|
||||
mControllers = do_CreateInstance(kXULControllersCID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/editor/editorcontroller;1", &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
|
||||
controller = do_CreateInstance("@mozilla.org/editor/editingcontroller;1", &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
}
|
||||
|
||||
return mControllers;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetControllers(nsIControllers** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!mControllers)
|
||||
{
|
||||
nsresult rv;
|
||||
mControllers = do_CreateInstance(kXULControllersCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/editor/editorcontroller;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
|
||||
controller = do_CreateInstance("@mozilla.org/editor/editingcontroller;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mControllers->AppendController(controller);
|
||||
}
|
||||
|
||||
*aResult = mControllers;
|
||||
ErrorResult error;
|
||||
*aResult = GetControllers(error);
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLTextAreaElement::GetTextLength()
|
||||
{
|
||||
nsAutoString val;
|
||||
GetValue(val);
|
||||
return val.Length();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetTextLength(int32_t *aTextLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTextLength);
|
||||
nsAutoString val;
|
||||
nsresult rv = GetValue(val);
|
||||
*aTextLength = val.Length();
|
||||
*aTextLength = GetTextLength();
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -609,35 +641,62 @@ HTMLTextAreaElement::GetSelectionStart(int32_t *aSelectionStart)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aSelectionStart);
|
||||
|
||||
int32_t selEnd;
|
||||
nsresult rv = GetSelectionRange(aSelectionStart, &selEnd);
|
||||
ErrorResult error;
|
||||
*aSelectionStart = GetSelectionStart(error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLTextAreaElement::GetSelectionStart(ErrorResult& aError)
|
||||
{
|
||||
int32_t selStart, selEnd;
|
||||
nsresult rv = GetSelectionRange(&selStart, &selEnd);
|
||||
|
||||
if (NS_FAILED(rv) && mState.IsSelectionCached()) {
|
||||
*aSelectionStart = mState.GetSelectionProperties().mStart;
|
||||
return NS_OK;
|
||||
return mState.GetSelectionProperties().mStart;
|
||||
}
|
||||
return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
return selStart;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetSelectionStart(int32_t aSelectionStart)
|
||||
{
|
||||
ErrorResult error;
|
||||
SetSelectionStart(aSelectionStart, error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::SetSelectionStart(uint32_t aSelectionStart, ErrorResult& aError)
|
||||
{
|
||||
if (mState.IsSelectionCached()) {
|
||||
mState.GetSelectionProperties().mStart = aSelectionStart;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString direction;
|
||||
nsresult rv = GetSelectionDirection(direction);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return;
|
||||
}
|
||||
int32_t start, end;
|
||||
rv = GetSelectionRange(&start, &end);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return;
|
||||
}
|
||||
start = aSelectionStart;
|
||||
if (end < start) {
|
||||
end = start;
|
||||
}
|
||||
return SetSelectionRange(start, end, direction);
|
||||
rv = SetSelectionRange(start, end, direction);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -645,35 +704,62 @@ HTMLTextAreaElement::GetSelectionEnd(int32_t *aSelectionEnd)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aSelectionEnd);
|
||||
|
||||
int32_t selStart;
|
||||
nsresult rv = GetSelectionRange(&selStart, aSelectionEnd);
|
||||
ErrorResult error;
|
||||
*aSelectionEnd = GetSelectionEnd(error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLTextAreaElement::GetSelectionEnd(ErrorResult& aError)
|
||||
{
|
||||
int32_t selStart, selEnd;
|
||||
nsresult rv = GetSelectionRange(&selStart, &selEnd);
|
||||
|
||||
if (NS_FAILED(rv) && mState.IsSelectionCached()) {
|
||||
*aSelectionEnd = mState.GetSelectionProperties().mEnd;
|
||||
return NS_OK;
|
||||
return mState.GetSelectionProperties().mEnd;
|
||||
}
|
||||
return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
return selEnd;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetSelectionEnd(int32_t aSelectionEnd)
|
||||
{
|
||||
ErrorResult error;
|
||||
SetSelectionEnd(aSelectionEnd, error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::SetSelectionEnd(uint32_t aSelectionEnd, ErrorResult& aError)
|
||||
{
|
||||
if (mState.IsSelectionCached()) {
|
||||
mState.GetSelectionProperties().mEnd = aSelectionEnd;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString direction;
|
||||
nsresult rv = GetSelectionDirection(direction);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return;
|
||||
}
|
||||
int32_t start, end;
|
||||
rv = GetSelectionRange(&start, &end);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
return;
|
||||
}
|
||||
end = aSelectionEnd;
|
||||
if (start > end) {
|
||||
start = end;
|
||||
}
|
||||
return SetSelectionRange(start, end, direction);
|
||||
rv = SetSelectionRange(start, end, direction);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -708,6 +794,14 @@ DirectionToName(nsITextControlFrame::SelectionDirection dir, nsAString& aDirecti
|
|||
|
||||
nsresult
|
||||
HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection)
|
||||
{
|
||||
ErrorResult error;
|
||||
GetSelectionDirection(aDirection, error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection, ErrorResult& aError)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
|
||||
|
@ -726,15 +820,23 @@ HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection)
|
|||
if (NS_FAILED(rv)) {
|
||||
if (mState.IsSelectionCached()) {
|
||||
DirectionToName(mState.GetSelectionProperties().mDirection, aDirection);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
aError.Throw(rv);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection) {
|
||||
HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection)
|
||||
{
|
||||
ErrorResult error;
|
||||
SetSelectionDirection(aDirection, error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection, ErrorResult& aError)
|
||||
{
|
||||
if (mState.IsSelectionCached()) {
|
||||
nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eNone;
|
||||
if (aDirection.EqualsLiteral("forward")) {
|
||||
|
@ -743,7 +845,7 @@ HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection) {
|
|||
dir = nsITextControlFrame::eBackward;
|
||||
}
|
||||
mState.GetSelectionProperties().mDirection = dir;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t start, end;
|
||||
|
@ -751,15 +853,29 @@ HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection) {
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetSelectionRange(start, end, aDirection);
|
||||
}
|
||||
|
||||
return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetSelectionRange(int32_t aSelectionStart,
|
||||
int32_t aSelectionEnd,
|
||||
const nsAString& aDirection)
|
||||
{
|
||||
{
|
||||
ErrorResult error;
|
||||
Optional<nsAString> dir;
|
||||
dir = &aDirection;
|
||||
SetSelectionRange(aSelectionStart, aSelectionEnd, dir, error);
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLTextAreaElement::SetSelectionRange(uint32_t aSelectionStart,
|
||||
uint32_t aSelectionEnd,
|
||||
const Optional<nsAString>& aDirection,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
|
||||
|
||||
|
@ -770,7 +886,7 @@ HTMLTextAreaElement::SetSelectionRange(int32_t aSelectionStart,
|
|||
// Note that we don't currently support directionless selections, so
|
||||
// "none" is treated like "forward".
|
||||
nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eForward;
|
||||
if (aDirection.EqualsLiteral("backward")) {
|
||||
if (aDirection.WasPassed() && aDirection.Value().EqualsLiteral("backward")) {
|
||||
dir = nsITextControlFrame::eBackward;
|
||||
}
|
||||
|
||||
|
@ -781,8 +897,10 @@ HTMLTextAreaElement::SetSelectionRange(int32_t aSelectionStart,
|
|||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLTextAreaElement::Reset()
|
||||
|
@ -1310,5 +1428,12 @@ HTMLTextAreaElement::FieldSetDisabledChanged(bool aNotify)
|
|||
nsGenericHTMLFormElement::FieldSetDisabledChanged(aNotify);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLTextAreaElement::WrapNode(JSContext* aCx, JSObject* aScope,
|
||||
bool* aTriedToWrap)
|
||||
{
|
||||
return HTMLTextAreaElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "nsStubMutationObserver.h"
|
||||
#include "nsIConstraintValidation.h"
|
||||
#include "nsHTMLFormElement.h"
|
||||
#include "nsGkAtoms.h"
|
||||
|
||||
#include "nsTextEditorState.h"
|
||||
|
||||
|
@ -159,9 +160,123 @@ public:
|
|||
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
||||
ValidityStateType aType);
|
||||
|
||||
// Web IDL binding methods
|
||||
bool Autofocus()
|
||||
{
|
||||
return GetBoolAttr(nsGkAtoms::autofocus);
|
||||
}
|
||||
void SetAutofocus(bool aAutoFocus, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLBoolAttr(nsGkAtoms::autofocus, aAutoFocus, aError);
|
||||
}
|
||||
uint32_t Cols()
|
||||
{
|
||||
return GetIntAttr(nsGkAtoms::cols, DEFAULT_COLS);
|
||||
}
|
||||
void SetCols(uint32_t aCols, ErrorResult& aError)
|
||||
{
|
||||
if (aCols == 0) {
|
||||
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
} else {
|
||||
SetHTMLUnsignedIntAttr(nsGkAtoms::cols, aCols, aError);
|
||||
}
|
||||
}
|
||||
bool Disabled()
|
||||
{
|
||||
return GetBoolAttr(nsGkAtoms::disabled);
|
||||
}
|
||||
void SetDisabled(bool aDisabled, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
|
||||
}
|
||||
// nsGenericHTMLFormElement::GetForm is fine
|
||||
using nsGenericHTMLFormElement::GetForm;
|
||||
int32_t MaxLength()
|
||||
{
|
||||
return GetIntAttr(nsGkAtoms::maxlength, -1);
|
||||
}
|
||||
void SetMaxLength(int32_t aMaxLength, ErrorResult& aError)
|
||||
{
|
||||
if (aMaxLength < 0) {
|
||||
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
} else {
|
||||
SetHTMLIntAttr(nsGkAtoms::maxlength, aMaxLength, aError);
|
||||
}
|
||||
}
|
||||
// XPCOM GetName is fine
|
||||
void SetName(const nsAString& aName, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
||||
}
|
||||
// XPCOM GetPlaceholder is fine
|
||||
void SetPlaceholder(const nsAString& aPlaceholder, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::placeholder, aPlaceholder, aError);
|
||||
}
|
||||
bool ReadOnly()
|
||||
{
|
||||
return GetBoolAttr(nsGkAtoms::readonly);
|
||||
}
|
||||
void SetReadOnly(bool aReadOnly, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLBoolAttr(nsGkAtoms::readonly, aReadOnly, aError);
|
||||
}
|
||||
bool Required()
|
||||
{
|
||||
return GetBoolAttr(nsGkAtoms::required);
|
||||
}
|
||||
void SetRequired(bool aRequired, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLBoolAttr(nsGkAtoms::required, aRequired, aError);
|
||||
}
|
||||
uint32_t Rows()
|
||||
{
|
||||
return GetIntAttr(nsGkAtoms::rows, DEFAULT_ROWS_TEXTAREA);
|
||||
}
|
||||
void SetRows(uint32_t aRows, ErrorResult& aError)
|
||||
{
|
||||
if (aRows == 0) {
|
||||
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
} else {
|
||||
SetHTMLUnsignedIntAttr(nsGkAtoms::rows, aRows, aError);
|
||||
}
|
||||
}
|
||||
// XPCOM GetWrap is fine
|
||||
void SetWrap(const nsAString& aWrap, ErrorResult& aError)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::wrap, aWrap, aError);
|
||||
}
|
||||
// XPCOM GetType is fine
|
||||
// XPCOM GetDefaultValue is fine
|
||||
void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError);
|
||||
// XPCOM GetValue/SetValue are fine
|
||||
uint32_t GetTextLength();
|
||||
// nsIConstraintValidation::WillValidate is fine.
|
||||
// nsIConstraintValidation::Validity() is fine.
|
||||
// nsIConstraintValidation::GetValidationMessage() is fine.
|
||||
// nsIConstraintValidation::CheckValidity() is fine.
|
||||
using nsIConstraintValidation::CheckValidity;
|
||||
// nsIConstraintValidation::SetCustomValidity() is fine.
|
||||
// XPCOM Select is fine
|
||||
uint32_t GetSelectionStart(ErrorResult& aError);
|
||||
void SetSelectionStart(uint32_t aSelectionStart, ErrorResult& aError);
|
||||
uint32_t GetSelectionEnd(ErrorResult& aError);
|
||||
void SetSelectionEnd(uint32_t aSelectionEnd, ErrorResult& aError);
|
||||
void GetSelectionDirection(nsAString& aDirection, ErrorResult& aError);
|
||||
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);
|
||||
nsIEditor* GetEditor()
|
||||
{
|
||||
return mState.GetEditor();
|
||||
}
|
||||
|
||||
protected:
|
||||
using nsGenericHTMLFormElement::IsSingleLineTextControl; // get rid of the compiler warning
|
||||
|
||||
virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
|
||||
bool *aTriedToWrap) MOZ_OVERRIDE;
|
||||
|
||||
nsCOMPtr<nsIControllers> mControllers;
|
||||
/** Whether or not the value has changed since its default value was given. */
|
||||
bool mValueChanged;
|
||||
|
|
|
@ -279,6 +279,7 @@ MOCHITEST_FILES = \
|
|||
test_bug803677.html \
|
||||
test_bug827126.html \
|
||||
test_bug827426.html \
|
||||
test_bug838582.html \
|
||||
test_bug841466.html \
|
||||
test_iframe_sandbox_inheritance.html \
|
||||
file_iframe_sandbox_a_if1.html \
|
||||
|
|
|
@ -58,8 +58,7 @@ function reflectString(aParameters)
|
|||
// TODO: remove this ugly hack when null stringification will work as expected.
|
||||
var todoAttrs = {
|
||||
form: [ "acceptCharset", "name", "target" ],
|
||||
input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ],
|
||||
textarea: [ "name", "placeholder" ]
|
||||
input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ]
|
||||
};
|
||||
if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) {
|
||||
is(element.getAttribute(contentAttr), "null",
|
||||
|
|
|
@ -25,7 +25,7 @@ var textareaChange = 0;
|
|||
function testUserInput() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var input = document.getElementById("input");
|
||||
var textarea = document.getElementById("textarea");
|
||||
var textarea = SpecialPowers.wrap(document.getElementById("textarea"));
|
||||
|
||||
input.focus();
|
||||
input.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).setUserInput("foo");
|
||||
|
@ -47,7 +47,7 @@ function testUserInput() {
|
|||
"Change event dispatched when input element doesn't have focus.");
|
||||
|
||||
textarea.focus();
|
||||
textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).setUserInput("foo");
|
||||
textarea.setUserInput("foo");
|
||||
textarea.blur();
|
||||
is(textareaChange, 1, "Textarea element should have got one change event.");
|
||||
|
||||
|
@ -61,7 +61,7 @@ function testUserInput() {
|
|||
is(textareaChange, 1,
|
||||
"Change event dispatched when setting the value of the textarea element (2).");
|
||||
|
||||
textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).setUserInput("foo");
|
||||
textarea.setUserInput("foo");
|
||||
is(textareaChange, 1,
|
||||
"Change event dispatched when textarea element doesn't have focus.");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=838582
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 838582</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="reflect.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=838582">Mozilla Bug 838582</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<textarea id="t">abc</textarea>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 838582 **/
|
||||
|
||||
var textarea = document.getElementById("t");
|
||||
|
||||
is(t.textLength, 3, "Correct textLength for defaultValue");
|
||||
t.value = "abcdef";
|
||||
is(t.textLength, 6, "Correct textLength for value");
|
||||
ok(!("controllers" in t), "Don't have web-visible controllers property");
|
||||
ok("controllers" in SpecialPowers.wrap(t), "Have chrome-visible controllers property");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -430,6 +430,15 @@ DOMInterfaces = {
|
|||
]
|
||||
},
|
||||
|
||||
'HTMLTextAreaElement': {
|
||||
'resultNotAddRefed': [
|
||||
'form', 'controllers', 'editor'
|
||||
],
|
||||
'binaryNames': {
|
||||
'textLength': 'getTextLength'
|
||||
}
|
||||
},
|
||||
|
||||
'HTMLStyleElement': {
|
||||
'resultNotAddRefed': [
|
||||
'sheet'
|
||||
|
@ -1214,6 +1223,7 @@ addExternalIface('NamedNodeMap')
|
|||
addExternalIface('NodeIterator')
|
||||
addExternalIface('nsIStreamListener', nativeType='nsIStreamListener', notflattened=True)
|
||||
addExternalIface('nsISupports', nativeType='nsISupports')
|
||||
addExternalIface('nsIEditor', nativeType='nsIEditor', notflattened=True)
|
||||
addExternalIface('OutputStream', nativeType='nsIOutputStream',
|
||||
notflattened=True)
|
||||
addExternalIface('Principal', nativeType='nsIPrincipal',
|
||||
|
|
|
@ -9,8 +9,11 @@ interface nsIEditor;
|
|||
|
||||
/**
|
||||
* This interface is implemented by elements which have inner editable content,
|
||||
* such as HTML input and textarea.
|
||||
*/
|
||||
* such as HTML input and textarea.
|
||||
*
|
||||
* Please make sure to update the HTMLTextAreaElement Web IDL interface to
|
||||
* mirror this interface when changing it.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(b33eb56c-3120-418c-892b-774b00c7dde8)]
|
||||
interface nsIDOMNSEditableElement : nsISupports
|
||||
|
|
|
@ -60,5 +60,7 @@ interface nsIDOMHTMLTextAreaElement : nsIDOMHTMLElement
|
|||
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
|
|
@ -15,8 +15,7 @@ function runTests() {
|
|||
textElt.focus();
|
||||
textElt.value = text;
|
||||
textElt.select();
|
||||
textElt.QueryInterface(Components.interfaces.nsIDOMNSEditableElement)
|
||||
.editor.copy();
|
||||
SpecialPowers.wrap(textElt).editor.copy();
|
||||
|
||||
is(plugin.getClipboardText(), text);
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#the-textarea-element
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
interface nsIEditor;
|
||||
interface MozControllers;
|
||||
|
||||
interface HTMLTextAreaElement : HTMLElement {
|
||||
// attribute DOMString autocomplete;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean autofocus;
|
||||
[SetterThrows, Pure]
|
||||
attribute unsigned long cols;
|
||||
// attribute DOMString dirName;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean disabled;
|
||||
[Pure]
|
||||
readonly attribute HTMLFormElement? form;
|
||||
// attribute DOMString inputMode;
|
||||
[SetterThrows, Pure]
|
||||
attribute long maxLength;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString name;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString placeholder;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean readOnly;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean required;
|
||||
[SetterThrows, Pure]
|
||||
attribute unsigned long rows;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString wrap;
|
||||
|
||||
[Constant]
|
||||
readonly attribute DOMString type;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString defaultValue;
|
||||
[TreatNullAs=EmptyString] attribute DOMString value;
|
||||
readonly attribute unsigned long textLength;
|
||||
|
||||
readonly attribute boolean willValidate;
|
||||
readonly attribute ValidityState validity;
|
||||
readonly attribute DOMString validationMessage;
|
||||
boolean checkValidity();
|
||||
void setCustomValidity(DOMString error);
|
||||
|
||||
// readonly attribute NodeList labels;
|
||||
|
||||
void select();
|
||||
[Throws]
|
||||
attribute unsigned long selectionStart;
|
||||
[Throws]
|
||||
attribute unsigned long selectionEnd;
|
||||
[Throws]
|
||||
attribute DOMString selectionDirection;
|
||||
// void setRangeText(DOMString replacement);
|
||||
// void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode);
|
||||
[Throws]
|
||||
void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
|
||||
};
|
||||
|
||||
partial interface HTMLTextAreaElement {
|
||||
// Mirrored chrome-only Mozilla extensions to nsIDOMHTMLTextAreaElement.
|
||||
// Please make sure to update this list of nsIDOMHTMLTextAreaElement changes.
|
||||
|
||||
[Throws, ChromeOnly]
|
||||
readonly attribute MozControllers controllers;
|
||||
};
|
||||
|
||||
partial interface HTMLTextAreaElement {
|
||||
// Mirrored chrome-only nsIDOMNSEditableElement methods. Please make sure
|
||||
// to update this list if nsIDOMNSEditableElement changes.
|
||||
|
||||
[ChromeOnly]
|
||||
readonly attribute nsIEditor? editor;
|
||||
|
||||
// This is similar to set .value on nsIDOMInput/TextAreaElements, but
|
||||
// handling of the value change is closer to the normal user input, so
|
||||
// 'change' event for example will be dispatched when focusing out the
|
||||
// element.
|
||||
[ChromeOnly]
|
||||
void setUserInput(DOMString input);
|
||||
};
|
|
@ -108,6 +108,7 @@ webidl_files = \
|
|||
HTMLTableElement.webidl \
|
||||
HTMLTableRowElement.webidl \
|
||||
HTMLTableSectionElement.webidl \
|
||||
HTMLTextAreaElement.webidl \
|
||||
HTMLTimeElement.webidl \
|
||||
HTMLTitleElement.webidl \
|
||||
HTMLUListElement.webidl \
|
||||
|
|
|
@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338427
|
|||
/** Test for Bug 338427 **/
|
||||
function init() {
|
||||
var textarea = document.getElementById("editor");
|
||||
var editor = textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor;
|
||||
var editor = textarea.editor;
|
||||
var spellchecker = editor.getInlineSpellChecker(true);
|
||||
spellchecker.enableRealTimeSpell = true;
|
||||
|
||||
|
|
|
@ -27,9 +27,7 @@ addLoadEvent(function() SimpleTest.executeSoon(runTest));
|
|||
var gMisspeltWords;
|
||||
|
||||
function getEditor() {
|
||||
return document.getElementById("edit")
|
||||
.QueryInterface(Ci.nsIDOMNSEditableElement)
|
||||
.editor;
|
||||
return SpecialPowers.wrap(document.getElementById("edit")).editor;
|
||||
}
|
||||
|
||||
function getSpellCheckSelection() {
|
||||
|
|
|
@ -427,7 +427,7 @@ function runTests()
|
|||
textarea.removeAttribute("readonly");
|
||||
const nsIPlaintextEditor = Components.interfaces.nsIPlaintextEditor;
|
||||
const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
|
||||
var editor = textarea.QueryInterface(nsIDOMNSEditableElement).editor;
|
||||
var editor = SpecialPowers.wrap(textarea).editor;
|
||||
var flags = editor.flags;
|
||||
editor.flags = flags & ~(nsIPlaintextEditor.eEditorWidgetMask |
|
||||
nsIPlaintextEditor.eEditorAllowInteraction);
|
||||
|
|
|
@ -30,7 +30,7 @@ addLoadEvent(function() {
|
|||
|
||||
var content = document.getElementById('content');
|
||||
var i = document.getElementById('i');
|
||||
var t = document.getElementById('t');
|
||||
var t = SpecialPowers.wrap(document.getElementById('t'));
|
||||
i.value = ""; i.placeholder = "foo";
|
||||
t.value = ""; t.placeholder = "foo";
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ var fixedDiv1 = document.getElementById("fixedDiv1");
|
|||
var fixedDiv2 = document.getElementById("fixedDiv2");
|
||||
var iframe = document.getElementById("iframe");
|
||||
var input = document.getElementById("input");
|
||||
var textarea = document.getElementById("textarea");
|
||||
var textarea = SpecialPowers.wrap(document.getElementById("textarea"));
|
||||
|
||||
function test()
|
||||
{
|
||||
|
@ -409,4 +409,4 @@ SimpleTest.waitForExplicitFinish();
|
|||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче