Commit graph

1362 commits

Author SHA1 Message Date
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
Emilio Cobos Álvarez
38cbada278
style: Optimize QuerySelector in shadow trees.
Pretty much the same setup we have for document.

We have the awkwardness of having to check containing shadow manually for
ShadowRoot because it's not available in TNode (and making it available added a
bit more complexity that wasn't worth it IMO).

Bug: 1464428
Reviewed-by: xidorn
MozReview-Commit-ID: CqOh0sLHf6o
2018-05-28 16:02:31 +02:00
Olli Pettay
f82bf81f8e
style: Make mBindingParent strong.
Bug: 1463116
Reviewed-by: bz
2018-05-28 15:37:47 +02:00
Xidorn Quan
514aba51ad
style: Use RefPtr::new instead of RefPtr::from_ptr_ref + clone.
Bug: 1461858
Reviewed-by: emilio
2018-05-20 18:58:44 +02:00
Xidorn Quan
ecb2ec63de
style: Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl.
Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: LJGm3lUS9mD
2018-05-20 18:58:31 +02:00
Xidorn Quan
5b0903e604
style: Have from_image_request reuse ImageValue from image request directly.
And also remove ComputedImageUrl::from_url_value_data.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: 5zifQlU7tOz
2018-05-20 18:58:13 +02:00
Xidorn Quan
45a37503af
style: Make from_image_request infallible.
All callsites already assert, so moving the assertion into the method
should be fine. It is not expected to handle a null image value anyway.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: J8CA8m22eSv
2018-05-20 18:57:55 +02:00
Xidorn Quan
dc2aadd43a
style: Make creating CssUrl infallible.
There were a check in CssUrl::parse_from_string for extra data, which
was removed as part of servo/servo#16241, so it never fails now.

CssUrl::from_url_value_data doesn't seem to need Result from the very
beginning. It is unclear why it was made that way.

Bug: 1461858
Reviewed-by: emilio
MozReview-Commit-ID: LXzKlZ6wPYW
2018-05-20 18:57:35 +02:00
bors-servo
b536774fbf
Auto merge of #20786 - emilio:gecko-sync, r=emilio
style: Sync changes from mozilla-central.

See individual commits for details.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20786)
<!-- Reviewable:end -->
2018-05-19 07:48:36 -04:00
Emilio Cobos Álvarez
164bfbcb40
Make servo-tidy happy. 2018-05-19 10:15:17 +02:00
Emilio Cobos Álvarez
1314f47da5
style: Distinguish between specified and computed URLs.
This is needed to serialize computed URLs correctly from getComputedStyle.

Bug: 1461288
Reviewed-by: xidorn
MozReview-Commit-ID: 9wakhqNrszb
2018-05-19 10:15:17 +02:00
Emilio Cobos Álvarez
2f18b67ce1
style: Make resolutions more like the rest of the CSS values.
Bug: 1460655
Reviewed-by: xidorn
MozReview-Commit-ID: 3Gt8VX1KhjC
2018-05-19 10:15:17 +02:00
Emilio Cobos Álvarez
06dbb6700d
style: Unprefix :-moz-selection.
Our implementation is totally not what the spec says, but totally what other
UAs do, see https://github.com/w3c/csswg-drafts/issues/2474.

So given this is causing webcompat pain, I think we should be pragmatic and just
unprefix this.

We could keep serialization and getComputedStyle with ::selection working with a
bit more effort, like we do for :-moz-placeholder, but I'd prefer not doing at
least the serialization bit, and just alias in nsCSSPseudoElements
:-moz-selection to selection too.

Bug: 509958
Reviewed-by: dbaron,xidorn
MozReview-Commit-ID: 6lxctozRDqv
2018-05-19 10:15:17 +02:00
Emilio Cobos Álvarez
932c00f95f Remove gecko generated files. 2018-05-17 11:24:59 -05:00
Emilio Cobos Álvarez
9d721072f5
style: Remove ServoStyleSheet usage.
Bug: 1457920
Reviewed-by: xidorn
MozReview-Commit-ID: LIBkovuQ6MB
2018-05-05 16:22:47 +02:00
Emilio Cobos Álvarez
9ed48952f5
style: Merge ServoStyleSheet and StyleSheet.
These are the most minimal changes I could make. More cleanups incoming.

Bug: 1457920
Reviewed-by: xidorn
MozReview-Commit-ID: AdMOA1acQIH
2018-05-05 16:22:47 +02:00
Xidorn Quan
8c322b9c1e
style: Make KTableEntry an independent type.
Bug: 1448759
Reviewed-by: heycam
MozReview-Commit-ID: oZfJAigThN
2018-05-05 16:19:46 +02:00
Xidorn Quan
07de715bb5
style: Manually implement collect_completion_keywords for some types.
Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: 6T35uylxgho
2018-04-29 03:28:50 +02:00
Xidorn Quan
7fe7b2ffb1
style: Add a ValueInfo trait for exposing types needed by devtools.
Most of types just derive it using proc_macro directly. Some of value
types need manual impl.

