Commit graph

186 commits

Author SHA1 Message Date
bors-servo
9b01a4cc97 Auto merge of #12382 - stshine:anonymous-block, r=SimonSapin
layout: Clear non-inherited properties on anonymous block

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

This is one of my pull requests that imlement basic flexible box layout.
This pull request adds a `modify_style_for_anonymous_flow()` function to use initial values for non-inherited properties and parent values for inherited properties as the flow style. It also set border and outline to zero and set the display property from the parameter. This function may also be reused to modify style of anonymous table object in the future.
Part of code comes from `cascade_anonymous()` from @SimonSapin .

---
<!-- 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
- [x] These changes do not require tests because flexbox is not implemented yet.

<!-- 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/12382)
<!-- Reviewable:end -->
2016-07-11 16:19:52 -07:00
Pu Xingyu
d40e6c5738 Clear non-inherited properties on anonymous block
Add a modify_style_for_anonymous_flow() function to use initial values
for non-inherited properties and parent values for inherited properties
as the block style. It also set border and outline to zero and set the
display property from the parameter.
2016-07-12 07:17:31 +08:00
Pu Xingyu
2aeed833e6 Treat flex flow as block in float calculation 2016-07-10 16:34:12 +08:00
Anthony Ramine
51ff916e09 Move util::print_tree to gfx_traits 2016-07-04 15:47:06 +02:00
Ms2ger
ea45e76840 Pass SharedStyleContext to assign_inline_sizes. 2016-06-22 14:50:04 +02:00
Ms2ger
f20ea08a1b Pass SharedStyleContext to explicit_block_containing_size. 2016-06-22 14:17:33 +02:00
Ms2ger
0d0b268138 Move LayoutNode and related traits to script_layout_interface. 2016-06-20 19:07:54 +02:00
Ms2ger
5c03dd8eb1 Introduce a script_layout_interface crate and move RestyleDamage to it. 2016-06-20 19:02:36 +02:00
Ms2ger
2383cb2eee Remove unused argument to place_float_if_applicable. 2016-06-20 12:37:56 +02: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
Patrick Walton
0198a9dda8 layout: Include float information in flows' debug output. 2016-05-04 13:20:22 -07:00
Patrick Walton
04f05349b1 layout: Check flow descendants of inline block fragments to find their
baselines when aligning inline fragments per CSS 2.1 § 10.8.1.
2016-05-04 13:20:21 -07:00
bors-servo
8db0367301 Auto merge of #10944 - mbrubeck:bitflags-0.6, r=frewsxcv
Upgrade a bunch of dependencies

<!-- 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/10944)
<!-- Reviewable:end -->
2016-04-30 15:21:22 -07:00
Matt Brubeck
1e23d90631 Upgrade to bitflags 0.6.0 and selectors 0.5.6
Types generated by `bitflags!` are now private by default.  This PR marks them
`pub` where necessary.
2016-04-30 10:14:03 -07:00
Samuel Harrington
b2cd35da47 Delete dead code from flow.rs 2016-04-29 20:12:22 -07:00
Emilio Cobos Álvarez
2a499d5a0b
layout: Stop storing PrecomputedStyleData in LayoutNode
Use the SharedStyleContext instead.
2016-04-29 22:54:48 +02:00
malayaleecoder
d4dcaf3167 Rename imm_child_iter() and child_iter(). Fixes #10286 2016-04-09 01:18:00 +05:30
Emilio Cobos Álvarez
92f39ea5cf Implement ::selection pseudo-element 2016-03-30 14:28:11 +02:00
Per Lundberg
4cb4cc93e4 Renamed TComputedValues to ComputedValues
This is a followup to #10210, and a continuation of #10185.
2016-03-29 23:30:13 +03:00
Per Lundberg
c2ad084713 ComputedValues is now ServoComputedValues
This is the first part of #10185. More to follow. I have built this locally with both servo and geckolib without errors; let's see if it succeeds on all platforms as well.
2016-03-27 10:55:43 +03:00
Patrick Walton
b29719e36b layout: Rewrite the block formatting context/float inline-size
speculation code.

The old code tried to do the speculation as a single bottom-up pass
after intrinsic inline-size calculation, which was unable to handle
cases like this:

    <div>
        <div style="float: left">Foo</div>
    </div>
    <div>
        <div style="overflow: hidden">Bar</div>
    </div>

