2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2011-06-11 11:52:24 +04:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
#include "mozilla/dom/HTMLTextAreaElement.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
|
|
|
|
#include "mozAutoDocUpdate.h"
|
2014-03-17 10:56:54 +04:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-06-16 10:24:16 +03:00
|
|
|
#include "mozilla/dom/HTMLFormSubmission.h"
|
2013-02-19 09:54:23 +04:00
|
|
|
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2018-06-22 19:48:42 +03:00
|
|
|
#include "mozilla/MappedDeclarations.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2019-11-01 23:43:11 +03:00
|
|
|
#include "mozilla/PresState.h"
|
|
|
|
#include "mozilla/TextControlState.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2019-04-03 15:52:14 +03:00
|
|
|
#include "nsBaseCommandController.h"
|
2001-02-22 06:01:34 +03:00
|
|
|
#include "nsContentCID.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsFocusManager.h"
|
|
|
|
#include "nsIConstraintValidation.h"
|
|
|
|
#include "nsIControllers.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsIFormControlFrame.h"
|
1998-09-23 21:16:51 +04:00
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsIForm.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsIFrame.h"
|
2002-07-27 00:57:24 +04:00
|
|
|
#include "nsITextControlFrame.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
1999-12-02 02:05:58 +03:00
|
|
|
#include "nsLinebreakConverter.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsMappedAttributes.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsPresContext.h"
|
2001-12-23 19:06:13 +03:00
|
|
|
#include "nsReadableUtils.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2018-09-07 16:39:36 +03:00
|
|
|
#include "nsBaseCommandController.h"
|
2018-09-13 18:02:50 +03:00
|
|
|
#include "nsXULControllers.h"
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2004-06-02 04:25:00 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(TextArea)
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
HTMLTextAreaElement::HTMLTextAreaElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-02-19 01:18:40 +04:00
|
|
|
FromParser aFromParser)
|
2019-11-25 09:35:15 +03:00
|
|
|
: TextControlElement(std::move(aNodeInfo), aFromParser, NS_FORM_TEXTAREA),
|
2011-10-17 18:59:28 +04:00
|
|
|
mValueChanged(false),
|
2016-08-06 18:59:08 +03:00
|
|
|
mLastValueChangeWasInteractive(false),
|
2011-10-17 18:59:28 +04:00
|
|
|
mHandlingSelect(false),
|
2006-11-28 06:17:03 +03:00
|
|
|
mDoneAddingChildren(!aFromParser),
|
2010-10-25 16:17:38 +04:00
|
|
|
mInhibitStateRestoration(!!(aFromParser & FROM_PARSER_FRAGMENT)),
|
2011-10-17 18:59:28 +04:00
|
|
|
mDisabledChanged(false),
|
|
|
|
mCanShowInvalidUI(true),
|
|
|
|
mCanShowValidUI(true),
|
2017-03-22 11:55:56 +03:00
|
|
|
mIsPreviewEnabled(false),
|
2017-11-09 08:35:04 +03:00
|
|
|
mAutocompleteAttrState(nsContentUtils::eAutocompleteAttrState_Unknown),
|
2019-11-01 23:49:12 +03:00
|
|
|
mState(TextControlState::Construct(this)) {
|
2007-01-30 08:48:22 +03:00
|
|
|
AddMutationObserver(this);
|
2011-06-01 05:46:57 +04:00
|
|
|
|
|
|
|
// Set up our default state. By default we're enabled (since we're
|
|
|
|
// a control type that can be disabled but not actually disabled
|
|
|
|
// right now), optional, and valid. We are NOT readwrite by default
|
|
|
|
// until someone calls UpdateEditableState on us, apparently! Also
|
|
|
|
// by default we don't have to show validity UI and so forth.
|
|
|
|
AddStatesSilently(NS_EVENT_STATE_ENABLED | NS_EVENT_STATE_OPTIONAL |
|
|
|
|
NS_EVENT_STATE_VALID);
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
|
|
|
|
2019-11-01 23:49:12 +03:00
|
|
|
HTMLTextAreaElement::~HTMLTextAreaElement() {
|
|
|
|
mState->Destroy();
|
|
|
|
mState = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTextAreaElement)
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTextAreaElement,
|
|
|
|
TextControlElement)
|
2019-11-01 23:49:12 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
|
|
|
|
if (tmp->mState) {
|
|
|
|
tmp->mState->Traverse(cb);
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLTextAreaElement,
|
|
|
|
TextControlElement)
|
2019-11-01 23:49:12 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
|
|
|
|
if (tmp->mState) {
|
|
|
|
tmp->mState->Unlink();
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2007-03-08 14:17:16 +03:00
|
|
|
|
2017-09-01 02:29:22 +03:00
|
|
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLTextAreaElement,
|
2019-11-25 09:35:15 +03:00
|
|
|
TextControlElement,
|
2017-09-01 02:29:22 +03:00
|
|
|
nsIMutationObserver,
|
|
|
|
nsIConstraintValidation)
|
1998-09-03 05:03:33 +04:00
|
|
|
|
1998-09-23 21:16:51 +04:00
|
|
|
// nsIDOMHTMLTextAreaElement
|
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult HTMLTextAreaElement::Clone(dom::NodeInfo* aNodeInfo,
|
|
|
|
nsINode** aResult) const {
|
2016-09-15 20:52:37 +03:00
|
|
|
*aResult = nullptr;
|
2018-09-21 23:45:49 +03:00
|
|
|
RefPtr<HTMLTextAreaElement> it =
|
|
|
|
new HTMLTextAreaElement(do_AddRef(aNodeInfo));
|
2016-09-15 20:52:37 +03:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult rv = const_cast<HTMLTextAreaElement*>(this)->CopyInnerTo(it);
|
2016-09-15 20:52:37 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (mValueChanged) {
|
|
|
|
// Set our value on the clone.
|
|
|
|
nsAutoString value;
|
|
|
|
GetValueInternal(value, true);
|
|
|
|
|
|
|
|
// SetValueInternal handles setting mValueChanged for us
|
2019-11-01 23:43:11 +03:00
|
|
|
rv = it->SetValueInternal(value, TextControlState::eSetValue_Notify);
|
2016-09-15 20:52:37 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
it->mLastValueChangeWasInteractive = mLastValueChangeWasInteractive;
|
|
|
|
it.forget(aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-07-28 09:26:55 +04:00
|
|
|
|
2000-12-23 13:56:31 +03:00
|
|
|
// nsIContent
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::Select() {
|
2008-10-07 22:53:23 +04:00
|
|
|
// XXX Bug? We have to give the input focus before contents can be
|
|
|
|
// selected
|
2000-05-30 06:45:55 +04:00
|
|
|
|
2008-10-07 22:53:23 +04:00
|
|
|
FocusTristate state = FocusState();
|
|
|
|
if (state == eUnfocusable) {
|
2017-10-31 02:14:51 +03:00
|
|
|
return;
|
2006-07-13 13:14:56 +04:00
|
|
|
}
|
|
|
|
|
2018-04-27 06:35:19 +03:00
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPresContext> presContext = GetPresContext(eForComposedDoc);
|
2008-10-07 22:53:23 +04:00
|
|
|
if (state == eInactiveWindow) {
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
if (fm) fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL);
|
2008-10-07 22:53:23 +04:00
|
|
|
SelectAll(presContext);
|
2017-10-31 02:14:51 +03:00
|
|
|
return;
|
2008-10-07 22:53:23 +04:00
|
|
|
}
|
2000-09-09 05:22:01 +04:00
|
|
|
|
2000-09-08 05:46:00 +04:00
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2015-09-02 09:08:00 +03:00
|
|
|
WidgetGUIEvent event(true, eFormSelect, nullptr);
|
2013-03-28 23:41:32 +04:00
|
|
|
// XXXbz HTMLInputElement guards against this reentering; shouldn't we?
|
2014-03-18 08:48:21 +04:00
|
|
|
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext, &event,
|
|
|
|
nullptr, &status);
|
2000-05-30 06:45:55 +04:00
|
|
|
|
2000-12-23 13:56:31 +03:00
|
|
|
// If the DOM event was not canceled (e.g. by a JS event handler
|
|
|
|
// returning false)
|
2000-09-09 05:22:01 +04:00
|
|
|
if (status == nsEventStatus_eIgnore) {
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
if (fm) {
|
|
|
|
fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL);
|
|
|
|
|
|
|
|
// ensure that the element is actually focused
|
2018-04-27 06:35:19 +03:00
|
|
|
if (this == fm->GetFocusedElement()) {
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
// Now Select all the text!
|
|
|
|
SelectAll(presContext);
|
2004-11-04 04:32:40 +03:00
|
|
|
}
|
2000-09-09 05:22:01 +04:00
|
|
|
}
|
|
|
|
}
|
2000-05-30 06:45:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-02-19 01:18:40 +04:00
|
|
|
HTMLTextAreaElement::SelectAll(nsPresContext* aPresContext) {
|
2011-10-17 18:59:28 +04:00
|
|
|
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
|
2000-12-23 13:56:31 +03:00
|
|
|
|
|
|
|
if (formControlFrame) {
|
2006-12-26 20:47:52 +03:00
|
|
|
formControlFrame->SetFormProperty(nsGkAtoms::select, EmptyString());
|
1998-09-23 21:16:51 +04:00
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
return NS_OK;
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
bool HTMLTextAreaElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
|
|
|
int32_t* aTabIndex) {
|
2013-08-02 05:21:31 +04:00
|
|
|
if (nsGenericHTMLFormElementWithState::IsHTMLFocusable(
|
|
|
|
aWithMouse, aIsFocusable, aTabIndex)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// disabled textareas are not focusable
|
2010-09-19 01:33:16 +04:00
|
|
|
*aIsFocusable = !IsDisabled();
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
int32_t HTMLTextAreaElement::TabIndexDefault() { return 0; }
|
1998-10-20 21:07:23 +04:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::GetType(nsAString& aType) {
|
2004-06-17 04:13:25 +04:00
|
|
|
aType.AssignLiteral("textarea");
|
1998-10-20 21:07:23 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::GetValue(nsAString& aValue) {
|
2019-11-25 09:35:17 +03:00
|
|
|
GetValueInternal(aValue, true);
|
|
|
|
MOZ_ASSERT(aValue.FindChar(static_cast<char16_t>('\r')) == -1);
|
2002-05-16 22:26:05 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::GetValueInternal(nsAString& aValue,
|
|
|
|
bool aIgnoreWrap) const {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->GetValue(aValue, aIgnoreWrap);
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:17 +03:00
|
|
|
bool HTMLTextAreaElement::ValueEquals(const nsAString& aValue) const {
|
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->ValueEquals(aValue);
|
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
TextEditor* HTMLTextAreaElement::GetTextEditor() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->GetTextEditor();
|
|
|
|
}
|
2010-04-22 00:17:41 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
TextEditor* HTMLTextAreaElement::GetTextEditorWithoutCreation() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->GetTextEditorWithoutCreation();
|
2018-11-21 06:59:02 +03:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
nsISelectionController* HTMLTextAreaElement::GetSelectionController() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->GetSelectionController();
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
nsFrameSelection* HTMLTextAreaElement::GetConstFrameSelection() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->GetConstFrameSelection();
|
1998-10-20 21:07:23 +04:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
nsresult HTMLTextAreaElement::BindToFrame(nsTextControlFrame* aFrame) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->BindToFrame(aFrame);
|
2002-12-17 02:49:16 +03:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
2010-07-22 04:59:25 +04:00
|
|
|
if (aFrame) {
|
2019-11-01 23:49:12 +03:00
|
|
|
mState->UnbindFromFrame(aFrame);
|
2010-07-22 04:59:25 +04:00
|
|
|
}
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
2001-11-19 13:35:52 +03:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
nsresult HTMLTextAreaElement::CreateEditor() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->PrepareEditor();
|
|
|
|
}
|
2001-11-16 05:38:10 +03:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::UpdateOverlayTextVisibility(bool aNotify) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->UpdateOverlayTextVisibility(aNotify);
|
2012-11-09 14:22:29 +04:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::GetPlaceholderVisibility() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->GetPlaceholderVisibility();
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::SetPreviewValue(const nsAString& aValue) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->SetPreviewText(aValue, true);
|
2017-03-20 19:08:01 +03:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::GetPreviewValue(nsAString& aValue) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->GetPreviewText(aValue);
|
2017-03-20 19:08:01 +03:00
|
|
|
}
|
2017-03-20 06:53:40 +03:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::EnablePreview() {
|
2017-03-22 11:55:56 +03:00
|
|
|
if (mIsPreviewEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mIsPreviewEnabled = true;
|
|
|
|
// Reconstruct the frame to append an anonymous preview node
|
2019-03-14 14:47:50 +03:00
|
|
|
nsLayoutUtils::PostRestyleEvent(this, RestyleHint{0},
|
2017-03-22 11:55:56 +03:00
|
|
|
nsChangeHint_ReconstructFrame);
|
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::IsPreviewEnabled() { return mIsPreviewEnabled; }
|
2017-03-22 11:55:56 +03:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::GetPreviewVisibility() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->GetPreviewVisibility();
|
2017-03-30 12:38:59 +03:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
nsresult HTMLTextAreaElement::SetValueInternal(const nsAString& aValue,
|
2015-06-18 17:56:20 +03:00
|
|
|
uint32_t aFlags) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
|
2017-03-09 22:44:04 +03:00
|
|
|
// Need to set the value changed flag here if our value has in fact changed
|
|
|
|
// (i.e. if eSetValue_Notify is in aFlags), so that
|
|
|
|
// nsTextControlFrame::UpdateValueDisplay retrieves the correct value if
|
|
|
|
// needed.
|
2019-11-01 23:43:11 +03:00
|
|
|
if (aFlags & TextControlState::eSetValue_Notify) {
|
2017-03-09 22:44:04 +03:00
|
|
|
SetValueChanged(true);
|
|
|
|
}
|
|
|
|
|
2019-11-01 23:49:12 +03:00
|
|
|
if (!mState->SetValue(aValue, aFlags)) {
|
2015-01-08 04:14:01 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
1999-02-01 21:44:59 +03:00
|
|
|
return NS_OK;
|
1998-10-20 21:07:23 +04:00
|
|
|
}
|
1998-09-03 05:03:33 +04:00
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
void HTMLTextAreaElement::SetValue(const nsAString& aValue,
|
|
|
|
ErrorResult& aError) {
|
2012-09-05 16:40:13 +04:00
|
|
|
// 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
|
|
|
|
// event, we should keep it that way. Otherwise, we should make sure the
|
|
|
|
// element will not fire any event because of the script interaction.
|
|
|
|
//
|
|
|
|
// NOTE: this is currently quite expensive work (too much string
|
|
|
|
// manipulation). We should probably optimize that.
|
|
|
|
nsAutoString currentValue;
|
|
|
|
GetValueInternal(currentValue, true);
|
|
|
|
|
2017-05-01 20:26:21 +03:00
|
|
|
nsresult rv = SetValueInternal(
|
2019-11-01 23:43:11 +03:00
|
|
|
aValue, TextControlState::eSetValue_ByContent |
|
|
|
|
TextControlState::eSetValue_Notify |
|
|
|
|
TextControlState::eSetValue_MoveCursorToEndIfValueChanged);
|
2017-10-31 02:14:51 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
aError.Throw(rv);
|
|
|
|
return;
|
|
|
|
}
|
2012-09-05 16:40:13 +04:00
|
|
|
|
|
|
|
if (mFocusedValue.Equals(currentValue)) {
|
|
|
|
GetValueInternal(mFocusedValue, true);
|
|
|
|
}
|
2001-12-11 08:39:36 +03:00
|
|
|
}
|
|
|
|
|
2018-06-02 05:35:23 +03:00
|
|
|
void HTMLTextAreaElement::SetUserInput(const nsAString& aValue,
|
|
|
|
nsIPrincipal& aSubjectPrincipal) {
|
2018-06-02 05:35:23 +03:00
|
|
|
SetValueInternal(
|
2019-11-01 23:43:11 +03:00
|
|
|
aValue, TextControlState::eSetValue_BySetUserInput |
|
|
|
|
TextControlState::eSetValue_Notify |
|
|
|
|
TextControlState::eSetValue_MoveCursorToEndIfValueChanged);
|
2007-10-02 20:56:07 +04:00
|
|
|
}
|
2001-11-05 09:50:21 +03:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
nsresult HTMLTextAreaElement::SetValueChanged(bool aValueChanged) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool previousValue = mValueChanged;
|
2010-11-24 02:46:49 +03:00
|
|
|
|
2001-12-23 19:06:13 +03:00
|
|
|
mValueChanged = aValueChanged;
|
2019-11-01 23:49:12 +03:00
|
|
|
if (!aValueChanged && !mState->IsEmpty()) {
|
|
|
|
mState->EmptyValue();
|
2013-03-25 23:35:55 +04:00
|
|
|
}
|
2010-08-25 08:39:10 +04:00
|
|
|
|
2010-11-24 02:49:50 +03:00
|
|
|
if (mValueChanged != previousValue) {
|
2011-06-01 05:46:57 +04:00
|
|
|
UpdateState(true);
|
2010-08-25 08:39:10 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 09:50:21 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
void HTMLTextAreaElement::GetDefaultValue(nsAString& aDefaultValue,
|
|
|
|
ErrorResult& aError) {
|
2015-05-22 21:16:20 +03:00
|
|
|
if (!nsContentUtils::GetNodeTextContent(this, false, aDefaultValue,
|
|
|
|
fallible)) {
|
2017-10-31 02:14:51 +03:00
|
|
|
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
2014-03-20 23:51:16 +04:00
|
|
|
}
|
2013-02-19 09:54:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void HTMLTextAreaElement::SetDefaultValue(const nsAString& aDefaultValue,
|
|
|
|
ErrorResult& aError) {
|
2011-10-17 18:59:28 +04:00
|
|
|
nsresult rv = nsContentUtils::SetNodeTextContent(this, aDefaultValue, true);
|
2005-06-02 06:30:09 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && !mValueChanged) {
|
|
|
|
Reset();
|
|
|
|
}
|
2013-02-19 09:54:23 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aError.Throw(rv);
|
|
|
|
}
|
2001-12-23 19:06:13 +03:00
|
|
|
}
|
1999-12-02 02:05:58 +03:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
bool HTMLTextAreaElement::ParseAttribute(int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2013-02-19 01:18:40 +04:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2013-02-19 01:18:40 +04:00
|
|
|
nsAttrValue& aResult) {
|
2005-11-29 19:37:15 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2016-08-17 07:11:24 +03:00
|
|
|
if (aAttribute == nsGkAtoms::maxlength ||
|
|
|
|
aAttribute == nsGkAtoms::minlength) {
|
2010-03-05 22:38:26 +03:00
|
|
|
return aResult.ParseNonNegativeIntValue(aValue);
|
2016-08-21 18:09:20 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::cols) {
|
|
|
|
aResult.ParseIntWithFallback(aValue, DEFAULT_COLS);
|
|
|
|
return true;
|
|
|
|
} else if (aAttribute == nsGkAtoms::rows) {
|
|
|
|
aResult.ParseIntWithFallback(aValue, DEFAULT_ROWS_TEXTAREA);
|
|
|
|
return true;
|
2017-11-09 08:35:04 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::autocomplete) {
|
|
|
|
aResult.ParseAtomArray(aValue);
|
|
|
|
return true;
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
1998-09-23 21:16:51 +04:00
|
|
|
}
|
2005-11-29 19:37:15 +03:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
aMaybeScriptedPrincipal, aResult);
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
void HTMLTextAreaElement::MapAttributesIntoRule(
|
|
|
|
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) {
|
2018-03-29 04:39:07 +03:00
|
|
|
// wrap=off
|
2018-06-22 19:48:42 +03:00
|
|
|
if (!aDecls.PropertyIsSet(eCSSProperty_white_space)) {
|
2018-03-29 04:39:07 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::wrap);
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
|
|
|
value->Equals(nsGkAtoms::OFF, eIgnoreCase)) {
|
2018-06-22 19:48:42 +03:00
|
|
|
aDecls.SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::Pre);
|
2014-10-28 20:33:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-22 19:48:42 +03:00
|
|
|
nsGenericHTMLFormElementWithState::MapDivAlignAttributeInto(aAttributes,
|
|
|
|
aDecls);
|
|
|
|
nsGenericHTMLFormElementWithState::MapCommonAttributesInto(aAttributes,
|
|
|
|
aDecls);
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsChangeHint HTMLTextAreaElement::GetAttributeChangeHint(
|
2013-02-19 01:18:40 +04:00
|
|
|
const nsAtom* aAttribute, int32_t aModType) const {
|
2004-10-24 21:10:32 +04:00
|
|
|
nsChangeHint retval =
|
2013-08-02 05:21:31 +04:00
|
|
|
nsGenericHTMLFormElementWithState::GetAttributeChangeHint(aAttribute,
|
|
|
|
aModType);
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::rows || aAttribute == nsGkAtoms::cols) {
|
2016-05-23 06:26:03 +03:00
|
|
|
retval |= NS_STYLE_HINT_REFLOW;
|
2010-02-06 11:51:10 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::wrap) {
|
2016-05-23 06:26:03 +03:00
|
|
|
retval |= nsChangeHint_ReconstructFrame;
|
2010-10-19 17:11:07 +04:00
|
|
|
} else if (aAttribute == nsGkAtoms::placeholder) {
|
2016-07-06 08:06:14 +03:00
|
|
|
retval |= nsChangeHint_ReconstructFrame;
|
2003-07-12 01:16:12 +04:00
|
|
|
}
|
2004-10-24 21:10:32 +04:00
|
|
|
return retval;
|
2003-07-12 01:16:12 +04:00
|
|
|
}
|
2003-04-17 00:54:20 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2017-10-03 01:05:19 +03:00
|
|
|
HTMLTextAreaElement::IsAttributeMapped(const nsAtom* aAttribute) const {
|
2014-10-30 16:09:22 +03:00
|
|
|
static const MappedAttributeEntry attributes[] = {{nsGkAtoms::wrap},
|
2014-10-28 20:33:15 +03:00
|
|
|
{nullptr}};
|
|
|
|
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2014-10-28 20:33:15 +03:00
|
|
|
attributes,
|
2003-07-12 01:16:12 +04:00
|
|
|
sDivAlignAttributeMap,
|
2003-04-17 00:54:20 +04:00
|
|
|
sCommonAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-07-07 05:24:40 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
nsMapRuleToAttributesFunc HTMLTextAreaElement::GetAttributeMappingFunction()
|
|
|
|
const {
|
2005-01-12 22:45:38 +03:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-05 08:00:06 +04:00
|
|
|
}
|
|
|
|
|
2018-10-31 11:55:33 +03:00
|
|
|
bool HTMLTextAreaElement::IsDisabledForEvents(WidgetEvent* aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
nsIFormControlFrame* formControlFrame = GetFormControlFrame(false);
|
2014-03-25 19:36:49 +04:00
|
|
|
nsIFrame* formFrame = do_QueryFrame(formControlFrame);
|
2018-10-31 11:55:33 +03:00
|
|
|
return IsElementDisabledForEvents(aEvent, formFrame);
|
2013-01-03 19:17:36 +04:00
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2016-10-21 05:11:07 +03:00
|
|
|
void HTMLTextAreaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aVisitor.mCanHandle = false;
|
2018-10-31 11:55:33 +03:00
|
|
|
if (IsDisabledForEvents(aVisitor.mEvent)) {
|
2018-04-05 20:42:41 +03:00
|
|
|
return;
|
2000-08-09 03:38:00 +04:00
|
|
|
}
|
|
|
|
|
2003-04-22 07:27:24 +04:00
|
|
|
// Don't dispatch a second select event if we are already handling
|
|
|
|
// one.
|
2015-09-02 09:08:00 +03:00
|
|
|
if (aVisitor.mEvent->mMessage == eFormSelect) {
|
2006-03-07 20:08:51 +03:00
|
|
|
if (mHandlingSelect) {
|
2018-04-05 20:42:41 +03:00
|
|
|
return;
|
2006-03-07 20:08:51 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mHandlingSelect = true;
|
2003-04-22 07:27:24 +04:00
|
|
|
}
|
|
|
|
|
2015-09-02 09:08:00 +03:00
|
|
|
if (aVisitor.mEvent->mMessage == eBlur) {
|
2016-10-21 12:33:41 +03:00
|
|
|
// Set mWantsPreHandleEvent and fire change event in PreHandleEvent to
|
|
|
|
// prevent it breaks event target chain creation.
|
|
|
|
aVisitor.mWantsPreHandleEvent = true;
|
2007-02-16 19:19:28 +03:00
|
|
|
}
|
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
nsGenericHTMLFormElementWithState::GetEventTargetParent(aVisitor);
|
2006-03-07 20:08:51 +03:00
|
|
|
}
|
2000-09-02 08:59:44 +04:00
|
|
|
|
2016-10-21 12:33:41 +03:00
|
|
|
nsresult HTMLTextAreaElement::PreHandleEvent(EventChainVisitor& aVisitor) {
|
|
|
|
if (aVisitor.mEvent->mMessage == eBlur) {
|
|
|
|
// Fire onchange (if necessary), before we do the blur, bug 370521.
|
|
|
|
FireChangeEventIfNeeded();
|
|
|
|
}
|
|
|
|
return nsGenericHTMLFormElementWithState::PreHandleEvent(aVisitor);
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::FireChangeEventIfNeeded() {
|
2012-05-24 14:54:25 +04:00
|
|
|
nsString value;
|
|
|
|
GetValueInternal(value, true);
|
|
|
|
|
|
|
|
if (mFocusedValue.Equals(value)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dispatch the change event.
|
|
|
|
mFocusedValue = value;
|
|
|
|
nsContentUtils::DispatchTrustedEvent(
|
|
|
|
OwnerDoc(), static_cast<nsIContent*>(this), NS_LITERAL_STRING("change"),
|
2018-06-25 19:23:50 +03:00
|
|
|
CanBubble::eYes, Cancelable::eNo);
|
2012-05-07 20:27:24 +04:00
|
|
|
}
|
|
|
|
|
2014-03-18 08:48:20 +04:00
|
|
|
nsresult HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
2015-09-02 09:08:00 +03:00
|
|
|
if (aVisitor.mEvent->mMessage == eFormSelect) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mHandlingSelect = false;
|
2003-04-22 07:27:24 +04:00
|
|
|
}
|
|
|
|
|
2015-09-02 09:08:00 +03:00
|
|
|
if (aVisitor.mEvent->mMessage == eFocus ||
|
2015-09-02 09:08:00 +03:00
|
|
|
aVisitor.mEvent->mMessage == eBlur) {
|
2015-09-02 09:08:00 +03:00
|
|
|
if (aVisitor.mEvent->mMessage == eFocus) {
|
2010-11-24 02:50:53 +03:00
|
|
|
// If the invalid UI is shown, we should show it while focusing (and
|
|
|
|
// update). Otherwise, we should not.
|
2012-05-07 20:27:24 +04:00
|
|
|
GetValueInternal(mFocusedValue, true);
|
2011-01-20 14:05:29 +03:00
|
|
|
mCanShowInvalidUI = !IsValid() && ShouldShowValidityUI();
|
2010-11-24 02:56:24 +03:00
|
|
|
|
|
|
|
// If neither invalid UI nor valid UI is shown, we shouldn't show the
|
|
|
|
// valid UI while typing.
|
2011-01-20 14:05:29 +03:00
|
|
|
mCanShowValidUI = ShouldShowValidityUI();
|
2015-09-02 09:08:00 +03:00
|
|
|
} else { // eBlur
|
2011-10-17 18:59:28 +04:00
|
|
|
mCanShowInvalidUI = true;
|
|
|
|
mCanShowValidUI = true;
|
2010-11-24 02:50:53 +03:00
|
|
|
}
|
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
UpdateState(true);
|
2010-08-25 08:39:10 +04:00
|
|
|
}
|
|
|
|
|
2006-03-07 20:08:51 +03:00
|
|
|
return NS_OK;
|
1998-09-03 05:03:33 +04:00
|
|
|
}
|
1998-09-23 21:16:51 +04:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::DoneAddingChildren(bool aHaveNotified) {
|
2005-06-16 04:41:50 +04:00
|
|
|
if (!mValueChanged) {
|
|
|
|
if (!mDoneAddingChildren) {
|
|
|
|
// Reset now that we're done adding children if the content sink tried to
|
|
|
|
// sneak some text in without calling AppendChildTo.
|
|
|
|
Reset();
|
|
|
|
}
|
2013-08-02 05:21:31 +04:00
|
|
|
|
2010-06-09 10:45:32 +04:00
|
|
|
if (!mInhibitStateRestoration) {
|
2019-07-01 10:20:04 +03:00
|
|
|
GenerateStateKey();
|
|
|
|
RestoreFormControlState();
|
2010-06-09 10:45:32 +04:00
|
|
|
}
|
2005-06-16 04:41:50 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mDoneAddingChildren = true;
|
2002-03-31 14:14:01 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
bool HTMLTextAreaElement::IsDoneAddingChildren() { return mDoneAddingChildren; }
|
1998-09-23 21:16:51 +04:00
|
|
|
|
1999-11-19 10:24:15 +03:00
|
|
|
// Controllers Methods
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
nsIControllers* HTMLTextAreaElement::GetControllers(ErrorResult& aError) {
|
1999-11-19 10:24:15 +03:00
|
|
|
if (!mControllers) {
|
2018-09-15 03:36:22 +03:00
|
|
|
mControllers = new nsXULControllers();
|
2018-09-13 18:02:50 +03:00
|
|
|
if (!mControllers) {
|
|
|
|
aError.Throw(NS_ERROR_FAILURE);
|
2013-02-19 09:54:23 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2002-12-11 17:24:49 +03:00
|
|
|
|
2019-04-03 15:52:14 +03:00
|
|
|
RefPtr<nsBaseCommandController> commandController =
|
2018-09-07 06:59:57 +03:00
|
|
|
nsBaseCommandController::CreateEditorController();
|
2019-04-03 15:52:14 +03:00
|
|
|
if (!commandController) {
|
2018-09-07 06:59:57 +03:00
|
|
|
aError.Throw(NS_ERROR_FAILURE);
|
2013-02-19 09:54:23 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2019-04-03 15:52:14 +03:00
|
|
|
mControllers->AppendController(commandController);
|
2011-12-24 04:11:30 +04:00
|
|
|
|
2019-04-03 15:52:14 +03:00
|
|
|
commandController = nsBaseCommandController::CreateEditingController();
|
|
|
|
if (!commandController) {
|
2018-09-07 16:39:36 +03:00
|
|
|
aError.Throw(NS_ERROR_FAILURE);
|
2013-02-19 09:54:23 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2011-12-24 04:11:30 +04:00
|
|
|
|
2019-04-03 15:52:14 +03:00
|
|
|
mControllers->AppendController(commandController);
|
1999-11-19 10:24:15 +03:00
|
|
|
}
|
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
return mControllers;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult HTMLTextAreaElement::GetControllers(nsIControllers** aResult) {
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
|
|
|
|
ErrorResult error;
|
|
|
|
*aResult = GetControllers(error);
|
1999-11-19 10:24:15 +03:00
|
|
|
NS_IF_ADDREF(*aResult);
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2015-04-27 16:18:51 +03:00
|
|
|
return error.StealNSResult();
|
2013-02-19 09:54:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t HTMLTextAreaElement::GetTextLength() {
|
|
|
|
nsAutoString val;
|
|
|
|
GetValue(val);
|
|
|
|
return val.Length();
|
1999-11-19 10:24:15 +03:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
Nullable<uint32_t> HTMLTextAreaElement::GetSelectionStart(ErrorResult& aError) {
|
2017-03-09 22:44:45 +03:00
|
|
|
uint32_t selStart, selEnd;
|
2017-03-09 22:44:04 +03:00
|
|
|
GetSelectionRange(&selStart, &selEnd, aError);
|
2016-08-09 00:19:00 +03:00
|
|
|
return Nullable<uint32_t>(selStart);
|
2002-06-28 00:22:28 +04:00
|
|
|
}
|
|
|
|
|
2016-08-09 00:19:00 +03:00
|
|
|
void HTMLTextAreaElement::SetSelectionStart(
|
|
|
|
const Nullable<uint32_t>& aSelectionStart, ErrorResult& aError) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->SetSelectionStart(aSelectionStart, aError);
|
2002-06-28 00:22:28 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
Nullable<uint32_t> HTMLTextAreaElement::GetSelectionEnd(ErrorResult& aError) {
|
2017-03-09 22:44:45 +03:00
|
|
|
uint32_t selStart, selEnd;
|
2017-03-09 22:44:04 +03:00
|
|
|
GetSelectionRange(&selStart, &selEnd, aError);
|
2016-08-09 00:19:00 +03:00
|
|
|
return Nullable<uint32_t>(selEnd);
|
2003-01-09 09:06:17 +03:00
|
|
|
}
|
2002-06-28 00:22:28 +04:00
|
|
|
|
2016-08-09 00:19:00 +03:00
|
|
|
void HTMLTextAreaElement::SetSelectionEnd(
|
|
|
|
const Nullable<uint32_t>& aSelectionEnd, ErrorResult& aError) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->SetSelectionEnd(aSelectionEnd, aError);
|
2011-07-28 21:51:22 +04:00
|
|
|
}
|
|
|
|
|
2017-03-09 22:44:45 +03:00
|
|
|
void HTMLTextAreaElement::GetSelectionRange(uint32_t* aSelectionStart,
|
|
|
|
uint32_t* aSelectionEnd,
|
2017-03-09 22:44:04 +03:00
|
|
|
ErrorResult& aRv) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->GetSelectionRange(aSelectionStart, aSelectionEnd, aRv);
|
2002-06-28 00:22:28 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
void HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection,
|
|
|
|
ErrorResult& aError) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->GetSelectionDirectionString(aDirection, aError);
|
2013-02-19 09:54:23 +04:00
|
|
|
}
|
|
|
|
|
2016-08-09 00:19:00 +03:00
|
|
|
void HTMLTextAreaElement::SetSelectionDirection(const nsAString& aDirection,
|
|
|
|
ErrorResult& aError) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->SetSelectionDirection(aDirection, aError);
|
2011-07-28 21:51:22 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
void HTMLTextAreaElement::SetSelectionRange(
|
|
|
|
uint32_t aSelectionStart, uint32_t aSelectionEnd,
|
|
|
|
const Optional<nsAString>& aDirection, ErrorResult& aError) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->SetSelectionRange(aSelectionStart, aSelectionEnd, aDirection, aError);
|
2013-02-19 09:54:23 +04:00
|
|
|
}
|
2003-01-09 09:06:17 +03:00
|
|
|
|
2013-10-04 19:30:07 +04:00
|
|
|
void HTMLTextAreaElement::SetRangeText(const nsAString& aReplacement,
|
|
|
|
ErrorResult& aRv) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->SetRangeText(aReplacement, aRv);
|
2013-10-04 19:30:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void HTMLTextAreaElement::SetRangeText(const nsAString& aReplacement,
|
|
|
|
uint32_t aStart, uint32_t aEnd,
|
2017-03-09 22:44:06 +03:00
|
|
|
SelectionMode aSelectMode,
|
|
|
|
ErrorResult& aRv) {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->SetRangeText(aReplacement, aStart, aEnd, aSelectMode, aRv);
|
2017-03-09 22:44:06 +03:00
|
|
|
}
|
2013-10-04 19:30:07 +04:00
|
|
|
|
2017-03-09 22:44:06 +03:00
|
|
|
void HTMLTextAreaElement::GetValueFromSetRangeText(nsAString& aValue) {
|
|
|
|
GetValueInternal(aValue, false);
|
|
|
|
}
|
2013-10-04 19:30:07 +04:00
|
|
|
|
2017-03-09 22:44:06 +03:00
|
|
|
nsresult HTMLTextAreaElement::SetValueFromSetRangeText(
|
|
|
|
const nsAString& aValue) {
|
2019-11-01 23:43:11 +03:00
|
|
|
return SetValueInternal(aValue, TextControlState::eSetValue_ByContent |
|
|
|
|
TextControlState::eSetValue_Notify);
|
2013-10-04 19:30:07 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
nsresult HTMLTextAreaElement::Reset() {
|
2010-08-21 21:52:57 +04:00
|
|
|
nsAutoString resetVal;
|
2018-02-01 22:21:14 +03:00
|
|
|
GetDefaultValue(resetVal, IgnoreErrors());
|
2017-03-09 22:44:04 +03:00
|
|
|
SetValueChanged(false);
|
|
|
|
|
2017-03-09 22:44:04 +03:00
|
|
|
nsresult rv =
|
2019-11-01 23:43:11 +03:00
|
|
|
SetValueInternal(resetVal, TextControlState::eSetValue_Internal);
|
2010-08-21 21:52:57 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-02-16 04:19:24 +03:00
|
|
|
NS_IMETHODIMP
|
2016-06-16 10:24:16 +03:00
|
|
|
HTMLTextAreaElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission) {
|
2002-02-16 04:19:24 +03:00
|
|
|
// Disabled elements don't submit
|
2010-09-19 01:33:16 +04:00
|
|
|
if (IsDisabled()) {
|
|
|
|
return NS_OK;
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
|
2002-02-16 04:19:24 +03:00
|
|
|
//
|
|
|
|
// Get the name (if no name, no submit)
|
|
|
|
//
|
2001-11-02 10:40:01 +03:00
|
|
|
nsAutoString name;
|
2010-11-23 11:50:55 +03:00
|
|
|
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
|
|
|
if (name.IsEmpty()) {
|
2005-10-28 15:25:24 +04:00
|
|
|
return NS_OK;
|
2002-02-16 04:19:24 +03:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
|
2002-02-16 04:19:24 +03:00
|
|
|
//
|
|
|
|
// Get the value
|
|
|
|
//
|
2001-11-02 10:40:01 +03:00
|
|
|
nsAutoString value;
|
2011-10-17 18:59:28 +04:00
|
|
|
GetValueInternal(value, false);
|
2001-11-02 10:40:01 +03:00
|
|
|
|
2002-02-16 04:19:24 +03:00
|
|
|
//
|
|
|
|
// Submit
|
|
|
|
//
|
2011-11-16 11:50:19 +04:00
|
|
|
return aFormSubmission->AddNameValuePair(name, value);
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-02-19 01:18:40 +04:00
|
|
|
HTMLTextAreaElement::SaveState() {
|
2002-03-31 14:14:01 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Only save if value != defaultValue (bug 62713)
|
2018-03-02 21:18:35 +03:00
|
|
|
PresState* state = nullptr;
|
2002-03-31 14:14:01 +04:00
|
|
|
if (mValueChanged) {
|
2013-07-24 11:38:13 +04:00
|
|
|
state = GetPrimaryPresState();
|
2002-03-31 14:14:01 +04:00
|
|
|
if (state) {
|
|
|
|
nsAutoString value;
|
2011-10-17 18:59:28 +04:00
|
|
|
GetValueInternal(value, true);
|
2002-03-31 14:14:01 +04:00
|
|
|
|
|
|
|
rv = nsLinebreakConverter::ConvertStringLineBreaks(
|
|
|
|
value, nsLinebreakConverter::eLinebreakPlatform,
|
|
|
|
nsLinebreakConverter::eLinebreakContent);
|
2016-05-06 01:50:35 +03:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Converting linebreaks failed!");
|
|
|
|
return rv;
|
|
|
|
}
|
2008-12-12 22:25:22 +03:00
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
state->contentData() = std::move(value);
|
2002-03-31 14:14:01 +04:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
|
|
|
|
2006-11-28 06:17:03 +03:00
|
|
|
if (mDisabledChanged) {
|
|
|
|
if (!state) {
|
2013-07-24 11:38:13 +04:00
|
|
|
state = GetPrimaryPresState();
|
|
|
|
rv = NS_OK;
|
2006-11-28 06:17:03 +03:00
|
|
|
}
|
|
|
|
if (state) {
|
2010-09-19 01:33:16 +04:00
|
|
|
// We do not want to save the real disabled state but the disabled
|
|
|
|
// attribute.
|
2018-03-02 21:18:35 +03:00
|
|
|
state->disabled() = HasAttr(kNameSpaceID_None, nsGkAtoms::disabled);
|
|
|
|
state->disabledSet() = true;
|
2006-11-28 06:17:03 +03:00
|
|
|
}
|
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2018-03-02 21:18:35 +03:00
|
|
|
bool HTMLTextAreaElement::RestoreState(PresState* aState) {
|
|
|
|
const PresContentData& state = aState->contentData();
|
2017-06-13 05:19:28 +03:00
|
|
|
|
2018-03-02 21:18:35 +03:00
|
|
|
if (state.type() == PresContentData::TnsString) {
|
2017-10-31 02:14:51 +03:00
|
|
|
ErrorResult rv;
|
2018-03-02 21:18:35 +03:00
|
|
|
SetValue(state.get_nsString(), rv);
|
2017-10-31 02:14:51 +03:00
|
|
|
ENSURE_SUCCESS(rv, false);
|
2008-08-14 14:06:40 +04:00
|
|
|
}
|
2007-10-10 07:39:16 +04:00
|
|
|
|
2018-03-02 21:18:35 +03:00
|
|
|
if (aState->disabledSet() && !aState->disabled()) {
|
2018-02-01 22:21:14 +03:00
|
|
|
SetDisabled(false, IgnoreErrors());
|
2006-11-28 06:17:03 +03:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-11-02 10:40:01 +03:00
|
|
|
}
|
2006-11-28 06:17:03 +03:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
EventStates HTMLTextAreaElement::IntrinsicState() const {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
|
2008-12-12 22:25:22 +03:00
|
|
|
|
2010-08-21 22:51:38 +04:00
|
|
|
if (IsCandidateForConstraintValidation()) {
|
2010-11-24 02:49:50 +03:00
|
|
|
if (IsValid()) {
|
2010-11-24 02:55:22 +03:00
|
|
|
state |= NS_EVENT_STATE_VALID;
|
2010-11-24 02:49:50 +03:00
|
|
|
} else {
|
|
|
|
state |= NS_EVENT_STATE_INVALID;
|
2011-01-27 16:51:45 +03:00
|
|
|
// :-moz-ui-invalid always apply if the element suffers from a custom
|
|
|
|
// error and never applies if novalidate is set on the form owner.
|
|
|
|
if ((!mForm ||
|
|
|
|
!mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) &&
|
|
|
|
(GetValidityState(VALIDITY_STATE_CUSTOM_ERROR) ||
|
2011-12-18 10:00:47 +04:00
|
|
|
(mCanShowInvalidUI && ShouldShowValidityUI()))) {
|
2010-11-24 02:49:50 +03:00
|
|
|
state |= NS_EVENT_STATE_MOZ_UI_INVALID;
|
|
|
|
}
|
|
|
|
}
|
2010-11-24 02:56:24 +03:00
|
|
|
|
|
|
|
// :-moz-ui-valid applies if all the following are true:
|
|
|
|
// 1. The element is not focused, or had either :-moz-ui-valid or
|
|
|
|
// :-moz-ui-invalid applying before it was focused ;
|
|
|
|
// 2. The element is either valid or isn't allowed to have
|
|
|
|
// :-moz-ui-invalid applying ;
|
2011-01-27 16:51:45 +03:00
|
|
|
// 3. The element has no form owner or its form owner doesn't have the
|
|
|
|
// novalidate attribute set ;
|
|
|
|
// 4. The element has already been modified or the user tried to submit the
|
|
|
|
// form owner while invalid.
|
|
|
|
if ((!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) &&
|
|
|
|
(mCanShowValidUI && ShouldShowValidityUI() &&
|
|
|
|
(IsValid() || (state.HasState(NS_EVENT_STATE_MOZ_UI_INVALID) &&
|
|
|
|
!mCanShowInvalidUI)))) {
|
2010-11-24 02:56:24 +03:00
|
|
|
state |= NS_EVENT_STATE_MOZ_UI_VALID;
|
|
|
|
}
|
2010-08-21 21:52:57 +04:00
|
|
|
}
|
|
|
|
|
2016-08-31 21:21:44 +03:00
|
|
|
if (HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) && IsValueEmpty()) {
|
|
|
|
state |= NS_EVENT_STATE_PLACEHOLDERSHOWN;
|
|
|
|
}
|
|
|
|
|
2010-08-19 04:03:20 +04:00
|
|
|
return state;
|
|
|
|
}
|
2008-12-12 22:25:22 +03:00
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult HTMLTextAreaElement::BindToTree(BindContext& aContext,
|
|
|
|
nsINode& aParent) {
|
|
|
|
nsresult rv =
|
|
|
|
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
|
2010-09-19 01:33:16 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// If there is a disabled fieldset in the parent chain, the element is now
|
|
|
|
// barred from constraint validation and can't suffer from value missing.
|
|
|
|
UpdateValueMissingValidityState();
|
|
|
|
UpdateBarredFromConstraintValidation();
|
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
// And now make sure our state is up to date
|
|
|
|
UpdateState(false);
|
|
|
|
|
2010-09-19 01:33:16 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2019-05-29 01:47:08 +03:00
|
|
|
void HTMLTextAreaElement::UnbindFromTree(bool aNullParent) {
|
|
|
|
nsGenericHTMLFormElementWithState::UnbindFromTree(aNullParent);
|
2010-09-19 01:33:16 +04:00
|
|
|
|
|
|
|
// We might be no longer disabled because of parent chain changed.
|
|
|
|
UpdateValueMissingValidityState();
|
|
|
|
UpdateBarredFromConstraintValidation();
|
2011-06-01 05:46:57 +04:00
|
|
|
|
|
|
|
// And now make sure our state is up to date
|
|
|
|
UpdateState(false);
|
2010-09-19 01:33:16 +04:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult HTMLTextAreaElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-03-16 21:50:41 +03:00
|
|
|
const nsAttrValueOrString* aValue,
|
2013-02-19 01:18:40 +04:00
|
|
|
bool aNotify) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aNotify && aName == nsGkAtoms::disabled &&
|
2006-11-28 06:17:03 +03:00
|
|
|
aNameSpaceID == kNameSpaceID_None) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mDisabledChanged = true;
|
2006-11-28 06:17:03 +03:00
|
|
|
}
|
|
|
|
|
2013-08-02 05:21:31 +04:00
|
|
|
return nsGenericHTMLFormElementWithState::BeforeSetAttr(aNameSpaceID, aName,
|
2006-11-28 06:17:03 +03:00
|
|
|
aValue, aNotify);
|
|
|
|
}
|
2007-01-30 08:48:22 +03:00
|
|
|
|
2018-03-01 14:36:58 +03:00
|
|
|
void HTMLTextAreaElement::CharacterDataChanged(nsIContent* aContent,
|
2018-02-27 17:30:27 +03:00
|
|
|
const CharacterDataChangeInfo&) {
|
2007-01-30 08:48:22 +03:00
|
|
|
ContentChanged(aContent);
|
|
|
|
}
|
|
|
|
|
2018-03-01 14:36:58 +03:00
|
|
|
void HTMLTextAreaElement::ContentAppended(nsIContent* aFirstNewContent) {
|
2010-06-28 22:04:37 +04:00
|
|
|
ContentChanged(aFirstNewContent);
|
2007-01-30 08:48:22 +03:00
|
|
|
}
|
|
|
|
|
2018-03-01 14:36:58 +03:00
|
|
|
void HTMLTextAreaElement::ContentInserted(nsIContent* aChild) {
|
2007-01-30 08:48:22 +03:00
|
|
|
ContentChanged(aChild);
|
|
|
|
}
|
|
|
|
|
2018-03-01 14:36:58 +03:00
|
|
|
void HTMLTextAreaElement::ContentRemoved(nsIContent* aChild,
|
2013-02-19 01:18:40 +04:00
|
|
|
nsIContent* aPreviousSibling) {
|
2007-01-30 08:48:22 +03:00
|
|
|
ContentChanged(aChild);
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::ContentChanged(nsIContent* aContent) {
|
2007-01-30 08:48:22 +03:00
|
|
|
if (!mValueChanged && mDoneAddingChildren &&
|
|
|
|
nsContentUtils::IsInSameAnonymousTree(this, aContent)) {
|
2010-07-21 19:33:32 +04:00
|
|
|
// Hard to say what the reset can trigger, so be safe pending
|
|
|
|
// further auditing.
|
|
|
|
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
|
2007-01-30 08:48:22 +03:00
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
}
|
2007-06-28 06:48:16 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult HTMLTextAreaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
|
|
|
bool aNotify) {
|
2010-08-21 21:52:57 +04:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None) {
|
|
|
|
if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled ||
|
|
|
|
aName == nsGkAtoms::readonly) {
|
Bug 1375599 - Change IsDisabled() to look at NS_EVENT_STATE_DISABLED instead of the "disabled" attribute. r=bz
In order to speed up IsDisabled(), instead of querying for the @disabled
attribute, we're now using the NS_EVENT_STATE_DISABLED flag to know whether an
element is disabled.
It is safe to use the NS_EVENT_STATE_DISABLED flag for the following reasons:
- For form elements, nsGenericHTMLFormElement::IsDisabled() is only called on
form elements that can be disabled; form elements that can't be disabled
overrides IsDisabled() to return false directly.
And, before this patch, NS_EVENT_STATE_DISABLED flag is set by
nsGenericHTMLFormElement::IntrinsicState() if and only if IsDisabled() in all
cases when CanBeDisabled() is true, and when CanBeDisabled() is false then
IsDisabled() is always false and the flag is not set.
- For non form elements, optgroup and option have the flag matching
IsDisabled(). Note that option's IsDisabled() should also refer to optgroup's
(if it exists) disabled state, which was not done before this patch.
For this to work correctly, we need to set NS_EVENT_STATE_DISABLED earlier,
that is, in AfterSetAttr(), before any consumer of IsDisabled().
We also need to update the flag whenever the element's parent (e.g. fieldset or
optgroup) disabled state changes and when moving into/out of a parent
container.
Note that NS_EVENT_STATE_DISABLED/ENABLED is now part of the
EXTERNALLY_MANAGED_STATES.
MozReview-Commit-ID: KSceikeqvvU
2017-07-20 09:15:00 +03:00
|
|
|
if (aName == nsGkAtoms::disabled) {
|
|
|
|
// This *has* to be called *before* validity state check because
|
|
|
|
// UpdateBarredFromConstraintValidation and
|
|
|
|
// UpdateValueMissingValidityState depend on our disabled state.
|
|
|
|
UpdateDisabledState(aNotify);
|
2017-08-03 08:27:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aName == nsGkAtoms::required) {
|
|
|
|
// This *has* to be called *before* UpdateValueMissingValidityState
|
|
|
|
// because UpdateValueMissingValidityState depends on our required
|
|
|
|
// state.
|
|
|
|
UpdateRequiredState(!!aValue, aNotify);
|
Bug 1375599 - Change IsDisabled() to look at NS_EVENT_STATE_DISABLED instead of the "disabled" attribute. r=bz
In order to speed up IsDisabled(), instead of querying for the @disabled
attribute, we're now using the NS_EVENT_STATE_DISABLED flag to know whether an
element is disabled.
It is safe to use the NS_EVENT_STATE_DISABLED flag for the following reasons:
- For form elements, nsGenericHTMLFormElement::IsDisabled() is only called on
form elements that can be disabled; form elements that can't be disabled
overrides IsDisabled() to return false directly.
And, before this patch, NS_EVENT_STATE_DISABLED flag is set by
nsGenericHTMLFormElement::IntrinsicState() if and only if IsDisabled() in all
cases when CanBeDisabled() is true, and when CanBeDisabled() is false then
IsDisabled() is always false and the flag is not set.
- For non form elements, optgroup and option have the flag matching
IsDisabled(). Note that option's IsDisabled() should also refer to optgroup's
(if it exists) disabled state, which was not done before this patch.
For this to work correctly, we need to set NS_EVENT_STATE_DISABLED earlier,
that is, in AfterSetAttr(), before any consumer of IsDisabled().
We also need to update the flag whenever the element's parent (e.g. fieldset or
optgroup) disabled state changes and when moving into/out of a parent
container.
Note that NS_EVENT_STATE_DISABLED/ENABLED is now part of the
EXTERNALLY_MANAGED_STATES.
MozReview-Commit-ID: KSceikeqvvU
2017-07-20 09:15:00 +03:00
|
|
|
}
|
|
|
|
|
2010-08-21 21:52:57 +04:00
|
|
|
UpdateValueMissingValidityState();
|
2010-09-10 09:08:56 +04:00
|
|
|
|
|
|
|
// This *has* to be called *after* validity has changed.
|
|
|
|
if (aName == nsGkAtoms::readonly || aName == nsGkAtoms::disabled) {
|
|
|
|
UpdateBarredFromConstraintValidation();
|
|
|
|
}
|
2017-11-09 08:35:04 +03:00
|
|
|
} else if (aName == nsGkAtoms::autocomplete) {
|
|
|
|
// Clear the cached @autocomplete attribute state.
|
|
|
|
mAutocompleteAttrState = nsContentUtils::eAutocompleteAttrState_Unknown;
|
2010-08-21 21:52:57 +04:00
|
|
|
} else if (aName == nsGkAtoms::maxlength) {
|
|
|
|
UpdateTooLongValidityState();
|
2016-08-17 07:11:24 +03:00
|
|
|
} else if (aName == nsGkAtoms::minlength) {
|
|
|
|
UpdateTooShortValidityState();
|
2010-08-21 21:52:57 +04:00
|
|
|
}
|
2007-06-28 06:48:16 +04:00
|
|
|
}
|
2010-08-21 21:52:57 +04:00
|
|
|
|
2013-08-02 05:21:31 +04:00
|
|
|
return nsGenericHTMLFormElementWithState::AfterSetAttr(
|
2017-10-10 00:33:38 +03:00
|
|
|
aNameSpaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
|
2013-08-02 05:21:31 +04:00
|
|
|
}
|
2009-12-11 07:02:13 +03:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult HTMLTextAreaElement::CopyInnerTo(Element* aDest) {
|
|
|
|
nsresult rv = nsGenericHTMLFormElementWithState::CopyInnerTo(aDest);
|
2009-12-11 07:02:13 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-18 14:53:36 +04:00
|
|
|
if (aDest->OwnerDoc()->IsStaticDocument()) {
|
2009-12-11 07:02:13 +03:00
|
|
|
nsAutoString value;
|
2011-11-16 11:50:19 +04:00
|
|
|
GetValueInternal(value, true);
|
2017-10-31 02:14:51 +03:00
|
|
|
ErrorResult ret;
|
|
|
|
static_cast<HTMLTextAreaElement*>(aDest)->SetValue(value, ret);
|
|
|
|
return ret.StealNSResult();
|
2009-12-11 07:02:13 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
bool HTMLTextAreaElement::IsMutable() const {
|
2010-09-19 01:33:16 +04:00
|
|
|
return (!HasAttr(kNameSpaceID_None, nsGkAtoms::readonly) && !IsDisabled());
|
2010-08-18 22:30:41 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
bool HTMLTextAreaElement::IsValueEmpty() const {
|
2011-04-13 10:33:01 +04:00
|
|
|
nsAutoString value;
|
2011-10-17 18:59:28 +04:00
|
|
|
GetValueInternal(value, true);
|
2011-04-13 10:33:01 +04:00
|
|
|
|
|
|
|
return value.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::SetCustomValidity(const nsAString& aError) {
|
2010-08-21 22:52:49 +04:00
|
|
|
nsIConstraintValidation::SetCustomValidity(aError);
|
2010-08-21 21:52:57 +04:00
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
UpdateState(true);
|
2010-08-21 21:52:57 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
bool HTMLTextAreaElement::IsTooLong() {
|
2016-08-06 18:59:08 +03:00
|
|
|
if (!mValueChanged || !mLastValueChangeWasInteractive ||
|
|
|
|
!HasAttr(kNameSpaceID_None, nsGkAtoms::maxlength)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-08-18 22:29:20 +04:00
|
|
|
}
|
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
int32_t maxLength = MaxLength();
|
2010-10-07 14:02:29 +04:00
|
|
|
|
|
|
|
// Maxlength of -1 means parsing error.
|
|
|
|
if (maxLength == -1) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-10-07 14:02:29 +04:00
|
|
|
}
|
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
int32_t textLength = GetTextLength();
|
2010-08-18 22:28:08 +04:00
|
|
|
|
2010-10-07 14:02:29 +04:00
|
|
|
return textLength > maxLength;
|
2010-08-18 22:28:08 +04:00
|
|
|
}
|
|
|
|
|
2016-08-17 07:11:24 +03:00
|
|
|
bool HTMLTextAreaElement::IsTooShort() {
|
|
|
|
if (!mValueChanged || !mLastValueChangeWasInteractive ||
|
|
|
|
!HasAttr(kNameSpaceID_None, nsGkAtoms::minlength)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
int32_t minLength = MinLength();
|
2016-08-17 07:11:24 +03:00
|
|
|
|
|
|
|
// Minlength of -1 means parsing error.
|
|
|
|
if (minLength == -1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
int32_t textLength = GetTextLength();
|
2016-08-17 07:11:24 +03:00
|
|
|
|
|
|
|
return textLength && textLength < minLength;
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
bool HTMLTextAreaElement::IsValueMissing() const {
|
2017-08-03 08:23:00 +03:00
|
|
|
if (!Required() || !IsMutable()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-08-18 22:30:41 +04:00
|
|
|
}
|
|
|
|
|
2011-04-13 10:33:01 +04:00
|
|
|
return IsValueEmpty();
|
2010-08-18 22:30:41 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::UpdateTooLongValidityState() {
|
2010-08-21 21:52:57 +04:00
|
|
|
SetValidityState(VALIDITY_STATE_TOO_LONG, IsTooLong());
|
|
|
|
}
|
|
|
|
|
2016-08-17 07:11:24 +03:00
|
|
|
void HTMLTextAreaElement::UpdateTooShortValidityState() {
|
|
|
|
SetValidityState(VALIDITY_STATE_TOO_SHORT, IsTooShort());
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::UpdateValueMissingValidityState() {
|
2010-08-21 21:52:57 +04:00
|
|
|
SetValidityState(VALIDITY_STATE_VALUE_MISSING, IsValueMissing());
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::UpdateBarredFromConstraintValidation() {
|
2010-09-10 09:08:56 +04:00
|
|
|
SetBarredFromConstraintValidation(
|
|
|
|
HasAttr(kNameSpaceID_None, nsGkAtoms::readonly) || IsDisabled());
|
2010-08-18 22:28:08 +04:00
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
nsresult HTMLTextAreaElement::GetValidationMessage(
|
|
|
|
nsAString& aValidationMessage, ValidityStateType aType) {
|
2010-08-18 22:28:08 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
switch (aType) {
|
2010-08-21 21:52:57 +04:00
|
|
|
case VALIDITY_STATE_TOO_LONG: {
|
2017-08-04 07:40:52 +03:00
|
|
|
nsAutoString message;
|
2017-10-31 02:14:51 +03:00
|
|
|
int32_t maxLength = MaxLength();
|
|
|
|
int32_t textLength = GetTextLength();
|
2010-08-18 22:28:08 +04:00
|
|
|
nsAutoString strMaxLength;
|
|
|
|
nsAutoString strTextLength;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-08-18 22:28:08 +04:00
|
|
|
strMaxLength.AppendInt(maxLength);
|
|
|
|
strTextLength.AppendInt(textLength);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-11-04 19:56:27 +03:00
|
|
|
rv = nsContentUtils::FormatMaybeLocalizedString(
|
2019-06-09 00:26:12 +03:00
|
|
|
message, nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooLong",
|
2019-11-04 19:56:27 +03:00
|
|
|
OwnerDoc(), strMaxLength, strTextLength);
|
2010-08-18 22:28:08 +04:00
|
|
|
aValidationMessage = message;
|
|
|
|
} break;
|
2016-08-17 07:11:24 +03:00
|
|
|
case VALIDITY_STATE_TOO_SHORT: {
|
2017-08-04 07:40:52 +03:00
|
|
|
nsAutoString message;
|
2017-10-31 02:14:51 +03:00
|
|
|
int32_t minLength = MinLength();
|
|
|
|
int32_t textLength = GetTextLength();
|
2016-08-17 07:11:24 +03:00
|
|
|
nsAutoString strMinLength;
|
|
|
|
nsAutoString strTextLength;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-08-17 07:11:24 +03:00
|
|
|
strMinLength.AppendInt(minLength);
|
|
|
|
strTextLength.AppendInt(textLength);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-11-04 19:56:27 +03:00
|
|
|
rv = nsContentUtils::FormatMaybeLocalizedString(
|
2019-06-09 00:26:12 +03:00
|
|
|
message, nsContentUtils::eDOM_PROPERTIES,
|
2019-11-04 19:56:27 +03:00
|
|
|
"FormValidationTextTooShort", OwnerDoc(), strMinLength,
|
|
|
|
strTextLength);
|
2016-08-17 07:11:24 +03:00
|
|
|
aValidationMessage = message;
|
|
|
|
} break;
|
2010-08-21 21:52:57 +04:00
|
|
|
case VALIDITY_STATE_VALUE_MISSING: {
|
2017-08-04 07:40:52 +03:00
|
|
|
nsAutoString message;
|
2019-11-04 19:56:27 +03:00
|
|
|
rv = nsContentUtils::GetMaybeLocalizedString(
|
|
|
|
nsContentUtils::eDOM_PROPERTIES, "FormValidationValueMissing",
|
|
|
|
OwnerDoc(), message);
|
2010-08-18 22:30:41 +04:00
|
|
|
aValidationMessage = message;
|
|
|
|
} break;
|
2010-08-18 22:28:08 +04:00
|
|
|
default:
|
2010-08-21 22:52:49 +04:00
|
|
|
rv = nsIConstraintValidation::GetValidationMessage(aValidationMessage,
|
|
|
|
aType);
|
2010-08-18 22:28:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::IsSingleLineTextControl() const { return false; }
|
2010-04-22 00:17:41 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::IsTextArea() const { return true; }
|
2010-04-22 00:17:41 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::IsPasswordTextControl() const { return false; }
|
2010-04-22 00:17:41 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
int32_t HTMLTextAreaElement::GetCols() { return Cols(); }
|
2010-04-22 00:17:41 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
int32_t HTMLTextAreaElement::GetWrapCols() {
|
2010-04-22 00:17:41 +04:00
|
|
|
nsHTMLTextWrap wrapProp;
|
2019-11-25 09:35:15 +03:00
|
|
|
TextControlElement::GetWrapPropertyEnum(this, wrapProp);
|
|
|
|
if (wrapProp == TextControlElement::eHTMLTextWrap_Off) {
|
2010-04-22 00:17:41 +04:00
|
|
|
// do not wrap when wrap=off
|
2015-02-26 23:26:12 +03:00
|
|
|
return 0;
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise we just wrap at the given number of columns
|
|
|
|
return GetCols();
|
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
int32_t HTMLTextAreaElement::GetRows() {
|
2010-04-22 00:17:41 +04:00
|
|
|
const nsAttrValue* attr = GetParsedAttr(nsGkAtoms::rows);
|
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rows = attr->GetIntegerValue();
|
2010-04-22 00:17:41 +04:00
|
|
|
return (rows <= 0) ? DEFAULT_ROWS_TEXTAREA : rows;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DEFAULT_ROWS_TEXTAREA;
|
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::GetDefaultValueFromContent(nsAString& aValue) {
|
2018-02-01 22:21:14 +03:00
|
|
|
GetDefaultValue(aValue, IgnoreErrors());
|
2013-03-25 23:35:55 +04:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::ValueChanged() const { return mValueChanged; }
|
2010-04-22 00:17:41 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::GetTextEditorValue(nsAString& aValue,
|
|
|
|
bool aIgnoreWrap) const {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->GetValue(aValue, aIgnoreWrap);
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::InitializeKeyboardEventListeners() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
mState->InitializeKeyboardEventListeners();
|
2010-04-22 00:17:41 +04:00
|
|
|
}
|
2010-08-21 21:52:57 +04:00
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
void HTMLTextAreaElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
|
2019-02-19 12:25:55 +03:00
|
|
|
if (aKind != ValueChangeKind::Internal) {
|
|
|
|
mLastValueChangeWasInteractive = aKind == ValueChangeKind::UserInteraction;
|
|
|
|
}
|
2016-08-06 18:59:08 +03:00
|
|
|
|
2010-08-21 21:52:57 +04:00
|
|
|
// Update the validity state
|
2011-09-29 10:19:26 +04:00
|
|
|
bool validBefore = IsValid();
|
2010-08-21 21:52:57 +04:00
|
|
|
UpdateTooLongValidityState();
|
2016-08-17 07:11:24 +03:00
|
|
|
UpdateTooShortValidityState();
|
2010-08-21 21:52:57 +04:00
|
|
|
UpdateValueMissingValidityState();
|
|
|
|
|
2016-08-31 21:21:44 +03:00
|
|
|
if (validBefore != IsValid() ||
|
|
|
|
HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)) {
|
2011-06-01 05:46:57 +04:00
|
|
|
UpdateState(aNotify);
|
2010-08-21 21:52:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-25 09:35:15 +03:00
|
|
|
bool HTMLTextAreaElement::HasCachedSelection() {
|
2019-11-01 23:49:12 +03:00
|
|
|
MOZ_ASSERT(mState);
|
|
|
|
return mState->IsSelectionCached();
|
|
|
|
}
|
2011-07-30 01:31:57 +04:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void HTMLTextAreaElement::FieldSetDisabledChanged(bool aNotify) {
|
Bug 1375599 - Change IsDisabled() to look at NS_EVENT_STATE_DISABLED instead of the "disabled" attribute. r=bz
In order to speed up IsDisabled(), instead of querying for the @disabled
attribute, we're now using the NS_EVENT_STATE_DISABLED flag to know whether an
element is disabled.
It is safe to use the NS_EVENT_STATE_DISABLED flag for the following reasons:
- For form elements, nsGenericHTMLFormElement::IsDisabled() is only called on
form elements that can be disabled; form elements that can't be disabled
overrides IsDisabled() to return false directly.
And, before this patch, NS_EVENT_STATE_DISABLED flag is set by
nsGenericHTMLFormElement::IntrinsicState() if and only if IsDisabled() in all
cases when CanBeDisabled() is true, and when CanBeDisabled() is false then
IsDisabled() is always false and the flag is not set.
- For non form elements, optgroup and option have the flag matching
IsDisabled(). Note that option's IsDisabled() should also refer to optgroup's
(if it exists) disabled state, which was not done before this patch.
For this to work correctly, we need to set NS_EVENT_STATE_DISABLED earlier,
that is, in AfterSetAttr(), before any consumer of IsDisabled().
We also need to update the flag whenever the element's parent (e.g. fieldset or
optgroup) disabled state changes and when moving into/out of a parent
container.
Note that NS_EVENT_STATE_DISABLED/ENABLED is now part of the
EXTERNALLY_MANAGED_STATES.
MozReview-Commit-ID: KSceikeqvvU
2017-07-20 09:15:00 +03:00
|
|
|
// This *has* to be called before UpdateBarredFromConstraintValidation and
|
|
|
|
// UpdateValueMissingValidityState because these two functions depend on our
|
|
|
|
// disabled state.
|
|
|
|
nsGenericHTMLFormElementWithState::FieldSetDisabledChanged(aNotify);
|
|
|
|
|
2010-09-19 01:33:16 +04:00
|
|
|
UpdateValueMissingValidityState();
|
|
|
|
UpdateBarredFromConstraintValidation();
|
Bug 1375599 - Change IsDisabled() to look at NS_EVENT_STATE_DISABLED instead of the "disabled" attribute. r=bz
In order to speed up IsDisabled(), instead of querying for the @disabled
attribute, we're now using the NS_EVENT_STATE_DISABLED flag to know whether an
element is disabled.
It is safe to use the NS_EVENT_STATE_DISABLED flag for the following reasons:
- For form elements, nsGenericHTMLFormElement::IsDisabled() is only called on
form elements that can be disabled; form elements that can't be disabled
overrides IsDisabled() to return false directly.
And, before this patch, NS_EVENT_STATE_DISABLED flag is set by
nsGenericHTMLFormElement::IntrinsicState() if and only if IsDisabled() in all
cases when CanBeDisabled() is true, and when CanBeDisabled() is false then
IsDisabled() is always false and the flag is not set.
- For non form elements, optgroup and option have the flag matching
IsDisabled(). Note that option's IsDisabled() should also refer to optgroup's
(if it exists) disabled state, which was not done before this patch.
For this to work correctly, we need to set NS_EVENT_STATE_DISABLED earlier,
that is, in AfterSetAttr(), before any consumer of IsDisabled().
We also need to update the flag whenever the element's parent (e.g. fieldset or
optgroup) disabled state changes and when moving into/out of a parent
container.
Note that NS_EVENT_STATE_DISABLED/ENABLED is now part of the
EXTERNALLY_MANAGED_STATES.
MozReview-Commit-ID: KSceikeqvvU
2017-07-20 09:15:00 +03:00
|
|
|
UpdateState(aNotify);
|
2010-09-19 01:33:16 +04:00
|
|
|
}
|
2013-02-19 01:18:40 +04:00
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* HTMLTextAreaElement::WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return HTMLTextAreaElement_Binding::Wrap(aCx, this, aGivenProto);
|
2013-02-19 09:54:23 +04:00
|
|
|
}
|
|
|
|
|
2017-11-09 08:35:04 +03:00
|
|
|
void HTMLTextAreaElement::GetAutocomplete(DOMString& aValue) {
|
|
|
|
const nsAttrValue* attributeVal = GetParsedAttr(nsGkAtoms::autocomplete);
|
|
|
|
|
|
|
|
mAutocompleteAttrState = nsContentUtils::SerializeAutocompleteAttribute(
|
|
|
|
attributeVal, aValue, mAutocompleteAttrState);
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|