Commit graph

170 commits

Author SHA1 Message Date
Simon Sapin
e4f241389e Box large components of Longhands structs. 2017-05-19 17:47:03 +02:00
Brian Birtles
49bc7b9e69 Add add() method to Animatable interface 2017-05-15 12:53:14 +09:00
Brian Birtles
2f07b29296 Rewrite interpolate() in terms of a more general add_weighted() function
Generalizing the procedure like this will allow us to re-use it for addition of
most types.
2017-05-15 12:26:21 +09:00
Brian Birtles
6dfc1d1aa8 Merge ComputeDistance trait into Animatable trait 2017-05-10 14:41:26 +09:00
Brian Birtles
4d25e87ac6 Rename the Interpolate trait to Animatable 2017-05-10 13:38:06 +09:00
Manish Goregaokar
33fb27c765 Allow vector properties to be set by iterator 2017-05-04 09:21:57 -07:00
Manish Goregaokar
c85aae4abd Add iterators for vector types
MozReview-Commit-ID: I7oOpYhVP5S
2017-05-04 07:15:16 -07:00
cku
3c3e7f63ee Stylo: Implement {specified|computed}::LayerImage. 2017-05-03 20:51:33 +08:00
Bobby Holley
d78ca4c4f9 Use StyleArc in the style system.
MozReview-Commit-ID: flF0fv9E9M
2017-05-02 17:35:44 -07:00
bors-servo
bf0bf4f4b4 Auto merge of #16663 - emilio:style-builder, r=bholley
style: Add a StyleBuilder struct to avoid refcount and atomic CAS during the cascade.

This should fix most of the complaints that caused
https://bugzilla.mozilla.org/show_bug.cgi?id=1360889 to be open, and also fix a
bunch of other FIXMEs across the style system.

<!-- 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/16663)
<!-- Reviewable:end -->
2017-04-30 18:31:41 -05:00
Emilio Cobos Álvarez
3b857f1c4e
style: Add a StyleBuilder struct to avoid refcount and atomic CAS during the cascade.
This should fix most of the complaints that caused
https://bugzilla.mozilla.org/show_bug.cgi?id=1360889 to be open, and also fix a
bunch of other FIXMEs across the style system.
2017-04-30 23:45:40 +02:00
Emilio Cobos Álvarez
0c5681140a
style: Use SmallVec in the computed value representation of most stuff. 2017-04-30 23:32:32 +02:00
Anthony Ramine
2aea6d8907 Implement the unitless length quirk for margin 2017-04-27 10:42:16 +02:00
Anthony Ramine
0e7308e6dc Implement the unitless length quirk for font-size 2017-04-27 10:42:08 +02:00
Anthony Ramine
b5a558e592 Implement the unitless length quirk for border-*-width 2017-04-27 10:42:01 +02: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
Ravi Shankar
d56aec4109 Make ShapeSource generic 2017-04-25 17:42:02 +05:30
Ravi Shankar
63965f55f5 Make use of predefined_type for some aliased types 2017-04-25 17:40:39 +05:30
Manish Goregaokar
795ab74f04 stylo: System font support for bitflag properties and font-language-override 2017-04-21 14:53:23 -07:00
Manish Goregaokar
b0dcb72722 stylo: System font support for keyword font longhands 2017-04-21 14:53:18 -07:00
Manish Goregaokar
c1c4c8fa59 stylo: Add basic system font support, use for font-size and font-family 2017-04-21 14:53:09 -07:00
Boris Chiou
57f87007f2 Bug 1332633 - Part 1: Implement ComputeDistance trait.
Introduce ComputeDistance trait, which implement compute_distance and
compute_squared_distance.

For vector, compute_squared_distance is necessary because we use Euclidean
distance as the distance between two values. The easier way to implement
compute_squared_distance is to square the result from compute_distance, but
for some property values, they may have many components, e.g. (v1, v2, v3).
If we just square the result from compute_distance, the computation is
(sqrt(v1^2 + v2^2 + v3^2))^2. There are two redundant operators:
"square-root" and then "square". In order to avoid this, we should
implement compute_squared_distance separately for these types.

MozReview-Commit-ID: LmmrUXYlDb6
2017-04-21 11:37:57 +08:00
Manish Goregaokar
3162babada stylo: Support scriptlevel computation and scriptminsize
scriptlevel is a property that affects how font-size is inherited. If scriptlevel is
+1, for example, it will inherit as the script size multiplier times
the parent font. This does not affect cases where the font-size is
explicitly set.

However, this transformation is not allowed to reduce the size below
scriptminsize. If this inheritance will reduce it to below
scriptminsize, it will be set to scriptminsize or the parent size,
whichever is smaller (the parent size could be smaller than the min size
because it was explicitly specified).

Now, within a node that has inherited a font-size which was
crossing scriptminsize once the scriptlevel was applied, a negative
scriptlevel may be used to increase the size again.

This should work, however if we have already been capped by the
scriptminsize multiple times, this can lead to a jump in the size.

For example, if we have text of the form:

huge large medium small tiny reallytiny tiny small medium huge

which is represented by progressive nesting and scriptlevel values of
+1 till the center after which the scriptlevel is -1, the "tiny"s should
be the same size, as should be the "small"s and "medium"s, etc.

