Commit graph

85 commits

Author SHA1 Message Date
bors-servo
7e363d60bb Auto merge of #18175 - stshine:no-floats-in-flexbox, r=mbrubeck
layout: Stop call normal block size assignment for flex container

No need to call the `assign_block_size_block_base()` method of normal block in flex.rs since it is implemented for CSS2.

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

<!-- 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/18175)
<!-- Reviewable:end -->
2017-08-29 19:15:59 -05:00
Pu Xingyu
9103743d0c layout: Stop calling normal block size assignment for flex container
No need to call the `assign_block_size_block_base()` method of normal
block since it is implemented for CSS2.
2017-08-29 01:30:09 +08:00
bors-servo
163f29ff63 Auto merge of #18243 - DominoTree:18224, r=stshine
[18224] Check if line_count is zero to calculate space around line

<!-- Please describe your changes on the following line: -->
Check line_count before attempting to calculate space around 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 #18224 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because changes are minimal and the error was triggered by a 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/18243)
<!-- Reviewable:end -->
2017-08-26 17:07:28 -05:00
Nick Price
684816bfb3 Check if line_count is zero to calculate space around line 2017-08-26 12:48:07 -04:00
Keith Yeung
1df72ba935 Remove border collapse argument from compute_border_and_padding 2017-08-25 23:41:55 -07:00
Martin Robinson
57704b0481 Improve containing block creation for position:absolute flows
Instead of only promoting flows with positioned fragments to containing
blocks, also do this for flows which have the transform, perspective or
filter properties set. This is what the spec requires and also fixes
some failing tests. It will allow us to stop creating stacking contexts
for overflow:hidden and overflow:scroll flows.

Fixes #18091.
2017-08-17 20:46:27 +02:00
Simon Sapin
b5a4b8d6a0 Upgrade to rustc 1.21.0-nightly (13d94d5fa 2017-08-10) 2017-08-15 14:10:44 +02:00
Matt Brubeck
a08bc13df9 Rename compute_absolute_position to compute_stacking_relative_position 2017-08-08 10:53:17 -07:00
Boris Chiou
4cc97746f2 Bug 1374233 - Part 1: Add NonNegativeNumber and GreaterThanOrEqualToOneNumber.
NonNegativeNumber: for -moz-box-flex, flex-grow, and flex-shrink.
GreaterThanOrEqualToOneNumber: for stroke-miterlimit.

MozReview-Commit-ID: Kgbt99BPdVA
2017-08-04 14:21:21 +08:00
Michael Partheil
b07ebbae6b Replace all uses of the style::stylearc alias with servo_arc.
The alias is left there temporarilly and will be removed completely in a later commit where
also components/style/gecko/generated/structs_{debug|release}.rs are re-generated (they still
use the old alias).
2017-07-19 09:29:05 +02:00
Manish Goregaokar
808b1f509b stylo: Use ComputedValuesInner instead of ComputedValues when we don't need it 2017-07-17 18:02:25 -07:00
Anthony Ramine
bc9bc1d340 Rename LengthOrPercentageOrAutoOrContent to FlexBasis 2017-06-17 13:46:35 +02:00
Anthony Ramine
608e7f71a2 Make computed types hold Percentage instead of bare CSSFloat 2017-06-15 16:59:03 +02:00
Anthony Ramine
d0b9bd9c64 Refactor how calc() clamping is done on computed values (fixes #15296) 2017-05-18 10:14:59 +02:00
Bobby Holley
7b0679848b Fix up script and layout. 2017-05-02 17:35:45 -07:00
石博文
22f99c71b9
Add to_computed method for CalcLengthOrPercentage
* Add to_computed method to calculate `calc()` value with parent size,
if parent container size is `None`, the result will be `None`.
* Add from_option method for `MaybeAuto`, to construct from
`Option<Au>`.
* Update some test case.
2017-04-24 14:22:14 +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
Matt Brubeck
39826f817e Initialize block_container_inline_size for non-block root flows
Fixes #14948.
2017-01-27 12:34:00 -08:00
Martin Robinson
29876d2703 Rework the way scroll roots are collected
Collect scroll roots during the collect_stacking_context phase instead
of during display list construction. This will be useful in order to
collect containing block scroll roots as well as to give scroll roots
sequential ids in the future. This change also pulls stacking context
children out of the StackingContext struct itself, which should reduce
very slightly the memory used by the finished display list. This also
simplifies the DisplayListBuilder because it no longer has to maintain
a stack of ScrollRootIds and StackingContextIds and can instead just
rely on the program stack.
2017-01-10 13:33:08 +01:00
bors-servo
58fec2f05a Auto merge of #14124 - shinglyu:flexbox-trace, r=glennw
Flexbox trace

<!-- Please describe your changes on the following line: -->
This is a follow up for #13740, so r? @jdm

The first patch enables JSON serialization for flexbox flows, the second one fixed format incompatibilities for the layout viewer.

The 3rd and 4th patches are just layout viewer UI enhancements, we could split that to a spearate PR if you prefer.

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

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because it's a trivial debug tool

<!-- 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/14124)
<!-- Reviewable:end -->
2016-12-28 00:33:31 -08:00
Shing Lyu
4b2d80afcf Activate flexbox layout tracing 2016-12-28 15:31:45 +08:00
Bobby Holley
648ce1e44e Make the DomTraversalContext own the SharedStyleContext and share it immutably across the traversal.
This allows us to get rid of a bunch of lifetimes and simplify a lot of code. It
also lets us get rid of that nasty lifetime transmute, which is awesome.

