Commit graph

287 commits

Author SHA1 Message Date
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
69e6eb4d91 Auto merge of #8304 - dzbarsky:borrowck, r=Ms2ger
Cleanup some unneeded let bindings

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8304)
<!-- Reviewable:end -->
2015-11-07 01:31:40 +05:30
Josh Matthews
989e80036e Implement cancellable runnables.
Additionally, make image load events cancellable. Resolves #7731.
2015-11-06 10:41:38 -05:00
David Zbarsky
dfc90db1d7 Cleanup some unneeded let bindings 2015-11-06 00:22:31 -08:00
bors-servo
1dc144d168 Auto merge of #8332 - Ms2ger:8209-comment, r=frewsxcv
Remove obsolete comment (fixes #8209).

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8332)
<!-- Reviewable:end -->
2015-11-05 06:25:54 +05:30
bors-servo
b4d234107e Auto merge of #7128 - Ms2ger:bc-root, r=jdm
Make BrowsingContext JS-managed.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7128)
<!-- Reviewable:end -->
2015-11-04 22:38:51 +05:30
Ms2ger
208140d208 Remove obsolete comment (fixes #8209). 2015-11-04 14:33:35 +01:00
Ms2ger
f86502f80c Make BrowsingContext JS-managed. 2015-11-04 12:30:13 +01: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
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
rohan.prinja
6e774ea6eb merge from master 2015-11-03 19:01:23 +09:00
bors-servo
9a800becdf Auto merge of #8239 - Ms2ger:ScriptReflow, r=pcwalton
Remove unused code around ScriptReflow.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8239)
<!-- Reviewable:end -->
2015-11-03 15:29:17 +05:30
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
Olivia Nordquist
aebf87cf5b Un-boxed ScriptReflow 2015-10-31 22:29:16 -07:00
Ms2ger
7fc93c0770 Remove unused Window::control_chan. 2015-10-31 12:40:18 +01:00
Ms2ger
02692d201f Remove unused Window::last_reflow_id. 2015-10-31 12:40:17 +01:00
Ms2ger
40b3b749bf Remove unused fields from ScriptReflow. 2015-10-31 12:40:14 +01:00
rohan.prinja
51df8e310b rearrange imports to be in alphabetical order 2015-10-30 20:28:59 +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
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
Ms2ger
1608450e4e Remove Window::layout_join_port.
It is only used in Window::force_reflow.
2015-10-22 16:12:59 +02:00
Ms2ger
2456ddf4ba Remove Window::handle_reflow_complete_msg and ScriptTask::handle_reflow_complete_msg.
Code on the script thread can only observe self.layout_join_port being Some()
between the time it is set in force_reflow, and the join_layout call later in
that function, and no significant code is called in that code.

Since these functions do nothing useful if layout_join_port is None, there is
no point in keeping them.
2015-10-22 16:12:58 +02:00
Ms2ger
7cd3870977 Inline Window::join_layout into its only caller.
I do not know if the FIXME comment is correct; I just copied it.
2015-10-22 16:12:57 +02:00
Ms2ger
9d739cf684 Remove layout_is_idle.
Code on the script thread can only observe self.layout_join_port being Some()
between the time it is set in force_reflow, and the join_layout call later in
that function, and no significant code is called in that code.

This implies that layout_is_idle will always return true, so there is no
reason for the function to exist.
2015-10-22 16:12:56 +02:00
Ms2ger
af448374f9 Remove pointless join_layout calls.
Code on the script thread can only observe self.layout_join_port being Some()
between the time it is set in force_reflow, and the join_layout call later in
that function, and no significant code is called in that code.

As join_layout does nothing when called if self.layout_join_port is None,
these two calls are useless.
2015-10-22 16:12:55 +02:00
benshu
553a0dbefd Timers are scheduled by a dedicated per-constellation thread. 2015-10-21 16:40:49 +02:00
Anthony Ramine
68014af78e Clean up the cast calls 2015-10-21 11:40:34 +02:00
Anthony Ramine
13ea3ac413 Introduce trait Castable
This trait is used to hold onto the downcast and upcast functions of all
castable IDL interfaces. A castable IDL interface is one which either derives
from or is derived by other interfaces.

The deriving relation is represented by implementations of marker trait
DerivedFrom<T: Castable> generated in InheritTypes.

/^[ ]*use dom::bindings::codegen::InheritTypes::.*(Base|Cast|Derived)/ {
    /::[a-zA-Z]+(Base|Cast|Derived);/d
    s/([{ ])[a-zA-Z]+(Base|Cast|Derived), /\1/g
    s/([{ ])[a-zA-Z]+(Base|Cast|Derived), /\1/g
    s/, [a-zA-Z]+(Base|Cast|Derived)([},])/\2/g
    s/, [a-zA-Z]+(Base|Cast|Derived)([},])/\2/g
    /\{([a-zA-Z]+(Base|Cast|Derived))?\};$/d
    s/\{([a-zA-Z_]+)\};$/\1;/
}

s/([a-zA-Z]+)Cast::from_ref\(\&?\**([a-zA-Z_]+)(\.r\(\))?\)/\2.upcast::<\1>()/g
s/([a-zA-Z]+)Cast::from_ref\(\&?\**([a-zA-Z_]+)(\.[a-zA-Z_]+\(\))?\)/\2\3.upcast::<\1>()/g
s/\(([a-zA-Z]+)Cast::from_ref\)/\(Castable::upcast::<\1>\)/g

s/([a-zA-Z]+)Cast::from_root/Root::upcast::<\1>/g

s/([a-zA-Z]+)Cast::from_layout_js\(\&([a-zA-Z_.]+)\)/\2.upcast::<\1>()/g

