Commit graph

290 commits

Author SHA1 Message Date
Anthony Ramine
c831c2c0a5 Remove helper traits
Now that JSRef<T> is gone, there is no need to have helper traits.

On components/script/*.rs:

    # Remove imports.
    /^ *use dom::[a-z]+::\{.*Helpers/ {
        s/\{(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers, /\{/
        s/, (Raw[^L]|[^L][^a])[a-zA-Z]+Helpers([,}])/\2/g
        s/\{([a-zA-Z]+)\}/\1/
        /\{\}/d
        s/::self;$/;/
    }
    /^ *use dom::[a-z]+::\{?(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers\}?;$/d

On components/script/dom/*.rs:

    # Ignore layout things.
    /^(pub )?(impl|trait).*Layout.* \{/,/^}$/ { P; D; }

    # Delete helpers traits.
    /^(pub )?trait ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? \{$/,/^\}$/D

    # Patch private helpers.
    /^impl.*Private.*Helpers/,/^\}$/ {
        s/^impl<'a> Private([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for &'a ([^ ]+) \{$/impl \3 {/
        /^ *(unsafe )?fn .*\(self.*[<&]'a/ {
            s/&'a /\&/g
            s/<'a, /</g
        }
        /^ *(unsafe )?fn /s/\(self([,)])/\(\&self\1/
    }

    # Patch public helpers.
    /^impl.*Helpers/,/^\}$/ {
        s/^impl(<'a>)? ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for (&'a )?([^ ]+) \{$/impl \5 {/
        /^ *(unsafe )?fn .*\(self.*[<&]'a/ {
            s/&'a /\&/g
            s/<'a, /</g
        }
        /^ *(unsafe )?fn .*\(&?self[,)]/s/(unsafe )?fn/pub &/
        /^ *pub (unsafe )?fn /s/\(self([,)])/\(\&self\1/
    }

The few error cases were then fixed by hand.
2015-08-27 16:59:02 +02:00
João Oliveira
fd87c8cb3e make dom_struct derive HeapSizeOf,
closes #7357
2015-08-27 01:17:48 +01:00
bors-servo
48945b0fc1 Auto merge of #7397 - Manishearth:doublepointer-meet-fire, r=nox
Remove doublepointer in VirtualMethods, and from_borrowed_ref



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7397)
<!-- Reviewable:end -->
2015-08-26 15:01:12 -06:00
Manish Goregaokar
b33c5427bc Remove doublepointer in VirtualMethods, and from_borrowed_ref
Most of the heavy lifting done by:

```
$ ls *rs | xargs gawk -i inplace '/let .*: &&.*from_borrowed_ref/{sub("&&", "\\&");sub("_borrowed_","_");} {print $0}'
$ ls *rs | xargs gawk -i inplace "/impl.*VirtualMethods/{in_vm=1; sub(/<'a>/,\"\");sub(/&'a /,\"\")} /^}\$/{in_vm=0;} in_vm{\$0=gensub(/\\*self([^.])/,\"self\\\1\",\"g\"); sub(/from_borrowed_ref/,\"from_ref\")} {print}"
```
2015-08-27 02:14:48 +05:30
bors-servo
fa06a96f8a Auto merge of #7334 - servo:active, r=SimonSapin
Parse :active pseudo-class selector.

This is #7258 with a spec link added in doc-comment.

The pseudo-class is never matched, but this can still help with stylesheets like `a:hover, a:active { color: something }` where failing to parse one pseudo-class makes the entire selector list invalid.

I filed #7333 about actually making it match.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7334)
<!-- Reviewable:end -->
2015-08-24 04:23:13 -06:00
Simon Sapin
daedee844f Add spec link for the IN_ACTIVE_STATE flag. 2015-08-24 11:45:41 +02:00
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
Manish Goregaokar
19241c95f7 Cleanup NodeIterator, Range, ServoHTMLParser, TextEncoder, URLHelper, URL, VirtualMethods 2015-08-18 19:37:42 +05:30
Manish Goregaokar
b21df4844c Cleanup node.rs 2015-08-18 18:37:02 +05:30
Patrick Walton
6567c269cf script: Update rust-selectors to get :active support.
I couldn't find the place in the spec where the precise behavior of
`:active` is described, so I don't set it. However, all the machinery to
keep track of its status is in place.

Improves YouTube.
2015-08-17 17:52:21 -07: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
Josh Matthews
8bb853f643 Fix existing syntactics nits. 2015-08-16 10:30:43 -04:00
João Oliveira
9c11781880 replace .len() == 0 with is_empty()
closes #7198
2015-08-14 04:00:33 +01:00
Bogdan Cuza
45145108da Measure heap memory usage for more types. Fixes #6951 2015-08-13 21:44:41 +03:00
bors-servo
2b9590c5a5 Auto merge of #6778 - nox:childnodes, r=jdm
Optimise Node.childNodes



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6778)
<!-- Reviewable:end -->
2015-08-10 14:05:02 -06:00
Anthony Ramine
4e8922a53a Optimise Node.childNodes
We use the virtual method children_changed() to propagate changes in the children
list to the NodeList tied to Node.childNodes.
2015-08-09 00:10:21 +02:00
Josh Matthews
8620fe5995 Start reporting memory usage for Window and all nodes in all DOM trees for frame treese in script tasks. 2015-08-03 23:05:00 -04:00
Anthony Ramine
a49eb14615 Cache the number of children of each node 2015-07-31 23:32:30 +02:00
bors-servo
5873a5cf20 Auto merge of #6800 - frewsxcv:childnode-before-childnode-after, r=Ms2ger
Implement ChildNode::before & ChildNode::after

Continued from #6536

The current implementations of `ChildNode::before` and
`ChildNode::after` do not match the WHATWG spec. This commit updates the
implementations to match the spec.

Our current implementation of `ChildNode::after` passes all the WPT
tests. So I made sure to add a regression test that failed with the
current implementation. There are a few other unit tests I added
to exhaust other corner cases I encountered.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6800)
<!-- Reviewable:end -->
2015-07-30 04:13:39 -06:00
bors-servo
9e8d231196 Auto merge of #6783 - dzbarsky:replacechild, r=Ms2ger
Clean up Node::ReplaceChild



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6783)
<!-- Reviewable:end -->
2015-07-30 02:11:57 -06:00
David Zbarsky
cbd9695c73 Clean up Node::ReplaceChild 2015-07-29 19:41:04 -04:00
Corey Farwell
8cfccda542 Implement ChildNode::before & ChildNode::after
Continued from #6536

The current implementations of `ChildNode::before` and
`ChildNode::after` do not match the WHATWG spec. This commit updates the
implementations to match the spec.

Our current implementation of `ChildNode::after` passes all the WPT
tests. So I made sure to add a regression test that failed with the
current implementation. There are a few other unit tests I added
to exhaust other corner cases I encountered.
2015-07-29 22:44:19 +07:00
Nick Thompson
072609ab8c Dispose layout data for every node removed from the tree 2015-07-28 12:08:20 -07:00
bors-servo
e0bd80f807 Auto merge of #6662 - tschneidereit:client-geometry, r=glennw,pcwatson
Implement Element.client{Top,Left,Width,Height}

This isn't done, but contains a working implementation of at least `clientTop`. Feedback would be much appreciated: it's probably far from ideal.

Implementing `clientLeft` is straight-forward, I think, but `clientWidth` and `clientHeight` require accessing the `border_box` - and I don't know how that works, yet.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6662)
<!-- Reviewable:end -->
2015-07-27 20:45:05 -06:00
bors-servo
5a66b59f9b Auto merge of #6760 - dzbarsky:comment-fix, r=jdm
Remove outdated comment about cloning elements

The comment points to the "implement element prefix" issue, but we clone the element's prefix when we construct the element right above.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6760)
<!-- Reviewable:end -->
2015-07-26 08:01:56 -06:00
David Zbarsky
3801cfdd35 Remove outdated comment about cloning elements 2015-07-25 13:40:29 -04:00
bors-servo
705c95dedb Auto merge of #6660 - nox:children-changed, r=jdm
Introduce VirtualMethods::children_changed()

This virtual method mimics the behaviour of mutation observers and make it more viable than the older child_inserted(), which didn't cover removed nodes and was called as many times as there were inserted nodes.

A few other shortcomings where remove_child() was called directly instead of Node::remove() were also fixed while at it.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6660)
<!-- Reviewable:end -->
2015-07-25 11:39:20 -06:00
Anthony Ramine
7b40cc9fd7 Introduce VirtualMethods::children_changed()
This virtual method mimics the behaviour of mutation observers and make it more
viable than the older child_inserted(), which didn't cover removed nodes and
was called as many times as there were inserted nodes.

A few other shortcomings where remove_child() was called directly instead of
Node::remove() were also fixed while at it.
2015-07-25 19:09:40 +02:00
bors-servo
f44d75e5b2 Auto merge of #6715 - Ms2ger:layoutelement, r=jdm
Implement more methods on LayoutJS.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6715)
<!-- Reviewable:end -->
2015-07-23 12:40:52 -06:00
Ms2ger
849eb7837a Move the flag getters to LayoutNodeHelpers. 2015-07-23 20:13:06 +02:00
Ms2ger
32ee62b4c8 Remove unused RawLayoutNodeHelpers::type_id_for_layout. 2015-07-23 19:54:12 +02:00
Simon Sapin
055a1c5cee Update rust-selectors
Update for https://github.com/servo/rust-selectors/pull/37
2015-07-23 18:53:57 +02:00
Michael Howell
402a2a8717 Optimize Node.normalize().
Do not copy the discarded node's text data, borrow it.

Closes #6658.
2015-07-22 10:53:50 -07:00
bors-servo
8a6681ba70 Auto merge of #6688 - Manishearth:smarter-root-lint, r=jdm
Handle type parameters in unused_must_root

fixes #6651

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6688)
<!-- Reviewable:end -->
2015-07-22 07:05:31 -06:00
Manish Goregaokar
a9f651cfa1 Address review comments; add docs 2015-07-22 18:34:54 +05:30
Corey Farwell
b1b03a32db Upgrade rust-selectors, pass ':empty' tests
https://github.com/servo/rust-selectors/pull/36
2015-07-22 18:27:33 +07:00
Manish Goregaokar
511e3337fb Fix rooting in script 2015-07-22 00:00:15 +05:30
Till Schneidereit
162ecd0aac Implement client{Top, Left, Height, Width} element properties 2015-07-19 15:04:50 +02:00
bors-servo
acf47a02cf Auto merge of #6568 - dzbarsky:delete_range, r=jdm
Implement Range#insertNode

Gecko doesn't really follow the spec but it seems to throw a HierarchyRequest error when parent is null.
Any ideas who I should talk to about fixing the spec to account for the null checks?

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6568)
<!-- Reviewable:end -->
2015-07-16 10:56:17 -06:00
David Zbarsky
c2664e52dd Implement Range#insertNode 2015-07-16 17:43:46 -04:00
Michael Wu
2752d3398e Directly append children to output node in parse_html_fragment 2015-07-15 17:09:26 -04:00
bors-servo
6a728712f9 Auto merge of #6617 - frewsxcv:fixme-ufcs, r=metajack
Complete FIXMEs related to UFCS



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6617)
<!-- Reviewable:end -->
2015-07-14 01:30:12 -06:00
Corey Farwell
78d2fe6e9b Complete FIXMEs related to UFCS 2015-07-14 09:24:53 +09:00
David Zbarsky
0fa8e51432 Test element prefix for element equality 2015-07-11 02:50:39 -04:00
David Zbarsky
326b2a7161 Test element prefix for element equality 2015-07-10 14:41:37 -04:00
bors-servo
1e16047846 Auto merge of #6559 - kball:IS1824-implement-Node.baseURI, r=Ms2ger
Implement Node.baseURI

Addresses Issue #1824.  Implements Node.baseURI based on https://www.w3.org/Bugs/Public/show_bug.cgi?id=20976#c32

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6559)
<!-- Reviewable:end -->
2015-07-06 11:04:45 -06:00
bors-servo
cc73aad447 Auto merge of #6546 - michaelwu:slim-layoutdatawrapper, r=Ms2ger
Remove LayoutChan from LayoutDataWrapper

Saves 32 bytes in Node.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6546)
<!-- Reviewable:end -->
2015-07-05 21:39:12 -06:00
Kevin Ball
dbbab3b113 Implement Node.baseURI 2015-07-05 15:29:04 -07:00
David Zbarsky
861ddedaef Remove some redundant let bindings 2015-07-04 13:12:49 -04:00
Michael Wu
1a014beb08 Remove LayoutChan from LayoutDataWrapper 2015-07-04 03:54:40 -04:00