Commit graph

674 commits

Author SHA1 Message Date
Simon Sapin
aeffca2a59 Replace RwLock<StyleRule> with Locked<StyleRule> 2017-03-19 22:30:37 +01:00
Bobby Holley
97dd3a1b08 Box more specified values to bring SpecifiedValue/PropertyDeclaration sizes down to 24/32 bytes.
MozReview-Commit-ID: xstAfjVQqi
2017-03-17 22:18:19 -07:00
Xidorn Quan
ab0e5c9d99 Switch column-count to use predefined integer type 2017-03-17 23:08:05 +11:00
Simon Sapin
9ff0153dda Rewrite PropertyDeclaration::id to help the optimizer.
If I’m reading the release-mode assembly correctly, before this change
PropertyDeclaration::id is implemented with a computed jump:

```assembly
	lea	rcx, [rip + .LJTI117_0]
	movsxd	rax, dword ptr [rcx + 4*rax]
	add	rax, rcx
	jmp	rax
.LBB117_3:
	mov	dword ptr [rdi], 65536
	mov	rax, rdi
	ret
.LBB117_2:
	mov	dword ptr [rdi], 0
	mov	rax, rdi
	ret
.LBB117_4:
	mov	dword ptr [rdi], 131072
	mov	rax, rdi
	ret
.LBB117_6:
	mov	dword ptr [rdi], 262144
	mov	rax, rdi
	ret
.LBB117_7:
	mov	dword ptr [rdi], 327680
	mov	rax, rdi
	ret

; Four similar lines repeated for each of the few hundred variants...
```

With Rust 1.15 (currently used for geckolib)
this doesn’t change significantly.
In Nightly 1.17 however, the compiled code uses a lookup table,
possibly thanks to https://github.com/rust-lang/rust/pull/39456.

```assembly
	movq	(%rsi), %rax
	cmpq	$171, %rax
	jne	.LBB23_1
	addq	$8, %rsi
	movq	%rsi, 8(%rdi)
	movb	$1, %al
	jmp	.LBB23_3
.LBB23_1:
	xorq	$128, %rax
	leaq	.Lswitch.table.6(%rip), %rcx
	movb	(%rax,%rcx), %al
	movb	%al, 1(%rdi)
	xorl	%eax, %eax
.LBB23_3:
	movb	%al, (%rdi)
	movq	%rdi, %rax
	retq
```
2017-03-17 01:09:30 +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
Bobby Holley
6744ed1639 Run size_of tests with test-stylo.
MozReview-Commit-ID: KapDMqX6OjH
2017-03-15 11:17:51 -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
eaf27ccfa0
style: Kill SharedStyleContext::default_computed_values.
Now that cascade() gets a Device, we can use the default computed values from
there to avoid propagating that state all over the place.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-03-14 00:49:16 +01:00
Matt Brubeck
16e318d055
Add support for non-standard -moz color keyword values.
Closes #15928
2017-03-14 00:49:08 +01:00
Emilio Cobos Álvarez
9c0424cca4
style: Remove unneeded indirection in default_computed_values. 2017-03-13 21:57:57 +01:00
Hiroyuki Ikezoe
448b74ba18 Cascade animation-name property earlier than other animation properties.
As per the CSS Animations spec, in the case when multiple values for an
animation property are set, if the value length is less than the length
of animation-name property, then shortage values are filled up. Because
of this we need to know the length of animation-name proper before we
set other animation properties, so we need to cascade animation-name property
earlier than other animation properties.
We do the same thing for transition-property.
2017-03-13 12:42:18 +09:00
bors-servo
dc3b32c853 Auto merge of #15861 - projektir:make-text-decoration-testable, r=Wafflespeanut
Make text decoration testable and do not serialize initial text-decoration-style

Servo now uses the same name for the text-decoration-line longhand property as Gecko. This was done to enable testing of the text-decoration shorthand.

The text-decoration shorthand has been fixed to not serialize initial text-decoration-style.

---

- [x ] `./mach build -d` does not report any errors
- [x ] `./mach test-tidy` does not report any errors
- [x ] These changes fix #15790

---

- [x ] There are tests for these changes

