Commit graph

510 commits

Author SHA1 Message Date
Eli Friedman
31c013858f Make the needs_reflow method actually work correctly.
The document node is always dirty because layout never clears the bit;
instead, check the dirty bit of the root element.
2015-11-21 15:49:58 -08:00
Corey Farwell
f34da4120d Implement 'url!(..)' macro
https://github.com/servo/rust-url/issues/136

https://github.com/servo/rust-url/pull/137
2015-11-21 08:15:56 -05:00
bors-servo
acbe413052 Auto merge of #8530 - KiChjang:split-constellation-msg, r=jdm
Split ConstellationMsg into ScriptMsg and CompositorMsg

Fixes #8356.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8530)
<!-- Reviewable:end -->
2015-11-19 04:39:20 +05:30
Ms2ger
0c61be7a57 Rustfmt some of script. 2015-11-18 11:14:05 +01:00
Keith Yeung
19294db6e5 Split ConstellationMsg into ScriptMsg and CompositorMsg 2015-11-16 23:10:53 -08:00
Ms2ger
4e60412c6d Remove the unused arguments to hit_test and mouse_over.
I don't think this code is called when there is no document element, but I
added assertions to make sure we notice in case I was wrong.
2015-11-16 15:53:49 +01:00
Greg Guthe
e49d592fba Add DOM-related performance timing properties 2015-11-13 17:51:34 -05:00
Alan Jeffrey
84bde75b42 Replaced DOMString constructor by conversion functions.
Replaced DOMString(...) by DOMString::from(...).
Replaced ....0 by String::from(...).
Removed any uses of .to_owner() in DOMString::from("...").
2015-11-12 17:52:59 -06:00
Josh Matthews
2340583e56 Differentiate between error and non-error event handlers per the spec. 2015-11-12 16:21:24 -05:00
Bobby Holley
7fa7936657 Implement attribute restyle hints.
Fixes #6942.
2015-11-10 11:57:24 -08:00
bors-servo
f39faaf994 Auto merge of #8227 - asajeffrey:versioned_dom, r=eefriedman
Versioned dom

This PR adds versioning to the DOM. There are now node.get_version and node.get_descendent_version methods that return a counter that is bumped when the node is dirtied. This is used to implement cache invalidation for caching HTMLCollection state. Caching HTMCollections gets a 1000x speedup in the Dromaeo DOM query tests.

Addresses https://github.com/servo/servo/issues/6901, https://github.com/servo/servo/issues/3381 and https://github.com/servo/servo/issues/1916.

Replaces PR https://github.com/servo/servo/pull/6927.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8227)
<!-- Reviewable:end -->
2015-11-10 01:11:23 +05:30
Eli Friedman
0901e5bc97 Move storage of bgcolor attribute on <body>. 2015-11-08 17:29:49 -08:00
Corey Farwell
9443b89af7 Minor 'node_from_nodes_and_strings' cleanup
This prevents an 'IntoIter' from getting unnecessarily allocated
2015-11-08 01:03:56 -05:00
Corey Farwell
fe4a5890d1 Add spec link for 'converting nodes into a node' 2015-11-08 00:49:33 -05:00
bors-servo
7ff3a17524 Auto merge of #8039 - tschneidereit:script-owns-stylesheets, r=jdm
Move Stylesheet loading and ownership from the layout task into HTML elements

Stylesheets for `HTMLLinkElement`s are now loaded by the resource task, triggered by the element in question. Stylesheets are owned by the elements they're associated with, which can be `HTMLStyleElement`, `HTMLLinkElement`, and `HTMLMetaElement` (for `<meta name="viewport">).

Additionally, the quirks mode stylesheet (just as the user and user agent stylesheets a couple of commits ago), is implemented as a lazy static, loaded once per process and shared between all documents.

This all has various nice consequences:
 - Stylesheet loading becomes a non-blocking operation.
 - Stylesheets are removed when the element they're associated with is removed from the document.
 - It'll be possible to implement the CSSOM APIs that require direct access to the stylesheets (i.e., ~ all of them).
 - Various subtle correctness issues are fixed.

One piece of interesting follow-up work would be to move parsing of external stylesheets to the resource task, too. Right now, it happens in the link element once loading is complete, so blocks the script task. Moving it to the resource task would probably be fairly straight-forward as it doesn't require access to any external state.

Depends on #7979 because without that loading stylesheets asynchronously breaks lots of content.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8039)
<!-- Reviewable:end -->
2015-11-08 01:11:54 +05:30
Till Schneidereit
543703e3d8 Move Stylesheet loading and ownership from the layout task into HTML elements
Stylesheets for `HTMLLinkElement`s are now loaded by the resource task, triggered by the element in question. Stylesheets are owned by the elements they're associated with, which can be `HTMLStyleElement`, `HTMLLinkElement`, and `HTMLMetaElement` (for `<meta name="viewport">).

Additionally, the quirks mode stylesheet (just as the user and user agent stylesheets a couple of commits ago), is implemented as a lazy static, loaded once per process and shared between all documents.

This all has various nice consequences:
 - Stylesheet loading becomes a non-blocking operation.
 - Stylesheets are removed when the element they're associated with is removed from the document.
 - It'll be possible to implement the CSSOM APIs that require direct access to the stylesheets (i.e., ~ all of them).
 - Various subtle correctness issues are fixed.

One piece of interesting follow-up work would be to move parsing of external stylesheets to the resource task, too. Right now, it happens in the link element once loading is complete, so blocks the script task. Moving it to the resource task would probably be fairly straight-forward as it doesn't require access to any external state.
2015-11-07 18:11:29 +01:00
bors-servo
3c794d0076 Auto merge of #8296 - notriddle:svg_title_prepend, r=nox
Prepend, rather than append, SVG title elements.

Fixes #8164

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8296)
<!-- Reviewable:end -->
2015-11-07 14:13:42 +05:30
bors-servo
65c3185b20 Auto merge of #8341 - bholley:state_hint_selector_ordering, r=pcwalton
Fix restyle hints to handle non-last psuedo-selectors, and track pristine state values rather than changesets

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8341)
<!-- Reviewable:end -->
2015-11-07 09:53:19 +05:30
Alan Jeffrey
237ddc3c0c Caching HTMCollections.
We cache the state of any live HTMLCollection, keeping track of

a) the optional cached length of the collection, and
b) an optional cursor into the collection (a node in the collection plus its index).

The cache is invalidated based on the version number of the node.

We use these caches for speeding up random access to the collection.
When returning coll[i], we search from the cursor, if it exists,
and otherwise search from the front of the collection.
In particular, both a forward for-loop and a backward for-loop
through the collection will now have each access take O(1)
time rather than O(n) time.

This gets 1000x speed-up on the relevant Dromaeo DOM query tests.
2015-11-06 17:23:17 -06:00
Michael Howell
71c5d1764a Prepend, rather than append, SVG title elements.
Fixes #8164
2015-11-06 09:34:42 -07:00
bors-servo
4067960ba5 Auto merge of #8326 - jdm:iframehover, r=glennw
Send mouse move events to the the previous layer when directing event…

…s to a new one for the first time. Resolves #7865.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8326)
<!-- Reviewable:end -->
2015-11-06 06:24:59 +05:30
Bobby Holley
7dba4447f1 Store pristine element state rather than a set of changes.
This is the strategy we'll need to take for attributes, and so this change
puts us in a position to handle attributes and state the same way.

This does mean that we stop taking care to track the situations where our
state has reverted to the original state, with no net change. I think that's
probably of negligible value though.
2015-11-04 19:09:58 -08:00
Ms2ger
6b75078503 Make DOMString a newtype around String, rather than a typedef.
This should make it somewhat easier to experiment with alternative
representations in the future. To reduce churn, this commit leaves the String
field public, though.

Also, this will allow us to use the default String type to represent the IDL
USVString type, which explicitly forbids unpaired surrogates, ans as such is
a better match to the Rust String type.
2015-11-04 12:09:11 +01:00
Ms2ger
e6aa976462 Use DOMString::new() somewhat consistently. 2015-11-04 12:09:10 +01:00
Josh Matthews
9529196d2f Send mouse move events to the the previous layer when directing events to a new one for the first time. Resolves #7865. 2015-11-04 03:40:13 -05:00
David Zbarsky
722aa86c89 Get rid of a bunch of explicit derefs 2015-11-03 19:51:46 -08:00
bors-servo
daad09d442 Auto merge of #8221 - wenderen:8130-reorganise, r=jdm
move modules around

