зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1584170: part 1) Factor out duplicated code to `IsInOlOrUl`. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D48320 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4170fd9b5c
Коммит
1f69cf48a9
|
@ -743,12 +743,12 @@ nsresult nsPlainTextSerializer::DoOpenContainer(const nsAtom* aTag) {
|
|||
}
|
||||
} else if (aTag == nsGkAtoms::ul) {
|
||||
// Indent here to support nested lists, which aren't included in li :-(
|
||||
EnsureVerticalSpace(mULCount + mOLStackIndex == 0 ? 1 : 0);
|
||||
EnsureVerticalSpace(IsInOlOrUl() ? 0 : 1);
|
||||
// Must end the current line before we change indention
|
||||
mCurrentLine.mIndentation.mLength += kIndentSizeList;
|
||||
mULCount++;
|
||||
} else if (aTag == nsGkAtoms::ol) {
|
||||
EnsureVerticalSpace(mULCount + mOLStackIndex == 0 ? 1 : 0);
|
||||
EnsureVerticalSpace(IsInOlOrUl() ? 0 : 1);
|
||||
if (mSettings.HasFlag(nsIDocumentEncoder::OutputFormatted)) {
|
||||
// Must end the current line before we change indention
|
||||
if (mOLStackIndex < OLStackSize) {
|
||||
|
@ -974,7 +974,8 @@ nsresult nsPlainTextSerializer::DoCloseContainer(const nsAtom* aTag) {
|
|||
} else if (aTag == nsGkAtoms::ul) {
|
||||
mOutputManager->Flush(mCurrentLine);
|
||||
mCurrentLine.mIndentation.mLength -= kIndentSizeList;
|
||||
if (--mULCount + mOLStackIndex == 0) {
|
||||
--mULCount;
|
||||
if (!IsInOlOrUl()) {
|
||||
mFloatingLines = 1;
|
||||
mLineBreakDue = true;
|
||||
}
|
||||
|
@ -984,7 +985,7 @@ nsresult nsPlainTextSerializer::DoCloseContainer(const nsAtom* aTag) {
|
|||
mCurrentLine.mIndentation.mLength -= kIndentSizeList;
|
||||
NS_ASSERTION(mOLStackIndex, "Wrong OLStack level!");
|
||||
mOLStackIndex--;
|
||||
if (mULCount + mOLStackIndex == 0) {
|
||||
if (!IsInOlOrUl()) {
|
||||
mFloatingLines = 1;
|
||||
mLineBreakDue = true;
|
||||
}
|
||||
|
@ -1765,6 +1766,10 @@ bool nsPlainTextSerializer::IsInOL() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool nsPlainTextSerializer::IsInOlOrUl() const {
|
||||
return (mULCount > 0) || (mOLStackIndex > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@return 0 = no header, 1 = h1, ..., 6 = h6
|
||||
*/
|
||||
|
|
|
@ -106,6 +106,7 @@ class nsPlainTextSerializer final : public nsIContentSerializer {
|
|||
// element.
|
||||
bool IsElementPreformatted() const;
|
||||
bool IsInOL() const;
|
||||
bool IsInOlOrUl() const;
|
||||
bool IsCurrentNodeConverted() const;
|
||||
bool MustSuppressLeaf() const;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче