Commit graph

172 commits

Author SHA1 Message Date
Manish Goregaokar
1b8458598e stylo: Support computing font-size against an arbitrary base size
MozReview-Commit-ID: 4jWcugvXR65
2017-04-19 22:10:43 -07:00
coalman
fc34b9a14d Fix indentation errors in servo rust code that tidy now finds. 2017-04-18 14:56:13 -04:00
bors-servo
c453e2ef89 Auto merge of #16473 - servo:rustup, r=emilio
Upgrade to rustc 1.18.0-nightly (5f13a3b54 2017-04-15)

This version enables [struct field reordering][1] which brings the size of the types for specified values of some CSS properties under the threshold such that they shouldn’t be boxed anymore, making unit tests fail.

Simply unboxing them moves the test failure to Stylo’s unit tests, since the stable compiler used in that case does not do field re-ordering. Therefore, we manually reorder a couple fields to effectively bring this optimization to older compilers for a few specific types.

[1]: https://github.com/rust-lang/rust/pull/40377

<!-- 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/16473)
<!-- Reviewable:end -->
2017-04-16 00:13:28 -05:00
bors-servo
91bd8f44f2 Auto merge of #16478 - yashmehrotra:fix-16423, r=Wafflespeanut
Support non-negative parsing of lengths for Either<Length, T> types

<!-- Please describe your changes on the following line: -->
Implemented a generic `impl<T> Either<Length, T>` which has a `parse_non_negative_length` method.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #16423

<!-- Either: -->
- [x] These changes do not require tests because this functionality makes code more modular and doesn't change any existing implementation.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16478)
<!-- Reviewable:end -->
2017-04-15 23:02:14 -05:00
Yash Mehrotra
de84a89827
Support non-negative parsing of lengths for Either<Length, T> types 2017-04-16 09:19:00 +05:30
Simon Sapin
daba02438d Upgrade to rustc 1.18.0-nightly (5f13a3b54 2017-04-15)
This version enables [struct field reordering][1] which brings the size
of the types for specified values of some CSS properties under the threshold
such that they shouldn’t be boxed anymore, making unit tests fail.

Simply unboxing them moves the test failure to Stylo’s unit tests,
since the stable compiler used in that case does not do field re-ordering.
Therefore, we manually reorder a couple fields to effectively bring this
optimization to older compilers for a few specific types.

[1]: https://github.com/rust-lang/rust/pull/40377
2017-04-15 14:00:00 +02: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
bors-servo
294f44eca0 Auto merge of #16382 - nox:calc-clamping, r=emilio
Don't reject out of bound calc() values at parsing-time

<!-- 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/16382)
<!-- Reviewable:end -->
2017-04-12 13:31:21 -05:00
Manish Goregaokar
6e842c373c stylo: Support mathsize, width, and scriptminsize presentation attributes in MathML 2017-04-12 22:16:01 +08:00
Anthony Ramine
12d46e7d01 Rename AllowedNumericType to AllowedLengthType 2017-04-12 13:58:38 +02:00
J. Ryan Stinnett
925af6c3f8 Disable viewport units in @page rules
Gecko disables viewport units in @page rules (bug 811391).  This makes the same
change in Servo.

MozReview-Commit-ID: 3KGiLGn619G
2017-04-12 16:40:57 +08:00
J. Ryan Stinnett
1a31b87c22 Pass ParserContext down to lengths
To make it possible to check the rule type when parsing lengths, we need to pass
the `ParserContext` down through many layers to the place where length units are
parsed.

This change leaves it unused, so it's only to prepare for the next change.

MozReview-Commit-ID: 70YwtcCxnWw
2017-04-12 16:40:48 +08:00
bors-servo
c8cd70f333 Auto merge of #16229 - tomhoule:fix-lengths, r=emilio
style: Do not immediately convert absolute specified lengths

<!-- Please describe your changes on the following line: -->

This PR aims to solve issue #15729. I tried to follow the recommendations there as much as possible.

This is my first attempt at contributing to Servo, so this will probably need a lot of input, although I'm eager to make it as polished as possible.

- The base inaccuracy issue seems solved, as can be easily verified with the `console.log` based example in the issue.
- Very basic unit tests were added.

I have doubts mainly about the right way to represent these new enum variants for the various length units:

