Commit graph

89 commits

Author SHA1 Message Date
bors-servo
bd9cf3ce98 Auto merge of #18281 - emilio:more-parse-dumbness, r=jdm
style: Avoid scanning the longhand id twice in the fast path of PropertyDeclarationBlock::parse_common

This makes the overhead of this function much lower according to `perf`.

And in general makes sense, removing overhead from the fast path.

<!-- 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/18281)
<!-- Reviewable:end -->
2017-08-29 02:48:09 -05:00
Emilio Cobos Álvarez
f6e4c5547c
style: Remove uninlineable function in PropertyDeclarationIterator.
That literally made no sense, and is probably leftover from where we passed Map
directly there.
2017-08-28 21:25:25 +02:00
Emilio Cobos Álvarez
344d53bd29
style: Avoid scanning the longhand id twice in the fast path of PropertyDeclarationBlock::push_common.
This makes the overhead of this function much lower according to `perf`.

And in general makes sense, removing overhead from the fast path.

MozReview-Commit-ID: 4dJRap9dxNG
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-08-28 21:20:46 +02:00
bors-servo
d4ddec8d33 Auto merge of #18209 - jdm:devirtualize, r=mbrubeck
Devirtualize CSS error reporting.

This removes a trait object from the path of reporting a CSS error.

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

<!-- 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/18209)
<!-- Reviewable:end -->
2017-08-24 13:19:25 -05:00
Josh Matthews
1297c0ff51 Devirtualize CSS error reporting. 2017-08-24 10:41:06 -07:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Brian Birtles
4f53ca2e39 Expand var() references in single_value_to_css
This is a temporary step needed to support Gecko's getKeyframes() API
until we implement bug 1391537. It only takes effect when
a ComputedValues object is supplied and only for longhand declarations.
2017-08-21 12:59:53 +09:00
Nazım Can Altınova
6893446b71 Add a pref checking mechanism for alias properties 2017-08-16 13:23:14 -07:00
Simon Sapin
7382dad939 Update to cssparser 0.19, count line numbers during tokenization 2017-08-09 22:37:16 +02:00
Simon Sapin
eb98ae6e04 Update cssparser to 0.18
https://github.com/servo/rust-cssparser/pull/171
2017-07-24 11:39:12 +02:00
Emilio Cobos Álvarez
fe8638a618
style: More ComputedValuesInner cleanup.
MozReview-Commit-ID: 8rkAP3pMEpD
2017-07-18 17:35:59 +02:00
Manish Goregaokar
808b1f509b stylo: Use ComputedValuesInner instead of ComputedValues when we don't need it 2017-07-17 18:02:25 -07:00
Josh Matthews
94d631c1f4 Suppress CSS parser errors for vendor-prefixed properties. 2017-07-17 10:00:31 -04:00
Emilio Cobos Álvarez
cc94a8b7cb
style: Undo the optimization for grabbing animation rules from the style data.
This is unfortunate, but for now it complicates things, I would like not needing
a ElementData to get the style of an Element in order to fix all the
getDefaultComputedStyle bugs.

MozReview-Commit-ID: LZvsdFEqrDE
2017-07-12 08:39:35 +02:00
Josh Matthews
0b43d0072c stylo: Update rust-cssparser; extract more specific error types when reporting (bug 1352669). 2017-07-10 20:46:12 -04:00
Gecko Backout
32269fa7cc Backed out changeset fec394734f83 (bug 17624) for build bustage a=backout CLOSED TREE
Backs out https://github.com/servo/servo/pull/17624
2017-07-06 21:58:15 +00:00
Josh Matthews
f5a3830ea2 stylo: Update rust-cssparser; extract more specific error types when reporting (bug 1352669). 2017-07-06 14:32:37 -04:00
Josh Matthews
dc2a500f4b stylo: Create error reporters linked to documents (bug 1352669) 2017-07-06 14:05:52 -04:00
Simon Sapin
a5bb55790f Untry style 2017-06-18 13:18:13 +02:00
Simon Sapin
b83afdedc8 Upgrade cssparser to 0.15 2017-06-16 15:05:46 +02:00
Brian Birtles
8f3dad598f Use AnimatableLonghand for AnimationValueMap and related code
In the next few patches we move all non-transition related code over to
using AnimatableLonghand instead of TransitionProperty. This will allow
us to re-purpose TransitionProperty to represent only properties that
can be transitioned (i.e. excluding discrete properties) as well as
simplifying the code by removing the need to deal with shorthands and
the "all" value in places that do not need to handle those values.
2017-06-15 10:18:18 +09:00
Emilio Cobos Álvarez
6e85601858
style: Avoid extra allocations in serialization of a property declaration block.
Concretely we avoid allocating and scanning a temporary vector of longhands not
yet serialized for each shorthand.

