Commit graph

6919 commits

Author SHA1 Message Date
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
Emilio Cobos Álvarez
689293e4fb
Fix Servo build. 2018-08-08 01:34:35 +02:00
Emilio Cobos Álvarez
6c5456b4b6
Appease tidy. 2018-08-08 01:34:35 +02:00
Emilio Cobos Álvarez
ffae32f844
style: Fixup some indentation. 2018-08-08 01:37:57 +02:00
Emilio Cobos Álvarez
0ae47b2659
style: Cleanup invalidation processor constructor.
It used to be this way because of lifetime issues (plus the shadow
datas were in RwLocks at some point IIRC). Now we guarantee that as long as the
element is away the cascade data is as well, so we don't need to thread it
around.

Differential Revision: https://phabricator.services.mozilla.com/D2768
2018-08-08 01:37:50 +02:00
Emilio Cobos Álvarez
bbcd7e414a
style: Remove unused selectors methods.
Differential Revision: https://phabricator.services.mozilla.com/D2767
2018-08-08 01:37:45 +02:00
Emilio Cobos Álvarez
489e224cb6
style: Don't print rerun-if-changed files until binding generation has succeeded.
Otherwise they may clobber useful output.

Differential Revision: https://phabricator.services.mozilla.com/D2783
2018-08-08 01:37:37 +02:00
Olli Pettay
87deddb631
style: Change storage of previous and next children in nsINode. 2018-08-08 01:37:28 +02:00
Emilio Cobos Álvarez
888ad3eabe
style: Restrict XUL tree pseudos on nightly and early-beta.
Differential Revision: https://phabricator.services.mozilla.com/D2598
2018-08-08 01:37:20 +02:00
Emilio Cobos Álvarez
998e6f1797
style: Remove the concept of 'canonical' pseudos.
We only have this so that ::-moz-placeholder keeps serializing as
::-moz-placeholder, but I don't think anybody really cares.

Edge aliases ::-webkit-input-placeholder to ::-ms-input-placeholder at parse
time as well, as can be seen in:

```
let s = document.createElement('style');
s.innerHTML = `input::-webkit-input-placeholder { color: red };`;
document.body.appendChild(s);
document.body.innerHTML = s.sheet.cssRules[0].cssText;
```

And I think this is more consistent with what we do for CSS properties that are
aliases.

Differential Revision: https://phabricator.services.mozilla.com/D2595
2018-08-08 01:37:07 +02:00
Cameron McCormack
62419adaaa
style: Shrink selectors::Component to 24 bytes.
This saves about 37 KiB of memory across the UA style sheets.

Bug: 1475197
Reviewed-by: emilio
2018-08-08 01:36:53 +02:00
Jonathan Watt
b05ace3e4a
style: Add a '-moz-menulist-button' value to '-moz-appearance'.
The '-moz-menulist-button' value currently behavies identically to the
'menulist-button' value.  This is not implemented as an alias because later
patches in this patch series will change the behavior of our pre-existing
'menulist-button' value to more closely match what Chrome does.

Bug: 1428676
Reviewed-by: emilio
2018-08-08 01:36:33 +02:00
Emilio Cobos Álvarez
bee7cbad0d
style: Micro-optimize is_root to avoid poking at the parent in the common case.
We can discard the common case of an element having another element or document
fragment parent, which is the common case.

Then we can discard detached subtrees looking at is_in_document().

The only case where we have a non-content parent is the document case:

  https://searchfox.org/mozilla-central/rev/033d45ca70ff32acf04286244644d19308c359d5/dom/base/Element.cpp#1683

Differential Revision: https://phabricator.services.mozilla.com/D2505
2018-08-08 01:36:25 +02:00
Emilio Cobos Álvarez
eb49995737
style: Convert GetStringValue to use Servo.
And remove gPropertyTable / kCSSRawProperties while at it.

Differential Revision: https://phabricator.services.mozilla.com/D2516
2018-08-08 01:36:18 +02:00
Emilio Cobos Álvarez
694d00eb5e
style: Implement nsCSSProps::LookupProperty using Rust.
Always assume allowed-for-all-content. There are a couple callers which weren't
doing that:

 * A unit test -> removed.

 * ComputeAnimationDistance: Used for testing (in transitions_per_property), and
   for the animation inspector. The animation inspector shouldn't show
   non-enabled properties. The transitions_per_property test already relies on
   getComputedStyle stuff which only uses eForAllContent.

 * GetCSSImageURLs: I added this API for the context menu page and such. It
   doesn't rely on non-enabled-everywhere properties, it was only using
   eInChrome because it was a ChromeOnly API, but it doesn't really need this.

Differential Revision: https://phabricator.services.mozilla.com/D2514
2018-08-08 01:36:10 +02:00
Emilio Cobos Álvarez
c3289ad46e
style: Improve logging for attribute changes.
And general Element logging. We now print all the attributes for comparison.

If this turns out to be too verbose we can change it to diff them or something.

Differential Revision: https://phabricator.services.mozilla.com/D2471
2018-08-08 01:36:03 +02:00
Emilio Cobos Álvarez
2e3aacdf80
style: Add a root bucket to the selector map.
:root can't change without getting unbound from the tree so no fancy stuff other
than that needed.

This removes a lot of revalidation and attribute invalidation matching from the
Chrome, and looks like it should be a good idea in general.

Differential Revision: https://phabricator.services.mozilla.com/D2462
2018-08-08 01:35:54 +02:00
Emilio Cobos Álvarez
0b520c9558
style: Make NonCustomPropertyId <-> nsCSSPropertyId conversions fast.
We have a different order in nsCSSPropertyId for no good reason. The only
invariant there is that longhands come before shorthands, and shorthands before
aliases.

Luckily that's also an invariant that NonCustomPropertyId has, so we can reuse
them.

Differential Revision: https://phabricator.services.mozilla.com/D2463

MozReview-Commit-ID: 1hsQu6hmqiN
2018-08-08 01:35:48 +02:00