Commit graph

6936 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
d12d420974
style: Adjust an assertion to account for the changes from bug 1485930. 2018-09-03 12:32:31 +02:00
Boris Chiou
68ab6217bd
style: Use cbindgen for basic_shape::FillRule.
Just a minor fix to use cbindgen to avoid the conversion between
basic_shape::FillRule and mozilla::StyleFillRule.

Differential Revision: https://phabricator.services.mozilla.com/D4171
2018-09-03 12:32:25 +02:00
Boris Chiou
e46daa09ea
style: Drop the manually implementation of ToCSS for BasicShape::Polygon.
The implementation of ToCSS for Polygon has some rule, and we could use skip_if
to handle and serialization of fill-rule. However, we should derive ToCSS for
the pair of LengthOrPercentages, so define a new type for it.

Differential Revision: https://phabricator.services.mozilla.com/D4153
2018-09-03 12:32:17 +02:00
Xidorn Quan
c587fa3586
style: Make tree pseudo-element prefix not case-sensitive.
Differential Revision: https://phabricator.services.mozilla.com/D4185
2018-09-03 12:32:10 +02:00
Emilio Cobos Álvarez
dceb58664e
style: Remove an assertion that doesn't hold in some cases. 2018-09-03 12:32:05 +02:00
Emilio Cobos Álvarez
86b4b70369
style: Make the counters non-atomic counters and merge afterwards.
This was consistently faster in the benchmark (even when counters were disabled,
which was slightly suspicious, but...).

Anyway, it's not really much code, most of it is FFI copy-pasta.

Differential Revision: https://phabricator.services.mozilla.com/D3874
2018-09-03 12:31:48 +02:00
Emilio Cobos Álvarez
4f04988c13
style: Add a test for the use counters.
Mostly testing that they work, and that they record what we expect them to
record, that is, the actual property that was parsed, and not the properties
that it'd resolve or expand to.

That may be another tricky part for CSSOM, I think style setters would fail an
alias test if implemented with the current setup (we do the property lookup in
C++).

Differential Revision: https://phabricator.services.mozilla.com/D3829
2018-09-03 12:31:41 +02:00
Emilio Cobos Álvarez
89b8f30737
style: Hook the use counters into StyleSheet parsing.
Still not hooked into telemetry, I talked with :janerik and :gfritzsche about
that, but test incoming!

This intentionally doesn't handle CSSOM and such for now, will file followups
for those, though should be trivial.

I want to unify / clean up how we do the use counters and the error reporting
stuff for CSSOM, since the current function call still shows up in profiles,
but that should be a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D3828
2018-09-03 12:31:33 +02:00
Emilio Cobos Álvarez
c8e5b7f1b0
style: Add a very simple use counter implementation.
As simple as I could make it, for now. We can improve on this.

Differential Revision: https://phabricator.services.mozilla.com/D3827
2018-09-03 12:31:23 +02:00
Emilio Cobos Álvarez
c3a4b27441
style: Remove useless StyleDisplay conversion.
Differential Revision: https://phabricator.services.mozilla.com/D3896
2018-09-03 12:31:18 +02:00
Emilio Cobos Álvarez
ae671a7d26
style: Use a consistent style for longhands.
It's a bit of a mess.

Differential Revision: https://phabricator.services.mozilla.com/D3892
2018-09-03 12:31:10 +02:00
Emilio Cobos Álvarez
a2d6566d0b
style: Make text-orientation, unicode-bidi, contain and will-change non-animatable.
Per recent CSSWG resolutions:

  https://github.com/w3c/csswg-drafts/issues/2737
  https://github.com/w3c/csswg-drafts/issues/2751

Differential Revision: https://phabricator.services.mozilla.com/D3888
2018-09-03 12:31:04 +02:00
Emilio Cobos Álvarez
e338bd3add
style: Serialize clip-path and shape-outside using Servo.
Differential Revision: https://phabricator.services.mozilla.com/D3653
2018-09-03 12:30:57 +02:00
Boris Chiou
b85c734c41
style: Use macro for path parser.
There are a lot of duplicates, so we use macro to refine them.

Depends on D2963

Differential Revision: https://phabricator.services.mozilla.com/D2966
2018-09-03 12:30:38 +02:00
Boris Chiou
dce2e2927f
style: Define offset-path and implement it in style system.
Define OffsetPath & SVGPathData on the servo-side, and StyleMotion &
StyleSVGPath on the gecko-side. We parse the SVG Path string into a
vector of PathCommand. To build the gfx::Path, we will convert it into
gfx::Path later in a different patch.

The basic flow is:
  - Parse SVG Path String into SVGPathData (in Rust).
  - Use cbindgen to make sure the layout of PathCommand and StylePathCommand, and then set the Box[PathCommand] into nsTArray<StylePathCommand>.
  - Try to convert nsTArray<StylePathCommand> into gfx::Path. (This part will be implemented in a different patch.)

Finally, we use the gfx::Path to create a motion path transform.
The layout implementation is in the later patch.

Depends on D2962

Differential Revision: https://phabricator.services.mozilla.com/D2963
2018-09-03 12:30:21 +02:00
Cameron McCormack
249b865eb8
style: Simplify PropertyDeclarationBlock::get a little.
Depends On D3747

