Commit graph

52 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
8ad595666f
style: Use a static atom instead of a dynamic one.
MozReview-Commit-ID: CUTwfsCrovQ
2018-05-28 15:39:06 +02:00
Emilio Cobos Álvarez
b6a17426a0
style: Fix font-stretch animation.
This is a regression from #20506 which Gecko tests caught while trying to import
this.
2018-05-21 11:57:03 +02:00
Jon Leighton
691c6c6f1a Implement font fallback
Prior to this change, if none of the fonts specified in CSS contained a
glyph for a codepoint, we tried only one fallback font. If that font
didn't contain the glyph, we'd give up.

With this change, we try multiple fonts in turn. The font names we try
differ across each platform, and based on the codepoint we're trying to
match. The current implementation is heavily inspired by the analogous
code in Gecko, but I've used to ucd lib to make it more readable,
whereas Gecko matches raw unicode ranges.

This fixes some of the issues reported in #17267, although colour emoji
support is not implemented.

== Notes on changes to WPT metadata ==

=== css/css-text/i18n/css3-text-line-break-opclns-* ===

A bunch of these have started failing on macos when they previously
passed.

These tests check that the browser automatically inserts line breaks
near certain characters that are classified as "opening and closing
punctuation". The idea is that if we have e.g. an opening parenthesis,
it does not make sense for it to appear at the end of a line box; it
should "stick" to the next character and go into the next line box.

Before this change, a lot of these codepoints rendered as a missing
glyph on Mac and Linux. In some cases, that meant that the test was
passing.

After this change, a bunch of these codepoints are now rendering glyphs
on Mac (but not Linux). In some cases, the test should continue to pass
where it previously did when rendering with the missing glyph.

However, it seems this has also exposed a layout bug. The "ref" div in
these tests contains a <br> element, and it seems that this, combined
with these punctuation characters, makes the spacing between glyphs ever
so slightly different to the "test" div. (Speculation: might be
something to do with shaping?)

Therefore I've had to mark a bunch of these tests failing on mac.

=== css/css-text/i18n/css3-text-line-break-baspglwj-* ===

Some of these previously passed on Mac due to a missing glyph. Now that
we're rendering the correct glyph, they are failing.

=== css/css-text/word-break/word-break-normal-bo-000.html ===

The characters now render correctly on Mac, and the test is passing. But
we do not find a suitable fallback font on Linux, so it is still failing
on that platform.

=== css/css-text/word-break/word-break-break-all-007.html ===

This was previously passing on Mac, but only because missing character
glyphs were rendered. Now that a fallback font is able to be found, it
(correctly) fails.

=== mozilla/tests/css/font_fallback_* ===

These are new tests added in this commit. 01 and 02 are marked failing
on Linux because the builders don't have the appropriate fonts installed
(that will be a follow-up).

Fix build errors from rebase

FontTemplateDescriptor can no longer just derive(Hash). We need to
implement it on each component part, because the components now
generally wrap floats, which do not impl Hash because of NaN. However in
this case we know that we won't have a NaN, so it is safe to manually
impl Hash.
2018-05-19 14:33:36 +10:00
Emilio Cobos Álvarez
54b444992d
Fix servo build. 2018-04-28 10:26:47 +02:00
Emilio Cobos Álvarez
16ca8de6df
style: Compare degrees for font-style to account for compute_angle introducing error. 2018-04-28 10:26:40 +02:00
Jonathan Watt
36cef8ec68
style: Use user defined types for font-stretch / font-style.
Co-authored-by: Emilio Cobos Álvarez <emilio@crisal.io>
Bug: 1436048
Reviewed-by: jfkthame,jwatt
MozReview-Commit-ID: 7ONYtICeAqb
2018-04-28 10:26:06 +02:00
Emilio Cobos Álvarez
0a8518b452
style: Fix clamping on animations for fort-style.
Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: Awyub0dMOmq
2018-04-28 10:26:06 +02:00
Emilio Cobos Álvarez
737501153b
style: Use a generic type in preparation to fix animation.
Apart from a bit more code reuse.

Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: 2BNOK6v30lX
2018-04-28 10:26:05 +02:00
Emilio Cobos Álvarez
32d4da8a99
style: Update font-style to css-fonts-4.
Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: 1Nq5DyCjaZe
2018-04-28 10:26:05 +02:00
Emilio Cobos Álvarez
f7636e6662
style: Update font-stretch to css-fonts-4.
These won't "just work", pending changes from bug 1436048 to use a floating
point representation for those.

