Commit graph

385 commits

Author SHA1 Message Date
Pu Xingyu
31ad3b2949 layout: Fix integer overflow when computing size of replace elements 2017-02-09 17:08:13 +08:00
Pu Xingyu
336aa795b4 Remove cached thread local context from LayoutContext
Remove cached thread local context from LayoutContext, use LayoutContext for
assign_inline_sizes(), and simplify the parallel flow traversal code.
2017-02-08 08:47:54 +08:00
Pu Xingyu
f07bfaa974 Remove redundant style_context() method of LayoutContext 2017-02-06 00:44:11 +08:00
Michael Howell
cef4ebed20 Preserve the un-truncated version of fragments
Fixes #14952
2017-01-12 22:02:53 +00:00
Michael Howell
8a90cda09f Do not replace an ellipsis when reflowing a line
The ellipsis should be replaced, if needed, when the text itself is reflowed.
2017-01-12 21:16:27 +00:00
Bobby Holley
962a4a79bb Bug 1325734 - Remove Servo Layout's dependency on the initial-ness of the style. r=emilio 2017-01-09 11:51:36 -08:00
Martin Robinson
f3577e41c1 Move some methods from display_list_builder.rs
These methods are not only used during display list construction, so
they are a better fit for the flow structs themselves. This does
not introduce any behavior change, but should make it easier to fix
2017-01-09 12:33:23 +01:00
Emilio Cobos Álvarez
fa26e87030
layout: Remove get_font_arc in favor of clone_font.
Since they do the same.
2016-12-31 04:53:36 +01:00
Nazım Can Altınova
aeb5d34394 Move perspective and perspective-origin properties from effects to box. 2016-12-23 19:01:32 +03:00
Pu Xingyu
b0de105bb0 Various fixes
Fix the behavior of block-direction margins of replaced element both
as block level or inline level, and no longer query fragment info when
building display list for canvas.
2016-12-12 18:10:39 +08:00
Pu Xingyu
b1b17f1869 Remove some unused methods
Simply use `Fragment::is_replaced()` in block, and remove
`content_inline_size()` method from Fragment.
2016-12-12 18:10:37 +08:00
Pu Xingyu
07250a7d58 Remove unused replaced size calculation methods
Remove some fields and methods from SpecificFragmentInfo and change
some function signatures.
2016-12-12 18:10:36 +08:00
Pu Xingyu
19a4f8f6c1 Switch to new methods for size calculation of replaced elements
Use `calculate_replaced_sizes()` in `compute_intrinsic_inline_sizes()`
and `assign_replaced_inline_size_if_necessary()`, and remove size
calculation in `assign_replaced_block_size_if_necessary()`, since
we've already done that.
2016-12-12 18:09:52 +08:00
Pu Xingyu
d3ab919745 Add new methods to Fragment for size calculation of replaced element
These new methods calculate both the used width and height of an
replaced element and the same time. The `has_intrinsic_ratio()` method
also exposes information about whether a fragment has intrinsic aspect
ratio.
2016-12-12 15:37:12 +08:00
Pu Xingyu
39780e894b Rename the MinMaxConstraint to SizeConstraint and enhancement
Renamed to `SizeConstraint`, add an optional `border` parameter to
deal with `box-sizing: border-box`, and fix its bug when involving
with `calc`.
2016-12-11 00:54:00 +08:00
Bobby Holley
80460cc549 Make Restyle tracking more granular.
The primary idea of this patch is to ditch the rigid enum of Previous/Current
styles, and replace it with a series of indicators for the various types of
work that needs to be performed (expanding snapshots, rematching, recascading,
and damage processing). This loses us a little bit of sanity checking (since
the up-to-date-ness of our style is no longer baked into the type system), but
gives us a lot more flexibility that we'll need going forward (especially when
we separate matching from cascading). We also eliminate get_styling_mode in
favor of a method on the traversal.

This patch does a few other things as ridealongs:
* Temporarily eliminates the handling for transfering ownership of styles to the
  frame. We'll need this again at some point, but for now it's causing too much
  complexity for a half-implemented feature.
* Ditches TRestyleDamage, which is no longer necessary post-crate-merge, and is
  a constant source of compilation failures from either needing to be imported
  or being unnecessarily imported (which varies between gecko and servo).
* Expands Snapshots for the traversal root, which was missing before.
* Fixes up the skip_root stuff to avoid visiting the skipped root.
* Unifies parallel traversal and avoids spawning for a single work item.
* Adds an explicit pre_traverse step do any pre-processing and determine whether
  we need to traverse at all.

MozReview-Commit-ID: IKhLAkAigXE
2016-12-09 14:46:40 -10:00
Simon Sapin
b203ab2419 Rename selector_impl.rs to selector_parser.rs
This makes it consistent with an upcoming update of the selectors crate.
2016-11-20 15:30:37 +01:00
Emilio Cobos Álvarez
913c874cb5
Urlmageddon: Use refcounted urls more often. 2016-11-17 18:34:23 +01:00
Manish Goregaokar
bb5f351f4a stylo: support transform 2016-11-10 16:38:15 -08:00
Pu Xingyu
eb22d33d4e style: Add a "start_end()" method to LogicalMargin
Add a `LogicalMargin::start_end()` method that receives a `Direction'
parameter. This is useful for some layout that is symmetric in inline
and block directions, like flexbox.
2016-11-10 19:17:29 +08:00
bors-servo
a91f48ee05 Auto merge of #13924 - cynicaldevil:text-overflow, r=emilio
implemented string-valued text-overflow

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

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

cc @Manishearth
The lorem-ipsum example from MDN works as expected.

<!-- 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/13924)

<!-- Reviewable:end -->
2016-11-09 16:36:45 -06:00
Nikhil Shagrithaya
4b2737606d implemented string-valued text-overflow 2016-11-10 00:00:21 +05:30
bors-servo
35f328d717 Auto merge of #14049 - Wafflespeanut:lon, r=SimonSapin
Add a generic type for sharing some CSS types

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

This would be useful for types such as `T(pub Option<U>)` or any type that's a mixture of two types (like `LengthOrFoo` for example). Well, it's a bit ugly, especially because we have to address the types as `Either::First` and `Either::Second` everywhere, but I don't have a brighter idea 😄

---
<!-- 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 it's a refactor

r? @SimonSapin (cc @Manishearth @emilio)

<!-- 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/14049)
<!-- Reviewable:end -->
2016-11-09 08:15:16 -06:00
Ravi Shankar
c4fc49c559 Make use of Either<A, B> for LengthOrNone 2016-11-09 13:04:26 +05:30
Pu Xingyu
7f721e1f2c layout: Mark flex items properly during construction
Set the flag of the fragment of children in a flex container according
to the direction of the container. The mark is done on the fragment
because flex item enstablish a stacking context when its z-index is
non-zero ,despite its `position' property.
2016-11-09 08:24:12 +08:00
bors-servo
ef5ca14283 Auto merge of #14084 - mrobinson:scroll_root_2, r=glennw
Don't promote all scrollable regions to stacking contexts

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

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.

---
<!-- 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 #13529 and #13298. (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/14084)
<!-- Reviewable:end -->
2016-11-07 18:49:53 -06:00
Bobby Holley
a2c7a9d0fb Stop using associated types for the concrete TRestyleDamage implementation.
MozReview-Commit-ID: LfaZFCVlIb1
2016-11-07 11:10:48 -08:00
Shing Lyu
8bea421329 Migrated -Z trace-layout to serde_json 2016-11-07 15:54:07 +08:00
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