Commit graph

55 commits

Author SHA1 Message Date
Zhen Zhang
fefdaf76de Implement ScrollTop and ScrollLeft getters:
Add new compositor message to get scroll_offset;
Add new layout query for computed value of overflow-x/y;
Implement layer_id method for ThreadSafeLayoutNode;
Add new layout query for layer_id;
Implement script interface for getting scrollTop and scrollLeft, as well as relavant helper functions.
2016-04-19 12:27:35 +08:00
Peter
b0ad3ddf5b Updated euclid to version 0.6.5
And updated existing usages of Matrix4 to use Matrix4D<T>
2016-04-17 18:39:49 +01:00
Alan Jeffrey
8c0fa01884 Added panic message to failures. 2016-04-13 16:09:48 -05:00
malayaleecoder
d4dcaf3167 Rename imm_child_iter() and child_iter(). Fixes #10286 2016-04-09 01:18:00 +05:30
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
bors-servo
aac2da75f4 Auto merge of #8641 - notriddle:no_headless, r=glennw
No more headless compositor. Just the normal one.

Fixes #8573

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8641)
<!-- Reviewable:end -->
2016-03-29 12:42:01 +05:30
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
Matt Brubeck
afb36ec8de Fix forced repaint on image load
After #10021, `LayoutThread::repaint` no longer forced a repaint because of
the `restyle_damage` check.  This patch adds the correct restyle damage and
fixes #10163.
2016-03-25 14:54:00 -07:00
bors-servo
605842f193 Auto merge of #10155 - bholley:generalize_style_structs, r=SimonSapin
Generalize the style structs

This allows geckolib to pass gecko style structs and have the style system write to them directly, provided we implement all the traits.

<!-- 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/10155)
<!-- Reviewable:end -->
2016-03-25 03:27:33 +05:30
Bobby Holley
c2daea2c9c Parameterize the rest of the style system on TNode. 2016-03-24 11:50:57 -07:00
Michael Howell
c9cb4839e4 No more headless compositor. Just the normal one.
This changes headless operation to strictly be a runtime option, rather
than a compile-time one. Note that the old headless version still relied
on a display server to support WebGL, while it now requires one all the
time.

Fixes #8573
2016-03-24 11:18:54 -07:00
Emilio Cobos Álvarez
a02daf7144 canvas: Remove all the canvas layerization infrastructure
It was never complete, and with webrender as a backend the way we render
WebGL contexts has changed a bit.

This should remove quite a bit of overhead.
2016-03-23 18:12:37 +01:00
Patrick Walton
0006c1923a gfx: Allow images to be shipped to the WebRender thread without shipping
over the data as well.

WebRender doesn't need the data, as it acquires it separately.

About a 50%-100% improvement in display list building time on
browser.html.
2016-03-22 14:49:47 -07:00
Patrick Walton
9fcf9215d0 layout: Flatten display list transfer into a separately-transferred byte
array, and consolidate the multitude of display list messages into one.

Improves display list building performance by 50%-100% for small display
lists.
2016-03-22 10:51:25 -07:00
bors-servo
41060dbdd7 Auto merge of #10105 - mbrubeck:dirty-viewport-percentages, r=SimonSapin
Don't re-add stylesheets to recompute vw/vh lengths

This is a follow-up to #9876.  It avoids clearing and rebuilding SelectorMaps
when vh and vw units need to be recomputed. Instead it just dirties all nodes,
to force elements to be re-cascaded.

Filed #10104 for later follow-up work to dirty only affected nodes.

r? @SimonSapin

<!-- 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/10105)
<!-- Reviewable:end -->
2016-03-22 18:58:47 +05:30
bors-servo
9a8ba23a76 Auto merge of #10088 - pkondzior:7038-report-memory-usage-in-layout-thread-data-stylist, r=ecoal95
Report memory usage from LayoutThreadData Stylist [#7038]

@jdm PTAL I'm not sure what is the approach of updating cargo components here, I've made a pull request https://github.com/servo/heapsize/pull/54 but it has to be landed first before merge and version bump.

<!-- 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/10088)
<!-- Reviewable:end -->
2016-03-22 06:54:11 +05:30
Matt Brubeck
37636e8377 Don't re-add stylesheets to recompute vw/vh lengths
This is a follow-up to #9876.  It avoids clearing and rebuilding SelectorMaps
when vh and vw units need to be recomputed. Instead it just dirties all nodes,
to force elements to be re-cascaded.

