зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1597679 - part 2: Make `nsITextControlElement` inherit `nsGenericHTMLFormElementWithState` r=smaug
Sub classes of `nsITextControlElement` are only `HTMLInputElement` and `HTMLTextAreaElement`. And both base class is `nsGenericHTMLFormElementWithState`. Therefore, we can make `nsITextControlElement` inherit `nsGenericHTMLFormElementWithState` and make `HTMLInputElement` and `HTMLTextAreaElement` inherit `nsITextControlElement`. Then, we can get rid of a lot of QI between `nsINode`/`nsIContent`/`Element` and `nsITextControlElement` (and note that some of them in a hot path). Additionally, this patch renames `nsITextControlElement` to `mozilla::TextControlElement`. Differential Revision: https://phabricator.services.mozilla.com/D54330 --HG-- rename : dom/html/nsITextControlElement.h => dom/html/TextControlElement.h extra : moz-landing-system : lando
This commit is contained in:
Родитель
efafd8cb17
Коммит
eea1784f2d
|
@ -28,7 +28,6 @@
|
||||||
#include "nsPersistentProperties.h"
|
#include "nsPersistentProperties.h"
|
||||||
#include "nsIScrollableFrame.h"
|
#include "nsIScrollableFrame.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsIMathMLFrame.h"
|
#include "nsIMathMLFrame.h"
|
||||||
#include "nsRange.h"
|
#include "nsRange.h"
|
||||||
#include "nsTextFragment.h"
|
#include "nsTextFragment.h"
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "nsIPersistentProperties2.h"
|
#include "nsIPersistentProperties2.h"
|
||||||
#include "nsISelectionController.h"
|
#include "nsISelectionController.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsITextControlFrame.h"
|
#include "nsITextControlFrame.h"
|
||||||
#include "nsNameSpaceManager.h"
|
#include "nsNameSpaceManager.h"
|
||||||
#include "mozilla/dom/ScriptSettings.h"
|
#include "mozilla/dom/ScriptSettings.h"
|
||||||
|
@ -29,6 +28,7 @@
|
||||||
#include "mozilla/EventStates.h"
|
#include "mozilla/EventStates.h"
|
||||||
#include "mozilla/FloatingPoint.h"
|
#include "mozilla/FloatingPoint.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/TextEditor.h"
|
#include "mozilla/TextEditor.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
@ -385,8 +385,8 @@ bool HTMLTextFieldAccessible::DoAction(uint8_t aIndex) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<TextEditor> HTMLTextFieldAccessible::GetEditor() const {
|
already_AddRefed<TextEditor> HTMLTextFieldAccessible::GetEditor() const {
|
||||||
nsCOMPtr<nsITextControlElement> textControlElement =
|
RefPtr<TextControlElement> textControlElement =
|
||||||
do_QueryInterface(mContent);
|
TextControlElement::FromNodeOrNull(mContent);
|
||||||
if (!textControlElement) {
|
if (!textControlElement) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,8 @@ class HTMLTextFieldAccessible final : public HyperTextAccessibleWrap {
|
||||||
HyperTextAccessibleWrap)
|
HyperTextAccessibleWrap)
|
||||||
|
|
||||||
// HyperTextAccessible
|
// HyperTextAccessible
|
||||||
virtual already_AddRefed<TextEditor> GetEditor() const override;
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual already_AddRefed<TextEditor> GetEditor()
|
||||||
|
const override;
|
||||||
|
|
||||||
// Accessible
|
// Accessible
|
||||||
virtual void Value(nsString& aValue) const override;
|
virtual void Value(nsString& aValue) const override;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "mozilla/StaticPrefs_privacy.h"
|
#include "mozilla/StaticPrefs_privacy.h"
|
||||||
#include "mozilla/StaticPrefs_security.h"
|
#include "mozilla/StaticPrefs_security.h"
|
||||||
#include "mozilla/StorageAccess.h"
|
#include "mozilla/StorageAccess.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/TextEditor.h"
|
#include "mozilla/TextEditor.h"
|
||||||
#include "mozilla/URLDecorationStripper.h"
|
#include "mozilla/URLDecorationStripper.h"
|
||||||
#include "mozilla/URLExtraData.h"
|
#include "mozilla/URLExtraData.h"
|
||||||
|
@ -283,7 +284,6 @@
|
||||||
#include "nsDOMCaretPosition.h"
|
#include "nsDOMCaretPosition.h"
|
||||||
#include "nsViewportInfo.h"
|
#include "nsViewportInfo.h"
|
||||||
#include "mozilla/StaticPtr.h"
|
#include "mozilla/StaticPtr.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsIHttpChannelInternal.h"
|
#include "nsIHttpChannelInternal.h"
|
||||||
#include "nsISecurityConsoleMessage.h"
|
#include "nsISecurityConsoleMessage.h"
|
||||||
#include "nsCharSeparatedTokenizer.h"
|
#include "nsCharSeparatedTokenizer.h"
|
||||||
|
@ -5009,14 +5009,12 @@ nsresult Document::TurnEditingOff() {
|
||||||
|
|
||||||
// Editor resets selection since it is being destroyed. But if focus is
|
// Editor resets selection since it is being destroyed. But if focus is
|
||||||
// still into editable control, we have to initialize selection again.
|
// still into editable control, we have to initialize selection again.
|
||||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
if (nsFocusManager* fm = nsFocusManager::GetFocusManager()) {
|
||||||
if (fm) {
|
if (RefPtr<TextControlElement> textControlElement =
|
||||||
Element* element = fm->GetFocusedElement();
|
TextControlElement::FromNodeOrNull(fm->GetFocusedElement())) {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(element);
|
RefPtr<TextEditor> textEditor = textControlElement->GetTextEditor();
|
||||||
if (txtCtrl) {
|
|
||||||
RefPtr<TextEditor> textEditor = txtCtrl->GetTextEditor();
|
|
||||||
if (textEditor) {
|
if (textEditor) {
|
||||||
textEditor->ReinitializeSelection(*element);
|
textEditor->ReinitializeSelection(*textControlElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1892,7 +1892,7 @@ class Document : public nsINode,
|
||||||
/* Midas implementation */
|
/* Midas implementation */
|
||||||
nsCommandManager* GetMidasCommandManager();
|
nsCommandManager* GetMidasCommandManager();
|
||||||
|
|
||||||
nsresult TurnEditingOff();
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult TurnEditingOff();
|
||||||
|
|
||||||
// MOZ_CAN_RUN_SCRIPT_BOUNDARY because this is called from all sorts
|
// MOZ_CAN_RUN_SCRIPT_BOUNDARY because this is called from all sorts
|
||||||
// of places, and I'm pretty sure the exact ExecCommand call it
|
// of places, and I'm pretty sure the exact ExecCommand call it
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
#include "mozilla/RestyleManager.h"
|
#include "mozilla/RestyleManager.h"
|
||||||
#include "mozilla/ScrollTypes.h"
|
#include "mozilla/ScrollTypes.h"
|
||||||
#include "mozilla/SizeOfState.h"
|
#include "mozilla/SizeOfState.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/TextEditor.h"
|
#include "mozilla/TextEditor.h"
|
||||||
#include "mozilla/TextEvents.h"
|
#include "mozilla/TextEvents.h"
|
||||||
#include "mozilla/dom/DirectionalityUtils.h"
|
#include "mozilla/dom/DirectionalityUtils.h"
|
||||||
|
@ -133,7 +134,6 @@
|
||||||
#include "mozilla/dom/NodeListBinding.h"
|
#include "mozilla/dom/NodeListBinding.h"
|
||||||
|
|
||||||
#include "nsStyledElement.h"
|
#include "nsStyledElement.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsITextControlFrame.h"
|
#include "nsITextControlFrame.h"
|
||||||
#include "nsISupportsImpl.h"
|
#include "nsISupportsImpl.h"
|
||||||
#include "mozilla/dom/CSSPseudoElement.h"
|
#include "mozilla/dom/CSSPseudoElement.h"
|
||||||
|
@ -3568,8 +3568,9 @@ void Element::InsertAdjacentText(const nsAString& aWhere,
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditor* Element::GetTextEditorInternal() {
|
TextEditor* Element::GetTextEditorInternal() {
|
||||||
nsCOMPtr<nsITextControlElement> textCtrl = do_QueryInterface(this);
|
TextControlElement* textControlElement = TextControlElement::FromNode(this);
|
||||||
return textCtrl ? textCtrl->GetTextEditor() : nullptr;
|
return textControlElement ? MOZ_KnownLive(textControlElement)->GetTextEditor()
|
||||||
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Element::SetBoolAttr(nsAtom* aAttr, bool aValue) {
|
nsresult Element::SetBoolAttr(nsAtom* aAttr, bool aValue) {
|
||||||
|
|
|
@ -1501,7 +1501,7 @@ class Element : public FragmentOrElement {
|
||||||
/**
|
/**
|
||||||
* Locate a TextEditor rooted at this content node, if there is one.
|
* Locate a TextEditor rooted at this content node, if there is one.
|
||||||
*/
|
*/
|
||||||
mozilla::TextEditor* GetTextEditorInternal();
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::TextEditor* GetTextEditorInternal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets value of boolean attribute. Only works for attributes in null
|
* Gets value of boolean attribute. Only works for attributes in null
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsIContentInlines.h"
|
#include "nsIContentInlines.h"
|
||||||
#include "nsIImageLoadingContent.h"
|
#include "nsIImageLoadingContent.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsIURIMutator.h"
|
#include "nsIURIMutator.h"
|
||||||
|
@ -49,6 +48,7 @@
|
||||||
#include "nsIMIMEInfo.h"
|
#include "nsIMIMEInfo.h"
|
||||||
#include "nsRange.h"
|
#include "nsRange.h"
|
||||||
#include "BrowserParent.h"
|
#include "BrowserParent.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/HTMLAreaElement.h"
|
#include "mozilla/dom/HTMLAreaElement.h"
|
||||||
#include "mozilla/dom/HTMLAnchorElement.h"
|
#include "mozilla/dom/HTMLAnchorElement.h"
|
||||||
|
@ -513,11 +513,11 @@ nsresult DragDataProducer::Produce(DataTransfer* aDataTransfer, bool* aCanDrag,
|
||||||
nsIContent* editingElement = mSelectionTargetNode->IsEditable()
|
nsIContent* editingElement = mSelectionTargetNode->IsEditable()
|
||||||
? mSelectionTargetNode->GetEditingHost()
|
? mSelectionTargetNode->GetEditingHost()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
nsCOMPtr<nsITextControlElement> textControl =
|
RefPtr<TextControlElement> textControlElement =
|
||||||
nsITextControlElement::GetTextControlElementFromEditingHost(
|
TextControlElement::GetTextControlElementFromEditingHost(editingElement);
|
||||||
editingElement);
|
if (textControlElement) {
|
||||||
if (textControl) {
|
nsISelectionController* selcon =
|
||||||
nsISelectionController* selcon = textControl->GetSelectionController();
|
textControlElement->GetSelectionController();
|
||||||
if (selcon) {
|
if (selcon) {
|
||||||
selection =
|
selection =
|
||||||
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
||||||
|
@ -556,7 +556,7 @@ nsresult DragDataProducer::Produce(DataTransfer* aDataTransfer, bool* aCanDrag,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isChromeShell && textControl) {
|
if (isChromeShell && textControlElement) {
|
||||||
// Only use the selection if the target node is in the selection.
|
// Only use the selection if the target node is in the selection.
|
||||||
if (!selection->ContainsNode(*mSelectionTargetNode, false, IgnoreErrors()))
|
if (!selection->ContainsNode(*mSelectionTargetNode, false, IgnoreErrors()))
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -4087,9 +4087,7 @@ nsresult nsContentUtils::DispatchInputEvent(Element* aEventTargetElement,
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
else {
|
else {
|
||||||
nsCOMPtr<nsITextControlElement> textControlElement =
|
MOZ_ASSERT(!aEventTargetElement->IsTextControlElement(),
|
||||||
do_QueryInterface(aEventTargetElement);
|
|
||||||
MOZ_ASSERT(!textControlElement,
|
|
||||||
"The event target may have editor, but we've not known it yet.");
|
"The event target may have editor, but we've not known it yet.");
|
||||||
}
|
}
|
||||||
#endif // #ifdef DEBUG
|
#endif // #ifdef DEBUG
|
||||||
|
|
|
@ -876,7 +876,7 @@ bool nsCopySupport::FireClipboardEvent(EventMessage aEventMessage,
|
||||||
// there is unmasked range but it's collapsed or it'll be masked
|
// there is unmasked range but it's collapsed or it'll be masked
|
||||||
// automatically, the selected password shouldn't be copied into the
|
// automatically, the selected password shouldn't be copied into the
|
||||||
// clipboard.
|
// clipboard.
|
||||||
if (HTMLInputElement* inputElement =
|
if (RefPtr<HTMLInputElement> inputElement =
|
||||||
HTMLInputElement::FromNodeOrNull(sourceContent)) {
|
HTMLInputElement::FromNodeOrNull(sourceContent)) {
|
||||||
if (TextEditor* textEditor = inputElement->GetTextEditor()) {
|
if (TextEditor* textEditor = inputElement->GetTextEditor()) {
|
||||||
if (textEditor->IsPasswordEditor() &&
|
if (textEditor->IsPasswordEditor() &&
|
||||||
|
|
|
@ -21,7 +21,6 @@ class nsAttrValue;
|
||||||
class nsAttrName;
|
class nsAttrName;
|
||||||
class nsTextFragment;
|
class nsTextFragment;
|
||||||
class nsIFrame;
|
class nsIFrame;
|
||||||
class nsITextControlElement;
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
class EventChainPreVisitor;
|
class EventChainPreVisitor;
|
||||||
|
|
|
@ -488,6 +488,8 @@ class nsINode : public mozilla::dom::EventTarget {
|
||||||
*/
|
*/
|
||||||
bool IsElement() const { return GetBoolFlag(NodeIsElement); }
|
bool IsElement() const { return GetBoolFlag(NodeIsElement); }
|
||||||
|
|
||||||
|
virtual bool IsTextControlElement() const { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return this node as an Element. Should only be used for nodes
|
* Return this node as an Element. Should only be used for nodes
|
||||||
* for which IsElement() is true. This is defined inline in Element.h.
|
* for which IsElement() is true. This is defined inline in Element.h.
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
#include "mozilla/dom/Document.h"
|
#include "mozilla/dom/Document.h"
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
#include "nsFrameLoaderOwner.h"
|
#include "nsFrameLoaderOwner.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "mozilla/PresShell.h"
|
#include "mozilla/PresShell.h"
|
||||||
#include "mozilla/StaticPrefs_mousewheel.h"
|
#include "mozilla/StaticPrefs_mousewheel.h"
|
||||||
#include "mozilla/StaticPrefs_test.h"
|
#include "mozilla/StaticPrefs_test.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/dom/WheelEventBinding.h"
|
#include "mozilla/dom/WheelEventBinding.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
@ -23,7 +24,6 @@
|
||||||
#include "mozilla/dom/Document.h"
|
#include "mozilla/dom/Document.h"
|
||||||
#include "DocumentInlines.h" // for Document and HTMLBodyElement
|
#include "DocumentInlines.h" // for Document and HTMLBodyElement
|
||||||
#include "nsIScrollableFrame.h"
|
#include "nsIScrollableFrame.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsITimer.h"
|
#include "nsITimer.h"
|
||||||
#include "nsPluginFrame.h"
|
#include "nsPluginFrame.h"
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
|
@ -87,11 +87,11 @@ WheelHandlingUtils::GetDisregardedWheelScrollDirection(const nsIFrame* aFrame) {
|
||||||
if (!content) {
|
if (!content) {
|
||||||
return Nothing();
|
return Nothing();
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsITextControlElement> ctrl = do_QueryInterface(
|
TextControlElement* textControlElement = TextControlElement::FromNodeOrNull(
|
||||||
content->IsInNativeAnonymousSubtree()
|
content->IsInNativeAnonymousSubtree()
|
||||||
? content->GetClosestNativeAnonymousSubtreeRootParent()
|
? content->GetClosestNativeAnonymousSubtreeRootParent()
|
||||||
: content);
|
: content);
|
||||||
if (!ctrl || !ctrl->IsSingleLineTextControl()) {
|
if (!textControlElement || !textControlElement->IsSingleLineTextControl()) {
|
||||||
return Nothing();
|
return Nothing();
|
||||||
}
|
}
|
||||||
// Disregard scroll in the block-flow direction by mouse wheel on a
|
// Disregard scroll in the block-flow direction by mouse wheel on a
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "nsCRTGlue.h"
|
#include "nsCRTGlue.h"
|
||||||
#include "nsQueryObject.h"
|
#include "nsQueryObject.h"
|
||||||
|
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsIRadioVisitor.h"
|
#include "nsIRadioVisitor.h"
|
||||||
#include "InputType.h"
|
#include "InputType.h"
|
||||||
|
|
||||||
|
@ -945,8 +944,8 @@ static nsresult FireEventForAccessibility(HTMLInputElement* aTarget,
|
||||||
HTMLInputElement::HTMLInputElement(
|
HTMLInputElement::HTMLInputElement(
|
||||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||||
FromParser aFromParser, FromClone aFromClone)
|
FromParser aFromParser, FromClone aFromClone)
|
||||||
: nsGenericHTMLFormElementWithState(std::move(aNodeInfo), aFromParser,
|
: TextControlElement(std::move(aNodeInfo), aFromParser,
|
||||||
kInputDefaultType->value),
|
kInputDefaultType->value),
|
||||||
mAutocompleteAttrState(nsContentUtils::eAutocompleteAttrState_Unknown),
|
mAutocompleteAttrState(nsContentUtils::eAutocompleteAttrState_Unknown),
|
||||||
mAutocompleteInfoState(nsContentUtils::eAutocompleteAttrState_Unknown),
|
mAutocompleteInfoState(nsContentUtils::eAutocompleteAttrState_Unknown),
|
||||||
mDisabledChanged(false),
|
mDisabledChanged(false),
|
||||||
|
@ -1037,8 +1036,8 @@ TextControlState* HTMLInputElement::GetEditorState() const {
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLInputElement)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLInputElement)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLInputElement,
|
||||||
HTMLInputElement, nsGenericHTMLFormElementWithState)
|
TextControlElement)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
|
||||||
if (tmp->IsSingleLineTextControl(false)) {
|
if (tmp->IsSingleLineTextControl(false)) {
|
||||||
|
@ -1050,8 +1049,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
|
||||||
}
|
}
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLInputElement,
|
||||||
HTMLInputElement, nsGenericHTMLFormElementWithState)
|
TextControlElement)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
|
||||||
if (tmp->IsSingleLineTextControl(false)) {
|
if (tmp->IsSingleLineTextControl(false)) {
|
||||||
|
@ -1064,9 +1063,11 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
|
||||||
// XXX should unlink more?
|
// XXX should unlink more?
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLInputElement,
|
||||||
HTMLInputElement, nsGenericHTMLFormElementWithState, nsITextControlElement,
|
TextControlElement,
|
||||||
imgINotificationObserver, nsIImageLoadingContent, nsIConstraintValidation)
|
imgINotificationObserver,
|
||||||
|
nsIImageLoadingContent,
|
||||||
|
nsIConstraintValidation)
|
||||||
|
|
||||||
// nsINode
|
// nsINode
|
||||||
|
|
||||||
|
@ -2234,11 +2235,11 @@ TextEditor* HTMLInputElement::GetTextEditorFromState() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(TextEditor*)
|
TextEditor* HTMLInputElement::GetTextEditor() {
|
||||||
HTMLInputElement::GetTextEditor() { return GetTextEditorFromState(); }
|
return GetTextEditorFromState();
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(TextEditor*)
|
TextEditor* HTMLInputElement::GetTextEditorWithoutCreation() {
|
||||||
HTMLInputElement::GetTextEditorWithoutCreation() {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2246,8 +2247,7 @@ HTMLInputElement::GetTextEditorWithoutCreation() {
|
||||||
return state->GetTextEditorWithoutCreation();
|
return state->GetTextEditorWithoutCreation();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(nsISelectionController*)
|
nsISelectionController* HTMLInputElement::GetSelectionController() {
|
||||||
HTMLInputElement::GetSelectionController() {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
return state->GetSelectionController();
|
return state->GetSelectionController();
|
||||||
|
@ -2263,8 +2263,7 @@ nsFrameSelection* HTMLInputElement::GetConstFrameSelection() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsresult HTMLInputElement::BindToFrame(nsTextControlFrame* aFrame) {
|
||||||
HTMLInputElement::BindToFrame(nsTextControlFrame* aFrame) {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
return state->BindToFrame(aFrame);
|
return state->BindToFrame(aFrame);
|
||||||
|
@ -2272,16 +2271,14 @@ HTMLInputElement::BindToFrame(nsTextControlFrame* aFrame) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
||||||
HTMLInputElement::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state && aFrame) {
|
if (state && aFrame) {
|
||||||
state->UnbindFromFrame(aFrame);
|
state->UnbindFromFrame(aFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsresult HTMLInputElement::CreateEditor() {
|
||||||
HTMLInputElement::CreateEditor() {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
return state->PrepareEditor();
|
return state->PrepareEditor();
|
||||||
|
@ -2289,16 +2286,14 @@ HTMLInputElement::CreateEditor() {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::UpdateOverlayTextVisibility(bool aNotify) {
|
||||||
HTMLInputElement::UpdateOverlayTextVisibility(bool aNotify) {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
state->UpdateOverlayTextVisibility(aNotify);
|
state->UpdateOverlayTextVisibility(aNotify);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::GetPlaceholderVisibility() {
|
||||||
HTMLInputElement::GetPlaceholderVisibility() {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2307,24 +2302,21 @@ HTMLInputElement::GetPlaceholderVisibility() {
|
||||||
return state->GetPlaceholderVisibility();
|
return state->GetPlaceholderVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::SetPreviewValue(const nsAString& aValue) {
|
||||||
HTMLInputElement::SetPreviewValue(const nsAString& aValue) {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
state->SetPreviewText(aValue, true);
|
state->SetPreviewText(aValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::GetPreviewValue(nsAString& aValue) {
|
||||||
HTMLInputElement::GetPreviewValue(nsAString& aValue) {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
state->GetPreviewText(aValue);
|
state->GetPreviewText(aValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::EnablePreview() {
|
||||||
HTMLInputElement::EnablePreview() {
|
|
||||||
if (mIsPreviewEnabled) {
|
if (mIsPreviewEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2335,11 +2327,9 @@ HTMLInputElement::EnablePreview() {
|
||||||
nsChangeHint_ReconstructFrame);
|
nsChangeHint_ReconstructFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::IsPreviewEnabled() { return mIsPreviewEnabled; }
|
||||||
HTMLInputElement::IsPreviewEnabled() { return mIsPreviewEnabled; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::GetPreviewVisibility() {
|
||||||
HTMLInputElement::GetPreviewVisibility() {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2733,8 +2723,7 @@ nsresult HTMLInputElement::SetValueInternal(const nsAString& aValue,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsresult HTMLInputElement::SetValueChanged(bool aValueChanged) {
|
||||||
HTMLInputElement::SetValueChanged(bool aValueChanged) {
|
|
||||||
bool valueChangedBefore = mValueChanged;
|
bool valueChangedBefore = mValueChanged;
|
||||||
|
|
||||||
mValueChanged = aValueChanged;
|
mValueChanged = aValueChanged;
|
||||||
|
@ -6716,21 +6705,17 @@ nsresult HTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||||
return mInputType->GetValidationMessage(aValidationMessage, aType);
|
return mInputType->GetValidationMessage(aValidationMessage, aType);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::IsSingleLineTextControl() const {
|
||||||
HTMLInputElement::IsSingleLineTextControl() const {
|
|
||||||
return IsSingleLineTextControl(false);
|
return IsSingleLineTextControl(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::IsTextArea() const { return false; }
|
||||||
HTMLInputElement::IsTextArea() const { return false; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::IsPasswordTextControl() const {
|
||||||
HTMLInputElement::IsPasswordTextControl() const {
|
|
||||||
return mType == NS_FORM_INPUT_PASSWORD;
|
return mType == NS_FORM_INPUT_PASSWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(int32_t)
|
int32_t HTMLInputElement::GetCols() {
|
||||||
HTMLInputElement::GetCols() {
|
|
||||||
// Else we know (assume) it is an input with size attr
|
// Else we know (assume) it is an input with size attr
|
||||||
const nsAttrValue* attr = GetParsedAttr(nsGkAtoms::size);
|
const nsAttrValue* attr = GetParsedAttr(nsGkAtoms::size);
|
||||||
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
||||||
|
@ -6743,16 +6728,13 @@ HTMLInputElement::GetCols() {
|
||||||
return DEFAULT_COLS;
|
return DEFAULT_COLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(int32_t)
|
int32_t HTMLInputElement::GetWrapCols() {
|
||||||
HTMLInputElement::GetWrapCols() {
|
|
||||||
return 0; // only textarea's can have wrap cols
|
return 0; // only textarea's can have wrap cols
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(int32_t)
|
int32_t HTMLInputElement::GetRows() { return DEFAULT_ROWS; }
|
||||||
HTMLInputElement::GetRows() { return DEFAULT_ROWS; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::GetDefaultValueFromContent(nsAString& aValue) {
|
||||||
HTMLInputElement::GetDefaultValueFromContent(nsAString& aValue) {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
GetDefaultValue(aValue);
|
GetDefaultValue(aValue);
|
||||||
|
@ -6764,28 +6746,24 @@ HTMLInputElement::GetDefaultValueFromContent(nsAString& aValue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::ValueChanged() const { return mValueChanged; }
|
||||||
HTMLInputElement::ValueChanged() const { return mValueChanged; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::GetTextEditorValue(nsAString& aValue,
|
||||||
HTMLInputElement::GetTextEditorValue(nsAString& aValue,
|
bool aIgnoreWrap) const {
|
||||||
bool aIgnoreWrap) const {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
state->GetValue(aValue, aIgnoreWrap);
|
state->GetValue(aValue, aIgnoreWrap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::InitializeKeyboardEventListeners() {
|
||||||
HTMLInputElement::InitializeKeyboardEventListeners() {
|
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
state->InitializeKeyboardEventListeners();
|
state->InitializeKeyboardEventListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLInputElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
|
||||||
HTMLInputElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
|
|
||||||
if (aKind != ValueChangeKind::Internal) {
|
if (aKind != ValueChangeKind::Internal) {
|
||||||
mLastValueChangeWasInteractive = aKind == ValueChangeKind::UserInteraction;
|
mLastValueChangeWasInteractive = aKind == ValueChangeKind::UserInteraction;
|
||||||
}
|
}
|
||||||
|
@ -6804,8 +6782,7 @@ HTMLInputElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLInputElement::HasCachedSelection() {
|
||||||
HTMLInputElement::HasCachedSelection() {
|
|
||||||
bool isCached = false;
|
bool isCached = false;
|
||||||
TextControlState* state = GetEditorState();
|
TextControlState* state = GetEditorState();
|
||||||
if (state) {
|
if (state) {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/Decimal.h"
|
#include "mozilla/Decimal.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/TextControlState.h"
|
#include "mozilla/TextControlState.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "mozilla/Variant.h"
|
#include "mozilla/Variant.h"
|
||||||
|
@ -19,7 +20,6 @@
|
||||||
#include "mozilla/dom/UnionTypes.h"
|
#include "mozilla/dom/UnionTypes.h"
|
||||||
#include "nsGenericHTMLElement.h"
|
#include "nsGenericHTMLElement.h"
|
||||||
#include "nsImageLoadingContent.h"
|
#include "nsImageLoadingContent.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsITimer.h"
|
#include "nsITimer.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIConstraintValidation.h"
|
#include "nsIConstraintValidation.h"
|
||||||
|
@ -117,9 +117,8 @@ class UploadLastDir final : public nsIObserver, public nsSupportsWeakReference {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
|
class HTMLInputElement final : public TextControlElement,
|
||||||
public nsImageLoadingContent,
|
public nsImageLoadingContent,
|
||||||
public nsITextControlElement,
|
|
||||||
public nsIConstraintValidation {
|
public nsIConstraintValidation {
|
||||||
friend class AfterSetFilesOrDirectoriesCallback;
|
friend class AfterSetFilesOrDirectoriesCallback;
|
||||||
friend class DispatchChangeEventCallback;
|
friend class DispatchChangeEventCallback;
|
||||||
|
@ -214,43 +213,42 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
|
||||||
virtual void RemoveStates(EventStates aStates) override;
|
virtual void RemoveStates(EventStates aStates) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// nsITextControlElement
|
// TextControlElement
|
||||||
NS_IMETHOD SetValueChanged(bool aValueChanged) override;
|
virtual nsresult SetValueChanged(bool aValueChanged) override;
|
||||||
NS_IMETHOD_(bool) IsSingleLineTextControl() const override;
|
virtual bool IsSingleLineTextControl() const override;
|
||||||
NS_IMETHOD_(bool) IsTextArea() const override;
|
virtual bool IsTextArea() const override;
|
||||||
NS_IMETHOD_(bool) IsPasswordTextControl() const override;
|
virtual bool IsPasswordTextControl() const override;
|
||||||
NS_IMETHOD_(int32_t) GetCols() override;
|
virtual int32_t GetCols() override;
|
||||||
NS_IMETHOD_(int32_t) GetWrapCols() override;
|
virtual int32_t GetWrapCols() override;
|
||||||
NS_IMETHOD_(int32_t) GetRows() override;
|
virtual int32_t GetRows() override;
|
||||||
NS_IMETHOD_(void) GetDefaultValueFromContent(nsAString& aValue) override;
|
virtual void GetDefaultValueFromContent(nsAString& aValue) override;
|
||||||
NS_IMETHOD_(bool) ValueChanged() const override;
|
virtual bool ValueChanged() const override;
|
||||||
NS_IMETHOD_(void)
|
virtual void GetTextEditorValue(nsAString& aValue,
|
||||||
GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const override;
|
bool aIgnoreWrap) const override;
|
||||||
NS_IMETHOD_(TextEditor*) GetTextEditor() override;
|
MOZ_CAN_RUN_SCRIPT TextEditor* GetTextEditor() override;
|
||||||
NS_IMETHOD_(TextEditor*) GetTextEditorWithoutCreation() override;
|
virtual TextEditor* GetTextEditorWithoutCreation() override;
|
||||||
NS_IMETHOD_(nsISelectionController*) GetSelectionController() override;
|
virtual nsISelectionController* GetSelectionController() override;
|
||||||
NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection() override;
|
virtual nsFrameSelection* GetConstFrameSelection() override;
|
||||||
NS_IMETHOD_(TextControlState*) GetTextControlState() const override {
|
virtual TextControlState* GetTextControlState() const override {
|
||||||
return GetEditorState();
|
return GetEditorState();
|
||||||
}
|
}
|
||||||
NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame) override;
|
virtual nsresult BindToFrame(nsTextControlFrame* aFrame) override;
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void UnbindFromFrame(
|
||||||
NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame) override;
|
nsTextControlFrame* aFrame) override;
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT virtual nsresult CreateEditor() override;
|
||||||
NS_IMETHOD CreateEditor() override;
|
virtual void UpdateOverlayTextVisibility(bool aNotify) override;
|
||||||
NS_IMETHOD_(void) UpdateOverlayTextVisibility(bool aNotify) override;
|
virtual void SetPreviewValue(const nsAString& aValue) override;
|
||||||
NS_IMETHOD_(void) SetPreviewValue(const nsAString& aValue) override;
|
virtual void GetPreviewValue(nsAString& aValue) override;
|
||||||
NS_IMETHOD_(void) GetPreviewValue(nsAString& aValue) override;
|
virtual void EnablePreview() override;
|
||||||
NS_IMETHOD_(void) EnablePreview() override;
|
virtual bool IsPreviewEnabled() override;
|
||||||
NS_IMETHOD_(bool) IsPreviewEnabled() override;
|
virtual bool GetPlaceholderVisibility() override;
|
||||||
NS_IMETHOD_(bool) GetPlaceholderVisibility() override;
|
virtual bool GetPreviewVisibility() override;
|
||||||
NS_IMETHOD_(bool) GetPreviewVisibility() override;
|
virtual void InitializeKeyboardEventListeners() override;
|
||||||
NS_IMETHOD_(void) InitializeKeyboardEventListeners() override;
|
virtual void OnValueChanged(bool aNotify, ValueChangeKind) override;
|
||||||
NS_IMETHOD_(void) OnValueChanged(bool aNotify, ValueChangeKind) override;
|
|
||||||
virtual void GetValueFromSetRangeText(nsAString& aValue) override;
|
virtual void GetValueFromSetRangeText(nsAString& aValue) override;
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual nsresult SetValueFromSetRangeText(
|
||||||
virtual nsresult SetValueFromSetRangeText(const nsAString& aValue) override;
|
const nsAString& aValue) override;
|
||||||
NS_IMETHOD_(bool) HasCachedSelection() override;
|
virtual bool HasCachedSelection() override;
|
||||||
|
|
||||||
// Methods for nsFormFillController so it can do selection operations on input
|
// Methods for nsFormFillController so it can do selection operations on input
|
||||||
// types the HTML spec doesn't support them on, like "email".
|
// types the HTML spec doesn't support them on, like "email".
|
||||||
|
@ -291,8 +289,7 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||||
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
||||||
|
|
||||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLInputElement,
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLInputElement, TextControlElement)
|
||||||
nsGenericHTMLFormElementWithState)
|
|
||||||
|
|
||||||
static UploadLastDir* gUploadLastDir;
|
static UploadLastDir* gUploadLastDir;
|
||||||
// create and destroy the static UploadLastDir object for remembering
|
// create and destroy the static UploadLastDir object for remembering
|
||||||
|
@ -871,7 +868,7 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
|
||||||
JS::Handle<JSObject*> aGivenProto) override;
|
JS::Handle<JSObject*> aGivenProto) override;
|
||||||
|
|
||||||
// Pull IsSingleLineTextControl into our scope, otherwise it'd be hidden
|
// Pull IsSingleLineTextControl into our scope, otherwise it'd be hidden
|
||||||
// by the nsITextControlElement version.
|
// by the TextControlElement version.
|
||||||
using nsGenericHTMLFormElementWithState::IsSingleLineTextControl;
|
using nsGenericHTMLFormElementWithState::IsSingleLineTextControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,8 +51,7 @@ namespace dom {
|
||||||
HTMLTextAreaElement::HTMLTextAreaElement(
|
HTMLTextAreaElement::HTMLTextAreaElement(
|
||||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
||||||
FromParser aFromParser)
|
FromParser aFromParser)
|
||||||
: nsGenericHTMLFormElementWithState(std::move(aNodeInfo), aFromParser,
|
: TextControlElement(std::move(aNodeInfo), aFromParser, NS_FORM_TEXTAREA),
|
||||||
NS_FORM_TEXTAREA),
|
|
||||||
mValueChanged(false),
|
mValueChanged(false),
|
||||||
mLastValueChangeWasInteractive(false),
|
mLastValueChangeWasInteractive(false),
|
||||||
mHandlingSelect(false),
|
mHandlingSelect(false),
|
||||||
|
@ -82,8 +81,8 @@ HTMLTextAreaElement::~HTMLTextAreaElement() {
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTextAreaElement)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTextAreaElement)
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTextAreaElement,
|
||||||
HTMLTextAreaElement, nsGenericHTMLFormElementWithState)
|
TextControlElement)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mValidity)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
|
||||||
if (tmp->mState) {
|
if (tmp->mState) {
|
||||||
|
@ -91,8 +90,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
|
||||||
}
|
}
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLTextAreaElement,
|
||||||
HTMLTextAreaElement, nsGenericHTMLFormElementWithState)
|
TextControlElement)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mValidity)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
|
||||||
if (tmp->mState) {
|
if (tmp->mState) {
|
||||||
|
@ -101,8 +100,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLTextAreaElement,
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLTextAreaElement,
|
||||||
nsGenericHTMLFormElementWithState,
|
TextControlElement,
|
||||||
nsITextControlElement,
|
|
||||||
nsIMutationObserver,
|
nsIMutationObserver,
|
||||||
nsIConstraintValidation)
|
nsIConstraintValidation)
|
||||||
|
|
||||||
|
@ -218,76 +216,64 @@ void HTMLTextAreaElement::GetValueInternal(nsAString& aValue,
|
||||||
mState->GetValue(aValue, aIgnoreWrap);
|
mState->GetValue(aValue, aIgnoreWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(TextEditor*)
|
TextEditor* HTMLTextAreaElement::GetTextEditor() {
|
||||||
HTMLTextAreaElement::GetTextEditor() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->GetTextEditor();
|
return mState->GetTextEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(TextEditor*)
|
TextEditor* HTMLTextAreaElement::GetTextEditorWithoutCreation() {
|
||||||
HTMLTextAreaElement::GetTextEditorWithoutCreation() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->GetTextEditorWithoutCreation();
|
return mState->GetTextEditorWithoutCreation();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(nsISelectionController*)
|
nsISelectionController* HTMLTextAreaElement::GetSelectionController() {
|
||||||
HTMLTextAreaElement::GetSelectionController() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->GetSelectionController();
|
return mState->GetSelectionController();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(nsFrameSelection*)
|
nsFrameSelection* HTMLTextAreaElement::GetConstFrameSelection() {
|
||||||
HTMLTextAreaElement::GetConstFrameSelection() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->GetConstFrameSelection();
|
return mState->GetConstFrameSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsresult HTMLTextAreaElement::BindToFrame(nsTextControlFrame* aFrame) {
|
||||||
HTMLTextAreaElement::BindToFrame(nsTextControlFrame* aFrame) {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->BindToFrame(aFrame);
|
return mState->BindToFrame(aFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
||||||
HTMLTextAreaElement::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
if (aFrame) {
|
if (aFrame) {
|
||||||
mState->UnbindFromFrame(aFrame);
|
mState->UnbindFromFrame(aFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsresult HTMLTextAreaElement::CreateEditor() {
|
||||||
HTMLTextAreaElement::CreateEditor() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->PrepareEditor();
|
return mState->PrepareEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::UpdateOverlayTextVisibility(bool aNotify) {
|
||||||
HTMLTextAreaElement::UpdateOverlayTextVisibility(bool aNotify) {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
mState->UpdateOverlayTextVisibility(aNotify);
|
mState->UpdateOverlayTextVisibility(aNotify);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::GetPlaceholderVisibility() {
|
||||||
HTMLTextAreaElement::GetPlaceholderVisibility() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->GetPlaceholderVisibility();
|
return mState->GetPlaceholderVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::SetPreviewValue(const nsAString& aValue) {
|
||||||
HTMLTextAreaElement::SetPreviewValue(const nsAString& aValue) {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
mState->SetPreviewText(aValue, true);
|
mState->SetPreviewText(aValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::GetPreviewValue(nsAString& aValue) {
|
||||||
HTMLTextAreaElement::GetPreviewValue(nsAString& aValue) {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
mState->GetPreviewText(aValue);
|
mState->GetPreviewText(aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::EnablePreview() {
|
||||||
HTMLTextAreaElement::EnablePreview() {
|
|
||||||
if (mIsPreviewEnabled) {
|
if (mIsPreviewEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -298,11 +284,9 @@ HTMLTextAreaElement::EnablePreview() {
|
||||||
nsChangeHint_ReconstructFrame);
|
nsChangeHint_ReconstructFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::IsPreviewEnabled() { return mIsPreviewEnabled; }
|
||||||
HTMLTextAreaElement::IsPreviewEnabled() { return mIsPreviewEnabled; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::GetPreviewVisibility() {
|
||||||
HTMLTextAreaElement::GetPreviewVisibility() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->GetPreviewVisibility();
|
return mState->GetPreviewVisibility();
|
||||||
}
|
}
|
||||||
|
@ -360,8 +344,7 @@ void HTMLTextAreaElement::SetUserInput(const nsAString& aValue,
|
||||||
TextControlState::eSetValue_MoveCursorToEndIfValueChanged);
|
TextControlState::eSetValue_MoveCursorToEndIfValueChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsresult HTMLTextAreaElement::SetValueChanged(bool aValueChanged) {
|
||||||
HTMLTextAreaElement::SetValueChanged(bool aValueChanged) {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
|
|
||||||
bool previousValue = mValueChanged;
|
bool previousValue = mValueChanged;
|
||||||
|
@ -1083,23 +1066,18 @@ nsresult HTMLTextAreaElement::GetValidationMessage(
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::IsSingleLineTextControl() const { return false; }
|
||||||
HTMLTextAreaElement::IsSingleLineTextControl() const { return false; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::IsTextArea() const { return true; }
|
||||||
HTMLTextAreaElement::IsTextArea() const { return true; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::IsPasswordTextControl() const { return false; }
|
||||||
HTMLTextAreaElement::IsPasswordTextControl() const { return false; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(int32_t)
|
int32_t HTMLTextAreaElement::GetCols() { return Cols(); }
|
||||||
HTMLTextAreaElement::GetCols() { return Cols(); }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(int32_t)
|
int32_t HTMLTextAreaElement::GetWrapCols() {
|
||||||
HTMLTextAreaElement::GetWrapCols() {
|
|
||||||
nsHTMLTextWrap wrapProp;
|
nsHTMLTextWrap wrapProp;
|
||||||
nsITextControlElement::GetWrapPropertyEnum(this, wrapProp);
|
TextControlElement::GetWrapPropertyEnum(this, wrapProp);
|
||||||
if (wrapProp == nsITextControlElement::eHTMLTextWrap_Off) {
|
if (wrapProp == TextControlElement::eHTMLTextWrap_Off) {
|
||||||
// do not wrap when wrap=off
|
// do not wrap when wrap=off
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1108,8 +1086,7 @@ HTMLTextAreaElement::GetWrapCols() {
|
||||||
return GetCols();
|
return GetCols();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(int32_t)
|
int32_t HTMLTextAreaElement::GetRows() {
|
||||||
HTMLTextAreaElement::GetRows() {
|
|
||||||
const nsAttrValue* attr = GetParsedAttr(nsGkAtoms::rows);
|
const nsAttrValue* attr = GetParsedAttr(nsGkAtoms::rows);
|
||||||
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
||||||
int32_t rows = attr->GetIntegerValue();
|
int32_t rows = attr->GetIntegerValue();
|
||||||
|
@ -1119,29 +1096,24 @@ HTMLTextAreaElement::GetRows() {
|
||||||
return DEFAULT_ROWS_TEXTAREA;
|
return DEFAULT_ROWS_TEXTAREA;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::GetDefaultValueFromContent(nsAString& aValue) {
|
||||||
HTMLTextAreaElement::GetDefaultValueFromContent(nsAString& aValue) {
|
|
||||||
GetDefaultValue(aValue, IgnoreErrors());
|
GetDefaultValue(aValue, IgnoreErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::ValueChanged() const { return mValueChanged; }
|
||||||
HTMLTextAreaElement::ValueChanged() const { return mValueChanged; }
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::GetTextEditorValue(nsAString& aValue,
|
||||||
HTMLTextAreaElement::GetTextEditorValue(nsAString& aValue,
|
bool aIgnoreWrap) const {
|
||||||
bool aIgnoreWrap) const {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
mState->GetValue(aValue, aIgnoreWrap);
|
mState->GetValue(aValue, aIgnoreWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::InitializeKeyboardEventListeners() {
|
||||||
HTMLTextAreaElement::InitializeKeyboardEventListeners() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
mState->InitializeKeyboardEventListeners();
|
mState->InitializeKeyboardEventListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(void)
|
void HTMLTextAreaElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
|
||||||
HTMLTextAreaElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
|
|
||||||
if (aKind != ValueChangeKind::Internal) {
|
if (aKind != ValueChangeKind::Internal) {
|
||||||
mLastValueChangeWasInteractive = aKind == ValueChangeKind::UserInteraction;
|
mLastValueChangeWasInteractive = aKind == ValueChangeKind::UserInteraction;
|
||||||
}
|
}
|
||||||
|
@ -1158,8 +1130,7 @@ HTMLTextAreaElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
bool HTMLTextAreaElement::HasCachedSelection() {
|
||||||
HTMLTextAreaElement::HasCachedSelection() {
|
|
||||||
MOZ_ASSERT(mState);
|
MOZ_ASSERT(mState);
|
||||||
return mState->IsSelectionCached();
|
return mState->IsSelectionCached();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
#define mozilla_dom_HTMLTextAreaElement_h
|
#define mozilla_dom_HTMLTextAreaElement_h
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/TextControlState.h"
|
#include "mozilla/TextControlState.h"
|
||||||
#include "mozilla/TextEditor.h"
|
#include "mozilla/TextEditor.h"
|
||||||
#include "mozilla/dom/HTMLFormElement.h"
|
#include "mozilla/dom/HTMLFormElement.h"
|
||||||
#include "mozilla/dom/HTMLInputElementBinding.h"
|
#include "mozilla/dom/HTMLInputElementBinding.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsIControllers.h"
|
#include "nsIControllers.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsGenericHTMLElement.h"
|
#include "nsGenericHTMLElement.h"
|
||||||
|
@ -34,8 +34,7 @@ namespace dom {
|
||||||
|
|
||||||
class HTMLFormSubmission;
|
class HTMLFormSubmission;
|
||||||
|
|
||||||
class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
|
class HTMLTextAreaElement final : public TextControlElement,
|
||||||
public nsITextControlElement,
|
|
||||||
public nsStubMutationObserver,
|
public nsStubMutationObserver,
|
||||||
public nsIConstraintValidation {
|
public nsIConstraintValidation {
|
||||||
public:
|
public:
|
||||||
|
@ -69,43 +68,42 @@ class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
|
||||||
|
|
||||||
virtual EventStates IntrinsicState() const override;
|
virtual EventStates IntrinsicState() const override;
|
||||||
|
|
||||||
// nsITextControlElemet
|
// TextControlElement
|
||||||
NS_IMETHOD SetValueChanged(bool aValueChanged) override;
|
virtual nsresult SetValueChanged(bool aValueChanged) override;
|
||||||
NS_IMETHOD_(bool) IsSingleLineTextControl() const override;
|
virtual bool IsSingleLineTextControl() const override;
|
||||||
NS_IMETHOD_(bool) IsTextArea() const override;
|
virtual bool IsTextArea() const override;
|
||||||
NS_IMETHOD_(bool) IsPasswordTextControl() const override;
|
virtual bool IsPasswordTextControl() const override;
|
||||||
NS_IMETHOD_(int32_t) GetCols() override;
|
virtual int32_t GetCols() override;
|
||||||
NS_IMETHOD_(int32_t) GetWrapCols() override;
|
virtual int32_t GetWrapCols() override;
|
||||||
NS_IMETHOD_(int32_t) GetRows() override;
|
virtual int32_t GetRows() override;
|
||||||
NS_IMETHOD_(void) GetDefaultValueFromContent(nsAString& aValue) override;
|
virtual void GetDefaultValueFromContent(nsAString& aValue) override;
|
||||||
NS_IMETHOD_(bool) ValueChanged() const override;
|
virtual bool ValueChanged() const override;
|
||||||
NS_IMETHOD_(void)
|
virtual void GetTextEditorValue(nsAString& aValue,
|
||||||
GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const override;
|
bool aIgnoreWrap) const override;
|
||||||
NS_IMETHOD_(TextEditor*) GetTextEditor() override;
|
MOZ_CAN_RUN_SCRIPT virtual TextEditor* GetTextEditor() override;
|
||||||
NS_IMETHOD_(TextEditor*) GetTextEditorWithoutCreation() override;
|
virtual TextEditor* GetTextEditorWithoutCreation() override;
|
||||||
NS_IMETHOD_(nsISelectionController*) GetSelectionController() override;
|
virtual nsISelectionController* GetSelectionController() override;
|
||||||
NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection() override;
|
virtual nsFrameSelection* GetConstFrameSelection() override;
|
||||||
NS_IMETHOD_(TextControlState*) GetTextControlState() const override {
|
virtual TextControlState* GetTextControlState() const override {
|
||||||
return mState;
|
return mState;
|
||||||
}
|
}
|
||||||
NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame) override;
|
virtual nsresult BindToFrame(nsTextControlFrame* aFrame) override;
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void UnbindFromFrame(
|
||||||
NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame) override;
|
nsTextControlFrame* aFrame) override;
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT virtual nsresult CreateEditor() override;
|
||||||
NS_IMETHOD CreateEditor() override;
|
virtual void UpdateOverlayTextVisibility(bool aNotify) override;
|
||||||
NS_IMETHOD_(void) UpdateOverlayTextVisibility(bool aNotify) override;
|
virtual bool GetPlaceholderVisibility() override;
|
||||||
NS_IMETHOD_(bool) GetPlaceholderVisibility() override;
|
virtual bool GetPreviewVisibility() override;
|
||||||
NS_IMETHOD_(bool) GetPreviewVisibility() override;
|
virtual void SetPreviewValue(const nsAString& aValue) override;
|
||||||
NS_IMETHOD_(void) SetPreviewValue(const nsAString& aValue) override;
|
virtual void GetPreviewValue(nsAString& aValue) override;
|
||||||
NS_IMETHOD_(void) GetPreviewValue(nsAString& aValue) override;
|
virtual void EnablePreview() override;
|
||||||
NS_IMETHOD_(void) EnablePreview() override;
|
virtual bool IsPreviewEnabled() override;
|
||||||
NS_IMETHOD_(bool) IsPreviewEnabled() override;
|
virtual void InitializeKeyboardEventListeners() override;
|
||||||
NS_IMETHOD_(void) InitializeKeyboardEventListeners() override;
|
virtual void OnValueChanged(bool aNotify, ValueChangeKind) override;
|
||||||
NS_IMETHOD_(void) OnValueChanged(bool aNotify, ValueChangeKind) override;
|
|
||||||
virtual void GetValueFromSetRangeText(nsAString& aValue) override;
|
virtual void GetValueFromSetRangeText(nsAString& aValue) override;
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||||
virtual nsresult SetValueFromSetRangeText(const nsAString& aValue) override;
|
virtual nsresult SetValueFromSetRangeText(const nsAString& aValue) override;
|
||||||
NS_IMETHOD_(bool) HasCachedSelection() override;
|
virtual bool HasCachedSelection() override;
|
||||||
|
|
||||||
// nsIContent
|
// nsIContent
|
||||||
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
||||||
|
@ -149,7 +147,7 @@ class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
|
||||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
||||||
|
|
||||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTextAreaElement,
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTextAreaElement,
|
||||||
nsGenericHTMLFormElementWithState)
|
TextControlElement)
|
||||||
|
|
||||||
// nsIConstraintValidation
|
// nsIConstraintValidation
|
||||||
bool IsTooLong();
|
bool IsTooLong();
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef nsITextControlElement_h___
|
#ifndef mozilla_TextControlElement_h
|
||||||
#define nsITextControlElement_h___
|
#define mozilla_TextControlElement_h
|
||||||
|
|
||||||
|
#include "mozilla/dom/FromParser.h"
|
||||||
|
#include "mozilla/dom/NodeInfo.h"
|
||||||
|
#include "nsGenericHTMLElement.h"
|
||||||
|
|
||||||
#include "nsISupports.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsStringFwd.h"
|
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
class nsISelectionController;
|
class nsISelectionController;
|
||||||
class nsFrameSelection;
|
class nsFrameSelection;
|
||||||
|
@ -21,76 +22,74 @@ class ErrorResult;
|
||||||
class TextControlState;
|
class TextControlState;
|
||||||
class TextEditor;
|
class TextEditor;
|
||||||
|
|
||||||
namespace dom {
|
|
||||||
class Element;
|
|
||||||
} // namespace dom
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
// IID for the nsITextControl interface
|
|
||||||
#define NS_ITEXTCONTROLELEMENT_IID \
|
|
||||||
{ \
|
|
||||||
0x3df7db6d, 0xa548, 0x4e20, { \
|
|
||||||
0x97, 0xfd, 0x75, 0xa3, 0x31, 0xa2, 0xf3, 0xd4 \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is used for the text control frame to get the editor and
|
* This abstract class is used for the text control frame to get the editor and
|
||||||
* selection controller objects, and some helper properties.
|
* selection controller objects, and some helper properties.
|
||||||
*/
|
*/
|
||||||
class nsITextControlElement : public nsISupports {
|
class TextControlElement : public nsGenericHTMLFormElementWithState {
|
||||||
public:
|
public:
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXTCONTROLELEMENT_IID)
|
TextControlElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo,
|
||||||
|
dom::FromParser aFromParser, uint8_t aType)
|
||||||
|
: nsGenericHTMLFormElementWithState(std::move(aNodeInfo), aFromParser,
|
||||||
|
aType){};
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextControlElement,
|
||||||
|
nsGenericHTMLFormElementWithState)
|
||||||
|
|
||||||
|
bool IsTextControlElement() const final { return true; }
|
||||||
|
|
||||||
|
NS_IMPL_FROMNODE_HELPER(TextControlElement, IsTextControlElement())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell the control that value has been deliberately changed (or not).
|
* Tell the control that value has been deliberately changed (or not).
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD SetValueChanged(bool changed) = 0;
|
virtual nsresult SetValueChanged(bool changed) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out whether this is a single line text control. (text or password)
|
* Find out whether this is a single line text control. (text or password)
|
||||||
* @return whether this is a single line text control
|
* @return whether this is a single line text control
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) IsSingleLineTextControl() const = 0;
|
virtual bool IsSingleLineTextControl() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out whether this control is a textarea.
|
* Find out whether this control is a textarea.
|
||||||
* @return whether this is a textarea text control
|
* @return whether this is a textarea text control
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) IsTextArea() const = 0;
|
virtual bool IsTextArea() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out whether this is a password control (input type=password)
|
* Find out whether this is a password control (input type=password)
|
||||||
* @return whether this is a password ontrol
|
* @return whether this is a password ontrol
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) IsPasswordTextControl() const = 0;
|
virtual bool IsPasswordTextControl() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cols attribute (if textarea) or a default
|
* Get the cols attribute (if textarea) or a default
|
||||||
* @return the number of columns to use
|
* @return the number of columns to use
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(int32_t) GetCols() = 0;
|
virtual int32_t GetCols() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the column index to wrap at, or -1 if we shouldn't wrap
|
* Get the column index to wrap at, or -1 if we shouldn't wrap
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(int32_t) GetWrapCols() = 0;
|
virtual int32_t GetWrapCols() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the rows attribute (if textarea) or a default
|
* Get the rows attribute (if textarea) or a default
|
||||||
* @return the number of rows to use
|
* @return the number of rows to use
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(int32_t) GetRows() = 0;
|
virtual int32_t GetRows() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default value of the text control
|
* Get the default value of the text control
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void) GetDefaultValueFromContent(nsAString& aValue) = 0;
|
virtual void GetDefaultValueFromContent(nsAString& aValue) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the value of the control has been changed.
|
* Return true if the value of the control has been changed.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) ValueChanged() const = 0;
|
virtual bool ValueChanged() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current value of the text editor.
|
* Get the current value of the text editor.
|
||||||
|
@ -99,8 +98,8 @@ class nsITextControlElement : public nsISupports {
|
||||||
* @param aIgnoreWrap whether to ignore the text wrapping behavior specified
|
* @param aIgnoreWrap whether to ignore the text wrapping behavior specified
|
||||||
* for the element.
|
* for the element.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void)
|
virtual void GetTextEditorValue(nsAString& aValue,
|
||||||
GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const = 0;
|
bool aIgnoreWrap) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the editor object associated with the text editor.
|
* Get the editor object associated with the text editor.
|
||||||
|
@ -110,79 +109,80 @@ class nsITextControlElement : public nsISupports {
|
||||||
* If you need editor only when the editor is there, you should use
|
* If you need editor only when the editor is there, you should use
|
||||||
* GetTextEditorWithoutCreation().
|
* GetTextEditorWithoutCreation().
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditor() = 0;
|
MOZ_CAN_RUN_SCRIPT virtual TextEditor* GetTextEditor() = 0;
|
||||||
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditorWithoutCreation() = 0;
|
virtual TextEditor* GetTextEditorWithoutCreation() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the selection controller object associated with the text editor.
|
* Get the selection controller object associated with the text editor.
|
||||||
* The return value is null if the control does not support an editor
|
* The return value is null if the control does not support an editor
|
||||||
* (for example, if it is a checkbox.)
|
* (for example, if it is a checkbox.)
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(nsISelectionController*) GetSelectionController() = 0;
|
virtual nsISelectionController* GetSelectionController() = 0;
|
||||||
|
|
||||||
NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection() = 0;
|
virtual nsFrameSelection* GetConstFrameSelection() = 0;
|
||||||
|
|
||||||
NS_IMETHOD_(mozilla::TextControlState*) GetTextControlState() const = 0;
|
virtual TextControlState* GetTextControlState() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds a frame to the text control. This is performed when a frame
|
* Binds a frame to the text control. This is performed when a frame
|
||||||
* is created for the content node.
|
* is created for the content node.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame) = 0;
|
virtual nsresult BindToFrame(nsTextControlFrame* aFrame) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unbinds a frame from the text control. This is performed when a frame
|
* Unbinds a frame from the text control. This is performed when a frame
|
||||||
* belonging to a content node is destroyed.
|
* belonging to a content node is destroyed.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame) = 0;
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void UnbindFromFrame(
|
||||||
|
nsTextControlFrame* aFrame) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an editor for the text control. This should happen when
|
* Creates an editor for the text control. This should happen when
|
||||||
* a frame has been created for the text control element, but the created
|
* a frame has been created for the text control element, but the created
|
||||||
* editor may outlive the frame itself.
|
* editor may outlive the frame itself.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD CreateEditor() = 0;
|
MOZ_CAN_RUN_SCRIPT virtual nsresult CreateEditor() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update preview value for the text control.
|
* Update preview value for the text control.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void) SetPreviewValue(const nsAString& aValue) = 0;
|
virtual void SetPreviewValue(const nsAString& aValue) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current preview value for text control.
|
* Get the current preview value for text control.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void) GetPreviewValue(nsAString& aValue) = 0;
|
virtual void GetPreviewValue(nsAString& aValue) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable preview for text control.
|
* Enable preview for text control.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void) EnablePreview() = 0;
|
virtual void EnablePreview() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out whether this control enables preview for form autofoll.
|
* Find out whether this control enables preview for form autofoll.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) IsPreviewEnabled() = 0;
|
virtual bool IsPreviewEnabled() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the keyboard event listeners.
|
* Initialize the keyboard event listeners.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void) InitializeKeyboardEventListeners() = 0;
|
virtual void InitializeKeyboardEventListeners() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the visibility of both the placholder and preview text based on the
|
* Update the visibility of both the placholder and preview text based on the
|
||||||
* element's state.
|
* element's state.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void) UpdateOverlayTextVisibility(bool aNotify) = 0;
|
virtual void UpdateOverlayTextVisibility(bool aNotify) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current expected placeholder visibility state.
|
* Returns the current expected placeholder visibility state.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) GetPlaceholderVisibility() = 0;
|
virtual bool GetPlaceholderVisibility() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current expected preview visibility state.
|
* Returns the current expected preview visibility state.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) GetPreviewVisibility() = 0;
|
virtual bool GetPreviewVisibility() = 0;
|
||||||
|
|
||||||
enum class ValueChangeKind {
|
enum class ValueChangeKind {
|
||||||
Internal,
|
Internal,
|
||||||
|
@ -193,8 +193,7 @@ class nsITextControlElement : public nsISupports {
|
||||||
/**
|
/**
|
||||||
* Callback called whenever the value is changed.
|
* Callback called whenever the value is changed.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(void)
|
virtual void OnValueChanged(bool aNotify, ValueChangeKind) = 0;
|
||||||
OnValueChanged(bool aNotify, ValueChangeKind) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpers for value manipulation from SetRangeText.
|
* Helpers for value manipulation from SetRangeText.
|
||||||
|
@ -223,12 +222,15 @@ class nsITextControlElement : public nsISupports {
|
||||||
* Note that this function has the side effect of making the editor for input
|
* Note that this function has the side effect of making the editor for input
|
||||||
* elements be initialized eagerly.
|
* elements be initialized eagerly.
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD_(bool) HasCachedSelection() = 0;
|
virtual bool HasCachedSelection() = 0;
|
||||||
|
|
||||||
static already_AddRefed<nsITextControlElement>
|
static already_AddRefed<TextControlElement>
|
||||||
GetTextControlElementFromEditingHost(nsIContent* aHost);
|
GetTextControlElementFromEditingHost(nsIContent* aHost);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~TextControlElement() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsITextControlElement, NS_ITEXTCONTROLELEMENT_IID)
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // nsITextControlElement_h___
|
#endif // mozilla_TextControlElement_h
|
|
@ -49,13 +49,30 @@
|
||||||
#include "mozilla/KeyEventHandler.h"
|
#include "mozilla/KeyEventHandler.h"
|
||||||
#include "mozilla/dom/KeyboardEvent.h"
|
#include "mozilla/dom/KeyboardEvent.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
using namespace dom;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* nsITextControlElement
|
* TextControlElement
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_CLASS(TextControlElement)
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
|
||||||
|
TextControlElement, nsGenericHTMLFormElementWithState)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
|
||||||
|
TextControlElement, nsGenericHTMLFormElementWithState)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(
|
||||||
|
TextControlElement, nsGenericHTMLFormElementWithState)
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
bool nsITextControlElement::GetWrapPropertyEnum(
|
bool TextControlElement::GetWrapPropertyEnum(
|
||||||
nsIContent* aContent, nsITextControlElement::nsHTMLTextWrap& aWrapProp) {
|
nsIContent* aContent, TextControlElement::nsHTMLTextWrap& aWrapProp) {
|
||||||
// soft is the default; "physical" defaults to soft as well because all other
|
// soft is the default; "physical" defaults to soft as well because all other
|
||||||
// browsers treat it that way and there is no real reason to maintain physical
|
// browsers treat it that way and there is no real reason to maintain physical
|
||||||
// and virtual as separate entities if no one else does. Only hard and off
|
// and virtual as separate entities if no one else does. Only hard and off
|
||||||
|
@ -82,23 +99,18 @@ bool nsITextControlElement::GetWrapPropertyEnum(
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
already_AddRefed<nsITextControlElement>
|
already_AddRefed<TextControlElement>
|
||||||
nsITextControlElement::GetTextControlElementFromEditingHost(nsIContent* aHost) {
|
TextControlElement::GetTextControlElementFromEditingHost(nsIContent* aHost) {
|
||||||
if (!aHost) {
|
if (!aHost) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsITextControlElement> parent =
|
RefPtr<TextControlElement> parent =
|
||||||
do_QueryInterface(aHost->GetParent());
|
TextControlElement::FromNodeOrNull(aHost->GetParent());
|
||||||
|
|
||||||
return parent.forget();
|
return parent.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace mozilla {
|
using ValueChangeKind = TextControlElement::ValueChangeKind;
|
||||||
|
|
||||||
using namespace dom;
|
|
||||||
|
|
||||||
using ValueChangeKind = nsITextControlElement::ValueChangeKind;
|
|
||||||
|
|
||||||
inline nsresult SetEditorFlagsIfNecessary(EditorBase& aEditorBase,
|
inline nsresult SetEditorFlagsIfNecessary(EditorBase& aEditorBase,
|
||||||
uint32_t aFlags) {
|
uint32_t aFlags) {
|
||||||
|
@ -793,7 +805,7 @@ nsresult TextInputSelectionController::CheckVisibilityContent(
|
||||||
* mozilla::TextInputListener
|
* mozilla::TextInputListener
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
TextInputListener::TextInputListener(nsITextControlElement* aTxtCtrlElement)
|
TextInputListener::TextInputListener(TextControlElement* aTxtCtrlElement)
|
||||||
: mFrame(nullptr),
|
: mFrame(nullptr),
|
||||||
mTxtCtrlElement(aTxtCtrlElement),
|
mTxtCtrlElement(aTxtCtrlElement),
|
||||||
mTextControlState(aTxtCtrlElement ? aTxtCtrlElement->GetTextControlState()
|
mTextControlState(aTxtCtrlElement ? aTxtCtrlElement->GetTextControlState()
|
||||||
|
@ -949,8 +961,8 @@ TextInputListener::HandleEvent(Event* aEvent) {
|
||||||
|
|
||||||
// XXX Do we execute only one handler even if the handler neither stops
|
// XXX Do we execute only one handler even if the handler neither stops
|
||||||
// propagation nor prevents default of the event?
|
// propagation nor prevents default of the event?
|
||||||
nsCOMPtr<EventTarget> target = do_QueryInterface(mTxtCtrlElement);
|
RefPtr<TextControlElement> textControlElement(mTxtCtrlElement);
|
||||||
nsresult rv = handler->ExecuteHandler(target, aEvent);
|
nsresult rv = handler->ExecuteHandler(textControlElement, aEvent);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1271,9 +1283,7 @@ class MOZ_STACK_CLASS AutoTextControlHandlingState {
|
||||||
}
|
}
|
||||||
return mParent ? mParent->IsHandling(aTextControlAction) : false;
|
return mParent ? mParent->IsHandling(aTextControlAction) : false;
|
||||||
}
|
}
|
||||||
nsITextControlElement* GetTextControlElement() const {
|
TextControlElement* GetTextControlElement() const { return mTextCtrlElement; }
|
||||||
return mTextCtrlElement;
|
|
||||||
}
|
|
||||||
TextInputListener* GetTextInputListener() const { return mTextInputListener; }
|
TextInputListener* GetTextInputListener() const { return mTextInputListener; }
|
||||||
uint32_t GetSetValueFlags() const {
|
uint32_t GetSetValueFlags() const {
|
||||||
MOZ_ASSERT(Is(TextControlAction::SetValue));
|
MOZ_ASSERT(Is(TextControlAction::SetValue));
|
||||||
|
@ -1317,7 +1327,7 @@ class MOZ_STACK_CLASS AutoTextControlHandlingState {
|
||||||
// mTextCtrlElement grabs TextControlState::mTextCtrlElement since
|
// mTextCtrlElement grabs TextControlState::mTextCtrlElement since
|
||||||
// if the text control element releases mTextControlState, only this
|
// if the text control element releases mTextControlState, only this
|
||||||
// can guarantee the instance of the text control element.
|
// can guarantee the instance of the text control element.
|
||||||
nsCOMPtr<nsITextControlElement> const mTextCtrlElement;
|
RefPtr<TextControlElement> const mTextCtrlElement;
|
||||||
// mTextInputListener grabs TextControlState::mTextListener because if
|
// mTextInputListener grabs TextControlState::mTextListener because if
|
||||||
// TextControlState is unbind from the frame, it's released.
|
// TextControlState is unbind from the frame, it's released.
|
||||||
RefPtr<TextInputListener> const mTextInputListener;
|
RefPtr<TextInputListener> const mTextInputListener;
|
||||||
|
@ -1338,7 +1348,7 @@ AutoTArray<TextControlState*, TextControlState::kMaxCountOfCacheToReuse>*
|
||||||
TextControlState::sReleasedInstances = nullptr;
|
TextControlState::sReleasedInstances = nullptr;
|
||||||
bool TextControlState::sHasShutDown = false;
|
bool TextControlState::sHasShutDown = false;
|
||||||
|
|
||||||
TextControlState::TextControlState(nsITextControlElement* aOwningElement)
|
TextControlState::TextControlState(TextControlElement* aOwningElement)
|
||||||
: mTextCtrlElement(aOwningElement),
|
: mTextCtrlElement(aOwningElement),
|
||||||
mBoundFrame(nullptr),
|
mBoundFrame(nullptr),
|
||||||
mEverInited(false),
|
mEverInited(false),
|
||||||
|
@ -1357,7 +1367,7 @@ TextControlState::TextControlState(nsITextControlElement* aOwningElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextControlState* TextControlState::Construct(
|
TextControlState* TextControlState::Construct(
|
||||||
nsITextControlElement* aOwningElement) {
|
TextControlElement* aOwningElement) {
|
||||||
if (sReleasedInstances && !sReleasedInstances->IsEmpty()) {
|
if (sReleasedInstances && !sReleasedInstances->IsEmpty()) {
|
||||||
TextControlState* state = sReleasedInstances->LastElement();
|
TextControlState* state = sReleasedInstances->LastElement();
|
||||||
sReleasedInstances->RemoveLastElement();
|
sReleasedInstances->RemoveLastElement();
|
||||||
|
@ -1581,8 +1591,7 @@ nsresult TextControlState::BindToFrame(nsTextControlFrame* aFrame) {
|
||||||
|
|
||||||
// If an editor exists from before, prepare it for usage
|
// If an editor exists from before, prepare it for usage
|
||||||
if (mTextEditor) {
|
if (mTextEditor) {
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
if (NS_WARN_IF(!mTextCtrlElement)) {
|
||||||
if (NS_WARN_IF(!content)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1598,7 +1607,7 @@ nsresult TextControlState::BindToFrame(nsTextControlFrame* aFrame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsContentUtils::AddScriptRunner(
|
nsContentUtils::AddScriptRunner(
|
||||||
new PrepareEditorEvent(*this, content, currentValue));
|
new PrepareEditorEvent(*this, mTextCtrlElement, currentValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1644,6 +1653,9 @@ nsresult TextControlState::PrepareEditor(const nsAString* aValue) {
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(mTextCtrlElement);
|
||||||
|
|
||||||
AutoTextControlHandlingState preparingEditor(
|
AutoTextControlHandlingState preparingEditor(
|
||||||
*this, TextControlAction::PrepareEditor);
|
*this, TextControlAction::PrepareEditor);
|
||||||
|
|
||||||
|
@ -1751,16 +1763,15 @@ nsresult TextControlState::PrepareEditor(const nsAString* aValue) {
|
||||||
|
|
||||||
if (!SuppressEventHandlers(presContext)) {
|
if (!SuppressEventHandlers(presContext)) {
|
||||||
nsCOMPtr<nsIControllers> controllers;
|
nsCOMPtr<nsIControllers> controllers;
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
if (HTMLInputElement* inputElement =
|
||||||
HTMLInputElement* inputElement = HTMLInputElement::FromNodeOrNull(content);
|
HTMLInputElement::FromNodeOrNull(mTextCtrlElement)) {
|
||||||
if (inputElement) {
|
|
||||||
rv = inputElement->GetControllers(getter_AddRefs(controllers));
|
rv = inputElement->GetControllers(getter_AddRefs(controllers));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
HTMLTextAreaElement* textAreaElement =
|
HTMLTextAreaElement* textAreaElement =
|
||||||
HTMLTextAreaElement::FromNodeOrNull(content);
|
HTMLTextAreaElement::FromNodeOrNull(mTextCtrlElement);
|
||||||
if (!textAreaElement) {
|
if (!textAreaElement) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -1804,28 +1815,26 @@ nsresult TextControlState::PrepareEditor(const nsAString* aValue) {
|
||||||
// Set max text field length
|
// Set max text field length
|
||||||
newTextEditor->SetMaxTextLength(GetMaxLength());
|
newTextEditor->SetMaxTextLength(GetMaxLength());
|
||||||
|
|
||||||
if (nsCOMPtr<Element> element = do_QueryInterface(mTextCtrlElement)) {
|
editorFlags = newTextEditor->Flags();
|
||||||
editorFlags = newTextEditor->Flags();
|
|
||||||
|
|
||||||
// Check if the readonly attribute is set.
|
// Check if the readonly attribute is set.
|
||||||
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::readonly)) {
|
if (mTextCtrlElement->HasAttr(kNameSpaceID_None, nsGkAtoms::readonly)) {
|
||||||
editorFlags |= nsIPlaintextEditor::eEditorReadonlyMask;
|
editorFlags |= nsIPlaintextEditor::eEditorReadonlyMask;
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the disabled attribute is set.
|
|
||||||
// TODO: call IsDisabled() here!
|
|
||||||
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
|
|
||||||
editorFlags |= nsIPlaintextEditor::eEditorDisabledMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable the selection if necessary.
|
|
||||||
if (newTextEditor->IsDisabled()) {
|
|
||||||
mSelCon->SetDisplaySelection(nsISelectionController::SELECTION_OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetEditorFlagsIfNecessary(*newTextEditor, editorFlags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the disabled attribute is set.
|
||||||
|
// TODO: call IsDisabled() here!
|
||||||
|
if (mTextCtrlElement->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
|
||||||
|
editorFlags |= nsIPlaintextEditor::eEditorDisabledMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable the selection if necessary.
|
||||||
|
if (newTextEditor->IsDisabled()) {
|
||||||
|
mSelCon->SetDisplaySelection(nsISelectionController::SELECTION_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetEditorFlagsIfNecessary(*newTextEditor, editorFlags);
|
||||||
|
|
||||||
if (shouldInitializeEditor) {
|
if (shouldInitializeEditor) {
|
||||||
// Hold on to the newly created editor
|
// Hold on to the newly created editor
|
||||||
preDestroyer.Swap(mTextEditor);
|
preDestroyer.Swap(mTextEditor);
|
||||||
|
@ -1872,7 +1881,7 @@ nsresult TextControlState::PrepareEditor(const nsAString* aValue) {
|
||||||
"Failed to disable undo/redo transaction");
|
"Failed to disable undo/redo transaction");
|
||||||
} else {
|
} else {
|
||||||
DebugOnly<bool> enabledUndoRedo =
|
DebugOnly<bool> enabledUndoRedo =
|
||||||
newTextEditor->EnableUndoRedo(nsITextControlElement::DEFAULT_UNDO_CAP);
|
newTextEditor->EnableUndoRedo(TextControlElement::DEFAULT_UNDO_CAP);
|
||||||
NS_WARNING_ASSERTION(enabledUndoRedo,
|
NS_WARNING_ASSERTION(enabledUndoRedo,
|
||||||
"Failed to enable undo/redo transaction");
|
"Failed to enable undo/redo transaction");
|
||||||
}
|
}
|
||||||
|
@ -2072,9 +2081,8 @@ void TextControlState::SetSelectionRange(
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
// It sure would be nice if we had an existing Element* or so to work with.
|
// It sure would be nice if we had an existing Element* or so to work with.
|
||||||
nsCOMPtr<nsINode> node = do_QueryInterface(mTextCtrlElement);
|
|
||||||
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
||||||
new AsyncEventDispatcher(node, NS_LITERAL_STRING("select"),
|
new AsyncEventDispatcher(mTextCtrlElement, NS_LITERAL_STRING("select"),
|
||||||
CanBubble::eYes, ChromeOnlyDispatch::eNo);
|
CanBubble::eYes, ChromeOnlyDispatch::eNo);
|
||||||
asyncDispatcher->PostDOMEvent();
|
asyncDispatcher->PostDOMEvent();
|
||||||
}
|
}
|
||||||
|
@ -2390,13 +2398,12 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
||||||
// Clean up the controller
|
// Clean up the controller
|
||||||
if (!SuppressEventHandlers(mBoundFrame->PresContext())) {
|
if (!SuppressEventHandlers(mBoundFrame->PresContext())) {
|
||||||
nsCOMPtr<nsIControllers> controllers;
|
nsCOMPtr<nsIControllers> controllers;
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
if (HTMLInputElement* inputElement =
|
||||||
HTMLInputElement* inputElement = HTMLInputElement::FromNodeOrNull(content);
|
HTMLInputElement::FromNodeOrNull(mTextCtrlElement)) {
|
||||||
if (inputElement) {
|
|
||||||
inputElement->GetControllers(getter_AddRefs(controllers));
|
inputElement->GetControllers(getter_AddRefs(controllers));
|
||||||
} else {
|
} else {
|
||||||
HTMLTextAreaElement* textAreaElement =
|
HTMLTextAreaElement* textAreaElement =
|
||||||
HTMLTextAreaElement::FromNodeOrNull(content);
|
HTMLTextAreaElement::FromNodeOrNull(mTextCtrlElement);
|
||||||
if (textAreaElement) {
|
if (textAreaElement) {
|
||||||
textAreaElement->GetControllers(getter_AddRefs(controllers));
|
textAreaElement->GetControllers(getter_AddRefs(controllers));
|
||||||
}
|
}
|
||||||
|
@ -2433,8 +2440,8 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
||||||
if (mTextListener) {
|
if (mTextListener) {
|
||||||
mTextListener->SetFrame(nullptr);
|
mTextListener->SetFrame(nullptr);
|
||||||
|
|
||||||
nsCOMPtr<EventTarget> target = do_QueryInterface(mTextCtrlElement);
|
EventListenerManager* manager =
|
||||||
EventListenerManager* manager = target->GetExistingListenerManager();
|
mTextCtrlElement->GetExistingListenerManager();
|
||||||
if (manager) {
|
if (manager) {
|
||||||
manager->RemoveEventListenerByType(mTextListener,
|
manager->RemoveEventListenerByType(mTextListener,
|
||||||
NS_LITERAL_STRING("keydown"),
|
NS_LITERAL_STRING("keydown"),
|
||||||
|
@ -2463,13 +2470,12 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t TextControlState::GetMaxLength() {
|
int32_t TextControlState::GetMaxLength() {
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
if (NS_WARN_IF(!mTextCtrlElement)) {
|
||||||
nsGenericHTMLElement* element = nsGenericHTMLElement::FromNodeOrNull(content);
|
|
||||||
if (NS_WARN_IF(!element)) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nsAttrValue* attr = element->GetParsedAttr(nsGkAtoms::maxlength);
|
const nsAttrValue* attr =
|
||||||
|
mTextCtrlElement->GetParsedAttr(nsGkAtoms::maxlength);
|
||||||
return attr && attr->Type() == nsAttrValue::eInteger ? attr->GetIntegerValue()
|
return attr && attr->Type() == nsAttrValue::eInteger ? attr->GetIntegerValue()
|
||||||
: -1;
|
: -1;
|
||||||
}
|
}
|
||||||
|
@ -2502,11 +2508,10 @@ void TextControlState::GetValue(nsAString& aValue, bool aIgnoreWrap) const {
|
||||||
nsIDocumentEncoder::OutputPersistNBSP |
|
nsIDocumentEncoder::OutputPersistNBSP |
|
||||||
nsIDocumentEncoder::OutputBodyOnly);
|
nsIDocumentEncoder::OutputBodyOnly);
|
||||||
if (!aIgnoreWrap) {
|
if (!aIgnoreWrap) {
|
||||||
nsITextControlElement::nsHTMLTextWrap wrapProp;
|
TextControlElement::nsHTMLTextWrap wrapProp;
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
if (mTextCtrlElement &&
|
||||||
if (content &&
|
TextControlElement::GetWrapPropertyEnum(mTextCtrlElement, wrapProp) &&
|
||||||
nsITextControlElement::GetWrapPropertyEnum(content, wrapProp) &&
|
wrapProp == TextControlElement::eHTMLTextWrap_Hard) {
|
||||||
wrapProp == nsITextControlElement::eHTMLTextWrap_Hard) {
|
|
||||||
flags |= nsIDocumentEncoder::OutputWrap;
|
flags |= nsIDocumentEncoder::OutputWrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2885,12 +2890,11 @@ bool TextControlState::SetValueWithoutTextEditor(
|
||||||
// the user operation which changes editor value with a built-in function
|
// the user operation which changes editor value with a built-in function
|
||||||
// like autocomplete, password manager, session restore, etc.
|
// like autocomplete, password manager, session restore, etc.
|
||||||
if (aHandlingSetValue.GetSetValueFlags() & eSetValue_BySetUserInput) {
|
if (aHandlingSetValue.GetSetValueFlags() & eSetValue_BySetUserInput) {
|
||||||
nsCOMPtr<Element> element =
|
MOZ_ASSERT(aHandlingSetValue.GetTextControlElement());
|
||||||
do_QueryInterface(aHandlingSetValue.GetTextControlElement());
|
|
||||||
MOZ_ASSERT(element);
|
|
||||||
MOZ_ASSERT(!aHandlingSetValue.GetSettingValue().IsVoid());
|
MOZ_ASSERT(!aHandlingSetValue.GetSettingValue().IsVoid());
|
||||||
DebugOnly<nsresult> rvIgnored = nsContentUtils::DispatchInputEvent(
|
DebugOnly<nsresult> rvIgnored = nsContentUtils::DispatchInputEvent(
|
||||||
element, EditorInputType::eInsertReplacementText, nullptr,
|
MOZ_KnownLive(aHandlingSetValue.GetTextControlElement()),
|
||||||
|
EditorInputType::eInsertReplacementText, nullptr,
|
||||||
nsContentUtils::InputEventOptions(
|
nsContentUtils::InputEventOptions(
|
||||||
aHandlingSetValue.GetSettingValue()));
|
aHandlingSetValue.GetSettingValue()));
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
|
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
|
||||||
|
@ -2929,8 +2933,8 @@ bool TextControlState::HasNonEmptyValue() {
|
||||||
|
|
||||||
void TextControlState::InitializeKeyboardEventListeners() {
|
void TextControlState::InitializeKeyboardEventListeners() {
|
||||||
// register key listeners
|
// register key listeners
|
||||||
nsCOMPtr<EventTarget> target = do_QueryInterface(mTextCtrlElement);
|
EventListenerManager* manager =
|
||||||
EventListenerManager* manager = target->GetOrCreateListenerManager();
|
mTextCtrlElement->GetOrCreateListenerManager();
|
||||||
if (manager) {
|
if (manager) {
|
||||||
manager->AddEventListenerByType(mTextListener, NS_LITERAL_STRING("keydown"),
|
manager->AddEventListenerByType(mTextListener, NS_LITERAL_STRING("keydown"),
|
||||||
TrustedEventsAtSystemGroupBubble());
|
TrustedEventsAtSystemGroupBubble());
|
||||||
|
@ -2988,8 +2992,8 @@ void TextControlState::UpdateOverlayTextVisibility(bool aNotify) {
|
||||||
mPlaceholderVisibility = valueIsEmpty && previewValue.IsEmpty();
|
mPlaceholderVisibility = valueIsEmpty && previewValue.IsEmpty();
|
||||||
|
|
||||||
if (mPlaceholderVisibility && !StaticPrefs::dom_placeholder_show_on_focus()) {
|
if (mPlaceholderVisibility && !StaticPrefs::dom_placeholder_show_on_focus()) {
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
mPlaceholderVisibility =
|
||||||
mPlaceholderVisibility = !nsContentUtils::IsFocusedContent(content);
|
!nsContentUtils::IsFocusedContent(mTextCtrlElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBoundFrame && aNotify) {
|
if (mBoundFrame && aNotify) {
|
||||||
|
@ -2999,8 +3003,7 @@ void TextControlState::UpdateOverlayTextVisibility(bool aNotify) {
|
||||||
|
|
||||||
void TextControlState::HideSelectionIfBlurred() {
|
void TextControlState::HideSelectionIfBlurred() {
|
||||||
MOZ_ASSERT(mSelCon, "Should have a selection controller if we have a frame!");
|
MOZ_ASSERT(mSelCon, "Should have a selection controller if we have a frame!");
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
if (!nsContentUtils::IsFocusedContent(mTextCtrlElement)) {
|
||||||
if (!nsContentUtils::IsFocusedContent(content)) {
|
|
||||||
mSelCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN);
|
mSelCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,20 @@
|
||||||
#define mozilla_TextControlState_h
|
#define mozilla_TextControlState_h
|
||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
#include "nsString.h"
|
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsITextControlFrame.h"
|
|
||||||
#include "nsCycleCollectionParticipant.h"
|
|
||||||
#include "mozilla/dom/Element.h"
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/Maybe.h"
|
#include "mozilla/Maybe.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/TextEditor.h"
|
#include "mozilla/TextEditor.h"
|
||||||
#include "mozilla/WeakPtr.h"
|
#include "mozilla/WeakPtr.h"
|
||||||
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/HTMLInputElementBinding.h"
|
#include "mozilla/dom/HTMLInputElementBinding.h"
|
||||||
#include "mozilla/dom/Nullable.h"
|
#include "mozilla/dom/Nullable.h"
|
||||||
|
#include "nsCycleCollectionParticipant.h"
|
||||||
|
#include "nsITextControlFrame.h"
|
||||||
|
|
||||||
class nsTextControlFrame;
|
class nsTextControlFrame;
|
||||||
class nsISelectionController;
|
class nsISelectionController;
|
||||||
class nsFrameSelection;
|
class nsFrameSelection;
|
||||||
class nsITextControlElement;
|
|
||||||
class nsFrame;
|
class nsFrame;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
@ -50,7 +48,7 @@ class HTMLInputElement;
|
||||||
*
|
*
|
||||||
* This class is held as a member of HTMLInputElement and HTMLTextAreaElement.
|
* This class is held as a member of HTMLInputElement and HTMLTextAreaElement.
|
||||||
* The public functions in this class include the public APIs which dom/
|
* The public functions in this class include the public APIs which dom/
|
||||||
* uses. Layout code uses the nsITextControlElement interface to invoke
|
* uses. Layout code uses the TextControlElement interface to invoke
|
||||||
* functions on this class.
|
* functions on this class.
|
||||||
*
|
*
|
||||||
* The design motivation behind this class is maintaining all of the things
|
* The design motivation behind this class is maintaining all of the things
|
||||||
|
@ -141,7 +139,7 @@ class TextControlState final : public SupportsWeakPtr<TextControlState> {
|
||||||
|
|
||||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(TextControlState)
|
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(TextControlState)
|
||||||
|
|
||||||
static TextControlState* Construct(nsITextControlElement* aOwningElement);
|
static TextControlState* Construct(TextControlElement* aOwningElement);
|
||||||
|
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
|
@ -383,7 +381,7 @@ class TextControlState final : public SupportsWeakPtr<TextControlState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit TextControlState(nsITextControlElement* aOwningElement);
|
explicit TextControlState(TextControlElement* aOwningElement);
|
||||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY ~TextControlState();
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY ~TextControlState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -444,7 +442,7 @@ class TextControlState final : public SupportsWeakPtr<TextControlState> {
|
||||||
// The text control element owns this object, and ensures that this object
|
// The text control element owns this object, and ensures that this object
|
||||||
// has a smaller lifetime except the owner releases the instance while it
|
// has a smaller lifetime except the owner releases the instance while it
|
||||||
// does something with this.
|
// does something with this.
|
||||||
nsITextControlElement* MOZ_NON_OWNING_REF mTextCtrlElement;
|
TextControlElement* MOZ_NON_OWNING_REF mTextCtrlElement;
|
||||||
RefPtr<TextInputSelectionController> mSelCon;
|
RefPtr<TextInputSelectionController> mSelCon;
|
||||||
RefPtr<RestoreSelectionState> mRestoringSelection;
|
RefPtr<RestoreSelectionState> mRestoringSelection;
|
||||||
RefPtr<TextEditor> mTextEditor;
|
RefPtr<TextEditor> mTextEditor;
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
#include "nsWeakReference.h"
|
#include "nsWeakReference.h"
|
||||||
|
|
||||||
class nsIFrame;
|
class nsIFrame;
|
||||||
class nsITextControlElement;
|
|
||||||
class nsTextControlFrame;
|
class nsTextControlFrame;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
class TextControlElement;
|
||||||
class TextControlState;
|
class TextControlState;
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
@ -27,7 +27,7 @@ class Selection;
|
||||||
class TextInputListener final : public nsIDOMEventListener,
|
class TextInputListener final : public nsIDOMEventListener,
|
||||||
public nsSupportsWeakReference {
|
public nsSupportsWeakReference {
|
||||||
public:
|
public:
|
||||||
explicit TextInputListener(nsITextControlElement* aTextControlElement);
|
explicit TextInputListener(TextControlElement* aTextControlElement);
|
||||||
|
|
||||||
void SetFrame(nsIFrame* aTextControlFrame) { mFrame = aTextControlFrame; }
|
void SetFrame(nsIFrame* aTextControlFrame) { mFrame = aTextControlFrame; }
|
||||||
void SettingValue(bool aValue) { mSettingValue = aValue; }
|
void SettingValue(bool aValue) { mSettingValue = aValue; }
|
||||||
|
@ -73,7 +73,7 @@ class TextInputListener final : public nsIDOMEventListener,
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsIFrame* mFrame;
|
nsIFrame* mFrame;
|
||||||
nsITextControlElement* const mTxtCtrlElement;
|
TextControlElement* const mTxtCtrlElement;
|
||||||
WeakPtr<TextControlState> const mTextControlState;
|
WeakPtr<TextControlState> const mTextControlState;
|
||||||
|
|
||||||
bool mSelectionWasCollapsed;
|
bool mSelectionWasCollapsed;
|
||||||
|
|
|
@ -40,10 +40,10 @@ EXPORTS += [
|
||||||
'nsIHTMLCollection.h',
|
'nsIHTMLCollection.h',
|
||||||
'nsIRadioGroupContainer.h',
|
'nsIRadioGroupContainer.h',
|
||||||
'nsIRadioVisitor.h',
|
'nsIRadioVisitor.h',
|
||||||
'nsITextControlElement.h',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
EXPORTS.mozilla += [
|
EXPORTS.mozilla += [
|
||||||
|
'TextControlElement.h',
|
||||||
'TextControlState.h',
|
'TextControlState.h',
|
||||||
'TextInputListener.h',
|
'TextInputListener.h',
|
||||||
]
|
]
|
||||||
|
|
|
@ -74,7 +74,6 @@
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
#include "mozAutoDocUpdate.h"
|
#include "mozAutoDocUpdate.h"
|
||||||
#include "nsHtml5Module.h"
|
#include "nsHtml5Module.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "mozilla/dom/ElementInlines.h"
|
#include "mozilla/dom/ElementInlines.h"
|
||||||
#include "HTMLFieldSetElement.h"
|
#include "HTMLFieldSetElement.h"
|
||||||
#include "nsTextNode.h"
|
#include "nsTextNode.h"
|
||||||
|
|
|
@ -79,7 +79,7 @@ SimpleTest.waitForFocus(function() {
|
||||||
let transactionManager = editor.transactionManager;
|
let transactionManager = editor.transactionManager;
|
||||||
is(transactionManager.numberOfUndoItems, 2,
|
is(transactionManager.numberOfUndoItems, 2,
|
||||||
editableElement.tagName + ": Initially, there should be 2 undo items");
|
editableElement.tagName + ": Initially, there should be 2 undo items");
|
||||||
// Defined as nsITextControlElement::DEFAULT_UNDO_CAP
|
// Defined as TextControlElement::DEFAULT_UNDO_CAP
|
||||||
is(transactionManager.maxTransactionCount, 1000,
|
is(transactionManager.maxTransactionCount, 1000,
|
||||||
editableElement.tagName + ": Initially, transaction manager should be able to have 1,000 undo items");
|
editableElement.tagName + ": Initially, transaction manager should be able to have 1,000 undo items");
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@
|
||||||
#include "nsRange.h"
|
#include "nsRange.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "prtime.h"
|
#include "prtime.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
@ -1088,8 +1087,7 @@ bool mozInlineSpellChecker::ShouldSpellCheckNode(TextEditor* aTextEditor,
|
||||||
while (node && node->IsInNativeAnonymousSubtree()) {
|
while (node && node->IsInNativeAnonymousSubtree()) {
|
||||||
node = node->GetParent();
|
node = node->GetParent();
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsITextControlElement> textControl = do_QueryInterface(node);
|
if (node && node->IsTextControlElement()) {
|
||||||
if (textControl) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,9 +132,10 @@ void nsTextControlFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
||||||
|
|
||||||
// Unbind the text editor state object from the frame. The editor will live
|
// Unbind the text editor state object from the frame. The editor will live
|
||||||
// on, but things like controllers will be released.
|
// on, but things like controllers will be released.
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
RefPtr<TextControlElement> textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
txtCtrl->UnbindFromFrame(this);
|
MOZ_ASSERT(textControlElement);
|
||||||
|
textControlElement->UnbindFromFrame(this);
|
||||||
|
|
||||||
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
||||||
|
|
||||||
|
@ -258,13 +259,14 @@ nsresult nsTextControlFrame::EnsureEditorInitialized() {
|
||||||
// Make sure that editor init doesn't do things that would kill us off
|
// Make sure that editor init doesn't do things that would kill us off
|
||||||
// (especially off the script blockers it'll create for its DOM mutations).
|
// (especially off the script blockers it'll create for its DOM mutations).
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
RefPtr<TextControlElement> textControlElement =
|
||||||
MOZ_ASSERT(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
|
|
||||||
// Hide selection changes during the initialization, as webpages should not
|
// Hide selection changes during the initialization, as webpages should not
|
||||||
// be aware of these initializations
|
// be aware of these initializations
|
||||||
AutoHideSelectionChanges hideSelectionChanges(
|
AutoHideSelectionChanges hideSelectionChanges(
|
||||||
txtCtrl->GetConstFrameSelection());
|
textControlElement->GetConstFrameSelection());
|
||||||
|
|
||||||
nsAutoScriptBlocker scriptBlocker;
|
nsAutoScriptBlocker scriptBlocker;
|
||||||
|
|
||||||
|
@ -296,7 +298,7 @@ nsresult nsTextControlFrame::EnsureEditorInitialized() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create an editor for the frame, if one doesn't already exist
|
// Create an editor for the frame, if one doesn't already exist
|
||||||
nsresult rv = txtCtrl->CreateEditor();
|
nsresult rv = textControlElement->CreateEditor();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_STATE(weakFrame.IsAlive());
|
NS_ENSURE_STATE(weakFrame.IsAlive());
|
||||||
|
|
||||||
|
@ -309,9 +311,9 @@ nsresult nsTextControlFrame::EnsureEditorInitialized() {
|
||||||
|
|
||||||
// Set the selection to the end of the text field (bug 1287655),
|
// Set the selection to the end of the text field (bug 1287655),
|
||||||
// but only if the contents has changed (bug 1337392).
|
// but only if the contents has changed (bug 1337392).
|
||||||
if (txtCtrl->ValueChanged()) {
|
if (textControlElement->ValueChanged()) {
|
||||||
nsAutoString val;
|
nsAutoString val;
|
||||||
txtCtrl->GetTextEditorValue(val, true);
|
textControlElement->GetTextEditorValue(val, true);
|
||||||
position = val.Length();
|
position = val.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,14 +407,14 @@ nsresult nsTextControlFrame::CreateAnonymousContent(
|
||||||
|
|
||||||
AddStateBits(NS_FRAME_INDEPENDENT_SELECTION);
|
AddStateBits(NS_FRAME_INDEPENDENT_SELECTION);
|
||||||
|
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
RefPtr<TextControlElement> textControlElement =
|
||||||
MOZ_ASSERT(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
nsresult rv = CreateRootNode();
|
nsresult rv = CreateRootNode();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Bind the frame to its text control
|
// Bind the frame to its text control
|
||||||
rv = txtCtrl->BindToFrame(this);
|
rv = textControlElement->BindToFrame(this);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
aElements.AppendElement(mRootNode);
|
aElements.AppendElement(mRootNode);
|
||||||
|
@ -422,7 +424,7 @@ nsresult nsTextControlFrame::CreateAnonymousContent(
|
||||||
// For textareas, UpdateValueDisplay doesn't initialize the visibility
|
// For textareas, UpdateValueDisplay doesn't initialize the visibility
|
||||||
// status of the placeholder because it returns early, so we have to
|
// status of the placeholder because it returns early, so we have to
|
||||||
// do that manually here.
|
// do that manually here.
|
||||||
txtCtrl->UpdateOverlayTextVisibility(true);
|
textControlElement->UpdateOverlayTextVisibility(true);
|
||||||
}
|
}
|
||||||
aElements.AppendElement(mPlaceholderDiv);
|
aElements.AppendElement(mPlaceholderDiv);
|
||||||
}
|
}
|
||||||
|
@ -446,8 +448,10 @@ bool nsTextControlFrame::ShouldInitializeEagerly() const {
|
||||||
|
|
||||||
// Also, input elements which have a cached selection should get eager
|
// Also, input elements which have a cached selection should get eager
|
||||||
// editor initialization.
|
// editor initialization.
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
if (txtCtrl->HasCachedSelection()) {
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
|
if (textControlElement->HasCachedSelection()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,8 +512,10 @@ void nsTextControlFrame::CreatePlaceholderIfNeeded() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsTextControlFrame::CreatePreviewIfNeeded() {
|
void nsTextControlFrame::CreatePreviewIfNeeded() {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
RefPtr<TextControlElement> textControlElement =
|
||||||
if (!txtCtrl->IsPreviewEnabled()) {
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
|
if (!textControlElement->IsPreviewEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,10 +699,11 @@ bool nsTextControlFrame::IsXULCollapsed() {
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTextControlFrame::ScrollOnFocusEvent::Run() {
|
nsTextControlFrame::ScrollOnFocusEvent::Run() {
|
||||||
if (mFrame) {
|
if (mFrame) {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl =
|
TextControlElement* textControlElement =
|
||||||
do_QueryInterface(mFrame->GetContent());
|
TextControlElement::FromNode(mFrame->GetContent());
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
MOZ_ASSERT(textControlElement);
|
||||||
nsISelectionController* selCon = txtCtrl->GetSelectionController();
|
nsISelectionController* selCon =
|
||||||
|
textControlElement->GetSelectionController();
|
||||||
if (selCon) {
|
if (selCon) {
|
||||||
mFrame->mScrollEvent.Forget();
|
mFrame->mScrollEvent.Forget();
|
||||||
selCon->ScrollSelectionIntoView(
|
selCon->ScrollSelectionIntoView(
|
||||||
|
@ -710,8 +717,9 @@ nsTextControlFrame::ScrollOnFocusEvent::Run() {
|
||||||
|
|
||||||
// IMPLEMENTING NS_IFORMCONTROLFRAME
|
// IMPLEMENTING NS_IFORMCONTROLFRAME
|
||||||
void nsTextControlFrame::SetFocus(bool aOn, bool aRepaint) {
|
void nsTextControlFrame::SetFocus(bool aOn, bool aRepaint) {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
|
|
||||||
// Revoke the previous scroll event if one exists
|
// Revoke the previous scroll event if one exists
|
||||||
mScrollEvent.Revoke();
|
mScrollEvent.Revoke();
|
||||||
|
@ -719,14 +727,14 @@ void nsTextControlFrame::SetFocus(bool aOn, bool aRepaint) {
|
||||||
// If 'dom.placeholeder.show_on_focus' preference is 'false', focusing or
|
// If 'dom.placeholeder.show_on_focus' preference is 'false', focusing or
|
||||||
// blurring the frame can have an impact on the placeholder visibility.
|
// blurring the frame can have an impact on the placeholder visibility.
|
||||||
if (mPlaceholderDiv) {
|
if (mPlaceholderDiv) {
|
||||||
txtCtrl->UpdateOverlayTextVisibility(true);
|
textControlElement->UpdateOverlayTextVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aOn) {
|
if (!aOn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsISelectionController* selCon = txtCtrl->GetSelectionController();
|
nsISelectionController* selCon = textControlElement->GetSelectionController();
|
||||||
if (!selCon) {
|
if (!selCon) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -814,9 +822,10 @@ nsTextControlFrame::GetTextEditor() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
RefPtr<TextControlElement> textControlElement =
|
||||||
MOZ_ASSERT(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
RefPtr<TextEditor> textEditor = txtCtrl->GetTextEditor();
|
MOZ_ASSERT(textControlElement);
|
||||||
|
RefPtr<TextEditor> textEditor = textControlElement->GetTextEditor();
|
||||||
return textEditor.forget();
|
return textEditor.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -840,9 +849,10 @@ nsresult nsTextControlFrame::SetSelectionInternal(
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Get the selection, clear it and add the new range to it!
|
// Get the selection, clear it and add the new range to it!
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
nsISelectionController* selCon = txtCtrl->GetSelectionController();
|
MOZ_ASSERT(textControlElement);
|
||||||
|
nsISelectionController* selCon = textControlElement->GetSelectionController();
|
||||||
NS_ENSURE_TRUE(selCon, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(selCon, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
RefPtr<Selection> selection =
|
RefPtr<Selection> selection =
|
||||||
|
@ -874,9 +884,10 @@ nsresult nsTextControlFrame::SetSelectionInternal(
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsTextControlFrame::ScrollSelectionIntoView() {
|
nsresult nsTextControlFrame::ScrollSelectionIntoView() {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
nsISelectionController* selCon = txtCtrl->GetSelectionController();
|
MOZ_ASSERT(textControlElement);
|
||||||
|
nsISelectionController* selCon = textControlElement->GetSelectionController();
|
||||||
if (selCon) {
|
if (selCon) {
|
||||||
// Scroll the selection into view (see bug 231389).
|
// Scroll the selection into view (see bug 231389).
|
||||||
return selCon->ScrollSelectionIntoView(
|
return selCon->ScrollSelectionIntoView(
|
||||||
|
@ -1035,9 +1046,10 @@ nsresult nsTextControlFrame::OffsetToDOMPoint(uint32_t aOffset,
|
||||||
nsresult nsTextControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
nsresult nsTextControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
||||||
nsAtom* aAttribute,
|
nsAtom* aAttribute,
|
||||||
int32_t aModType) {
|
int32_t aModType) {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
nsISelectionController* selCon = txtCtrl->GetSelectionController();
|
MOZ_ASSERT(textControlElement);
|
||||||
|
nsISelectionController* selCon = textControlElement->GetSelectionController();
|
||||||
const bool needEditor =
|
const bool needEditor =
|
||||||
nsGkAtoms::maxlength == aAttribute || nsGkAtoms::readonly == aAttribute ||
|
nsGkAtoms::maxlength == aAttribute || nsGkAtoms::readonly == aAttribute ||
|
||||||
nsGkAtoms::disabled == aAttribute || nsGkAtoms::spellcheck == aAttribute;
|
nsGkAtoms::disabled == aAttribute || nsGkAtoms::spellcheck == aAttribute;
|
||||||
|
@ -1112,11 +1124,12 @@ nsresult nsTextControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsTextControlFrame::GetText(nsString& aText) {
|
void nsTextControlFrame::GetText(nsString& aText) {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
if (IsSingleLineTextControl()) {
|
if (IsSingleLineTextControl()) {
|
||||||
// There will be no line breaks so we can ignore the wrap property.
|
// There will be no line breaks so we can ignore the wrap property.
|
||||||
txtCtrl->GetTextEditorValue(aText, true);
|
textControlElement->GetTextEditorValue(aText, true);
|
||||||
} else {
|
} else {
|
||||||
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromNode(mContent);
|
HTMLTextAreaElement* textArea = HTMLTextAreaElement::FromNode(mContent);
|
||||||
if (textArea) {
|
if (textArea) {
|
||||||
|
@ -1158,9 +1171,10 @@ void nsTextControlFrame::SetInitialChildList(ChildListID aListID,
|
||||||
if (nsIFrame* first = PrincipalChildList().FirstChild()) {
|
if (nsIFrame* first = PrincipalChildList().FirstChild()) {
|
||||||
first->AddStateBits(NS_FRAME_REFLOW_ROOT);
|
first->AddStateBits(NS_FRAME_REFLOW_ROOT);
|
||||||
|
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
txtCtrl->InitializeKeyboardEventListeners();
|
MOZ_ASSERT(textControlElement);
|
||||||
|
textControlElement->InitializeKeyboardEventListeners();
|
||||||
|
|
||||||
nsPoint* contentScrollPos = GetProperty(ContentScrollPos());
|
nsPoint* contentScrollPos = GetProperty(ContentScrollPos());
|
||||||
if (contentScrollPos) {
|
if (contentScrollPos) {
|
||||||
|
@ -1179,22 +1193,19 @@ void nsTextControlFrame::SetInitialChildList(ChildListID aListID,
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsTextControlFrame::SetValueChanged(bool aValueChanged) {
|
void nsTextControlFrame::SetValueChanged(bool aValueChanged) {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl =
|
TextControlElement* textControlElement =
|
||||||
HTMLInputElement::FromNode(GetContent());
|
TextControlElement::FromNode(GetContent());
|
||||||
if (!txtCtrl) {
|
MOZ_ASSERT(textControlElement);
|
||||||
txtCtrl = HTMLTextAreaElement::FromNode(GetContent());
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(txtCtrl, "Content not a text control element");
|
|
||||||
|
|
||||||
if (mPlaceholderDiv) {
|
if (mPlaceholderDiv) {
|
||||||
AutoWeakFrame weakFrame(this);
|
AutoWeakFrame weakFrame(this);
|
||||||
txtCtrl->UpdateOverlayTextVisibility(true);
|
textControlElement->UpdateOverlayTextVisibility(true);
|
||||||
if (!weakFrame.IsAlive()) {
|
if (!weakFrame.IsAlive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
txtCtrl->SetValueChanged(aValueChanged);
|
textControlElement->SetValueChanged(aValueChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsTextControlFrame::UpdateValueDisplay(bool aNotify,
|
nsresult nsTextControlFrame::UpdateValueDisplay(bool aNotify,
|
||||||
|
@ -1226,15 +1237,16 @@ nsresult nsTextControlFrame::UpdateValueDisplay(bool aNotify,
|
||||||
|
|
||||||
NS_ENSURE_TRUE(textContent, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(textContent, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
MOZ_ASSERT(txtCtrl);
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
|
|
||||||
// Get the current value of the textfield from the content.
|
// Get the current value of the textfield from the content.
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
if (aValue) {
|
if (aValue) {
|
||||||
value = *aValue;
|
value = *aValue;
|
||||||
} else {
|
} else {
|
||||||
txtCtrl->GetTextEditorValue(value, true);
|
textControlElement->GetTextEditorValue(value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the display of the placeholder value and preview text if needed.
|
// Update the display of the placeholder value and preview text if needed.
|
||||||
|
@ -1242,7 +1254,7 @@ nsresult nsTextControlFrame::UpdateValueDisplay(bool aNotify,
|
||||||
// EnsureEditorInitialized takes care of this.
|
// EnsureEditorInitialized takes care of this.
|
||||||
if ((mPlaceholderDiv || mPreviewDiv) && !aBeforeEditorInit) {
|
if ((mPlaceholderDiv || mPreviewDiv) && !aBeforeEditorInit) {
|
||||||
AutoWeakFrame weakFrame(this);
|
AutoWeakFrame weakFrame(this);
|
||||||
txtCtrl->UpdateOverlayTextVisibility(aNotify);
|
textControlElement->UpdateOverlayTextVisibility(aNotify);
|
||||||
NS_ENSURE_STATE(weakFrame.IsAlive());
|
NS_ENSURE_STATE(weakFrame.IsAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,20 +1274,21 @@ nsTextControlFrame::GetOwnedSelectionController(
|
||||||
nsISelectionController** aSelCon) {
|
nsISelectionController** aSelCon) {
|
||||||
NS_ENSURE_ARG_POINTER(aSelCon);
|
NS_ENSURE_ARG_POINTER(aSelCon);
|
||||||
|
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
|
|
||||||
*aSelCon = txtCtrl->GetSelectionController();
|
*aSelCon = textControlElement->GetSelectionController();
|
||||||
NS_IF_ADDREF(*aSelCon);
|
NS_IF_ADDREF(*aSelCon);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsFrameSelection* nsTextControlFrame::GetOwnedFrameSelection() {
|
nsFrameSelection* nsTextControlFrame::GetOwnedFrameSelection() {
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element");
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
return txtCtrl->GetConstFrameSelection();
|
return textControlElement->GetConstFrameSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
UniquePtr<PresState> nsTextControlFrame::SaveState() {
|
UniquePtr<PresState> nsTextControlFrame::SaveState() {
|
||||||
|
@ -1325,8 +1338,9 @@ void nsTextControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||||
*/
|
*/
|
||||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsTextControlFrame");
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsTextControlFrame");
|
||||||
|
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
|
TextControlElement* textControlElement =
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element!");
|
TextControlElement::FromNode(GetContent());
|
||||||
|
MOZ_ASSERT(textControlElement);
|
||||||
|
|
||||||
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
||||||
|
|
||||||
|
@ -1341,9 +1355,9 @@ void nsTextControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||||
// If the frame is the placeholder or preview frame, we should only show
|
// If the frame is the placeholder or preview frame, we should only show
|
||||||
// it if it has to be visible.
|
// it if it has to be visible.
|
||||||
if (!((kid->GetContent() == mPlaceholderDiv &&
|
if (!((kid->GetContent() == mPlaceholderDiv &&
|
||||||
!txtCtrl->GetPlaceholderVisibility()) ||
|
!textControlElement->GetPlaceholderVisibility()) ||
|
||||||
(kid->GetContent() == mPreviewDiv &&
|
(kid->GetContent() == mPreviewDiv &&
|
||||||
!txtCtrl->GetPreviewVisibility()))) {
|
!textControlElement->GetPreviewVisibility()))) {
|
||||||
BuildDisplayListForChild(aBuilder, kid, set, 0);
|
BuildDisplayListForChild(aBuilder, kid, set, 0);
|
||||||
}
|
}
|
||||||
kid = kid->GetNextSibling();
|
kid = kid->GetNextSibling();
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
#define nsTextControlFrame_h___
|
#define nsTextControlFrame_h___
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/TextControlElement.h"
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "nsContainerFrame.h"
|
#include "nsContainerFrame.h"
|
||||||
#include "nsIAnonymousContentCreator.h"
|
#include "nsIAnonymousContentCreator.h"
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsITextControlFrame.h"
|
#include "nsITextControlFrame.h"
|
||||||
#include "nsITextControlElement.h"
|
|
||||||
#include "nsIStatefulFrame.h"
|
#include "nsIStatefulFrame.h"
|
||||||
|
|
||||||
class nsISelectionController;
|
class nsISelectionController;
|
||||||
|
@ -130,7 +130,8 @@ class nsTextControlFrame final : public nsContainerFrame,
|
||||||
|
|
||||||
//==== NSITEXTCONTROLFRAME
|
//==== NSITEXTCONTROLFRAME
|
||||||
|
|
||||||
NS_IMETHOD_(already_AddRefed<mozilla::TextEditor>) GetTextEditor() override;
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHOD_(already_AddRefed<mozilla::TextEditor>)
|
||||||
|
GetTextEditor() override;
|
||||||
NS_IMETHOD SetSelectionRange(uint32_t aSelectionStart, uint32_t aSelectionEnd,
|
NS_IMETHOD SetSelectionRange(uint32_t aSelectionStart, uint32_t aSelectionEnd,
|
||||||
SelectionDirection aDirection = eNone) override;
|
SelectionDirection aDirection = eNone) override;
|
||||||
NS_IMETHOD GetOwnedSelectionController(
|
NS_IMETHOD GetOwnedSelectionController(
|
||||||
|
@ -142,7 +143,8 @@ class nsTextControlFrame final : public nsContainerFrame,
|
||||||
* @throws NS_ERROR_NOT_INITIALIZED if mEditor has not been created
|
* @throws NS_ERROR_NOT_INITIALIZED if mEditor has not been created
|
||||||
* @throws various and sundry other things
|
* @throws various and sundry other things
|
||||||
*/
|
*/
|
||||||
virtual nsresult EnsureEditorInitialized() override;
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual nsresult EnsureEditorInitialized()
|
||||||
|
override;
|
||||||
|
|
||||||
//==== END NSITEXTCONTROLFRAME
|
//==== END NSITEXTCONTROLFRAME
|
||||||
|
|
||||||
|
@ -185,11 +187,11 @@ class nsTextControlFrame final : public nsContainerFrame,
|
||||||
nsresult MaybeBeginSecureKeyboardInput();
|
nsresult MaybeBeginSecureKeyboardInput();
|
||||||
void MaybeEndSecureKeyboardInput();
|
void MaybeEndSecureKeyboardInput();
|
||||||
|
|
||||||
#define DEFINE_TEXTCTRL_CONST_FORWARDER(type, name) \
|
#define DEFINE_TEXTCTRL_CONST_FORWARDER(type, name) \
|
||||||
type name() const { \
|
type name() const { \
|
||||||
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent()); \
|
mozilla::TextControlElement* textControlElement = \
|
||||||
NS_ASSERTION(txtCtrl, "Content not a text control element"); \
|
mozilla::TextControlElement::FromNode(GetContent()); \
|
||||||
return txtCtrl->name(); \
|
return textControlElement->name(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsSingleLineTextControl)
|
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsSingleLineTextControl)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче