Commit graph

4994 commits

Author SHA1 Message Date
Boris Chiou
4ed1a6be20 Fix the identity transform of rotatex and rotatey.
Let's see the example: "rotatex(360deg)" to "none".

While we do interpolation between "rotatex" and "none", the original code
path is:
1. Build an identity transform for none and always use (0, 0, 1) as the
   direction vector, i.e. Rotate(0, 0, 1, 0deg).
2. Do interpolation between rotatex (i.e. Rotate(1, 0, 0, 360deg)) and
   Rotate(0, 0, 1, 0deg). Because their direction vectors are different,
   so we do matrix decomposition/interpolation/recomposition on both
   functions. The problem is, matrix decomposition makes the 360deg
   disappear, so it looks like "rotatex(0deg)".
3. Obviously, we are trying to interpolate from rotatex(0deg) to none, so
   the interpolated matrix is always an identity matrix.

I think rotatex, rotatey, and rotatez are special cases which should
really rotate according to the angle, so we should build the identity
transform for them according to the normalized direction vector, and so we do
interpolation on the angle, instead of converting them into matrix.

Replacing build_identity_transform_list() with
add_weighted_transform_lists(list, list, 0, 0) might be another solution;
However, I didn't do that because build_identity_transform_list() is
much simpler.
2017-08-20 02:26:18 +08:00
Boris Chiou
03cf0a8cb8 Fix divided by zero problem on non-normalizable direction vector.
While normalizing the direction vector, we have to make sure we don't
divide the components by zero length to avoid any assertion of "NaN".
2017-08-20 02:26:08 +08:00
bors-servo
c1b196b7cb Auto merge of #18148 - tamird:computedvalues-arc-borrow, r=emilio
style: pass a borrow instead of an Arc

https://bugzilla.mozilla.org/show_bug.cgi?id=1380133 has landed,
permitting us to pass a plain borrow into Gecko_CalcStyleDifference;
propagate this through style.

Closes #17795.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- 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/18148)
<!-- Reviewable:end -->
2017-08-19 08:51:16 -05:00
bors-servo
0b45a4f651 Auto merge of #18136 - upsuper:shadow-color, r=emilio
Use Option<RGBA> for color in shadow

This fixes [bug 1390697](https://bugzilla.mozilla.org/show_bug.cgi?id=1390697) by downgrading the support of currentcolor in shadow to what Gecko currently supports.

<!-- 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/18136)
<!-- Reviewable:end -->
2017-08-19 05:45:53 -05:00
Tamir Duberstein
c348d5afb3
style: pass a borrow instead of an Arc
https://bugzilla.mozilla.org/show_bug.cgi?id=1380133 has landed,
permitting us to pass a plain borrow into Gecko_CalcStyleDifference;
propagate this through style.

Closes #17795.
2017-08-19 03:24:46 -07:00
bors-servo
62d0de349d Auto merge of #18056 - cynicaldevil:remove-treesink-dep-on-dom, r=nox
End TreeBuilder's reliance on DOM.

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

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->

Fixed h5e's TreeBuilder so that it does not use `same_tree` and `has_parent_node` methods: d8c2ea5cb6
<!-- 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/18056)
<!-- Reviewable:end -->
2017-08-18 16:27:05 -05:00
bors-servo
9bf70d4865 Auto merge of #18144 - canaltinova:legacy-position-x, r=emilio
Handle single X keyword value in LegacyPosition

This is reviewed by emilio in bugzilla.

---
<!-- 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 [Bug 1391432](https://bugzilla.mozilla.org/show_bug.cgi?id=1391432)

<!-- 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/18144)
<!-- Reviewable:end -->
2017-08-18 15:28:37 -05:00
Nazım Can Altınova
692d009e32 Handle single X keyword value in LegacyPosition 2017-08-18 11:06:58 -07:00
bors-servo
941e0dbb5a Auto merge of #18142 - emilio:less-mess-ns, r=SimonSapin
style: Less messy namespace handling.

This PR accounts for the fact that the namespace table is only needed in
`NestedRuleParser`, and only for style rules, in order to simplify the setup and
be able to fix a few bugs wrt parsing of invalid rules.

<!-- 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/18142)
<!-- Reviewable:end -->
2017-08-18 12:58:46 -05:00
Emilio Cobos Álvarez
62d42a090b
style: Fix namespace handling during keyframe parsing. 2017-08-18 19:58:00 +02:00
Emilio Cobos Álvarez
a962c54928
style: Cleanup ParserContext::new_with_rule_type. 2017-08-18 19:57:59 +02:00
Nikhil Shagrithaya
99235c9201 Updated h5e and x5e 2017-08-18 19:51:17 +05:30
Xidorn Quan
4e0b1071e7 Use Option<RGBA> for color in shadow 2017-08-19 00:20:24 +10:00
Emilio Cobos Álvarez
4763d05cf0
style: A few minor formatting cleanups. 2017-08-18 16:10:41 +02:00
Emilio Cobos Álvarez
48ce204cb2
style: Less messy namespace handling.
This PR accounts for the fact that the namespace table is only needed in
`NestedRuleParser`, and only for style rules, in order to simplify the setup and
be able to fix a few bugs wrt parsing of invalid rules.
2017-08-18 16:10:29 +02:00
Emilio Cobos Álvarez
d1725b1f19
style: Replicate the list of stylesheets on the layout thread.
This is a patch that unifies a bit how Gecko and Stylo stylesheets work, in
order to be able to eventually move the stylesheets into the stylist, and be
able to incrementally update the invalidation map.
2017-08-18 14:31:35 +02:00
bors-servo
92176d1152 Auto merge of #18131 - emilio:calc-serialization, r=canaltinova
style: Multiple calc serialization fixes.

This puts us in line with the spec as written, except for caveat in https://github.com/w3c/csswg-drafts/issues/1731.

Need to fix computed calc() too, I'm less confident that we won't need to change test expectations.

<!-- 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/18131)
<!-- Reviewable:end -->
2017-08-18 04:42:12 -05:00
Emilio Cobos Álvarez
6df597b0b8
style: Use Au::abs. 2017-08-18 11:06:39 +02:00
Emilio Cobos Álvarez
7bf1748c34
style: update app_units. 2017-08-18 11:06:37 +02:00
Emilio Cobos Álvarez
22d6a73436
style: Make computed serialization of calc() match the spec too. 2017-08-18 11:06:36 +02:00
Emilio Cobos Álvarez
1d54a8e857
style: Add a note about weirdness in serialization of computed calc(). 2017-08-18 11:06:34 +02:00
Emilio Cobos Álvarez
e05c673df3
style: Serialize percentages first in specified calc() expressions. 2017-08-18 11:06:32 +02:00
Emilio Cobos Álvarez
f8a6eccda2
style: Update calc() serialization to the spec. 2017-08-18 11:06:31 +02:00
bors-servo
494dcd7e52 Auto merge of #18086 - BorisChiou:stylo/transform/distance, r=nox,birtles
stylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList

We implement ComputeSquaredDistance for TransformList.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1362896](https://bugzilla.mozilla.org/show_bug.cgi?id=1362896).
- [X] These changes do not require tests because Gecko has related tests.

<!-- 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/18086)
<!-- Reviewable:end -->
2017-08-18 02:24:33 -05:00
bors-servo
d17f27640b Auto merge of #17704 - mantaroh:interpolate-stroke, r=nox
Add animation value related with stroke-dasharray / stroke-dashoffset / stroke-width.

<!-- Please describe your changes on the following line: -->
This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1369614

This patch will:
 * Add animation value conversion of LengthOrPercentage in order to interpolate length and number.
 * Add animation value of Vec<LengthOrPercentage> in order to interpolate the stroke-dasharray.

Spec is as follow:
https://svgwg.org/svg2-draft/painting.html#StrokeDashing

---
<!-- 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

<!-- Either: -->
There are tests for these changes, a test case will be landed in wpt in https://bugzilla.mozilla.org/show_bug.cgi?id=1369614.

<!-- 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/17288)
<!-- Reviewable:end -->
2017-08-17 23:39:00 -05:00
Bobby Holley
d2842daa2d Avoid creating a stylo thread pool in e10s parent processes.
MozReview-Commit-ID: LW92yNDKZf4
2017-08-17 19:14:16 -07:00
Mantaroh Yoshinaga
1c574cf93b Add SVGLengthOrPercentageOrNumber for stroke-*.
We need to use enum instead of Either since we can't interpolate stroke-* between
unitless length and unit length(e.g. '5' -> '10px').

This coomit make following:

 * Introduce SVGLengthOrPercentageOrNumber on computed and specified values.
 * Make SVGLengthOrPercentageOrNumber animatable.
 * Make stroke-dasharray not-accumulate.
2017-08-18 10:28:11 +09:00
bors-servo
cc86ca2bcd Auto merge of #18126 - servo:glow-fox, r=emilio
geckolib: Fix some warnings (treated as error) new in Rust Nigthly

<!-- 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/18126)
<!-- Reviewable:end -->
2017-08-17 11:05:32 -05:00
Simon Sapin
35282042bc geckolib: Fix some warnings (treated as error) new in Rust Nigthly 2017-08-17 15:59:33 +02:00
Tom Tromey
7224a5617f Expose the source map URL on a style sheet
This changes Servo to track the source map URL of a style sheet.  This
parallels a change going in to Gecko:
https://bugzilla.mozilla.org/show_bug.cgi?id=1388855
2017-08-17 06:51:30 -06:00
Boris Chiou
e8fad236ef Implement ComputeSquaredDistance for Matrix and Perspective. 2017-08-17 13:53:25 +08:00
Boris Chiou
3a5cbfb769 Implement ComputeSquaredDistance for TransformList. 2017-08-17 13:53:20 +08:00
Boris Chiou
03e1794c12 Use f64 for Quaternion.
The unit of gfxQuaternion in Gecko is gfxFloat, which is "double", so
it's better to use f64 to match the precision of Gecko.
2017-08-17 13:53:15 +08:00
Boris Chiou
a5433ad68a Tweak CalcLengthOrPercentage to use pixel value.
We compute the distance for eCSSUnit_Calc by pixel value in Gecko,
so let's follow the same rules.
2017-08-17 13:53:07 +08:00
Ting-Yu Lin
ede8a23986 style: Move functions related to anonymous element to GeckoElement (Bug 1390773)
MozReview-Commit-ID: 6LqAPM86MQC
2017-08-17 10:50:34 +08:00
bors-servo
575bcf3989 Auto merge of #18117 - servo:we-are-leaving-babylon, r=emilio
Move more CSS values to their own submodules

<!-- 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/18117)
<!-- Reviewable:end -->
2017-08-16 20:26:22 -05:00
bors-servo
846b6dcb07 Auto merge of #18102 - hiikezoe:compute-distance-for-shadow-list, r=boris
Implement distance for shadow list.

<!-- Please describe your changes on the following line: -->
https://bugzilla.mozilla.org/show_bug.cgi?id=1387973
---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- 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/18102)
<!-- Reviewable:end -->
2017-08-16 18:17:18 -05:00
Anthony Ramine
4ebeaa599b Move specified and computed time values to submodules 2017-08-17 00:05:59 +02:00
Anthony Ramine
1bd12bf91a Move specified and computed angles to submodules 2017-08-17 00:01:23 +02:00
Nazım Can Altınova
46adb0f0a7 Update bindings 2017-08-16 13:23:15 -07:00
Nazım Can Altınova
6893446b71 Add a pref checking mechanism for alias properties 2017-08-16 13:23:14 -07:00
bors-servo
75cae28728 Auto merge of #18103 - birtles:drop-fill-none-interpolation, r=hiro
Don't allow interpolating 'fill:none' with 'fill:none'