Bug: 1454883
Reviewed-by: xidorn
MozReview-Commit-ID: Bi5iTdFreMA
2018-04-28 10:26:04 +02:00
Emilio Cobos Álvarez
48de556f8c
style: Fixups for css-fonts-4 font-weight. 2018-04-28 10:26:03 +02:00
Emilio Cobos Álvarez
bc1126ee8c
style: Update font-weight property and descriptor to css-fonts-4.
Bug: 1454596
Reviewed-by: xidorn
MozReview-Commit-ID: 27aS2UrgXjs
2018-04-28 10:25:59 +02:00
Jonathan Watt
245d848508
style: Use a user defined type for font weight everywhere.
Bug: 1436048
Reviewed-by: emilio
2018-04-14 21:15:43 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Anthony Ramine
ca45695db1 Introduce #[css(skip)] 2018-03-05 15:53:15 +01:00
Anthony Ramine
b17fea1d7f Make KeywordInfo generic 2018-02-15 12:03:00 +01:00
Xidorn Quan
caa15ab6a7 Output unquoted family name as a series of identifiers.
It tries to serialize unquoted family names as a series of identifiers.
For family names which contain special white spaces like leading white
space, trailing white space, and consective white spaces, unquoted names
are marked quoted in parsing to avoid complicating serialization code.
2018-02-13 09:17:19 +11:00
Emilio Cobos Álvarez
655e0c6beb
style: Remove unneeded clone. 2018-02-09 12:30:20 +01:00
Gecko Backout
1231868663 Backed out changeset 24f85c628472 for failing in layout/style/test/test_value_storage.html on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/19983
2018-02-08 09:43:28 +00:00
Emilio Cobos Álvarez
9490786876
style: Tweak font-family serialization so that it is simpler.
In particular, every time that there's at least more than one identifier, switch
to quoted family name, since the reconstruction of the serialization will be
lossy anyway.

This allows us to avoid copies and all that.

What Chrome implements doesn't make much sense in the sense that they always
serialize:

  font-family: "foo";  -> font-family: foo;
  font-family: foo bar;  -> font-family: "foo bar";
  font-family: foo\ bar; -> font-family: "foo bar";

This patch makes us match on the second case, but not on the rest, because I
think Gecko's behavior is preferable in those cases.

Bug: 1434802
Reviewed-by: xidorn
MozReview-Commit-ID: JwBECA93lfi
2018-02-08 01:09:39 +01:00
Emilio Cobos Álvarez
f4c9c598a3
style: Optimize serialization of identifiers of length <= 16 🐉🐲
Much like we optimize to_ascii_lowercase.

This also fixes a bug in Servo where attr() rules with an unknown namespace
prefix are parsed, which is wrong.
2018-02-07 17:34:22 +01:00
Emilio Cobos Álvarez
3b34d734e6
style: Refactor font-feature-settings and font-variation-settings.
This fixes all known issues with serialization and parsing of these two
properties, and in particular calc handling and such:

  https://bugzilla.mozilla.org/show_bug.cgi?id=1434692
  https://bugzilla.mozilla.org/show_bug.cgi?id=1434724

Also does a fair amount of cleanup and all that, which was needed.
2018-02-01 12:54:45 +01:00
Emilio Cobos Álvarez
09398d42af
style: Move a bunch of font stuff living under generics to the proper module.
FontSettingsTagInt and such shouldn't be in the generic module, I know...

