Commit graph

1527 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
96ea1a335c
stylo: don't double check that the root node is dirty in restyle_tree, since now we ensure it in the caller. 2016-07-24 12:51:58 -07:00
Emilio Cobos Álvarez
a3020419d9
stylo: Don't traverse the whole dom every restyle, propagate the dirty flag down the DOM.
This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo
might rely on a full bottom up reconstruction of the flows. I'll need to double
check and implement that separately.
2016-07-24 12:51:58 -07:00
bors-servo
1e0321f7dd Auto merge of #12469 - emilio:stylo, r=bholley
style: Rewrite the restyle hints code to allow different kinds of element snapshots.

<!-- 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: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] These changes do not require tests because refactoring.

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

This is a rewrite for how style interfaces with its consumers in order to allow
different representations for an element snapshot.

This also changes the requirements of an element snapshot, requiring them to
only implement MatchAttr, instead of MatchAttrGeneric. This is important for
stylo since implementing MatchAttrGeneric is way more difficult for us given the
atom limitations. This also allows for more performant implementations in the
Gecko side of things.

I don't want to get this merged just yet, mainly because the stylo part is not
implemented, but I'd like early feedback from @bholley and/or @heycam: How do
you see this approach? I don't think we'll have much problem to implement
MatchAttr for our element snapshots, but... worth checking.

r? @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/12469)
<!-- Reviewable:end -->
2016-07-21 16:54:34 -05:00
Emilio Cobos Álvarez
f44e31aa58
stylo: Update generated bindings 2016-07-21 14:24:05 -07:00
Emilio Cobos Álvarez
611e611215
style: Rewrite the restyle hints code to allow different kinds of element snapshots, and use it for Gecko.
This is a rewrite for how style interfaces with its consumers in order to allow
different representations for an element snapshot.

This also changes the requirements of an element snapshot, requiring them to
only implement MatchAttr, instead of MatchAttrGeneric. This is important for
stylo since implementing MatchAttrGeneric is way more difficult for us given the
atom limitations. This also allows for more performant implementations in the
Gecko side of things.
2016-07-21 14:24:04 -07:00
bors-servo
4a77cbdbb2 Auto merge of #12521 - Manishearth:safer-coord, r=bholley
Introduce safer layer of sugar for nsStyleUnion

This routes (almost) all access to nsStyleUnion through a largely safe interface, CoordData.

It also introduces a corresponding Rust enum, CoordDataValue, which can be used when interacting with CoordData

LLVM should optimize the costs away in release mode. eddyb tested this a bit, and LLVM has no trouble threading matches together with inlining -- so all of the matches using enums here will have the same generated code as the old matches on the units.

Some unresolved questions:

Should I provide convenience methods like `set_coord`, `set_auto`, etc on CoordData? `.set_enum(CoordDataValue::Something)` should optimize down to the same thing, but the convenience methods look cleaner and won't load the optimizer as much.

Also, we're converting immutable references to mutable ones, which can be used to cause unsafety using some acrobatics. Perhaps a trait-based approach is better?
The issue is that in some places we only have a `&CoordData` (eg copy_from), but CoordData internally is `*mut`. It would be nice if CoordData could parametrize over its mutability, but Rust doesn't let us do that.

The alternate approach is to make CoordData a trait (also CoordDataMut). The trait requires you to implement `get_union()` and `get_unit()`, and gives you the rest of the functions for free. `nsStyleCoord` would directly implement both traits. `nsStyleSides` would have `data_at(idx)` and `data_at_mut(idx)` methods which return a struct `SidesData` containing a reference to the Sides and the index, which itself implements the `CoordData` and `CoordDataMut` trait (we need two traits here because there will have to be two `SidesData` structs).

I decided not to implement the traits approach first since it's pretty trivial to change this code to use traits, and the current design is more straightforward.

Thoughts?

r? @bholley

