зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1611713 - Remove TextControlState::GetParentNumberControl. r=masayuki
Can't return anything useful anymore since bug 981248. Differential Revision: https://phabricator.services.mozilla.com/D61091 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f97d7df528
Коммит
cbd110d718
|
@ -964,7 +964,6 @@ HTMLInputElement::HTMLInputElement(
|
|||
mNumberControlSpinnerIsSpinning(false),
|
||||
mNumberControlSpinnerSpinsUp(false),
|
||||
mPickerRunning(false),
|
||||
mSelectionCached(true),
|
||||
mIsPreviewEnabled(false),
|
||||
mHasBeenTypePassword(false),
|
||||
mHasPatternAttribute(false) {
|
||||
|
|
|
@ -303,23 +303,6 @@ class HTMLInputElement final : public TextControlElement,
|
|||
|
||||
void MaybeLoadImage();
|
||||
|
||||
void SetSelectionCached() {
|
||||
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
||||
mSelectionCached = true;
|
||||
}
|
||||
bool IsSelectionCached() const {
|
||||
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
||||
return mSelectionCached;
|
||||
}
|
||||
void ClearSelectionCached() {
|
||||
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
||||
mSelectionCached = false;
|
||||
}
|
||||
TextControlState::SelectionProperties& GetSelectionProperties() {
|
||||
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
||||
return mSelectionProperties;
|
||||
}
|
||||
|
||||
bool HasPatternAttribute() const { return mHasPatternAttribute; }
|
||||
|
||||
// nsIConstraintValidation
|
||||
|
@ -1496,13 +1479,6 @@ class HTMLInputElement final : public TextControlElement,
|
|||
*/
|
||||
nsAutoPtr<DateTimeValue> mDateTimeInputBoxValue;
|
||||
|
||||
/**
|
||||
* The selection properties cache for number controls. This is needed because
|
||||
* the number controls don't recycle their text field, so the normal cache in
|
||||
* TextControlState cannot do its job.
|
||||
*/
|
||||
TextControlState::SelectionProperties mSelectionProperties;
|
||||
|
||||
/**
|
||||
* The triggering principal for the src attribute.
|
||||
*/
|
||||
|
@ -1572,7 +1548,6 @@ class HTMLInputElement final : public TextControlElement,
|
|||
bool mNumberControlSpinnerIsSpinning : 1;
|
||||
bool mNumberControlSpinnerSpinsUp : 1;
|
||||
bool mPickerRunning : 1;
|
||||
bool mSelectionCached : 1;
|
||||
bool mIsPreviewEnabled : 1;
|
||||
bool mHasBeenTypePassword : 1;
|
||||
bool mHasPatternAttribute : 1;
|
||||
|
|
|
@ -1949,8 +1949,7 @@ nsresult TextControlState::PrepareEditor(const nsAString* aValue) {
|
|||
}
|
||||
|
||||
// Restore our selection after being bound to a new frame
|
||||
HTMLInputElement* number = GetParentNumberControl(mBoundFrame);
|
||||
if (number ? number->IsSelectionCached() : mSelectionCached) {
|
||||
if (mSelectionCached) {
|
||||
if (mRestoringSelection) { // paranoia
|
||||
mRestoringSelection->Revoke();
|
||||
}
|
||||
|
@ -1967,11 +1966,7 @@ nsresult TextControlState::PrepareEditor(const nsAString* aValue) {
|
|||
// happens before our RestoreSelectionState runs, it looks like we'll lose our
|
||||
// selection info, because we will think we don't have it cached and try to
|
||||
// read it from the selection controller, which will not have it yet.
|
||||
if (number) {
|
||||
number->ClearSelectionCached();
|
||||
} else {
|
||||
mSelectionCached = false;
|
||||
}
|
||||
mSelectionCached = false;
|
||||
|
||||
return preparingEditor.IsTextControlStateDestroyed()
|
||||
? NS_ERROR_NOT_INITIALIZED
|
||||
|
@ -1982,27 +1977,6 @@ void TextControlState::FinishedRestoringSelection() {
|
|||
mRestoringSelection = nullptr;
|
||||
}
|
||||
|
||||
bool TextControlState::IsSelectionCached() const {
|
||||
if (mBoundFrame) {
|
||||
HTMLInputElement* number = GetParentNumberControl(mBoundFrame);
|
||||
if (number) {
|
||||
return number->IsSelectionCached();
|
||||
}
|
||||
}
|
||||
return mSelectionCached;
|
||||
}
|
||||
|
||||
TextControlState::SelectionProperties&
|
||||
TextControlState::GetSelectionProperties() {
|
||||
if (mBoundFrame) {
|
||||
HTMLInputElement* number = GetParentNumberControl(mBoundFrame);
|
||||
if (number) {
|
||||
return number->GetSelectionProperties();
|
||||
}
|
||||
}
|
||||
return mSelectionProperties;
|
||||
}
|
||||
|
||||
void TextControlState::SyncUpSelectionPropertiesBeforeDestruction() {
|
||||
if (mBoundFrame) {
|
||||
UnbindFromFrame(mBoundFrame);
|
||||
|
@ -2370,31 +2344,6 @@ void TextControlState::SetRangeText(const nsAString& aReplacement,
|
|||
// The instance may have already been deleted here.
|
||||
}
|
||||
|
||||
HTMLInputElement* TextControlState::GetParentNumberControl(
|
||||
nsFrame* aFrame) const {
|
||||
MOZ_ASSERT(aFrame);
|
||||
nsIContent* content = aFrame->GetContent();
|
||||
MOZ_ASSERT(content);
|
||||
nsIContent* parent = content->GetParent();
|
||||
if (!parent) {
|
||||
return nullptr;
|
||||
}
|
||||
nsIContent* parentOfParent = parent->GetParent();
|
||||
if (!parentOfParent) {
|
||||
return nullptr;
|
||||
}
|
||||
HTMLInputElement* input = HTMLInputElement::FromNode(parentOfParent);
|
||||
if (!input) {
|
||||
return nullptr;
|
||||
}
|
||||
// This function might be called during frame reconstruction as a result
|
||||
// of changing the input control's type from number to something else. In
|
||||
// that situation, the type of the control has changed, but its frame has
|
||||
// not been reconstructed yet. So we need to check the type of the input
|
||||
// control in addition to the type of the frame.
|
||||
return (input->ControlType() == NS_FORM_INPUT_NUMBER) ? input : nullptr;
|
||||
}
|
||||
|
||||
void TextControlState::DestroyEditor() {
|
||||
// notify the editor that we are going away
|
||||
if (mEditorInitialized) {
|
||||
|
@ -2449,15 +2398,7 @@ void TextControlState::UnbindFromFrame(nsTextControlFrame* aFrame) {
|
|||
props.SetStart(start);
|
||||
props.SetEnd(end);
|
||||
props.SetDirection(direction);
|
||||
HTMLInputElement* number = GetParentNumberControl(aFrame);
|
||||
if (number) {
|
||||
// If we are inside a number control, cache the selection on the
|
||||
// parent control, because this text editor state will be destroyed
|
||||
// together with the native anonymous text control.
|
||||
number->SetSelectionCached();
|
||||
} else {
|
||||
mSelectionCached = true;
|
||||
}
|
||||
mSelectionCached = true;
|
||||
}
|
||||
|
||||
// Destroy our editor
|
||||
|
|
|
@ -320,8 +320,8 @@ class TextControlState final : public SupportsWeakPtr<TextControlState> {
|
|||
nsITextControlFrame::SelectionDirection mDirection;
|
||||
};
|
||||
|
||||
bool IsSelectionCached() const;
|
||||
SelectionProperties& GetSelectionProperties();
|
||||
bool IsSelectionCached() const { return mSelectionCached; }
|
||||
SelectionProperties& GetSelectionProperties() { return mSelectionProperties; }
|
||||
MOZ_CAN_RUN_SCRIPT void SetSelectionProperties(SelectionProperties& aProps);
|
||||
void WillInitEagerly() { mSelectionRestoreEagerInit = true; }
|
||||
bool HasNeverInitializedBefore() const { return !mEverInited; }
|
||||
|
@ -422,8 +422,6 @@ class TextControlState final : public SupportsWeakPtr<TextControlState> {
|
|||
|
||||
void FinishedRestoringSelection();
|
||||
|
||||
HTMLInputElement* GetParentNumberControl(nsFrame* aFrame) const;
|
||||
|
||||
bool EditorHasComposition();
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче