Commit graph

89 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
66f00c5566
style: Multiple style nits and cleanups. 2017-03-29 12:40:34 +02:00
Emilio Cobos Álvarez
835d95eb41
style: Correctly track whether a longhand contains any variable. 2017-03-29 12:16:28 +02:00
Matthias Devlamynck
05b5aabc69
Shorthand with variable reference should not have extra whitespace after colon for serialization 2017-03-29 12:16:28 +02:00
Hiroyuki Ikezoe
c0baac4194 Add a function to convert AnimationValueMap to PropertyDeclarationBlock.
We need to convert all AnimationValue (AnimationValueMap) on an element
to PropertyDeclarationBlock in order to push the value inside the CSS cascade.

Two reasons we did not add the function in AnimationValueMap:

 1) All members of PropertyDeclarationBlock are private.
 2) Rust does not allow us impl for type alias, so if we do impl the function
    in AnimationValueMap we need to make AnimationValueMap as a tuple or struct.
2017-03-17 12:30:01 +09:00
Emilio Cobos Álvarez
b4de69e3eb
style: Avoid cloning all over the error reporter. 2017-03-14 00:49:18 +01:00
Simon Sapin
765be69780 Fix debug assertion failure https://bugzilla.mozilla.org/show_bug.cgi?id=1345483 2017-03-08 13:35:18 -08:00
Simon Sapin
60f454d7c4 Use a bitmap to optimize adding to a PropertyDeclarationBlock. 2017-03-07 23:37:32 +01:00
Simon Sapin
f70a49974a Make PropertyDeclarationBlock fields private 2017-03-07 23:37:32 +01:00
Simon Sapin
da4e5146e9 Make PropertyDeclarationBlock::important_count private. 2017-03-07 23:37:31 +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
Xidorn Quan
4f07826837 Return true in set_property only when declaration block is changed 2017-03-06 22:21:59 +11:00
Simon Sapin
0b4877590f Move deduplicate_property_declarations to PropertyDeclaration::deduplicate 2017-02-26 19:02:51 +01:00
Michael Nelson
bcafe21dc9 Animation shorthand should be serialized only when the value lists have the same length.
Fixes #15398

The previous commit did most of the work here of updating the algorithm
to skip shorthands if a shorthand value was an empty string. This commit
just updates animations LonghandToSerialize's implementation of
to_css_declared to write an empty string value if the list lengths
differ (and updates the test to match).
2017-02-24 12:03:04 +11:00
Michael Nelson
a0998d30d4 Update PropertyDeclarationBlock::to_css so that the iteration of
possible shorthands matches the linked spec.

Previously substep 5 attempted to serialize the complete shorthand
declaration and substep 6 skipped to the next shorthand only if the
current shorthand was not serialized, but this did not catch empty
serializations. The spec on the other hand specifically says that the
*value* should be evaluated first and if the value is empty substep 6
should skip to the next shorthand - which is what happens now.

To do this required some refactoring which mostly simplifies the code.
Specifically:
 - append_declaration_value was refactored so that importance is not
   required as a arg (by moving it to the end of append_serialization)
   and is_overflow_with_name was removed as an arg also (initially I
   refactored it elsewhere, but it turns out it's no longer required at
   all - more below). With these changes, append_declaration_value can
   be used within the algorithm for to_css to obtain just the value for
   substep 5.
 - Substeps 7 and 8 of the algorithm become explicit (they were implicit
   before) by passing the value, shorthand and importance to
   append_serialization.
 - serialize_shorthand_to_buffer is no longer required (as the algorithm
   serializes the value first instead, as per the spec.

A surprising result of this was that I could also remove a lot of code
handling the special case of the overflow properties serialization. This
is because the overflow's LonghandToCss implementation of
to_css_declared already does the right thing according to the spec - it
writes the single value if both overflow-x and -y are equal, and
writes nothing otherwise - so that the algorithm now skips that shorthand
instead rendering the longhands.
2017-02-23 17:26:59 +11:00
Manish Goregaokar
5cc0fa5ec2 stylo: Support pixel and percent presentation attributes 2017-02-18 20:31:01 -08:00
Xidorn Quan
d06ffc2289 Parse value entirely for setting property via CSSOM
Fixes #15037
2017-02-02 16:07:49 +11:00
Emilio Cobos Álvarez
dd90366775
script: Refactor CSSStyleDeclaration and fix some bugs in the way. 2017-01-28 14:47:09 +01:00
Manish Goregaokar
b5cb401aef Reduce allocator churn when parsing property declaration blocks (fixes #15060) 2017-01-18 16:31:46 -08:00
Xidorn Quan
c183899c06 Correctly handle unserializable shorthand
get_shorthand_appendable_value doesn't always return a serializable
value. This change makes it handle that case correctly.
2017-01-09 15:38:13 +11:00
Simon Sapin
125a216bde More docs in style.
Follow up to #14802.
2017-01-02 10:40:20 +01:00
Emilio Cobos Álvarez
5241fa35ab
style: Tidy and document the declaration_block module. 2016-12-31 23:24:16 +01:00
Nazım Can Altınova
c351092457 Fix overflow shorthand serialization. 2016-12-31 15:26:36 +03:00
Emilio Cobos Álvarez
277ef70d39
style: Consistently indent stuff, add a bit of documentation driving by. 2016-12-31 12:16:57 +01:00
Simon Sapin
433c33c4df Match on PropertyId (not strings) to parse a declaration. 2016-12-09 17:06:51 -10:00
Simon Sapin
137e30b825 Introduce enums for identifying CSS properties.
* `LonghandId` and `ShorthandId` are C-like enums
* `Atom` is used for the name of custom properties.
* `PropertyDeclarationId` is the identifier for `PropertyDeclaration`,
  after parsing and shorthand expansion. (Longhand or custom property.)
* `PropertyId` represents any CSS property, e.g. in CSSOM.
  (Longhand, shorthand, or custom.)

Using these instead of strings avoids some memory allocations and copies.
2016-12-09 10:56:22 -10:00
Nazım Can Altınova
d4c3035659 Property declaration block serialization should check for importance 2016-11-26 14:16:33 +03:00
Emilio Cobos Álvarez
913c874cb5
Urlmageddon: Use refcounted urls more often. 2016-11-17 18:34:23 +01:00
Manish Goregaokar
c387eff065 Fix single_value_to_css 2016-11-13 23:50:50 -08:00
Ravi Shankar
6061985898 Prefer Servo-specific ToCss for all types 2016-11-07 09:14:22 +05:30
Simon Sapin
0eed39c198 Move CSSStyleDeclaration.SetPropertyPriority logic to style 2016-10-10 16:48:23 +02:00
Simon Sapin
c740a76410 Move (some) CSSStyleDeclaration.SetProperty logic to style 2016-10-10 16:42:23 +02:00
Simon Sapin
bd4a4c38c8 Move CSSStyleDeclaration.RemoveProperty logic to style 2016-10-10 16:20:44 +02:00
Simon Sapin
fc6a536b3a Move CSSStyleDeclaration.GetPropertyPriority logic to style 2016-10-10 16:01:23 +02:00
Simon Sapin
bd37f4e694 Move CSSStyleDeclaration.GetPropertyValue logic to style 2016-10-10 15:54:24 +02:00
Simon Sapin
540ba90bab Move PropertyDeclarationBlock into its own module. 2016-10-06 15:57:52 +02:00