1. With new enum variants in `NoCalcLength` *and* newtypes (current solution)
2. With a `NoCalcLength::Absolute` variant that contains a new `AbsoluteLength` enum, but without newtypes
3. Same as solution 2 but with newtypes

- I mostly cared about unit tests until now but will investigate other types of tests
- Tests to check the clamping
- Write a proper commit message

Thanks for your time and feedback :)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15729.

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16229)
<!-- Reviewable:end -->
2017-04-12 01:16:32 -05:00
Tom Houlé
7ecee05e4a Style: Do not immediately convert absolute specified lengths
The NoCalcLength::Absolute variant has been rewritten to accommodate
other units than Au with the new AbsoluteLength enum. This avoids loss
of precision for some operations.

The conversion from floating point absolute lengths to integer
application unit values adopts the same clamping limits as Gecko.
2017-04-12 11:51:57 +08:00
Manish Goregaokar
25667d0321 stylo: Use gecko's font metrics 2017-04-10 14:29:51 +08:00
Manish Goregaokar
e402c72d0e stylo: Store font metrics provider in thread local style context 2017-04-09 19:15:35 +08:00
Emilio Cobos Álvarez
846c950b6b
style: More cleanups around length parsing and viewport rule parsing. 2017-04-06 20:56:24 +02:00
Emilio Cobos Álvarez
705ecb4557
style: Multiple style nits across parsing code. 2017-04-06 20:56:23 +02:00
Carlos Martinez
b85f1a0240 Reject negative values of flex-basis.
Fixes #15902
2017-04-05 18:59:09 +02:00
bors-servo
b783cacc54 Auto merge of #16157 - n0max:perspective_parse_non_negative, r=emilio
Parse perspective property as non negative and add tests

