Commit graph

3198 commits

Author SHA1 Message Date
bors-servo
6a3c3a4e18
Auto merge of #26447 - jdm:white-space-2020, r=nox
Layout 2020: Implement basic white-space: pre support

With these changes `<pre>` and `<br>` preserve spaces and force line breaks appropriately.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #26440
- [x] There are tests for these changes
2020-07-29 10:29:30 -04:00
Manish Goregaokar
139f240baf Enable clip property in layout 2020 2020-07-27 19:59:59 -07:00
Josh Matthews
d8b4dab4e3 Implement basic white-space: pre support for layout 2020. 2020-07-27 20:06:53 -04:00
Simon Sapin
b91e293819 Add layout support for list markers 2020-07-24 09:31:24 +02:00
Manish Goregaokar
1af5efc542 flexbox 2020: Enable align-self and align-items in CSS 2020-07-20 14:26:14 -07:00
Kagami Sascha Rosylight
d01648d637 Fix remaining flake8 warnings 2020-06-21 03:34:32 +02:00
Emilio Cobos Álvarez
97f29c893f
style: Fix gecko build. 2020-06-18 23:51:18 +02:00
Emilio Cobos Álvarez
33b548ae64
style: Use an enum class for LookAndFeel::FontID.
Differential Revision: https://phabricator.services.mozilla.com/D76696
2020-06-18 23:51:16 +02:00
neil
7b5953da95
style: Remove the layout.css.scrollbar-width.enabled and layout.css.scrollbar-color.enabled prefs.
Differential Revision: https://phabricator.services.mozilla.com/D78400
2020-06-18 23:51:16 +02:00
Emilio Cobos Álvarez
8f215a8444
style: Port the style crate to rust 2018.
Differential Revision: https://phabricator.services.mozilla.com/D80101
2020-06-18 23:51:15 +02:00
Cameron McCormack
9b980e2f49
style: Add telemetry for -moz-appearance usage.
Differential Revision: https://phabricator.services.mozilla.com/D77637
2020-06-18 23:51:15 +02:00
Emilio Cobos Álvarez
3884328ce3
style: Clear last_parsed_property_id right after successfully parsing the value.
Rather than waiting until parsing another id (successfully or
unsuccessfully).

If we error before we even get to PropertyId::parse, we'd incorrectly
associate the error with the wrong property, incorrectly omitting it
sometimes.

Differential Revision: https://phabricator.services.mozilla.com/D78260
2020-06-18 23:51:14 +02:00
Emilio Cobos Álvarez
685e749cfc
style: Switch all callsites of try() to try_parse() in the style crate.
Fully automated via:

  $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g'
  $ cd servo/components/style && cargo +nightly fmt

Differential Revision: https://phabricator.services.mozilla.com/D80099
2020-06-18 23:51:14 +02:00
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
Martin Robinson
36701e0223 Combine AnimationAndTransitionDeclarations and AnimationRules
These two structs are very similar, so we can combine them.
2020-06-16 19:25:52 +02:00
Matthias Deiml
b85a5dac5d Implement visibility for layout_2020 2020-06-14 00:31:37 +02:00
bors-servo
721271dcd3
Auto merge of #26697 - utsavoza:ugo/issue-11681/22-05-2020, r=jdm
Implement CanvasRenderingContext2d.fillText

The PR consists of broadly two main changes:
- Implementation of Canvas2dRenderingContext.font
- Basic implementation of Canvas2dRenderingContext.fillText

Although I am not fully sure about the long term goals for the canvas backend in Servo, I assumed limited scope for font and text handling (should support simple text drawing with font selection) in the current implementation as I believe a more complete implementation would eventually be brought in as a part of #22957.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #11681
- [x] There are tests for these changes
2020-06-12 13:43:51 -04:00
Utsav Oza
8372cf1bd8 Derive Serialize and Deserialize traits for font styles for #[cfg_attr(feature = "servo")] 2020-06-12 18:43:09 +05:30
bors-servo
d85c6ee341
Auto merge of #26838 - servo:flexbox, r=nox
Flexbox, the boring parts