Filed #10104 for later follow-up work to dirty only affected nodes.
2016-03-21 10:05:17 -07:00
Patrick Walton
7cb9429a0f layout: Don't start the reflow pass unless some node needs to be
reflowed.

Reduces CPU usage when mousing over simple pages.

Part of #9999.
2016-03-21 08:39:45 -07:00
Patrick Walton
acfd8e448c layout: Don't rebuild display lists at all unless restyling tells us
some object needs to be repainted.

Reduces CPU usage when mousing over simple documents. (More complex
documents tend to trigger unnecessary reflow bugs and so still have high
CPU.)

Part of #9999.
2016-03-21 08:39:44 -07:00
Pawel Kondzior
db2e10a70f Report memory usage from LayoutThreadData Stylist [#7038] 2016-03-19 11:53:13 -07:00
Patrick Walton
5ea8c34276 layout: Move overflow calculation to be a separate, sequential,
bottom-up pass.

Right now, the only reason that overflow calculation works is that we
rely on script inducing extra reflows that are sent for display. This
was preventing #10021 from landing.

This change regresses layout performance by about 1% in my tests.

Fixes #7797 properly.
2016-03-18 22:11:51 -07:00
Bobby Holley
539f839958 Remove lifetimes from LayoutNode and friends. 2016-03-14 14:31:57 -07:00
bors-servo
d330ecdafc Auto merge of #9964 - mbrubeck:incremental-damage, r=pcwalton
Compute damage even when incremental layout is disabled

This fixes traversals that use the damage flags to decide which nodes to process, such as `resolve_generated_content`, which was broken in non-incremental mode. r? @pcwalton

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9964)
<!-- Reviewable:end -->
2016-03-12 05:00:17 +05:30
Daniel Robertson
16d2778ece Add scrollWidth/Height to element interface
Add the scrollWidth and scrollHeight extensions to the element
interface.
2016-03-11 18:22:16 +00:00
Matt Brubeck
ae5cfc31e3 Compute damage even when incremental layout is disabled
This fixes traversals that use the damage flags to decide which nodes to
process, such as `resolve_generated_content`, which was broken in
non-incremental mode.
2016-03-11 09:52:22 -08:00
bors-servo
1c63bf9822 Auto merge of #9861 - pcwalton:superflat, r=glennw
Flatten the WebRender API to allow us to use shared memory to transfer display lists.

Improves performance significantly.

Requires servo/webrender_traits#15 and servo/webrender#222.

r? @glennw

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9861)
<!-- Reviewable:end -->
2016-03-04 06:45:45 +05:30
bors-servo
aba500a698 Auto merge of #9858 - glennw:anim-smoothness, r=pcwalton
Fix animation smoothness when using requestAnimationFrame.

Previously, the flow for ticking animations was:

Compositor -> Constellation -> Layout -> Script

However, this means that the compositor <-> layout messages can thrash, meaning layout thread is very rarely idle.

This means that the script thread (which joins on the layout thread during reflow) was unable to execute and run rAF callbacks.

With this change, the flow is now:

Compositor -> Constellation -> Script (when rAF is active).
Compositor -> Constellation -> Layout (when transitions / animations are active and no rAF is present).

This makes rAF based animation *much* smoother.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9858)
<!-- Reviewable:end -->
2016-03-04 05:50:50 +05:30
Patrick Walton
5e17325e54 Flatten the WebRender API to allow us to use shared memory to transfer
display lists.

Improves performance significantly.

Requires servo/webrender_traits#15 and servo/webrender#222.
2016-03-03 14:44:48 -08:00
bors-servo
37bcc161fe Auto merge of #9832 - metajack:suppress-reflows, r=mbrubeck
Suppress reflows before RefreshTick or FirstLoad

