mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1598327 - part 2: Make TopLevelEditSubActionData::mCachedInlineStyle
create only in HTMLEditor
r=m_kato
The initialization cost of `AutoStyleCacheArray` is still expensive and it's used only by `HTMLEditor`. Therefore, we should make it `Maybe` and construct it only when the editor is an `HTMLEditor`. Depends on D54253 Differential Revision: https://phabricator.services.mozilla.com/D54254 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
1ecc9bd28e
commit
f846ab4ab6
@ -5491,6 +5491,7 @@ EditorBase::AutoEditActionDataSetter::AutoEditActionDataSetter(
|
||||
->GetSelectedRangeItemForTopLevelEditSubAction();
|
||||
mTopLevelEditSubActionData.mChangedRange =
|
||||
mEditorBase.AsHTMLEditor()->GetChangedRangeForTopLevelEditSubAction();
|
||||
mTopLevelEditSubActionData.mCachedInlineStyles.emplace();
|
||||
}
|
||||
}
|
||||
mEditorBase.mEditActionData = this;
|
||||
|
@ -630,7 +630,10 @@ class EditorBase : public nsIEditor,
|
||||
// styles because inline style can be specified with "style" attribute
|
||||
// and/or CSS in <style> elements or CSS files. So, we need to look
|
||||
// for better implementation about this.
|
||||
AutoStyleCacheArray mCachedInlineStyles;
|
||||
// FYI: Initialization cost of AutoStyleCacheArray is expensive and it is
|
||||
// not used by TextEditor so that we should construct it only when
|
||||
// we're an HTMLEditor.
|
||||
Maybe<AutoStyleCacheArray> mCachedInlineStyles;
|
||||
|
||||
// If we tried to delete selection, set to true.
|
||||
bool mDidDeleteSelection;
|
||||
@ -698,7 +701,9 @@ class EditorBase : public nsIEditor,
|
||||
mNewBlockElement = nullptr;
|
||||
mSelectedRange->Clear();
|
||||
mChangedRange->Reset();
|
||||
mCachedInlineStyles.Clear();
|
||||
if (mCachedInlineStyles.isSome()) {
|
||||
mCachedInlineStyles->Clear();
|
||||
}
|
||||
mDidDeleteSelection = false;
|
||||
mDidDeleteNonCollapsedRange = false;
|
||||
mDidDeleteEmptyParentBlocks = false;
|
||||
|
@ -641,7 +641,7 @@ nsresult HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal() {
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles.Clear();
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1292,7 +1292,7 @@ nsresult HTMLEditor::PrepareInlineStylesForCaret() {
|
||||
// For most actions we want to clear the cached styles, but there are
|
||||
// exceptions
|
||||
if (!IsStyleCachePreservingSubAction(GetTopLevelEditSubAction())) {
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles.Clear();
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles->Clear();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -8153,7 +8153,7 @@ nsresult HTMLEditor::HandleInsertParagraphInHeadingElement(Element& aHeader,
|
||||
sibling = GetNextHTMLSibling(aHeader.GetNextSibling());
|
||||
}
|
||||
if (!sibling || !sibling->IsHTMLElement(nsGkAtoms::br)) {
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles.Clear();
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles->Clear();
|
||||
mTypeInState->ClearAllProps();
|
||||
|
||||
// Create a paragraph
|
||||
@ -9367,7 +9367,7 @@ nsresult HTMLEditor::CacheInlineStyles(nsINode& aNode) {
|
||||
MOZ_ASSERT(IsTopLevelEditSubActionDataAvailable());
|
||||
|
||||
nsresult rv = GetInlineStyles(
|
||||
aNode, TopLevelEditSubActionDataRef().mCachedInlineStyles);
|
||||
aNode, *TopLevelEditSubActionDataRef().mCachedInlineStyles);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "GetInlineStyles() failed");
|
||||
return rv;
|
||||
}
|
||||
@ -9446,7 +9446,7 @@ nsresult HTMLEditor::ReapplyCachedStyles() {
|
||||
for (size_t i = 0; i < styleCacheArrayAtInsertionPoint.Length(); ++i) {
|
||||
StyleCache& styleCacheAtInsertionPoint = styleCacheArrayAtInsertionPoint[i];
|
||||
StyleCache& styleCacheBeforeEdit =
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles[i];
|
||||
TopLevelEditSubActionDataRef().mCachedInlineStyles->ElementAt(i);
|
||||
if (styleCacheBeforeEdit.mPresent) {
|
||||
bool bFirst, bAny, bAll;
|
||||
bFirst = bAny = bAll = false;
|
||||
|
Loading…
Reference in New Issue
Block a user