Commit graph

507 commits

Author SHA1 Message Date
Martin Robinson
ef82d772c1 Don't promote all scrollable regions to stacking contexts
Instead annotate all flows with their owning ScrollRoots. When
processing the display list items into a flattened display list, we add
PushScrollRoot and PopScrollRoot to signal when scrolling regions start
and end. It is possible for content from different scrolling regions to
intersect and when they do, the stack of scrolling regions is
duplicated.  When these duplicated scrolling regions stacks reach
WebRender, it will scroll them in tandem.

The PushScrollRoot and PopScrollRoot items are currently represented as
StackingContexts in WebRender, but eventually these will be replaced
with special WebRender display items.

Fixes #13529.
Fixed #13298.
2016-11-05 18:36:45 +01:00
Michael Howell
5f320bd2ca Make FlowRef a newtype
This creates a sharp distinction between `Arc<Flow>`s, which may be
owned by anyone, and `FlowRef`s, which may only be owned by the
traversal code. By checking the reference count, we ensure that a `Flow`
cannot be pointed to by `Arc`s and `FlowRef`s simultaneously.

This is not a complete fix for #6503, though it is a necessary start
(enforcing the no-aliasing rule of `FlowRef::deref_mut` will require far
more work).

Fixes #14014
2016-11-04 13:36:04 -07:00
Simon Sapin
53b638c0e2 Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
Bobby Holley
46e29184bd Move core pseudo-element handling to ThreadSafeLayoutElement. 2016-10-28 10:47:57 -07:00
Patrick Walton
ce2e5dc707 layout: Make intrinsic inline sizes take the value of box-sizing into
account.
2016-10-26 14:14:13 -07:00
Patrick Walton
d222e3e8a3 layout: Assign border and padding to tables instead of table wrappers.
This is more straightforward when anonymous table object generation is
involved.
2016-10-26 14:14:12 -07:00
Patrick Walton
bc2f5864bc layout: Rewrite the anonymous table object generation code.
This patch introduces a "legalizer", which encapsulates all the
anonymous flow generation logic in one place. The legalizer knows how
to, for example, place adjacent blocks with `display: table-cell` in the
same table row.

Improves etsy.com.

Closes #13782.
2016-10-26 14:14:05 -07:00
Patrick Walton
179547b68f layout: Make surrounding_intrinsic_inline_size report border/padding
and margin separately.

This makes correct table layout easier.
2016-10-26 14:04:12 -07:00
Patrick Walton
41976c0afc layout: Remove margins from inline absolute hypothetical boxes.
As they're hypothetical, their margins shouldn't take up space!

Improves Google search results.

Closes #13915.
2016-10-25 18:52:17 -07:00
Martin Robinson
ccb7ab926a Remove concept of Layers from Servo
Layers were a feature of the legacy drawing path. If we re-add them at
some point, it probably makes more sense to make them a product of
display list inspection.

This change also remove a bunch of dead painting code.
2016-10-21 08:38:34 +02:00
Patrick Walton
d5443ee450 layout: Make percentages in top and bottom for relative positions
relative to height, not width.

Improves etsy.com.

Closes #13760.
2016-10-14 11:15:39 -07:00
Patrick Walton
c25dd2adf6 layout: Use the margin box for vertical positioning of inline-block
fragments if `overflow` is not `visible` per CSS 2.1 § 10.8.1.

Additionally, this patch reverts the change introduced in #12642 in
favor of the spec-compliant behavior described above. This patch also
removes the `inline_block_overflow.html` reftest introduced in #3725, as
the behavior it expected contradicted CSS 2.1 (and in fact the test
fails in Gecko).

The changes that this patch makes to `input_selection_a.html` and
`input_selection_incremental_a.html` are necessary workarounds to make
the tests pass in light of the fact that Servo's UA stylesheet applies
`overflow: hidden` to `<input>` elements. I believe that the changes are
not necessary in other rendering engines because they hard-code
`overflow: hidden`-like behavior for `<input>` elements, while Servo
uses the actual CSS `overflow: hidden` behavior. As far as I can tell,
Servo's behavior is arguably more spec-compliant, but it remains to be
seen how Web compatible it is.

Improves the Google results pages.

Closes #13707.
2016-10-13 09:36:02 -07:00
Patrick Walton
773614f84c layout: Rewrite Servo's vertical-align support to match CSS 2.1 §
10.8, and implement `vertical-align: middle` per CSS 2.1 § 10.8.1.