No single bottom-up pass could possibly handle this case, because the
inline-size of the float flowing out of the "Foo" block could never make
it down to the "Bar" block, where it is needed for speculation.

On the pages I tried, this regresses layout performance by 1%-2%.

I first noticed this breaking some pages, like the Google SERPs, several
months ago.
2016-03-25 18:39:16 -07:00
Bobby Holley
c2daea2c9c Parameterize the rest of the style system on TNode. 2016-03-24 11:50:57 -07:00
Bobby Holley
539f839958 Remove lifetimes from LayoutNode and friends. 2016-03-14 14:31:57 -07:00
Patrick Walton
d3d2dd05f2 layout: Switch display list building from bottom-up to top-down.
This eliminates a lot of allocations and O(n^2) behavior.
2016-03-03 13:09:56 -08:00
Patrick Walton
f4b95dd00b layout: Remove the validate_display_list_geometry debugging tool.
I don't think anyone was using it, and it's incompatible with taking
display lists out of flows.
2016-03-03 13:09:55 -08:00
Patrick Walton
940bff1f9c gfx: Stop cloning clipping regions so much.
Clipping regions can contain vectors and so can be expensive to copy.
2016-03-03 13:09:50 -08:00
Patrick Walton
4233e0f163 gfx: Box stacking contexts to minimize memmove traffic.
`memmove` was showing up high in the profile when concatenating and
shorting display lists. This change drastically reduces the `memmove`
cost in exchange for some minor additional allocation cost.
2016-03-03 13:09:48 -08:00
Glenn Watson
ff831bb478 Fix unexpected overflow with overflow: hidden set.
Fixes #9719.
2016-03-03 05:02:37 +10:00
Martin Robinson
e7019f2721 Flatten display list structure
Instead of producing a tree of stacking contexts, display list
generation now produces a flat list of display items and a tree of
stacking contexts. This will eventually allow display list construction
to produce and modify WebRender vertex buffers directly, removing the
overhead of display list conversion.  This change also moves
layerization of the display list to the paint thread, since it isn't
currently useful for WebRender.

To accomplish this, display list generation now takes three passes of
the flow tree:

        1. Calculation of absolute positions.
        2. Collection of a tree of stacking contexts.
        3. Creation of a list of display items.

After collection of display items, they are sorted based upon the index
of their parent stacking contexts and their position in CSS 2.1
Appendeix E stacking order.

This is a big change, but it actually simplifies display list generation.
2016-03-01 14:50:07 -08:00
Anthony Ramine
db8d502f41 Move util::logical_geometry to style 2016-02-18 10:17:13 +01:00
Patrick Walton
7c5b2d6cb3 layout: Separate out overflow-for-scrolling from overflow-for-paint.
Closes #9484.
2016-02-03 16:06:24 -08:00
Simon Sapin
5498b54347 Add Multicolumn support block fragmentation. 2016-01-28 09:43:14 +01:00
Simon Sapin
9abbd1b5d1 Sequentialize assign_block_size for flows that can be fragmented.
Fragmentation will be intertwined with block size calculation.
2016-01-28 09:42:17 +01:00
Patrick Walton
9c7b9fa32d layout: Remove some bogus code that tried to handle
absolutely-positioned flows separately when storing overflow.

This code dates back to the time when absolutely positioned flows were
ignored by all of their ancestors up to the containing block. This
hasn't been true for at least a year.

Closes #9306.
Closes #9309.
Is a partial fix for #9308.
2016-01-25 10:52:07 -08:00
Thomas Gummerer
70a2179cd2 Move LayerType enum to gfx_trait
The LayerType enum is only used in gfx_traits and layout, so it
shouldn't be defined in msg.  Move the definition to gfx_traits
instead.

Fixes #9220
2016-01-10 16:20:37 +01:00
Bobby Holley
27987c3bb4 Introduce a concept of restyle damage to the style system.
We can't hoist RestyleDamage itself, because it's very layout-dependent. But this
should be enough to let us hoist the things we need.
2016-01-04 09:38:04 -08:00
Brandon Fairchild
637afecec9 Move LayerKind and ScrollPolicy enums to gfx_traits
This also moves LayerId and LayerProperties to gfx_traits.

