Commit graph

195 commits

Author SHA1 Message Date
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
9faa2de0fc Use static atoms in some places. 2015-09-14 10:33:16 +02:00
bors-servo
eaf90c0b1c Auto merge of #7452 - nox:cleanup-attributes, r=nox
Introduce VirtualMethods::attribute_mutated()



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7452)
<!-- Reviewable:end -->
2015-09-02 08:14:33 -06:00
Anthony Ramine
58e1bd0e57 Introduce VirtualMethods::attribute_mutated()
This replaces before_remove_attr(), after_remove_attr() and after_set_attr().
The virtual method takes the mutated attribute and an AttributeMutation value
to disambiguate between "attribute is changed", "attribute is added" and
"attribute is removed".

In the case of "attribute is changed", the mutation value contains a reference
to the old value of the mutated attribute, which is used to unregister outdated
named elements when the "id" attribute is changed on an element.

This greatly simplifies the handling of attributes, which in many cases don't
have any specific behaviour whether they are removed or changed or added. It
also fixes a few bugs where things were put in before_remove_attr() instead of
after_remove_attr() (e.g. when removing an href attribute from a base element).

A few helper functions in Element were also renamed and made private.
2015-09-02 15:45:38 +02:00
Corey Farwell
3a1d140ab5 Enforce linking to spec for method implementations via macros 2015-08-31 21:02:23 -04:00
Anthony Ramine
51418fc348 Replace many uses of Attr::Value() by Attr::value()
The later only borrows the attribute, without copying its value as a string.
2015-08-30 15:30:01 +02:00
Anthony Ramine
105d990845 Replace many uses of to_ascii_lowercase() by make_ascii_lowercase() 2015-08-30 15:30:00 +02:00
Corey Farwell
5ccb0d43ef Merge adjacent identical impl sections
Prior to #7416 and #7401, many of these `impl` sections were not
identical
2015-08-28 10:30:42 -04:00
benshu
1e6a2f08fc Time distribution across script event categories. 2015-08-28 00:52:41 +02:00
Anthony Ramine
709d347872 Make the traits for the IDL interfaces take &self 2015-08-27 22:27:43 +02:00
Anthony Ramine
2a028f66a2 Remove AttributeHandlers
On components/script/*.rs:

    # Remove imports.
    /^ *use dom::element::\{.*AttributeHandlers/ {
        s/\{AttributeHandlers, /\{/
        s/, AttributeHandlers//g
        s/\{([a-zA-Z]+)\}/\1/
        /\{\}/d
        s/::self;$/;/
    }
    /^ *use dom::element::\{?AttributeHandlers\}?;$/d

    # Remove AttributeHandlers.
    /^pub trait AttributeHandlers \{$/,/^\}$/D

    # Patch AttributeHandlers methods.
    /^impl<'a> AttributeHandlers for &'a Element \{/,/^\}$/ {
        s/^impl<'a> AttributeHandlers for &'a Element \{/impl Element {/
        /^ *fn /s/\(self([,)])/\(\&self\1/
	/^ *fn.*\(&self/s/fn/pub fn/
    }

The few error cases were then fixed by hand.
2015-08-27 16:59:04 +02:00
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
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
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
bors-servo
6a52ec9484 Auto merge of #7006 - Wafflespeanut:script_cleanup, r=jdm
Splitting ScriptMsg into various enums...

... for #3734, which is also one of the oldest issues. (/cc @jdm)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7006)
<!-- Reviewable:end -->
2015-08-15 03:48:47 -06:00
Ravi Shankar
89153116fb Splitting ScriptMsg into various enums; r=jdm 2015-08-15 02:00:48 +05:30
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
Patrick Walton
2aa5174246 script: Make the resource task communication use IPC channels. 2015-07-31 11:28:09 -07:00
Patrick Walton
44d13f7fd4 net: Use a thread for each AsyncResponseTarget to avoid having to send
trait objects across process boundaries.
2015-07-31 11:27:49 -07:00
Patrick Walton
9c9d7dc93b net: Make most of the resource task messages serializable. 2015-07-31 11:27:49 -07: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
Michael Wu
675267b782 Upgrade to SM 39 2015-06-19 18:42:48 -04:00
Corey Farwell
8e3f4bba85 Reduce max line length from 150 to 120 characters
Part of https://github.com/servo/servo/issues/6041
2015-05-24 00:01:49 -04:00
Josh Matthews
ef8a127156 Update test expectations. Mark script loads as complete when the response is complete. 2015-05-21 09:53:19 -04:00
Josh Matthews
8082df7d0d Make external script sources load asynchronously, yet still block further parsing. Hook up document loading to async networking events. 2015-05-20 14:22:09 -04:00
Josh Matthews
7f0706ed42 Implement a DocumentLoader type that tracks pending loads and notifies the script task when the queue is empty. Dispatch the document load event based on the DocumentLoader's notification. 2015-05-11 13:41:51 -04:00
Anthony Ramine
7197052c0d Uniformise root() methods
They now live in traits Rootable, OptionalOptionalRootable, OptionalRootable
and ResultRootable.
2015-04-28 09:22:45 +02:00
Manish Goregaokar
dcb0a0eab6 Fix some no_move errors 2015-04-28 04:20:45 +05:30
Ms2ger
a862479ca8 Remove as_slice() calls from script. 2015-04-26 10:52:55 +02:00
Corey Farwell
8b08c6f43f Don't link to specific WHATWG multipage page
"Links to the multipage version of the specification are unfortunately
likely to break over time."
-- https://html.spec.whatwg.org/multipage/asefij.html

This commit removes all references to the specific pages when viewing
WHATWG using multipage mode. I went through all these links and they
redirect fine.

Regex used to generate this commit:

`s_whatwg.org/multipage/.*#_whatwg.org/multipage/#_g`
2015-04-16 22:39:25 -04:00
Corey Farwell
5eaa922045 Update WHATWG links to use HTTPS
Extracted this out of #5649

This commit was created with the following commands:

```
find . -iname "*.webidl" -type f -print0 | xargs -0 sed -i '' 's/http:\(.*\)whatwg.org/https:\1whatwg.org/g'
```

```
find . -iname "*.rs" -type f -print0 | xargs -0 sed -i '' 's/http:\(.*\)whatwg.org/https:\1whatwg.org/g'
```
2015-04-13 21:34:27 -07:00
Anthony Ramine
cdb3efec87 Use a Temporary iterator in Node::collect_text_contents() 2015-04-07 20:27:30 +02:00
Anthony Ramine
254207730e Make Element::get_attribute() take its namespace by reference 2015-04-06 14:31:27 +02:00
Gilles Leblanc
ba36a108c1 Split out shared networking code into net_traits crate
Fixes #4476
2015-04-03 13:38:10 -04:00
Ms2ger
c8106da277 Rewrite NodeChildrenIterator to return Temporary. 2015-04-02 13:07:51 +02:00
Keith Yeung
fdcf9618cb Handle the for and event attributes on a script element correctly when one of them is present (fixes #5258). 2015-04-01 12:43:17 +02:00
Brandon DeRosier
ccc55d658f Use box syntax instead of Box::new()
Closes #5417
2015-03-29 13:41:14 -04:00
Zack Slayton
08ac0766ed Use new if let syntax wherever possible. Fixes #4153. 2015-03-10 09:18:55 -04:00
bors-servo
73e5bbec43 auto merge of #5054 : psdh/servo/scriptimplementation, r=jdm
Fixes #4089
2015-03-06 13:36:53 -07:00
Prabhjyot Singh Sodhi
64ba4a914e implement missing steps from "prepare a script" algorithm
Fixes #4089
2015-03-06 03:16:59 +05:30
Josh Matthews
e2c4f5ed67 Move everything unrelated to the frame tree out of Page and into Document or Window. Reduce the API surface of Page to a bare minimum to allow for easier future removal. 2015-03-03 16:25:40 -05:00
James Gilbertson
5f5d1246ef Implement Document.currentScript 2015-02-27 11:11:02 -07:00
James Gilbertson
0b085df1bc Implement 'beforescriptexecute' and 'afterscriptexecute' events.
Spec: https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block, sections 2.b.2 & 2.b.9
2015-02-25 15:37:54 -07:00
Ms2ger
ada6a088d1 Split the 'Execute a script block' code out of prepare().
This also adds comments for missing steps.

The only change in behaviour should be the debug message when an external
script fails to load.
2015-02-23 10:28:49 +01:00
Tetsuharu OHZEKI
36722182c0 Introduce dom::htmlscriptelement::EventDispatcher. 2015-02-23 05:35:26 +09:00
Prabhjyot Singh Sodhi
cc48797999 Fixing Intermittent failure in pages with timers
Fixes #4923
2015-02-22 00:27:16 +05:30
bors-servo
0be6389158 auto merge of #4939 : KiChjang/servo/script-element-error-events, r=jdm
Fixes #4506
2015-02-21 08:42:46 -07:00