Commit graph

23312 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
d5b49f14da
style: Fix LengthPercentage on big-endian machines.
Always store the pointer in little-endian order so that the tag trick works.

Differential Revision: https://phabricator.services.mozilla.com/D61386
2020-02-12 02:43:24 +01:00
Emilio Cobos Álvarez
071ce6f345
style: Rustfmt recent changes. 2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
1754c832d8
layout_2020: Avoid decomposing mixed length / percentages in intrinsic sizing.
As that makes no sense in presence of min / max.
2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
f03026b869
layout: Resolve word_spacing ahead of time.
It's not possible anymore, in the presence of min() / max(), to split a
<length-percentage> value into a <length> and a <percentage> component.

Tweak word_spacing to do what Gecko does (resolving it in advance).
2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
e227715aee
style: Miscellaneous Servo build fixes. 2020-02-12 02:43:23 +01:00
Emilio Cobos Álvarez
8c6fe09dce
style: Fix Servo build. 2020-02-12 02:43:22 +01:00
Emilio Cobos Álvarez
cccac2cedd
malloc_size_of: Add a missing cfg guard. 2020-02-12 02:43:22 +01:00
Emilio Cobos Álvarez
1a22fa7b1d
style: Make rust generate better code for some of the functions introduced here.
See https://github.com/rust-lang/rust/issues/68867.

Differential Revision: https://phabricator.services.mozilla.com/D61760
2020-02-12 02:43:22 +01:00
Emilio Cobos Álvarez
3e14422788
style: Add some calc infrastructure to deal with simplification / sorting / etc.
For now, we still bail out at the stage of getting the calc node into a
CalcLengthPercentage if we couldn't simplify the min() / max() / clamps()
involved.

After this plan is to use just CalcNode everywhere instead of
specified::CalcLengthPercentage, and then modify the computed
CalcLengthPercentage, which would look slightly different as we know all the sum
terms for those are a struct like { Length, Percentage, bool has_percentage } or
such, so all the simplification code for that becomes much simpler, ideally.

Or we could turn CalcNode generic otherwise, if it's too much code... We'll see.

Differential Revision: https://phabricator.services.mozilla.com/D61739
2020-02-12 02:43:21 +01:00
Emilio Cobos Álvarez
71b414f9dc
style: Make rust generate better code for derive(Animate) and derive(ComputeSquaredDistance).
See https://github.com/rust-lang/rust/issues/68867.

This technically changes the semantics of #[animate(fallback)] and such when
combined with #[animate(error)]. But no such combination exists and the new
semantics are perfectly reasonable as well, IMHO.

Differential Revision: https://phabricator.services.mozilla.com/D61761
2020-02-12 02:43:21 +01:00
Emilio Cobos Álvarez
6876fed6e0
style: Fix two issues with themed widgets in high contrast mode.
There were two issues with the existing code that we use to determine whether a
widget is styled or not.

First, it was using `color == Color::transparent()` instead of
`color.is_transparent()` to check for transparent backgrounds. That is not sound
as `Color::transparent()` is the literal value `rgba(0, 0, 0, 0)`, not the
`transparent` keyword, so the equality check would fail.

The other issue is that this function was early-returning false if that check
was returning false. It is a bug for this function to early-return false, as it
makes the result of the function dependent of the order of the declarations.

Differential Revision: https://phabricator.services.mozilla.com/D62060
2020-02-12 02:43:21 +01:00
Tim Nguyen
5ed8fe8ee2
style: Add AngleOrPercentage to style system.
Differential Revision: https://phabricator.services.mozilla.com/D62158
2020-02-12 02:43:21 +01: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
07027fc923
style: style: convert ns style position defines to enum class.
Differential Revision: https://phabricator.services.mozilla.com/D61958
2020-02-12 02:43:20 +01:00
Emilio Cobos Álvarez
48eff19ff3
style: Don't use a binary tree representation for calc() sums / products.
Keep a flat list of sum members. Simpify product and division ASAP.

I want to preserve the tree for a bit longer to implement min / max / clamp.
This doesn't do anything for it that we weren't doing already, but it helps to
eventually keep this specified representation and the equivalent computed
representation for <length-percentage> values.

Enable the tests for the comparison functions too, to prevent regressions.