Fixes #8836.
2015-12-20 20:43:31 -05:00
Alexander Mankuta
546d2f564f Replaced ZERO_RECT with Rect::zero() 2015-12-03 15:39:30 +02:00
Bobby Holley
cf33f00018 Generalize the rest of layout to operate on generic Layout*.
There wasn't a good way to split this up, unfortunately.

With this change, the only remaining usage of the Servo-specific structures is
in layout_task, where the root node is received from the script task. \o/
2015-11-28 18:01:02 -08:00
Martin Robinson
8dd664a438 Improve readability of flow tree dump
Use the PrintTree utility to improve the readability of flow tree
dumps. Blocks and fragments are now split over two dump levels, because
otherwise they are impenetrable. Also start printing the restyle damage of
fragments.
2015-11-23 15:17:32 -08:00
Bobby Holley
afa3834f3b Rename ThreadSafeLayoutFoo to ServoThreadSafeLayoutFoo and TThreadSafeLayoutFoo to ThreadSafeLayoutFoo. 2015-11-21 11:26:49 -08:00
Bobby Holley
a85ae24c51 Hoist exported ThreadSafeLayoutFoo functionality into traits. 2015-11-21 11:25:20 -08:00
Ms2ger
5ec1cdea9b Remove dead code from layout. 2015-11-18 15:00:58 +01:00
Ms2ger
11e760d582 Remove unused Flow::remove_compositor_layers.
The caller was removed in c72d0c2ed0.
2015-11-07 11:23:43 +01:00
bors-servo
da25b8c848 Auto merge of #8337 - mrobinson:remove-display-list-result, r=pcwalton
Remove DisplayListBuildingResult

Always produce a DisplayList when processing nodes for display list
construction. StackingContexts are now added to the positioned content
section of DisplayLists. This makes the code a bit simpler and opens up
the possibility of producing a StackingContext in another section of
the DisplayList. This doesn't change behavior, but is a cleanup
prerequisite for proper inline stacking context support.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8337)
<!-- Reviewable:end -->
2015-11-06 05:36:35 +05:30
Martin Robinson
6f4ce7a06e Eliminate LAYERS_NEEDED_FOR_DESCENDANTS flag
This flag is no longer necessary, because stacking contexts can now
create layers lazily for content that needs to be stacked above a
layer. This should reduce the number of layers on pages, hopefully
reducing overdraw.
2015-11-04 15:29:47 -08:00
Martin Robinson
e5b2feda3f Remove DisplayListBuildingResult
Always produce a DisplayList when processing nodes for display list
construction. StackingContexts are now added to the positioned content
section of DisplayLists. This makes the code a bit simpler and opens up
the possibility of producing a StackingContext in another section of
the DisplayList. This doesn't change behavior, but is a cleanup
prerequisite for proper inline stacking context support.
2015-11-04 12:52:14 -08:00
bors-servo
ca56ebbb09 Auto merge of #8306 - glennw:fix-abd-overflow, r=pcwalton
Change overflow calculation to be calculated after compute_absolute_position.

Also include absolutely positioned elements in the overflow rect calculation.

Fixes #7797.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8306)
<!-- Reviewable:end -->
2015-11-04 08:15:58 +05:30
bors-servo
86e3add8fd Auto merge of #8266 - mrobinson:stacking-context-mix, r=pcwalton
Mix stacking contexts into the positioned content list

Sometimes positioned content needs to be layered on top of stacking
contexts. The layer synthesis code can do this, but the current design
prevents it because stacking contexts are stored in a separate struct
member. In order to preserve tree order, mix stacking contexts into the
positioned content list, by adding a new StackingContextClass
DisplayItem. Such items do not have a base DisplayItem.

In some ways this simplifies the code, because we no longer have to
have a separate code path in the StackingContextLayerCreator.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8266)
<!-- Reviewable:end -->
2015-11-04 07:22:43 +05:30
Martin Robinson
c1a38e240a Mix stacking contexts into the positioned content list
Sometimes positioned content needs to be layered on top of stacking
contexts. The layer synthesis code can do this, but the current design
prevents it because stacking contexts are stored in a separate struct
member. In order to preserve tree order, mix stacking contexts into the
positioned content list, by adding a new StackingContextClass
DisplayItem. Such items do not have a base DisplayItem.

In some ways this simplifies the code, because we no longer have to
have a separate code path in the StackingContextLayerCreator.

Fixes #7779.
Fixes #7983.
Fixes #8122.
Fixes #8310.
2015-11-03 17:47:39 -08:00