`InlineMetrics` has been split into `InlineMetrics` for fragments and
`LineMetrics` for lines. Both structures' fields have been renamed in
order to more clearly delineate the difference between *space* and
*content*. Vertical positioning of fragments has been reworked to take
margins and borders into account only for replaced content.

This patch fixes the `vertical_align_super_a.html` reftest. Servo now
matches the rendering that Gecko and WebKit produce.

Additionally, this includes a test for the popular inline-block
centering technique described here:
https://s.codepen.io/shshaw/fullpage/gEiDt?#Inline-Block
2016-10-11 12:47:50 -07:00
bors-servo
dad3b4785a Auto merge of #13589 - splav:SVGElement#12974, r=pcwalton,Ms2ger
Support SVG element

<!-- Please describe your changes on the following line: -->
minimal SVG element implementation
---
<!-- 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 #12974 (github issue number if applicable).

<!-- Either: -->
- [x] 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/13589)
<!-- Reviewable:end -->
2016-10-07 17:40:13 -05:00
Alexandrov Sergey
14934a42d7 add SVG fragment (SpecificFragmentInfo::Svg) 2016-10-07 21:41:02 +03:00
Patrick Walton
5232b0c85f layout: Place inline absolute hypothetical boxes properly during block
fragment position assignment.

Improves Rust documentation.

Closes #13471.
2016-10-04 18:40:40 -07:00
bors-servo
19a5a30113 Auto merge of #13387 - emilio:debug-assertions, r=aneeshusa,jdm,pcwalton
Honor SERVO_ENABLE_DEBUG_ASSERTIONS on the build machines.

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

As part of #13127.

cc @aneeshusa

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

<!-- 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/13387)
<!-- Reviewable:end -->
2016-10-04 14:01:49 -05:00
Bobby Holley
5bcc4192bf Stop using Ref::map for selected_style and resolved_style.
Same concept as the previous patch.

MozReview-Commit-ID: RFC8s7qQPM
2016-10-02 19:19:52 -07:00
Bobby Holley
18d552a1e9 Stop using Ref::map for style().
It's not possible to implement a Ref::map equivalent method on AtomicRefCell
while having AtomicRefCell implemented on top of RwArc. We could potentially
reimplement AtomicRefCell to be more like RefCell and add a Ref::map equivalent
method, but I (and pcwalton) think we should try just cloning a few extra
Arcs at these callsites instead.

MozReview-Commit-ID: 6H8vAWguO3z
2016-10-02 19:19:52 -07:00
Emilio Cobos Álvarez
bdf1d179ba
layout: Use the fragment's writing mode when computing sizes relevant to that fragment.
Otherwise we might mix writing modes. Not totally sure this change is correct in
the case we're mixing them, we might need to just not checking that operation.
2016-10-02 17:57:07 +02:00
Felipe Lacerda
fb66abba74 combine normal and keep-all into a single strategy 2016-09-27 20:07:32 +02:00
Felipe
e0a48fe596 Use word-break to decide how glyph runs should be created 2016-09-27 11:25:21 +02:00
Felipe
d5669ead29 Implement word-break: keep_all 2016-09-27 11:25:21 +02:00
Martin Robinson
68ae97fd0e Add support for background-repeat: space and round
This adds support for more background-repeat modes using the legacy
rendering backend.
2016-09-22 13:20:08 +02:00
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00
bors-servo
6191748907 Auto merge of #13012 - servo:shared-layout-context, r=nox
Stop creating a LayoutContext in build_display_list_for_subtree.

<!-- 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/13012)
<!-- Reviewable:end -->
2016-08-24 09:38:31 -05:00
bors-servo
3993fde90a Auto merge of #12935 - shinglyu:layout_json, r=glennw
Fixed layout flow tree JSON serialization

<!-- Please describe your changes on the following line: -->
The second argument for the `emit_struct()` is the number of fields, if given `0`, the output JSON will always be empty.

This is used in `./mach run -d -Z trace-layout https://servo.org`, which will dump the layout flow tree into a `layout_trace.json` file for debugging.

This also unblocks https://github.com/servo/servo/issues/12675

---
<!-- 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] These changes do not require tests because its a debugging tool, not critical for normal code path