Differential Revision: https://phabricator.services.mozilla.com/D3748
2018-09-03 12:30:12 +02:00
Cameron McCormack
b20bbea033
style: Replace NormalDeclarationIterator return type with impl Trait.
Differential Revision: https://phabricator.services.mozilla.com/D3747
2018-09-03 12:30:01 +02:00
Simon Sapin
bcc1b25fd9 Update bindgen to 0.39.0
This fixes a build error for i686-linux-android with some versions of libclang:

```
error[E0560]: struct `generated::root::JS::Value` has no field named `__bindgen_align`sys
  --> /home/simon/projects/mozjs/src/jsval.rs:83:2
   |
83 |     __bindgen_align: [],
   |     ^^^^^^^^^^^^^^^ `generated::root::JS::Value` does not have this field
   |
   = note: available fields are: `data`

error: aborting due to previous error
```
2018-08-24 20:22:27 +02:00
Craig Disselkoen
916e2c206d Remove outdated comment in stylist.rs 2018-08-22 13:26:39 -07:00
Emilio Cobos Álvarez
38a00745e2
Appease tidy. 2018-08-18 18:41:40 +02:00
Emilio Cobos Álvarez
935b5393a9
Port servo to the new media query system.
Port `width`, and also add the `scan` media feature so I don't need to add
ugliness just to workaround the unused keyword_evaluator macro.
2018-08-18 18:23:26 +02:00
Emilio Cobos Álvarez
4d3f96f562
style: Relax the version requirement of num-integer. 2018-08-18 17:58:44 +02:00
Emilio Cobos Álvarez
67f2185f54
style: Make webkit device-pixel-ratio media queries a proper alias to resolution.
According to the spec:

  https://compat.spec.whatwg.org/#css-media-queries-webkit-device-pixel-ratio

And to the Chromium implementation:

  https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/media_query_evaluator.cc?l=366&rcl=1d7328865bcf06a687aafc18ff95d55317030672

They're no different than resolution.

In our implementation `resolution` does slightly different stuff. Given we
still haven't shipped -webkit-device-pixel-ratio, making this match resolution
looks better than the opposite.

Differential Revision: https://phabricator.services.mozilla.com/D3588
2018-08-18 17:54:54 +02:00
Xidorn Quan
c9c5e56079
style: Use AspectRatio directly for RangeOrOperator::evaluate.
Differential Revision: https://phabricator.services.mozilla.com/D3587
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
d63ce552f7
style: Deduplicate system metric atoms.
Now that :-moz-system-metric is gone, there's no real reason for the atoms to
be separate.

Differential Revision: https://phabricator.services.mozilla.com/D3497
2018-08-18 17:54:54 +02:00
Xidorn Quan
cd4d281984
style: Add scrollbar-width property.
Bug: 1475033
Reviewed-by: heycam
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
9350fa4c55
style: Remove an inaccurate and useless debug message. 2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
e9a99b2a7f
style: Manually inline class and ID getters.
Somewhat ugly but hopefully not too much. Somehow it ends up removing more lines
than adding.

Differential Revision: https://phabricator.services.mozilla.com/D3536
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
fe05c8ecad
style: Add some spec links to media queries.
Differential Revision: https://phabricator.services.mozilla.com/D3489
2018-08-18 17:54:54 +02:00
Xidorn Quan
f1fe15981a
style: Simplify some code in NoCalcLength::parse_dimension.
Differential Revision: https://phabricator.services.mozilla.com/D3473
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
dc0f937224
style: Rewrite media queries so that they work on an evaluator function.
This moves most of the code to be Rust, except potentially some evaluator
functions, and allows to unblock the use case from any-hover / any-pointer and
remove nsMediaFeatures.

Differential Revision: https://phabricator.services.mozilla.com/D2976
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
a0cb37d29d
style: Simplify visited-related code in invalidation.
We match with AllLinksVisitedAndUnvisited for style invalidation, and we already
do a subtree restyle because :visited matching doesn't depend on the actual
element state.

So all this stuff is just not needed. The comment points to the attribute tests
in bug 1328509, but those still trivially pass with this change.

I think this was unneeded since I introduced AllLinksVisitedAndUnvisited, or
maybe since https://github.com/servo/servo/pull/19520. In any case it doesn't
really matter, and I already had done this cleanup in my WIP patches for
bug 1406622, but I guess this is a slightly more suitable place to land them :)

Differential Revision: https://phabricator.services.mozilla.com/D3305
2018-08-18 17:54:54 +02:00
Emilio Cobos Álvarez
87b1e1cdc9
style: no-op visited changes earlier if visited links are disabled.
We force a repaint from ContentStateChangedInternal if visited links are
disabled, and that's observable. Let's cut it off as early as we can to avoid
timing attacks even when :visited is disabled.

