From 5c4d2d792801f58b3f1a567728e5fc95d2f7382f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 14 May 2015 13:09:13 +0200 Subject: [PATCH 1/5] Move handling of CanvasWebGLMsgs into WebGLPaintTask::handle_webgl_message. This clarifies the code flow in WebGLPaintTask::start a bit, and as a bonus, reduces the line lengths. --- components/canvas/webgl_paint_task.rs | 56 ++++++++++++++------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/components/canvas/webgl_paint_task.rs b/components/canvas/webgl_paint_task.rs index 806440db36b..155cbde2297 100644 --- a/components/canvas/webgl_paint_task.rs +++ b/components/canvas/webgl_paint_task.rs @@ -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) -> Result, &'static str> { let (chan, port) = channel::(); let mut painter = try!(WebGLPaintTask::new(size)); @@ -44,33 +72,7 @@ impl WebGLPaintTask { painter.init(); loop { match port.recv().unwrap() { - CanvasMsg::WebGL(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::WebGL(message) => painter.handle_webgl_message(message), CanvasMsg::Common(message) => { match message { CanvasCommonMsg::Close => break, From 422b6bd223b1bf887b7a87ff744bd4bae89e237c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 14 May 2015 13:10:40 +0200 Subject: [PATCH 2/5] Fix comments in devtools. In particular, use the right kind of documentation comments. --- components/devtools/actors/console.rs | 7 ++++--- components/devtools/actors/inspector.rs | 9 ++++++--- components/devtools/actors/network_event.rs | 5 +++-- components/devtools/actors/tab.rs | 7 ++++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs index 834ccc99235..bef7e456a49 100644 --- a/components/devtools/actors/console.rs +++ b/components/devtools/actors/console.rs @@ -2,9 +2,10 @@ * 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/. */ -/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js). -/// Mediates interaction between the remote web console and equivalent functionality (object -/// inspection, JS evaluation, autocompletion) in Servo. +//! Liberally derived from the [Firefox JS implementation] +//! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js). +//! Mediates interaction between the remote web console and equivalent functionality (object +//! inspection, JS evaluation, autocompletion) in Servo. use actor::{Actor, ActorRegistry}; use protocol::JsonPacketStream; diff --git a/components/devtools/actors/inspector.rs b/components/devtools/actors/inspector.rs index 3dbaf5c6d43..35025a9c21b 100644 --- a/components/devtools/actors/inspector.rs +++ b/components/devtools/actors/inspector.rs @@ -2,7 +2,8 @@ * 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/. */ -/// 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::{GetRootNode, GetDocumentElement, GetChildren}; @@ -461,12 +462,14 @@ impl Actor for PageStyleActor { let auto_margins = msg.get(&"autoMargins".to_string()).unwrap().as_boolean().unwrap(); //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 { width: width.round() as i32, height: height.round() as i32, 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(); m.insert("top".to_string(), "auto".to_string().to_json()); m.insert("bottom".to_string(), "auto".to_string().to_json()); diff --git a/components/devtools/actors/network_event.rs b/components/devtools/actors/network_event.rs index 28a6acc18f0..9a741913cdd 100644 --- a/components/devtools/actors/network_event.rs +++ b/components/devtools/actors/network_event.rs @@ -2,8 +2,9 @@ * 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/. */ -/// Liberally derived from the [Firefox JS implementation](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. +//! Liberally derived from the [Firefox JS implementation] +//! (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; diff --git a/components/devtools/actors/tab.rs b/components/devtools/actors/tab.rs index 7450ae45143..4a157edd692 100644 --- a/components/devtools/actors/tab.rs +++ b/components/devtools/actors/tab.rs @@ -2,9 +2,10 @@ * 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/. */ -/// Liberally derived from the [Firefox JS implementation](http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webbrowser.js). -/// 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. +//! Liberally derived from the [Firefox JS implementation] +//! (http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webbrowser.js). +//! 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 actors::console::ConsoleActor; From db61c54858e0c9c308b25f0a82e4d5991602498f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 14 May 2015 13:10:56 +0200 Subject: [PATCH 3/5] Remove an unused import. --- components/layout/inline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 5b65fc49ce1..9625787f019 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -32,7 +32,7 @@ use std::u16; use style::computed_values::{display, overflow_x, position, text_align, text_justify}; use style::computed_values::{text_overflow, vertical_align, white_space}; 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::range::{Range, RangeIndex}; use util; From 40a91d6227a8ee89b6278758ebebb53625535e0d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 14 May 2015 13:11:49 +0200 Subject: [PATCH 4/5] Use HTMLDataListElementCast in HTMLFormElement. --- components/script/dom/htmlformelement.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index c5c1ae2e77a..f926b521f5c 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -9,7 +9,8 @@ use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMet use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods; 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::js::{JSRef, OptionalRootable, Rootable, Temporary}; use dom::document::{Document, DocumentHelpers}; @@ -260,7 +261,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> { return None; } 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; } // XXXManishearth don't include it if it is a button but not the submitter From d84c3e7a303c5582cd240be637574067bd5cac91 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 14 May 2015 13:26:13 +0200 Subject: [PATCH 5/5] Fix some overlong lines. --- components/msg/constellation_msg.rs | 3 ++- components/script/dom/htmlmediaelement.rs | 4 +++- components/script/dom/node.rs | 15 ++++++++++----- components/script/dom/websocket.rs | 3 ++- ports/gonk/src/window.rs | 8 ++++++-- python/tidy.py | 2 +- tests/unit/net/data_loader.rs | 8 ++++++-- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index a147842db25..d60f45b8b0e 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -262,7 +262,8 @@ pub enum MozBrowserEvent { AsyncScroll, /// Sent when window.close() is called within a browser