This doesn't save a lot of time in Linux, but I bet it's somewhat important on
OSX.
2017-06-14 15:39:28 +02:00
Emilio Cobos Álvarez
8b20d7a982
style: Avoid quadratic time serialization of a declaration block.
At least when the longhands aren't custom properties.

We should also look into not serializing the style attribute eagerly when it's
not needed... But a lot of code currently rely on attribute values being
dereferenciables to &str, so that's harder to fix.

We should really look into all those vectors around too, but that's probably
less urgent.
2017-06-14 11:41:01 +02:00
Hiroyuki Ikezoe
8bfed4cb3c Move ParsingMode into style_traits. 2017-06-14 09:51:36 +09:00
Josh Matthews
27ae1ef2e7 Thread ParseError return values through CSS parsing. 2017-06-09 16:46:25 -04:00
Josh Matthews
fd6e54d9e3 Report CSS parse errors via enum instead of strings. 2017-06-09 13:16:32 -04:00
Hiroyuki Ikezoe
2b929a1cb1 Factor out a process that creates AnimationValue iterator from PropertyDeclarationBlock. 2017-06-09 07:03:11 +09:00
Emilio Cobos Álvarez
acdd8aa99a
style: Insert declarations last while parsing.
The CSSOM spec forces us to reuse the slot, so we need to conditionally keep the
previous behavior.

This fixes bug 1369198.

MozReview-Commit-ID: LM9mK6ngZ4e
2017-06-02 11:21:02 +02:00
Manish Goregaokar
7123e5333f stylo: Fix serialization of system fonts 2017-06-01 13:55:52 -07:00
Nicholas Nethercote
6d5b1242db Introduce and start using the MallocSizeOf trait.
MallocSizeOf is similar to the existing HeapSizeOf trait from the
heapsize crate. The only difference is that MallocSizeOf's
malloc_size_of_children() function takes an additional MallocSizeOfFn
argument, which is used to measure heap blocks. This extra argument
makes MallocSizeOf match how Gecko's memory measurements work, and is
required for Stylo to integrate with DMD.

The patch also introduces a second trait, MallocSizeOfWithGuard, which
is much the same as MallocSizeOf, but with a |guard| argument for the
global style lock.

Finally, the patch uses the new traits to measure a small amount of
Stylo's memory usage.
2017-05-29 10:16:55 +10:00
Hiroyuki Ikezoe
4935d972e5 Use animation values that have been processed during animation-only restyle for normal restyle. 2017-05-24 11:11:57 +09:00
Hiroyuki Ikezoe
35e0e3aa11 Move AnimationRules into declaration_block.rs. 2017-05-24 11:11:42 +09:00
Hiroyuki Ikezoe
7330dab51f Factor out PropertyDeclaration only iterator. 2017-05-22 07:16:23 +09:00
Simon Sapin
cb8f77891f Use Vec::reserve in PropertyDeclarationBlock 2017-05-19 18:53:26 +02:00
Simon Sapin
d2be5239f5 Avoid returning / passing around a huge ParsedDeclaration type
This enum type used to contain the result of parsing
one CSS source declaration (`name: value;`) and expanding shorthands.
Enum types are as big as the biggest of their variant (plus discriminant),
which was quite big because some shorthands
expand to many longhand properties.
This type was returned through many functions and methods,
wrapped and rewrapped in `Result` with different error types.
This presumably caused significant `memmove` traffic.

Instead, we now allocate an `ArrayVec` on the stack
and pass `&mut` references to it for various functions to push into it.
This type is also very big, but we never move it.

We still use an intermediate data structure because we sometimes decide
after shorthand expansion that a declaration is invalid after all
and that we’re gonna drop it.
Only later do we push to a `PropertyDeclarationBlock`,
with an entire `ArrayVec` or nothing.