Differential Revision: https://phabricator.services.mozilla.com/D3304
2018-08-18 17:54:54 +02:00
Cameron McCormack
cc1897597c
style: Generate static atom hash in StaticAtoms.py.
Differential Revision: https://phabricator.services.mozilla.com/D3295
2018-08-18 17:54:54 +02:00
Cameron McCormack
f86e9a411a
style: Remove support for multiple static atom sources.
Differential Revision: https://phabricator.services.mozilla.com/D3285
2018-08-18 17:54:54 +02:00
Cameron McCormack
f75419dd7a
style: Move CSS anonymous box atoms to nsGkAtoms.
Differential Revision: https://phabricator.services.mozilla.com/D3284
2018-08-18 17:54:54 +02:00
Cameron McCormack
99a292dd6d
style: Move CSS pseudo-element atoms to nsGkAtoms.
Differential Revision: https://phabricator.services.mozilla.com/D3283
2018-08-18 17:54:54 +02:00
Cameron McCormack
cc3c059bfc
style: Define atom type in nsGkAtomList.h.
Differential Revision: https://phabricator.services.mozilla.com/D3282
2018-08-18 17:54:54 +02:00
Nathan Froyd
064252437b
style: remove unused kernel32-sys dependency from style.
Bug: 1483344
Reviewed-by: emilio
2018-08-18 17:49:21 +02:00
Henri Sivonen
0ec5db90a6
Use encoding_rs for XPCOM string encoding conversions.
Correctness improvements:

 * UTF errors are handled safely per spec instead of dangerously truncating
   strings.

 * There are fewer converter implementations.

Performance improvements:

 * The old code did exact buffer length math, which meant doing UTF math twice
   on each input string (once for length calculation and another time for
   conversion). Exact length math is more complicated when handling errors
   properly, which the old code didn't do. The new code does UTF math on the
   string content only once (when converting) but risks allocating more than
   once. There are heuristics in place to lower the probability of
   reallocation in cases where the double math avoidance isn't enough of a
   saving to absorb an allocation and memcpy.

 * Previously, in UTF-16 <-> UTF-8 conversions, an ASCII prefix was optimized
   but a single non-ASCII code point pessimized the rest of the string. The
   new code tries to get back on the fast ASCII path.

 * UTF-16 to Latin1 conversion guarantees less about handling of out-of-range
   input to eliminate an operation from the inner loop on x86/x86_64.

 * When assigning to a pre-existing string, the new code tries to reuse the
   old buffer instead of first releasing the old buffer and then allocating a
   new one.

 * When reallocating from the new code, the memcpy covers only the data that
   is part of the logical length of the old string instead of memcpying the
   whole capacity. (For old callers old excess memcpy behavior is preserved
   due to bogus callers. See bug 1472113.)

 * UTF-8 strings in XPConnect that are in the Latin1 range are passed to
   SpiderMonkey as Latin1.

New features:

 * Conversion between UTF-8 and Latin1 is added in order to enable faster
   future interop between Rust code (or otherwise UTF-8-using code) and text
   node and SpiderMonkey code that uses Latin1.

Bug: 1402247
Reviewed-by: Nika,erahm,froydnj
2018-08-18 17:48:29 +02:00
Xidorn Quan
916dc79dc9
style: Rename StyleUserInterface to StyleUI.
Differential Revision: https://phabricator.services.mozilla.com/D3276
2018-08-18 17:48:22 +02:00
Cameron McCormack
e305b5a1f8
style: Remove unused BorrowedAtom.
Differential Revision: https://phabricator.services.mozilla.com/D3159
2018-08-18 17:48:12 +02:00
L. David Baron
9206283f7e
style: Swap order of values in 'overflow' shorthand property.
Differential Revision: https://phabricator.services.mozilla.com/D3069
2018-08-18 17:48:02 +02:00
Xidorn Quan
f14a3edd7d
style: Use function pointer rather than Fn trait object for collect_property_completion_keywords.
Differential Revision: https://phabricator.services.mozilla.com/D2985
2018-08-18 17:47:56 +02:00
Xidorn Quan
c77ecd6984
style: Implement flow-relative values for resize property.
Differential Revision: https://phabricator.services.mozilla.com/D2908
2018-08-18 17:47:51 +02:00
Xidorn Quan
5299ce31aa
style: Make several more specified values Copy.
Differential Revision: https://phabricator.services.mozilla.com/D2932
2018-08-18 17:47:44 +02:00
Xidorn Quan
e22850dc85
style: Add check for non-Copy specified value to ensure specified_is_copy always returns the right result.
Differential Revision: https://phabricator.services.mozilla.com/D2931
2018-08-18 17:47:37 +02:00
Xidorn Quan
e7945bbfcb
style: Put overflow: -moz-scrollbar-* behind pref.
Differential Revision: https://phabricator.services.mozilla.com/D2845
2018-08-18 17:47:30 +02:00
Boris Chiou
c87668fcd5
style: Use union to wrap different shape-like types. r=xidorn
1. We will add more shape-like types in the future, so it's better to
   use union to reduce the memory usage.
2. Those shape-like types are mutual exclusive, so we could use union to
   wrap them.

Differential Revision: https://phabricator.services.mozilla.com/D2746
2018-08-18 17:47:24 +02:00
Bastien Orivel
71fd4477d6 Dedupe num-traits 2018-08-09 18:26:28 +02:00