Commit graph

956 commits

Author SHA1 Message Date
Philipp Zech
5af0d7ca7c
style: Remove StyleFontSize enum from nsStyleConsts.h.
Differential Revision: https://phabricator.services.mozilla.com/D77511
2020-06-18 23:51:14 +02:00
longsonr
4359aae44e style: Don't apply minimum font sizes to SVG text.
Differential Revision: https://phabricator.services.mozilla.com/D74581
2020-06-04 01:50:36 +02:00
Philipp Zech
709c52fefb style: Convert style-font #defines to an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D73728
2020-06-04 01:50:36 +02:00
Mats Palmgren
6f58c66589 style: Implement style system support for Masonry layout.
This implements support for this CSS Masonry layout proposal:
https://github.com/w3c/csswg-drafts/issues/4650

I've intentionally left out a shorthand (place-tracks?) for now until
we have a draft CSS spec for this.

Differential Revision: https://phabricator.services.mozilla.com/D67061
2020-06-04 01:50:36 +02:00
Cameron McCormack
c55cd22339 style: Assert that initial values in style structs match those in property definitions.
Differential Revision: https://phabricator.services.mozilla.com/D67930
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
7af9a087aa style: Use enums for text-align / text-align-last.
This also fixes some backwards logic in nsBlockFrame::ReflowDirtyLines, and adds
some static assertions to nsGenericHTMLElement that almost cause a very subtle
bug.

Depends on D63792

Differential Revision: https://phabricator.services.mozilla.com/D63793
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
582ccf4778 style: Minor cleanup of gecko.mako.rs.
Differential Revision: https://phabricator.services.mozilla.com/D63779
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
76e9cb44f0 style: Use cbindgen for SVG lengths.
Depends on D63777

Differential Revision: https://phabricator.services.mozilla.com/D63778
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
18570bf077 style: Use cbindgen for cursors.
Pretty straight-forward.

Differential Revision: https://phabricator.services.mozilla.com/D63777
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
ab03688994 style: Use cbindgen for shape-outside and clip-path.
Differential Revision: https://phabricator.services.mozilla.com/D62372
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
558cc59288 style: Use cbindgen instead of nsStyleImage.
The trickier part is that we represent -moz-image-rect as a Rect() type instead
of image with non-null clip-rect. So we need to add a bit of code to
distinguish "image request types" from other types of images.

But it's not too annoying, and we need to do the same for fancier images like
image-set and such whenever we implement it, so seems nice to get rid of
most explicit usages of nsStyleImage::GetType().

Differential Revision: https://phabricator.services.mozilla.com/D62164
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
4dadcf71a5 style: Some preparation to start using cbindgen for shape-outside and clip-path.
Tweak the ShapeSourceRepresentation so that it doesn't store Option<>s.

Some renames so that GeometryBox doesn't conflict with the Gecko type, and some
other usual bits / re-exports to deal with cbindgen and generics.

Also, drive-by derive parsing of GeometryBox as it's trivial.

Doing this unfortunately is not possible without removing nsStyleImage first, so
let's do that before.

This makes us serialize in the shortest form for shape-outside, but that's what
we should do anyway.

(aside: the shapes code is a bit too generic, maybe we should unify
ClippingShape and FloatAreaShape...)

Differential Revision: https://phabricator.services.mozilla.com/D62163
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
149cb5f5f1 style: Merge ImageLayer and Image.
ImageLayer is almost the only usage of Image, so keeping them in the same enum
makes the resulting C++ struct smaller, and makes it map more cleanly to
nsStyleImage.

Differential Revision: https://phabricator.services.mozilla.com/D62161
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
97382a2c41
style: Remove nsStyleImageRequest.
This removes nsStyleImageRequest by moving the load state to LoadData instead
(where other lazy state like the resolved URL and load id lives).

That way we can use cbindgen for more stuff (there's no blocker for using it for
all images now), and we can undo the image tracking shenanigans that I had to do
in bug 1605803 in nsImageFrame.

This removes the mDocGroup member because well, there's no real upside of that
now that quantum DOM is not a thing.