I have a local branch starting to implement https://drafts.csswg.org/css-flexbox/#layout-algorithm. It’s not PR-ready yet, but it’s going to be large so here are some of the less interesting parts meaningful by themselves. Landing the module split in particular will help reduce merge conflicts.

CC https://github.com/servo/servo/issues/26639
2020-06-10 17:19:16 -04:00
Utsav Oza
c21fde3751 Implement CanvasRenderingContext2D.font property 2020-06-10 22:11:24 +05:30
Simon Sapin
dcd25a06da Enable (behind a pref) parsing of the flex-* properties 2020-06-10 08:38:36 +02:00
Martin Robinson
364235ac0c Include animations and transitions in the cascade
Instead of applying animations and transitions to styled elements,
include them in the cascade. This allows them to interact properly with
things like font-size and !important rules.
2020-06-09 11:41:07 +02:00
Martin Robinson
b875f14e86 Better computation of animation keyframes
This begins to address #26625 by properly applying CSS variables during
keyframe computation and no longer using `apply_declarations`. Instead,
walk the declarations, combining them into IntermediateComputedKeyframe,
maintaining declarations that modify CSS custom properties. Then compute
a set of AnimationValues for each keyframe and use those to produce
interpolated animation values.
2020-06-05 13:40:29 +02:00
Martin Robinson
83fa1b9eaa Cache animation computed values when animations change
Instead of recalculating the animation style every tick of an animation,
cache the computed values when animations change. In addition to being
more efficient, this will allow us to return animation rules as property
declarations because we don't need to consult the final style to produce
them.
2020-06-05 13:21:19 +02:00
Simon Sapin
29005e1626 Keep flex items in order-modified document order in the box tree 2020-06-04 13:19:53 +02:00
Emilio Cobos Álvarez
332aec212c style: Miscellaneous servo build fixes. 2020-06-04 01:50:36 +02:00
Mats Palmgren
1fcc00a11a style: Allow 'opacity' on ::first-letter/::first-line pseudos.
Differential Revision: https://phabricator.services.mozilla.com/D76387
2020-06-04 01:50:36 +02:00
Boris Chiou
fc9321bb23 style: Let aspect-ratio (css-sizing-4) support 'auto | <ratio>'.
In order to test its parsing and serialization, we expose it but protect
it behind a pref.

Besides, I would like to drop layout.css.aspect-ratio-number.enabled in
the next patch because the spec has been updated. It seems we don't have
to keep this pref and we should always use Number.

Differential Revision: https://phabricator.services.mozilla.com/D74955
2020-06-04 01:50:36 +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
Emilio Cobos Álvarez
ec6ecf7d21 style: Clean up cascade rule iteration. r=nordzilla
The current API was pretty awkward as a result of two things:

 * Not being able to create empty iterators for smallbitvec.
 * We used to call the `F` function multiple times, but turns out that
   collecting the declarations in a SmallVec was a perf win.

So clean this up so that it looks more similar to other APIs, taking an
iterator directly.

This is a bit more code, but hopefully easier to understand (and also hopefully
easier to optimize).

The motivation for this work is that I plan to investigate rebasing / landing
https://github.com/servo/servo/pull/20151, and I don't want more instantiations
of apply_declarations and such.

Differential Revision: https://phabricator.services.mozilla.com/D74369
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
Emilio Cobos Álvarez
c67c9fdcee style: Only override to default color in high-contrast / forced-colors mode if inheriting from transparent.
That way elements inside links, form controls, etc have the right
contrast, even if the page overrides the color.

We can't do it when inheriting from transparent because we've already
forgotten about the "right" color to inherit, so the default color makes
sense. But that is a pretty unlikely edge case.

