From 5649e1881391488eff61824056ccafe0f49ce533 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 28 Feb 2017 12:41:37 -0500 Subject: [PATCH] Bug 1342197 part 2. Use nsITextControlElement::GetRootEditorNode to get the root editor node in nsTextControlFrame::GetSelectionRange. r=ehsan MozReview-Commit-ID: 7ncJVNVGF78 --- layout/forms/nsTextControlFrame.cpp | 11 +---------- layout/forms/nsTextControlFrame.h | 8 ++++++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index cee4bbc5cb08..9ce80e74c3e0 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -803,15 +803,6 @@ nsTextControlFrame::ScrollSelectionIntoView() return NS_ERROR_FAILURE; } -mozilla::dom::Element* -nsTextControlFrame::GetRootNodeAndInitializeEditor() -{ - nsCOMPtr root; - GetRootNodeAndInitializeEditor(getter_AddRefs(root)); - nsCOMPtr rootElem = do_QueryInterface(root); - return rootElem; -} - nsresult nsTextControlFrame::GetRootNodeAndInitializeEditor(nsIDOMElement **aRootElement) { @@ -1062,7 +1053,7 @@ nsTextControlFrame::GetSelectionRange(int32_t* aSelectionStart, return NS_OK; } - mozilla::dom::Element* root = GetRootNodeAndInitializeEditor(); + mozilla::dom::Element* root = txtCtrl->GetRootEditorNode(); NS_ENSURE_STATE(root); nsContentUtils::GetSelectionInTextControl(sel, root, *aSelectionStart, *aSelectionEnd); diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index 9d4d0b77c914..175e37cc715b 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -321,9 +321,13 @@ private: SelectionDirection aDirection = eNone); /** - * Return the root DOM element, and implicitly initialize the editor if needed. + * Return the root DOM element, and implicitly initialize the editor if + * needed. + * + * XXXbz This function is slow. Very slow. Consider using + * EnsureEditorInitialized() if you need that, and + * nsITextControlElement::GetRootEditorNode on our content if you need that. */ - mozilla::dom::Element* GetRootNodeAndInitializeEditor(); nsresult GetRootNodeAndInitializeEditor(nsIDOMElement **aRootElement); void FinishedInitializer() {