Bug 1395146 - part1: Get rid of nsITextControlElement::IsPlainTextControl() and nsTextEditorState::IsPlainTextEditor() r?smaug
nsTextEditorState::GetValue() refers nsITextControlElement::IsPlainTextControl()
via nsTextEditorState::IsPlainTextEditor(). However, it always returns true and
virtual call with QI. So, we should get rid of these unnecessary methods.
MozReview-Commit-ID: 3gHdGrzlys4
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -7398,23 +7398,16 @@ HTMLInputElement::IsSingleLineTextContro
NS_IMETHODIMP_(bool)
HTMLInputElement::IsTextArea() const
{
return false;
}
NS_IMETHODIMP_(bool)
-HTMLInputElement::IsPlainTextControl() const
-{
- // need to check our HTML attribute and/or CSS.
- return true;
-}
-
-NS_IMETHODIMP_(bool)
HTMLInputElement::IsPasswordTextControl() const
{
return mType == NS_FORM_INPUT_PASSWORD;
}
NS_IMETHODIMP_(int32_t)
HTMLInputElement::GetCols()
{
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -228,17 +228,16 @@ private:
virtual void RemoveStates(EventStates aStates) override;
public:
// nsITextControlElement
NS_IMETHOD SetValueChanged(bool aValueChanged) override;
NS_IMETHOD_(bool) IsSingleLineTextControl() const override;
NS_IMETHOD_(bool) IsTextArea() const override;
- NS_IMETHOD_(bool) IsPlainTextControl() const override;
NS_IMETHOD_(bool) IsPasswordTextControl() const override;
NS_IMETHOD_(int32_t) GetCols() override;
NS_IMETHOD_(int32_t) GetWrapCols() override;
NS_IMETHOD_(int32_t) GetRows() override;
NS_IMETHOD_(void) GetDefaultValueFromContent(nsAString& aValue) override;
NS_IMETHOD_(bool) ValueChanged() const override;
NS_IMETHOD_(void) GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const override;
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditor() override;
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -1326,23 +1326,16 @@ HTMLTextAreaElement::IsSingleLineTextCon
NS_IMETHODIMP_(bool)
HTMLTextAreaElement::IsTextArea() const
{
return true;
}
NS_IMETHODIMP_(bool)
-HTMLTextAreaElement::IsPlainTextControl() const
-{
- // need to check our HTML attribute and/or CSS.
- return true;
-}
-
-NS_IMETHODIMP_(bool)
HTMLTextAreaElement::IsPasswordTextControl() const
{
return false;
}
NS_IMETHODIMP_(int32_t)
HTMLTextAreaElement::GetCols()
{
--- a/dom/html/HTMLTextAreaElement.h
+++ b/dom/html/HTMLTextAreaElement.h
@@ -84,17 +84,16 @@ public:
virtual void FieldSetDisabledChanged(bool aNotify) override;
virtual EventStates IntrinsicState() const override;
// nsITextControlElemet
NS_IMETHOD SetValueChanged(bool aValueChanged) override;
NS_IMETHOD_(bool) IsSingleLineTextControl() const override;
NS_IMETHOD_(bool) IsTextArea() const override;
- NS_IMETHOD_(bool) IsPlainTextControl() const override;
NS_IMETHOD_(bool) IsPasswordTextControl() const override;
NS_IMETHOD_(int32_t) GetCols() override;
NS_IMETHOD_(int32_t) GetWrapCols() override;
NS_IMETHOD_(int32_t) GetRows() override;
NS_IMETHOD_(void) GetDefaultValueFromContent(nsAString& aValue) override;
NS_IMETHOD_(bool) ValueChanged() const override;
NS_IMETHOD_(void) GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const override;
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditor() override;
--- a/dom/html/nsITextControlElement.h
+++ b/dom/html/nsITextControlElement.h
@@ -52,22 +52,16 @@ public:
/**
* Find out whether this control is a textarea.
* @return whether this is a textarea text control
*/
NS_IMETHOD_(bool) IsTextArea() const = 0;
/**
- * Find out whether this control edits plain text. (Currently always true.)
- * @return whether this is a plain text control
- */
- NS_IMETHOD_(bool) IsPlainTextControl() const = 0;
-
- /**
* Find out whether this is a password control (input type=password)
* @return whether this is a password ontrol
*/
NS_IMETHOD_(bool) IsPasswordTextControl() const = 0;
/**
* Get the cols attribute (if textarea) or a default
* @return the number of columns to use
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -1415,19 +1415,17 @@ nsTextEditorState::PrepareEditor(const n
// Note that we don't check mTextEditor here, because we might already have
// one around, in which case we don't create a new one, and we'll just tie
// the required machinery to it.
nsPresContext *presContext = mBoundFrame->PresContext();
nsIPresShell *shell = presContext->GetPresShell();
// Setup the editor flags
- uint32_t editorFlags = 0;
- if (IsPlainTextControl())
- editorFlags |= nsIPlaintextEditor::eEditorPlaintextMask;
+ uint32_t editorFlags = nsIPlaintextEditor::eEditorPlaintextMask;
if (IsSingleLineTextControl())
editorFlags |= nsIPlaintextEditor::eEditorSingleLineMask;
if (IsPasswordTextControl())
editorFlags |= nsIPlaintextEditor::eEditorPasswordMask;
// All nsTextControlFrames are widgets
editorFlags |= nsIPlaintextEditor::eEditorWidgetMask;
@@ -2442,23 +2440,18 @@ nsTextEditorState::GetValue(nsAString& a
aValue = mCachedValue;
return;
}
aValue.Truncate(); // initialize out param
uint32_t flags = (nsIDocumentEncoder::OutputLFLineBreak |
nsIDocumentEncoder::OutputPreformatted |
- nsIDocumentEncoder::OutputPersistNBSP);
-
- if (IsPlainTextControl())
- {
- flags |= nsIDocumentEncoder::OutputBodyOnly;
- }
-
+ nsIDocumentEncoder::OutputPersistNBSP |
+ nsIDocumentEncoder::OutputBodyOnly);
if (!aIgnoreWrap) {
nsITextControlElement::nsHTMLTextWrap wrapProp;
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
if (content &&
nsITextControlElement::GetWrapPropertyEnum(content, wrapProp) &&
wrapProp == nsITextControlElement::eHTMLTextWrap_Hard) {
flags |= nsIDocumentEncoder::OutputWrap;
}
--- a/dom/html/nsTextEditorState.h
+++ b/dom/html/nsTextEditorState.h
@@ -215,19 +215,16 @@ public:
}
bool IsSingleLineTextControl() const {
return mTextCtrlElement->IsSingleLineTextControl();
}
bool IsTextArea() const {
return mTextCtrlElement->IsTextArea();
}
- bool IsPlainTextControl() const {
- return mTextCtrlElement->IsPlainTextControl();
- }
bool IsPasswordTextControl() const {
return mTextCtrlElement->IsPasswordTextControl();
}
int32_t GetCols() {
return mTextCtrlElement->GetCols();
}
int32_t GetWrapCols() {
return mTextCtrlElement->GetWrapCols();
--- a/layout/forms/nsTextControlFrame.h
+++ b/layout/forms/nsTextControlFrame.h
@@ -201,17 +201,16 @@ public: //for methods who access nsTextC
type name() const { \
nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent()); \
NS_ASSERTION(txtCtrl, "Content not a text control element"); \
return txtCtrl->name(); \
}
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsSingleLineTextControl)
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsTextArea)
- DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsPlainTextControl)
DEFINE_TEXTCTRL_CONST_FORWARDER(bool, IsPasswordTextControl)
DEFINE_TEXTCTRL_CONST_FORWARDER(int32_t, GetCols)
DEFINE_TEXTCTRL_CONST_FORWARDER(int32_t, GetWrapCols)
DEFINE_TEXTCTRL_CONST_FORWARDER(int32_t, GetRows)
#undef DEFINE_TEXTCTRL_CONST_FORWARDER
#undef DEFINE_TEXTCTRL_FORWARDER