In future work we can try to avoid a large stack-allocated array,
and instead writing directly to the heap allocation
of the `Vec` inside `PropertyDeclarationBlock`.
However this is tricky:
we need to preserve this "all or nothing" aspect
of parsing one source declaration,
and at the same time we want to make it as little error-prone as possible
for the various call sites.
`PropertyDeclarationBlock` curently does property deduplication
incrementally: as each `PropertyDeclaration` is pushed,
we check if an existing declaration of the same property exists
and if so overwrite it.
To get rid of the stack allocated array we’d need to somehow
deduplicate separately after pushing multiple `PropertyDeclaration`.
2017-05-19 18:53:25 +02:00
Hiroyuki Ikezoe
b6b3187efa Make ParsingMode bitflags.
assert_parsing_mode_match() is mostly the same as
assert_restyle_hints_match().
2017-05-14 07:15:19 +09:00
Hiroyuki Ikezoe
fcc50ea421 Rename LengthParsingMode to ParsingMode and LengthParsingMode::SVG to PasingMode::AllowUnitlessLength.
We need another flag that represents allow-negative-number for SMIL, so
this enum will also comprise the another parsing mode that allows negative number.
2017-05-14 07:15:19 +09:00
Nazım Can Altınova
e1053f2c71
Rename ALIAS_PROPERTY with SHORTHAND_ALIAS_PROPERTY to prevent confusion 2017-05-09 14:23:39 +03:00
Anthony Ramine
f68e2fded9 Propagate quirks mode all the way to ParserContext
The quirks mode is still not properly propagated in geckolib.
2017-04-27 10:41:55 +02:00
Nazım Can Altınova
f9225d84aa
Implement moz-transform property 2017-04-19 22:11:54 +03:00
Hiroyuki Ikezoe
bd066af640 Add an FFI which returns computed values for a given declaration block with/without parent_style. r?heycam
The function uses document's default computed values if the parent style
is not specified.
2017-04-15 13:21:20 +09:00
Hiroyuki Ikezoe
39d3c22edc Add a function that checks PropertyDeclarationBlock has a CSSWideKeyword for a given property.
It will be used to check whether the PropertyDeclarationBlock has 'inherit',
'initial' or 'unset'.
2017-04-15 13:21:20 +09:00
J. Ryan Stinnett
8144aa1163 Expose CSS length mode in Stylo glue
Add length mode args to Stylo glue functions so that Gecko can enable the
special SVG mode as needed.

MozReview-Commit-ID: 1luM13MFEXX
2017-04-14 17:22:16 +08:00
J. Ryan Stinnett
6069e44f02 SVG length parsing mode
SVG allows non-zero lengths to be accepted and assumes they are in px.  This
adds this length parsing mode to Servo.

MozReview-Commit-ID: Kxd3x64r9Ye
2017-04-14 17:22:16 +08:00
Bobby Holley
687ea0ef9e Add more useful statistics to DUMP_STYLE_STATISTICS. 2017-04-13 13:43:05 +08:00
J. Ryan Stinnett
1ae1d370f2 Check context to test keyframe rule_type
Now that the `context` contains the `rule_type`, we can remove the `in_keyframe`
arg and check the `rule_type` to achieve the same thing.

MozReview-Commit-ID: oXrFBPuKMz
2017-04-12 16:40:37 +08:00
J. Ryan Stinnett
4574cd8ea6 Pull rule_type into ParserContext
Absorb `rule_type` into the `ParserContext` so that it's easier to pass down to
deeper levels of the parser.

MozReview-Commit-ID: DjBNytLxGKX
2017-04-12 16:40:17 +08:00
J. Ryan Stinnett
981571f4f8 Ignore non-margin properties in @page rule
Extend Servo's @page parsing to match Gecko's CSS 2.2 behavior, where only
margin properties are allowed in an @page rule.  Other properties are ignored.

MozReview-Commit-ID: IPYUlnkLYSb
2017-04-09 17:49:41 +08:00
Xidorn Quan
37585309e9 Use a UrlExtraData type alias to unify url handling logic. 2017-04-03 21:57:16 +10:00
Simon Sapin
4f2b9a33fe Replace ParsedDeclaration::expand with non-generic method
... to reduce its code size impact.

https://bugzilla.mozilla.org/show_bug.cgi?id=1351737
2017-03-29 20:28:25 +02:00