<!-- 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/15861)
<!-- Reviewable:end -->
2017-03-08 21:39:30 -08:00
projektir
b4c50de31e Don't serialize initial text-decoration-style #15790 2017-03-09 00:33:17 -05:00
Simon Sapin
446aaa5845 Better variable name, remove obsolete comment 2017-03-08 12:03:47 +01: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
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
da6316fbe3 Return shorthand decarations as a new enum, don’t push them to a Vec. 2017-03-07 23:37:26 +01:00
Xidorn Quan
6273fa0305 Make animation-name parse none 2017-03-06 22:00:04 +11:00
Jyotsna Prakash
27b60135be replace match with if-let 2017-03-05 17:52:39 -08: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
2cc6593fa1 Don't serialize shorthand when some but not all of its longhands are CSS-wide keyword
Shorthand cannot represent CSS-wide keyword in individual longhands, and
thus we cannot serialize longhand with CSS-wide keyword as part of a
shorthand.
2017-03-02 11:09:05 +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
Simon Sapin
288ef97055 Update cssparser for https://github.com/servo/rust-cssparser/pull/123 2017-02-28 17:16:36 +01: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
bors-servo
cecbc33c01 Auto merge of #15742 - emilio:stylo-orig-display, r=bzbarsky
stylo: Fix adjustment of the display property to save mOriginalDisplay properly.

r? @heycam

<!-- 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/15742)
<!-- Reviewable:end -->
2017-02-27 07:54:30 -08:00
Simon Sapin
d007eef5c7 Remove some accessors for public fields.
(Maybe they date from this was a trait?)
2017-02-26 19:24:51 +01:00
Simon Sapin
e0c63efe01 Remove/don’t call no-op compute_font_hash method for stylo.
This removes a potentially-costly Arc::mut call.
2017-02-26 19:24:51 +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
Simon Sapin
16a34ef6b6 Remove PropertyBitField::{get,set}_* methods 2017-02-26 19:02:54 +01:00
Simon Sapin
86562992da Cascade: skip duplicated properties before rather than after a virtual call. 2017-02-26 19:02:53 +01:00
Simon Sapin
0b4877590f Move deduplicate_property_declarations to PropertyDeclaration::deduplicate 2017-02-26 19:02:51 +01:00
Simon Sapin
066c5a01b2 Rewrite deduplicate_property_declarations to not require Mako. 2017-02-26 19:02:51 +01:00
Emilio Cobos Álvarez
f695789aaa
stylo: Fix adjustment of the display property to save mOriginalDisplay properly. 2017-02-26 13:23:18 +01:00
bors-servo
94e563e4d9 Auto merge of #15735 - servo:cssparserup, r=emilio
Update cssparser to 0.11

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

<s>Depends on https://github.com/servo/rust-cssparser/pull/122.</s>

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/15735)
<!-- Reviewable:end -->
2017-02-26 02:19:32 -08:00
Simon Sapin
2f996e34f5 Use ascii_case_insensitive_phf_map! in PropertyId::parse 2017-02-26 11:10:33 +01: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
bors-servo
eb281531f8 Auto merge of #15730 - emilio:adjust-float, r=SimonSapin
style: Adjust float if the element is positioned per CSS 2.1 section 9.7

We've found crashes related to this in Gecko.

r? @simonsapin or @heycam

<!-- 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/15730)
<!-- Reviewable:end -->
2017-02-25 12:23:36 -08:00
Emilio Cobos Álvarez
6875c65d37
Bug 1341083: Implement dynamic restyling for display: contents. r=heycam
MozReview-Commit-ID: KimTU2j4V4p
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-02-25 19:58:56 +01:00
Emilio Cobos Álvarez
e67f5c7585
style: Adjust float if the element is positioned per CSS 2.1 section 9.7
We've found crashes related to this in Gecko.
2017-02-24 21:28:56 +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
Hiroyuki Ikezoe
279a50fb74 Make PropertyFiledBit usable for TransitionProperty. 2017-02-22 19:04:43 +09:00
Manish Goregaokar
1541a2d154 Actually include file with marker shorthand 2017-02-18 23:20:39 -08:00
deror1869107
2dec238d1c Use bitflags for multikeyword properties 2017-02-19 01:22:56 +08:00