The situation with thread-local contexts is still suboptimal, but we fix that in
subsequent patches.
2016-12-16 10:57:27 -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
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
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
Bobby Holley
a2c7a9d0fb Stop using associated types for the concrete TRestyleDamage implementation.
MozReview-Commit-ID: LfaZFCVlIb1
2016-11-07 11:10:48 -08:00
Martin Robinson
71d285af80 Use a new id type for tracking scrolling areas
This is a step in disassociating scrolling areas from stacking
contexts. Now scroll areas are defined by unique ids, which means that
in the future stacking context will be able to contain more than one.
2016-10-30 21:10:04 +01:00
Patrick Walton
3d645a9253 layout: Don't use BlockFlow::assign_block_size() when assigning flex
flows' block sizes.

This ensures that we never collapse margins for flex flows.
2016-10-26 14:14:04 -07:00
Patrick Walton
92b7189f31 layout: Add a safe way for layout to perform random access on child
flows.

This uses caching to ensure that we perform no more than O(n) pointer
loads.
2016-10-26 14:04:15 -07:00
Patrick Walton
d990a7eb84 layout: Don't leak FlowRefs to the flexbox layout code.
This can cause memory safety problems. Comments have been added to
`flow_list.rs` to prevent this from happening again.
2016-10-26 14:04:14 -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
be252371ea layout: Refactor Flow::from_fragment-style constructors to be
consistent.
2016-10-26 14:04:08 -07:00
Martin Robinson
066775915c Simplify stacking context collection
Simplify the way that stacking contexts are collected. Instead of
passing the StackingContextId down the tree, pass the parent
StackingContext itself. This will allow future patches to get more
information about the parent stacking context (such as location).

Also remove the return value of collect_stacking_contexts, which was
unused.
2016-09-27 10:48:44 +02:00
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00
Ms2ger
871c207c44 Pass SharedLayoutContext to Flow::compute_absolute_position. 2016-08-24 10:12:38 +02:00
Pu Xingyu
2c2c60e44d layout: Freeze flex item properly
Fix the currently logic that a item will freeze if it should
grow(shrink) and its basesize is less(more) than its min(max) size. Also
fix the divide by zero error when an item should shrink but it has zero
length and zero min size.
2016-08-08 10:34:02 +08:00
Pu Xingyu
60e2f44a19 Add Minor fixes and tests 2016-08-03 21:10:35 +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
Pu Xingyu
7df5974456 Rename enum 'Mode' to 'Direction'
Rename the 'Mode' enum to 'Direction' and move it to 'model.rs', thus it
can be used to indicate logical direction.
2016-07-24 14:58:02 +08:00
Pu Xingyu
a70d2bbed8 Flex elements in a row flex container
Iterate over the items, create lines from them, resolve flex lengths
against them, set their inline size and margin lengths, and align them
according to 'justify-content', 'align-content' and 'align-self'.
2016-07-23 01:07:22 +08:00
Pu Xingyu
05cf52cb0b Filter abs-pos children and sort by 'order' field
As the flexbox spec change in May 2016, the absolutely positioned
children painting order no longer follow the `order` property, thus we
can simply filter them out.

Also sort items by the order field of 'FlexItem', no longer do two
vtable lookups in each compare.
2016-07-22 16:06:59 +08:00
Pu Xingyu
196d19a311 Add 'get_flex_line()' method to flex flow
The method returns 'Option<FlexLine>', can be used to obtain a line in
flex container.
2016-07-22 16:06:59 +08:00
Pu Xingyu
87a041d416 Add FlexLine and its method for flex resolving
Add the 'FlexLine' struct to represent a line in flex container, and the
'flex_resolve()' method for flex lengths resolving.
2016-07-22 16:06:59 +08:00
Pu Xingyu
bf5805f2a6 Add flags 'is_wrappable' and 'cross_reverse'
These 'is_wrappable' flag can be used to determine if a flex flow can be
multi-line. The 'is_reverse' flag is replaced by 'main_reverse' and
'cross_reverse' since flex flow can go reverse individually in main and
cross direction.
2016-07-22 16:06:59 +08:00
Pu Xingyu
5da880e2c2 Extend fields of FlexItem and add methods
Extend fields of `FlexItem` struct with values that are necessary to
resolve flexible lengths, and the 'order' property. Add other methods
for size computing to make the code more modular.
2016-07-22 16:06:14 +08:00
Simon Sapin
6d0e48f6cc Remove some type aliases that are now just re-exports. 2016-07-20 08:42:47 +02:00
Simon Sapin
789807b7b0 Remove the ComputedValue traits and style_struct_traits 2016-07-20 08:42:40 +02:00
Ms2ger
ea45e76840 Pass SharedStyleContext to assign_inline_sizes. 2016-06-22 14:50:04 +02:00
Ms2ger
9731a001db Pass SharedStyleContext to compute_used_inline_size. 2016-06-22 14:26:52 +02:00
Ms2ger
5c03dd8eb1 Introduce a script_layout_interface crate and move RestyleDamage to it. 2016-06-20 19:02:36 +02:00