Skip to content

Commit

Permalink
[css-counter-styles] Various small cleanups
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=256155
rdar://108720314

Unreviewed, address Darin's comments on #13320.

- Remove unnecessary `=`
- Add _s suffix to appropriate strings
- Remove unnecessary #include
- Enable @counter-style on Windows DRT (not sure why it was disabled in the first place)

* Source/WebCore/css/CSSCounterStyle.cpp:
(WebCore::CSSCounterStyle::counterForSystemAdditive const):
(WebCore::CSSCounterStyle::counterForSystemSimplifiedChineseInformal):
(WebCore::CSSCounterStyle::counterForSystemSimplifiedChineseFormal):
(WebCore::CSSCounterStyle::counterForSystemTraditionalChineseInformal):
(WebCore::CSSCounterStyle::counterForSystemTraditionalChineseFormal):
* Source/WebCore/css/CSSCounterStyleDescriptors.cpp:
(WebCore::CSSCounterStyleDescriptors::systemCSSText const):
* Source/WebCore/css/CSSCounterStyleRegistry.cpp:
* Tools/DumpRenderTree/TestOptions.cpp:
(WTR::TestOptions::defaults):

Canonical link: https://commits.webkit.org/263546@main
  • Loading branch information
nt1m committed May 1, 2023
1 parent 7a82d30 commit e9b1660
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
13 changes: 5 additions & 8 deletions Source/WebCore/css/CSSCounterStyle.cpp
Expand Up @@ -28,9 +28,6 @@

#include "CSSCounterStyleDescriptors.h"
#include "CSSCounterStyleRegistry.h"
#include "CSSCounterStyleRule.h"
#include "CSSPrimitiveValue.h"
#include "CSSValuePair.h"
#include <cmath>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/TextBreakIterator.h>
Expand Down Expand Up @@ -146,7 +143,7 @@ String CSSCounterStyle::counterForSystemAdditive(unsigned value) const
}

StringBuilder result;
auto appendToResult = [&](String symbol, unsigned frequency) {
auto appendToResult = [&](const String& symbol, unsigned frequency) {
for (unsigned i = 0; i < frequency; ++i)
result.append(symbol);
};
Expand Down Expand Up @@ -252,7 +249,7 @@ static String counterForSystemCJK(int number, const std::array<UChar, 17>& table

String CSSCounterStyle::counterForSystemSimplifiedChineseInformal(int value)
{
static constexpr std::array<UChar, 17> simplifiedChineseInformalTable = {
static constexpr std::array<UChar, 17> simplifiedChineseInformalTable {
0x842C, 0x5104, 0x5146, // These three group markers are probably wrong; OK because we don't use this on big enough numbers.
0x5341, 0x767E, 0x5343,
0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB,
Expand All @@ -264,7 +261,7 @@ String CSSCounterStyle::counterForSystemSimplifiedChineseInformal(int value)

String CSSCounterStyle::counterForSystemSimplifiedChineseFormal(int value)
{
static constexpr std::array<UChar, 17> simplifiedChineseFormalTable = {
static constexpr std::array<UChar, 17> simplifiedChineseFormalTable {
0x842C, 0x5104, 0x5146, // These three group markers are probably wrong; OK because we don't use this on big enough numbers.
0x62FE, 0x4F70, 0x4EDF,
0x96F6, 0x58F9, 0x8D30, 0x53C1, 0x8086,
Expand All @@ -276,7 +273,7 @@ String CSSCounterStyle::counterForSystemSimplifiedChineseFormal(int value)

String CSSCounterStyle::counterForSystemTraditionalChineseInformal(int value)
{
static constexpr std::array<UChar, 17> traditionalChineseInformalTable = {
static constexpr std::array<UChar, 17> traditionalChineseInformalTable {
0x842C, 0x5104, 0x5146,
0x5341, 0x767E, 0x5343,
0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB,
Expand All @@ -288,7 +285,7 @@ String CSSCounterStyle::counterForSystemTraditionalChineseInformal(int value)

String CSSCounterStyle::counterForSystemTraditionalChineseFormal(int value)
{
static constexpr std::array<UChar, 17> traditionalChineseFormalTable = {
static constexpr std::array<UChar, 17> traditionalChineseFormalTable {
0x842C, 0x5104, 0x5146, // These three group markers are probably wrong; OK because we don't use this on big enough numbers.
0x62FE, 0x4F70, 0x4EDF,
0x96F6, 0x58F9, 0x8CB3, 0x53C3, 0x8086,
Expand Down
7 changes: 3 additions & 4 deletions Source/WebCore/css/CSSCounterStyleDescriptors.cpp
Expand Up @@ -27,7 +27,6 @@
#include "CSSCounterStyleDescriptors.h"

#include "CSSCounterStyleRule.h"
#include "CSSMarkup.h"
#include "CSSPrimitiveValue.h"
#include "CSSValueList.h"
#include "CSSValuePair.h"
Expand Down Expand Up @@ -410,7 +409,7 @@ String CSSCounterStyleDescriptors::systemCSSText() const
if (!m_explicitlySetDescriptors.contains(ExplicitlySetDescriptors::System))
return emptyString();
if (m_isExtendedResolved)
return makeString("extends ", m_extendsName);
return makeString("extends "_s, m_extendsName);

switch (m_system) {
case System::Cyclic:
Expand All @@ -424,9 +423,9 @@ String CSSCounterStyleDescriptors::systemCSSText() const
case System::Additive:
return "additive"_s;
case System::Fixed:
return makeString("fixed ", m_fixedSystemFirstSymbolValue);
return makeString("fixed "_s, m_fixedSystemFirstSymbolValue);
case System::Extends:
return makeString("extends ", m_extendsName);
return makeString("extends "_s, m_extendsName);
// Internal values should not be exposed.
case System::SimplifiedChineseInformal:
case System::SimplifiedChineseFormal:
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/css/CSSCounterStyleRegistry.cpp
Expand Up @@ -27,7 +27,6 @@
#include "CSSCounterStyleRegistry.h"

#include "CSSCounterStyle.h"
#include "CSSCounterStyleRule.h"
#include "CSSPrimitiveValue.h"
#include "CSSValuePair.h"
#include "ListStyleType.h"
Expand Down
1 change: 0 additions & 1 deletion Tools/DumpRenderTree/TestOptions.cpp
Expand Up @@ -136,7 +136,6 @@ const TestFeatures& TestOptions::defaults()
{ "AttachmentWideLayoutEnabled", false },
{ "CSSContainmentEnabled", false },
{ "CSSCounterStyleAtRuleImageSymbolsEnabled", false },
{ "CSSCounterStyleAtRulesEnabled", false },
{ "CSSGradientInterpolationColorSpacesEnabled", true },
{ "CSSGradientPremultipliedAlphaInterpolationEnabled", true },
{ "CSSInputSecurityEnabled", true },
Expand Down

0 comments on commit e9b1660

Please sign in to comment.