Commit graph

659 commits

Author SHA1 Message Date
Bobby Holley
79ac365a68 Move EventState to rust-selectors. 2015-10-30 21:02:35 -07:00
Ms2ger
7ccc5ad7da Support unions that contain USVStrings. 2015-10-30 16:24:04 +01:00
bors-servo
851e7098c9 Auto merge of #8248 - Ms2ger:finite-zero, r=jdm
Remove the Zeroable definition for Finite<T>.

I have no idea why it was added, and it appears to be unused.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8248)
<!-- Reviewable:end -->
2015-10-30 07:21:57 +05:30
bors-servo
00b60b9386 Auto merge of #8250 - wenderen:8246-remove-get-rooted, r=Ms2ger
remove get_rooted() and replace all references to it with references …

…to get()

for #8246

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8250)
<!-- Reviewable:end -->
2015-10-30 06:37:44 +05:30
bors-servo
88f501c412 Auto merge of #5745 - servo:gc, r=Manishearth
Move the DOM memory management blog post into the tree.

This is a WIP, but I wanted to get eyes on it already.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5745)
<!-- Reviewable:end -->
2015-10-29 21:58:22 +05:30
Ms2ger
4dbc99c7f3 Move the DOM memory management blog post into the tree. 2015-10-29 17:25:00 +01: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
Ms2ger
04e32c7ab0 Remove the Zeroable definition for Finite<T>.
I have no idea why it was added, and it appears to be unused.
2015-10-29 12:21:51 +01:00
Ms2ger
85a57b5111 Add thread assertions to js.rs. 2015-10-29 11:56:17 +01: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
30ce2a84c1 Auto merge of #8242 - Ms2ger:update-js, r=metajack
Update js.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8242)
<!-- Reviewable:end -->
2015-10-28 23:35:40 +05:30
Ms2ger
2a2ab23dfb Update js. 2015-10-28 18:02:10 +01:00
bors-servo
3efa749976 Auto merge of #8226 - froydnj:gc-zeal, r=Ms2ger
unblock using JS_GC_ZEAL

I think these patches move the `JS_SetReservedSlot` call to the right place for #6057.  I'm not sure that the interface to `create_dom_global` is the best; passing a `JSVal` or a `*libc::c_void` seemed about equal, so I'd welcome feedback there.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8226)
<!-- Reviewable:end -->
2015-10-28 17:24:36 +05:30
Nathan Froyd
c82b6ce843 move reserved slot setting for DOM globals
Moving this slot setting prior to initializing standard classes and
other initialization tasks means that we can effectively use JS_GC_ZEAL.

Fixes #6057.
2015-10-27 18:08:35 -04:00
Nathan Froyd
3d39646c8e reduce indentation in CodegenRust.py
We're going to wind up tacking on different pieces of code for the
global vs. non-global case once we move the JS_SetReservedSlot call into
create_dom_global.  We might as well separate the indentation changes
into a separate commit.
2015-10-27 16:46:01 -04: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
630b9f8fa0 Implement Hash and Eq for JS<T> and LayoutJS<T>. 2015-10-27 12:41:14 -07:00
bors-servo
d1295e9e7d Auto merge of #8040 - froydnj:codegen-arg-info, r=jdm
generate JIT argument type information for methods

This enhances `CodegenRust.py` to output `JSTypedMethodJitInfo` structures where appropriate.  This brings a notable speedup to tests like Dromaeo's `dom-attr/getAttribute`, which improves by several orders of magnitude with these patches applied.

If there are tricks for addressing the XXX comments, I would appreciate hearing them.

I think this addresses all of #6904.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8040)
<!-- Reviewable:end -->
2015-10-28 01:06:06 +05:30
Nathan Froyd
4f649ac6dd generate JIT argument type information for methods
Fixes #6904.
2015-10-27 15:09:32 -04:00
Nathan Froyd
dd74572dc0 add CGMemberJITInfo.{getJSArgType,getSingleArgType}
These are copied directly from Gecko's Codegen.py, with two changes:

- We need to use ArgType:: to qualify the enums rather than plain
  JSJitInfo::

- Given Rust's stronger notion of enums, we need to treat everything as an
  i32 so we can bitwise-or things together.
2015-10-27 15:07:55 -04: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
bors-servo
6b95c3957b Auto merge of #8097 - wenderen:8090-partialeq-for-mutheap, r=nox
implement PartialEq for MutHeap<JS<T>> and MutNullableHeap<JS<T>>

for #8090

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8097)
<!-- Reviewable:end -->
2015-10-26 06:08:01 -05:00
Rohan Prinja
c1abb4fdb2 clean code as per code review 2015-10-26 03:52:05 +09:00
Ms2ger
54d3462fa5 Use the new define_methods and define_properties functions from js. 2015-10-25 19:50:10 +01:00
bors-servo
bb88832c07 Auto merge of #8073 - eefriedman:root-lint, r=Manishearth
Make unrooted_must_root a bit more aggressive.

Basically, instead of trying to check for specific kinds of statements,
just check the types of all local variables.