<!-- 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/12935)
<!-- Reviewable:end -->
2016-08-23 21:43:13 -05:00
Ms2ger
938569e3c7 Pass SharedLayoutContext to ImageFragmentInfo::new. 2016-08-23 17:32:06 +02:00
Ms2ger
7524e5549f Pass SharedStyleContext to CanvasFragmentInfo::new. 2016-08-23 17:13:11 +02:00
Ms2ger
d00d9994e9 Pass SharedStyleContext to ReplacedImageFragmentInfo::new. 2016-08-23 16:58:55 +02:00
Ms2ger
0cb0c6bc4e Move image fetching methods to SharedLayoutContext. 2016-08-23 16:13:23 +02:00
Nazım Can Altınova
a14f6cb7e7 Fix wrong calculation of inline element's block size 2016-08-22 11:17:41 +03:00
Shing Lyu
a07be4c850 Fixed layout flow tree JSON serialization 2016-08-19 15:29:25 +08:00
Anthony Ramine
fc6faf72ee Update Rust to 1.12.0-nightly (1deb02ea6 2016-08-12) 2016-08-13 18:34:44 +02:00
Alexandrov Sergey
ba0a670876 reduce max_inline_size inside breaking strategy by border_padding 2016-08-08 19:45:32 +03:00
bors-servo
15947f8f73 Auto merge of #12330 - stshine:flexitem, r=pcwalton
Implement flexible box layout for row container

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

This pull requests implements basic flexible box layout for row container.
It  has implemented most basic flexbox features, including grow, shrink, multi-line, *reverse properties, and alignment under `justify-content`, `align-items`, `align-self`, `align-content`.

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

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

r? @pcwalton

<!-- 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/12330)
<!-- Reviewable:end -->
2016-08-03 09:24:31 -05:00
Pu Xingyu
60e2f44a19 Add Minor fixes and tests 2016-08-03 21:10:35 +08:00
Michael Howell
afbd047695 Use explicit height of inline-block fragments
Fixes #12492
2016-07-28 16:04:53 -07:00
bors-servo
a3e8199c97 Auto merge of #12388 - kilobtye:textarea2, r=pcwalton
Let textarea wrap lines

<!-- Please describe your changes on the following line: -->
1. Change textarea's style from white-space: pre to white-space: pre-wrap.
2. Display insertion point when a line is wrapped.

---
<!-- 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 #10053 (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/12388)
<!-- Reviewable:end -->
2016-07-26 08:31:49 -05:00
kilobtye
0a86543e6d Let textarea wrap lines 2016-07-26 20:38:11 +08:00
Pu Xingyu
62dd3f4df4 Refator 'box-sizing' calculation into a method
The 'box_sizing_boundary()' method return the border_padding width in
certain direction if fragment has property 'box-sizing: border-box'. The
'border_padding' field should be initialized before.
2016-07-25 20:59:04 +08:00
Simon Sapin
789807b7b0 Remove the ComputedValue traits and style_struct_traits 2016-07-20 08:42:40 +02:00
Ms2ger
9f13278b77 Move arc_ptr_eq to style. 2016-07-11 12:13:12 +02:00
Emilio Cobos Álvarez
383ba964ab
layout: text: Don't consider the REQUIRES_LINE_BREAK_AFTERWARD_IF_WRAPPING_ON_NEWLINES if the fragment can wrap text.
This was making us fall in a loop where the start split was empty, but we didn't
ignore it because the current fragment had this flag, but then we treated it
differently depending on the white_space property.

Not totally sure this is the proper fix, but it makes sense to me. In case it
is:

Fixes #12369.
2016-07-10 15:34:57 -07:00
Anthony Ramine
8ecb5962f3 Move util::str to style 2016-07-05 10:43:54 +02:00
Michael Howell
46396d7f3b Do not merge text fragments of differing colors
The display list item for a line of text has a single color assigned for
it, so text fragments with different colors cannot be merged.

There is no issue number for this, as far as I know. I found this while
trying an internal program that uses red asterisks for required text
fields.
2016-06-28 20:26:49 -07:00
Ms2ger
0d0b268138 Move LayoutNode and related traits to script_layout_interface. 2016-06-20 19:07:54 +02:00
Ms2ger
000e2de57a Move HTMLCanvasData to script_layout_interface. 2016-06-20 19:04:41 +02:00
Ms2ger
5c03dd8eb1 Introduce a script_layout_interface crate and move RestyleDamage to it. 2016-06-20 19:02:36 +02:00
Michael Howell
4717cea51c Account for the font of empty input fields
Fixes #11653
2016-06-19 13:06:06 -07:00