Commit graph

76 commits

Author SHA1 Message Date
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
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
Jim Berlage
380a9ce22b Adds bufferedAmount to Websocket (fixes #7856). 2015-10-15 17:06:24 -05:00
bors-servo
26902a9a9b Auto merge of #7871 - psdh:sendReason, r=jdm
Send reason in the Websocket close handshake

Fixes #7862

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7871)
<!-- Reviewable:end -->
2015-10-13 17:25:27 -06:00
bors-servo
8c81d9ab28 Auto merge of #7885 - jimberlage:7858/null-message, r=Ms2ger
Creates empty string when passed null

This should fix #7858.  An empty `USVString` is now used when `data` is `None`.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7885)
<!-- Reviewable:end -->
2015-10-09 09:02:45 -06:00
Jim Berlage
0ffd2f636f Require the argument to WebSocket#send() (fixes #7858). 2015-10-08 12:08:26 -05:00
vectorijk
0fb5e745e5 make blacklist as const array 2015-10-06 09:03:51 -07:00
vectorijk
4e21b9fa83 Fix #7855 Implement port blocking
For WebSocket connection algorithm
2015-10-06 07:31:33 -07:00
Anthony Urena
ba86131cd5 Refactor Error enum usage to consistently be qualified 2015-10-06 05:43:52 -04:00
Roman Klauke
1f82e5121c remove data field from websockets
The data field is currently not used (no reads/ writes). This commit
removes this field.

Ref.-Issue: #7859
2015-10-05 21:23:42 +02:00
Prabhjyot Singh Sodhi
61fa1e4440 Send reason in the Websocket close handshake 2015-10-05 17:59:39 +05:30
Ravi Shankar
35d7ced89e fixed the 'as_slice' deprecated warning 2015-09-26 00:51:04 +05:30
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
Michael Wu
941f7dc04b Move EventTargetTypeId/NodeTypeId to DOMClass 2015-09-12 01:09:46 +02:00
Corey Farwell
3a1d140ab5 Enforce linking to spec for method implementations via macros 2015-08-31 21:02:23 -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
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
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
Manish Goregaokar
a53b86f107 Cleanup WebGLRenderingContext, Websocker, WorkerGlobalScope 2015-08-18 18:38:36 +05:30
Josh Matthews
8bb853f643 Fix existing syntactics nits. 2015-08-16 10:30:43 -04:00
bors-servo
7c63c7d7c1 Auto merge of #7214 - tomjakubowski:websocket-binaryType, r=Ms2ger
Implement WebSocket#binaryType

Closes #7098

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7214)
<!-- Reviewable:end -->
2015-08-15 19:57:58 -06:00
Tom Jakubowski
e92f4629db WebSocket: Implement WebSocket#binaryType 2015-08-15 12:44:22 -07:00
Ravi Shankar
89153116fb Splitting ScriptMsg into various enums; r=jdm 2015-08-15 02:00:48 +05:30
Bogdan Cuza
45145108da Measure heap memory usage for more types. Fixes #6951 2015-08-13 21:44:41 +03:00
Ms2ger
352229b6fa Implement WebSocket#onmessage. 2015-08-08 10:29:03 +02:00
Ms2ger
2a97ab36f7 Dispatch message events for WebSocket. 2015-08-07 10:58:33 +02:00
James Graham
f52276d2cc Use hosts-replaced URL only when loading resources 2015-08-05 10:34:20 +01:00
Bogdan Cuza
233a769c67 Add spec links 2015-07-28 13:28:41 +02:00
Ms2ger
6329dec31f Move the WebSocket constructor logic out of WebSocket::new. 2015-07-23 09:00:34 +02:00
Ms2ger
32ddd356b8 Spawn a thread for WebSocket messages. 2015-07-22 20:29:32 +02:00
Ms2ger
91849cb603 Set the WebSocket's Sender from the ConnectionEstablishedTask.
This needs to happen off a task because we won't be able to access the
WebSocket object directly once this code moves to a background thread.

There is no behaviour change, because we make sure that self.ready_state is
not Connecting in Send().
2015-07-22 20:28:17 +02:00
Ms2ger
78df6e8d3e Remove the receiver field from WebSocket.
The receiver will be used from another thread than the WebSocket object in
the future.
2015-07-22 20:28:15 +02:00
Ms2ger
56c660d4de Split up WebSocketTaskHandler.
There's no real reason to have internal dynamic dispatch inside a trait
object.
2015-07-22 20:28:13 +02:00
Josh Matthews
d385cb701b Reject websocket protocol requests that don't match https://tools.ietf.org/html/rfc6455#section-4.1 . 2015-07-22 09:35:07 -04:00
Ms2ger
b467f3e9d6 Don't try to send a message in WebSocket#close if the sender isn't present. 2015-07-16 14:29:04 +02:00
Ms2ger
072fdf695b Handle Send correctly if readyState is not Open. 2015-07-16 12:43:10 +02:00
Ms2ger
cd741e681d Remove WebSocket::sendCloseFrame.
It is a field that is used a function argument. Given that the control flow
is not quite the same, and we can't add an argument to Send, I opted for a
separate function.
2015-07-16 12:43:08 +02:00
Ms2ger
6a61a5dcf5 Remove parse_web_socket_url in favour of functions in rust-websocket. 2015-07-15 11:26:49 +02:00
Ms2ger
48b94ec02b Throw an InvalidStateError from WebSocket#send when it is called too early. 2015-07-14 17:27:10 +02:00
Ms2ger
86e94786ae Stop panicking while establishing a WebSocket connection. 2015-07-14 16:01:59 +02:00
Bogdan Cuza
35d5328271 Fix #6379 2015-07-13 12:03:19 -04:00
Ms2ger
f93f49490f Replace WebSocketTask::Open by ConnectionEstablished. 2015-07-13 16:03:02 +02:00
Ms2ger
17bd7e5ec3 Remove some dead code from WebSockets. 2015-07-13 16:02:55 +02:00
Ms2ger
4c0c60a4d6 Return the parsed URL from WebSocket#url. 2015-07-13 14:21:18 +02:00
David Winslow
4cf46bff2d Refactor #[jstraceable] to #[derive(JSTraceable)]
fixes #6524
2015-07-01 18:27:06 -04:00