Commit graph

500 commits

Author SHA1 Message Date
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
Darin Minamoto
4a4be1d7e5 Image with height defined in % resizes properly 2016-06-15 16:39:22 -07:00
Ms2ger
6a1722e18d Make layout only depend on script::layout_interface. 2016-06-07 13:46:49 +02:00
bors-servo
5002dff853 Auto merge of #11442 - mitchhentges:87-debug-id, r=KiChjang
Fragment debug_id u16 only exists in debug, prod will format mem address

<!-- Please describe your changes on the following line: -->
Each fragment has a `u16` `debug_id` in debug mode, but no `debug_id` in production to save memory. To format a debug id in production, the address of the empty `debug_id` is displayed.

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

<!-- Either: -->
- [X] These changes do not require tests because it looks like it's not possible to mock out `cfg` options in `#[test]`s

<!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11442)
<!-- Reviewable:end -->
2016-06-04 16:03:59 -05:00
Mitchell Hentges
43396c027d Fragment debug_id u16 only exists in debug, prod will format mem address 2016-06-04 19:19:42 +02:00
bors-servo
cc7953e25e Auto merge of #11035 - mrobinson:no-stacking-contexts-for-text-fragments, r=pcwalton
Do not create stacking contexts for text fragments

Without this change, each text fragment in a block that establishes a
stacking context will establish its own stacking context. This is
unnecessary and increases the amount of work done during display list
construction. This change should not change output, but should improve
performance.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11035)
<!-- Reviewable:end -->
2016-06-01 19:22:22 -05:00
Martin Robinson
7e4cf6a4dc Do not create stacking contexts for text fragments
Without this change, each text fragment in a block that establishes a
stacking context will establish its own stacking context. This is
unnecessary and increases the amount of work done during display list
construction.
2016-06-01 15:24:02 -07:00
Patrick Walton
a86f77e36d script: Keep the DOM-side viewport up to date when scrolling happens in
WebRender.

This happens asynchronously, just as it does in non-WebRender mode.

This functionality is a prerequisite for doing proper display-list-based
hit testing in WebRender, since it moves the scroll offsets into Servo
(and, specifically, into the script thread, enabling iframe event
forwarding) instead of keeping them private to WebRender.

Requires servo/webrender_traits#55 and servo/webrender#277.

Partially addresses #11108.
2016-05-31 14:12:51 -07:00