Also included are some commented-out proposals for some slightly more
aggressive lints which might be useful (but trigger a little too
frequently at the moment).

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8073)
<!-- Reviewable:end -->
2015-10-24 20:20:04 -05:00
Eli Friedman
81ecf7824c Make unrooted_must_root a bit more aggressive.
Basically, instead of trying to check for specific kinds of statements,
just check the types of all local variables.

Also included are some commented-out proposals for some slightly more
aggressive lints which might be useful (but trigger a little too
frequently at the moment).
2015-10-23 14:43:44 -07:00
Rohan Prinja
fe59b62db7 make changes according to code review (#8097) 2015-10-24 01:42:22 +09:00
Ms2ger
970b8aa8bc Remove the unused default implementation of Reflectable::init_reflector. 2015-10-23 17:21:04 +02:00
Ms2ger
9be52dc41a Implement GlobalRef::reflector as an inherent method.
Reflectable is meant for actual DOM objects, not for references to them.
2015-10-23 17:20:17 +02:00
Matt Brubeck
4ed15a8853 Add bindings for TouchEvent DOM interfaces 2015-10-22 10:35:11 -07:00
Matt Brubeck
e9f9eaa61c Fix type in MutHeap docs 2015-10-21 12:27:04 -07:00
Rohan Prinja
d9f8f68615 add equal() methods for comparisons with other types 2015-10-22 03:05:13 +09:00
bors-servo
3342cd9531 Auto merge of #8132 - akiss77:codegen-u8, r=Ms2ger
Fix char types in script binding codegen

Use `libc::c_char` instead of `i8` for character data since that's more
portable. (Some architectures, e.g. AArch64, have unsigned characters,
i.e. `u8`.)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8132)
<!-- Reviewable:end -->
2015-10-21 10:44:14 -06:00
Rohan Prinja
5e8dc366de in PartialEq impls, use Self instead of explicitly naming the struct type 2015-10-22 01:05:48 +09:00
benshu
553a0dbefd Timers are scheduled by a dedicated per-constellation thread. 2015-10-21 16:40:49 +02:00
Akos Kiss
8405ac70c9 Fix char types in script binding codegen
Use `libc::c_char` instead of `i8` for character data since that's more
portable. (Some architectures, e.g. AArch64, have unsigned characters,
i.e. `u8`.)
2015-10-21 14:31:07 +00:00
bors-servo
674589c370 Auto merge of #8041 - nox:castable, r=jdm
Introduce trait Castable

Removes all those messy FooCast structures in InheritTypes.rs.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8041)
<!-- Reviewable:end -->
2015-10-21 07:57:32 -06:00
Ms2ger
4e8033b739 Remove unused JS::assign. 2015-10-21 12:17:50 +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
Anthony Ramine
c77d3b965f Introduce IDLInterface::derives()
This method is given a DOMClass value and returns whether it derives from Self.

Interfaces with no descendants directly check whether the given DOMClass is the
same as their own.
2015-10-21 10:59:36 +02:00
Adam Szopa
88991013ab Remove explicit lifetimes which can be elided. 2015-10-21 01:27:48 +02:00
Rohan Prinja
ab70c8c942 implement PartialEq for MutHeap<JS<T>> and MutNullableHeap<JS<T>> 2015-10-21 01:40:19 +09:00
bors-servo
6111cf9ffc Auto merge of #7943 - pierrechevalier83:fix_issue_7941, r=Ms2ger
Clarify some code in do_create_interface_objects

rval.get() is believed to be always null upon entering this function.
This assumption is verified by the added assertion.
It makes more sense to move the block of code that was moved inside
the if statement which is the only place where it can be initialized.

Fixes #7941.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7943)
<!-- Reviewable:end -->
2015-10-19 09:37:03 -06: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
Corey Farwell
26abff9663 Fix formatting for variable in doc-comment within codegen 2015-10-17 15:20:12 -04:00
Anthony Ramine
6c7f37061b 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.
2015-10-17 01:58:52 +02:00
bors-servo
7a71f39320 Auto merge of #8031 - creativcoder:spec-links-js, r=jdm
added spec link for type mapping

Hi. added some of the spec links, that i could understand from the spec. Please mention if anything else needs to be added.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8031)
<!-- Reviewable:end -->
2015-10-16 13:38:30 -06:00
bors-servo
7c7dbde0f4 Auto merge of #8026 - eefriedman:js-rooting, r=nox
Fix uses of JS<T> as a type on the stack

`JS<T>` belongs on the heap, and only on the heap.  This is a collection of fixes so that code uses either `Root<T>` or `&T` to pass around garbage-collected pointers.

Ideally, we could completely ban constructing a `JS<T>` outside of constructor functions, but we aren't quite there yet.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8026)
<!-- Reviewable:end -->
2015-10-16 08:05:59 -06:00
Ms2ger
1f03ce1b1f Enable some warnings for generated code.
None of those warnings currently occur.
2015-10-16 12:07:57 +02:00
Eli Friedman
5713867778 Fix documentation for JS<T> and friends. 2015-10-15 14:03:57 -07:00