From [Gecko bug 1390364](https://bugzilla.mozilla.org/show_bug.cgi?id=1390364).

In SMIL we don't expect the 'none' value of the 'fill' property to be additive and hence the following animation should have no effect:

```svg
  <rect width="100" height="100" y="100" fill="blue">
    <animate attributeName="fill" dur="3s" from="red" by="none"/>
  </rect>
```

Although SMIL doesn't make this entirely clear, [it says](https://www.w3.org/TR/smil-animation/#AnimFuncValues) that "by animation" and "from-by animation" may only be used "with attributes that support addition (e.g.  most numeric attributes)" and [SVG says](https://www.w3.org/TR/SVG11/animate.html#AnimationAttributesAndProperties) that `<paint>`s are "only additive if each value can be converted to an RGB color". As a result, the animation above should have no effect.

By extrapolation, animating from 'none' by 'none' should also have no effect:

```svg
  <rect width="100" height="100" y="100" fill="blue">
    <animate attributeName="fill" dur="3s" from="none" by="none"/>
  </rect>
```

However, in Servo's interpolation of `<paint>`s we special case the interpolation and addition of 'none' such that if both values are 'none' it is allowed.

We should disallow this in order to produce the expected behavior and in order to match Gecko's behavior.

<!-- 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/18103)
<!-- Reviewable:end -->
2017-08-16 05:46:56 -05:00
bors-servo
467316e35b Auto merge of #18097 - bholley:avoid_recursion_clear_descendant_data, r=emilio
Avoid recursion in clear_descendant_data

This will allow us to have a tight stack limit in https://bugzilla.mozilla.org/show_bug.cgi?id=1376883

<!-- 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/18097)
<!-- Reviewable:end -->
2017-08-16 04:22:23 -05:00
bors-servo
b300800b2c Auto merge of #18087 - emilio:stylist-clear-cleanup, r=heycam
style: Cleanup a bit Stylist and SelectorMap.

Bug: 1390255
Reviewed-by: heycam

<!-- 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/18087)
<!-- Reviewable:end -->
2017-08-16 02:56:13 -05:00
Emilio Cobos Álvarez
4c80cccbd2
stylo: Cleanup a bit of the Stylist clear setup.
This moves us to clear on rebuild, which allows us to remove yet another place
where we track stylist dirtiness.

Bug: 1390255
Reviewed-by: heycam
MozReview-Commit-ID: nihQbUAbh8
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-16 08:49:41 +02:00
Emilio Cobos Álvarez
b040d79333
style: Avoid multiple selector walk-ups during SelectorMap insertion.
MozReview-Commit-ID: 5b2X0GL2753
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-16 08:49:39 +02:00
Ting-Yu Lin
0e82ca1d3a style: Skip matching :nth-child if element is the root of anonymous subtree
This implement the logic in Gecko's nsNthIndexCache::GetNthIndex().

MozReview-Commit-ID: 8lzK9iIbfzo
2017-08-16 14:25:01 +08:00
Bobby Holley
653107d6c4 Avoid recursion in clear_descendant_data.
MozReview-Commit-ID: LeMhhcKoLr9
2017-08-15 23:24:17 -07:00
Brian Birtles
9ecb0aa7fa Don't allow interpolating 'fill:none' with 'fill:none'
In SMIL we don't expect the 'none' value of the 'fill' property to be
additive and hence the following animation should have no effect:

  <rect width="100" height="100" y="100" fill="blue">
    <animate attributeName="fill" dur="3s" from="red" by="none"/>
  </rect>

Although SMIL doesn't make this entirely clear, [1] says that "by
animation" and "from-by animation" may only be used "with attributes
that support addition (e.g.  most numeric attributes)" and [2] says that
<paint>s are "only additive if each value can be converted to an RGB
color". As a result, the animation above should have no effect.

By extrapolation, animating from 'none' by 'none' should also have no
effect:

  <rect width="100" height="100" y="100" fill="blue">
    <animate attributeName="fill" dur="3s" from="none" by="none"/>
  </rect>

However, in Servo's interpolation of <paint>s we special case the
interpolation and addition of 'none' such that if both values are 'none'
it is allowed.

We should disallow this in order to produce the expected behavior and in
order to match Gecko's behavior.

[1] https://www.w3.org/TR/smil-animation/#AnimFuncValues
[2] https://www.w3.org/TR/SVG11/animate.html#AnimationAttributesAndProperties
2017-08-16 15:01:44 +09:00
Hiroyuki Ikezoe
41cbd2fa62 Implement distance for shadow list. 2017-08-16 14:25:30 +09:00