Bug 1637335 - Make MozEditableElement.editor flush frames if needed. r=smaug

URLBarInput relies on it being non-null when created, but that may not
happen if we construct frames lazily without this patch.

Differential Revision: https://phabricator.services.mozilla.com/D74891
This commit is contained in:
Emilio Cobos Álvarez 2020-05-12 22:32:18 +00:00
Родитель 2646aa4245
Коммит 92acdc30e3
6 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -2240,7 +2240,13 @@ void HTMLInputElement::SetUserInput(const nsAString& aValue,
}
}
nsIEditor* HTMLInputElement::GetEditor() { return GetTextEditorFromState(); }
nsIEditor* HTMLInputElement::GetEditorForBindings() {
if (!GetPrimaryFrame()) {
// Ensure we construct frames (and thus an editor) if needed.
GetPrimaryFrame(FlushType::Frames);
}
return GetTextEditorFromState();
}
bool HTMLInputElement::HasEditor() { return !!GetTextEditorWithoutCreation(); }

Просмотреть файл

@ -808,10 +808,8 @@ class HTMLInputElement final : public TextControlElement,
bool MozIsTextField(bool aExcludePassword);
/**
* GetEditor() and HasEditor() for webidl bindings.
*/
MOZ_CAN_RUN_SCRIPT nsIEditor* GetEditor();
MOZ_CAN_RUN_SCRIPT nsIEditor* GetEditorForBindings();
// For WebIDL bindings.
bool HasEditor();
bool IsInputEventTarget() const { return IsSingleLineTextControl(false); }

Просмотреть файл

@ -214,6 +214,13 @@ bool HTMLTextAreaElement::ValueEquals(const nsAString& aValue) const {
return mState->ValueEquals(aValue);
}
nsIEditor* HTMLTextAreaElement::GetEditorForBindings() {
if (!GetPrimaryFrame()) {
GetPrimaryFrame(FlushType::Frames);
}
return GetTextEditor();
}
TextEditor* HTMLTextAreaElement::GetTextEditor() {
MOZ_ASSERT(mState);
return mState->GetTextEditor();

Просмотреть файл

@ -271,10 +271,7 @@ class HTMLTextAreaElement final : public TextControlElement,
// XPCOM adapter function widely used throughout code, leaving it as is.
nsresult GetControllers(nsIControllers** aResult);
MOZ_CAN_RUN_SCRIPT nsIEditor* GetEditor() {
MOZ_ASSERT(mState);
return mState->GetTextEditor();
}
MOZ_CAN_RUN_SCRIPT nsIEditor* GetEditorForBindings();
bool HasEditor() {
MOZ_ASSERT(mState);
return !!mState->GetTextEditorWithoutCreation();

Просмотреть файл

@ -188,7 +188,7 @@ interface mixin MozEditableElement {
// Returns an nsIEditor instance which is associated with the element.
// If the element can be associated with an editor but not yet created,
// this creates new one automatically.
[Pure, ChromeOnly]
[Pure, ChromeOnly, BinaryName="editorForBindings"]
readonly attribute nsIEditor? editor;
// Returns true if an nsIEditor instance has already been associated with

Просмотреть файл

@ -537,10 +537,10 @@ nsresult nsTypeAheadFind::FindItNow(uint32_t aMode, bool aIsLinksOnly,
nsCOMPtr<nsIEditor> editor;
if (RefPtr<HTMLInputElement> input =
HTMLInputElement::FromNode(node)) {
editor = input->GetEditor();
editor = input->GetTextEditor();
} else if (RefPtr<HTMLTextAreaElement> textarea =
HTMLTextAreaElement::FromNode(node)) {
editor = textarea->GetEditor();
editor = textarea->GetTextEditor();
} else {
node = node->GetParentNode();
continue;