Skip to content

Commit f0bab5c

Browse files
author
ci_lynx
committed
fix: revert "[Optimize][Input] Add placeholder styling definitions"
This reverts commit 46e7c94e43a5e3b9564f0b07eddb510991fc1933
1 parent 4ac561a commit f0bab5c

File tree

19 files changed

+9
-504
lines changed

19 files changed

+9
-504
lines changed

core/renderer/css/computed_css_style.cc

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,22 +1488,6 @@ bool ComputedCSSStyle::SetFontSize(const tasm::CSSValue& value,
14881488
return base::FloatsNotEqual(text_attributes_->font_size, old_value);
14891489
}
14901490

1491-
bool ComputedCSSStyle::SetXPlaceholderFontSize(const tasm::CSSValue& value,
1492-
const bool reset) {
1493-
PrepareOptionalForPlaceholderTextAttributes();
1494-
const float default_font_size =
1495-
DEFAULT_FONT_SIZE_DP * length_context_.layouts_unit_per_px_;
1496-
auto old_value = placeholder_text_attributes_->font_size;
1497-
if (reset) {
1498-
placeholder_text_attributes_->font_size = default_font_size;
1499-
} else {
1500-
CalculateCSSValueToFloat(value, placeholder_text_attributes_->font_size,
1501-
length_context_, parser_configs_);
1502-
}
1503-
return base::FloatsNotEqual(placeholder_text_attributes_->font_size,
1504-
old_value);
1505-
}
1506-
15071491
bool ComputedCSSStyle::SetLineHeight(const tasm::CSSValue& value,
15081492
const bool reset) {
15091493
PrepareOptionalForTextAttributes();
@@ -2175,35 +2159,6 @@ bool ComputedCSSStyle::SetColor(const tasm::CSSValue& value, const bool reset) {
21752159
old_value_gradient != text_attributes_->text_gradient;
21762160
}
21772161

2178-
bool ComputedCSSStyle::SetXPlaceholderColor(const tasm::CSSValue& value,
2179-
const bool reset) {
2180-
PrepareOptionalForPlaceholderTextAttributes();
2181-
auto old_value_color = placeholder_text_attributes_->color;
2182-
auto old_value_gradient = placeholder_text_attributes_->text_gradient;
2183-
if (reset) {
2184-
placeholder_text_attributes_->color = DefaultColor::DEFAULT_TEXT_COLOR;
2185-
placeholder_text_attributes_->text_gradient.reset();
2186-
} else {
2187-
CSS_HANDLER_FAIL_IF_NOT(
2188-
value.IsNumber() || value.IsArray(),
2189-
parser_configs_.enable_css_strict_mode, tasm::TYPE_MUST_BE,
2190-
tasm::CSSProperty::GetPropertyName(tasm::kPropertyIDXPlaceholderColor)
2191-
.c_str(),
2192-
tasm::ARRAY_OR_NUMBER_TYPE)
2193-
2194-
if (value.IsNumber()) {
2195-
placeholder_text_attributes_->color =
2196-
static_cast<uint32_t>(value.GetValue().Number());
2197-
placeholder_text_attributes_->text_gradient.reset();
2198-
} else {
2199-
placeholder_text_attributes_->color = DefaultColor::DEFAULT_TEXT_COLOR;
2200-
placeholder_text_attributes_->text_gradient = value.GetValue();
2201-
}
2202-
}
2203-
return old_value_color != placeholder_text_attributes_->color ||
2204-
old_value_gradient != placeholder_text_attributes_->text_gradient;
2205-
}
2206-
22072162
bool ComputedCSSStyle::SetBackground(const tasm::CSSValue& value,
22082163
const bool reset) {
22092164
return tasm::UnitHandler::CSSMethodUnreachable(
@@ -2422,14 +2377,6 @@ bool ComputedCSSStyle::SetFontFamily(const tasm::CSSValue& value,
24222377
"font family must be a string!", parser_configs_);
24232378
}
24242379

2425-
bool ComputedCSSStyle::SetXPlaceholderFontFamily(const tasm::CSSValue& value,
2426-
const bool reset) {
2427-
PrepareOptionalForPlaceholderTextAttributes();
2428-
return CSSStyleUtils::ComputeStringStyle(
2429-
value, reset, placeholder_text_attributes_->font_family, base::String(),
2430-
"font family must be a string!", parser_configs_);
2431-
}
2432-
24332380
bool ComputedCSSStyle::SetCaretColor(const lynx::tasm::CSSValue& value,
24342381
bool reset) {
24352382
return CSSStyleUtils::ComputeStringStyle(
@@ -2463,15 +2410,6 @@ bool ComputedCSSStyle::SetFontWeight(const tasm::CSSValue& value,
24632410
parser_configs_);
24642411
}
24652412

2466-
bool ComputedCSSStyle::SetXPlaceholderFontWeight(const tasm::CSSValue& value,
2467-
const bool reset) {
2468-
PrepareOptionalForPlaceholderTextAttributes();
2469-
return CSSStyleUtils::ComputeEnumStyle<starlight::FontWeightType>(
2470-
value, reset, placeholder_text_attributes_->font_weight,
2471-
DefaultComputedStyle::DEFAULT_FONT_WEIGHT, "font weight must be an enum!",
2472-
parser_configs_);
2473-
}
2474-
24752413
bool ComputedCSSStyle::SetWordBreak(const tasm::CSSValue& value,
24762414
const bool reset) {
24772415
PrepareOptionalForTextAttributes();
@@ -2490,15 +2428,6 @@ bool ComputedCSSStyle::SetFontStyle(const tasm::CSSValue& value,
24902428
parser_configs_);
24912429
}
24922430

2493-
bool ComputedCSSStyle::SetXPlaceholderFontStyle(const tasm::CSSValue& value,
2494-
const bool reset) {
2495-
PrepareOptionalForPlaceholderTextAttributes();
2496-
return CSSStyleUtils::ComputeEnumStyle<starlight::FontStyleType>(
2497-
value, reset, placeholder_text_attributes_->font_style,
2498-
DefaultComputedStyle::DEFAULT_FONT_STYLE, "font style must be an enum!",
2499-
parser_configs_);
2500-
}
2501-
25022431
bool ComputedCSSStyle::SetTextAlign(const tasm::CSSValue& value,
25032432
const bool reset) {
25042433
PrepareOptionalForTextAttributes();
@@ -3087,14 +3016,6 @@ lepus_value ComputedCSSStyle::FontSizeToLepus() {
30873016
}
30883017
}
30893018

3090-
lepus_value ComputedCSSStyle::XPlaceholderFontSizeToLepus() {
3091-
if (placeholder_text_attributes_) {
3092-
return lepus_value(placeholder_text_attributes_->font_size);
3093-
} else {
3094-
return lepus_value();
3095-
}
3096-
}
3097-
30983019
lepus_value ComputedCSSStyle::LineHeightToLepus() {
30993020
if (text_attributes_) {
31003021
return lepus_value(text_attributes_->computed_line_height);
@@ -3178,19 +3099,6 @@ lepus_value ComputedCSSStyle::ColorToLepus() {
31783099
}
31793100
}
31803101

3181-
lepus_value ComputedCSSStyle::XPlaceholderColorToLepus() {
3182-
if (placeholder_text_attributes_) {
3183-
if (placeholder_text_attributes_->text_gradient.has_value() &&
3184-
placeholder_text_attributes_->text_gradient->IsArray()) {
3185-
return *placeholder_text_attributes_->text_gradient;
3186-
} else {
3187-
return lepus_value(placeholder_text_attributes_->color);
3188-
}
3189-
} else {
3190-
return lepus_value();
3191-
}
3192-
}
3193-
31943102
lepus_value ComputedCSSStyle::BackgroundToLepus() { return lepus_value(); }
31953103

31963104
lepus_value ComputedCSSStyle::BackgroundColorToLepus() {
@@ -3552,14 +3460,6 @@ lepus_value ComputedCSSStyle::FontFamilyToLepus() {
35523460
}
35533461
}
35543462

3555-
lepus_value ComputedCSSStyle::XPlaceholderFontFamilyToLepus() {
3556-
if (placeholder_text_attributes_) {
3557-
return lepus_value(placeholder_text_attributes_->font_family);
3558-
} else {
3559-
return lepus_value();
3560-
}
3561-
}
3562-
35633463
lepus_value ComputedCSSStyle::CaretColorToLepus() {
35643464
return lepus::Value(caret_color_);
35653465
}
@@ -3611,15 +3511,6 @@ lepus_value ComputedCSSStyle::FontWeightToLepus() {
36113511
}
36123512
}
36133513

3614-
lepus_value ComputedCSSStyle::XPlaceholderFontWeightToLepus() {
3615-
if (placeholder_text_attributes_) {
3616-
return lepus_value(
3617-
static_cast<int>(placeholder_text_attributes_->font_weight));
3618-
} else {
3619-
return lepus_value();
3620-
}
3621-
}
3622-
36233514
lepus_value ComputedCSSStyle::FontStyleToLepus() {
36243515
if (text_attributes_) {
36253516
return lepus_value(static_cast<int>(text_attributes_->font_style));
@@ -3628,15 +3519,6 @@ lepus_value ComputedCSSStyle::FontStyleToLepus() {
36283519
}
36293520
}
36303521

3631-
lepus_value ComputedCSSStyle::XPlaceholderFontStyleToLepus() {
3632-
if (placeholder_text_attributes_) {
3633-
return lepus_value(
3634-
static_cast<int>(placeholder_text_attributes_->font_style));
3635-
} else {
3636-
return lepus_value();
3637-
}
3638-
}
3639-
36403522
lepus_value ComputedCSSStyle::TextAlignToLepus() {
36413523
if (text_attributes_) {
36423524
return lepus_value(static_cast<int>(text_attributes_->text_align));

core/renderer/css/computed_css_style.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,6 @@ class ComputedCSSStyle {
241241
return text_attributes_;
242242
}
243243

244-
base::flex_optional<TextAttributes>& GetPlaceholderTextAttributes() {
245-
return placeholder_text_attributes_;
246-
}
247-
248244
base::flex_optional<BackgroundData>& GetBackgroundData() {
249245
return background_data_;
250246
}
@@ -322,13 +318,6 @@ class ComputedCSSStyle {
322318
default_font_size);
323319
}
324320

325-
void PrepareOptionalForPlaceholderTextAttributes() {
326-
const float default_font_size =
327-
DEFAULT_FONT_SIZE_DP * length_context_.layouts_unit_per_px_;
328-
CSSStyleUtils::PrepareOptionalForTextAttributes(
329-
placeholder_text_attributes_, default_font_size);
330-
}
331-
332321
XAnimationColorInterpolationType new_animator_interpolation() {
333322
return new_animator_interpolation_;
334323
}
@@ -385,7 +374,6 @@ class ComputedCSSStyle {
385374
base::flex_optional<base::InlineVector<TransitionData, 1>> transition_data_;
386375
base::flex_optional<base::InlineVector<ShadowData, 1>> box_shadow_;
387376
base::flex_optional<TextAttributes> text_attributes_;
388-
base::flex_optional<TextAttributes> placeholder_text_attributes_;
389377
base::flex_optional<TransformOriginData> transform_origin_;
390378
base::flex_optional<FilterData> filter_;
391379
base::flex_optional<PerspectiveData> perspective_data_;
@@ -542,12 +530,7 @@ class ComputedCSSStyle {
542530
V(OffsetRotate) \
543531
V(FontVariationSettings) \
544532
V(FontFeatureSettings) \
545-
V(FontOpticalSizing) \
546-
V(XPlaceholderColor) \
547-
V(XPlaceholderFontFamily) \
548-
V(XPlaceholderFontSize) \
549-
V(XPlaceholderFontWeight) \
550-
V(XPlaceholderFontStyle)
533+
V(FontOpticalSizing)
551534

552535
#define GETTER_STYLE_STRING(name) lepus_value name##ToLepus();
553536
FOREACH_PLATFORM_PROPERTY(GETTER_STYLE_STRING)

core/renderer/css/css_decoder.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,11 @@ std::string CSSDecoder::CSSValueEnumToString(
220220
case lynx::tasm::kPropertyIDFontWeight:
221221
return ToFontWeightType(value.GetEnum<FontWeightType>());
222222
break;
223-
case lynx::tasm::kPropertyIDXPlaceholderFontWeight:
224-
return ToXPlaceholderFontWeightType(
225-
value.GetEnum<XPlaceholderFontWeightType>());
226223
case lynx::tasm::kPropertyIDWordBreak:
227224
return ToWordBreakType(value.GetEnum<WordBreakType>());
228225
case lynx::tasm::kPropertyIDFontStyle:
229226
return ToFontStyleType(value.GetEnum<FontStyleType>());
230227
break;
231-
case lynx::tasm::kPropertyIDXPlaceholderFontStyle:
232-
return ToXPlaceholderFontStyleType(
233-
value.GetEnum<XPlaceholderFontStyleType>());
234228
case lynx::tasm::kPropertyIDTextAlign:
235229
return ToTextAlignType(value.GetEnum<TextAlignType>());
236230
break;

core/renderer/css/css_property_unittest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace test {
1515

1616
TEST(CSSProperty, GetComputeStyleMap) {
1717
auto map = CSSProperty::GetComputeStyleMap();
18-
EXPECT_EQ(map.size(), 225);
18+
EXPECT_EQ(map.size(), 220);
1919
}
2020

2121
TEST(CSSProperty, GetPropertyID) {

core/renderer/css/parser/enum_handler.cc

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -522,54 +522,6 @@ static bool ToFontOpticalSizingType(std::string_view str, int& result) {
522522
return true;
523523
}
524524

525-
using starlight::XPlaceholderFontWeightType;
526-
static bool ToXPlaceholderFontWeightType(std::string_view str, int& result) {
527-
XPlaceholderFontWeightType type = XPlaceholderFontWeightType::kNormal;
528-
if (str == "normal") {
529-
type = XPlaceholderFontWeightType::kNormal;
530-
} else if (str == "bold") {
531-
type = XPlaceholderFontWeightType::kBold;
532-
} else if (str == "100") {
533-
type = XPlaceholderFontWeightType::k100;
534-
} else if (str == "200") {
535-
type = XPlaceholderFontWeightType::k200;
536-
} else if (str == "300") {
537-
type = XPlaceholderFontWeightType::k300;
538-
} else if (str == "400") {
539-
type = XPlaceholderFontWeightType::k400;
540-
} else if (str == "500") {
541-
type = XPlaceholderFontWeightType::k500;
542-
} else if (str == "600") {
543-
type = XPlaceholderFontWeightType::k600;
544-
} else if (str == "700") {
545-
type = XPlaceholderFontWeightType::k700;
546-
} else if (str == "800") {
547-
type = XPlaceholderFontWeightType::k800;
548-
} else if (str == "900") {
549-
type = XPlaceholderFontWeightType::k900;
550-
} else {
551-
return false;
552-
}
553-
result = static_cast<int>(type);
554-
return true;
555-
}
556-
557-
using starlight::XPlaceholderFontStyleType;
558-
static bool ToXPlaceholderFontStyleType(std::string_view str, int& result) {
559-
XPlaceholderFontStyleType type = XPlaceholderFontStyleType::kNormal;
560-
if (str == "normal") {
561-
type = XPlaceholderFontStyleType::kNormal;
562-
} else if (str == "italic") {
563-
type = XPlaceholderFontStyleType::kItalic;
564-
} else if (str == "oblique") {
565-
type = XPlaceholderFontStyleType::kOblique;
566-
} else {
567-
return false;
568-
}
569-
result = static_cast<int>(type);
570-
return true;
571-
}
572-
573525
// AUTO INSERT END, DON'T CHANGE IT!
574526

575527
using starlight::FlexAlignType;
@@ -761,12 +713,6 @@ HANDLER_IMPL() {
761713
case kPropertyIDFontOpticalSizing:
762714
success = ToFontOpticalSizingType(str, result);
763715
break;
764-
case kPropertyIDXPlaceholderFontWeight:
765-
success = ToXPlaceholderFontWeightType(str, result);
766-
break;
767-
case kPropertyIDXPlaceholderFontStyle:
768-
success = ToXPlaceholderFontStyleType(str, result);
769-
break;
770716
// AUTO INSERT END, DON'T CHANGE IT!
771717
case kPropertyIDLinearDirection:
772718
success = ToLinearOrientationType(str, result);
@@ -825,8 +771,6 @@ HANDLER_REGISTER_IMPL() {
825771
array[kPropertyIDXAppRegion] = &Handle;
826772
array[kPropertyIDXAnimationColorInterpolation] = &Handle;
827773
array[kPropertyIDFontOpticalSizing] = &Handle;
828-
array[kPropertyIDXPlaceholderFontWeight] = &Handle;
829-
array[kPropertyIDXPlaceholderFontStyle] = &Handle;
830774
// AUTO INSERT END, DON'T CHANGE IT!
831775
array[kPropertyIDLinearDirection] = &Handle;
832776
array[kPropertyIDAlignItems] = &Handle;

0 commit comments

Comments
 (0)