Commit graph

69 commits

Author SHA1 Message Date
Brad Werth
31584e3c14 Deep clone ServoStyleSheets.
MozReview-Commit-ID: 6hYIcOa86Y
2017-05-24 15:05:26 -07: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
Xidorn Quan
462cc49e42 Implement CSSKeyframesRule and CSSKeyframeRule for stylo. 2017-05-19 13:56:57 +10:00
Xidorn Quan
1c865ddc3c Impl to_css for KeyframeSelector. 2017-05-19 13:30:21 +10: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
Bobby Holley
d78ca4c4f9 Use StyleArc in the style system.
MozReview-Commit-ID: flF0fv9E9M
2017-05-02 17:35:44 -07: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
Boris Chiou
02fc1789e8 Bug 1357357 - Make the parser of transition-property match the spec.
1. We add a new arm to TransitionProperty, TransitionProperty::Unsupported,
   which contains an Atom, so it's better to remove the Copy trait from
   TransitionProperty.
2. TransitionProperty::Unsupported(Atom) represents any non-animatable, custom,
   or unrecognized property, and we use Atom to store the ident string for
   serialization.
2017-04-26 21:35:05 +08:00
Simon Sapin
de1fe51dc6 Rename MemoryHoleReporter to NullReporter 2017-04-24 07:56:50 +02:00
Hiroyuki Ikezoe
973d8287a9 Support vendor prefix keyframes rule.
If there are multiple prefixed/non-prefixed @keyframes with the same name;

* non-prefixed rule overrides earlier rules.
* prefixed rule overrides earlier prefixed rules.
2017-04-21 12:18:12 +09: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
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
Simon Sapin
1bacd0eb15 Move all PropertyDeclarationBlock from RwLock<_> to Locked<_> 2017-03-19 22:30:38 +01:00
Simon Sapin
57724e5a37 Replace RwLock<Keyframe> with Locked<Keyframe> 2017-03-19 22:30:37 +01:00
Bobby Holley
8cf331a498 Rearrange PropertyDeclaration to avoid embedding DeclaredValue.
From https://bugzilla.mozilla.org/show_bug.cgi?id=1347719

This effectively combines the discriminants of the two enums and reduces the
size of PropertyDeclaration by one word.

MozReview-Commit-ID: 9rCRiSVZTQT
2017-03-16 14:40:55 -07:00
Emilio Cobos Álvarez
b4de69e3eb
style: Avoid cloning all over the error reporter. 2017-03-14 00:49:18 +01:00
Simon Sapin
446aaa5845 Better variable name, remove obsolete comment 2017-03-08 12:03:47 +01:00
Simon Sapin
f70a49974a Make PropertyDeclarationBlock fields private 2017-03-07 23:37:32 +01:00
Simon Sapin
460fd6eba8 Deduplicate declarations when inserting each one, not at the end of parsing.
This will reduce the amount of re-allocations and copies.
It will be further optimized with a bit map.
2017-03-07 23:37:30 +01:00
Simon Sapin
4b4a873c3e Move parse method of PropertyDeclaration to ParsedDeclaration
This is what it now returns.
2017-03-07 23:37:29 +01:00
Simon Sapin
9d663ea7af Make PropertyDeclaration::parse return an enum rather than push to a Vec. 2017-03-07 23:37:29 +01:00
Simon Sapin
8160490272 Remove some unused impls. 2017-03-07 23:37:28 +01:00
Simon Sapin
7455ad5eb4 PropertyDeclarationParseResult -> Result<(), PropertyDeclarationParseError> 2017-03-07 23:37:27 +01:00
Simon Sapin
4ad844f7bd Rename PropertyBitField to LonghandIdSet 2017-02-26 19:24:50 +01:00
Simon Sapin
c81ebca7df Move PropertyBitField out of its module 2017-02-26 19:02:55 +01:00
Hiroyuki Ikezoe
501edfdbdb Get all animated properties in *all* keyframes.
@keyframes anim {
  from { transform: none; }
  to { opacity: 0; transform: none; }
}

In above case, we have to add opacity property and value in the 'from' keyframe.
2017-02-22 19:04:49 +09:00
Hiroyuki Ikezoe
35192b03c3 Assert if there is an important declaration while collecting animated properties in keyframes.
Parser has already dropped it.
2017-02-01 07:33:37 +09:00
Hiroyuki Ikezoe
a80725c91b Allow empty keyframe and keyframes with non-animatable properties.
We need to create CSS animations that have empty keyframe or keyframes
which have only invalid properties or non-animatable properties to fire
animation events for such animations.
2017-02-01 07:06:38 +09:00
Hiroyuki Ikezoe
90571eaa54 Bug 1328787 - Part 11: The last keyframe's KeyframePercentage is 1.0. r=heycam
MozReview-Commit-ID: Hgsc45m9401
2017-01-29 09:07:41 +09:00
Hiroyuki Ikezoe
e20a3ad9b5 Bug 1328787 - Part 8: Animation timing function can be overridden by animation-timing-function specified in keyframe. r=heycam 2017-01-29 09:07:41 +09:00
Manish Goregaokar
b5cb401aef Reduce allocator churn when parsing property declaration blocks (fixes #15060) 2017-01-18 16:31:46 -08:00
Emilio Cobos Álvarez
0b3c1a8924
style: Document the keyframes module. 2017-01-02 12:57:54 +01:00
Emilio Cobos Álvarez
fa01716c52
style: Avoid ending up with an invalid keyframe when inf or NaN are at play. 2016-12-15 13:58:51 +01:00
Simon Sapin
433c33c4df Match on PropertyId (not strings) to parse a declaration. 2016-12-09 17:06:51 -10:00
Nazım Can Altınova
e978f11c9f Fix Keyframe selector serialization 2016-12-06 01:38:06 +03:00
Simon Sapin
70b250fe2a Use stylesheet’s base URL and ns prefixes in CSSOM insert/appendRule. 2016-11-28 18:01:02 +01:00
Manish Goregaokar
18742e72fa Update test expectations 2016-11-23 09:32:48 -08:00
Manish Goregaokar
8108fc465a Add CSSNamespaceRule.{namespaceURI, prefix} 2016-11-23 09:32:46 -08:00
Manish Goregaokar
64442090ba Add CSSKeyframesRule.{findRule, deleteRule, appendRule} 2016-11-23 09:32:44 -08:00
Nazım Can Altınova
fdbadcdce2 Implement ToCss serialization for CSSRules 2016-11-18 12:17:53 +03:00
Simon Sapin
742681a623 Add RwLock in more Arc’d things in stylesheets. 2016-10-19 19:55:05 +02:00
Simon Sapin
89a29a7f12 Use parking_lot::RwLock instead of DOMRefCell for PropertyDeclarationBlock 2016-10-04 18:34:59 +02:00
Simon Sapin
d986fd2d2f Use PropertyDeclarationBlock in a DOMRefCell everywhere. 2016-10-04 18:34:57 +02:00
Simon Sapin
29c72d15a9 Make style build without impl<T: HeapSizeOf> HeapSizeOf for Arc<T>.
The removal of this impl is not included in this commit.
CC https://github.com/servo/heapsize/issues/37#issuecomment-249861171
2016-10-04 13:45:57 +02:00
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00