Skip to content

Commit

Permalink
# This is a combination of 39 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

resolved merge conflict

# This is the commit message servo#2:

style(capture_webrender): use eprintln for error output

# This is the commit message servo#3:

Fix some more WebGL methods

# This is the commit message servo#4:

Implement OES_element_index_uint (fixes servo#20384)

# This is the commit message servo#5:

Use mozjs 0.4

# This is the commit message servo#6:

Add safe `handle` function for rooted heap values

# This is the commit message servo#7:

Use unsafe Heap::handle wherever needed

# This is the commit message servo#8:

Change WebGL function signatures accepting typed arrays

# This is the commit message servo#9:

Adapt function bodies for usage with typed array args

# This is the commit message servo#10:

Adapt uniform[fv] and similar to accept typed array args

# This is the commit message servo#11:

Appease test-tidy

# This is the commit message servo#12:

Fix sanity check in vertex attrib

# This is the commit message servo#13:

Fix indentation

# This is the commit message servo#14:

Unify argument auto rooting in codegen

# This is the commit message servo#15:

Add codegen test for function overloads taking typed array args

# This is the commit message servo#16:

Use safe to_vec() for typed arrays in WebGL bindings

# This is the commit message servo#17:

Bug 1448138 - Rename string DataFlags::SHARED to REFCOUNTED to make it clearer to those reading the code.  (Servo changes.)  r=erahm

# This is the commit message servo#18:

Used the zip function to iterate over both vectors simultaneously instead of an
index variable and unwrapping the result.

# This is the commit message servo#19:

Implement HTMLCanvasElement.toDataURL for WebGL canvas (fixes servo#19147)

# This is the commit message servo#20:

Update web-platform-tests to revision d04a8fc02b85bd32799691759c8c05ead07cd939

# This is the commit message servo#21:

Implement missing checks in WebGLRenderingContext::GetBufferParameter

# This is the commit message servo#22:

Implement WebGLRenderingContextBase.getAttachedShaders

# This is the commit message servo#23:

Implement missing WebGLShader checks

Methods compileShader and getShaderParameter should emit an error when
the shader has been deleted.

# This is the commit message servo#24:

Add constructors for typed arrays in DOMMatrix and DOMMatrixReadOnly

# This is the commit message servo#25:

feat(webidl): expose arraybuffer overload in body idl

# This is the commit message servo#26:

feat(consume_body): implement consume_body accepts arraybuffer

# This is the commit message servo#27:

refactor(consume_body): json stored in roottraceablebox

# This is the commit message servo#28:

test(wpt): update fetch test metadata

# This is the commit message servo#29:

Implement gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE)

# This is the commit message servo#30:

TextDecoder's Decode now receives a BufferSource as input

# This is the commit message servo#31:

Update mozjs.

# This is the commit message servo#32:

Switches WriteValue to use BufferSource

# This is the commit message servo#33:

Switches characteristic to use BufferSource

# This is the commit message servo#34:

Updates Bluetooth type to use BufferSource

# This is the commit message servo#35:

Websockets send typed arrays now

# This is the commit message servo#36:

Dedupe lazy_static

:tada: :tada: :tada:

# This is the commit message servo#37:

Statically allocate static atoms.

# This is the commit message servo#38:

Update web-platform-tests to revision d04a8fc02b85bd32799691759c8c05ead07cd939

# This is the commit message servo#39:

refactor(websocket): do not borrow sender anymore
  • Loading branch information
pmocher committed Mar 30, 2018
1 parent 873edca commit f9b7c03
Show file tree
Hide file tree
Showing 342 changed files with 4,024 additions and 3,818 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Servo.app
.config.mk.last
/glfw
capture_webrender/
/components/compositing/webrender_revision.rs

# Editors

Expand Down
72 changes: 33 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/canvas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ compositing = {path = "../compositing"}
cssparser = "0.23.0"
euclid = "0.17"
fnv = "1.0"
gleam = "0.4"
gleam = "0.4.29"
ipc-channel = "0.10"
log = "0.3.5"
num-traits = "0.1.32"
Expand Down
3 changes: 3 additions & 0 deletions components/canvas/webgl_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,9 @@ impl WebGLImpl {
ctx.gl().delete_vertex_arrays(&[id.get()]),
WebGLCommand::BindVertexArray(id) =>
ctx.gl().bind_vertex_array(id.map_or(0, WebGLVertexArrayId::get)),
WebGLCommand::AliasedPointSizeRange(sender) => {
sender.send(ctx.gl().alias_point_size_range()).unwrap()
}
}

// TODO: update test expectations in order to enable debug assertions
Expand Down
4 changes: 3 additions & 1 deletion components/canvas_traits/webgl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ pub enum WebGLCommand {
CreateVertexArray(WebGLSender<Option<WebGLVertexArrayId>>),
DeleteVertexArray(WebGLVertexArrayId),
BindVertexArray(Option<WebGLVertexArrayId>),
AliasedPointSizeRange(WebGLSender<(f32, f32)>),
}

macro_rules! define_resource_id_struct {
Expand Down Expand Up @@ -546,7 +547,8 @@ impl fmt::Debug for WebGLCommand {
GenerateMipmap(..) => "GenerateMipmap",
CreateVertexArray(..) => "CreateVertexArray",
DeleteVertexArray(..) => "DeleteVertexArray",
BindVertexArray(..) => "BindVertexArray"
BindVertexArray(..) => "BindVertexArray",
AliasedPointSizeRange(..) => "AliasedPointSizeRange",
};

write!(f, "CanvasWebGLMsg::{}(..)", name)
Expand Down
2 changes: 1 addition & 1 deletion components/compositing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ path = "lib.rs"
[dependencies]
euclid = "0.17"
gfx_traits = {path = "../gfx_traits"}
gleam = "0.4"
gleam = "0.4.29"
image = "0.18"
ipc-channel = "0.10"
libc = "0.2"
Expand Down
29 changes: 4 additions & 25 deletions components/compositing/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,11 @@ extern crate toml;
use std::env;
use std::fs::File;
use std::io::{Read, Write};

const WEBRENDER_REVISION_TEMPLATE: &'static str =
"/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http:https://mozilla.org/MPL/2.0/. */
/// auto-generated by cargo. do not manually modify.
pub const REVISION: &'static str = ";
use std::path::Path;

fn main() {
let current_path = env::current_dir().expect("Failed to access path to lockfile");
let lockfile_path = current_path.join("..").join("..").join("Cargo.lock");
let revision_file_path = current_path.join("webrender_revision.rs");

let mut existing_revision_exported = String::new();
match File::open(&revision_file_path) {
Ok(mut f) => {
f.read_to_string(&mut existing_revision_exported).unwrap_or_default();
},
Err(_) => ()
}
let lockfile_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("..").join("..").join("Cargo.lock");
let revision_file_path = Path::new(&env::var_os("OUT_DIR").unwrap()).join("webrender_revision.rs");

let mut lockfile = String::new();
File::open(lockfile_path).expect("Cannot open lockfile")
Expand All @@ -49,13 +33,8 @@ fn main() {
let parsed: Vec<&str> = source.split("#").collect();
let revision = if parsed.len() > 1 { parsed[1] } else { source };

if let Some(_) = existing_revision_exported.find(revision) {
return
}

let revision_contents = format!("{}\"{}\";", WEBRENDER_REVISION_TEMPLATE, revision);
let mut revision_module_file = File::create(&revision_file_path).unwrap();
write!(&mut revision_module_file, "{}", revision_contents).unwrap();
write!(&mut revision_module_file, "{}", format!("\"{}\"", revision)).unwrap();
},
_ => panic!("Cannot find package definitions in lockfile")
}
Expand Down
11 changes: 6 additions & 5 deletions components/compositing/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,22 +1547,23 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let revision_file_path = capture_path.join("wr.txt");

if let Err(err) = create_dir_all(&capture_path) {
println!("Unable to create path '{:?}' for capture: {:?}", capture_path, err);
eprintln!("Unable to create path '{:?}' for capture: {:?}", capture_path, err);
return
}

self.webrender_api.save_capture(capture_path, webrender_api::CaptureBits::all());

match File::create(revision_file_path) {
Ok(mut file) => {
if let Err(err) = write!(&mut file, "{}", REVISION) {
println!("Unable to write webrender revision: {:?}", err)
let revision = include!(concat!(env!("OUT_DIR"), "/webrender_revision.rs"));
if let Err(err) = write!(&mut file, "{}", revision) {
eprintln!("Unable to write webrender revision: {:?}", err)
}
}
Err(err) => println!("Capture triggered, creating webrender revision info skipped: {:?}", err)
Err(err) => eprintln!("Capture triggered, creating webrender revision info skipped: {:?}", err)
}
},
Err(err) => println!("Unable to locate path to save captures: {:?}", err)
Err(err) => eprintln!("Unable to locate path to save captures: {:?}", err)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion components/compositing/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use style_traits::CSSPixel;
mod compositor;
pub mod compositor_thread;
mod touch;
mod webrender_revision;
pub mod windowing;

pub struct SendableFrameTree {
Expand Down
2 changes: 1 addition & 1 deletion components/malloc_size_of/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ app_units = "0.6"
cssparser = "0.23.0"
euclid = "0.17"
hashglobe = { path = "../hashglobe" }
mozjs = { version = "0.3", features = ["promises"], optional = true }
mozjs = { version = "0.4", features = ["promises"], optional = true }
selectors = { path = "../selectors" }
servo_arc = { path = "../servo_arc" }
smallbitvec = "1.0.3"
Expand Down
9 changes: 3 additions & 6 deletions components/net/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ pub type Connector = HttpsConnector;

pub fn create_ssl_client(ca_file: &PathBuf) -> OpensslClient {
let mut ssl_connector_builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap();
{
let context = ssl_connector_builder.builder_mut();
context.set_ca_file(ca_file).expect("could not set CA file");
context.set_cipher_list(DEFAULT_CIPHERS).expect("could not set ciphers");
context.set_options(SSL_OP_NO_SSLV2 | SSL_OP_NO_SSLV3 | SSL_OP_NO_COMPRESSION);
}
ssl_connector_builder.set_ca_file(ca_file).expect("could not set CA file");
ssl_connector_builder.set_cipher_list(DEFAULT_CIPHERS).expect("could not set ciphers");
ssl_connector_builder.set_options(SSL_OP_NO_SSLV2 | SSL_OP_NO_SSLV3 | SSL_OP_NO_COMPRESSION);
let ssl_connector = ssl_connector_builder.build();
OpensslClient::from(ssl_connector)
}
Expand Down
4 changes: 2 additions & 2 deletions components/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ domobject_derive = {path = "../domobject_derive"}
encoding_rs = "0.7"
euclid = "0.17"
fnv = "1.0"
gleam = "0.4"
gleam = "0.4.29"
half = "1.0"
html5ever = "0.22"
hyper = "0.10"
Expand All @@ -62,7 +62,7 @@ metrics = {path = "../metrics"}
mitochondria = "1.1.2"
mime = "0.2.1"
mime_guess = "1.8.0"
mozjs = { version = "0.3", features = ["promises"]}
mozjs = { version = "0.4", features = ["promises"]}
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
num-traits = "0.1.32"
Expand Down
29 changes: 26 additions & 3 deletions components/script/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ use dom::bindings::error::{Error, Fallible};
use dom::bindings::reflector::DomObject;
use dom::bindings::root::DomRoot;
use dom::bindings::str::USVString;
use dom::bindings::trace::RootedTraceableBox;
use dom::blob::{Blob, BlobImpl};
use dom::formdata::FormData;
use dom::globalscope::GlobalScope;
use dom::promise::Promise;
use js::jsapi::Heap;
use js::jsapi::JSContext;
use js::jsapi::JSObject;
use js::jsapi::JS_ClearPendingException;
use js::jsapi::JS_ParseJSON;
use js::jsapi::Value as JSValue;
use js::jsval::UndefinedValue;
use js::typedarray::{ArrayBuffer, CreateWith};
use mime::{Mime, TopLevel, SubLevel};
use std::cell::Ref;
use std::ptr;
use std::rc::Rc;
use std::str;
use url::form_urlencoded;
Expand All @@ -27,14 +32,16 @@ pub enum BodyType {
Blob,
FormData,
Json,
Text
Text,
ArrayBuffer
}

pub enum FetchedData {
Text(String),
Json(JSValue),
Json(RootedTraceableBox<Heap<JSValue>>),
BlobData(DomRoot<Blob>),
FormData(DomRoot<FormData>),
ArrayBuffer(RootedTraceableBox<Heap<*mut JSObject>>),
}

// https://fetch.spec.whatwg.org/#concept-body-consume-body
Expand Down Expand Up @@ -83,6 +90,7 @@ pub fn consume_body_with_promise<T: BodyOperations + DomObject>(object: &T,
FetchedData::Json(j) => promise.resolve_native(&j),
FetchedData::BlobData(b) => promise.resolve_native(&b),
FetchedData::FormData(f) => promise.resolve_native(&f),
FetchedData::ArrayBuffer(a) => promise.resolve_native(&a)
};
},
Err(err) => promise.reject_error(err),
Expand All @@ -104,6 +112,9 @@ fn run_package_data_algorithm<T: BodyOperations + DomObject>(object: &T,
BodyType::Json => run_json_data_algorithm(cx, bytes),
BodyType::Blob => run_blob_data_algorithm(&global, bytes, mime),
BodyType::FormData => run_form_data_algorithm(&global, bytes, mime),
BodyType::ArrayBuffer => unsafe {
run_array_buffer_data_algorithm(cx, bytes)
}
}
}

Expand All @@ -126,7 +137,8 @@ fn run_json_data_algorithm(cx: *mut JSContext,
// TODO: See issue #13464. Exception should be thrown instead of cleared.
return Err(Error::Type("Failed to parse JSON".to_string()));
}
Ok(FetchedData::Json(rval.get()))
let rooted_heap = RootedTraceableBox::from_box(Heap::boxed(rval.get()));
Ok(FetchedData::Json(rooted_heap))
}
}