Differential Revision: https://phabricator.services.mozilla.com/D61514
2020-02-12 02:43:20 +01:00
Emilio Cobos Álvarez
b038924d44
style: Try to collect some more crash information so that we can diagnose this better.
Differential Revision: https://phabricator.services.mozilla.com/D59704
2020-02-12 02:43:19 +01:00
Jonathan Kew
df01cec675
style: Move the from-font value from text-underline-offset to text-underline-position, as per recent spec changes, and fix interaction between position and offset.
Differential Revision: https://phabricator.services.mozilla.com/D59778
2020-02-12 02:43:19 +01:00
Jonathan Kew
2910ca6197
style: Support percentage values for the CSS text-decoration-thickness and text-underline-offset properties.
Differential Revision: https://phabricator.services.mozilla.com/D59777
2020-02-12 02:43:19 +01:00
Tim Nguyen
127755551d
style: Remove nsGroupBoxFrame (display: -moz-groupbox).
Differential Revision: https://phabricator.services.mozilla.com/D61422
2020-02-12 02:43:19 +01:00
Thomas Dolezal
561de2f748
style: Converting empty-cells defines into enum class.
Differential Revision: https://phabricator.services.mozilla.com/D61398
2020-02-12 02:43:18 +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
Jonathan Kew
f426b644ca
style: Don't apply text-combine-upright in sideways-* writing modes.
Differential Revision: https://phabricator.services.mozilla.com/D61326
2020-02-12 02:43:18 +01:00
Thomas Dolezal
6682f725cf
style: Replacing table-layout defines with an enum.
Differential Revision: https://phabricator.services.mozilla.com/D61260
2020-02-12 02:43:17 +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
Thomas Dolezal
41ae92e045
style: Convert image-rendering #defines to an enum class.
MANUAL PUSH: Contributor didn't use Phabricator and I don't want patch to rot
2020-02-12 02:43:17 +01:00
Martin McNickle
143184d807
style: Convert scroll-behavior #defines to an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D61164
2020-02-12 02:43:17 +01:00
Martin McNickle
c447395c66
style: Convert mask-type #defines to an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D60987
2020-02-12 02:43:16 +01:00
Emilio Cobos Álvarez
13d12d0d5f
style: Tweak background-color and color handling in ignored-colors mode.
We're resetting `color` to the default color when there's a declaration that
applies in order to make stuff like this:

<div style="color: transparent">
  <div style="color: red">
    Red
  </div>
</div>

To not show transparent. But the behavior we want is more like "override with
default color iff there's no other declaration that would set the color from an
user or UA sheet".

This implements that behavior, plus avoids it if we're not inheriting
from transparent, so that stuff like this preserves the behavior from before bug
844349:

<a href="foo">
  <span style="color: red">Should be the red color</span>
</a>

Differential Revision: https://phabricator.services.mozilla.com/D60391
2020-02-12 02:43:16 +01:00
Sakura Mochizuki
017d6f0416
style: Convert dominant-baseline #defines to an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D61046
2020-02-12 02:43:16 +01:00
Boris Chiou
9aed1de6a5
style: Make the empty svg path valid.
Per SVG2 spec, the EBNF allows the path data string to be empty.
An empty path data string disables rendering of the path.
Therefore, we should make path('') a valid path string.

The related spec issue: https://github.com/w3c/fxtf-drafts/issues/392.
Now we serialize `path("")` as `path("")` for offset-path and clip-path.

Differential Revision: https://phabricator.services.mozilla.com/D60771
2020-02-12 02:43:15 +01:00
Emilio Cobos Álvarez
3991ab9999
style: Make direction use an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D60857
2020-02-12 02:43:15 +01:00
Martin McNickle
55f76be5e2
style: Convert stroke-linejoin #defines to an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D60865
2020-02-12 02:43:15 +01:00
Emilio Cobos Álvarez
16e5331950
style: Simplify calc expressions earlier.
This simplifies a bit the code, and guarantees that all calc()s have percentages
and lengths.

I also wanted to remove unclamped_length() / specified_percentage() (for the
same reason as the above patch), but they're needed for animations for now. When
I implement min() / max() for <length-percentage> they'll be fixed.

Differential Revision: https://phabricator.services.mozilla.com/D60194
2020-02-12 02:43:15 +01:00
Emilio Cobos Álvarez
5237d4fac8
style: Forbid accessing the length and percentage parts of a LengthPercentage separately.
This is just not a thing you can do if you have min() / max() / etc, as the min
/ max value may depend on the percentage basis.

Differential Revision: https://phabricator.services.mozilla.com/D60168
2020-02-12 02:43:14 +01:00
Emilio Cobos Álvarez
e7e6e62ed3
style: Remove font-size calc() hack to propagate keyword information.
It does not make any sense with min() / max() / clamp. So just forget the
keyword info when calc() is used. This also removes a bit of complex / hacky
code.

