Commit graph

490 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
2184e3f2e5 style: Cleanup generic font-family handling.
To be more similar between Rust and C++. This introduces GenericFontFamily and
exposes that plus FontFamilyNameSyntax to C++, using that where appropriate
instead of plain uint8_t as we were doing.

As a follow-up, as discussed on IRC with Jonathan, we can remove the -moz-fixed
family, and turn it just into an alias of Monospace.

The only non-trivial change is the MatchType changes, but they're ok I think.
The code already assumed at most one CSS generic, and the struct still takes 8
bits. I've verified that the relevant tests are passing (though try is closed).

Differential Revision: https://phabricator.services.mozilla.com/D24272
2019-04-12 12:19:55 +02:00
Emilio Cobos Álvarez
ff41f82720 style: Fix Gecko and Servo builds, and appease tidy. 2019-03-27 14:29:28 +01:00
Mats Palmgren
ab8c00e41a style: Add support for the ::marker pseudo element on list items. Alias :-moz-list-bullet/number to that in the parser.
Bug: 205202
Reviewed-by: emilio
2019-03-27 14:29:24 +01:00
Emilio Cobos Álvarez
14b176019c style: Simplify a bit our generated bindings by getting rid of FooBorrowed and FooBorrowedMut.
This reduces a lot the boilerplate that's needed in order to add simple binding
functions.

This starts using &Foo and Option<&Foo> instead, and as a result we need to
remove the servo_function_signatures test, which is a bit unfortunate.

