Commit graph

163 commits

Author SHA1 Message Date
Brandon Fairchild
dce7c7bb69 Remove multiple unused imports in gfx
Fixes #9342.
2016-01-16 14:16:03 -05:00
rohan.prinja
1f02c4ebbb task -> thread 2016-01-10 17:58:13 +09:00
Martin Robinson
d720452698 Use DisplayListSection everywhere
DisplayListSection, StackingLevel, and BackgroundAndBorderLevel all
represent pretty much the same thing, a particular section of the
display list. Instead of maintaining three enums which do the same
thing, just use DisplayListSection everywhere. It's a superset of the
other two and this change will make it easier to flatten the DisplayList
in the future for WebRender.
2016-01-08 10:19:03 -08:00
Patrick Walton
3103b03262 gfx: Eagerly transform clips into ClippingRegion::max() if possible.
This helps WebRender look for useless clips and optimize them out.
2016-01-06 19:48:14 -08:00
Johannes Linke
6b215f38ee Fix a bunch of clippy lints 2016-01-02 23:27:15 +01:00
Bobby Holley
47059d2d26 Separate style+layout and layout-specific wrapper functionality.
This patch does a number of things, unfortunately all at once:
* Hoists a large subset of the layout wrapper functionality into the style system.
* Merges TElementAttributes into the newly-created TElement.
* Reorganizes LayoutData by style vs layout, and removes LayoutDataShared.
* Simplifies the API for borrowing style/layout data.

There's still more to do to make the style system usable standalone, but
this is a good start.
2015-12-29 11:50:03 -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
Ms2ger
208c05f944 Fix warnings. 2015-12-04 10:31:19 +01:00
bors-servo
68922e0ac2 Auto merge of #8797 - cheba:rect-contains, r=Manishearth
Replaced rect_contains_point with Rect.contains()

This is a proposed in servo/servo#8791 clean up.

Fixes #8791.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8797)
<!-- Reviewable:end -->
2015-12-04 04:01:44 +05:30
Alexander Mankuta
96a8b442b8 Replaced rect_contains_point with Rect.contains() 2015-12-03 16:15:34 +02:00
Alexander Mankuta
546d2f564f Replaced ZERO_RECT with Rect::zero() 2015-12-03 15:39:30 +02:00
bors-servo
8d8ffa8265 Auto merge of #7696 - mskrzypkows:PaintContext_Units, r=mbrubeck
Draft. Change PaintContext rects to TypedRects #7023

I created draft. I'm not sure if we need any units conversion in PaintContext. There is also strange 'clear' method, we use PagePx origin and ScreenPx size is it OK?

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7696)
<!-- Reviewable:end -->
2015-11-07 00:22:59 +05:30
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
Maciej Skrzypkowski
2a7927d074 Change PaintContext rects to TypedRects #7023
Needs update to_nearest_pixel method in app_unit module.
Argument of to_nearest_pixel should be:
ScaleFactor<PagePx, ScreenPx, f32>
2015-11-04 08:39:15 +01:00
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
Martin Robinson
ac5525aeeb Integrate iframes into the display list
Instead of always promoting iframes to StackingContexts, integrate them
into the display list. This prevents stacking bugs when
non-stacking-context elements should be drawn on top of iframes.

To accomplish this, we add another step to ordering layer creation,
where LayeredItems in the DisplayList are added to layers described by
the LayerInfo structures collected at the end of the DisplayList.
Unlayered items that follow these layered items are added to
synthesized layers.

Another result of this change is that iframe layers can be positioned
directly at the location of the iframe fragment, eliminating the need
for the SubpageLayerInfo struct entirely.

Iframes are the first type of content treated this way, but this change
opens up the possibility to properly order canvas and all other layered
content that does not create a stacking context.

Fixes #7566.
Fixes #7796.
2015-10-20 07:29:06 -07:00
bors-servo
6d52bdf4ff Auto merge of #7891 - mrobinson:display-list-paint-layer, r=pcwalton
Properly size synthesized layers

Layers that are composed of several stacking contexts that need to be
rendered on top of other layered content need synthesized layers.
Previously, these layers were placed into a stacking context that was
the same size as their parent. This patch creates a new type of
PaintLayer which simply holds a display list. The layer is sized to the
bounds of the DisplayList and its children are positioned relative to
the parent stacking context.

