Commit graph

2636 commits

Author SHA1 Message Date
CYBAI
baccc4eda2 Use specific negative assertion for layout floats 2018-01-26 01:55:24 +08:00
CYBAI
bb7964a4bb Use specific assertion for layout multicol 2018-01-26 01:01:01 +08:00
CYBAI
da4a4475de Use specific assertion for layout layout_debug 2018-01-26 01:01:01 +08:00
bors-servo
9c13073075 Auto merge of #19688 - Manishearth:linebreak, r=mbrubeck
Detect adjoining text fragments with no line break opportunity between them

First attempt at https://github.com/servo/servo/issues/874

<!-- 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/19688)
<!-- Reviewable:end -->
2018-01-24 22:42:59 -06:00
Jon Leighton
84713df622 Allow floats to impact list item marker position
Although not required by the specification, this matches the rendering
of Gecko and Blink.

Fixes #19796.
2018-01-24 12:26:32 +01:00
Manish Goregaokar
fc97f0b464 do not preserve suppress flag on second half of split 2018-01-24 14:31:07 +05:30
Manish Goregaokar
f3c81fcda8 Share line breaking state across text runs
Fixes #874
2018-01-24 12:51:33 +05:30
Emilio Cobos Álvarez
5ac12b5df4
style: Make the TElement type arrive to the cascade function.
Not super-proud of this one, but it's the easiest way I could think of.

The changeset looks bigger than what it is, because while at it I've rewrapped a
fair amount of functions around to use proper block indentation.

Alternatives are parameterizing Stylist by <E>, which is not fun, or moving the
concrete element from layout_thread to layout, but that implies layout depending
on script, which isn't fun either.

Other alternative is implementing an empty enum and making anon boxes work on
it. It has the advantage of removing the annoying type parameter, but the
disadvantage of instantiating `cascade` twice, which isn't great, and having to
maintain all the boilerplate of a `TElement` implementation that just does
nothing.
2018-01-23 00:57:54 +01:00
bors-servo
c1ed4bb2d5 Auto merge of #19829 - servo:rustup, r=nox
Update Rust and use the newly-stable std::ptr::NonNull

<!-- 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/19829)
<!-- Reviewable:end -->
2018-01-22 11:11:44 -06:00
Simon Sapin
10ec5a2bb0 Replace NonZero<*{const,mut} _> with std::ptr::NonNull 2018-01-22 17:41:25 +01:00
Simon Sapin
897a5b39c5 Fix some "unnecessary parentheses" warnings 2018-01-22 17:41:25 +01:00
bors-servo
ec8975b18d Auto merge of #19789 - ferjm:issue-18831-fb-layout, r=mbrubeck
Do not leave space below baseline when it is not needed (i.e.there is…

… no text)

This is my first layout fix and a naive approach to fix #18831.

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

<!-- 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/19789)
<!-- Reviewable:end -->
2018-01-22 08:14:29 -06:00
Fernando Jiménez Moreno
a241bed53c Do not leave space below baseline when it is not needed (i.e.there is no text) 2018-01-22 11:38:39 +01:00
bors-servo
59033e6970 Auto merge of #19798 - gootorov:move_cursor_from_mako, r=emilio
style: Move cursor property out of mako

<!-- Please describe your changes on the following line: -->
Sub-PR of #19015

r? emilio