In my current plan, this new trait will be used in bug 1434130 to expose
values as well.

Bug: 1455576
Reviewed-by: emilio
MozReview-Commit-ID: LI7fy45VkRw
2018-04-29 03:28:34 +02:00
Emilio Cobos Álvarez
276fb7e04b
style: Unify MediaList and ServoMediaList.
Bug: 1456471
Reviewed-by: xidorn
MozReview-Commit-ID: KFWxoohpGlb
2018-04-29 03:28:33 +02:00
Emilio Cobos Álvarez
1f5d90568d
style: Make tidy happy. 2018-04-28 10:26:08 +02:00
Jonathan Watt
36cef8ec68
style: Use user defined types for font-stretch / font-style.
Co-authored-by: Emilio Cobos Álvarez <emilio@crisal.io>
Bug: 1436048
Reviewed-by: jfkthame,jwatt
MozReview-Commit-ID: 7ONYtICeAqb
2018-04-28 10:26:06 +02:00
Emilio Cobos Álvarez
737501153b
style: Use a generic type in preparation to fix animation.
Apart from a bit more code reuse.

Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: 2BNOK6v30lX
2018-04-28 10:26:05 +02:00
Emilio Cobos Álvarez
32d4da8a99
style: Update font-style to css-fonts-4.
Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: 1Nq5DyCjaZe
2018-04-28 10:26:05 +02:00
Emilio Cobos Álvarez
f7636e6662
style: Update font-stretch to css-fonts-4.
These won't "just work", pending changes from bug 1436048 to use a floating
point representation for those.

Bug: 1454883
Reviewed-by: xidorn
MozReview-Commit-ID: Bi5iTdFreMA
2018-04-28 10:26:04 +02:00
Emilio Cobos Álvarez
91c3214772
style: Update bindings. 2018-04-28 10:26:03 +02:00
Emilio Cobos Álvarez
48de556f8c
style: Fixups for css-fonts-4 font-weight. 2018-04-28 10:26:03 +02:00
Emilio Cobos Álvarez
bc1126ee8c
style: Update font-weight property and descriptor to css-fonts-4.
Bug: 1454596
Reviewed-by: xidorn
MozReview-Commit-ID: 27aS2UrgXjs
2018-04-28 10:25:59 +02:00
Emilio Cobos Álvarez
376aafc2c8
style: Update bindings. 2018-04-17 20:02:33 +02:00
Emilio Cobos Álvarez
1bc30a6732
style: Move unboxing to style, and handle display: contents before other suppressions.
This also adopts the resolution of [1] while at it, and switches XUL to not
support display: contents until a use case appears.

This makes our behavior consistent both with the spec and also in terms of
handling dynamic changes to stuff that would otherwise get suppressed.

Also makes us consistent with both Blink and WebKit in terms of computed style.
We were the only ones respecting "behaves as display: none" without actually
computing to display: none. Will file a spec issue to get that changed.