cc @emilio @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/12521)
<!-- Reviewable:end -->
2016-07-21 03:05:56 -05:00
Manish Goregaokar
73d7db0d5e
Make nsStyleUnion sugar use traits 2016-07-21 13:35:47 +05:30
Emilio Cobos Álvarez
0b67b218d0
style: Add a new Timer structure to the shared style context, and basic infrastructure for controlling animations. 2016-07-20 09:05:53 -07:00
Manish Goregaokar
6e9a68a0db
Introduce safer layer of sugar for nsStyleUnion 2016-07-20 18:28:07 +05:30
Simon Sapin
6d0e48f6cc Remove some type aliases that are now just re-exports. 2016-07-20 08:42:47 +02:00
Simon Sapin
5c70dfab01 Have a concrete SelectorImpl type everywhere in the style crate.
It is conditionally compiled to one implementation or the other
(Gecko or Servo) with `#[cfg(…)]`.
2016-07-20 08:42:46 +02:00
Simon Sapin
4b7060554b Rename ComputedValuesStruct to ComputedValues.
Doing this in a separate commit avoids mixups
with the ComputedValues trait that the previous commit removed.
2016-07-20 08:42:45 +02:00
Simon Sapin
789807b7b0 Remove the ComputedValue traits and style_struct_traits 2016-07-20 08:42:40 +02:00
Simon Sapin
b2a7e44373 Move ServoSelectorImpl to a dedicated module. 2016-07-20 08:40:53 +02:00
Simon Sapin
2f967893f3 Move geckolib/selector_impl.rs -> style/gecko_selector_impl.rs 2016-07-20 08:40:49 +02:00
Simon Sapin
db3607471f Move geckolib/properties.mako.rs to style/properties/gecko.mako.rs 2016-07-20 08:40:22 +02:00
Simon Sapin
2c1f7c8a85 Move geckolib/values.rs to style/gecko_values.rs 2016-07-20 08:33:52 +02:00
Manish Goregaokar
f51b115db0
Address review comments 2016-07-19 11:29:13 +05:30
Manish Goregaokar
704d7a01c9
Handle Calc refcounting 2016-07-19 11:29:11 +05:30
Manish Goregaokar
67bcb96cea
Add glue for calc values 2016-07-19 11:29:07 +05:30
bors-servo
d28f2b8904 Auto merge of #12361 - stshine:blockify-flex-item, r=pcwalton
Blockify elements in a flex container

<!-- Please describe your changes on the following line: -->
The is one of my pull requests that implement basic flexible box layout.
As the spec stated in https://drafts.csswg.org/css-flexbox/#flex-items ,
A inline-level child of a flex container should be converted to its block equivalent, according to CSS2.1 § 9.7.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because flexbox is not actually implemented yet.

<!-- 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/12361)
<!-- Reviewable:end -->
2016-07-18 11:21:04 -07:00
Shing Lyu
f754cacbd5 Only restyle viewport-relative nodes on viewport size change 2016-07-18 11:01:42 +08:00
Manish Goregaokar
e21828080b
Error when non-allow_empty property is empty 2016-07-16 11:01:03 +05:30
Manish Goregaokar
a37eb82da8
Use allow_empty vector longhand for box-shadow 2016-07-15 15:15:28 +05:30
Manish Goregaokar
b6edae2f5e
Add allow_empty to vector_longhand 2016-07-15 15:15:26 +05:30
Manish Goregaokar
34c82d6e78
Replace gecko_autoarray_longhand with configurable vector_longhand 2016-07-15 15:15:23 +05:30
Alan Jeffrey
62e95c5a61 All our Cargo.toml files should contain an MPL-2.0 license field. 2016-07-14 10:26:34 -05:00
Manish Goregaokar
209255b20a Address review comments 2016-07-14 12:35:34 +05:30
Manish Goregaokar
38b57c435d Make background-image an array for stylo 2016-07-14 12:34:07 +05:30
Manish Goregaokar
b1a3831bf6 Add framework for properties which are single elements in servo and arrays in gecko 2016-07-14 12:34:04 +05:30
Manish Goregaokar
2091981db8 Some fixes in style 2016-07-12 20:00:24 +05:30
Manish Goregaokar
3ead9cc67b Improve mach clippy, add plugins to style/util 2016-07-12 19:59:58 +05:30
bors-servo
9b01a4cc97 Auto merge of #12382 - stshine:anonymous-block, r=SimonSapin
layout: Clear non-inherited properties on anonymous block

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

This is one of my pull requests that imlement basic flexible box layout.
This pull request adds a `modify_style_for_anonymous_flow()` function to use initial values for non-inherited properties and parent values for inherited properties as the flow style. It also set border and outline to zero and set the display property from the parameter. This function may also be reused to modify style of anonymous table object in the future.
Part of code comes from `cascade_anonymous()` from @SimonSapin .

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because flexbox is not implemented yet.

