Bug 1362914 - Drop initial values of properties other than font-size and font-family in serialization of canvas font attribute. r?manishearth
According to the canvas spec [1], we must drop initial values other than
font-size and font-family when we serialize canvas font attribute.
As for font-size and font-family, the default values, '10px sans-serif' [2]
are not dropped at all.
[1] https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-font
[2] https://html.spec.whatwg.org/multipage/scripting.html#canvastextdrawingstyles
MozReview-Commit-ID: EyOxzJCQYQl
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2896,19 +2896,17 @@ GetFontStyleForServo(Element* aElement,
RefPtr<ServoComputedValues> sc =
styleSet->ResolveForDeclarations(parentStyle, declarations);
// The font getter is required to be reserialized based on what we
// parsed (including having line-height removed). (Older drafts of
// the spec required font sizes be converted to pixels, but that no
// longer seems to be required.)
- Servo_DeclarationBlock_SerializeOneValue(declarations,
- eCSSProperty_font,
- &aOutUsedFont);
+ Servo_SerializeFontValueForCanvas(declarations, &aOutUsedFont);
return sc.forget();
}
static already_AddRefed<Declaration>
CreateFilterDeclaration(const nsAString& aFilter,
nsINode* aNode,
bool* aOutFilterChanged)
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -464,16 +464,21 @@ SERVO_BINDING_FUNC(Servo_AssertTreeIsCle
// Returns computed values for the given element without any animations rules.
SERVO_BINDING_FUNC(Servo_StyleSet_GetBaseComputedValuesForElement,
ServoComputedValuesStrong,
RawServoStyleSetBorrowed set,
RawGeckoElementBorrowed element,
const mozilla::ServoElementSnapshotTable* snapshots,
mozilla::CSSPseudoElementType pseudo_type)
+// For canvas font.
+SERVO_BINDING_FUNC(Servo_SerializeFontValueForCanvas, void,
+ RawServoDeclarationBlockBorrowed declarations,
+ nsAString* buffer)
+
// Style-struct management.
#define STYLE_STRUCT(name, checkdata_cb) \
struct nsStyle##name; \
SERVO_BINDING_FUNC(Servo_GetStyle##name, const nsStyle##name*, \
ServoComputedValuesBorrowedOrNull computed_values)
#include "nsStyleStructList.h"
#undef STYLE_STRUCT