Bug 1738658 - Serialize text-decoration using Servo. r=layout-reviewers,mats

The code introduced in the preceding patch deals with currentColor correctly,
so we should be able to do this now.

This uncovers a bug in the existing serialization code when a non-auto
text-decoration-thickness was used, caught by
css/css-text-decor/parsing/text-decoration-computed.html.

Differential Revision: https://phabricator.services.mozilla.com/D130018
This commit is contained in:
Emilio Cobos Álvarez 2021-11-02 14:21:38 +00:00
parent ac72dbe343
commit 7c1b2c19fd
5 changed files with 6 additions and 58 deletions

View file

@ -17,6 +17,7 @@
#include "nsFocusManager.h"
#include "nsFrameManager.h"
#include "nsRefreshDriver.h"
#include "nsStyleUtil.h"
#include "mozilla/dom/Animation.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/BlobBinding.h"
@ -3997,8 +3998,8 @@ nsDOMWindowUtils::GetOMTAStyle(Element* aElement, const nsAString& aProperty,
OMTAValue value = GetOMTAValue(
frame, DisplayItemType::TYPE_BACKGROUND_COLOR, GetWebRenderBridge());
if (value.type() == OMTAValue::Tnscolor) {
cssValue = new nsROCSSPrimitiveValue;
nsComputedDOMStyle::SetToRGBAColor(cssValue, value.get_nscolor());
nsStyleUtil::GetSerializedColorValue(value.get_nscolor(), aResult);
return NS_OK;
}
}
}

View file

@ -99,10 +99,8 @@ LONGHANDS_NOT_SERIALIZED_WITH_SERVO = [
def serialized_by_servo(prop):
if prop.type() == "shorthand":
# FIXME: Need to serialize a value interpolated with currentcolor
# properly to be able to use text-decoration, and figure out what to do
# with relative mask urls.
return prop.name != "text-decoration" and prop.name != "mask"
# FIXME: Need to figure out what to do with relative mask urls.
return prop.name != "mask"
# Keywords are all fine, except -moz-osx-font-smoothing, which does
# resistfingerprinting stuff.
if prop.keyword and prop.name != "-moz-osx-font-smoothing":

View file

@ -1192,19 +1192,6 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetBottom() {
return GetOffsetWidthFor(eSideBottom);
}
/* static */
void nsComputedDOMStyle::SetToRGBAColor(nsROCSSPrimitiveValue* aValue,
nscolor aColor) {
nsAutoString string;
nsStyleUtil::GetSerializedColorValue(aColor, string);
aValue->SetString(string);
}
void nsComputedDOMStyle::SetValueFromComplexColor(
nsROCSSPrimitiveValue* aValue, const mozilla::StyleColor& aColor) {
SetToRGBAColor(aValue, aColor.CalcColor(*mComputedStyle));
}
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetColumnRuleWidth() {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
val->SetAppUnits(StyleColumn()->GetComputedColumnRuleWidth());
@ -1848,41 +1835,6 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetLineHeight() {
return val.forget();
}
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetTextDecoration() {
auto getPropertyValue = [&](nsCSSPropertyID aID) {
RefPtr<nsROCSSPrimitiveValue> value = new nsROCSSPrimitiveValue;
nsAutoCString string;
mComputedStyle->GetComputedPropertyValue(aID, string);
value->SetString(string);
return value.forget();
};
const nsStyleTextReset* textReset = StyleTextReset();
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
if (textReset->mTextDecorationLine != StyleTextDecorationLine::NONE) {
valueList->AppendCSSValue(
getPropertyValue(eCSSProperty_text_decoration_line));
}
if (!textReset->mTextDecorationThickness.IsAuto()) {
valueList->AppendCSSValue(
getPropertyValue(eCSSProperty_text_decoration_thickness));
}
if (textReset->mTextDecorationStyle != NS_STYLE_TEXT_DECORATION_STYLE_SOLID) {
valueList->AppendCSSValue(
getPropertyValue(eCSSProperty_text_decoration_style));
}
// The resolved color shouldn't be currentColor, so we always serialize it.
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueFromComplexColor(val, StyleTextReset()->mTextDecorationColor);
valueList->AppendCSSValue(val.forget());
return valueList.forget();
}
already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetHeight() {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;

View file

@ -133,7 +133,6 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
static already_AddRefed<nsROCSSPrimitiveValue> MatrixToCSSValue(
const mozilla::gfx::Matrix4x4& aMatrix);
static void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
static void RegisterPrefChangeCallbacks();
static void UnregisterPrefChangeCallbacks();
@ -267,7 +266,6 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
/* Text Properties */
already_AddRefed<CSSValue> DoGetLineHeight();
already_AddRefed<CSSValue> DoGetTextDecoration();
/* Display properties */
already_AddRefed<CSSValue> DoGetTransform();
@ -282,8 +280,6 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration,
already_AddRefed<CSSValue> DummyGetter();
/* Helper functions */
void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue,
const mozilla::StyleColor& aColor);
void SetValueToPosition(const mozilla::Position& aPosition,
nsDOMCSSValueList* aValueList);
void SetValueToURLValue(const mozilla::StyleComputedUrl* aURL,

View file

@ -93,6 +93,7 @@
dest.write_str(" ")?;
}
self.text_decoration_thickness.to_css(dest)?;
has_value = true;
}
% if engine == "gecko":