<!-- 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/12382)
<!-- Reviewable:end -->
2016-07-11 16:19:52 -07:00
Pu Xingyu
d40e6c5738 Clear non-inherited properties on anonymous block
Add a modify_style_for_anonymous_flow() function to use initial values
for non-inherited properties and parent values for inherited properties
as the block style. It also set border and outline to zero and set the
display property from the parameter.
2016-07-12 07:17:31 +08:00
Pu Xingyu
6d0756512d Blockify elements in a flex container
A inline-level child of a flex container should be converted to its
block equivalent. according to CSS2.1 § 9.7.
2016-07-12 07:13:25 +08:00
bors-servo
c3a8cbbd38 Auto merge of #12385 - Ms2ger:arc_ptr_eq, r=SimonSapin
Move arc_ptr_eq to style.

<!-- 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/12385)
<!-- Reviewable:end -->
2016-07-11 05:11:48 -07:00
Ms2ger
cbfe77cee1 Move some unit type definitions to style_traits. 2016-07-11 12:14:27 +02:00
Ms2ger
9f13278b77 Move arc_ptr_eq to style. 2016-07-11 12:13:12 +02:00
bors-servo
beaef005c2 Auto merge of #11873 - notriddle:rotate_anim, r=glennw
Rotate animation

Add rotation interpolation code for the case where their direction vectors are equal.
___

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11808 (github issue number if applicable).
- [X] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11873)
<!-- Reviewable:end -->
2016-07-10 16:30:48 -07:00
bors-servo
35a23bfef3 Auto merge of #12338 - upsuper:win-geckolib-fix, r=bholley
Fix geckolib build for Windows

It contains several fixes to make `./mach build-geckolib` work on Windows.

<!-- 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/12338)
<!-- Reviewable:end -->
2016-07-08 11:14:48 -07:00
Ms2ger
e7f9959ad9 Fix a build warning in animation.rs. 2016-07-08 16:44:50 +02:00
Ms2ger
8dd711d3db Move util::cache to style. 2016-07-08 16:44:47 +02:00
Xidorn Quan
6519d06b23 Replace windows path sep with unix sep
It seems python in msys2 has some weird behavior. For __file__, it
returns a string which uses windows-style separator '\', however,
os.path.dirname only recognizes the unix-style separator '/', and
consequently, the path of Mako is not added properly.
2016-07-08 18:51:05 +10:00
Xidorn Quan
6389107e19 Detect python2.7.exe on windows
Latest python2 package on msys2 installs the executable file to
python2.7.exe rather than python27.exe.
2016-07-08 18:50:59 +10:00
Emilio Cobos Álvarez
3a4539f043
style: stylistic nit. be consistent on how we write inline annotations. 2016-07-07 16:05:30 -07:00
Emilio Cobos Álvarez
8ba676533b
style: Fix timing-function overriding from the keyframe declaration list.
The previous behavior is plain wrong, since that array has always at least one
element, so we effectively couldn't specify anything else than "ease" in our
animations.
2016-07-07 16:05:28 -07:00
Emilio Cobos Álvarez
8bbebd0514
style: bonus: Fix parsing of steps() function.
Still doesn't work properly (this also happened with transitions).

This is spec'd in:
https://www.w3.org/TR/css3-transitions/#transition-timing-function
2016-07-07 16:05:26 -07:00
Emilio Cobos Álvarez
411ae84908
style: Add support to the animation shorthand and fix parsing of animation-name. 2016-07-07 16:05:22 -07:00
bors-servo
0d76cf8e5c Auto merge of #11948 - stshine:flex-shorthand-properties, r=emilio
Support 'flex' and 'flex-flow' shorthand properties

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

Support the `flex` and `flex-flow` shorthand properties in
servo. Currently they are marked as experimental, so they are added to
`__dir__.ini`.
Thanks SimonSapin and jdm for help :)

---
<!-- 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] There are tests for these changes

<!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11948)
<!-- Reviewable:end -->
2016-07-05 20:08:07 -07:00
Bobby Holley
187a47d89d Remove get_attr from TElement. \o/ 2016-07-05 18:03:41 -07:00