Bug 1784192 - part 9: Rename `TypeInState` to `PendingStyles` r=m_kato

Additionally,
* `PropItem` -> `PendingStyle`
* `StyleCache` -> `PendingStyleCache`
* `AutoStyleCacheArray` -> `AutoPendingStyleCacheArray`

And finally, `PendingStyle` (formally `PropItem`) is changed to `class` and
its members are encapsuled.

Differential Revision: https://phabricator.services.mozilla.com/D155318
This commit is contained in:
Masayuki Nakano 2022-08-26 03:31:26 +00:00
Родитель ef559e105f
Коммит 8bbdf5e967
11 изменённых файлов: 238 добавлений и 217 удалений

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

@ -6168,7 +6168,7 @@ EditorBase::AutoEditActionDataSetter::AutoEditActionDataSetter(
->GetSelectedRangeItemForTopLevelEditSubAction();
mTopLevelEditSubActionData.mChangedRange =
mEditorBase.AsHTMLEditor()->GetChangedRangeForTopLevelEditSubAction();
mTopLevelEditSubActionData.mCachedInlineStyles.emplace();
mTopLevelEditSubActionData.mCachedPendingStyles.emplace();
}
}
mEditorBase.mEditActionData = this;

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

@ -15,7 +15,7 @@
#include "mozilla/Likely.h" // for MOZ_UNLIKELY, MOZ_LIKELY
#include "mozilla/Maybe.h" // for Maybe
#include "mozilla/OwningNonNull.h" // for OwningNonNull
#include "mozilla/TypeInState.h" // for PropItem, StyleCache
#include "mozilla/PendingStyles.h" // for PendingStyle, PendingStyleCache
#include "mozilla/RangeBoundary.h" // for RawRangeBoundary, RangeBoundary
#include "mozilla/SelectionState.h" // for RangeUpdater, etc.
#include "mozilla/StyleSheet.h" // for StyleSheet
@ -797,14 +797,14 @@ class EditorBase : public nsIEditor,
// Computing changed range while we're handling sub actions.
RefPtr<nsRange> mChangedRange;
// XXX In strict speaking, mCachedInlineStyles isn't enough to cache inline
// 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.
// 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;
// XXX In strict speaking, mCachedPendingStyles isn't enough to cache
// inline 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.
// FYI: Initialization cost of AutoPendingStyleCacheArray is expensive and
// it is not used by TextEditor so that we should construct it only
// when we're an HTMLEditor.
Maybe<AutoPendingStyleCacheArray> mCachedPendingStyles;
// If we tried to delete selection, set to true.
bool mDidDeleteSelection;
@ -881,8 +881,8 @@ class EditorBase : public nsIEditor,
}
mSelectedRange->Clear();
mChangedRange->Reset();
if (mCachedInlineStyles.isSome()) {
mCachedInlineStyles->Clear();
if (mCachedPendingStyles.isSome()) {
mCachedPendingStyles->Clear();
}
mDidDeleteSelection = false;
mDidDeleteNonCollapsedRange = false;
@ -2891,12 +2891,13 @@ class EditorBase : public nsIEditor,
friend class MoveNodeTransaction; // ToGenericNSResult
friend class ParagraphStateAtSelection; // AutoEditActionDataSetter,
// ToGenericNSResult
friend class PendingStyles; // GetEditAction,
// GetFirstSelectionStartPoint,
// SelectionRef
friend class ReplaceTextTransaction; // AllowsTransactionsToChangeSelection,
// CollapseSelectionTo, DoReplaceText,
// RangeUpdaterRef
friend class SplitNodeTransaction; // ToGenericNSResult
friend class TypeInState; // GetEditAction, GetFirstSelectionStartPoint,
// SelectionRef
friend class WhiteSpaceVisibilityKeeper; // AutoTransactionsConserveSelection
friend class nsIEditor; // mIsHTMLEditorClass

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

@ -41,7 +41,7 @@ enum class EditAction; // mozilla/EditAction.h
enum class EditorCommandParamType : uint16_t; // mozilla/EditorCommands.h
enum class EditSubAction : int32_t; // mozilla/EditAction.h
enum class ParagraphSeparator; // mozilla/HTMLEditor.h
enum class SpecifiedStyle : uint8_t; // mozilla/TypeInState.h
enum class SpecifiedStyle : uint8_t; // mozilla/PendingStyles.h
enum class SuggestCaret; // mozilla/EditorUtils.h
enum class JoinNodesDirection; // HTMLEditHelper.h
@ -71,20 +71,21 @@ using EditorRawDOMPointInText = EditorDOMPointBase<dom::Text*, nsIContent*>;
* classes
******************************************************************************/
class AutoSelectionRangeArray; // mozilla/EditorUtils.h
class AutoStyleCacheArray; // mozilla/TypeInState.h
class ChangeStyleTransaction; // mozilla/ChangeStyleTransaction.h
class CSSEditUtils; // mozilla/CSSEditUtils.h
class EditActionResult; // mozilla/EditorUtils.h
class EditTransactionBase; // mozilla/EditTransactionBase.h
class EditorBase; // mozilla/EditorBase.h
class HTMLEditor; // mozilla/HTMLEditor.h
class ManualNACPtr; // mozilla/ManualNAC.h
class RangeUpdater; // mozilla/SelectionState.h
class SelectionState; // mozilla/SelectionState.h
class StyleCache; // mozilla/TypeInState.h
class TextEditor; // mozilla/TextEditor.h
class TypeInState; // mozilla/TypeInState.h
class AutoPendingStyleCacheArray; // mozilla/PendingStyles.h
class AutoSelectionRangeArray; // mozilla/EditorUtils.h
class ChangeStyleTransaction; // mozilla/ChangeStyleTransaction.h
class CSSEditUtils; // mozilla/CSSEditUtils.h
class EditActionResult; // mozilla/EditorUtils.h
class EditTransactionBase; // mozilla/EditTransactionBase.h
class EditorBase; // mozilla/EditorBase.h
class HTMLEditor; // mozilla/HTMLEditor.h
class ManualNACPtr; // mozilla/ManualNAC.h
class PendingStyle; // mozilla/PendingStyles.h
class PendingStyleCache; // mozilla/PendingStyles.h
class PendingStyles; // mozilla/PendingStyles.h
class RangeUpdater; // mozilla/SelectionState.h
class SelectionState; // mozilla/SelectionState.h
class TextEditor; // mozilla/TextEditor.h
class AutoRangeArray; // AutoRangeArray.h
class ChangeAttributeTransaction; // ChangeAttributeTransaction.h
@ -119,7 +120,6 @@ class WSScanResult; // WSRunObject.h
struct EditorInlineStyle; // HTMLEditHelpers.h
struct EditorInlineStyleAndValue; // HTMLEditHelpers.h
struct PropItem; // mozilla/TypeInState.h
struct RangeItem; // mozilla/SelectionState.h
/******************************************************************************

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

@ -16,7 +16,7 @@
#include "EditorUtils.h"
#include "HTMLEditHelpers.h"
#include "HTMLEditUtils.h"
#include "TypeInState.h" // for SpecifiedStyle
#include "PendingStyles.h" // for SpecifiedStyle
#include "WSRunObject.h"
#include "mozilla/Assertions.h"
@ -86,7 +86,8 @@ using WalkTreeOption = HTMLEditUtils::WalkTreeOption;
* first some helpful functors we will use
********************************************************/
static bool IsStyleCachePreservingSubAction(EditSubAction aEditSubAction) {
static bool IsPendingStyleCachePreservingSubAction(
EditSubAction aEditSubAction) {
switch (aEditSubAction) {
case EditSubAction::eDeleteSelectedContent:
case EditSubAction::eInsertLineBreak:
@ -220,7 +221,7 @@ void HTMLEditor::OnStartToHandleTopLevelEditSubAction(
break;
default:
cacheInlineStyles =
IsStyleCachePreservingSubAction(aTopLevelEditSubAction);
IsPendingStyleCachePreservingSubAction(aTopLevelEditSubAction);
break;
}
if (cacheInlineStyles) {
@ -598,7 +599,7 @@ nsresult HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal() {
break;
default:
reapplyCachedStyle =
IsStyleCachePreservingSubAction(GetTopLevelEditSubAction());
IsPendingStyleCachePreservingSubAction(GetTopLevelEditSubAction());
break;
}
@ -632,14 +633,16 @@ nsresult HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal() {
// But the cached inline styles should be restored from type-in-state later.
if (reapplyCachedStyle) {
DebugOnly<nsresult> rvIgnored = mTypeInState->UpdateSelState(*this);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
"TypeInState::UpdateSelState() failed, but ignored");
DebugOnly<nsresult> rvIgnored =
mPendingStylesToApplyToNewContent->UpdateSelState(*this);
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rvIgnored),
"PendingStyles::UpdateSelState() failed, but ignored");
rvIgnored = ReapplyCachedStyles();
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rvIgnored),
"HTMLEditor::ReapplyCachedStyles() failed, but ignored");
TopLevelEditSubActionDataRef().mCachedInlineStyles->Clear();
TopLevelEditSubActionDataRef().mCachedPendingStyles->Clear();
}
}
@ -947,8 +950,8 @@ nsresult HTMLEditor::PrepareInlineStylesForCaret() {
}
// For most actions we want to clear the cached styles, but there are
// exceptions
if (!IsStyleCachePreservingSubAction(GetTopLevelEditSubAction())) {
TopLevelEditSubActionDataRef().mCachedInlineStyles->Clear();
if (!IsPendingStyleCachePreservingSubAction(GetTopLevelEditSubAction())) {
TopLevelEditSubActionDataRef().mCachedPendingStyles->Clear();
}
return NS_OK;
}
@ -5770,7 +5773,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::CreateStyleForInsertText(
const EditorDOMPoint& aPointToInsertText) {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(aPointToInsertText.IsSetAndValid());
MOZ_ASSERT(mTypeInState);
MOZ_ASSERT(mPendingStylesToApplyToNewContent);
const RefPtr<Element> documentRootElement = GetDocument()->GetRootElement();
if (NS_WARN_IF(!documentRootElement)) {
@ -5778,33 +5781,37 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::CreateStyleForInsertText(
}
// process clearing any styles first
UniquePtr<PropItem> style = mTypeInState->TakeClearingStyle();
UniquePtr<PendingStyle> pendingStyle =
mPendingStylesToApplyToNewContent->TakeClearingStyle();
EditorDOMPoint pointToPutCaret(aPointToInsertText);
{
// Transactions may set selection, but we will set selection if necessary.
AutoTransactionsConserveSelection dontChangeMySelection(*this);
while (style && pointToPutCaret.GetContainer() != documentRootElement) {
// MOZ_KnownLive because we own `style` which guarantees the lifetime of
// its members.
Result<EditorDOMPoint, nsresult> pointToPutCaretOrError = ClearStyleAt(
pointToPutCaret, MOZ_KnownLive(style->mTag),
MOZ_KnownLive(style->mAttribute), style->mSpecifiedStyle);
while (pendingStyle &&
pointToPutCaret.GetContainer() != documentRootElement) {
// MOZ_KnownLive because we own pendingStyle which guarantees the lifetime
// of its members.
Result<EditorDOMPoint, nsresult> pointToPutCaretOrError =
ClearStyleAt(pointToPutCaret, MOZ_KnownLive(pendingStyle->GetTag()),
MOZ_KnownLive(pendingStyle->GetAttribute()),
pendingStyle->GetSpecifiedStyle());
if (MOZ_UNLIKELY(pointToPutCaretOrError.isErr())) {
NS_WARNING("HTMLEditor::ClearStyleAt() failed");
return pointToPutCaretOrError;
}
pointToPutCaret = pointToPutCaretOrError.unwrap();
style = mTypeInState->TakeClearingStyle();
pendingStyle = mPendingStylesToApplyToNewContent->TakeClearingStyle();
}
}
// then process setting any styles
const int32_t relFontSize = mTypeInState->TakeRelativeFontSize();
style = mTypeInState->TakePreservedStyle();
const int32_t relFontSize =
mPendingStylesToApplyToNewContent->TakeRelativeFontSize();
pendingStyle = mPendingStylesToApplyToNewContent->TakePreservedStyle();
if (style || relFontSize) {
if (pendingStyle || relFontSize) {
// we have at least one style to add; make a new text node to insert style
// nodes above.
EditorDOMPoint pointToInsertTextNode(pointToPutCaret);
@ -5864,15 +5871,16 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::CreateStyleForInsertText(
}
}
while (style) {
while (pendingStyle) {
// MOZ_KnownLive(...ContainerAs<nsIContent>()) because pointToPutCaret()
// grabs the result.
// MOZ_KnownLive(style->*) because we own `style` which guarantees the
// lifetime of its members.
// MOZ_KnownLive(pendingStyle->*) because we own pendingStyle which
// guarantees the lifetime of its members.
Result<EditorDOMPoint, nsresult> setStyleResult = SetInlinePropertyOnNode(
MOZ_KnownLive(*pointToPutCaret.ContainerAs<nsIContent>()),
MOZ_KnownLive(*style->mTag), MOZ_KnownLive(style->mAttribute),
style->mAttributeValueOrCSSValue);
MOZ_KnownLive(*pendingStyle->GetTag()),
MOZ_KnownLive(pendingStyle->GetAttribute()),
pendingStyle->AttributeValueOrCSSValueRef());
if (MOZ_UNLIKELY(setStyleResult.isErr())) {
NS_WARNING("HTMLEditor::SetInlinePropertyOnNode() failed");
return Err(setStyleResult.unwrapErr());
@ -5880,7 +5888,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::CreateStyleForInsertText(
// We don't need to update here because we'll suggest caret position which
// is computed above.
MOZ_ASSERT(pointToPutCaret.IsSet());
style = mTypeInState->TakePreservedStyle();
pendingStyle = mPendingStylesToApplyToNewContent->TakePreservedStyle();
}
}
@ -7101,8 +7109,8 @@ SplitNodeResult HTMLEditor::HandleInsertParagraphInHeadingElement(
return SplitNodeResult(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE);
}
TopLevelEditSubActionDataRef().mCachedInlineStyles->Clear();
mTypeInState->ClearAllStyles();
TopLevelEditSubActionDataRef().mCachedPendingStyles->Clear();
mPendingStylesToApplyToNewContent->ClearAllStyles();
// Create a paragraph if the right heading element is not followed by an
// editable <br> element.
@ -8614,16 +8622,16 @@ nsresult HTMLEditor::CacheInlineStyles(nsIContent& aContent) {
MOZ_ASSERT(IsTopLevelEditSubActionDataAvailable());
nsresult rv = GetInlineStyles(
aContent, *TopLevelEditSubActionDataRef().mCachedInlineStyles);
aContent, *TopLevelEditSubActionDataRef().mCachedPendingStyles);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"HTMLEditor::GetInlineStyles() failed");
return rv;
}
nsresult HTMLEditor::GetInlineStyles(nsIContent& aContent,
AutoStyleCacheArray& aStyleCacheArray) {
nsresult HTMLEditor::GetInlineStyles(
nsIContent& aContent, AutoPendingStyleCacheArray& aPendingStyleCacheArray) {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(aStyleCacheArray.IsEmpty());
MOZ_ASSERT(aPendingStyleCacheArray.IsEmpty());
bool useCSS = IsCSSEnabled();
@ -8659,13 +8667,14 @@ nsresult HTMLEditor::GetInlineStyles(nsIContent& aContent,
}
// If type-in state is set, don't intervene
bool typeInSet, unused;
mTypeInState->GetTypingState(typeInSet, unused, *tag, attribute, nullptr);
mPendingStylesToApplyToNewContent->GetTypingState(typeInSet, unused, *tag,
attribute, nullptr);
if (typeInSet) {
continue;
}
bool isSet = false;
nsString value; // Don't use nsAutoString here because it requires memcpy
// at creating new StyleCache instance.
// at creating new PendingStyleCache instance.
// Don't use CSS for <font size>, we don't support it usefully (bug 780035)
if (!useCSS || (property == nsGkAtoms::size)) {
isSet = HTMLEditUtils::IsInlineStyleSetByElement(
@ -8682,7 +8691,8 @@ nsresult HTMLEditor::GetInlineStyles(nsIContent& aContent,
isSet = isComputedCSSEquivalentToHTMLInlineStyleOrError.unwrap();
}
if (isSet) {
aStyleCacheArray.AppendElement(StyleCache(*tag, attribute, value));
aPendingStyleCacheArray.AppendElement(
PendingStyleCache(*tag, attribute, value));
}
}
return NS_OK;
@ -8695,7 +8705,7 @@ nsresult HTMLEditor::ReapplyCachedStyles() {
// been removed. If so, add typeinstate for them, so that they will be
// reinserted when new content is added.
if (TopLevelEditSubActionDataRef().mCachedInlineStyles->IsEmpty() ||
if (TopLevelEditSubActionDataRef().mCachedPendingStyles->IsEmpty() ||
!SelectionRef().RangeCount()) {
return NS_OK;
}
@ -8714,7 +8724,7 @@ nsresult HTMLEditor::ReapplyCachedStyles() {
return NS_OK;
}
AutoStyleCacheArray styleCacheArrayAtInsertionPoint;
AutoPendingStyleCacheArray styleCacheArrayAtInsertionPoint;
nsresult rv =
GetInlineStyles(*startContainerContent, styleCacheArrayAtInsertionPoint);
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
@ -8725,8 +8735,8 @@ nsresult HTMLEditor::ReapplyCachedStyles() {
return NS_OK;
}
for (StyleCache& styleCacheBeforeEdit :
*TopLevelEditSubActionDataRef().mCachedInlineStyles) {
for (PendingStyleCache& styleCacheBeforeEdit :
*TopLevelEditSubActionDataRef().mCachedPendingStyles) {
bool isFirst = false, isAny = false, isAll = false;
nsAutoString currentValue;
if (useCSS) {
@ -8761,18 +8771,20 @@ nsresult HTMLEditor::ReapplyCachedStyles() {
}
}
// This style has disappeared through deletion. Let's add the styles to
// mTypeInState when same style isn't applied to the node already.
if (isAny && !IsStyleCachePreservingSubAction(GetTopLevelEditSubAction())) {
// mPendingStylesToApplyToNewContent when same style isn't applied to the
// node already.
if (isAny &&
!IsPendingStyleCachePreservingSubAction(GetTopLevelEditSubAction())) {
continue;
}
AutoStyleCacheArray::index_type index =
AutoPendingStyleCacheArray::index_type index =
styleCacheArrayAtInsertionPoint.IndexOf(
styleCacheBeforeEdit.TagRef(), styleCacheBeforeEdit.GetAttribute());
if (index == AutoStyleCacheArray::NoIndex ||
if (index == AutoPendingStyleCacheArray::NoIndex ||
styleCacheBeforeEdit.AttributeValueOrCSSValueRef() !=
styleCacheArrayAtInsertionPoint.ElementAt(index)
.AttributeValueOrCSSValueRef()) {
mTypeInState->PreserveStyle(styleCacheBeforeEdit);
mPendingStylesToApplyToNewContent->PreserveStyle(styleCacheBeforeEdit);
}
}
return NS_OK;

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

@ -15,9 +15,9 @@
#include "InsertNodeTransaction.h"
#include "JoinNodesTransaction.h"
#include "MoveNodeTransaction.h"
#include "PendingStyles.h"
#include "ReplaceTextTransaction.h"
#include "SplitNodeTransaction.h"
#include "TypeInState.h"
#include "WSRunObject.h"
#include "mozilla/ComposerCommandsUpdater.h"
@ -227,7 +227,7 @@ HTMLEditor::~HTMLEditor() {
: 0);
}
mTypeInState = nullptr;
mPendingStylesToApplyToNewContent = nullptr;
if (mDisabledLinkHandling) {
if (Document* doc = GetDocument()) {
@ -243,7 +243,7 @@ HTMLEditor::~HTMLEditor() {
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLEditor)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLEditor, EditorBase)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTypeInState)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingStylesToApplyToNewContent)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mComposerCommandsUpdater)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChangedRangeForTopLevelEditSubAction)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPaddingBRElementForEmptyEditor)
@ -251,7 +251,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLEditor, EditorBase)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLEditor, EditorBase)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTypeInState)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingStylesToApplyToNewContent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mComposerCommandsUpdater)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChangedRangeForTopLevelEditSubAction)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPaddingBRElementForEmptyEditor)
@ -349,7 +349,7 @@ nsresult HTMLEditor::Init(Document& aDocument,
}
// init the type-in state
mTypeInState = new TypeInState();
mPendingStylesToApplyToNewContent = new PendingStyles();
if (!IsInteractionAllowed()) {
nsCOMPtr<nsIURI> uaURI;
@ -592,14 +592,14 @@ NS_IMETHODIMP HTMLEditor::NotifySelectionChanged(Document* aDocument,
return NS_ERROR_NOT_INITIALIZED;
}
if (mTypeInState) {
RefPtr<TypeInState> typeInState = mTypeInState;
typeInState->OnSelectionChange(*this, aReason);
if (mPendingStylesToApplyToNewContent) {
RefPtr<PendingStyles> pendingStyles = mPendingStylesToApplyToNewContent;
pendingStyles->OnSelectionChange(*this, aReason);
// We used a class which derived from nsISelectionListener to call
// HTMLEditor::RefreshEditingUI(). The lifetime of the class was
// exactly same as mTypeInState. So, call it only when mTypeInState
// is not nullptr.
// exactly same as mPendingStylesToApplyToNewContent. So, call it only when
// mPendingStylesToApplyToNewContent is not nullptr.
if ((aReason & (nsISelectionListener::MOUSEDOWN_REASON |
nsISelectionListener::KEYPRESS_REASON |
nsISelectionListener::SELECTALL_REASON)) &&
@ -1030,31 +1030,32 @@ void HTMLEditor::StopPreservingSelection() {
}
void HTMLEditor::PreHandleMouseDown(const MouseEvent& aMouseDownEvent) {
if (mTypeInState) {
// mTypeInState will be notified of selection change even if aMouseDownEvent
// is not an acceptable event for this editor. Therefore, we need to notify
// it of this event too.
mTypeInState->PreHandleMouseEvent(aMouseDownEvent);
if (mPendingStylesToApplyToNewContent) {
// mPendingStylesToApplyToNewContent will be notified of selection change
// even if aMouseDownEvent is not an acceptable event for this editor.
// Therefore, we need to notify it of this event too.
mPendingStylesToApplyToNewContent->PreHandleMouseEvent(aMouseDownEvent);
}
}
void HTMLEditor::PreHandleMouseUp(const MouseEvent& aMouseUpEvent) {
if (mTypeInState) {
// mTypeInState will be notified of selection change even if aMouseUpEvent
// is not an acceptable event for this editor. Therefore, we need to notify
// it of this event too.
mTypeInState->PreHandleMouseEvent(aMouseUpEvent);
if (mPendingStylesToApplyToNewContent) {
// mPendingStylesToApplyToNewContent will be notified of selection change
// even if aMouseUpEvent is not an acceptable event for this editor.
// Therefore, we need to notify it of this event too.
mPendingStylesToApplyToNewContent->PreHandleMouseEvent(aMouseUpEvent);
}
}
void HTMLEditor::PreHandleSelectionChangeCommand(Command aCommand) {
if (mTypeInState) {
mTypeInState->PreHandleSelectionChangeCommand(aCommand);
if (mPendingStylesToApplyToNewContent) {
mPendingStylesToApplyToNewContent->PreHandleSelectionChangeCommand(
aCommand);
}
}
void HTMLEditor::PostHandleSelectionChangeCommand(Command aCommand) {
if (!mTypeInState) {
if (!mPendingStylesToApplyToNewContent) {
return;
}
@ -1062,7 +1063,8 @@ void HTMLEditor::PostHandleSelectionChangeCommand(Command aCommand) {
if (!editActionData.CanHandle()) {
return;
}
mTypeInState->PostHandleSelectionChangeCommand(*this, aCommand);
mPendingStylesToApplyToNewContent->PostHandleSelectionChangeCommand(*this,
aCommand);
}
nsresult HTMLEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent) {

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

@ -1052,8 +1052,8 @@ class HTMLEditor final : public EditorBase,
/**
* PrepareInlineStylesForCaret() consider inline styles from top level edit
* sub-action and setting it to `mTypeInState` and clear inline style cache
* if necessary.
* sub-action and setting it to `mPendingStylesToApplyToNewContent` and clear
* inline style cache if necessary.
* NOTE: This method should be called only when `Selection` is collapsed.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult PrepareInlineStylesForCaret();
@ -1069,14 +1069,15 @@ class HTMLEditor final : public EditorBase,
/**
* GetInlineStyles() retrieves the style of aNode and modifies each item of
* aStyleCacheArray. This might cause flushing layout at retrieving computed
* values of CSS properties.
* aPendingStyleCacheArray. This might cause flushing layout at retrieving
* computed values of CSS properties.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
GetInlineStyles(nsIContent& aContent, AutoStyleCacheArray& aStyleCacheArray);
GetInlineStyles(nsIContent& aContent,
AutoPendingStyleCacheArray& aPendingStyleCacheArray);
/**
* CacheInlineStyles() caches style of aContent into mCachedInlineStyles of
* CacheInlineStyles() caches style of aContent into mCachedPendingStyles of
* TopLevelEditSubAction. This may cause flushing layout at retrieving
* computed value of CSS properties.
*/
@ -1092,7 +1093,7 @@ class HTMLEditor final : public EditorBase,
/**
* CreateStyleForInsertText() sets CSS properties which are stored in
* TypeInState to proper element node.
* PendingStyles to proper element node.
*
* @param aPointToInsertText The point to insert text.
* @return A suggest point to put caret or unset point.
@ -3298,9 +3299,9 @@ class HTMLEditor final : public EditorBase,
Document& aDocument, const nsACString& aCharacterSet);
/**
* SetInlinePropertiesAsSubAction() stores new styles with mTypeInState if
* `Selection` is collapsed. Otherwise, applying the styles to all selected
* contents.
* SetInlinePropertiesAsSubAction() stores new styles with
* mPendingStylesToApplyToNewContent if `Selection` is collapsed. Otherwise,
* applying the styles to all selected contents.
*
* @param aStylesToSet The styles which should be applied to the
* selected content.
@ -3311,7 +3312,8 @@ class HTMLEditor final : public EditorBase,
/**
* RemoveInlinePropertiesAsSubAction() removes specified styles from
* mTypeInState if `Selection` is collapsed. Otherwise, removing the style.
* mPendingStylesToApplyToNewContent if `Selection` is collapsed. Otherwise,
* removing the style.
*
* @param aStylesToRemove Styles to remove from the selected contents.
*/
@ -4432,7 +4434,7 @@ class HTMLEditor final : public EditorBase,
const char* const mRequesterFuncName;
};
RefPtr<TypeInState> mTypeInState;
RefPtr<PendingStyles> mPendingStylesToApplyToNewContent;
RefPtr<ComposerCommandsUpdater> mComposerCommandsUpdater;
// Used by TopLevelEditSubActionData::mSelectedRange.

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

@ -14,8 +14,8 @@
#include "HTMLEditHelpers.h"
#include "HTMLEditUtils.h"
#include "InternetCiter.h"
#include "PendingStyles.h"
#include "SelectionState.h"
#include "TypeInState.h"
#include "WSRunObject.h"
#include "mozilla/dom/Comment.h"

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

@ -11,8 +11,8 @@
#include "EditorUtils.h"
#include "HTMLEditHelpers.h"
#include "HTMLEditUtils.h"
#include "PendingStyles.h"
#include "SelectionState.h"
#include "TypeInState.h"
#include "mozilla/Assertions.h"
#include "mozilla/ContentIterator.h"
@ -205,7 +205,7 @@ nsresult HTMLEditor::SetInlinePropertiesAsSubAction(
if (SelectionRef().IsCollapsed()) {
// Manipulating text attributes on a collapsed selection only sets state
// for the next text insertion
mTypeInState->PreserveStyles(aStylesToSet);
mPendingStylesToApplyToNewContent->PreserveStyles(aStylesToSet);
return NS_OK;
}
@ -1772,13 +1772,14 @@ nsresult HTMLEditor::GetInlinePropertyBase(nsStaticAtom& aHTMLProperty,
bool isSet, theSetting;
nsString tOutString;
if (aAttribute) {
mTypeInState->GetTypingState(isSet, theSetting, aHTMLProperty,
aAttribute, &tOutString);
mPendingStylesToApplyToNewContent->GetTypingState(
isSet, theSetting, aHTMLProperty, aAttribute, &tOutString);
if (outValue) {
outValue->Assign(tOutString);
}
} else {
mTypeInState->GetTypingState(isSet, theSetting, aHTMLProperty);
mPendingStylesToApplyToNewContent->GetTypingState(isSet, theSetting,
aHTMLProperty);
}
if (isSet) {
*aFirst = *aAny = *aAll = theSetting;
@ -2175,7 +2176,7 @@ nsresult HTMLEditor::RemoveInlinePropertiesAsSubAction(
if (SelectionRef().IsCollapsed()) {
// Manipulating text attributes on a collapsed selection only sets state
// for the next text insertion
mTypeInState->ClearStyles(aStylesToRemove);
mPendingStylesToApplyToNewContent->ClearStyles(aStylesToRemove);
return NS_OK;
}
@ -2637,7 +2638,8 @@ nsresult HTMLEditor::IncrementOrDecrementFontSizeAsSubAction(
// Manipulating text attributes on a collapsed selection only sets state
// for the next text insertion
mTypeInState->PreserveStyle(bigOrSmallTagName, nullptr, u""_ns);
mPendingStylesToApplyToNewContent->PreserveStyle(bigOrSmallTagName, nullptr,
u""_ns);
return NS_OK;
}

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

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "TypeInState.h"
#include "PendingStyles.h"
#include <stddef.h>
@ -32,38 +32,23 @@ namespace mozilla {
using namespace dom;
/********************************************************************
* mozilla::TypeInState
* mozilla::PendingStyles
*******************************************************************/
NS_IMPL_CYCLE_COLLECTION_CLASS(TypeInState)
NS_IMPL_CYCLE_COLLECTION_CLASS(PendingStyles)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(TypeInState)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(PendingStyles)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLastSelectionPoint)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TypeInState)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(PendingStyles)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLastSelectionPoint)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(TypeInState, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(TypeInState, Release)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PendingStyles, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PendingStyles, Release)
TypeInState::TypeInState()
: mRelativeFontSize(0),
mLastSelectionCommand(Command::DoNothing),
mMouseDownFiredInLinkElement(false),
mMouseUpFiredInLinkElement(false) {
Reset();
}
TypeInState::~TypeInState() {
// Call Reset() to release any data that may be in
// mClearingStyles and mPreservingStyles.
Reset();
}
nsresult TypeInState::UpdateSelState(const HTMLEditor& aHTMLEditor) {
nsresult PendingStyles::UpdateSelState(const HTMLEditor& aHTMLEditor) {
if (!aHTMLEditor.SelectionRef().IsCollapsed()) {
return NS_OK;
}
@ -79,7 +64,7 @@ nsresult TypeInState::UpdateSelState(const HTMLEditor& aHTMLEditor) {
return NS_OK;
}
void TypeInState::PreHandleMouseEvent(const MouseEvent& aMouseDownOrUpEvent) {
void PendingStyles::PreHandleMouseEvent(const MouseEvent& aMouseDownOrUpEvent) {
MOZ_ASSERT(aMouseDownOrUpEvent.WidgetEventPtr()->mMessage == eMouseDown ||
aMouseDownOrUpEvent.WidgetEventPtr()->mMessage == eMouseUp);
bool& eventFiredInLinkElement =
@ -104,11 +89,11 @@ void TypeInState::PreHandleMouseEvent(const MouseEvent& aMouseDownOrUpEvent) {
HTMLEditUtils::IsContentInclusiveDescendantOfLink(*targetContent);
}
void TypeInState::PreHandleSelectionChangeCommand(Command aCommand) {
void PendingStyles::PreHandleSelectionChangeCommand(Command aCommand) {
mLastSelectionCommand = aCommand;
}
void TypeInState::PostHandleSelectionChangeCommand(
void PendingStyles::PostHandleSelectionChangeCommand(
const HTMLEditor& aHTMLEditor, Command aCommand) {
if (mLastSelectionCommand != aCommand) {
return;
@ -149,8 +134,8 @@ void TypeInState::PostHandleSelectionChangeCommand(
ClearLinkAndItsSpecifiedStyle();
}
void TypeInState::OnSelectionChange(const HTMLEditor& aHTMLEditor,
int16_t aReason) {
void PendingStyles::OnSelectionChange(const HTMLEditor& aHTMLEditor,
int16_t aReason) {
// XXX: Selection currently generates bogus selection changed notifications
// XXX: (bug 140303). It can notify us when the selection hasn't actually
// XXX: changed, and it notifies us more than once for the same change.
@ -337,12 +322,7 @@ void TypeInState::OnSelectionChange(const HTMLEditor& aHTMLEditor,
CancelClearingStyle(*nsGkAtoms::a, nullptr);
}
void TypeInState::Reset() {
mClearingStyles.Clear();
mPreservingStyles.Clear();
}
void TypeInState::PreserveStyles(
void PendingStyles::PreserveStyles(
const nsTArray<EditorInlineStyleAndValue>& aStylesToPreserve) {
for (const EditorInlineStyleAndValue& styleToPreserve : aStylesToPreserve) {
PreserveStyle(styleToPreserve.HTMLPropertyRef(), styleToPreserve.mAttribute,
@ -350,8 +330,9 @@ void TypeInState::PreserveStyles(
}
}
void TypeInState::PreserveStyle(nsStaticAtom& aHTMLProperty, nsAtom* aAttribute,
const nsAString& aAttributeValueOrCSSValue) {
void PendingStyles::PreserveStyle(nsStaticAtom& aHTMLProperty,
nsAtom* aAttribute,
const nsAString& aAttributeValueOrCSSValue) {
// special case for big/small, these nest
if (nsGkAtoms::big == &aHTMLProperty) {
mRelativeFontSize++;
@ -365,18 +346,18 @@ void TypeInState::PreserveStyle(nsStaticAtom& aHTMLProperty, nsAtom* aAttribute,
Maybe<size_t> index = IndexOfPreservingStyle(aHTMLProperty, aAttribute);
if (index.isSome()) {
// If it's already set, update the value
mPreservingStyles[index.value()]->mAttributeValueOrCSSValue =
aAttributeValueOrCSSValue;
mPreservingStyles[index.value()]->UpdateAttributeValueOrCSSValue(
aAttributeValueOrCSSValue);
return;
}
mPreservingStyles.AppendElement(MakeUnique<PropItem>(
mPreservingStyles.AppendElement(MakeUnique<PendingStyle>(
&aHTMLProperty, aAttribute, aAttributeValueOrCSSValue));
CancelClearingStyle(aHTMLProperty, aAttribute);
}
void TypeInState::ClearStyles(
void PendingStyles::ClearStyles(
const nsTArray<EditorInlineStyle>& aStylesToClear) {
for (const EditorInlineStyle& styleToClear : aStylesToClear) {
if (styleToClear.IsStyleToClearAllInlineStyles()) {
@ -392,7 +373,7 @@ void TypeInState::ClearStyles(
}
}
void TypeInState::ClearStyleInternal(
void PendingStyles::ClearStyleInternal(
nsStaticAtom* aHTMLProperty, nsAtom* aAttribute,
SpecifiedStyle aSpecifiedStyle /* = SpecifiedStyle::Preserve */) {
if (IsStyleCleared(aHTMLProperty, aAttribute)) {
@ -401,24 +382,24 @@ void TypeInState::ClearStyleInternal(
CancelPreservingStyle(aHTMLProperty, aAttribute);
mClearingStyles.AppendElement(
MakeUnique<PropItem>(aHTMLProperty, aAttribute, u""_ns, aSpecifiedStyle));
mClearingStyles.AppendElement(MakeUnique<PendingStyle>(
aHTMLProperty, aAttribute, u""_ns, aSpecifiedStyle));
}
/**
* TakeRelativeFontSize() hands back relative font value, which is then
* cleared out.
*/
int32_t TypeInState::TakeRelativeFontSize() {
int32_t PendingStyles::TakeRelativeFontSize() {
int32_t relSize = mRelativeFontSize;
mRelativeFontSize = 0;
return relSize;
}
void TypeInState::GetTypingState(bool& isSet, bool& theSetting,
nsStaticAtom& aProp,
nsAtom* aAttr /* = nullptr */,
nsString* aOutValue /* = nullptr */) {
void PendingStyles::GetTypingState(bool& isSet, bool& theSetting,
nsStaticAtom& aProp,
nsAtom* aAttr /* = nullptr */,
nsString* aOutValue /* = nullptr */) {
if (IndexOfPreservingStyle(aProp, aAttr, aOutValue).isSome()) {
isSet = true;
theSetting = true;
@ -434,8 +415,8 @@ void TypeInState::GetTypingState(bool& isSet, bool& theSetting,
isSet = false;
}
void TypeInState::CancelPreservingStyle(nsStaticAtom* aHTMLProperty,
nsAtom* aAttribute) {
void PendingStyles::CancelPreservingStyle(nsStaticAtom* aHTMLProperty,
nsAtom* aAttribute) {
if (!aHTMLProperty) {
mPreservingStyles.Clear();
mRelativeFontSize = 0;
@ -447,8 +428,8 @@ void TypeInState::CancelPreservingStyle(nsStaticAtom* aHTMLProperty,
}
}
void TypeInState::CancelClearingStyle(nsStaticAtom& aHTMLProperty,
nsAtom* aAttribute) {
void PendingStyles::CancelClearingStyle(nsStaticAtom& aHTMLProperty,
nsAtom* aAttribute) {
Maybe<size_t> index =
IndexOfStyleInArray(&aHTMLProperty, aAttribute, nullptr, mClearingStyles);
if (index.isSome()) {
@ -456,17 +437,17 @@ void TypeInState::CancelClearingStyle(nsStaticAtom& aHTMLProperty,
}
}
Maybe<size_t> TypeInState::IndexOfStyleInArray(
Maybe<size_t> PendingStyles::IndexOfStyleInArray(
nsStaticAtom* aHTMLProperty, nsAtom* aAttribute, nsAString* aOutValue,
const nsTArray<UniquePtr<PropItem>>& aArray) {
const nsTArray<UniquePtr<PendingStyle>>& aArray) {
if (aAttribute == nsGkAtoms::_empty) {
aAttribute = nullptr;
}
for (size_t i : IntegerRange(aArray.Length())) {
const UniquePtr<PropItem>& item = aArray[i];
if (item->mTag == aHTMLProperty && item->mAttribute == aAttribute) {
const UniquePtr<PendingStyle>& item = aArray[i];
if (item->GetTag() == aHTMLProperty && item->GetAttribute() == aAttribute) {
if (aOutValue) {
*aOutValue = item->mAttributeValueOrCSSValue;
*aOutValue = item->AttributeValueOrCSSValueRef();
}
return Some(i);
}

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

@ -3,8 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_TypeInState_h
#define mozilla_TypeInState_h
#ifndef mozilla_PendingStyles_h
#define mozilla_PendingStyles_h
#include "mozilla/EditorDOMPoint.h"
#include "mozilla/EditorForwards.h"
@ -30,7 +30,30 @@ class Selection;
enum class SpecifiedStyle : uint8_t { Preserve, Discard };
struct PropItem {
class PendingStyle final {
public:
PendingStyle() = delete;
PendingStyle(nsStaticAtom* aTag, nsAtom* aAttribute, const nsAString& aValue,
SpecifiedStyle aSpecifiedStyle = SpecifiedStyle::Preserve)
: mTag(aTag),
mAttribute(aAttribute != nsGkAtoms::_empty ? aAttribute : nullptr),
mAttributeValueOrCSSValue(aValue),
mSpecifiedStyle(aSpecifiedStyle) {
MOZ_COUNT_CTOR(PendingStyle);
}
MOZ_COUNTED_DTOR(PendingStyle)
MOZ_KNOWN_LIVE nsStaticAtom* GetTag() const { return mTag; }
MOZ_KNOWN_LIVE nsAtom* GetAttribute() const { return mAttribute; }
const nsString& AttributeValueOrCSSValueRef() const {
return mAttributeValueOrCSSValue;
}
void UpdateAttributeValueOrCSSValue(const nsAString& aNewValue) {
mAttributeValueOrCSSValue = aNewValue;
}
SpecifiedStyle GetSpecifiedStyle() const { return mSpecifiedStyle; }
private:
MOZ_KNOWN_LIVE nsStaticAtom* const mTag = nullptr;
// TODO: Once we stop using `HTMLEditor::SetInlinePropertiesAsSubAction` to
// add any attributes of <a href>, we can make this `nsStaticAtom*`.
@ -42,24 +65,13 @@ struct PropItem {
nsString mAttributeValueOrCSSValue;
// Whether the class and style attribute should be preserved or discarded.
const SpecifiedStyle mSpecifiedStyle = SpecifiedStyle::Preserve;
PropItem() = delete;
PropItem(nsStaticAtom* aTag, nsAtom* aAttribute, const nsAString& aValue,
SpecifiedStyle aSpecifiedStyle = SpecifiedStyle::Preserve)
: mTag(aTag),
mAttribute(aAttribute != nsGkAtoms::_empty ? aAttribute : nullptr),
mAttributeValueOrCSSValue(aValue),
mSpecifiedStyle(aSpecifiedStyle) {
MOZ_COUNT_CTOR(PropItem);
}
MOZ_COUNTED_DTOR(PropItem)
};
class StyleCache final {
class PendingStyleCache final {
public:
StyleCache() = delete;
StyleCache(nsStaticAtom& aTag, nsStaticAtom* aAttribute,
const nsAString& aValue)
PendingStyleCache() = delete;
PendingStyleCache(nsStaticAtom& aTag, nsStaticAtom* aAttribute,
const nsAString& aValue)
: mTag(aTag), mAttribute(aAttribute), mAttributeValueOrCSSValue(aValue) {}
MOZ_KNOWN_LIVE nsStaticAtom& TagRef() const { return mTag; }
@ -74,13 +86,13 @@ class StyleCache final {
const nsString mAttributeValueOrCSSValue;
};
class MOZ_STACK_CLASS AutoStyleCacheArray final
: public AutoTArray<StyleCache, 21> {
class MOZ_STACK_CLASS AutoPendingStyleCacheArray final
: public AutoTArray<PendingStyleCache, 21> {
public:
index_type IndexOf(const nsStaticAtom& aTag,
const nsStaticAtom* aAttribute) const {
for (index_type index = 0; index < Length(); ++index) {
const StyleCache& styleCache = ElementAt(index);
const PendingStyleCache& styleCache = ElementAt(index);
if (&styleCache.TagRef() == &aTag &&
styleCache.GetAttribute() == aAttribute) {
return index;
@ -90,13 +102,22 @@ class MOZ_STACK_CLASS AutoStyleCacheArray final
}
};
class TypeInState final {
/******************************************************************************
* PendingStyles stores pending inline styles which WILL be applied to new
* content when it'll be inserted. I.e., updating styles of this class means
* that it does NOT update the DOM tree immediately.
******************************************************************************/
class PendingStyles final {
public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TypeInState)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(TypeInState)
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PendingStyles)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(PendingStyles)
TypeInState();
void Reset();
PendingStyles() = default;
void Reset() {
mClearingStyles.Clear();
mPreservingStyles.Clear();
}
nsresult UpdateSelState(const HTMLEditor& aHTMLEditor);
@ -143,7 +164,7 @@ class TypeInState final {
* Preserve the style with new value specified with aStyleToPreserve.
* See above for the detail.
*/
void PreserveStyle(const StyleCache& aStyleToPreserve) {
void PreserveStyle(const PendingStyleCache& aStyleToPreserve) {
PreserveStyle(aStyleToPreserve.TagRef(), aStyleToPreserve.GetAttribute(),
aStyleToPreserve.AttributeValueOrCSSValueRef());
}
@ -192,7 +213,7 @@ class TypeInState final {
* This must be used only for handling to clear the styles from inserting
* content.
*/
UniquePtr<PropItem> TakeClearingStyle() {
UniquePtr<PendingStyle> TakeClearingStyle() {
if (mClearingStyles.IsEmpty()) {
return nullptr;
}
@ -204,7 +225,7 @@ class TypeInState final {
* styles. This should be used only for handling setting new style for
* inserted content.
*/
UniquePtr<PropItem> TakePreservedStyle() {
UniquePtr<PendingStyle> TakePreservedStyle() {
if (mPreservingStyles.IsEmpty()) {
return nullptr;
}
@ -221,7 +242,7 @@ class TypeInState final {
nsAtom* aAttr = nullptr, nsString* aOutValue = nullptr);
protected:
virtual ~TypeInState();
virtual ~PendingStyles() { Reset(); };
void ClearStyleInternal(
nsStaticAtom* aHTMLProperty, nsAtom* aAttribute,
@ -263,17 +284,17 @@ class TypeInState final {
static Maybe<size_t> IndexOfStyleInArray(
nsStaticAtom* aHTMLProperty, nsAtom* aAttribute, nsAString* aOutValue,
const nsTArray<UniquePtr<PropItem>>& aArray);
const nsTArray<UniquePtr<PendingStyle>>& aArray);
nsTArray<UniquePtr<PropItem>> mPreservingStyles;
nsTArray<UniquePtr<PropItem>> mClearingStyles;
nsTArray<UniquePtr<PendingStyle>> mPreservingStyles;
nsTArray<UniquePtr<PendingStyle>> mClearingStyles;
EditorDOMPoint mLastSelectionPoint;
int32_t mRelativeFontSize;
Command mLastSelectionCommand;
bool mMouseDownFiredInLinkElement;
bool mMouseUpFiredInLinkElement;
int32_t mRelativeFontSize = 0;
Command mLastSelectionCommand = Command::DoNothing;
bool mMouseDownFiredInLinkElement = false;
bool mMouseUpFiredInLinkElement = false;
};
} // namespace mozilla
#endif // #ifndef mozilla_TypeInState_h
#endif // #ifndef mozilla_PendingStyles_h

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

@ -29,9 +29,9 @@ EXPORTS.mozilla += [
"HTMLEditorController.h",
"HTMLEditUtils.h",
"ManualNAC.h",
"PendingStyles.h",
"SelectionState.h",
"TextEditor.h",
"TypeInState.h",
]
UNIFIED_SOURCES += [
@ -72,6 +72,7 @@ UNIFIED_SOURCES += [
"InternetCiter.cpp",
"JoinNodesTransaction.cpp",
"MoveNodeTransaction.cpp",
"PendingStyles.cpp",
"PlaceholderTransaction.cpp",
"ReplaceTextTransaction.cpp",
"SelectionState.cpp",
@ -79,7 +80,6 @@ UNIFIED_SOURCES += [
"TextEditor.cpp",
"TextEditorDataTransfer.cpp",
"TextEditSubActionHandler.cpp",
"TypeInState.cpp",
"WSRunObject.cpp",
]