Commit graph

249 commits

Author SHA1 Message Date
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
Simon Sapin
86562992da Cascade: skip duplicated properties before rather than after a virtual call. 2017-02-26 19:02:53 +01:00
Manish Goregaokar
b85e1f5f0c stylo: Add helpers for converting Gecko keywords to Servo, use to support keyword pres attrs 2017-02-18 20:31:08 -08:00
Manish Goregaokar
ff08de8ad1 stylo: Support stroke-dasharray and stroke-dashoffset
MozReview-Commit-ID: 4QKKzJ1DVYP
2017-02-18 02:43:36 -08:00
Bobby Holley
ae87b8a910 Switch from error! and println! to warn!, and set the default log level to warn on debug builds. 2017-02-14 17:19:01 -08:00
Manish Goregaokar
6b0d3902de Factor out ClipRect type into values; use Either for clip
MozReview-Commit-ID: C3R1erJdiID
2017-02-09 15:09:35 -08:00
Manish Goregaokar
20796ee94e stylo: Implement scroll-snap-coordinate
MozReview-Commit-ID: 6mr4ktfeEGT
2017-02-09 15:09:27 -08:00
Nazım Can Altınova
adb6d20293 Box DeclaredValue::WithVariables 2017-02-09 11:10:10 +01:00
Nazım Can Altınova
78afe2b8d1 Box larger specified values to avoid memmove impact 2017-02-09 11:10:08 +01:00
Nazım Can Altınova
abc40f61c0 Replace NoViewportPercentage with a macro 2017-02-09 10:41:16 +01:00
Simon Sapin
8767b0d7cc Add font-style descriptor in @font-face 2017-02-02 19:57:40 +01:00
Hiroyuki Ikezoe
aa6372d99d Bug 1328787 - Part 9: Set Keyframe.mPropertyValues for the case where keyframe is specified. r=heycam
MozReview-Commit-ID: Ayt7IsYShl4
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
Nazım Can Altınova
77368ac48c Fix SingleSpecifiedValue in vector_longhand 2017-01-08 16:29:50 +03:00
Boris Zbarsky
8367c96c1b Bug 1298588 part 11. Pass through useful default styles to CascadePropertyFn. r=bholley 2017-01-04 23:13:49 -05:00
Manish Goregaokar
3128694bff Add spec links for margin properties, support spec links on four_sides_shorthand 2017-01-03 14:03:25 -08:00
Manish Goregaokar
6a88723409 Support logical values for float/clear 2017-01-03 14:03:10 -08:00
Manish Goregaokar
29c2db4457 Add spec argument to property helpers 2017-01-03 10:23:02 -08:00
Emilio Cobos Álvarez
b556449a96
style: Require docs in the less-straightforward part of the properties module. 2017-01-02 12:57:48 +01:00
Emilio Cobos Álvarez
277ef70d39
style: Consistently indent stuff, add a bit of documentation driving by. 2016-12-31 12:16:57 +01:00
Xidorn Quan
2a502d7377 Store unset keyword as specified value 2016-12-21 10:43:26 +11: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