It also removes the static clones of the image requests, and the need for each
computed value instance to have its own request. These were needed because we
needed the image loader for the particular document to observe the image
changes. But we were also tracking the request -> loader for other purposes.
Instead, Now all the images get loaded with GlobalImageObserver as a listener,
which looks in the image map and forwards the notification to all the interested
loaders instead dynamically.

The style value is only responsible to load the image, and no longer tracks /
locks it. Instead, the loader does so, via the image tracker.

Differential Revision: https://phabricator.services.mozilla.com/D58519
2020-02-12 02:43:20 +01:00
Thomas Dolezal
625170ddd4
style: Replace transform style defines to an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D61388
2020-02-12 02:43:18 +01:00
Emilio Cobos Álvarez
16fd7cad0c
style: Add a style flag for the root element style.
This is needed to make the root element not a containing block in presence of
filters or what not.

Differential Revision: https://phabricator.services.mozilla.com/D61167
2020-02-12 02:43:18 +01:00
Emilio Cobos Álvarez
2bdcd766bb
style: Use cbindgen for css-align types.
This provides stronger typing and removes a bunch of subtle constants matching.

Differential Revision: https://phabricator.services.mozilla.com/D61058
2020-02-12 02:43:17 +01:00
Emilio Cobos Álvarez
219c0f6328
style: Use cbindgen for content property.
This cleans up and also allows us to keep the distinction between content: none
and content: normal, which allows us to fix the computed style we return from
getComputedStyle().

Do this last bit from the resolved value instead of StyleAdjuster, because
otherwise we need to tweak every initial struct for ::before / ::after.

Differential Revision: https://phabricator.services.mozilla.com/D58276
2020-02-12 02:43:08 +01:00
Emilio Cobos Álvarez
789ddd9dc1 style: Make LengthPercentage not copy.
This is needed to support min() / max() / clamp(), etc.

Differential Revision: https://phabricator.services.mozilla.com/D57249
2019-12-16 14:23:56 +01:00
Emilio Cobos Álvarez
a541046147 style: Use less Au in font code.
Font code is the only thing that was using Au in the style system without
interfacing with Gecko, and there was no real reason for it to do so.

This slightly simplifies the code.

Differential Revision: https://phabricator.services.mozilla.com/D57248
2019-12-16 14:23:56 +01:00
Emilio Cobos Álvarez
c28ca7b405
style: Use MaybeUninit in style struct clone impls / constructors.
Differential Revision: https://phabricator.services.mozilla.com/D51788
2019-11-30 20:44:57 +01:00
Emilio Cobos Álvarez
fc1233f3d2 style: Remove -moz-binding, nsStyleDisplay::mBinding and similar.
Differential Revision: https://phabricator.services.mozilla.com/D50556
2019-11-04 13:36:32 +01:00
Emilio Cobos Álvarez
987a1eeb62 style: Use cbindgen for counters.
Differential Revision: https://phabricator.services.mozilla.com/D44403
2019-09-12 22:34:16 +02:00
Mats Palmgren
f7a87c49b1 style: [css-lists-3] Make 'none' invalid as a <counter-style> in counter()/counters().
CSSWG resolution:
https://github.com/w3c/csswg-drafts/issues/4163#issuecomment-521331100

Spec:
https://drafts.csswg.org/css-lists-3/#counter-functions

Differential Revision: https://phabricator.services.mozilla.com/D43893
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
b238698691 style: Use cbindgen for clip / -moz-image-region.
This also fixes some of the issues with -moz-image-region, where we just minted
an auto out of the blue.

Differential Revision: https://phabricator.services.mozilla.com/D43474
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
53cd37ce39 style: Remove old warning allow which is no longer relevant.
-moz-appearance uses cbindgen since a long time ago.

Differential Revision: https://phabricator.services.mozilla.com/D43472
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
ee106992e1 style: Simplify -x-span property.
Differential Revision: https://phabricator.services.mozilla.com/D42914
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
432b417d98 style: Avoid manual paint-order glue code.
Differential Revision: https://phabricator.services.mozilla.com/D42913
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
14c7e133ad style: Avoid some signed -> unsigned conversions for box-ordinal-group.
This is consistent with the `order` property anyhow, and allows to simplify some
code.