This will also be useful in the future, when items outside of
StackingContexts are given their own layer for render order purposes.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7891)
<!-- Reviewable:end -->
2015-10-09 17:00:21 -06:00
Paul Rouget
99cccb2193 Snap to screen pixels instead of px 2015-10-08 06:44:05 +02:00
Martin Robinson
fb80e51bd1 Properly size synthesized layers
Layers that are composed of several stacking contexts that need to be
rendered on top of other layered content need synthesized layers.
Previously, these layers were placed into a stacking context that was
the same size as their parent. This patch creates a new type of
PaintLayer which simply holds a display list. The layer is sized to the
bounds of the DisplayList and its children are positioned relative to
the parent stacking context.

This will also be useful in the future, when items outside of
StackingContexts are given their own layer for render order purposes.
2015-10-07 15:12:36 -07:00
Patrick Walton
e3b988a1fe layout: Add a field in the display list for simple border radii on box
shadows.

Only supported in WebRender (with my upcoming PR) for now.
2015-10-06 14:04:50 -07:00
Martin Robinson
553f1fc192 Rework how StackingContexts are dynamically added to layers
StackingContexts are added to layers when it is necessary to maintain
their ordering on top of other layered StackingContexts. Instead of
tracking the information about a layer scattered around into different
structs, combine it all into LayerInfo. LayerInfo will be used in the
future to hold layer information for DisplayItems that are layerized
independently of StackingContexts.
2015-10-05 13:35:31 -07:00
Glenn Watson
339a3f869b Split Au type into separate crate, with minimal dependencies. 2015-10-01 07:16:11 +10:00
bors-servo
b1d9f438b7 Auto merge of #7751 - mrobinson:refactor-hit-testing, r=pcwalton
Make DisplayList hit testing a method on DisplayList

This will allow us to hit test into DisplayLists that are not directly
contained in StackingContexts, but instead are children of PaintLayers.
It also makes things slightly simpler.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7751)
<!-- Reviewable:end -->
2015-09-30 03:04:16 -06:00
Patrick Walton
c72d0c2ed0 layout: Make the compositor rather than layout determine the position of
each iframe.

The old code that attempted to do this during layout wasn't able to work
for multiple reasons: it couldn't know where the iframe was going to be
on the page (because of nested iframes), and at the time it was building
the display list for a fragment it couldn't know where that fragment was
going to be in page coordinates.

This patch rewrites that code so that both the sizes and positions of
iframes are determined by the compositor. Layout layerizes all iframes
and marks the iframe layers with the appropriate pipeline and subpage
IDs so that the compositor can place them correctly. This approach is
similar in spirit to Gecko's `RefLayer` infrastructure. The logic that
determines when it is time to take the screenshot for reftests has been
significantly revamped to deal with this change in delegation of
responsibility.

Additionally, this code removes the infrastructure that sends layout
data back to the layout task to be destroyed, since it is now all
thread-safe and can be destroyed on the script task.

The failing tests now fail because of a pre-existing bug related to
intrinsic heights and borders on inline replaced elements. They happened
to pass before because we never rendered the iframes at all, which meant
they never had a chance to draw the red border the tests expect to not
render!

Closes #7377.
2015-09-29 09:47:28 -07:00
Martin Robinson
a2cf8e583d Make DisplayList hit testing a method on DisplayList
This will allow us to hit test into DisplayLists that are not directly
contained in StackingContexts, but instead are children of PaintLayers.
It also makes things slightly simpler.
2015-09-28 18:34:07 -07:00
bors-servo
09b970af4a Auto merge of #7710 - mrobinson:small-dl-refactor, r=pcwalton
A few small bits of refactoring to prepare for more advanced DisplayList layerization

This will be useful when PaintLayers that contain DisplayLists instead
of StackingContexts need to draw themselves. This is a simple
preparatory refactoring and doesn't change any behavior.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7710)
<!-- Reviewable:end -->
2015-09-23 17:22:31 -06:00
Ravi Shankar
889eec364b sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
Martin Robinson
31a5eea823 Remove an unused function 2015-09-22 11:29:53 -07:00
Martin Robinson
71b83d6e99 Pass PaintTile to painting threads
This will be useful because in the future, PaintTiles might hold simple
DisplayLists instead of StackingContexts.
2015-09-22 11:29:15 -07:00
Martin Robinson
117c278936 Move DisplayList drawing logic to struct implementation
This will be useful when PaintLayers that contain DisplayLists instead
of StackingContexts need to draw themselves. This is a simple
preparatory refactoring and doesn't change any behavior.
2015-09-22 09:33:07 -07:00
Brandon Fairchild
de3547e401 Fix reported test-tidy errors for unmerged import blocks
This merges import blocks that were reported by tidy as unmerged.
2015-09-19 12:50:14 -04:00
Martin Robinson
1e6f797268 Ensure unique LayerIds for pseudo-elements
Currently pseudo-elements, like the fragments created for ::before and
::after, with layers will have the same LayerId as the body of their
owning fragments. Instead all LayerIds should be unique.