Differential Revision: https://phabricator.services.mozilla.com/D73069
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
Daniel Holbert
cd63d7b272 style: Remove pref for CSS Containment (layout.css.contain.enabled) r=AlaskanEmily
(Since we've been shipping with it default-enabled for a while now.)

See https://bugzilla.mozilla.org/show_bug.cgi?id=1466008#c9 through #c13 for
notes on the reftest.list change.

Differential Revision: https://phabricator.services.mozilla.com/D71861
2020-06-04 01:50:36 +02:00
Martin Robinson
a238597a18 layout_2020: Add support for transitions and animations 2020-05-19 10:02:03 +02:00
Martin Robinson
183f15d5aa Implement animation-fill-mode
Fixes #26460.
2020-05-17 20:42:57 +02:00
Martin Robinson
0f1831e2fa Remove AnimatedProperty
This removes an extra layer of abstraction and allows Servo to share
more code with Gecko. In addition, we will need to handle raw
`AnimationValue` structs soon in order to fully implement "faster
reversing of interrupted transitions."
2020-05-13 11:02:52 +02:00
Martin Robinson
fad79a724c Add an iterator for transition properties
This simplifies the code a bit and also will allow us to more easily
make improvements to servo's animation implementation in the future.
2020-04-17 15:11:49 +02:00
Emilio Cobos Álvarez
35f872e2d9 style: appease tidy. 2020-04-16 18:34:36 +02:00
Emilio Cobos Álvarez
7c96aed31d style: Sync some other changes. 2020-04-16 17:50:17 +02:00
Mike Hommey
7ec0e56848 style: Build mako-generated stylo rust sources deterministically.
Differential Revision: https://phabricator.services.mozilla.com/D70633
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
3aa38ff4c5 style: Update mako in the style system.
This uses Mako-1.1.2 wheel format, rather than zip, and works with py3 and py2.

It'd be great to make mako more like other third party python dependencies but
this allows me to build central again.

This is downloaded from:

  https://files.pythonhosted.org/packages/50/78/f6ade1e18aebda570eed33b7c534378d9659351cadce2fcbc7b31be5f615/Mako-1.1.2-py2.py3-none-any.whl

Via pip-download.

Differential Revision: https://phabricator.services.mozilla.com/D70517
2020-04-16 16:35:07 +02:00
Mike Hommey
07c1b39637 style: Convert GenerateServoCSSPropList.py to py3.
Differential Revision: https://phabricator.services.mozilla.com/D70308
2020-04-16 16:35:07 +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
Cameron McCormack
fa733ecb72 style: Fix a few initial values in Rust property definitions.
Differential Revision: https://phabricator.services.mozilla.com/D67929
2020-04-16 16:35:07 +02:00
Cameron McCormack
257b96c549 style: Make image-orientation initial value change be Nightly only.
We'll let this ride the trains once Chrome 81 is set to be released.

Differential Revision: https://phabricator.services.mozilla.com/D67932
2020-04-16 16:35:07 +02:00
Cameron McCormack
53f7e45285 style: Add support for pref-controlled initial values.
Differential Revision: https://phabricator.services.mozilla.com/D67931
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
3cb019ac1e style: Tweak background: transparent handling so that color: transparent doesn't override UA sheet backgrounds.
Differential Revision: https://phabricator.services.mozilla.com/D68408
2020-04-16 16:35:07 +02:00
Philipp Zech
9fd243bb39 style: Convert control-character-visibility #defines to an enum class.
Differential Revision: https://phabricator.services.mozilla.com/D68705
2020-04-16 16:35:07 +02:00
Emilio Cobos Álvarez
414edb5a4a style: Simplify the implementation of HasAuthorSpecifiedRules.
This patch computes the author-specified properties during the CSS cascade, and
removes the complex rule-tree-based implementation that tries to do the cascade
again.

This changes behavior in two ways, one of them which is not observable to
content, I believe:

 * revert now re-enables the native styling. This was brought up in
   https://github.com/w3c/csswg-drafts/issues/4777 and I think it is a bug-fix.

   This is observable to content, and I'm adding a test for it.

 * We don't look at inherited styles from our ancestors when `inherit` is
   specified in a non-author stylesheet. This was introduced for bug 452969 but
   we don't seem to inherit background anymore for file controls or such. It
   seems back then file controls used to have a text-field.

   I audited forms.css and ua.css and we don't explicitly inherit
   padding / border / background-color into any nested form control.

We keep the distinction between border/background and padding, because the later
has some callers. I think we should try to align with Chromium in the long run
and remove the padding bit.

We need to give an appearance to the range-thumb and such so that we can assert
that we don't call HasAuthorSpecifiedRules on non-themed stuff. I used a new
internal value for that.

Differential Revision: https://phabricator.services.mozilla.com/D67722
2020-04-16 16:35:07 +02:00