This fixes a bug where partially loaded content is displayed to the user
before it should be, usually before stylesheets have loaded. This commit
supresses reflows until either FirstLoad or RefreshTick, whichever comes
first.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9832)
<!-- Reviewable:end -->
2016-03-04 04:00:30 +05:30
Jack Moffitt
2507bfb2cf Suppress reflows before RefreshTick or FirstLoad
This fixes a bug where partially loaded content is displayed to the user
before it should be, usually before stylesheets have loaded. This commit
supresses reflows until either FirstLoad or RefreshTick, whichever comes
first.

Unfortunately, hit_test and mouse_over did not do reflows if they were
necessary, and so by suppressing the initial spurious reflows, these
methods started to panic without a display list to query. This patch
also transforms these into queries similar to the other existing
queries.
2016-03-03 15:17:46 -07:00
Glenn Watson
92061132f3 Fix animation smoothness when using requestAnimationFrame.
Previously, the flow for ticking animations was:

Compositor -> Constellation -> Layout -> Script

However, this means that the compositor <-> layout messages can thrash, meaning layout thread is very rarely idle.

This means that the script thread (which joins on the layout thread during reflow) was unable to execute and run rAF callbacks.

With this change, the flow is now:

Compositor -> Constellation -> Script (when rAF is active).
Compositor -> Constellation -> Layout (when transitions / animations are active and no rAF is present).

This makes rAF based animation *much* smoother.
2016-03-04 07:26:00 +10: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
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
bors-servo
9d47b344d9 Auto merge of #9663 - pcwalton:browser-html-jank-fix, r=glennw
compositing: Stop compositing unnecessarily after each animation frame.

Instead, schedule a delayed composite after each frame of an animation.

The previous code would cause jank, because the following sequence
frequently occurred:

1. The page uses `requestAnimationFrame()` to request a frame.

2. The compositor receives the message, schedules a composite,
dispatches the rAF message to the script thread, composites, and goes to
sleep waiting for vblank (frame 1).

3. The script makes a change and sends it through the pipeline.
Eventually it gets painted and is sent to the compositor, but the
compositor is sleeping.

4. The compositor wakes up, sees the new painted content, page flips,
and goes to sleep (frame 2). Repeat from step 1.

The problem is that we have two composition frames, not just one. This
halves Web apps' framerate!

This commit fixes the problem by scheduling the composite in step 2 to
12 ms in the future. We already have this delayed-composition
functionality in the form of the scrolling timer, which I repurposed and
renamed to the "delayed composition timer" for this task. This change
gives the page 12 ms to prepare the frame, which seems to usually be
enough, especially with WebRender.

Note that simply removing the scheduled composite after rAF is not the
correct solution. If this is done, then pages that call rAF and don't
modify the page won't receive future rAFs, since the compositor will be
sleeping and won't be notified of vblank.

Fixes a bunch of jank in browser.html. The remaining jank seems to be a
problem with browser.html itself.

r? @glennw

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9663)
<!-- Reviewable:end -->
2016-02-25 03:56:02 +05:30
Patrick Walton
9b4cc41695 compositing: Stop compositing unnecessarily after each animation frame.
Instead, schedule a delayed composite after each frame of an animation.

The previous code would cause jank, because the following sequence
frequently occurred:

1. The page uses `requestAnimationFrame()` to request a frame.

2. The compositor receives the message, schedules a composite,
dispatches the rAF message to the script thread, composites, and goes to
sleep waiting for vblank (frame 1).

3. The script makes a change and sends it through the pipeline.
Eventually it gets painted and is sent to the compositor, but the
compositor is sleeping.

4. The compositor wakes up, sees the new painted content, page flips,
and goes to sleep (frame 2). Repeat from step 1.

The problem is that we have two composition frames, not just one. This
halves Web apps' framerate!

This commit fixes the problem by scheduling the composite in step 2 to
12 ms in the future. We already have this delayed-composition
functionality in the form of the scrolling timer, which I repurposed and
renamed to the "delayed composition timer" for this task. This change
gives the page 12 ms to prepare the frame, which seems to usually be
enough, especially with WebRender.