<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15449  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16157)
<!-- Reviewable:end -->
2017-03-29 15:12:07 -05:00
n0max
20c07332a1 Parse perspective property as non negative and add tests 2017-03-28 22:57:06 +02:00
Emilio Cobos Álvarez
8175bfd60b
style: Add a note regarding why we don't need to handle percentages here. 2017-03-27 12:42:23 +02:00
Emilio Cobos Álvarez
fc72f096a0
style: Properly track whether <angle> or <time> values came from calc() expressions. 2017-03-27 12:42:22 +02:00
Emilio Cobos Álvarez
372379428b
style: Make PercentageOrNumber also reject negative percentages. 2017-03-26 19:56:55 +02:00
Nazım Can Altınova
645971b387
Rename and move PercentageOrNumber to values 2017-03-25 21:58:32 +03:00
Manish Goregaokar
fddddc9711 stylo: Calculate font-size keywords based on base size
MozReview-Commit-ID: Ff6kt8RLChI
2017-03-24 10:54:06 -07:00
Manish Goregaokar
c9198d92d5 Add separate specified value for keyword font sizes
In Gecko, these keywords compute to different values depending on the
font.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1341775
2017-03-20 00:06:04 -07:00
Emilio Cobos Álvarez
60d340d76f
style: Remove outdated comment. 2017-03-18 15:05:26 +01:00
Emilio Cobos Álvarez
1eb24f1adc
style: Allow trailing whitespace in a calc expression. 2017-03-08 17:07:54 +01:00
Emilio Cobos Álvarez
dae17dcaf3
style: Fix indentation in calc parsing code. 2017-03-08 16:54:10 +01:00
radhika2896
0138bbcdd1 Require spaces around operators in calc() (fixes #15486) 2017-03-08 14:32:25 +01:00
Xidorn Quan
2e07ce7e84 Add get_initial_specified_value to many longhands 2017-02-28 15:20:34 +11:00
Simon Sapin
0f2d000a23 Borrow input to match_ignore_ascii_case!
In cssparser version 0.11, this macro will stop implicitly borrowing its
own input.
2017-02-26 10:40:09 +01:00
Simon Sapin
4fa3e8e82c Replace 1-variant match_ignore_ascii_case! with expect_ident_matching 2017-02-26 10:39:10 +01:00
Ethan Glasser-Camp
dd4f331603 Add support for MaxLength
This builds on the ExtremumLength type from the previous commit.
2017-02-24 15:44:49 -05:00
Ethan Glasser-Camp
76de979231 Implement a MinLength type
Implement an ExtremumLength type which contains all the enumerated
keyword values for min-width, min-height, max-width, and
max-height. Then, implement a MinLength which can be used for min-width
and min-height. So far this just maps to Gecko values.

Refs #13821.
2017-02-23 16:28:26 -05:00
Nazım Can Altınova
19978f2087
Fix parsing methods of column-{gap,width} 2017-02-20 21:07:19 +03:00
Manish Goregaokar
5cc0fa5ec2 stylo: Support pixel and percent presentation attributes 2017-02-18 20:31:01 -08:00
Manish Goregaokar
895fcb222b stylo: Support nonstandard CSS_PROPERTY_NUMBERS_ARE_PIXELS behavior
MozReview-Commit-ID: 4QKKzJ1DVYP
2017-02-18 02:43:37 -08:00
Manish Goregaokar
7e4f788172 stylo: Implement tab-size
MozReview-Commit-ID: DNmtu1hm8u1
2017-02-09 10:16:33 -08:00
Sam
3682434828 Allow negative values for letter-spacing and word-spacing. Inline Length parse functions.
Signed-off-by: Sam <sam@sam.uk.net>

Use existing parse functions for any length parsing of letter-spacing and word-spacing.

Signed-off-by: Sam <sam@sam.uk.net>

Add letter-spacing test

Signed-off-by: Sam <sam@sam.uk.net>

Add tests for letter-spacing and word-spacing negative parsing.

Signed-off-by: Sam <sam@sam.uk.net>

Remove extra line.

Signed-off-by: Sam <sam@sam.uk.net>

Remove _ of _context.

Signed-off-by: Sam <sam@sam.uk.net>

Refactor tests to use new NoCalcLength

Signed-off-by: Sam <sam@sam.uk.net>

Remove unused import.

Signed-off-by: Sam <sam@sam.uk.net>

Remove un-needed use.
2017-02-06 23:52:35 +00:00
Manish Goregaokar
34ba00e6d9 Basic handling framework for presentation attributes in Stylo, with handling for font-size and color
This introduces a basic framework for servo's style system to be able
to query the style of presentation attributes which it can then insert
into the cascade. It uses that framework to implement the size and
color attributes on <font>.

There are a number of improvements that can be done on top of this:

 - Implement all other properties
 - Abstractify the ruledata parameter of the mappers using templates or virtual dispatch so that it can be a Servo decl block instead
 - Implement aforementiond abstraction over Servo decl blocks (this obsoletes the code in the first item above, so it might just be better to skip that and directly do this)
 - Replace uses of nsHTMLStyleSheet with an abstract base class containing common elements between Servo and Gecko

I'd prefer for these to be done in separate steps.
2017-02-03 17:35:44 -08:00
bors-servo
dfcfc1d2c1 Auto merge of #15278 - atheed:zero-parsing, r=Wafflespeanut
Parsing "0" as Number for line-height and border-image-outset

Fixes #15171 by correctly parsing `0` as `0` (rather than as `0px`, as was the case earlier) for the `line-height` and `border-image-outset` CSS properties. Wrote unit tests for both; `./mach test-unit -p style` passes all tests.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15171

<!-- Either: -->
- [X] There are tests for these changes.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15278)
<!-- Reviewable:end -->
2017-01-28 22:18:44 -08:00
Ravi Shankar
8d09d64856 Change LengthOrPercentageOrAutoOrContent to use NoCalcLength 2017-01-29 02:30:39 +05:30
Ravi Shankar
39ae0bbf47 Change LengthOrPercentageOrNone to use NoCalcLength 2017-01-29 02:30:37 +05:30
Ravi Shankar
bdb08b9a82 Change LengthOrPercentageOrAuto to make use of NoCalcLength 2017-01-29 02:30:34 +05:30
Ravi Shankar
590c9579f0 Change LengthOrPercentage to make use of NoCalcLength 2017-01-29 02:30:25 +05:30
Ravi Shankar
377a23df50 Refactor and modify stuff to make use of NoCalcLength 2017-01-29 02:04:24 +05:30
Ravi Shankar
4035bbd738 Split the Length type (introduce NoCalcLength) 2017-01-28 23:33:00 +05:30
Atheed Thameem
beeca1213c implement parsing of line_height and border_image_outset to parse plain zero as Number 2017-01-28 08:51:31 -05:00