Negatives are still not parsed, but rust uses a similar representation for all
CSS <integer> values and so should C++.

Differential Revision: https://phabricator.services.mozilla.com/D42912
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
7c4dc9e797 style: Make font-variant-alternates use cbindgen.
Differential Revision: https://phabricator.services.mozilla.com/D42859
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
b8108eaa80 style: Remove unused impl_coord_copy.
Differential Revision: https://phabricator.services.mozilla.com/D42857
2019-09-12 22:34:16 +02:00
Emilio Cobos Álvarez
9404ac89b7 style: Don't clamp font-size calc() factors too early.
These two bugs (bug 1572738 and bug 1572451) are stylo regressions.

When font-family changes, we try to recompute the font-size with a length /
percentage combinations in case the generic family changes, so the user
preferences are kept.

When calc() is involved, we clamp to non-negative too early, via
NonNegativeLength::scale_by.

I think we should generally dump this "try to track font-size across calc()"
thingie, as as various comments note it is not quite perfect, and it's not clear
how it should work in presence of min()/max().

This patch fixes the issue and simplifies code a bit, I may consider removing
this altogether in a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D41776
2019-09-12 22:07:45 +02:00
Emilio Cobos Álvarez
7f02662770
style: Use cbindgen for text-emphasis-style.
I sent https://github.com/eqrion/cbindgen/pull/377 since I got sick of
copy-pasting the private default constructor stuff :)

Differential Revision: https://phabricator.services.mozilla.com/D41419
2019-08-15 17:01:14 +02:00
Emilio Cobos Álvarez
fa06241ab6
style: Simplify text-emphasis-style.
Differential Revision: https://phabricator.services.mozilla.com/D41418
2019-08-15 17:01:06 +02:00
Emilio Cobos Álvarez
69191d8b8c
style: Don't write manual glue code for the order property.
The default code works just as well.

Differential Revision: https://phabricator.services.mozilla.com/D40698
2019-08-15 17:00:18 +02:00
Emilio Cobos Álvarez
3e39998068
style: Refactor grid types to preserve repeat() at computed value time and use cbindgen.
I'm _really_ sorry for the size of the patch. I tried to do this in two steps
but it was a lot of work and pretty ugly.