Expand Down Expand Up @@ -166,6 +178,17 @@ fn run_form_data_algorithm(root: &GlobalScope, bytes: Vec<u8>, mime: &[u8]) -> F
}
}

#[allow(unsafe_code)]
unsafe fn run_array_buffer_data_algorithm(cx: *mut JSContext, bytes: Vec<u8>) -> Fallible<FetchedData> {
rooted!(in(cx) let mut array_buffer_ptr = ptr::null_mut::<JSObject>());
let arraybuffer = ArrayBuffer::create(cx, CreateWith::Slice(&bytes), array_buffer_ptr.handle_mut());
if arraybuffer.is_err() {
return Err(Error::JSFailed);
}
let rooted_heap = RootedTraceableBox::from_box(Heap::boxed(array_buffer_ptr.get()));
Ok(FetchedData::ArrayBuffer(rooted_heap))
}

pub trait BodyOperations {
fn get_body_used(&self) -> bool;
fn set_body_promise(&self, p: &Rc<Promise>, body_type: BodyType);
Expand Down
15 changes: 8 additions & 7 deletions components/script/dom/bindings/codegen/CodegenRust.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def pickFirstSignature(condition, filterLambda):
template,
{"val": distinguishingArg},
declType,
"arg%d" % distinguishingIndex)
"arg%d" % distinguishingIndex,
needsAutoRoot=type_needs_auto_root(type))