However, if scriptminsize kicked it at around "medium", then
medium/tiny/reallytiny will all be the same size (the min size).
A -1 scriptlevel change after this will increase the min size by the
multiplier, making the second tiny larger than medium.

Instead, we wish for the second "tiny" to still be capped by the script
level, and when we reach the second "large", it should be the same size
as the original one.

We do this by cascading two separate font sizes. The font size (mSize)
is the actual displayed font size. The unconstrained font size
(mScriptUnconstrainedSize) is the font size in the situation where
scriptminsize never applied.

We calculate the proposed inherited font size based on scriptlevel and
the parent unconstrained size, instead of using the parent font size.
This is stored in the node's unconstrained size and will also be stored
in the font size provided that it is above the min size.

All of this only applies when inheriting. When the font size is
manually set, scriptminsize does not apply, and both the real and
unconstrained size are set to the explicit value. However, if the font
size is manually set to an em or percent unit, the unconstrained size
will be set to the value of that unit computed against the parent
unconstrained size, whereas the font size will be set computing against
the parent font size.

MozReview-Commit-ID: 820BIWqno3L
2017-04-19 22:19:55 -07:00
Cameron McCormack
408100818d Revert #16517 for Gecko heap write hazard failures. 2017-04-19 16:35:23 +10:00
Manish Goregaokar
681df60191 stylo: System font support for bitflag properties and font-language-override 2017-04-18 09:46:03 -07:00
Manish Goregaokar
5b06a32032 stylo: System font support for keyword font longhands 2017-04-18 09:45:41 -07:00
Manish Goregaokar
2c5ac9fc2d stylo: Add basic system font support, use for font-size and font-family 2017-04-18 09:45:29 -07:00
Cameron McCormack
10f2d3c38e style: Add support for property value aliases.
For keyword-typed properties with aliases but no extra_specified values,
the storage of the specified and computed values could be the same,
since value aliases are resolved at parse time.  But to prevent
computed_value::T::parse from recognizing these aliases, we keep the
specified and computed value types distinct.
2017-04-17 11:24:21 +10:00
Cameron McCormack
fb26ae7df5 stylo: Generate eCSSPropertyID_all as a const rather than an enum value. 2017-04-14 13:33:21 +08:00
Manish Goregaokar
8b9163900d stylo: Cascade relative font-sizes applied to keyword sizes 2017-04-12 16:59:14 +08:00
Hiroyuki Ikezoe
c120b0b701 Introduce a macro to define Interpolate trait for tuple struct which has Option<T>.
The computed value of word-spacing is T(pub Option<LengthOrPercentage>),
the computed value of letter-spacing is similar to this, T(pub Option<Au>).
It would be nice to have re-usable macro for these kind of struct.
2017-04-07 11:21:07 +09:00
Xidorn Quan
37585309e9 Use a UrlExtraData type alias to unify url handling logic. 2017-04-03 21:57:16 +10:00
Emilio Cobos Álvarez
bcd107967b
style: Stylistic nits. 2017-03-27 12:42:30 +02:00
bors-servo
fe45283169 Auto merge of #16121 - froydnj:unused-property-mako-imports, r=cbrewster
remove unused `use` statements in mako helpers

These are no longer needed, according to `./mach build -d` and grep.

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because compilation is sufficient

<!-- 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/16121)
<!-- Reviewable:end -->
2017-03-24 20:32:06 -07:00
Manish Goregaokar
3139a90386 stylo: Special-case initial-computation of font-size
MozReview-Commit-ID: Ff6kt8RLChI
2017-03-24 11:10:35 -07:00
Nathan Froyd
5f49e38650 remove unused use statements in mako helpers
These are no longer needed, according to `./mach build -d` and grep.
2017-03-24 11:28:43 -04: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
Emilio Cobos Álvarez
9c0424cca4
style: Remove unneeded indirection in default_computed_values. 2017-03-13 21:57:57 +01:00
Simon Sapin
da6316fbe3 Return shorthand decarations as a new enum, don’t push them to a Vec. 2017-03-07 23:37:26 +01:00
Emilio Cobos Álvarez
dffba35d83
style: Remove unneeded indirection in LonghandsToSerialize. 2017-03-06 08:04:22 +01:00
Xidorn Quan
4bc0fbeeb1 Impl ToCss on LonghandsToSerialize directly 2017-03-02 11:10:30 +11:00
Xidorn Quan
f327b2fc73 Make LonghandsToSerialize store reference to specified value
This significantly simplify the code.
2017-03-02 11:09:06 +11:00
Xidorn Quan
03f6d21cb5 Make DeclaredValue store CSSWideKeyword
Rather than having separate variant for each CSS-wide keyword.
2017-03-02 11:09:05 +11:00
Xidorn Quan
29fd30601e Simplify values of CSSWideKeyword 2017-03-02 11:09:05 +11:00
Xidorn Quan
f33b0b4ea3 Have shorthand parsing functions return values
Shorthands are responsible to set all its longhands to a proper value,
rather than returning None.

Fixes #15380.
2017-02-28 15:24:08 +11:00
Xidorn Quan
2e07ce7e84 Add get_initial_specified_value to many longhands 2017-02-28 15:20:34 +11:00
Xidorn Quan
ce46e6d034 Remove raw_longhand helper function 2017-02-28 13:45:12 +11: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