Differential Revision: https://phabricator.services.mozilla.com/D60663
2020-02-12 02:43:14 +01:00
Boris Chiou
83daa7484d
style: Use Serde for OffsetRotate and PositionOrAuto.
Differential Revision: https://phabricator.services.mozilla.com/D60088
2020-02-12 02:43:14 +01:00
Boris Chiou
2b3ef3ff37
style: Use Serde for SVGOffsetPath.
Differential Revision: https://phabricator.services.mozilla.com/D60087
2020-02-12 02:43:14 +01:00
Boris Chiou
5ac08e4780
style: Use Serde for Transform.
Though this may make us use more space when serializing
StyleTransform, but we don't have to do extra conversion on the compostior
side, and this makes us easier to maintain the Rust type.

Differential Revision: https://phabricator.services.mozilla.com/D60045
2020-02-12 02:43:13 +01:00
Boris Chiou
238e9ca2fb
style: Use Serde for rotate, scale, and translate properties.
The only drawback is: we resolve LengthPercentage value before passing
translate property through IPC, so its percentage part is redundant.
However, this makes us easier to maintain the Rust type.

Differential Revision: https://phabricator.services.mozilla.com/D60044
2020-02-12 02:43:13 +01:00
Ting-Yu Lin
5043695c78
style: Remove moz-prefixed aliases for column-gap and CSS multi-column properties.
Introduce a new pref "layout.css.prefixes.columns" to guard the prefixed
aliases.

The modification to `properties-db.js` was generated by
`./mach devtools-css-db`.

Differential Revision: https://phabricator.services.mozilla.com/D59564
2020-02-12 02:43:13 +01:00
Emilio Cobos Álvarez
9817ca386c
style: Remove lazy_static usage from custom_properties.rs.
Differential Revision: https://phabricator.services.mozilla.com/D60039
2020-02-12 02:43:13 +01:00
Emilio Cobos Álvarez
6fa03e1d04
style: Implement min() / max() / clamp() for simple css types behind a pref.
So for everything but <length> and <length-percentage>, which have more complex
mechanics.

The pref is off for now of course.

Differential Revision: https://phabricator.services.mozilla.com/D60012
2020-02-12 02:43:12 +01:00
Emilio Cobos Álvarez
d74f90e3a7
style: Centralize calc function parsing.
So that extending it to support other math functions like min / max / etc is
simpler.

There should be no behavior change with this patch, though I added a comment to
some places where we don't do calc() clamping correctly (though other browsers
don't either so...).

Differential Revision: https://phabricator.services.mozilla.com/D59939
2020-02-12 02:43:12 +01:00
Emilio Cobos Álvarez
9026720f04
style: Rewrite <input type=number> to avoid an anonymous input.
Instead, subclass nsTextControlFrame. This simplifies the code and avoids
correctness issues.

I kept the localization functionality though it is not spec compliant. But I
filed a bug to remove it in a followup.

Differential Revision: https://phabricator.services.mozilla.com/D57193
2020-02-12 02:43:12 +01:00
Emilio Cobos Álvarez
c569d314a5
style: Do not ignore color: transparent in high contrast mode.
PDFJS uses it, for example to allow text selection. It's not great if it shows
on top of the actual PDF :-)

Differential Revision: https://phabricator.services.mozilla.com/D58703
2020-02-12 02:43:11 +01:00
Makoto Kato
e9c14bb9fc
style: Don't use hardcoded value for safearea.
To implement safe area support on Gecko, we should get safe area from Device.

Differential Revision: https://phabricator.services.mozilla.com/D52504
2020-02-12 02:43:11 +01:00
Makoto Kato
80a1b64384
style: Part 2. Use Device for parameter instead of CssEnvironment.
CssEnvironment always is in Device, so use Device as parameter instead of CssEnvironment.

Differential Revision: https://phabricator.services.mozilla.com/D52507
2020-02-12 02:43:11 +01:00
Makoto Kato
c5bd98354d
style: Always use CssEnvironment from media query's device.
Although CssEnvironment is in Device of media query implementation, some code
creates CssEnvironment instance without Device. So I would like always to use it from Device of media query.

Differential Revision: https://phabricator.services.mozilla.com/D52506
2020-02-12 02:43:11 +01:00
Emilio Cobos Álvarez
88fe64d845
style: Pack LengthPercentage better.
So that it takes one pointer instead of two, and doesn't make nsStylePosition's
size blow up.

This is not as ugly as I was fearing, thankfully, though it requires a bit of
boilerplate. I think it's acceptable.

Differential Revision: https://phabricator.services.mozilla.com/D58702
2020-02-12 02:43:10 +01:00