Auto merge of #6044 - Ms2ger:cleanup, r=jdm

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6044)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-05-14 07:16:42 -05:00
commit 7bda431e61
14 changed files with 80 additions and 54 deletions

View file

@ -37,6 +37,34 @@ impl WebGLPaintTask {
}) })
} }
pub fn handle_webgl_message(&self, message: CanvasWebGLMsg) {
match message {
CanvasWebGLMsg::AttachShader(program_id, shader_id) => self.attach_shader(program_id, shader_id),
CanvasWebGLMsg::BindBuffer(buffer_type, buffer_id) => self.bind_buffer(buffer_type, buffer_id),
CanvasWebGLMsg::BufferData(buffer_type, data, usage) => self.buffer_data(buffer_type, data, usage),
CanvasWebGLMsg::Clear(mask) => self.clear(mask),
CanvasWebGLMsg::ClearColor(r, g, b, a) => self.clear_color(r, g, b, a),
CanvasWebGLMsg::CreateBuffer(chan) => self.create_buffer(chan),
CanvasWebGLMsg::DrawArrays(mode, first, count) => self.draw_arrays(mode, first, count),
CanvasWebGLMsg::EnableVertexAttribArray(attrib_id) => self.enable_vertex_attrib_array(attrib_id),
CanvasWebGLMsg::GetAttribLocation(program_id, name, chan) => self.get_attrib_location(program_id, name, chan),
CanvasWebGLMsg::GetShaderInfoLog(shader_id, chan) => self.get_shader_info_log(shader_id, chan),
CanvasWebGLMsg::GetShaderParameter(shader_id, param_id, chan) => self.get_shader_parameter(shader_id, param_id, chan),
CanvasWebGLMsg::GetUniformLocation(program_id, name, chan) => self.get_uniform_location(program_id, name, chan),
CanvasWebGLMsg::CompileShader(shader_id) => self.compile_shader(shader_id),
CanvasWebGLMsg::CreateProgram(chan) => self.create_program(chan),
CanvasWebGLMsg::CreateShader(shader_type, chan) => self.create_shader(shader_type, chan),
CanvasWebGLMsg::LinkProgram(program_id) => self.link_program(program_id),
CanvasWebGLMsg::ShaderSource(shader_id, source) => self.shader_source(shader_id, source),
CanvasWebGLMsg::Uniform4fv(uniform_id, data) => self.uniform_4fv(uniform_id, data),
CanvasWebGLMsg::UseProgram(program_id) => self.use_program(program_id),
CanvasWebGLMsg::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset) => {
self.vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset);
},
CanvasWebGLMsg::Viewport(x, y, width, height) => self.viewport(x, y, width, height),
}
}
pub fn start(size: Size2D<i32>) -> Result<Sender<CanvasMsg>, &'static str> { pub fn start(size: Size2D<i32>) -> Result<Sender<CanvasMsg>, &'static str> {
let (chan, port) = channel::<CanvasMsg>(); let (chan, port) = channel::<CanvasMsg>();
let mut painter = try!(WebGLPaintTask::new(size)); let mut painter = try!(WebGLPaintTask::new(size));
@ -44,33 +72,7 @@ impl WebGLPaintTask {
painter.init(); painter.init();
loop { loop {
match port.recv().unwrap() { match port.recv().unwrap() {
CanvasMsg::WebGL(message) => { CanvasMsg::WebGL(message) => painter.handle_webgl_message(message),
match message {
CanvasWebGLMsg::AttachShader(program_id, shader_id) => painter.attach_shader(program_id, shader_id),
CanvasWebGLMsg::BindBuffer(buffer_type, buffer_id) => painter.bind_buffer(buffer_type, buffer_id),
CanvasWebGLMsg::BufferData(buffer_type, data, usage) => painter.buffer_data(buffer_type, data, usage),
CanvasWebGLMsg::Clear(mask) => painter.clear(mask),
CanvasWebGLMsg::ClearColor(r, g, b, a) => painter.clear_color(r, g, b, a),
CanvasWebGLMsg::CreateBuffer(chan) => painter.create_buffer(chan),
CanvasWebGLMsg::DrawArrays(mode, first, count) => painter.draw_arrays(mode, first, count),
CanvasWebGLMsg::EnableVertexAttribArray(attrib_id) => painter.enable_vertex_attrib_array(attrib_id),
CanvasWebGLMsg::GetAttribLocation(program_id, name, chan) => painter.get_attrib_location(program_id, name, chan),
CanvasWebGLMsg::GetShaderInfoLog(shader_id, chan) => painter.get_shader_info_log(shader_id, chan),
CanvasWebGLMsg::GetShaderParameter(shader_id, param_id, chan) => painter.get_shader_parameter(shader_id, param_id, chan),
CanvasWebGLMsg::GetUniformLocation(program_id, name, chan) => painter.get_uniform_location(program_id, name, chan),
CanvasWebGLMsg::CompileShader(shader_id) => painter.compile_shader(shader_id),
CanvasWebGLMsg::CreateProgram(chan) => painter.create_program(chan),
CanvasWebGLMsg::CreateShader(shader_type, chan) => painter.create_shader(shader_type, chan),
CanvasWebGLMsg::LinkProgram(program_id) => painter.link_program(program_id),
CanvasWebGLMsg::ShaderSource(shader_id, source) => painter.shader_source(shader_id, source),
CanvasWebGLMsg::Uniform4fv(uniform_id, data) => painter.uniform_4fv(uniform_id, data),
CanvasWebGLMsg::UseProgram(program_id) => painter.use_program(program_id),
CanvasWebGLMsg::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset) => {
painter.vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset);
},
CanvasWebGLMsg::Viewport(x, y, width, height) => painter.viewport(x, y, width, height),
}
},
CanvasMsg::Common(message) => { CanvasMsg::Common(message) => {
match message { match message {
CanvasCommonMsg::Close => break, CanvasCommonMsg::Close => break,

View file

@ -2,9 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js). //! Liberally derived from the [Firefox JS implementation]
/// Mediates interaction between the remote web console and equivalent functionality (object //! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js).
/// inspection, JS evaluation, autocompletion) in Servo. //! Mediates interaction between the remote web console and equivalent functionality (object
//! inspection, JS evaluation, autocompletion) in Servo.
use actor::{Actor, ActorRegistry}; use actor::{Actor, ActorRegistry};
use protocol::JsonPacketStream; use protocol::JsonPacketStream;

View file

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/inspector.js). //! Liberally derived from the [Firefox JS implementation]
//! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/inspector.js).
use devtools_traits::{DevtoolScriptControlMsg, NodeInfo}; use devtools_traits::{DevtoolScriptControlMsg, NodeInfo};
use devtools_traits::DevtoolScriptControlMsg::{GetRootNode, GetDocumentElement, GetChildren}; use devtools_traits::DevtoolScriptControlMsg::{GetRootNode, GetDocumentElement, GetChildren};
@ -461,12 +462,14 @@ impl Actor for PageStyleActor {
let auto_margins = msg.get(&"autoMargins".to_string()).unwrap().as_boolean().unwrap(); let auto_margins = msg.get(&"autoMargins".to_string()).unwrap().as_boolean().unwrap();
//TODO: the remaining layout properties (margin, border, padding, position) //TODO: the remaining layout properties (margin, border, padding, position)
// as specified in getLayout in http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js // as specified in getLayout in
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
let msg = GetLayoutReply { let msg = GetLayoutReply {
width: width.round() as i32, width: width.round() as i32,
height: height.round() as i32, height: height.round() as i32,
autoMargins: if auto_margins { autoMargins: if auto_margins {
//TODO: real values like processMargins in http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js //TODO: real values like processMargins in
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
let mut m = BTreeMap::new(); let mut m = BTreeMap::new();
m.insert("top".to_string(), "auto".to_string().to_json()); m.insert("top".to_string(), "auto".to_string().to_json());
m.insert("bottom".to_string(), "auto".to_string().to_json()); m.insert("bottom".to_string(), "auto".to_string().to_json());

View file

@ -2,8 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js). //! Liberally derived from the [Firefox JS implementation]
/// Handles interaction with the remote web console on network events (HTTP requests, responses) in Servo. //! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js).
//! Handles interaction with the remote web console on network events (HTTP requests, responses) in Servo.
extern crate hyper; extern crate hyper;

View file

@ -2,9 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webbrowser.js). //! Liberally derived from the [Firefox JS implementation]
/// Connection point for remote devtools that wish to investigate a particular tab's contents. //! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webbrowser.js).
/// Supports dynamic attaching and detaching which control notifications of navigation, etc. //! Connection point for remote devtools that wish to investigate a particular tab's contents.
//! Supports dynamic attaching and detaching which control notifications of navigation, etc.
use actor::{Actor, ActorRegistry}; use actor::{Actor, ActorRegistry};
use actors::console::ConsoleActor; use actors::console::ConsoleActor;

View file

@ -32,7 +32,7 @@ use std::u16;
use style::computed_values::{display, overflow_x, position, text_align, text_justify}; use style::computed_values::{display, overflow_x, position, text_align, text_justify};
use style::computed_values::{text_overflow, vertical_align, white_space}; use style::computed_values::{text_overflow, vertical_align, white_space};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use util::geometry::{Au, MAX_AU, ZERO_POINT, ZERO_RECT}; use util::geometry::{Au, MAX_AU, ZERO_RECT};
use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use util::range::{Range, RangeIndex}; use util::range::{Range, RangeIndex};
use util; use util;

View file

@ -260,7 +260,8 @@ pub enum MozBrowserEvent {
AsyncScroll, AsyncScroll,
/// Sent when window.close() is called within a browser <iframe>. /// Sent when window.close() is called within a browser <iframe>.
Close, Close,
/// Sent when a browser <iframe> tries to open a context menu. This allows handling <menuitem> element available within the browser <iframe>'s content. /// Sent when a browser <iframe> tries to open a context menu. This allows
/// handling <menuitem> element available within the browser <iframe>'s content.
ContextMenu, ContextMenu,
/// Sent when an error occurred while trying to load content within a browser <iframe>. /// Sent when an error occurred while trying to load content within a browser <iframe>.
Error, Error,

View file

@ -9,7 +9,8 @@ use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMet
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods; use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLFormElementDerived, NodeCast}; use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLFormElementDerived, NodeCast};
use dom::bindings::codegen::InheritTypes::{HTMLInputElementCast, HTMLTextAreaElementCast, HTMLFormElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLInputElementCast, HTMLTextAreaElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLFormElementCast, HTMLDataListElementCast};
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JSRef, OptionalRootable, Rootable, Temporary}; use dom::bindings::js::{JSRef, OptionalRootable, Rootable, Temporary};
use dom::document::{Document, DocumentHelpers}; use dom::document::{Document, DocumentHelpers};
@ -260,7 +261,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
return None; return None;
} }
if child.r().ancestors() if child.r().ancestors()
.any(|a| a.root().r().type_id() == NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLDataListElement))) { .any(|a| HTMLDataListElementCast::to_temporary(a).is_some()) {
return None; return None;
} }
// XXXManishearth don't include it if it is a button but not the submitter // XXXManishearth don't include it if it is a button but not the submitter

View file

@ -26,7 +26,9 @@ impl HTMLMediaElementDerived for EventTarget {
} }
impl HTMLMediaElement { impl HTMLMediaElement {
pub fn new_inherited(type_id: HTMLMediaElementTypeId, tag_name: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLMediaElement { pub fn new_inherited(type_id: HTMLMediaElementTypeId, tag_name: DOMString,
prefix: Option<DOMString>, document: JSRef<Document>)
-> HTMLMediaElement {
HTMLMediaElement { HTMLMediaElement {
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLMediaElement(type_id), tag_name, prefix, document) htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLMediaElement(type_id), tag_name, prefix, document)
} }

View file

@ -2234,13 +2234,18 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
match node.type_id() { match node.type_id() {
// Step 3. // Step 3.
NodeTypeId::DocumentType if !is_equal_doctype(this, node) => return false, NodeTypeId::DocumentType
NodeTypeId::Element(..) if !is_equal_element(this, node) => return false, if !is_equal_doctype(this, node) => return false,
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) if !is_equal_processinginstruction(this, node) => return false, NodeTypeId::Element(..)
if !is_equal_element(this, node) => return false,
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction)
if !is_equal_processinginstruction(this, node) => return false,
NodeTypeId::CharacterData(CharacterDataTypeId::Text) | NodeTypeId::CharacterData(CharacterDataTypeId::Text) |
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) if !is_equal_characterdata(this, node) => return false, NodeTypeId::CharacterData(CharacterDataTypeId::Comment)
if !is_equal_characterdata(this, node) => return false,
// Step 4. // Step 4.
NodeTypeId::Element(..) if !is_equal_element_attrs(this, node) => return false, NodeTypeId::Element(..)
if !is_equal_element_attrs(this, node) => return false,
_ => () _ => ()
} }

View file

@ -156,7 +156,8 @@ impl<'a> WebSocketMethods for JSRef<'a, WebSocket> {
fn Send(self, data: Option<DOMString>)-> Fallible<()>{ fn Send(self, data: Option<DOMString>)-> Fallible<()>{
/*TODO: This is not up to spec see http://html.spec.whatwg.org/multipage/comms.html search for "If argument is a string" /*TODO: This is not up to spec see http://html.spec.whatwg.org/multipage/comms.html search for "If argument is a string"
TODO: Need to buffer data TODO: Need to buffer data
TODO: bufferedAmount attribute returns the size of the buffer in bytes - this is a required attribute defined in the websocket.webidle file TODO: bufferedAmount attribute returns the size of the buffer in bytes -
this is a required attribute defined in the websocket.webidl file
TODO: The send function needs to flag when full by using the following TODO: The send function needs to flag when full by using the following
self.full.set(true). This needs to be done when the buffer is full self.full.set(true). This needs to be done when the buffer is full
*/ */

View file

@ -399,8 +399,12 @@ extern fn set_usage(window: *mut GonkNativeWindow,
println!("Setting usage flags to {}", usage); println!("Setting usage flags to {}", usage);
unsafe { unsafe {
(*window).usage = usage; (*window).usage = usage;
(*window).bufs[0] = Some(GonkNativeWindowBuffer::new((*window).alloc_dev, (*window).width, (*window).height, (*window).format, (*window).usage)); (*window).bufs[0] = Some(GonkNativeWindowBuffer::new(
(*window).bufs[1] = Some(GonkNativeWindowBuffer::new((*window).alloc_dev, (*window).width, (*window).height, (*window).format, (*window).usage)); (*window).alloc_dev, (*window).width, (*window).height,
(*window).format, (*window).usage));
(*window).bufs[1] = Some(GonkNativeWindowBuffer::new(
(*window).alloc_dev, (*window).width, (*window).height,
(*window).format, (*window).usage));
} }
0 0
} }

View file

@ -68,7 +68,7 @@ def check_license(contents):
def check_length(idx, line): def check_length(idx, line):
if len(line) >= 160: if len(line) >= 150:
yield (idx + 1, "(much) overlong line") yield (idx + 1, "(much) overlong line")
def check_whatwg_url(idx, line): def check_whatwg_url(idx, line):

View file

@ -70,12 +70,16 @@ fn base64() {
#[test] #[test]
fn base64_ct() { fn base64_ct() {
assert_parse("data:application/octet-stream;base64,C62+7w==", assert_parse("data:application/octet-stream;base64,C62+7w==",
Some(ContentType(Mime(TopLevel::Application, SubLevel::Ext("octet-stream".to_string()), vec!()))), None, Some(vec!(0x0B, 0xAD, 0xBE, 0xEF))); Some(ContentType(Mime(TopLevel::Application, SubLevel::Ext("octet-stream".to_string()), vec!()))),
None,
Some(vec!(0x0B, 0xAD, 0xBE, 0xEF)));
} }
#[test] #[test]
fn base64_charset() { fn base64_charset() {
assert_parse("data:text/plain;charset=koi8-r;base64,8PLl9+XkIO3l5Pfl5A==", assert_parse("data:text/plain;charset=koi8-r;base64,8PLl9+XkIO3l5Pfl5A==",
Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, vec!((Attr::Charset, Value::Ext("koi8-r".to_string())))))), Some("koi8-r".to_string()), Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain,
vec!((Attr::Charset, Value::Ext("koi8-r".to_string())))))),
Some("koi8-r".to_string()),
Some(vec!(0xF0, 0xF2, 0xE5, 0xF7, 0xE5, 0xE4, 0x20, 0xED, 0xE5, 0xE4, 0xF7, 0xE5, 0xE4))); Some(vec!(0xF0, 0xF2, 0xE5, 0xF7, 0xE5, 0xE4, 0x20, 0xED, 0xE5, 0xE4, 0xF7, 0xE5, 0xE4)));
} }