for #8130

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8221)
<!-- Reviewable:end -->
2015-11-04 02:56:02 +05:30
bors-servo
3fdaa6e3f3 Auto merge of #8232 - mbrubeck:glutin-touch, r=glennw
Correct event dispatching for multiple simultaneous touch points

Instead of just converting the mouse into a single "touch" input, Servo can now listen for multi-touch events from Glutin, maintain a list of active touch points, and dispatch events for all of them.

r? @glennw (for the compositor changes) and @jdm (for the DOM changes)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8232)
<!-- Reviewable:end -->
2015-11-03 22:45:21 +05:30
Matt Brubeck
ef93650db9 Handle multi-touch events from glutin 2015-11-03 08:56:34 -08:00
Alan Jeffrey
d3ea0a0256 Removced unncessary call to dirty() in Document::node_and_heritage_change, since the node is aready dirtied by force_dirty_ancestors(). 2015-11-03 09:08:13 -06:00
rohan.prinja
6e774ea6eb merge from master 2015-11-03 19:01:23 +09:00
Eli Friedman
df7fb8fa32 Remove JSTraceable implementation from RefCell.
The implementation wasn't really right, and we would rather just use
DOMRefCell anyway.
2015-11-02 14:40:57 -08:00
bors-servo
912359fcbd Auto merge of #8282 - Ms2ger:handle_mouse_move_event, r=Manishearth
Cleanup Document::handle_mouse_move_event a bit.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8282)
<!-- Reviewable:end -->
2015-10-31 18:57:31 +05:30
nxnfufunezn
d8ef3809a6 Removed JS::root Fixes #8251 2015-10-31 18:15:16 +05:30
Ms2ger
e05d9d0646 Cleanup Document::handle_mouse_move_event a bit. 2015-10-31 13:25:32 +01:00
Bobby Holley
79ac365a68 Move EventState to rust-selectors. 2015-10-30 21:02:35 -07:00
rohan.prinja
51df8e310b rearrange imports to be in alphabetical order 2015-10-30 20:28:59 +09:00
rohan.prinja
9fd823e449 replace InheritTypes imports with inheritance imports 2015-10-30 20:26:30 +09:00
rohan.prinja
45224028db more refactoring 2015-10-30 20:26:29 +09:00
rohan.prinja
bb2536cd01 move Castable into dom::bindings::inheritance 2015-10-30 20:24:42 +09:00
rohan.prinja
4a4f041948 remove get_rooted() and replace all references to it with references to get() 2015-10-29 21:48:39 +09:00
bors-servo
285e29c066 Auto merge of #8098 - bholley:dirty_from_layout, r=jdm
Track event state changes on Document and do the dirtying from layout

This is a first step in fixing #6942.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8098)
<!-- Reviewable:end -->
2015-10-29 00:24:53 +05:30
bors-servo
7c9f4644f3 Auto merge of #8169 - ax3lst:master, r=eefriedman
Implement document.createEvent(TouchEvent)

This solves #8160

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8169)
<!-- Reviewable:end -->
2015-10-28 05:55:03 +05:30
Bobby Holley
069c40f788 Check modified event state from layout and dirty it there.
This adds some overhead, but also provides the small performance benefit of
avoiding dirtying in the case where an event state is toggled an even
number of times between reflows.

The main benefit here though is that it sets us up to be smarter about
what we mark as dirty using restyle hints.
2015-10-27 12:48:48 -07:00
Bobby Holley
441c84d75d Pass the document instead of the documentElement to reflow. 2015-10-27 12:41:16 -07:00
Rohan Prinja
6b42a7366a remove DocumentProgressTask enum 2015-10-27 10:24:37 +09:00
bors-servo
704c5ef25a Auto merge of #7979 - tschneidereit:script-loading-fixes, r=jdm
Improve spec-compliance of script loading and execution during document startup

Including proper support for async and deferred scripts.

r? @jdm

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7979)
<!-- Reviewable:end -->
2015-10-26 15:48:23 -05:00
Till Schneidereit
a0c5d47910 Improve spec-compliance of script loading and execution during document startup
Including proper support for async and deferred scripts.
2015-10-26 21:35:09 +01:00
Axel Solis Trompler
5542f87400 Refactor document.createEvent(touchevent) 2015-10-25 16:36:16 +01:00
Corey Farwell
f97d1d148b Implement 'control' attribute for <label> elements 2015-10-25 08:06:31 -04:00