I think it's worth though, this causes problems on some platforms (see bug
1534844), and messing up the functions signature is not something that I've ever
seen (other than bug 1308234, which already had all the FooBorrowed mess which
I'm removing).

Also, cbindgen understands references and Option<&Foo>, so it will be the way to
go in the future.

After this patch we can also remove HasSimpleFFI, but I've kept it for now since
I still use it in a few places, and this patch is quite big on its own.

Differential Revision: https://phabricator.services.mozilla.com/D24092
2019-03-27 14:29:19 +01:00
Cameron McCormack
d4635f1d12 style: Use horizontal metrics for ch in vertical mixed/sideways writing modes and for ex always.
Differential Revision: https://phabricator.services.mozilla.com/D23426
2019-03-27 14:29:18 +01:00
Cameron McCormack
d5f208e18c style: Allow FontMetricsProvider to produce ex height and zero width independently.
We are always able to produce an x height, but depending on whether the
glyph exists, we sometimes can't produce a zero glyph width.

Differential Revision: https://phabricator.services.mozilla.com/D23424
2019-03-27 14:29:17 +01:00
Emilio Cobos Álvarez
d3f254d2e4 style: Make all font-metrics-affecting properties cascade early.
And make font-size computation work on the whole font of the parent, not just
accounting for the parent's font-size.

Differential Revision: https://phabricator.services.mozilla.com/D20656
2019-03-27 14:29:08 +01:00
Emilio Cobos Álvarez
95ee1a5adf style: Use a single RestyleHint representation.
Differential Revision: https://phabricator.services.mozilla.com/D22828
2019-03-27 14:29:05 +01:00
Emilio Cobos Álvarez
5aeab7adb1 style: Reformat recent changes. 2019-03-13 15:08:38 +01:00
Emilio Cobos Álvarez
e723a5b7d6 style: Make the pres context optional in the style system.
Differential Revision: https://phabricator.services.mozilla.com/D21239
2019-03-13 15:08:32 +01:00
Emilio Cobos Álvarez
4e3e4c106a style: Refactor preference stylesheet prefs to not require a pres context.
We really only have two sets of prefs, one for chrome-like documents
(stuff in chrome docshells + chrome-origin images), and one for the rest.

Differential Revision: https://phabricator.services.mozilla.com/D20946
2019-03-13 15:08:31 +01:00
Emilio Cobos Álvarez
4c1076a9ac style: Fix gecko build. 2019-01-07 00:32:54 +01:00
Emilio Cobos Álvarez
5f173c463e style: Rustfmt recent changes. 2019-01-07 00:32:54 +01:00
Emilio Cobos Álvarez
a454f6233d Rename nsIDocument to mozilla::dom::Document.
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.

Overall it's not a very interesting patch I think.

nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.

I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.

While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.

Bug: 1517241
Reviewed-by: smaug
2019-01-07 00:32:51 +01:00
Emilio Cobos Álvarez
8929087d83 style: Update the Rust target version for bindgen.
This brings us alignas support and also associated constants for bitfield enums.

Differential Revision: https://phabricator.services.mozilla.com/D15334
2019-01-07 00:32:50 +01:00
Simon Sapin
be69f9c3e6 Rustfmt has changed its default style :/ 2018-12-28 13:17:47 +01:00
Olli Pettay
28719f2455 Move FragmentOrElement::mAttrs to Element.
Bug: 1512256
Reviewed-by: ehsan
2018-12-16 13:35:09 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
b1822a39fa cargo fix --edition --features gecko 2018-11-10 17:47:28 +01:00
Emilio Cobos Álvarez
8cb5b149eb
style: Some minor formatting nits. 2018-11-08 15:22:31 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Pyfisch
cb07debcb6 Format remaining files 2018-11-06 22:30:31 +01:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
72b29d3202
style: Simplify the Lang pseudo-class stuff a bit.
Differential Revision: https://phabricator.services.mozilla.com/D4754
2018-09-03 12:36:49 +02:00
Cameron McCormack
2af9264cfe
style: Use an Atom to store pseudo-class string arguments.
Differential Revision: https://phabricator.services.mozilla.com/D4740
2018-09-03 12:33:24 +02:00
Cameron McCormack
4ee3b56d54
style: Use an Atom to represent Direction values in pseudo-classes.
Differential Revision: https://phabricator.services.mozilla.com/D4730
2018-09-03 12:33:13 +02:00
Emilio Cobos Álvarez
1e6aa62c6f
style: Make the allocation of AuthorStyles for ShadowRoot lazy.
So that we don't waste a bunch of memory with stuff like <svg:use>. I
plan to shrink AuthorStyles further, but this should help regardless, and isn't
very complex.

Differential Revision: https://phabricator.services.mozilla.com/D4618
2018-09-03 12:33:03 +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
ffae32f844
style: Fixup some indentation. 2018-08-08 01:37:57 +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
Olli Pettay
87deddb631
style: Change storage of previous and next children in nsINode. 2018-08-08 01:37:28 +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
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
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
Nicholas Nethercote
fc9df0bcf3
style: Convert FnvHash{Set,Map} instances to FxHash{Set,Map}.
Bug: 1477628
Reviewed-by: heycam
2018-08-08 01:34:35 +02:00
Emilio Cobos Álvarez
02d27ad3dd
style: Make svg:use use an actual shadow tree.
This fixes a couple fuzz bugs and prevents special-casing <svg:use> even more in
bug 1431255.

Unfortunately not as many hacks went away as I'd have hoped, since we still need
to match document rules, see the linked SVGWG issues.

But blocks_ancestor_combinators goes away, which is nice since it's on a very
hot path.

Bug: 1450250
Reviewed-by: heycam
Differential Revision: https://phabricator.services.mozilla.com/D2154

MozReview-Commit-ID: C4mthjoSNFh
2018-07-24 03:30:12 +02:00
Emilio Cobos Álvarez
45435a57e9
style: Cleanup might_need_transitions_update.
Thought I had to update this as well, but nope. When basically any style changes
we already update transitions.

needs_transitions_update already handles the physical mapping changing by
checking whether any transition for the physical property remain there or not.

Bug: 1309752
Reviewed-by: birtles
MozReview-Commit-ID: 6vKwal4yzRU
2018-07-24 03:28:36 +02:00
Emilio Cobos Álvarez
5504cbdfd7
style: Animate logical properties.
The setup is that AnimationValue only contains physical properties, and
we physicalize when building keyframes and transitions.

Bug: 1309752
Reviewed-by: birtles
MozReview-Commit-ID: 9dI20N0LFrk
2018-07-24 03:28:10 +02:00
Olli Pettay
6483a89848
if ExtendedDOMSlots are used before slots, use FatSlots to have fewer allocations.
Bug: 1419661
2018-07-01 00:09:54 +02:00
Olli Pettay
b68e4c2352
style: Implement :defined pseudo-class for custom elements.
Bug: 1331334
Reviewed-by: emilio
2018-07-01 00:08:33 +02:00
Hiroyuki Ikezoe
2274f392d8
style: Try to allocate possible size for AnimationValueMap before composing.
The EffectSet count does not exactly represent the count what we really need
for AnimationValueMap, but in most cases it matches.  For example;

1) The element has two different keyframes animations

 @keyframes anim1 {
   to { opacity: 0; }
 }
 @keyframes anim2 {
   to { transform: rotate(360deg); }
 }

 In this case the number matches.

2) The element has two animations but both keyframes have the same CSS property

 @keyframes anim1 {
   to { opacity: 0; }
 }
 @keyframes anim2 {
   to { opacity: 0.1; }
 }

 In this case the number doesn't match, moreover it results more memory than we
 ever needed, but this case is presumably less common.