Note that simply removing the scheduled composite after rAF is not the
correct solution. If this is done, then pages that call rAF and don't
modify the page won't receive future rAFs, since the compositor will be
sleeping and won't be notified of vblank.

Fixes a bunch of jank in browser.html. The remaining jank seems to be a
problem with browser.html itself.
2016-02-24 14:06:46 -08:00
bors-servo
7f8c34ce8e Auto merge of #9706 - mrobinson:remove-parallel-display-list-building, r=pcwalton
Remove parallel display list construction

Parallel display list construction hasn't been shown to give any
performance gains. It is also incompatible with the current flat display
list implementation. Once flat display lists have landed, we can explore
possible benefits of parallel construction once again.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9706)
<!-- Reviewable:end -->
2016-02-25 02:52:45 +05:30
benshu
0785d91ae4 Completed implementation of devtools' getLayout. 2016-02-24 13:51:47 -05:00
Martin Robinson
630a9d4255 Remove parallel display list construction
Parallel display list construction hasn't been shown to give any
performance gains. It is also incompatible with the current flat display
list implementation. Once flat display lists have landed, we can explore
possible benefits of parallel construction once again.
2016-02-19 15:53:12 -08:00
bors-servo
ab07b06823 Auto merge of #9589 - glennw:webrender, r=pcwalton
Add WebRender integration to Servo.

WebRender is an experimental GPU accelerated rendering backend for Servo.

The WebRender backend can be specified by running Servo with the -w option (otherwise the default rendering backend will be used).

WebRender has many bugs, and missing features - but it is usable to browse most websites - please report any WebRender specific rendering bugs you encounter!

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9589)
<!-- Reviewable:end -->
2016-02-19 00:54:06 +05:30
Anthony Ramine
db8d502f41 Move util::logical_geometry to style 2016-02-18 10:17:13 +01:00
Glenn Watson
c0531c312f Add WebRender integration to Servo.
WebRender is an experimental GPU accelerated rendering backend for Servo.

The WebRender backend can be specified by running Servo with the -w option (otherwise the default rendering backend will be used).

WebRender has many bugs, and missing features - but it is usable to browse most websites - please report any WebRender specific rendering bugs you encounter!
2016-02-18 10:35:29 +10:00
Emilio Cobos Álvarez
dd503dfacb Refactor style to be completely backend-independent
This commit refactors the style crate to be completely independent of
the actual implementation and pseudo-elements supported.

This also adds a gecko backend which introduces parsing for the
anonymous box pseudo-elements[1], although there's still no way of
querying them.

https://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSAnonBoxList.h
2016-02-13 16:05:14 +01:00
Josh Matthews
e6d906dbbf Report CSS errors to script task for further processing. 2016-02-11 14:48:47 -05:00
bors-servo
fb3fe3d784 Auto merge of #9522 - pcwalton:two-overflows, r=mbrubeck
layout: Separate out overflow-for-scrolling from overflow-for-paint.

Closes #9484.

r? @mbrubeck

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9522)
<!-- Reviewable:end -->
2016-02-05 10:58:50 +05:30
bors-servo
87aaa5ffe0 Auto merge of #9523 - ruud-v-a:hasher, r=Wafflespeanut
Upgrade to new Hasher API

This fixes #9494.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9523)
<!-- Reviewable:end -->
2016-02-05 07:32:13 +05:30
Anthony Ramine
cb5cd8d881 Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +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
Ruud van Asseldonk
95be0b9a25 Upgrade to new Hasher API 2016-02-03 20:06:39 +01:00
Simon Sapin
357463864b Avoid a transmute that relied on undefined struct layout. 2016-01-27 16:37:08 +01:00
Bobby Holley
384cdfcfff Hoist ParseErrorReporter into style and remove the dependency on msg.
The pipeline id stuff is currently unused. If someone needs it, they can add
an additional trait bound on their css error reporter to get the pipeline id.
2016-01-11 18:01:48 -08:00