Bug 1295370 - Stop lazily creating the root node in nsTextEditorState::GetRootFrame. r=ehsan

AFAICT this doesn't change behavior, since all the callers of GetRootNode should
occur after we've already called BindToFrame. However, it makes it easier for
future static analysis to see that we don't trigger node creation from
nsTextControlFrame::AppendAnonymousContentTo.
This commit is contained in:
Bobby Holley 2016-08-15 16:29:05 -07:00
parent 31b4bcc859
commit c2cbbe5f56
2 changed files with 6 additions and 6 deletions

View File

@ -1157,9 +1157,11 @@ nsTextEditorState::BindToFrame(nsTextControlFrame* aFrame)
mBoundFrame = aFrame;
nsIContent *rootNode = GetRootNode();
nsresult rv = CreateRootNode();
NS_ENSURE_SUCCESS(rv, rv);
nsresult rv = InitializeRootNode();
nsIContent *rootNode = GetRootNode();
rv = InitializeRootNode();
NS_ENSURE_SUCCESS(rv, rv);
nsIPresShell *shell = mBoundFrame->PresContext()->GetPresShell();
@ -1753,8 +1755,8 @@ nsTextEditorState::UnbindFromFrame(nsTextControlFrame* aFrame)
nsresult
nsTextEditorState::CreateRootNode()
{
NS_ENSURE_TRUE(!mRootNode, NS_ERROR_UNEXPECTED);
NS_ENSURE_ARG_POINTER(mBoundFrame);
MOZ_ASSERT(!mRootNode);
MOZ_ASSERT(mBoundFrame);
nsIPresShell *shell = mBoundFrame->PresContext()->GetPresShell();
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);

View File

@ -163,8 +163,6 @@ public:
nsresult CreatePlaceholderNode();
mozilla::dom::Element* GetRootNode() {
if (!mRootNode)
CreateRootNode();
return mRootNode;
}
mozilla::dom::Element* GetPlaceholderNode() {