Issue #2862 - Change code references from CSS lowering to CSS flattening

This commit is contained in:
Basilisk-Dev 2026-03-13 08:58:18 -04:00 • committed by wuggy
commit 64d55b0a2e
4 changed files with 19 additions and 19 deletions

View file

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CSSNestingLowerer.h" #include "CSSNestingFlattener.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "nsString.h" #include "nsString.h"
@ -14,22 +14,22 @@ namespace css {
namespace { namespace {
class CSSNestingLowerer final class CSSNestingFlattener final
{ {
using SelectorList = nsTArray<nsString>; using SelectorList = nsTArray<nsString>;
public: public:
explicit CSSNestingLowerer(const nsAString& aInput) explicit CSSNestingFlattener(const nsAString& aInput)
: mInput(aInput) : mInput(aInput)
, mPos(0) , mPos(0)
, mSawNesting(false) , mSawNesting(false)
{ {
} }
bool Lower(nsAString& aOutput) bool Flatten(nsAString& aOutput)
{ {
nsAutoString lowered; nsAutoString flattened;
if (!ProcessStylesheet(lowered, false)) { if (!ProcessStylesheet(flattened, false)) {
return false; return false;
} }
@ -38,7 +38,7 @@ public:
return false; return false;
} }
aOutput.Assign(lowered); aOutput.Assign(flattened);
return true; return true;
} }
@ -952,10 +952,10 @@ private:
} // namespace } // namespace
bool bool
LowerBasicCSSNesting(const nsAString& aInput, nsAString& aOutput) FlattenBasicCSSNesting(const nsAString& aInput, nsAString& aOutput)
{ {
CSSNestingLowerer lowerer(aInput); CSSNestingFlattener flattener(aInput);
return lowerer.Lower(aOutput); return flattener.Flatten(aOutput);
} }
} // namespace css } // namespace css

View file

@ -3,17 +3,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef CSSNestingLowerer_h #ifndef CSSNestingFlattener_h
#define CSSNestingLowerer_h #define CSSNestingFlattener_h
class nsAString; class nsAString;
namespace mozilla { namespace mozilla {
namespace css { namespace css {
bool LowerBasicCSSNesting(const nsAString& aInput, nsAString& aOutput); bool FlattenBasicCSSNesting(const nsAString& aInput, nsAString& aOutput);
} // namespace css } // namespace css
} // namespace mozilla } // namespace mozilla
#endif // CSSNestingLowerer_h #endif // CSSNestingFlattener_h

View file

@ -127,7 +127,7 @@ UNIFIED_SOURCES += [
'CounterStyleManager.cpp', 'CounterStyleManager.cpp',
'CSS.cpp', 'CSS.cpp',
'CSSLexer.cpp', 'CSSLexer.cpp',
'CSSNestingLowerer.cpp', 'CSSNestingFlattener.cpp',
'CSSRuleList.cpp', 'CSSRuleList.cpp',
'CSSStyleSheet.cpp', 'CSSStyleSheet.cpp',
'CSSVariableDeclarations.cpp', 'CSSVariableDeclarations.cpp',

View file

@ -18,7 +18,7 @@
#include <regex> // for std::regex and std::regex_match #include <regex> // for std::regex and std::regex_match
#include "nsCSSParser.h" #include "nsCSSParser.h"
#include "CSSNestingLowerer.h" #include "CSSNestingFlattener.h"
#include "nsAlgorithm.h" #include "nsAlgorithm.h"
#include "nsCSSProps.h" #include "nsCSSProps.h"
#include "nsCSSKeywords.h" #include "nsCSSKeywords.h"
@ -1826,11 +1826,11 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
"Sheet principal does not match passed principal"); "Sheet principal does not match passed principal");
#endif #endif
nsAutoString loweredInput; nsAutoString flattenedInput;
const nsAString* input = &aInput; const nsAString* input = &aInput;
if (sNestingEnabled && if (sNestingEnabled &&
mozilla::css::LowerBasicCSSNesting(aInput, loweredInput)) { mozilla::css::FlattenBasicCSSNesting(aInput, flattenedInput)) {
input = &loweredInput; input = &flattenedInput;
} }
nsCSSScanner scanner(*input, aLineNumber); nsCSSScanner scanner(*input, aLineNumber);