# Indent by 4, since we need to indent further than our "do" statement
caseBody.append(CGIndenter(testCode, 4))
Expand Down Expand Up @@ -1211,7 +1212,8 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,


def instantiateJSToNativeConversionTemplate(templateBody, replacements,
declType, declName):
declType, declName,
needsAutoRoot=False):
"""
Take the templateBody and declType as returned by
getJSToNativeConversionInfo, a set of replacements as required by the
Expand All @@ -1236,6 +1238,8 @@ def instantiateJSToNativeConversionTemplate(templateBody, replacements,
else:
result.append(conversion)

if needsAutoRoot:
result.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (declName, declName)))
# Add an empty CGGeneric to get an extra newline after the argument
# conversion.
result.append(CGGeneric(""))
Expand Down Expand Up @@ -1318,11 +1322,8 @@ def __init__(self, argument, index, args, argc, descriptorProvider,
arg = "arg%d" % index

self.converter = instantiateJSToNativeConversionTemplate(
template, replacementVariables, declType, arg)

# The auto rooting is done only after the conversion is performed
if type_needs_auto_root(argument.type):
self.converter.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (arg, arg)))
template, replacementVariables, declType, arg,
needsAutoRoot=type_needs_auto_root(argument.type))

else:
assert argument.optional
Expand Down
3 changes: 2 additions & 1 deletion components/script/dom/bindings/reflector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ impl Reflector {
/// Get the reflector.
#[inline]
pub fn get_jsobject(&self) -> HandleObject {
self.object.handle()
// We're rooted, so it's safe to hand out a handle to object in Heap
unsafe { self.object.handle() }
}

/// Initialize the reflector. (May be called only once.)
Expand Down
14 changes: 12 additions & 2 deletions components/script/dom/bindings/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ use hyper::mime::Mime;
use hyper::status::StatusCode;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use js::glue::{CallObjectTracer, CallValueTracer};
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
use js::jsapi::{GCTraceKindToAscii, Heap, Handle, JSObject, JSTracer, TraceKind};
use js::jsval::JSVal;
use js::rust::Runtime;
use js::rust::{GCMethods, Runtime};
use js::typedarray::TypedArray;
use js::typedarray::TypedArrayElement;
use metrics::{InteractiveMetrics, InteractiveWindow};
Expand Down Expand Up @@ -790,6 +790,16 @@ impl<T: JSTraceable + 'static> RootedTraceableBox<T> {
}
}

impl<T> RootedTraceableBox<Heap<T>>
where
Heap<T>: JSTraceable + 'static,
T: GCMethods + Copy,
{
pub fn handle(&self) -> Handle<T> {
unsafe { (*self.ptr).handle() }
}
}

impl<T: JSTraceable + Default> Default for RootedTraceableBox<T> {
fn default() -> RootedTraceableBox<T> {
RootedTraceableBox::new(T::default())
Expand Down
14 changes: 11 additions & 3 deletions components/script/dom/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::Bluetoot
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerBinding::
BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, PermissionState};
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
use dom::bindings::codegen::UnionTypes::{ArrayBufferViewOrArrayBuffer, StringOrUnsignedLong};
use dom::bindings::error::Error::{self, Network, Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
Expand Down Expand Up @@ -442,12 +442,20 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdatafilterinit-canonicalizing
fn canonicalize_bluetooth_data_filter_init(bdfi: &BluetoothDataFilterInit) -> Fallible<(Vec<u8>, Vec<u8>)> {
// Step 1.
let data_prefix = bdfi.dataPrefix.clone().unwrap_or(vec![]);
let data_prefix = match bdfi.dataPrefix {
Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(),
Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(),
None => vec![]
};

// Step 2.
// If no mask present, mask will be a sequence of 0xFF bytes the same length as dataPrefix.
// Masking dataPrefix with this, leaves dataPrefix untouched.
let mask = bdfi.mask.clone().unwrap_or(vec![0xFF; data_prefix.len()]);
let mask = match bdfi.mask {
Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(),
Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(),
None => vec![0xFF; data_prefix.len()]
};

// Step 3.
if mask.len() != data_prefix.len() {
Expand Down
Loading

0 comments on commit f9b7c03

Please sign in to comment.