s/([a-zA-Z]+)Cast::to_ref\(\&?\**([a-zA-Z_]+)(\.r\(\))?\)/\2.downcast::<\1>()/g
s/([a-zA-Z]+)Cast::to_ref\(\&?\**([a-zA-Z_]+)(\.[a-zA-Z_]+\(\))?\)/\2\3.downcast::<\1>()/g
s/\(([a-zA-Z]+)Cast::to_ref\)/\(Castable::downcast::<\1>\)/g

s/([a-zA-Z]+)Cast::to_root/Root::downcast::<\1>/g

s/([a-zA-Z]+)Cast::to_layout_js\(&?([a-zA-Z_.]+(\(\))?)\)/\2.downcast::<\1>()/g

s/\.is_document\(\)/.is::<Document>()/g
s/\.is_htmlanchorelement\(\)/.is::<HTMLAnchorElement>()/g
s/\.is_htmlappletelement\(\)/.is::<HTMLAppletElement>()/g
s/\.is_htmlareaelement\(\)/.is::<HTMLAreaElement>()/g
s/\.is_htmlbodyelement\(\)/.is::<HTMLBodyElement>()/g
s/\.is_htmlembedelement\(\)/.is::<HTMLEmbedElement>()/g
s/\.is_htmlfieldsetelement\(\)/.is::<HTMLFieldSetElement>()/g
s/\.is_htmlformelement\(\)/.is::<HTMLFormElement>()/g
s/\.is_htmlframesetelement\(\)/.is::<HTMLFrameSetElement>()/g
s/\.is_htmlhtmlelement\(\)/.is::<HTMLHtmlElement>()/g
s/\.is_htmlimageelement\(\)/.is::<HTMLImageElement>()/g
s/\.is_htmllegendelement\(\)/.is::<HTMLLegendElement>()/g
s/\.is_htmloptgroupelement\(\)/.is::<HTMLOptGroupElement>()/g
s/\.is_htmloptionelement\(\)/.is::<HTMLOptionElement>()/g
s/\.is_htmlscriptelement\(\)/.is::<HTMLScriptElement>()/g
s/\.is_htmltabledatacellelement\(\)/.is::<HTMLTableDataCellElement>()/g
s/\.is_htmltableheadercellelement\(\)/.is::<HTMLTableHeaderCellElement>()/g
s/\.is_htmltablerowelement\(\)/.is::<HTMLTableRowElement>()/g
s/\.is_htmltablesectionelement\(\)/.is::<HTMLTableSectionElement>()/g
s/\.is_htmltitleelement\(\)/.is::<HTMLTitleElement>()/g
2015-10-21 11:37:16 +02:00
bors-servo
1a376aa75d Auto merge of #8060 - nox:deref-js, r=Ms2ger
Implement Deref<Target=T> for JS<T> where T: Reflectable

We can only borrow `JS<T>` from rooted things, so it's safe to deref it.
The only types that provide mutable `JS<T>` things are `MutHeap<JS<T>>` and
`MutNullableHeap<JS<T>>`, which don't actually expose that they contain
`JS<T>` values.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8060)
<!-- Reviewable:end -->
2015-10-19 06:32:05 -06:00
Anthony Ramine
6ab7f64620 Return a reference in BrowserContext::active_window() 2015-10-19 09:36:53 +02:00
Anthony Ramine
264e943597 Return a reference in BrowserContext::frame_element() 2015-10-17 02:17:25 +02:00
Anthony Ramine
1f31d5b856 Return a reference in BrowserContext::active_document() 2015-10-17 02:07:52 +02:00
KALPESH KRISHNA
a183eacb63 Adding window.onstorage EventHandler 2015-10-16 02:37:27 +05:30
bors-servo
417cf5738e Auto merge of #8020 - nox:codegen-derived, r=Ms2ger
Generate all Derived implementations in codegen

Follow-up of #7873.

@Ms2ger r? :)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8020)
<!-- Reviewable:end -->
2015-10-15 12:53:08 -06:00
Anthony Ramine
617fc08783 Generate all Derived implementations in codegen 2015-10-14 22:04:20 +02:00
Michael Wu
e733a7c46a Support the updated spidermonkey bindings 2015-10-14 15:30:52 -04:00
Anthony Ramine
aab2c40389 Generate the TypeId enums in codegen 2015-10-14 18:45:35 +02:00
Eli Friedman
fa606bf1c8 Link to the HTML multipage spec, not the single-page one. 2015-10-13 11:48:51 -07:00
Corey Farwell
9b68d715de Explicitly place '/' before fragment for multipage spec links
This prevents us from 301 redirecting, which could cause the fragment to
get lost
2015-10-10 12:07:10 -04:00
Corey Farwell
85f2b6fc5b Replace usage of old-style WHATWG spec links 2015-10-10 11:55:09 -04:00
Anthony Urena
ba86131cd5 Refactor Error enum usage to consistently be qualified 2015-10-06 05:43:52 -04:00
Glenn Watson
339a3f869b Split Au type into separate crate, with minimal dependencies. 2015-10-01 07:16:11 +10:00
Patrick Walton
9bb6acd690 layout: Load Web fonts asynchronously.
Improves page load times significantly.

Closes #7343.
2015-09-27 15:38:20 -07:00
Patrick Walton
5dce5f0c97 script: Stop copying the document URL. 2015-09-24 18:54:53 -07:00
Ravi Shankar
889eec364b sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
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
Ms2ger
b7a0440f91 Emit markers for all events, not just UI events. 2015-09-16 16:29:01 +02:00