Fixes #2010.
2015-09-17 06:42:29 -07:00
Martin Robinson
30963d76be Improve printing of DisplayLists
Use box tree characters to make DisplayLists easier to scan when
printing them out.
2015-09-16 12:31:38 -07:00
Martin Robinson
184238c348 Layerize StackingContexts that are on top of layers
StackingContexts that should be painted on top of StackingContexts that
are already layerized should automatically get their own layer. This
will ensure proper painting order.
2015-09-09 09:13:14 -07:00
bors-servo
5bad6b1b6e Auto merge of #7502 - bjwbell:elliptical-borders, r=pcwalton
gfx: Add elliptical border radius support

TODO: Add code for parsing shorthand border-radius e.g. "border-radius: 10px 5% / 20px".

r? @pcwalton

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7502)
<!-- Reviewable:end -->
2015-09-04 18:46:24 -06:00
bors-servo
8e0b010117 Auto merge of #7487 - mrobinson:paint-layer-upgrade, r=pcwalton
Have PaintLayers own StackingContexts instead of the opposite

Previously, StackingContexts might have a PaintLayer. We switch the
ownership, for several reasons:

   * We want PaintLayers to potentially contain something other
     than a StackingContext soon.
   * We want to delay the creation of PaintLayers until the last
     minute, so that we can synthesize new layers for sandwiched
     content.

This commit also implements the second goal. Instead of creating
PaintLayers during layout itself, wait until we are sorting and
layerizing a completed DisplayList.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7487)
<!-- Reviewable:end -->
2015-09-04 17:31:54 -06:00
Martin Robinson
4ca93c39d6 Have PaintLayers own StackingContexts instead of the opposite
Previously, StackingContexts might have a PaintLayer. We switch the
ownership, for several reasons:

   * We want PaintLayers to potentially contain something other
     than a StackingContext soon.
   * We want to delay the creation of PaintLayers until the last
     minute, so that we can synthesize new layers for sandwiched
     content.

This commit also implements the second goal. Instead of creating
PaintLayers during layout itself, wait until we are sorting and
layerizing a completed DisplayList.
2015-09-04 15:07:09 -07:00
Bryan Bell
3e5fb49b6f gfx: Add elliptical border radius support 2015-09-04 14:42:44 -07:00
Manish Goregaokar
54c036cd66 Elide most 'a lifetimes 2015-09-04 08:55:51 +05:30
Martin Robinson
1c09b1d8aa Split out layered child stacking contexts in display lists
This patch is in preparation for more dynamic layerization of the
pieces of display lists. It also prevents having to sort the children
by z-index multiple times.
2015-08-26 10:20:28 -07:00
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
João Oliveira
067a22a868 Replace uses of for foo in bar.iter(),
and `for foo in bar.iter_mut(), and for foo in bar.into_iter()
(continuation of #7197)
2015-08-18 01:46:11 +01:00
João Oliveira
1e20447746 replace len() !=0 with !is_empty() 2015-08-17 02:56:07 +01:00
Josh Matthews
8bb853f643 Fix existing syntactics nits. 2015-08-16 10:30:43 -04:00
João Oliveira
0038580abf Replace uses of for foo in bar.iter() and for foo in bar.iter_mut()
closes #7197
2015-08-15 02:27:39 +01:00
bors-servo
85022a4c34 Auto merge of #7208 - jxs:master, r=Ms2ger
replace .len() == 0 with is_empty()

closes #7198

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7208)
<!-- Reviewable:end -->
2015-08-14 00:51:59 -06:00
João Oliveira
9c11781880 replace .len() == 0 with is_empty()
closes #7198
2015-08-14 04:00:33 +01:00
Glenn Watson
8218ead707 Fix "'PaintWorker' panicked at 'index 0 and/or 4 in * do not lie on character boundary" when printing display list.
This whole piece of code seems a bit fragile, but it fixes the immediate problem for now.
2015-08-14 11:48:36 +10:00
Glenn Watson
be8864ae5c Enable item clipping on normal transform layers. Fixes rounded corners on layers with 2d transforms.
Needed for #6643.
2015-08-13 16:03:25 +10:00
Patrick Walton
67d86ac507 gfx: Print the color of solid color display items when dumping the
display list.
2015-08-11 11:21:53 -07:00