It also makes us match Blink and WebKit in terms of respecting display: contents
before other suppressions, see the reftest which I didn't write as a WPT
(because there's no spec supporting neither that or the opposite of what we do),
where a <g> element respects display: contents even though if it had any other
kind of display value we'd suppress the frame for it and all the descendants
since it's an SVG element in a non-SVG subtree.

Also, this removes the page-break bit from the display: contents loop, which I
think is harmless.

As long as the tests under style are based in namespace id / node name /
traversal parent, this should not make style sharing go wrong in any way, since
that's the first style sharing check we do at [2].

The general idea under this change is making all nodes with computed style of
display: contents actually honor it. Otherwise there's no way of making the
setup sound except re-introducing something similar to all the state tracking
removed in bug 1303605.

[1]: https://github.com/w3c/csswg-drafts/issues/2167
[2]: https://searchfox.org/mozilla-central/rev/fca4426325624fecbd493c31389721513fc49fef/servo/components/style/sharing/mod.rs#700

Bug: 1453702
Reviewed-by: mats, xidorn
MozReview-Commit-ID: JoCKnGYEleD
2018-04-17 20:01:46 +02:00
Bobby Holley
afe484e46b
style: Allow placeholder import sheets.
This is necessary because we can't create GeckoStyleSheets off-main-thread,
so we need a placeholder until it can be filled in.

Bug: 1454030
Reviewed-by: emilio
MozReview-Commit-ID: ssRme4fLYg
2018-04-17 20:01:27 +02:00
Emilio Cobos Álvarez
0d15ab17d3
style: Update binidngs. 2018-04-14 21:15:44 +02:00
Emilio Cobos Álvarez
3ef77f59d8
style: Fix IsInAnonymousSubtree to account for XBL in Shadow DOM.
Bug: 1453206
Reviewed-by: smaug
MozReview-Commit-ID: B2aYury8K7i
2018-04-14 21:15:44 +02:00
Jonathan Watt
245d848508
style: Use a user defined type for font weight everywhere.
Bug: 1436048
Reviewed-by: emilio
2018-04-14 21:15:43 +02:00
Emilio Cobos Álvarez
1b84019832
style: Update bindings.
MozReview-Commit-ID: Fxe4m6jgBuZ
2018-04-11 09:50:20 +02:00
Emilio Cobos Álvarez
1d8e64c8ee
style: Simplify ImageValue.
Bug: 1452987
Reviewed-by: heycam
MozReview-Commit-ID: 5LRaaEPSSdY
2018-04-11 09:47:47 +02:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Bobby Holley
f7ae1a37e3 Manual fixups so that the rustfmt output won't trigger tidy. 2018-04-10 17:33:25 -07:00
Emilio Cobos Álvarez
db5db13559
style: Implement the non-functional :host selector.
Kinda tricky because :host only matches rules on the shadow root where the rules
come from. So we need to be careful during invalidation and style sharing.

I didn't use the non_ts_pseudo_class_list bits because as soon as we implement
the :host(..) bits we're going to need to special-case it anyway.

The general schema is the following:

 * Rightmost featureless :host selectors are handled inserting them in the
   host_rules hashmap. Note that we only insert featureless stuff there. We
   could insert all of them and just filter during matching, but that's slightly
   annoying.

 * The other selectors, like non-featureless :host or what not, are added to the
   normal cascade data. This is harmless, since the shadow host rules are never
   matched against the host, so we know they'll just never match, and avoids
   adding more special-cases.

 * Featureless :host selectors to the left of a combinator are handled during
   matching, in the special-case of next_element_for_combinator in selectors.
   This prevents this from being more invasive, and keeps the usual fast path
   slim, but it's a bit hard to match the spec and the implementation.

   We could keep a copy of the SelectorIter instead in the matching context to
   make the handling of featureless-ness explicit in match_non_ts_pseudo_class,
   but we'd still need the special-case anyway, so I'm not fond of it.

 * We take advantage of one thing that makes this sound. As you may have
   noticed, if you had `root` element which is a ShadowRoot, and you matched
   something like `div:host` against it, using a MatchingContext with
   current_host == root, we'd incorrectly report a match. But this is impossible
   due to the following constraints:

    * Shadow root rules aren't matched against the host during styling (except
      these featureless selectors).

    * DOM APIs' current_host needs to be the _containing_ host, not the element
      itself if you're a Shadow host.

Bug: 992245
Reviewed-by: xidorn
MozReview-Commit-ID: KayYNfTXb5h
2018-04-09 12:19:05 +02:00
Bobby Holley
9b5354f953 Stop using Gecko namespace ids in servo.
MozReview-Commit-ID: 2532dHCGPXW
2018-04-06 11:32:00 -07:00
Jonathan Watt
f72136800f Stop using NS_STYLE_FONT_WEIGHT_NORMAL and NS_STYLE_FONT_WEIGHT_BOLD
The Servo side of the changes for
https://bugzilla.mozilla.org/show_bug.cgi?id=1452040
2018-04-06 11:03:51 +01:00
Xidorn Quan
a140a70c12 Update bindings. 2018-04-05 19:37:20 +10:00
Xidorn Quan
80ab893e3a Use Servo data to back @counter-style rule. 2018-04-05 09:33:45 +10:00
bors-servo
34b13dac66
Auto merge of #20519 - upsuper:font-face-rule, r=emilio
Use Servo data to back @font-face rule in Gecko

This is the Servo side change of [bug 1449087](https://bugzilla.mozilla.org/show_bug.cgi?id=1449087).

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20519)
<!-- Reviewable:end -->
2018-04-03 19:33:59 -04:00
Xidorn Quan
ac7467221a Use Servo data to back @font-face rule in Gecko. 2018-04-04 09:33:07 +10:00
bors-servo
d744e35d38
Auto merge of #20482 - brainlessdeveloper:list-style-image-computed, r=emilio
Implement a URL-generic type for ListStyleImage

<!-- Please describe your changes on the following line: -->

This should fix the following two "expected to fail" tests described in https://github.com/servo/servo/issues/18015:

- getComputedStyle(elem) for url() listStyleImage uses the resolved URL
  and elem.style uses the original URL

- getComputedStyle(elem) for url() listStyle uses the resolved URL
  and elem.style uses the original URL

I updated the test failure expectations by removing the corresponding `.ini` file.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #18015 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20482)
<!-- Reviewable:end -->
2018-04-03 18:12:13 -04:00
Fausto Núñez Alberro
cc838f54e5
Implement a URL-generic type for list-style-image
This should fix the following two "expected to fail" tests:

- getComputedStyle(elem) for url() listStyleImage uses the resolved URL
  and elem.style uses the original URL

- getComputedStyle(elem) for url() listStyle uses the resolved URL
  and elem.style uses the original URL
2018-04-03 22:01:26 +02:00
Nicholas Nethercote
8705fb3783 Convert StylePrefs to StaticPrefs. 2018-04-03 11:41:03 +10:00