This patch makes us use cbindgen for grid-template-{rows,columns}, in order to:

 * Make us preserve repeat() at computed-value time. This is per spec since
   interpolation needs to know about repeat(). Except for subgrid, which did the
   repeat expansion at parse-time and was a bit more annoying (plus it doesn't
   really animate yet so we don't need it to comply with the spec).

 * Tweaks the WPT tests for interpolation to adopt the resolution at:
   https://github.com/w3c/csswg-drafts/issues/3503.

Trade-off here, as this patch stands, is that this change makes us use less
long-living memory, since we expand repeat() during layout, but at the cost of a
bit of CPU time during layout (conditional on the property applying though,
which wasn't the case before). It should be very easy to store a cached version
of the template, should this be too hot (I expect it isn't), or to change the
representation in other ways to optimize grid layout code if it's worth it.

Another trade-off: I've used SmallPointerArray to handle line-name merging,
pointing to the individual arrays in the style data, rather than actually
heap-allocating the merged lists. This would also be pretty easy to change
should we measure and see that it's not worth it.

This patch also opens the gate to potentially improving memory usage in some
other ways, by reference-counting line-name lists for example, though I don't
have data that suggests it is worth it.

In general, this patch makes much easier to tweak the internal representation of
the grid style data structures. Overall, I think it's a win, the amount of magic
going on in that mako code was a bit huge; it took a bit to wrap my head around
it.

This patch comments out the style struct size assertions. They will be
uncommented in a follow-up patch which contains some improvements for this type,
which are worth getting reviewed separately.

Also, this patch doesn't remove as much code as I would've hoped for because of
I tried not to change most of the dom/grid code for inspector, but I think a
fair bit of the nsGridContainerFrame.cpp code that collects information for it
can be simplified / de-copy-pasted to some extent. But that was a pre-existing
problem and this patch is already quite massive.

Differential Revision: https://phabricator.services.mozilla.com/D36598
2019-08-15 16:58:44 +02:00
Emilio Cobos Álvarez
46236d015b
style: Fix some issues with #23856 in Gecko. 2019-07-30 12:06:26 +02:00
bors-servo
8f7440f368
Auto merge of #23827 - emilio:gecko-sync, r=emilio,manishearth
style: Sync changes from mozilla-central, and update euclid

See individual commits for details.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23827)
<!-- Reviewable:end -->
2019-07-23 18:42:00 -04:00
Emilio Cobos Álvarez
137044a3db
style: Update animations when a pseudo-element had animations but no longer has, and has been re-framed in the meantime.
This is the easy fix.

The hard fix (outlined in the comment) would be nice, but I don't think this bug
alone justifies it.

Differential Revision: https://phabricator.services.mozilla.com/D38184
2019-07-23 22:54:06 +02:00
Simon Sapin
17ec774a49 Stylo: replace uses of mem::uninitialized with MaybeUninit
MozReview-Commit-ID: KGhYL6DJRaR
2019-07-16 08:03:54 +02:00
Emilio Cobos Álvarez
03a8e57b9c
style: Appease tidy. 2019-07-08 12:58:20 +02:00
Emilio Cobos Álvarez
341023690c
style: Use cbindgen for fill and stroke.
Differential Revision: https://phabricator.services.mozilla.com/D36807
2019-07-08 12:46:46 +02:00
Emilio Cobos Álvarez
83da7c1535
style: Simplify parsing and storage of SVG paint server fallback. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D36806
2019-07-08 12:46:39 +02:00
Emilio Cobos Álvarez
cc15afa348
style: Use cbindgen for grid track sizing.
Differential Revision: https://phabricator.services.mozilla.com/D36118
2019-07-08 12:45:21 +02:00
Emilio Cobos Álvarez
87e3dadf22
style: Use the cbindgen representation for grid line properties.
We clamp earlier (parse time rather than computed value time), but that's the
only behavior change, which I think doesn't really matter.

Differential Revision: https://phabricator.services.mozilla.com/D35198
2019-07-08 12:43:39 +02:00
Emilio Cobos Álvarez
98091243a7
style: Use a more similar representation in Rust and C++ for grid lines.
Option<> is not FFI-safe, so if we want to use the same representation
everywhere we need to get rid of it. This also makes it take the same amount of
memory as the C++ representation, and it's not very complex, I'd think.

Differential Revision: https://phabricator.services.mozilla.com/D35195
2019-07-08 12:43:07 +02:00
Emilio Cobos Álvarez
c87da27bca
style: Use atoms for grid line names.
The style system already atomizes all CustomIdent values, which means that we're
just wasting memory and CPU by doing string copies all over the place.

This patch fixes it. This also simplifies further changes to use as much of the
rust data structures as possible.

I had to switch from nsTHashtable to mozilla::HashTable because the former
doesn't handle well non-default-constructible structs (like NamedLine, which
now has a StyleAtom, which is not default-constructible).

Differential Revision: https://phabricator.services.mozilla.com/D35119
2019-06-25 13:11:31 +02:00
Emilio Cobos Álvarez
6cb588d2b5
style: Use Servo for the representation of grid template areas.
Right now we do a lot of useless string copying. In order to avoid transcoding
to utf-16 during layout, make sure to use nsCString at a few related places.

I may revisit this since we're storing other line names as atoms in some places.
So it may be better to just use atoms everywhere.

But that'd be a different patch either way.

Differential Revision: https://phabricator.services.mozilla.com/D35117
2019-06-25 13:11:30 +02:00
Emilio Cobos Álvarez
e8271ee926
style: Use more ffi-friendly types in grid template areas.
Differential Revision: https://phabricator.services.mozilla.com/D35116
2019-06-25 13:11:30 +02:00
Emilio Cobos Álvarez
a4690ce158
style: Use cbindgen for gradients.
Differential Revision: https://phabricator.services.mozilla.com/D33901
2019-06-25 13:11:27 +02:00