---
<!-- 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 build-geckolib` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #19775 (github issue number if applicable).

<!-- Either: -->
- [x] These changes do not require tests

<!-- 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/19798)
<!-- Reviewable:end -->
2018-01-20 12:10:58 -06:00
Igor Gutorov
4ee9eb8563 style: Move cursor property out of mako 2018-01-20 19:06:29 +02:00
Anthony Ramine
a311e0f569 Merge layout and layout_tests 2018-01-20 15:33:39 +01:00
Pyfisch
af52233ae5 Introduce MaxRect trait
It is implemented for LayoutRect and Rect<Au>.
Replaces the max_rect() function from servo_geometry.
2018-01-17 23:29:57 +01:00
Pyfisch
8c7c5f6e79 Use more WebRender types in gfx/display_list
This uses floating-point (Layout) coordinates in where possible.
Replace NormalBorder struct with WebRender equivalent.
Remove ToPointF and ToRectF traits.
Convert border RepeatKeyword with ToLayout.
Add some definitions to malloc_size_of for WebRender types.
2018-01-17 23:29:57 +01:00
Glenn Watson
cad21f1c0b Update WR (persistent box-shadow render task cache) 2018-01-18 06:06:03 +10:00
bors-servo
f2036e7661 Auto merge of #19757 - emilio:bye-custom-cascade, r=nox
style: Remove -servo-text-decorations-in-effect

It is bogus, because it depends on the display property as it's cascaded, but
the display property can change afterwards, for example, if we get blockified
because we're the root element or a flex item.

Replace it with a normal field instead.

Also, it carries some weight, because it's the last property that uses this
concept of "derived" property, and "custom cascade". So we can remove some code
after this.

Compute it after the cascade process in StyleAdjuster.

<!-- 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/19757)
<!-- Reviewable:end -->
2018-01-15 05:14:49 -06:00
Emilio Cobos Álvarez
95edda93c4
layout: Add a FIXME for #19771. 2018-01-15 03:12:22 +01:00
Emilio Cobos Álvarez
ecf538ff04
layout: Avoid doing stupid calls to Node::style. 2018-01-15 03:09:13 +01:00
Emilio Cobos Álvarez
bc29a16285
layout: Deduplicate Node::fragment_type and FragmentDisplayListBuilding::fragment_type. 2018-01-14 21:45:39 +01:00
Emilio Cobos Álvarez
e32d6f6adf
layout: Remove type parameter from PseudoElementType.
Everyone uses () now.
2018-01-14 21:45:39 +01:00
Emilio Cobos Álvarez
cb2bba8777
style: Remove unused optional display from PseudoElementType definition.
Everyone passes None now.
2018-01-14 21:45:38 +01:00
Emilio Cobos Álvarez
8732a1d7de
style: Remove -servo-text-decorations-in-effect.
It is bogus, because it depends on the display property as it's cascaded, but
the display property can change afterwards, for example, if we get blockified
because we're the root element or a flex item.

Replace it with a normal field instead.

Also, it carries some weight, because it's the last property that uses this
concept of "derived" property, and "custom cascade". So we can remove some code
after this.

Compute it after the cascade process in StyleAdjuster.
2018-01-14 17:10:44 +01:00
CYBAI
0291a75b3c style: Remove -servo-display-for-hypothetical-box from longhand 2018-01-13 20:54:50 +08:00
Pyfisch
a74688b992 Remove BoxShadowClipMode from gfx 2018-01-07 23:13:41 +01:00
Pyfisch
246b54507a Use the new WebRender conversion functions.
Remove the old ones.
2018-01-07 22:53:51 +01:00
Pyfisch
71e542c424 Create a file for WebRender conversions 2018-01-07 22:29:23 +01:00
Pyfisch
ea062e6e47 Create own file for background calculations in layout
Move display_list_builder.rs and webrender_helpers.rs
along with the new file to components/layout/display_list/

Remove apparently unused IdType enum.
Only variant used was OverflowClip.

See #19676
2018-01-06 20:19:32 +01:00
bors-servo
12a74de5a1 Auto merge of #19699 - pyfisch:background-position-fix, r=emilio
Correctly place images with background-position: center

Add a regression ref test.
See also #19680.

<!-- 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] 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/19699)
<!-- Reviewable:end -->
2018-01-05 06:37:38 -06:00
bors-servo
83a8891bd4 Auto merge of #18893 - emilio:bye-can-be-fragmented, r=SimonSapin
style: Remove TNode::set_can_be_fragmented and TNode::can_be_fragmented.

Replace them instead by a computed value flag, the same way as the
IS_IN_DISPLAY_NONE_SUBTREE flag works.

<!-- 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/18893)
<!-- Reviewable:end -->
2018-01-05 05:11:00 -06:00
Pyfisch
859f002bf2 Correctly place images with background-position: center
Add a regression ref test.
See also #19680.
2018-01-05 10:45:26 +01:00
Pyfisch
8a57bff59d Remove mention of some old issues
* #228 was done (confirmed by mbrubeck)
* #2012 fixed TODO item
* servo/webrender#28 (zoom does work)
2018-01-04 20:31:41 +01:00
Emilio Cobos Álvarez
f3ea248188
style: Remove TNode::set_can_be_fragmented and TNode::can_be_fragmented.
Replace them instead by a computed value flag, the same way as the
IS_IN_DISPLAY_NONE_SUBTREE flag works.
2018-01-04 14:45:54 +01:00
Pyfisch
83bce468ea Format parts of layout
Formats the following files:
* components/layout/display_list_builder.rs
* components/layout/webrender_helpers.rs

Remove outdated options from rustfmt.toml.
Configure rustfmt to place binary operators
at the end of line (to match ./mach test-tidy).
2018-01-03 21:49:47 +01:00
Pyfisch
b3b49e3ff0 Implement correct corner clipping for background color
Add one regression ref test.

See also #19649
2018-01-03 16:16:35 +01:00
bors-servo
691bff86b6 Auto merge of #19651 - pyfisch:background-placement, r=emilio
Unify background placement code

Merges the implementations for background-image placement
from gradients and images. Add missing parts and fix bugs.

Now supported are the CSS properties:

* background-attachment (except for local value, see #19650)
* background-clip
* background-origin
* background-position-x/y
* background-repeat
* background-size

It should be noted that backgrounds are not clipped to
rounded border corners.
(This was done before but worked only in simple cases)
See: #19649

This solves the following issues:
closes #19626
closes #16657
closes #19482 (examples from http://lea.verou.me/css3patterns/ are rendered perfectly but the round border is completely ignored now)
closes #19577

- `./mach build -d` does not report any errors
- `./mach test-tidy` does not report any errors

I enabled a few tests with the first commit but I have written about a dozen manual tests I will try to turn into ref tests either before or after this patch lands.

@bors-servo try

The relationship between the different inputs is visualized in this flowchart:
![flowchart-background](https://user-images.githubusercontent.com/2781017/34394430-5a06c72c-eb59-11e7-9d51-3d23e2215f07.png)

<!-- 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/19651)
<!-- Reviewable:end -->
2018-01-02 08:47:24 -06:00
Pyfisch
cf12e27364 Test with fixes for background repeat: spaced
Test the interaction between background-repeat: spaced
and CSS borders. Fix tile_image_axis() function.
2018-01-02 13:57:32 +01:00
bors-servo
1ce6d8ea2d Auto merge of #19652 - pyfisch:issue18435, r=emilio
Fix division by zero in gradient stop calculation

Check if total_length is zero and return 0.0 instead
of NaN in this case.

Closes #18435

<!-- 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 #18435 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [x] These changes do not require tests because simple bugfix/no idea for good test

<!-- 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/19652)
<!-- Reviewable:end -->
2018-01-01 09:38:07 -06:00
Pyfisch
4d84acda19 Remove solved FIXMEs about border radii 2017-12-29 22:21:21 +01:00
Pyfisch
94f3e3353d Fix division by zero in gradient stop calculation
Check if total_length is zero and return 0.0 instead
of NaN in this case.

Closes #18435

Regression test for crash.
2017-12-28 21:18:49 +01:00
Pyfisch
3b3d4a9853 Unify background placement code
Merges the implementations for background-image placement
from gradients and images. Add missing parts and fix bugs.

Now supported are the CSS properties:

* background-attachment (except for local value)
* background-clip
* background-origin
* background-position-x/y
* background-repeat
* background-size

It should be noted that backgrounds are not clipped to
rounded border corners.
2017-12-28 20:14:31 +01:00
bors-servo
7aae164fcd Auto merge of #19622 - tigercosmos:x2, r=shinglyu
pretty print tree

<!-- Please describe your changes on the following line: -->
```
│  │  │  │  │  │  │         floatspec-out=L 0px R 0px
│  │  │  │  │  │  │         overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│  │  │  │  │  │  │         damage=BUBBLE_ISIZES
│  │  │  │  │  │  │  └─ ↑↑ Fragment for block:
│  │  │  │  │  │  │  │         SpecificFragmentInfo::Table(2671) []
│  │  │  │  │  │  │  │         border_box=LogicalRect(H LTR, i0px×b0px, @ (i0px,b0px))
│  │  │  │  │  │  │  │         damage=REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW
│  │  │  │  ├─ Block(1268a9710)
│  │  │  │  │         sc=StackingContextId(0)
│  │  │  │  │         pos=LogicalRect(H LTR, i720px×b36px, @ (i152px,b2636.883333333333px))
│  │  │  │  │         floatspec-in=L 0px R 0px
│  │  │  │  │         floatspec-out=L 0px R 0px
│  │  │  │  │         overflow=Overflow { scroll: TypedRect(750px×36px at (-15px,0px)), paint: TypedRect(750px×36px at (-15px,0px)) }
│  │  │  │  │         children=1
│  │  │  │  │         damage=BUBBLE_ISIZES
│  │  │  │  │  ├─ ↑↑ Fragment for block:
│  │  │  │  │  │         SpecificFragmentInfo::Generic(2673) []
│  │  │  │  │  │         border_box=LogicalRect(H LTR, i720px×b36px, @ (i0px,b0px))
│  │  │  │  │  │         border_padding=LogicalMargin(H LTR, i:0px..0px b:6px..0px)
│  │  │  │  │  │         damage=REPOSITION | STORE_OVERFLOW
│  │  │  │  │  ├─ Block(128554f10)
│  │  │  │  │  │         sc=StackingContextId(0)
│  │  │  │  │  │         pos=LogicalRect(H LTR, i750px×b30px, @ (i0px,b6px))
│  │  │  │  │  │         floatspec-in=L 0px R 0px
│  │  │  │  │  │         floatspec-out=L 0px R 0px
│  │  │  │  │  │         overflow=Overflow { scroll: TypedRect(750px×30px at (-15px,0px)), paint: TypedRect(750px×30px at (-15px,0px)) }
│  │  │  │  │  │         children=6
│  │  │  │  │  │         damage=BUBBLE_ISIZES
│  │  │  │  │  │  ├─ ↑↑ Fragment for block:
│  │  │  │  │  │  │         SpecificFragmentInfo::Generic(2361) []
│  │  │  │  │  │  │         border_box=LogicalRect(H LTR, i750px×b30px, @ (i-15px,b0px))
│  │  │  │  │  │  │         margin=LogicalMargin(H LTR, i:-15px..-15px b:0px..0px)
│  │  │  │  │  │  │         damage=REPOSITION | STORE_OVERFLOW
│  │  │  │  │  │  ├─ TableWrapperFlow: Block(128555410)
│  │  │  │  │  │  │         sc=StackingContextId(0)
│  │  │  │  │  │  │         pos=LogicalRect(H LTR, i750px×b0px, @ (i-15px,b0px))
│  │  │  │  │  │  │         floatspec-in=L 0px R 0px
│  │  │  │  │  │  │         floatspec-out=L 0px R 0px
│  │  │  │  │  │  │         overflow=Overflow { scroll: TypedRect(0px×0px at (0px,0px)), paint: TypedRect(0px×0px at (0px,0px)) }
│  │  │  │  │  │  │         children=1
│  │  │  │  │  │  │         damage=BUBBLE_ISIZES
```

---
<!-- 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 #12675 (github issue number if applicable).

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

<!-- 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/19622)
<!-- Reviewable:end -->
2017-12-25 07:56:42 -06:00
tigercosmos
43c94d3445 pretty print tree 2017-12-23 14:40:06 +08:00
Yati Sagade
aa48a2c2e3 Paint worklets: Implement timeout for worklet painter threads
When a paint worklet thread takes too long, we would like to move on,
since we have a ~16ms budget for rendering @60fps. At the moment, there
is no provision in the paintworklet spec to signal such timeouts to the
developer. ajeffrey opened an [issue][1] for this, but it got punted to
v2 of the spec. Hence we are silently timing out unresponsive paint
scripts.

The timeout value is chosen to be 10ms by default, and can be overridden
by setting the `dom.worklet.timeout_ms` pref.

In the absence of such a timeout, the reftest in this commit would fail
by timing out the testrunner itself, since the paint script never
returns. From my discussions with ajeffrey, this should do until we spec
out a way to signal timeouts to the script developer.

Since we did not have a better way to trigger a timeout than a busy
waiting loop (which would hog one core of the test machine until the
timeout was reached), we decided to implement a test only blocking
sleep, available to the PaintWorkletGlobalScope. Since
`dom.worklet.enabled` enables worklets in general, we also decided to
have another pref `dom.worklet.blockingsleep.enabled`, which, in
addition to `dom.worklet.enabled`, would be required for the blocking
sleep to be available.

This fixes #17370.

[1]: https://github.com/w3c/css-houdini-drafts/issues/507
2017-12-22 10:47:23 +01:00
Nazım Can Altınova
9882d0bae5 style: Move text-align outside of the mako file. 2017-12-18 11:58:06 -06:00
bors-servo
dbfcb7bc39 Auto merge of #19568 - pyfisch:background-origin-gradients1, r=mbrubeck
layout: background-origin attribute for gradients

Fixes the glitches mentioned in #19554.
Now gradient tiles are placed in the whole bounding box.

<!-- 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

<!-- 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/19568)
<!-- Reviewable:end -->
2017-12-15 15:54:59 -06:00
Pyfisch
b0492f53af layout: background-origin attribute for gradients
Fixes the glitches mentioned in #19554.
Now gradient tiles are placed in the whole bounding box.
2017-12-15 22:16:58 +01:00