3) The element has an animation having keyframes for two different CSS
   properties.

 @keyframes anim {
   from { opacity: 0; transform: rotate(360deg); }
 }

 In this kind of cases, the number doesn't match.  But even so, this patch
 reduces the opportunities that the AnimationValueMap tries to allocate a new
 memory (i.e. less opportunities on expanding the map).

Note that when the hash map is expanded, we do allocate a new RawTable with the
new size then replace the old one with the new one [1], so I believe this
change will reduce the crash rate to some extent.

[1] https://hg.mozilla.org/mozilla-central/file/15c95df467be/servo/components/hashglobe/src/hash_map.rs#l734

Bug: 1418806
Reviewed-by: birtles
MozReview-Commit-ID: 6tcF9aqXh7a
2018-07-01 00:05:46 +02:00
Emilio Cobos Álvarez
63981e962a
style: Relax a bit an invalid assertion.
We may end up looking at a non-flushed AuthorStyles object when looking at
whether attribute changes and such may affect style.

Check the styles are clean to preserve the assertion, since if that happens
before the first flush, we may not have updated the quirks_mode field (and
that's fine).

Bug: 1468640
MozReview-Commit-ID: FgVpiTf4qMr
2018-06-18 19:17:12 +02:00
Emilio Cobos Álvarez
8d069d127a
style: Work around a bindgen bug on Android.
Bug: 1466406
Reviewed-by: xidorn
MozReview-Commit-ID: 2lltjH7IoZu
2018-06-12 12:15:09 -07:00
Emilio Cobos Álvarez
710184b670
style: Sprinkle some #[inline] on methods that have inline fast-paths.
MozReview-Commit-ID: 5kOmctLTAX0
2018-06-12 12:15:09 -07:00
Emilio Cobos Álvarez
2baa794de6
style: Sprinkle some inline in methods that are just pointer-chasing or function calls.
MozReview-Commit-ID: 8G2NQPBVuXn
2018-06-12 12:15:08 -07:00
Emilio Cobos Álvarez
90ef5607e4
style: Move TransitionProperty where it belongs.
Bug: 1419695
Reviewed-by: xidorn
MozReview-Commit-ID: 9PN6VfbDbLA
2018-06-12 12:15:05 -07:00
Emilio Cobos Álvarez
6940787916
style: Make the transition-property code make more sense.
We were working around the lack of alias support during parsing in
TransitionProperty by doing a Gecko lookup. That's a hack and is now gone.

Bug: 1419695
Reviewed-by: xidorn
MozReview-Commit-ID: EptUvJNTrZr
2018-06-12 12:15:04 -07:00
Emilio Cobos Álvarez
35a1a30f6b
style: Remove invalid assertion.
We can look at stale styles while trying to figure out if we need any
invalidation, and that's ok.

Bug: 1449243
MozReview-Commit-ID: 4mBIFNm9qJv
2018-06-12 12:15:04 -07:00
Nazım Can Altınova
93472bcdea
style: Merge ServoDeclarationBlock and DeclarationBlock.
Bug: 1464496
Reviewed-by: emilio
MozReview-Commit-ID: By9fV70Oq0K
2018-06-02 12:08:06 +02:00
Emilio Cobos Álvarez
5507d53611
style: Make element-backed pseudos inherit from NAC subtree roots and other NAC inherit from their parents.
Currently, NAC always inherits from the closest non-NAC ancestor element,
regardless of whether it is for an element-backed pseudo or not.

This patch changes the inheritance so that for element-backed pseudos, we
inherit from the closest native anonymous root's parent, and for other NAC we
inherit from the parent.

This prevents the following two issues and allows us to remove the
NODE_IS_NATIVE_ANONYMOUS flag:

 * Avoiding inheriting from the non-NAC ancestor in XBL bindings bound to NAC.

   - This is no longer a problem since we apply the rule only if we're a
     pseudo-element, and all pseudo-elements are in native anonymous subtrees.

   - This also allows to remove the hack that propagates the
     NODE_IS_NATIVE_ANONYMOUS flag from the ::cue pseudo-element from
     BindToTree.

 * Inheriting from the wrong thing if we're a nested NAC subtree.

   - We no longer look past our NAC subtree, with the exception of
     ::-moz-number-text's pseudo-elements, for which we do want to propagate
     ::placeholder to.

A few rules from forms.css have been modified because they're useless or needed
to propagate stuff to the anonymous form control in input[type="number"] which
previously inherited from the input itself.

Bug: 1460382
Reviewed-by: heycam
MozReview-Commit-ID: IDKYt3EJtSH
2018-06-02 12:07:07 +02:00