But that will change in a bit.
2018-02-01 02:35:33 +01:00
Anthony Ramine
cd8f96cc9e Change ToCss to take a CssWriter<W>
This more concrete wrapper type can write a prefix the very first time something
is written to it. This allows removing plenty of useless monomorphisations caused
by the former W/SequenceWriter<W> pair of types.
2018-01-23 10:41:42 +01:00
Bobby Holley
f858ce91e8 Avoid entraining various Debug impls in release builds.
MozReview-Commit-ID: Lp9i9EI5qdU
2018-01-13 09:51:46 -08:00
Emilio Cobos Álvarez
af879523ea
style: Make all keywords CamelCase for consistency.
This prevents confusion and paves the ground for derive(Parse) of them.
2017-12-06 02:35:10 +01:00
CYBAI
a470ebd501 style: Move font-family outside of mako 2017-11-26 00:36:00 +08:00
CYBAI
20cfefbbbd style: Move -moz-script-size-multiplier outside of mako 2017-11-23 10:26:50 +08:00
CYBAI
d671859426 style: Move -x-lang outside of mako 2017-11-21 23:46:34 +08:00
CYBAI
dcdc384122 Implement normal for FontSettings 2017-11-20 21:38:50 +08:00
CYBAI
70033edccd style: Move font-feature-settings outside of mako 2017-11-20 11:26:09 +08:00
CYBAI
a38de8b540 style: Move font-variant-numeric outside of mako 2017-11-18 17:57:22 +08:00
CYBAI
3ff497aaff style: Move font-variant-ligatures outside of mako 2017-11-17 10:12:46 +08:00
CYBAI
c110c8a131 style: Move font-variant-east-asian outside of mako 2017-11-15 21:27:12 +08:00
CYBAI
c561c2cb9b style: Move font-variation-settings outside of mako 2017-11-14 19:56:27 +08:00
CYBAI
38eae70666 style: Move font-language-override outside of mako 2017-11-13 23:15:09 +08:00
Emilio Cobos Álvarez
194c2712b5
style: Make MozScriptLevel::Absolute serialize as -moz-absolute(foo). 2017-11-12 16:25:01 +01:00
CYBAI
aeae3113bf style: Move font-variant-alternates outside of mako 2017-11-11 02:21:12 +08:00
CYBAI
b5370aa688 style: Move font-synthesis outside of mako 2017-11-10 09:00:31 +08:00
CYBAI
e73f2377cf style: Move font-size-adjust outside of mako 2017-11-08 23:40:23 +08:00
CYBAI
0f57d250bb style: Move font-size outside of mako 2017-11-08 14:31:06 +08:00
CYBAI
d316c55590 style: Move font -moz-script-level outside of mako 2017-11-03 09:49:19 +08:00
Connor Brewster
f37859375e style: Cleanup font-weight parsing. 2017-11-01 17:04:40 -05:00
Connor Brewster
285d8bb58b style: Move font-weight outside of mako 2017-11-01 11:06:40 -05:00
Emilio Cobos Álvarez
ed9cf6b4eb
style: Avoid double-applying text-zoom for keywords.
Bug: 1412743
Reviewed-by: Manishearth
2017-10-31 20:20:55 +01:00
CYBAI
63cd930fd0 style: Move font -moz-script-min-size outside of mako 2017-10-31 00:44:55 +08:00
CYBAI
cefc622e9b style: Move -x-text-zoom outside of mako 2017-10-27 02:32:59 +08:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.
2017-10-18 22:20:37 +11:00
Manish Goregaokar
b238eae66c Add FIXME for font-size animated value 2017-09-24 00:47:54 -07:00
Manish Goregaokar
ce7d82e9c4 stylo: Animate font-size as NonNegativeLength 2017-09-23 16:22:42 -07:00