зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1784192 - part 10: Make `PendingStyles::GetTypeInState()` return an `enum class` instead of taking 2 bool out parameters r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D155319
This commit is contained in:
Родитель
8bbdf5e967
Коммит
64fe7ed79d
|
@ -8666,10 +8666,9 @@ nsresult HTMLEditor::GetInlineStyles(
|
|||
attribute = nullptr;
|
||||
}
|
||||
// If type-in state is set, don't intervene
|
||||
bool typeInSet, unused;
|
||||
mPendingStylesToApplyToNewContent->GetTypingState(typeInSet, unused, *tag,
|
||||
attribute, nullptr);
|
||||
if (typeInSet) {
|
||||
const PendingStyleState styleState =
|
||||
mPendingStylesToApplyToNewContent->GetStyleState(*tag, attribute);
|
||||
if (styleState != PendingStyleState::NotUpdated) {
|
||||
continue;
|
||||
}
|
||||
bool isSet = false;
|
||||
|
|
|
@ -1769,20 +1769,21 @@ nsresult HTMLEditor::GetInlinePropertyBase(nsStaticAtom& aHTMLProperty,
|
|||
if (NS_WARN_IF(!collapsedNode)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
bool isSet, theSetting;
|
||||
nsString tOutString;
|
||||
if (aAttribute) {
|
||||
mPendingStylesToApplyToNewContent->GetTypingState(
|
||||
isSet, theSetting, aHTMLProperty, aAttribute, &tOutString);
|
||||
if (outValue) {
|
||||
outValue->Assign(tOutString);
|
||||
const PendingStyleState styleState = [&]() {
|
||||
if (aAttribute) {
|
||||
auto state = mPendingStylesToApplyToNewContent->GetStyleState(
|
||||
aHTMLProperty, aAttribute, &tOutString);
|
||||
if (outValue) {
|
||||
outValue->Assign(tOutString);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
} else {
|
||||
mPendingStylesToApplyToNewContent->GetTypingState(isSet, theSetting,
|
||||
aHTMLProperty);
|
||||
}
|
||||
if (isSet) {
|
||||
*aFirst = *aAny = *aAll = theSetting;
|
||||
return mPendingStylesToApplyToNewContent->GetStyleState(aHTMLProperty);
|
||||
}();
|
||||
if (styleState != PendingStyleState::NotUpdated) {
|
||||
*aFirst = *aAny = *aAll =
|
||||
(styleState == PendingStyleState::BeingPreserved);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -396,23 +396,20 @@ int32_t PendingStyles::TakeRelativeFontSize() {
|
|||
return relSize;
|
||||
}
|
||||
|
||||
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;
|
||||
return;
|
||||
PendingStyleState PendingStyles::GetStyleState(
|
||||
nsStaticAtom& aHTMLProperty, nsAtom* aAttribute /* = nullptr */,
|
||||
nsString* aOutNewAttributeValueOrCSSValue /* = nullptr */) const {
|
||||
if (IndexOfPreservingStyle(aHTMLProperty, aAttribute,
|
||||
aOutNewAttributeValueOrCSSValue)
|
||||
.isSome()) {
|
||||
return PendingStyleState::BeingPreserved;
|
||||
}
|
||||
|
||||
if (IsStyleCleared(&aProp, aAttr)) {
|
||||
isSet = true;
|
||||
theSetting = false;
|
||||
return;
|
||||
if (IsStyleCleared(&aHTMLProperty, aAttribute)) {
|
||||
return PendingStyleState::BeingCleared;
|
||||
}
|
||||
|
||||
isSet = false;
|
||||
return PendingStyleState::NotUpdated;
|
||||
}
|
||||
|
||||
void PendingStyles::CancelPreservingStyle(nsStaticAtom* aHTMLProperty,
|
||||
|
|
|
@ -102,6 +102,15 @@ class MOZ_STACK_CLASS AutoPendingStyleCacheArray final
|
|||
}
|
||||
};
|
||||
|
||||
enum class PendingStyleState {
|
||||
// Will be not changed in new content
|
||||
NotUpdated,
|
||||
// Will be applied to new content
|
||||
BeingPreserved,
|
||||
// Will be cleared from new content
|
||||
BeingCleared,
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* 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
|
||||
|
@ -238,8 +247,22 @@ class PendingStyles final {
|
|||
*/
|
||||
int32_t TakeRelativeFontSize();
|
||||
|
||||
void GetTypingState(bool& isSet, bool& theSetting, nsStaticAtom& aProp,
|
||||
nsAtom* aAttr = nullptr, nsString* aOutValue = nullptr);
|
||||
/**
|
||||
* GetStyleState() returns whether the style will be applied to new content,
|
||||
* removed from new content or not changed.
|
||||
*
|
||||
* @param aHTMLProperty The HTML tag name which represents the style.
|
||||
* For example, nsGkAtoms::b for bold text.
|
||||
* @param aAttribute nullptr or attribute name which represents the
|
||||
* style with aHTMLProperty. E.g., nsGkAtoms::size
|
||||
* for nsGkAtoms::font.
|
||||
* @param aOutNewAttributeValueOrCSSValue
|
||||
* [out, optional] If applied to new content, this
|
||||
* is set to the new value.
|
||||
*/
|
||||
PendingStyleState GetStyleState(
|
||||
nsStaticAtom& aHTMLProperty, nsAtom* aAttribute = nullptr,
|
||||
nsString* aOutNewAttributeValueOrCSSValue = nullptr) const;
|
||||
|
||||
protected:
|
||||
virtual ~PendingStyles() { Reset(); };
|
||||
|
|
Загрузка…
Ссылка в новой задаче