mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #22126 - pyfisch:autoformat, r=jdm
Enforce rustfmt on CI <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22126) <!-- Reviewable:end -->
This commit is contained in:
commit
da2d9b2228
609 changed files with 7934 additions and 5334 deletions
|
@ -4,6 +4,9 @@ matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- sudo: false
|
- sudo: false
|
||||||
|
before_install:
|
||||||
|
- curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y
|
||||||
|
- source ~/.profile
|
||||||
script:
|
script:
|
||||||
- ./mach test-tidy --no-progress --all
|
- ./mach test-tidy --no-progress --all
|
||||||
- ./mach test-tidy --no-progress --self-test
|
- ./mach test-tidy --no-progress --self-test
|
||||||
|
|
|
@ -23,38 +23,30 @@ mod platform {
|
||||||
|
|
||||||
/// Memory allocation APIs compatible with libc
|
/// Memory allocation APIs compatible with libc
|
||||||
pub mod libc_compat {
|
pub mod libc_compat {
|
||||||
pub use super::ffi::{malloc, realloc, free};
|
pub use super::ffi::{free, malloc, realloc};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Allocator;
|
pub struct Allocator;
|
||||||
|
|
||||||
// The minimum alignment guaranteed by the architecture. This value is used to
|
// The minimum alignment guaranteed by the architecture. This value is used to
|
||||||
// add fast paths for low alignment values.
|
// add fast paths for low alignment values.
|
||||||
#[cfg(
|
#[cfg(all(any(
|
||||||
all(
|
target_arch = "arm",
|
||||||
any(
|
target_arch = "mips",
|
||||||
target_arch = "arm",
|
target_arch = "mipsel",
|
||||||
target_arch = "mips",
|
target_arch = "powerpc"
|
||||||
target_arch = "mipsel",
|
)))]
|
||||||
target_arch = "powerpc"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)]
|
|
||||||
const MIN_ALIGN: usize = 8;
|
const MIN_ALIGN: usize = 8;
|
||||||
#[cfg(
|
#[cfg(all(any(
|
||||||
all(
|
target_arch = "x86",
|
||||||
any(
|
target_arch = "x86_64",
|
||||||
target_arch = "x86",
|
target_arch = "aarch64",
|
||||||
target_arch = "x86_64",
|
target_arch = "powerpc64",
|
||||||
target_arch = "aarch64",
|
target_arch = "powerpc64le",
|
||||||
target_arch = "powerpc64",
|
target_arch = "mips64",
|
||||||
target_arch = "powerpc64le",
|
target_arch = "s390x",
|
||||||
target_arch = "mips64",
|
target_arch = "sparc64"
|
||||||
target_arch = "s390x",
|
)))]
|
||||||
target_arch = "sparc64"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)]
|
|
||||||
const MIN_ALIGN: usize = 16;
|
const MIN_ALIGN: usize = 16;
|
||||||
|
|
||||||
fn layout_to_flags(align: usize, size: usize) -> c_int {
|
fn layout_to_flags(align: usize, size: usize) -> c_int {
|
||||||
|
@ -106,8 +98,8 @@ mod platform {
|
||||||
mod platform {
|
mod platform {
|
||||||
extern crate kernel32;
|
extern crate kernel32;
|
||||||
|
|
||||||
pub use std::alloc::System as Allocator;
|
|
||||||
use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate};
|
use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate};
|
||||||
|
pub use std::alloc::System as Allocator;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
/// Get the size of a heap block.
|
/// Get the size of a heap block.
|
||||||
|
|
|
@ -6,7 +6,7 @@ extern crate string_cache_codegen;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufReader, BufRead};
|
use std::io::{BufRead, BufReader};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -16,11 +16,13 @@ extern crate uuid;
|
||||||
|
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
|
use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
|
||||||
|
use bluetooth_traits::scanfilter::{
|
||||||
|
BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions,
|
||||||
|
};
|
||||||
use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg, BluetoothServiceMsg};
|
use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg, BluetoothServiceMsg};
|
||||||
use bluetooth_traits::{BluetoothDeviceMsg, BluetoothRequest, BluetoothResponse, GATTType};
|
use bluetooth_traits::{BluetoothDeviceMsg, BluetoothRequest, BluetoothResponse, GATTType};
|
||||||
use bluetooth_traits::{BluetoothError, BluetoothResponseResult, BluetoothResult};
|
use bluetooth_traits::{BluetoothError, BluetoothResponseResult, BluetoothResult};
|
||||||
use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
|
|
||||||
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions};
|
|
||||||
use device::bluetooth::{BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic};
|
use device::bluetooth::{BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic};
|
||||||
use device::bluetooth::{BluetoothGATTDescriptor, BluetoothGATTService};
|
use device::bluetooth::{BluetoothGATTDescriptor, BluetoothGATTService};
|
||||||
use embedder_traits::{EmbedderMsg, EmbedderProxy};
|
use embedder_traits::{EmbedderMsg, EmbedderProxy};
|
||||||
|
@ -74,7 +76,8 @@ impl BluetoothThreadFactory for IpcSender<BluetoothRequest> {
|
||||||
BluetoothAdapter::init()
|
BluetoothAdapter::init()
|
||||||
} else {
|
} else {
|
||||||
BluetoothAdapter::init_mock()
|
BluetoothAdapter::init_mock()
|
||||||
}.ok();
|
}
|
||||||
|
.ok();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("BluetoothThread".to_owned())
|
.name("BluetoothThread".to_owned())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
@ -465,8 +468,10 @@ impl BluetoothManager {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.retain(|s| {
|
services.retain(|s| {
|
||||||
!uuid_is_blocklisted(&s.get_uuid().unwrap_or(String::new()), Blocklist::All) &&
|
!uuid_is_blocklisted(&s.get_uuid().unwrap_or(String::new()), Blocklist::All) && self
|
||||||
self.allowed_services.get(device_id).map_or(false, |uuids| {
|
.allowed_services
|
||||||
|
.get(device_id)
|
||||||
|
.map_or(false, |uuids| {
|
||||||
uuids.contains(&s.get_uuid().unwrap_or(String::new()))
|
uuids.contains(&s.get_uuid().unwrap_or(String::new()))
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -556,9 +561,9 @@ impl BluetoothManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn characteristic_is_cached(&self, characteristic_id: &str) -> bool {
|
fn characteristic_is_cached(&self, characteristic_id: &str) -> bool {
|
||||||
self.cached_characteristics.contains_key(characteristic_id) &&
|
self.cached_characteristics.contains_key(characteristic_id) && self
|
||||||
self.characteristic_to_service
|
.characteristic_to_service
|
||||||
.contains_key(characteristic_id)
|
.contains_key(characteristic_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptor
|
// Descriptor
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
|
|
||||||
use crate::BluetoothManager;
|
use crate::BluetoothManager;
|
||||||
use device::bluetooth::{BluetoothAdapter, BluetoothDevice};
|
use device::bluetooth::{BluetoothAdapter, BluetoothDevice};
|
||||||
use device::bluetooth::{BluetoothGATTCharacteristic, BluetoothGATTDescriptor, BluetoothGATTService};
|
use device::bluetooth::{
|
||||||
|
BluetoothGATTCharacteristic, BluetoothGATTDescriptor, BluetoothGATTService,
|
||||||
|
};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::{HashSet, HashMap};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -294,14 +296,16 @@ fn create_generic_access_service(
|
||||||
NUMBER_OF_DIGITALS_UUID.to_owned(),
|
NUMBER_OF_DIGITALS_UUID.to_owned(),
|
||||||
vec![49],
|
vec![49],
|
||||||
)?;
|
)?;
|
||||||
number_of_digitals_descriptor_1.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;
|
number_of_digitals_descriptor_1
|
||||||
|
.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;
|
||||||
|
|
||||||
let number_of_digitals_descriptor_2 = create_descriptor_with_value(
|
let number_of_digitals_descriptor_2 = create_descriptor_with_value(
|
||||||
&device_name_characteristic,
|
&device_name_characteristic,
|
||||||
NUMBER_OF_DIGITALS_UUID.to_owned(),
|
NUMBER_OF_DIGITALS_UUID.to_owned(),
|
||||||
vec![50],
|
vec![50],
|
||||||
)?;
|
)?;
|
||||||
number_of_digitals_descriptor_2.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;
|
number_of_digitals_descriptor_2
|
||||||
|
.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;
|
||||||
|
|
||||||
// Characteristic User Description Descriptor
|
// Characteristic User Description Descriptor
|
||||||
let _characteristic_user_description = create_descriptor_with_value(
|
let _characteristic_user_description = create_descriptor_with_value(
|
||||||
|
|
|
@ -3,14 +3,16 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use azure::azure::AzFloat;
|
use azure::azure::AzFloat;
|
||||||
|
use azure::azure_hl::SurfacePattern;
|
||||||
use azure::azure_hl::{AntialiasMode, CapStyle, CompositionOp, JoinStyle};
|
use azure::azure_hl::{AntialiasMode, CapStyle, CompositionOp, JoinStyle};
|
||||||
use azure::azure_hl::{BackendType, DrawOptions, DrawTarget, Pattern, StrokeOptions, SurfaceFormat};
|
use azure::azure_hl::{
|
||||||
|
BackendType, DrawOptions, DrawTarget, Pattern, StrokeOptions, SurfaceFormat,
|
||||||
|
};
|
||||||
use azure::azure_hl::{Color, ColorPattern, DrawSurfaceOptions, Filter, PathBuilder};
|
use azure::azure_hl::{Color, ColorPattern, DrawSurfaceOptions, Filter, PathBuilder};
|
||||||
use azure::azure_hl::{ExtendMode, GradientStop, LinearGradientPattern, RadialGradientPattern};
|
use azure::azure_hl::{ExtendMode, GradientStop, LinearGradientPattern, RadialGradientPattern};
|
||||||
use azure::azure_hl::SurfacePattern;
|
|
||||||
use canvas_traits::canvas::*;
|
use canvas_traits::canvas::*;
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D};
|
use euclid::{Point2D, Rect, Size2D, Transform2D, Vector2D};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use num_traits::ToPrimitive;
|
use num_traits::ToPrimitive;
|
||||||
use pixels;
|
use pixels;
|
||||||
|
@ -39,7 +41,7 @@ impl<'a> CanvasData<'a> {
|
||||||
size: Size2D<u32>,
|
size: Size2D<u32>,
|
||||||
webrender_api_sender: webrender_api::RenderApiSender,
|
webrender_api_sender: webrender_api::RenderApiSender,
|
||||||
antialias: AntialiasMode,
|
antialias: AntialiasMode,
|
||||||
canvas_id: CanvasId
|
canvas_id: CanvasId,
|
||||||
) -> CanvasData<'a> {
|
) -> CanvasData<'a> {
|
||||||
let draw_target = CanvasData::create(size);
|
let draw_target = CanvasData::create(size);
|
||||||
let path_builder = draw_target.create_path_builder();
|
let path_builder = draw_target.create_path_builder();
|
||||||
|
@ -63,7 +65,7 @@ impl<'a> CanvasData<'a> {
|
||||||
image_size: Size2D<f64>,
|
image_size: Size2D<f64>,
|
||||||
dest_rect: Rect<f64>,
|
dest_rect: Rect<f64>,
|
||||||
source_rect: Rect<f64>,
|
source_rect: Rect<f64>,
|
||||||
smoothing_enabled: bool
|
smoothing_enabled: bool,
|
||||||
) {
|
) {
|
||||||
// We round up the floating pixel values to draw the pixels
|
// We round up the floating pixel values to draw the pixels
|
||||||
let source_rect = source_rect.ceil();
|
let source_rect = source_rect.ceil();
|
||||||
|
@ -75,14 +77,22 @@ impl<'a> CanvasData<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let writer = |draw_target: &DrawTarget| {
|
let writer = |draw_target: &DrawTarget| {
|
||||||
write_image(&draw_target, image_data, source_rect.size, dest_rect,
|
write_image(
|
||||||
smoothing_enabled, self.state.draw_options.composition,
|
&draw_target,
|
||||||
self.state.draw_options.alpha);
|
image_data,
|
||||||
|
source_rect.size,
|
||||||
|
dest_rect,
|
||||||
|
smoothing_enabled,
|
||||||
|
self.state.draw_options.composition,
|
||||||
|
self.state.draw_options.alpha,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.need_to_draw_shadow() {
|
if self.need_to_draw_shadow() {
|
||||||
let rect = Rect::new(Point2D::new(dest_rect.origin.x as f32, dest_rect.origin.y as f32),
|
let rect = Rect::new(
|
||||||
Size2D::new(dest_rect.size.width as f32, dest_rect.size.height as f32));
|
Point2D::new(dest_rect.origin.x as f32, dest_rect.origin.y as f32),
|
||||||
|
Size2D::new(dest_rect.size.width as f32, dest_rect.size.height as f32),
|
||||||
|
);
|
||||||
|
|
||||||
self.draw_with_shadow(&rect, writer);
|
self.draw_with_shadow(&rect, writer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -103,7 +113,10 @@ impl<'a> CanvasData<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fill_text(&self, text: String, x: f64, y: f64, max_width: Option<f64>) {
|
pub fn fill_text(&self, text: String, x: f64, y: f64, max_width: Option<f64>) {
|
||||||
error!("Unimplemented canvas2d.fillText. Values received: {}, {}, {}, {:?}.", text, x, y, max_width);
|
error!(
|
||||||
|
"Unimplemented canvas2d.fillText. Values received: {}, {}, {}, {:?}.",
|
||||||
|
text, x, y, max_width
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fill_rect(&self, rect: &Rect<f32>) {
|
pub fn fill_rect(&self, rect: &Rect<f32>) {
|
||||||
|
@ -111,7 +124,8 @@ impl<'a> CanvasData<'a> {
|
||||||
return; // Paint nothing if gradient size is zero.
|
return; // Paint nothing if gradient size is zero.
|
||||||
}
|
}
|
||||||
|
|
||||||
let draw_rect = Rect::new(rect.origin,
|
let draw_rect = Rect::new(
|
||||||
|
rect.origin,
|
||||||
match self.state.fill_style {
|
match self.state.fill_style {
|
||||||
Pattern::Surface(ref surface) => {
|
Pattern::Surface(ref surface) => {
|
||||||
let surface_size = surface.size();
|
let surface_size = surface.size();
|
||||||
|
@ -119,21 +133,29 @@ impl<'a> CanvasData<'a> {
|
||||||
(true, true) => rect.size,
|
(true, true) => rect.size,
|
||||||
(true, false) => Size2D::new(rect.size.width, surface_size.height as f32),
|
(true, false) => Size2D::new(rect.size.width, surface_size.height as f32),
|
||||||
(false, true) => Size2D::new(surface_size.width as f32, rect.size.height),
|
(false, true) => Size2D::new(surface_size.width as f32, rect.size.height),
|
||||||
(false, false) => Size2D::new(surface_size.width as f32, surface_size.height as f32),
|
(false, false) => {
|
||||||
|
Size2D::new(surface_size.width as f32, surface_size.height as f32)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => rect.size,
|
_ => rect.size,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.need_to_draw_shadow() {
|
if self.need_to_draw_shadow() {
|
||||||
self.draw_with_shadow(&draw_rect, |new_draw_target: &DrawTarget| {
|
self.draw_with_shadow(&draw_rect, |new_draw_target: &DrawTarget| {
|
||||||
new_draw_target.fill_rect(&draw_rect, self.state.fill_style.to_pattern_ref(),
|
new_draw_target.fill_rect(
|
||||||
Some(&self.state.draw_options));
|
&draw_rect,
|
||||||
|
self.state.fill_style.to_pattern_ref(),
|
||||||
|
Some(&self.state.draw_options),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.drawtarget.fill_rect(&draw_rect, self.state.fill_style.to_pattern_ref(),
|
self.drawtarget.fill_rect(
|
||||||
Some(&self.state.draw_options));
|
&draw_rect,
|
||||||
|
self.state.fill_style.to_pattern_ref(),
|
||||||
|
Some(&self.state.draw_options),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,27 +170,40 @@ impl<'a> CanvasData<'a> {
|
||||||
|
|
||||||
if self.need_to_draw_shadow() {
|
if self.need_to_draw_shadow() {
|
||||||
self.draw_with_shadow(&rect, |new_draw_target: &DrawTarget| {
|
self.draw_with_shadow(&rect, |new_draw_target: &DrawTarget| {
|
||||||
new_draw_target.stroke_rect(rect, self.state.stroke_style.to_pattern_ref(),
|
new_draw_target.stroke_rect(
|
||||||
&self.state.stroke_opts, &self.state.draw_options);
|
rect,
|
||||||
|
self.state.stroke_style.to_pattern_ref(),
|
||||||
|
&self.state.stroke_opts,
|
||||||
|
&self.state.draw_options,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
} else if rect.size.width == 0. || rect.size.height == 0. {
|
} else if rect.size.width == 0. || rect.size.height == 0. {
|
||||||
let cap = match self.state.stroke_opts.line_join {
|
let cap = match self.state.stroke_opts.line_join {
|
||||||
JoinStyle::Round => CapStyle::Round,
|
JoinStyle::Round => CapStyle::Round,
|
||||||
_ => CapStyle::Butt
|
_ => CapStyle::Butt,
|
||||||
};
|
};
|
||||||
|
|
||||||
let stroke_opts =
|
let stroke_opts = StrokeOptions::new(
|
||||||
StrokeOptions::new(self.state.stroke_opts.line_width,
|
self.state.stroke_opts.line_width,
|
||||||
self.state.stroke_opts.line_join,
|
self.state.stroke_opts.line_join,
|
||||||
cap,
|
cap,
|
||||||
self.state.stroke_opts.miter_limit,
|
self.state.stroke_opts.miter_limit,
|
||||||
self.state.stroke_opts.mDashPattern);
|
self.state.stroke_opts.mDashPattern,
|
||||||
self.drawtarget.stroke_line(rect.origin, rect.bottom_right(),
|
);
|
||||||
self.state.stroke_style.to_pattern_ref(),
|
self.drawtarget.stroke_line(
|
||||||
&stroke_opts, &self.state.draw_options);
|
rect.origin,
|
||||||
|
rect.bottom_right(),
|
||||||
|
self.state.stroke_style.to_pattern_ref(),
|
||||||
|
&stroke_opts,
|
||||||
|
&self.state.draw_options,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
self.drawtarget.stroke_rect(rect, self.state.stroke_style.to_pattern_ref(),
|
self.drawtarget.stroke_rect(
|
||||||
&self.state.stroke_opts, &self.state.draw_options);
|
rect,
|
||||||
|
self.state.stroke_style.to_pattern_ref(),
|
||||||
|
&self.state.stroke_opts,
|
||||||
|
&self.state.draw_options,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,9 +220,11 @@ impl<'a> CanvasData<'a> {
|
||||||
return; // Paint nothing if gradient size is zero.
|
return; // Paint nothing if gradient size is zero.
|
||||||
}
|
}
|
||||||
|
|
||||||
self.drawtarget.fill(&self.path_builder.finish(),
|
self.drawtarget.fill(
|
||||||
self.state.fill_style.to_pattern_ref(),
|
&self.path_builder.finish(),
|
||||||
&self.state.draw_options);
|
self.state.fill_style.to_pattern_ref(),
|
||||||
|
&self.state.draw_options,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stroke(&self) {
|
pub fn stroke(&self) {
|
||||||
|
@ -195,10 +232,12 @@ impl<'a> CanvasData<'a> {
|
||||||
return; // Paint nothing if gradient size is zero.
|
return; // Paint nothing if gradient size is zero.
|
||||||
}
|
}
|
||||||
|
|
||||||
self.drawtarget.stroke(&self.path_builder.finish(),
|
self.drawtarget.stroke(
|
||||||
self.state.stroke_style.to_pattern_ref(),
|
&self.path_builder.finish(),
|
||||||
&self.state.stroke_opts,
|
self.state.stroke_style.to_pattern_ref(),
|
||||||
&self.state.draw_options);
|
&self.state.stroke_opts,
|
||||||
|
&self.state.draw_options,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clip(&self) {
|
pub fn clip(&self) {
|
||||||
|
@ -210,7 +249,7 @@ impl<'a> CanvasData<'a> {
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
_fill_rule: FillRule,
|
_fill_rule: FillRule,
|
||||||
chan: IpcSender<bool>
|
chan: IpcSender<bool>,
|
||||||
) {
|
) {
|
||||||
let path = self.path_builder.finish();
|
let path = self.path_builder.finish();
|
||||||
let result = path.contains_point(x, y, &self.state.transform);
|
let result = path.contains_point(x, y, &self.state.transform);
|
||||||
|
@ -227,19 +266,22 @@ impl<'a> CanvasData<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rect(&self, rect: &Rect<f32>) {
|
pub fn rect(&self, rect: &Rect<f32>) {
|
||||||
self.path_builder.move_to(Point2D::new(rect.origin.x, rect.origin.y));
|
self.path_builder
|
||||||
self.path_builder.line_to(Point2D::new(rect.origin.x + rect.size.width, rect.origin.y));
|
.move_to(Point2D::new(rect.origin.x, rect.origin.y));
|
||||||
self.path_builder.line_to(Point2D::new(rect.origin.x + rect.size.width,
|
self.path_builder
|
||||||
rect.origin.y + rect.size.height));
|
.line_to(Point2D::new(rect.origin.x + rect.size.width, rect.origin.y));
|
||||||
self.path_builder.line_to(Point2D::new(rect.origin.x, rect.origin.y + rect.size.height));
|
self.path_builder.line_to(Point2D::new(
|
||||||
|
rect.origin.x + rect.size.width,
|
||||||
|
rect.origin.y + rect.size.height,
|
||||||
|
));
|
||||||
|
self.path_builder.line_to(Point2D::new(
|
||||||
|
rect.origin.x,
|
||||||
|
rect.origin.y + rect.size.height,
|
||||||
|
));
|
||||||
self.path_builder.close();
|
self.path_builder.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn quadratic_curve_to(
|
pub fn quadratic_curve_to(&self, cp: &Point2D<AzFloat>, endpoint: &Point2D<AzFloat>) {
|
||||||
&self,
|
|
||||||
cp: &Point2D<AzFloat>,
|
|
||||||
endpoint: &Point2D<AzFloat>
|
|
||||||
) {
|
|
||||||
self.path_builder.quadratic_curve_to(cp, endpoint)
|
self.path_builder.quadratic_curve_to(cp, endpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +289,7 @@ impl<'a> CanvasData<'a> {
|
||||||
&self,
|
&self,
|
||||||
cp1: &Point2D<AzFloat>,
|
cp1: &Point2D<AzFloat>,
|
||||||
cp2: &Point2D<AzFloat>,
|
cp2: &Point2D<AzFloat>,
|
||||||
endpoint: &Point2D<AzFloat>
|
endpoint: &Point2D<AzFloat>,
|
||||||
) {
|
) {
|
||||||
self.path_builder.bezier_curve_to(cp1, cp2, endpoint)
|
self.path_builder.bezier_curve_to(cp1, cp2, endpoint)
|
||||||
}
|
}
|
||||||
|
@ -258,17 +300,13 @@ impl<'a> CanvasData<'a> {
|
||||||
radius: AzFloat,
|
radius: AzFloat,
|
||||||
start_angle: AzFloat,
|
start_angle: AzFloat,
|
||||||
end_angle: AzFloat,
|
end_angle: AzFloat,
|
||||||
ccw: bool
|
ccw: bool,
|
||||||
) {
|
) {
|
||||||
self.path_builder.arc(*center, radius, start_angle, end_angle, ccw)
|
self.path_builder
|
||||||
|
.arc(*center, radius, start_angle, end_angle, ccw)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arc_to(
|
pub fn arc_to(&self, cp1: &Point2D<AzFloat>, cp2: &Point2D<AzFloat>, radius: AzFloat) {
|
||||||
&self,
|
|
||||||
cp1: &Point2D<AzFloat>,
|
|
||||||
cp2: &Point2D<AzFloat>,
|
|
||||||
radius: AzFloat
|
|
||||||
) {
|
|
||||||
let cp0 = self.path_builder.get_current_point();
|
let cp0 = self.path_builder.get_current_point();
|
||||||
let cp1 = *cp1;
|
let cp1 = *cp1;
|
||||||
let cp2 = *cp2;
|
let cp2 = *cp2;
|
||||||
|
@ -314,9 +352,17 @@ impl<'a> CanvasData<'a> {
|
||||||
let angle_end = (tp2.y - cy).atan2(tp2.x - cx);
|
let angle_end = (tp2.y - cy).atan2(tp2.x - cx);
|
||||||
|
|
||||||
self.line_to(&tp1);
|
self.line_to(&tp1);
|
||||||
if [cx, cy, angle_start, angle_end].iter().all(|x| x.is_finite()) {
|
if [cx, cy, angle_start, angle_end]
|
||||||
self.arc(&Point2D::new(cx, cy), radius,
|
.iter()
|
||||||
angle_start, angle_end, anticlockwise);
|
.all(|x| x.is_finite())
|
||||||
|
{
|
||||||
|
self.arc(
|
||||||
|
&Point2D::new(cx, cy),
|
||||||
|
radius,
|
||||||
|
angle_start,
|
||||||
|
angle_end,
|
||||||
|
anticlockwise,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,9 +374,17 @@ impl<'a> CanvasData<'a> {
|
||||||
rotation_angle: AzFloat,
|
rotation_angle: AzFloat,
|
||||||
start_angle: AzFloat,
|
start_angle: AzFloat,
|
||||||
end_angle: AzFloat,
|
end_angle: AzFloat,
|
||||||
ccw: bool
|
ccw: bool,
|
||||||
) {
|
) {
|
||||||
self.path_builder.ellipse(*center, radius_x, radius_y, rotation_angle, start_angle, end_angle, ccw);
|
self.path_builder.ellipse(
|
||||||
|
*center,
|
||||||
|
radius_x,
|
||||||
|
radius_y,
|
||||||
|
rotation_angle,
|
||||||
|
start_angle,
|
||||||
|
end_angle,
|
||||||
|
ccw,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_fill_style(&mut self, style: FillOrStrokeStyle) {
|
pub fn set_fill_style(&mut self, style: FillOrStrokeStyle) {
|
||||||
|
@ -371,7 +425,9 @@ impl<'a> CanvasData<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_global_composition(&mut self, op: CompositionOrBlending) {
|
pub fn set_global_composition(&mut self, op: CompositionOrBlending) {
|
||||||
self.state.draw_options.set_composition_op(op.to_azure_style());
|
self.state
|
||||||
|
.draw_options
|
||||||
|
.set_composition_op(op.to_azure_style());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(size: Size2D<u32>) -> DrawTarget {
|
pub fn create(size: Size2D<u32>) -> DrawTarget {
|
||||||
|
@ -398,7 +454,13 @@ impl<'a> CanvasData<'a> {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn send_pixels(&mut self, chan: IpcSender<Option<ByteBuf>>) {
|
pub fn send_pixels(&mut self, chan: IpcSender<Option<ByteBuf>>) {
|
||||||
let data = unsafe { self.drawtarget.snapshot().get_data_surface().data().to_vec() };
|
let data = unsafe {
|
||||||
|
self.drawtarget
|
||||||
|
.snapshot()
|
||||||
|
.get_data_surface()
|
||||||
|
.data()
|
||||||
|
.to_vec()
|
||||||
|
};
|
||||||
chan.send(Some(data.into())).unwrap();
|
chan.send(Some(data.into())).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,9 +476,9 @@ impl<'a> CanvasData<'a> {
|
||||||
is_opaque: false,
|
is_opaque: false,
|
||||||
allow_mipmaps: false,
|
allow_mipmaps: false,
|
||||||
};
|
};
|
||||||
let data = webrender_api::ImageData::Raw(Arc::new(
|
let data = webrender_api::ImageData::Raw(Arc::new(unsafe {
|
||||||
unsafe { self.drawtarget.snapshot().get_data_surface().data().into() },
|
self.drawtarget.snapshot().get_data_surface().data().into()
|
||||||
));
|
}));
|
||||||
|
|
||||||
let mut txn = webrender_api::Transaction::new();
|
let mut txn = webrender_api::Transaction::new();
|
||||||
|
|
||||||
|
@ -424,15 +486,17 @@ impl<'a> CanvasData<'a> {
|
||||||
Some(image_key) => {
|
Some(image_key) => {
|
||||||
debug!("Updating image {:?}.", image_key);
|
debug!("Updating image {:?}.", image_key);
|
||||||
txn.update_image(image_key, descriptor, data, None);
|
txn.update_image(image_key, descriptor, data, None);
|
||||||
}
|
},
|
||||||
None => {
|
None => {
|
||||||
self.image_key = Some(self.webrender_api.generate_image_key());
|
self.image_key = Some(self.webrender_api.generate_image_key());
|
||||||
debug!("New image {:?}.", self.image_key);
|
debug!("New image {:?}.", self.image_key);
|
||||||
txn.add_image(self.image_key.unwrap(), descriptor, data, None);
|
txn.add_image(self.image_key.unwrap(), descriptor, data, None);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(image_key) = mem::replace(&mut self.very_old_image_key, self.old_image_key.take()) {
|
if let Some(image_key) =
|
||||||
|
mem::replace(&mut self.very_old_image_key, self.old_image_key.take())
|
||||||
|
{
|
||||||
txn.delete_image(image_key);
|
txn.delete_image(image_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,12 +513,15 @@ impl<'a> CanvasData<'a> {
|
||||||
assert_eq!(imagedata.len() % 4, 0);
|
assert_eq!(imagedata.len() % 4, 0);
|
||||||
assert_eq!(rect.size.area() as usize, imagedata.len() / 4);
|
assert_eq!(rect.size.area() as usize, imagedata.len() / 4);
|
||||||
pixels::byte_swap_and_premultiply_inplace(&mut imagedata);
|
pixels::byte_swap_and_premultiply_inplace(&mut imagedata);
|
||||||
let source_surface = self.drawtarget.create_source_surface_from_data(
|
let source_surface = self
|
||||||
&imagedata,
|
.drawtarget
|
||||||
rect.size.to_i32(),
|
.create_source_surface_from_data(
|
||||||
rect.size.width as i32 * 4,
|
&imagedata,
|
||||||
SurfaceFormat::B8G8R8A8,
|
rect.size.to_i32(),
|
||||||
).unwrap();
|
rect.size.width as i32 * 4,
|
||||||
|
SurfaceFormat::B8G8R8A8,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
self.drawtarget.copy_surface(
|
self.drawtarget.copy_surface(
|
||||||
source_surface,
|
source_surface,
|
||||||
Rect::from_size(rect.size.to_i32()),
|
Rect::from_size(rect.size.to_i32()),
|
||||||
|
@ -481,15 +548,19 @@ impl<'a> CanvasData<'a> {
|
||||||
// https://html.spec.whatwg.org/multipage/#when-shadows-are-drawn
|
// https://html.spec.whatwg.org/multipage/#when-shadows-are-drawn
|
||||||
fn need_to_draw_shadow(&self) -> bool {
|
fn need_to_draw_shadow(&self) -> bool {
|
||||||
self.state.shadow_color.a != 0.0f32 &&
|
self.state.shadow_color.a != 0.0f32 &&
|
||||||
(self.state.shadow_offset_x != 0.0f64 ||
|
(self.state.shadow_offset_x != 0.0f64 ||
|
||||||
self.state.shadow_offset_y != 0.0f64 ||
|
self.state.shadow_offset_y != 0.0f64 ||
|
||||||
self.state.shadow_blur != 0.0f64)
|
self.state.shadow_blur != 0.0f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_draw_target_for_shadow(&self, source_rect: &Rect<f32>) -> DrawTarget {
|
fn create_draw_target_for_shadow(&self, source_rect: &Rect<f32>) -> DrawTarget {
|
||||||
let draw_target = self.drawtarget.create_similar_draw_target(&Size2D::new(source_rect.size.width as i32,
|
let draw_target = self.drawtarget.create_similar_draw_target(
|
||||||
source_rect.size.height as i32),
|
&Size2D::new(
|
||||||
self.drawtarget.get_format());
|
source_rect.size.width as i32,
|
||||||
|
source_rect.size.height as i32,
|
||||||
|
),
|
||||||
|
self.drawtarget.get_format(),
|
||||||
|
);
|
||||||
let matrix = Transform2D::identity()
|
let matrix = Transform2D::identity()
|
||||||
.pre_translate(-source_rect.origin.to_vector().cast())
|
.pre_translate(-source_rect.origin.to_vector().cast())
|
||||||
.pre_mul(&self.state.transform);
|
.pre_mul(&self.state.transform);
|
||||||
|
@ -498,19 +569,26 @@ impl<'a> CanvasData<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_with_shadow<F>(&self, rect: &Rect<f32>, draw_shadow_source: F)
|
fn draw_with_shadow<F>(&self, rect: &Rect<f32>, draw_shadow_source: F)
|
||||||
where F: FnOnce(&DrawTarget)
|
where
|
||||||
|
F: FnOnce(&DrawTarget),
|
||||||
{
|
{
|
||||||
let shadow_src_rect = self.state.transform.transform_rect(rect);
|
let shadow_src_rect = self.state.transform.transform_rect(rect);
|
||||||
let new_draw_target = self.create_draw_target_for_shadow(&shadow_src_rect);
|
let new_draw_target = self.create_draw_target_for_shadow(&shadow_src_rect);
|
||||||
draw_shadow_source(&new_draw_target);
|
draw_shadow_source(&new_draw_target);
|
||||||
self.drawtarget.draw_surface_with_shadow(new_draw_target.snapshot(),
|
self.drawtarget.draw_surface_with_shadow(
|
||||||
&Point2D::new(shadow_src_rect.origin.x as AzFloat,
|
new_draw_target.snapshot(),
|
||||||
shadow_src_rect.origin.y as AzFloat),
|
&Point2D::new(
|
||||||
&self.state.shadow_color,
|
shadow_src_rect.origin.x as AzFloat,
|
||||||
&Vector2D::new(self.state.shadow_offset_x as AzFloat,
|
shadow_src_rect.origin.y as AzFloat,
|
||||||
self.state.shadow_offset_y as AzFloat),
|
),
|
||||||
(self.state.shadow_blur / 2.0f64) as AzFloat,
|
&self.state.shadow_color,
|
||||||
self.state.draw_options.composition);
|
&Vector2D::new(
|
||||||
|
self.state.shadow_offset_x as AzFloat,
|
||||||
|
self.state.shadow_offset_y as AzFloat,
|
||||||
|
),
|
||||||
|
(self.state.shadow_blur / 2.0f64) as AzFloat,
|
||||||
|
self.state.draw_options.composition,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// It reads image data from the canvas
|
/// It reads image data from the canvas
|
||||||
|
@ -519,11 +597,19 @@ impl<'a> CanvasData<'a> {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn read_pixels(&self, read_rect: Rect<u32>, canvas_size: Size2D<u32>) -> Vec<u8> {
|
pub fn read_pixels(&self, read_rect: Rect<u32>, canvas_size: Size2D<u32>) -> Vec<u8> {
|
||||||
let canvas_rect = Rect::from_size(canvas_size);
|
let canvas_rect = Rect::from_size(canvas_size);
|
||||||
if canvas_rect.intersection(&read_rect).map_or(true, |rect| rect.is_empty()) {
|
if canvas_rect
|
||||||
|
.intersection(&read_rect)
|
||||||
|
.map_or(true, |rect| rect.is_empty())
|
||||||
|
{
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
let data_surface = self.drawtarget.snapshot().get_data_surface();
|
let data_surface = self.drawtarget.snapshot().get_data_surface();
|
||||||
pixels::get_rect(unsafe { data_surface.data() }, canvas_size.to_u32(), read_rect.to_u32()).into_owned()
|
pixels::get_rect(
|
||||||
|
unsafe { data_surface.data() },
|
||||||
|
canvas_size.to_u32(),
|
||||||
|
read_rect.to_u32(),
|
||||||
|
)
|
||||||
|
.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +648,13 @@ impl<'a> CanvasPaintState<'a> {
|
||||||
draw_options: DrawOptions::new(1.0, CompositionOp::Over, antialias),
|
draw_options: DrawOptions::new(1.0, CompositionOp::Over, antialias),
|
||||||
fill_style: Pattern::Color(ColorPattern::new(Color::black())),
|
fill_style: Pattern::Color(ColorPattern::new(Color::black())),
|
||||||
stroke_style: Pattern::Color(ColorPattern::new(Color::black())),
|
stroke_style: Pattern::Color(ColorPattern::new(Color::black())),
|
||||||
stroke_opts: StrokeOptions::new(1.0, JoinStyle::MiterOrBevel, CapStyle::Butt, 10.0, &[]),
|
stroke_opts: StrokeOptions::new(
|
||||||
|
1.0,
|
||||||
|
JoinStyle::MiterOrBevel,
|
||||||
|
CapStyle::Butt,
|
||||||
|
10.0,
|
||||||
|
&[],
|
||||||
|
),
|
||||||
transform: Transform2D::identity(),
|
transform: Transform2D::identity(),
|
||||||
shadow_offset_x: 0.0,
|
shadow_offset_x: 0.0,
|
||||||
shadow_offset_y: 0.0,
|
shadow_offset_y: 0.0,
|
||||||
|
@ -594,10 +686,10 @@ fn write_image(
|
||||||
dest_rect: Rect<f64>,
|
dest_rect: Rect<f64>,
|
||||||
smoothing_enabled: bool,
|
smoothing_enabled: bool,
|
||||||
composition_op: CompositionOp,
|
composition_op: CompositionOp,
|
||||||
global_alpha: f32
|
global_alpha: f32,
|
||||||
) {
|
) {
|
||||||
if image_data.is_empty() {
|
if image_data.is_empty() {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let image_rect = Rect::new(Point2D::zero(), image_size);
|
let image_rect = Rect::new(Point2D::zero(), image_size);
|
||||||
|
|
||||||
|
@ -612,12 +704,14 @@ fn write_image(
|
||||||
};
|
};
|
||||||
let image_size = image_size.to_i32();
|
let image_size = image_size.to_i32();
|
||||||
|
|
||||||
let source_surface = draw_target.create_source_surface_from_data(
|
let source_surface = draw_target
|
||||||
&image_data,
|
.create_source_surface_from_data(
|
||||||
image_size,
|
&image_data,
|
||||||
image_size.width * 4,
|
image_size,
|
||||||
SurfaceFormat::B8G8R8A8,
|
image_size.width * 4,
|
||||||
).unwrap();
|
SurfaceFormat::B8G8R8A8,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
let draw_surface_options = DrawSurfaceOptions::new(filter, true);
|
let draw_surface_options = DrawSurfaceOptions::new(filter, true);
|
||||||
let draw_options = DrawOptions::new(global_alpha, composition_op, AntialiasMode::None);
|
let draw_options = DrawOptions::new(global_alpha, composition_op, AntialiasMode::None);
|
||||||
draw_target.draw_surface(
|
draw_target.draw_surface(
|
||||||
|
@ -635,8 +729,7 @@ pub trait PointToi32 {
|
||||||
|
|
||||||
impl PointToi32 for Point2D<f64> {
|
impl PointToi32 for Point2D<f64> {
|
||||||
fn to_i32(&self) -> Point2D<i32> {
|
fn to_i32(&self) -> Point2D<i32> {
|
||||||
Point2D::new(self.x.to_i32().unwrap(),
|
Point2D::new(self.x.to_i32().unwrap(), self.y.to_i32().unwrap())
|
||||||
self.y.to_i32().unwrap())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,8 +739,7 @@ pub trait SizeToi32 {
|
||||||
|
|
||||||
impl SizeToi32 for Size2D<f64> {
|
impl SizeToi32 for Size2D<f64> {
|
||||||
fn to_i32(&self) -> Size2D<i32> {
|
fn to_i32(&self) -> Size2D<i32> {
|
||||||
Size2D::new(self.width.to_i32().unwrap(),
|
Size2D::new(self.width.to_i32().unwrap(), self.height.to_i32().unwrap())
|
||||||
self.height.to_i32().unwrap())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,19 +750,24 @@ pub trait RectToi32 {
|
||||||
|
|
||||||
impl RectToi32 for Rect<f64> {
|
impl RectToi32 for Rect<f64> {
|
||||||
fn to_i32(&self) -> Rect<i32> {
|
fn to_i32(&self) -> Rect<i32> {
|
||||||
Rect::new(Point2D::new(self.origin.x.to_i32().unwrap(),
|
Rect::new(
|
||||||
self.origin.y.to_i32().unwrap()),
|
Point2D::new(
|
||||||
Size2D::new(self.size.width.to_i32().unwrap(),
|
self.origin.x.to_i32().unwrap(),
|
||||||
self.size.height.to_i32().unwrap()))
|
self.origin.y.to_i32().unwrap(),
|
||||||
|
),
|
||||||
|
Size2D::new(
|
||||||
|
self.size.width.to_i32().unwrap(),
|
||||||
|
self.size.height.to_i32().unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ceil(&self) -> Rect<f64> {
|
fn ceil(&self) -> Rect<f64> {
|
||||||
Rect::new(Point2D::new(self.origin.x.ceil(),
|
Rect::new(
|
||||||
self.origin.y.ceil()),
|
Point2D::new(self.origin.x.ceil(), self.origin.y.ceil()),
|
||||||
Size2D::new(self.size.width.ceil(),
|
Size2D::new(self.size.width.ceil(), self.size.height.ceil()),
|
||||||
self.size.height.ceil()))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ToAzureStyle {
|
pub trait ToAzureStyle {
|
||||||
|
@ -682,12 +779,13 @@ impl ToAzureStyle for Rect<f64> {
|
||||||
type Target = Rect<AzFloat>;
|
type Target = Rect<AzFloat>;
|
||||||
|
|
||||||
fn to_azure_style(self) -> Rect<AzFloat> {
|
fn to_azure_style(self) -> Rect<AzFloat> {
|
||||||
Rect::new(Point2D::new(self.origin.x as AzFloat, self.origin.y as AzFloat),
|
Rect::new(
|
||||||
Size2D::new(self.size.width as AzFloat, self.size.height as AzFloat))
|
Point2D::new(self.origin.x as AzFloat, self.origin.y as AzFloat),
|
||||||
|
Size2D::new(self.size.width as AzFloat, self.size.height as AzFloat),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ToAzureStyle for LineCapStyle {
|
impl ToAzureStyle for LineCapStyle {
|
||||||
type Target = CapStyle;
|
type Target = CapStyle;
|
||||||
|
|
||||||
|
@ -717,17 +815,17 @@ impl ToAzureStyle for CompositionStyle {
|
||||||
|
|
||||||
fn to_azure_style(self) -> CompositionOp {
|
fn to_azure_style(self) -> CompositionOp {
|
||||||
match self {
|
match self {
|
||||||
CompositionStyle::SrcIn => CompositionOp::In,
|
CompositionStyle::SrcIn => CompositionOp::In,
|
||||||
CompositionStyle::SrcOut => CompositionOp::Out,
|
CompositionStyle::SrcOut => CompositionOp::Out,
|
||||||
CompositionStyle::SrcOver => CompositionOp::Over,
|
CompositionStyle::SrcOver => CompositionOp::Over,
|
||||||
CompositionStyle::SrcAtop => CompositionOp::Atop,
|
CompositionStyle::SrcAtop => CompositionOp::Atop,
|
||||||
CompositionStyle::DestIn => CompositionOp::DestIn,
|
CompositionStyle::DestIn => CompositionOp::DestIn,
|
||||||
CompositionStyle::DestOut => CompositionOp::DestOut,
|
CompositionStyle::DestOut => CompositionOp::DestOut,
|
||||||
CompositionStyle::DestOver => CompositionOp::DestOver,
|
CompositionStyle::DestOver => CompositionOp::DestOver,
|
||||||
CompositionStyle::DestAtop => CompositionOp::DestAtop,
|
CompositionStyle::DestAtop => CompositionOp::DestAtop,
|
||||||
CompositionStyle::Copy => CompositionOp::Source,
|
CompositionStyle::Copy => CompositionOp::Source,
|
||||||
CompositionStyle::Lighter => CompositionOp::Add,
|
CompositionStyle::Lighter => CompositionOp::Add,
|
||||||
CompositionStyle::Xor => CompositionOp::Xor,
|
CompositionStyle::Xor => CompositionOp::Xor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,20 +835,20 @@ impl ToAzureStyle for BlendingStyle {
|
||||||
|
|
||||||
fn to_azure_style(self) -> CompositionOp {
|
fn to_azure_style(self) -> CompositionOp {
|
||||||
match self {
|
match self {
|
||||||
BlendingStyle::Multiply => CompositionOp::Multiply,
|
BlendingStyle::Multiply => CompositionOp::Multiply,
|
||||||
BlendingStyle::Screen => CompositionOp::Screen,
|
BlendingStyle::Screen => CompositionOp::Screen,
|
||||||
BlendingStyle::Overlay => CompositionOp::Overlay,
|
BlendingStyle::Overlay => CompositionOp::Overlay,
|
||||||
BlendingStyle::Darken => CompositionOp::Darken,
|
BlendingStyle::Darken => CompositionOp::Darken,
|
||||||
BlendingStyle::Lighten => CompositionOp::Lighten,
|
BlendingStyle::Lighten => CompositionOp::Lighten,
|
||||||
BlendingStyle::ColorDodge => CompositionOp::ColorDodge,
|
BlendingStyle::ColorDodge => CompositionOp::ColorDodge,
|
||||||
BlendingStyle::ColorBurn => CompositionOp::ColorBurn,
|
BlendingStyle::ColorBurn => CompositionOp::ColorBurn,
|
||||||
BlendingStyle::HardLight => CompositionOp::HardLight,
|
BlendingStyle::HardLight => CompositionOp::HardLight,
|
||||||
BlendingStyle::SoftLight => CompositionOp::SoftLight,
|
BlendingStyle::SoftLight => CompositionOp::SoftLight,
|
||||||
BlendingStyle::Difference => CompositionOp::Difference,
|
BlendingStyle::Difference => CompositionOp::Difference,
|
||||||
BlendingStyle::Exclusion => CompositionOp::Exclusion,
|
BlendingStyle::Exclusion => CompositionOp::Exclusion,
|
||||||
BlendingStyle::Hue => CompositionOp::Hue,
|
BlendingStyle::Hue => CompositionOp::Hue,
|
||||||
BlendingStyle::Saturation => CompositionOp::Saturation,
|
BlendingStyle::Saturation => CompositionOp::Saturation,
|
||||||
BlendingStyle::Color => CompositionOp::Color,
|
BlendingStyle::Color => CompositionOp::Color,
|
||||||
BlendingStyle::Luminosity => CompositionOp::Luminosity,
|
BlendingStyle::Luminosity => CompositionOp::Luminosity,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -778,32 +876,49 @@ impl ToAzurePattern for FillOrStrokeStyle {
|
||||||
Pattern::Color(ColorPattern::new(color.to_azure_style()))
|
Pattern::Color(ColorPattern::new(color.to_azure_style()))
|
||||||
},
|
},
|
||||||
FillOrStrokeStyle::LinearGradient(ref linear_gradient_style) => {
|
FillOrStrokeStyle::LinearGradient(ref linear_gradient_style) => {
|
||||||
let gradient_stops: Vec<GradientStop> = linear_gradient_style.stops.iter().map(|s| {
|
let gradient_stops: Vec<GradientStop> = linear_gradient_style
|
||||||
GradientStop {
|
.stops
|
||||||
|
.iter()
|
||||||
|
.map(|s| GradientStop {
|
||||||
offset: s.offset as AzFloat,
|
offset: s.offset as AzFloat,
|
||||||
color: s.color.to_azure_style()
|
color: s.color.to_azure_style(),
|
||||||
}
|
})
|
||||||
}).collect();
|
.collect();
|
||||||
|
|
||||||
Pattern::LinearGradient(LinearGradientPattern::new(
|
Pattern::LinearGradient(LinearGradientPattern::new(
|
||||||
&Point2D::new(linear_gradient_style.x0 as AzFloat, linear_gradient_style.y0 as AzFloat),
|
&Point2D::new(
|
||||||
&Point2D::new(linear_gradient_style.x1 as AzFloat, linear_gradient_style.y1 as AzFloat),
|
linear_gradient_style.x0 as AzFloat,
|
||||||
|
linear_gradient_style.y0 as AzFloat,
|
||||||
|
),
|
||||||
|
&Point2D::new(
|
||||||
|
linear_gradient_style.x1 as AzFloat,
|
||||||
|
linear_gradient_style.y1 as AzFloat,
|
||||||
|
),
|
||||||
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
||||||
&Transform2D::identity(),
|
&Transform2D::identity(),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
FillOrStrokeStyle::RadialGradient(ref radial_gradient_style) => {
|
FillOrStrokeStyle::RadialGradient(ref radial_gradient_style) => {
|
||||||
let gradient_stops: Vec<GradientStop> = radial_gradient_style.stops.iter().map(|s| {
|
let gradient_stops: Vec<GradientStop> = radial_gradient_style
|
||||||
GradientStop {
|
.stops
|
||||||
|
.iter()
|
||||||
|
.map(|s| GradientStop {
|
||||||
offset: s.offset as AzFloat,
|
offset: s.offset as AzFloat,
|
||||||
color: s.color.to_azure_style()
|
color: s.color.to_azure_style(),
|
||||||
}
|
})
|
||||||
}).collect();
|
.collect();
|
||||||
|
|
||||||
Pattern::RadialGradient(RadialGradientPattern::new(
|
Pattern::RadialGradient(RadialGradientPattern::new(
|
||||||
&Point2D::new(radial_gradient_style.x0 as AzFloat, radial_gradient_style.y0 as AzFloat),
|
&Point2D::new(
|
||||||
&Point2D::new(radial_gradient_style.x1 as AzFloat, radial_gradient_style.y1 as AzFloat),
|
radial_gradient_style.x0 as AzFloat,
|
||||||
radial_gradient_style.r0 as AzFloat, radial_gradient_style.r1 as AzFloat,
|
radial_gradient_style.y0 as AzFloat,
|
||||||
|
),
|
||||||
|
&Point2D::new(
|
||||||
|
radial_gradient_style.x1 as AzFloat,
|
||||||
|
radial_gradient_style.y1 as AzFloat,
|
||||||
|
),
|
||||||
|
radial_gradient_style.r0 as AzFloat,
|
||||||
|
radial_gradient_style.r1 as AzFloat,
|
||||||
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
|
||||||
&Transform2D::identity(),
|
&Transform2D::identity(),
|
||||||
))
|
))
|
||||||
|
@ -822,7 +937,7 @@ impl ToAzurePattern for FillOrStrokeStyle {
|
||||||
surface_style.repeat_y,
|
surface_style.repeat_y,
|
||||||
&Transform2D::identity(),
|
&Transform2D::identity(),
|
||||||
))
|
))
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,9 +946,11 @@ impl ToAzureStyle for RGBA {
|
||||||
type Target = Color;
|
type Target = Color;
|
||||||
|
|
||||||
fn to_azure_style(self) -> Color {
|
fn to_azure_style(self) -> Color {
|
||||||
Color::rgba(self.red_f32() as AzFloat,
|
Color::rgba(
|
||||||
self.green_f32() as AzFloat,
|
self.red_f32() as AzFloat,
|
||||||
self.blue_f32() as AzFloat,
|
self.green_f32() as AzFloat,
|
||||||
self.alpha_f32() as AzFloat)
|
self.blue_f32() as AzFloat,
|
||||||
|
self.alpha_f32() as AzFloat,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,13 @@ use std::collections::HashMap;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use webrender_api;
|
use webrender_api;
|
||||||
|
|
||||||
pub struct CanvasPaintThread <'a> {
|
pub struct CanvasPaintThread<'a> {
|
||||||
canvases: HashMap<CanvasId, CanvasData<'a>>,
|
canvases: HashMap<CanvasId, CanvasData<'a>>,
|
||||||
next_canvas_id: CanvasId,
|
next_canvas_id: CanvasId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CanvasPaintThread <'a> {
|
impl<'a> CanvasPaintThread<'a> {
|
||||||
fn new() -> CanvasPaintThread <'a> {
|
fn new() -> CanvasPaintThread<'a> {
|
||||||
CanvasPaintThread {
|
CanvasPaintThread {
|
||||||
canvases: HashMap::new(),
|
canvases: HashMap::new(),
|
||||||
next_canvas_id: CanvasId(0),
|
next_canvas_id: CanvasId(0),
|
||||||
|
@ -29,52 +29,49 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
/// communicate with it.
|
/// communicate with it.
|
||||||
pub fn start() -> IpcSender<CanvasMsg> {
|
pub fn start() -> IpcSender<CanvasMsg> {
|
||||||
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
|
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
|
||||||
thread::Builder::new().name("CanvasThread".to_owned()).spawn(move || {
|
thread::Builder::new()
|
||||||
let mut canvas_paint_thread = CanvasPaintThread::new();
|
.name("CanvasThread".to_owned())
|
||||||
loop {
|
.spawn(move || {
|
||||||
match receiver.recv() {
|
let mut canvas_paint_thread = CanvasPaintThread::new();
|
||||||
Ok(msg) => {
|
loop {
|
||||||
match msg {
|
match receiver.recv() {
|
||||||
|
Ok(msg) => match msg {
|
||||||
CanvasMsg::Canvas2d(message, canvas_id) => {
|
CanvasMsg::Canvas2d(message, canvas_id) => {
|
||||||
canvas_paint_thread.process_canvas_2d_message(message, canvas_id);
|
canvas_paint_thread.process_canvas_2d_message(message, canvas_id);
|
||||||
},
|
},
|
||||||
CanvasMsg::Close(canvas_id) =>{
|
CanvasMsg::Close(canvas_id) => {
|
||||||
canvas_paint_thread.canvases.remove(&canvas_id);
|
canvas_paint_thread.canvases.remove(&canvas_id);
|
||||||
},
|
},
|
||||||
CanvasMsg::Create(creator, size, webrenderer_api_sender, antialias) => {
|
CanvasMsg::Create(creator, size, webrenderer_api_sender, antialias) => {
|
||||||
let canvas_id = canvas_paint_thread.create_canvas(
|
let canvas_id = canvas_paint_thread.create_canvas(
|
||||||
size,
|
size,
|
||||||
webrenderer_api_sender,
|
webrenderer_api_sender,
|
||||||
antialias
|
antialias,
|
||||||
);
|
);
|
||||||
creator.send(canvas_id).unwrap();
|
creator.send(canvas_id).unwrap();
|
||||||
},
|
},
|
||||||
CanvasMsg::Recreate(size, canvas_id) =>{
|
CanvasMsg::Recreate(size, canvas_id) => {
|
||||||
canvas_paint_thread.canvas(canvas_id).recreate(size);
|
canvas_paint_thread.canvas(canvas_id).recreate(size);
|
||||||
},
|
},
|
||||||
CanvasMsg::FromScript(message, canvas_id) => {
|
CanvasMsg::FromScript(message, canvas_id) => match message {
|
||||||
match message {
|
FromScriptMsg::SendPixels(chan) => {
|
||||||
FromScriptMsg::SendPixels(chan) => {
|
canvas_paint_thread.canvas(canvas_id).send_pixels(chan);
|
||||||
canvas_paint_thread.canvas(canvas_id).send_pixels(chan);
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
CanvasMsg::FromLayout(message, canvas_id) => {
|
CanvasMsg::FromLayout(message, canvas_id) => match message {
|
||||||
match message {
|
FromLayoutMsg::SendData(chan) => {
|
||||||
FromLayoutMsg::SendData(chan) => {
|
canvas_paint_thread.canvas(canvas_id).send_data(chan);
|
||||||
canvas_paint_thread.canvas(canvas_id).send_data(chan);
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
CanvasMsg::Exit => break,
|
CanvasMsg::Exit => break,
|
||||||
}
|
},
|
||||||
},
|
Err(e) => {
|
||||||
Err(e) => {
|
warn!("Error on CanvasPaintThread receive ({})", e);
|
||||||
warn!("Error on CanvasPaintThread receive ({})", e);
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}).expect("Thread spawning failed");
|
.expect("Thread spawning failed");
|
||||||
|
|
||||||
sender
|
sender
|
||||||
}
|
}
|
||||||
|
@ -83,7 +80,7 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
&mut self,
|
&mut self,
|
||||||
size: Size2D<u32>,
|
size: Size2D<u32>,
|
||||||
webrender_api_sender: webrender_api::RenderApiSender,
|
webrender_api_sender: webrender_api::RenderApiSender,
|
||||||
antialias: bool
|
antialias: bool,
|
||||||
) -> CanvasId {
|
) -> CanvasId {
|
||||||
let antialias = if antialias {
|
let antialias = if antialias {
|
||||||
AntialiasMode::Default
|
AntialiasMode::Default
|
||||||
|
@ -105,33 +102,17 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
Canvas2dMsg::FillText(text, x, y, max_width) => {
|
Canvas2dMsg::FillText(text, x, y, max_width) => {
|
||||||
self.canvas(canvas_id).fill_text(text, x, y, max_width)
|
self.canvas(canvas_id).fill_text(text, x, y, max_width)
|
||||||
},
|
},
|
||||||
Canvas2dMsg::FillRect(ref rect) => {
|
Canvas2dMsg::FillRect(ref rect) => self.canvas(canvas_id).fill_rect(rect),
|
||||||
self.canvas(canvas_id).fill_rect(rect)
|
Canvas2dMsg::StrokeRect(ref rect) => self.canvas(canvas_id).stroke_rect(rect),
|
||||||
},
|
Canvas2dMsg::ClearRect(ref rect) => self.canvas(canvas_id).clear_rect(rect),
|
||||||
Canvas2dMsg::StrokeRect(ref rect) => {
|
Canvas2dMsg::BeginPath => self.canvas(canvas_id).begin_path(),
|
||||||
self.canvas(canvas_id).stroke_rect(rect)
|
Canvas2dMsg::ClosePath => self.canvas(canvas_id).close_path(),
|
||||||
},
|
Canvas2dMsg::Fill => self.canvas(canvas_id).fill(),
|
||||||
Canvas2dMsg::ClearRect(ref rect) => {
|
Canvas2dMsg::Stroke => self.canvas(canvas_id).stroke(),
|
||||||
self.canvas(canvas_id).clear_rect(rect)
|
Canvas2dMsg::Clip => self.canvas(canvas_id).clip(),
|
||||||
},
|
Canvas2dMsg::IsPointInPath(x, y, fill_rule, chan) => self
|
||||||
Canvas2dMsg::BeginPath => {
|
.canvas(canvas_id)
|
||||||
self.canvas(canvas_id).begin_path()
|
.is_point_in_path(x, y, fill_rule, chan),
|
||||||
},
|
|
||||||
Canvas2dMsg::ClosePath => {
|
|
||||||
self.canvas(canvas_id).close_path()
|
|
||||||
},
|
|
||||||
Canvas2dMsg::Fill => {
|
|
||||||
self.canvas(canvas_id).fill()
|
|
||||||
},
|
|
||||||
Canvas2dMsg::Stroke => {
|
|
||||||
self.canvas(canvas_id).stroke()
|
|
||||||
},
|
|
||||||
Canvas2dMsg::Clip => {
|
|
||||||
self.canvas(canvas_id).clip()
|
|
||||||
},
|
|
||||||
Canvas2dMsg::IsPointInPath(x, y, fill_rule, chan) => {
|
|
||||||
self.canvas(canvas_id).is_point_in_path(x, y, fill_rule, chan)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::DrawImage(
|
Canvas2dMsg::DrawImage(
|
||||||
imagedata,
|
imagedata,
|
||||||
image_size,
|
image_size,
|
||||||
|
@ -156,12 +137,11 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
image_size,
|
image_size,
|
||||||
dest_rect,
|
dest_rect,
|
||||||
source_rect,
|
source_rect,
|
||||||
smoothing
|
smoothing,
|
||||||
) => {
|
) => {
|
||||||
let image_data = self.canvas(canvas_id).read_pixels(
|
let image_data = self
|
||||||
source_rect.to_u32(),
|
.canvas(canvas_id)
|
||||||
image_size.to_u32(),
|
.read_pixels(source_rect.to_u32(), image_size.to_u32());
|
||||||
);
|
|
||||||
self.canvas(other_canvas_id).draw_image(
|
self.canvas(other_canvas_id).draw_image(
|
||||||
image_data.into(),
|
image_data.into(),
|
||||||
source_rect.size,
|
source_rect.size,
|
||||||
|
@ -170,68 +150,34 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
smoothing,
|
smoothing,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
Canvas2dMsg::MoveTo(ref point) => {
|
Canvas2dMsg::MoveTo(ref point) => self.canvas(canvas_id).move_to(point),
|
||||||
self.canvas(canvas_id).move_to(point)
|
Canvas2dMsg::LineTo(ref point) => self.canvas(canvas_id).line_to(point),
|
||||||
},
|
Canvas2dMsg::Rect(ref rect) => self.canvas(canvas_id).rect(rect),
|
||||||
Canvas2dMsg::LineTo(ref point) => {
|
|
||||||
self.canvas(canvas_id).line_to(point)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::Rect(ref rect) => {
|
|
||||||
self.canvas(canvas_id).rect(rect)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::QuadraticCurveTo(ref cp, ref pt) => {
|
Canvas2dMsg::QuadraticCurveTo(ref cp, ref pt) => {
|
||||||
self.canvas(canvas_id).quadratic_curve_to(cp, pt)
|
self.canvas(canvas_id).quadratic_curve_to(cp, pt)
|
||||||
}
|
},
|
||||||
Canvas2dMsg::BezierCurveTo(ref cp1, ref cp2, ref pt) => {
|
Canvas2dMsg::BezierCurveTo(ref cp1, ref cp2, ref pt) => {
|
||||||
self.canvas(canvas_id).bezier_curve_to(cp1, cp2, pt)
|
self.canvas(canvas_id).bezier_curve_to(cp1, cp2, pt)
|
||||||
}
|
},
|
||||||
Canvas2dMsg::Arc(ref center, radius, start, end, ccw) => {
|
Canvas2dMsg::Arc(ref center, radius, start, end, ccw) => {
|
||||||
self.canvas(canvas_id).arc(center, radius, start, end, ccw)
|
self.canvas(canvas_id).arc(center, radius, start, end, ccw)
|
||||||
}
|
},
|
||||||
Canvas2dMsg::ArcTo(ref cp1, ref cp2, radius) => {
|
Canvas2dMsg::ArcTo(ref cp1, ref cp2, radius) => {
|
||||||
self.canvas(canvas_id).arc_to(cp1, cp2, radius)
|
self.canvas(canvas_id).arc_to(cp1, cp2, radius)
|
||||||
}
|
|
||||||
Canvas2dMsg::Ellipse(ref center, radius_x, radius_y, rotation, start, end, ccw) => {
|
|
||||||
self.canvas(canvas_id).ellipse(
|
|
||||||
center,
|
|
||||||
radius_x,
|
|
||||||
radius_y,
|
|
||||||
rotation,
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
ccw
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Canvas2dMsg::RestoreContext => {
|
|
||||||
self.canvas(canvas_id).restore_context_state()
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SaveContext => {
|
|
||||||
self.canvas(canvas_id).save_context_state()
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetFillStyle(style) => {
|
|
||||||
self.canvas(canvas_id).set_fill_style(style)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetStrokeStyle(style) => {
|
|
||||||
self.canvas(canvas_id).set_stroke_style(style)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetLineWidth(width) => {
|
|
||||||
self.canvas(canvas_id).set_line_width(width)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetLineCap(cap) => {
|
|
||||||
self.canvas(canvas_id).set_line_cap(cap)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetLineJoin(join) => {
|
|
||||||
self.canvas(canvas_id).set_line_join(join)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetMiterLimit(limit) => {
|
|
||||||
self.canvas(canvas_id).set_miter_limit(limit)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetTransform(ref matrix) => {
|
|
||||||
self.canvas(canvas_id).set_transform(matrix)
|
|
||||||
},
|
|
||||||
Canvas2dMsg::SetGlobalAlpha(alpha) => {
|
|
||||||
self.canvas(canvas_id).set_global_alpha(alpha)
|
|
||||||
},
|
},
|
||||||
|
Canvas2dMsg::Ellipse(ref center, radius_x, radius_y, rotation, start, end, ccw) => self
|
||||||
|
.canvas(canvas_id)
|
||||||
|
.ellipse(center, radius_x, radius_y, rotation, start, end, ccw),
|
||||||
|
Canvas2dMsg::RestoreContext => self.canvas(canvas_id).restore_context_state(),
|
||||||
|
Canvas2dMsg::SaveContext => self.canvas(canvas_id).save_context_state(),
|
||||||
|
Canvas2dMsg::SetFillStyle(style) => self.canvas(canvas_id).set_fill_style(style),
|
||||||
|
Canvas2dMsg::SetStrokeStyle(style) => self.canvas(canvas_id).set_stroke_style(style),
|
||||||
|
Canvas2dMsg::SetLineWidth(width) => self.canvas(canvas_id).set_line_width(width),
|
||||||
|
Canvas2dMsg::SetLineCap(cap) => self.canvas(canvas_id).set_line_cap(cap),
|
||||||
|
Canvas2dMsg::SetLineJoin(join) => self.canvas(canvas_id).set_line_join(join),
|
||||||
|
Canvas2dMsg::SetMiterLimit(limit) => self.canvas(canvas_id).set_miter_limit(limit),
|
||||||
|
Canvas2dMsg::SetTransform(ref matrix) => self.canvas(canvas_id).set_transform(matrix),
|
||||||
|
Canvas2dMsg::SetGlobalAlpha(alpha) => self.canvas(canvas_id).set_global_alpha(alpha),
|
||||||
Canvas2dMsg::SetGlobalComposition(op) => {
|
Canvas2dMsg::SetGlobalComposition(op) => {
|
||||||
self.canvas(canvas_id).set_global_composition(op)
|
self.canvas(canvas_id).set_global_composition(op)
|
||||||
},
|
},
|
||||||
|
@ -240,7 +186,8 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
sender.send(&pixels).unwrap();
|
sender.send(&pixels).unwrap();
|
||||||
},
|
},
|
||||||
Canvas2dMsg::PutImageData(rect, receiver) => {
|
Canvas2dMsg::PutImageData(rect, receiver) => {
|
||||||
self.canvas(canvas_id).put_image_data(receiver.recv().unwrap(), rect);
|
self.canvas(canvas_id)
|
||||||
|
.put_image_data(receiver.recv().unwrap(), rect);
|
||||||
},
|
},
|
||||||
Canvas2dMsg::SetShadowOffsetX(value) => {
|
Canvas2dMsg::SetShadowOffsetX(value) => {
|
||||||
self.canvas(canvas_id).set_shadow_offset_x(value)
|
self.canvas(canvas_id).set_shadow_offset_x(value)
|
||||||
|
@ -248,12 +195,10 @@ impl<'a> CanvasPaintThread <'a> {
|
||||||
Canvas2dMsg::SetShadowOffsetY(value) => {
|
Canvas2dMsg::SetShadowOffsetY(value) => {
|
||||||
self.canvas(canvas_id).set_shadow_offset_y(value)
|
self.canvas(canvas_id).set_shadow_offset_y(value)
|
||||||
},
|
},
|
||||||
Canvas2dMsg::SetShadowBlur(value) => {
|
Canvas2dMsg::SetShadowBlur(value) => self.canvas(canvas_id).set_shadow_blur(value),
|
||||||
self.canvas(canvas_id).set_shadow_blur(value)
|
Canvas2dMsg::SetShadowColor(ref color) => self
|
||||||
},
|
.canvas(canvas_id)
|
||||||
Canvas2dMsg::SetShadowColor(ref color) => {
|
.set_shadow_color(color.to_azure_style()),
|
||||||
self.canvas(canvas_id).set_shadow_color(color.to_azure_style())
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,18 @@
|
||||||
* 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/. */
|
||||||
|
|
||||||
use canvas_traits::webgl::{WebGLCommand, WebGLVersion, WebGLCommandBacktrace};
|
use super::webgl_thread::{GLState, WebGLImpl};
|
||||||
use compositing::compositor_thread::{CompositorProxy, self};
|
use canvas_traits::webgl::{WebGLCommand, WebGLCommandBacktrace, WebGLVersion};
|
||||||
|
use compositing::compositor_thread::{self, CompositorProxy};
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
use offscreen_gl_context::{ColorAttachmentType, GLContext, GLContextAttributes, GLContextDispatcher};
|
use offscreen_gl_context::{
|
||||||
|
ColorAttachmentType, GLContext, GLContextAttributes, GLContextDispatcher,
|
||||||
|
};
|
||||||
use offscreen_gl_context::{GLLimits, GLVersion};
|
use offscreen_gl_context::{GLLimits, GLVersion};
|
||||||
use offscreen_gl_context::{NativeGLContext, NativeGLContextHandle, NativeGLContextMethods};
|
use offscreen_gl_context::{NativeGLContext, NativeGLContextHandle, NativeGLContextMethods};
|
||||||
use offscreen_gl_context::{OSMesaContext, OSMesaContextHandle};
|
use offscreen_gl_context::{OSMesaContext, OSMesaContextHandle};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use super::webgl_thread::{WebGLImpl, GLState};
|
|
||||||
|
|
||||||
/// The GLContextFactory is used to create shared GL contexts with the main thread GL context.
|
/// The GLContextFactory is used to create shared GL contexts with the main thread GL context.
|
||||||
/// Currently, shared textures are used to render WebGL textures into the WR compositor.
|
/// Currently, shared textures are used to render WebGL textures into the WR compositor.
|
||||||
|
@ -48,7 +50,7 @@ impl GLContextFactory {
|
||||||
&self,
|
&self,
|
||||||
webgl_version: WebGLVersion,
|
webgl_version: WebGLVersion,
|
||||||
size: Size2D<u32>,
|
size: Size2D<u32>,
|
||||||
attributes: GLContextAttributes
|
attributes: GLContextAttributes,
|
||||||
) -> Result<GLContextWrapper, &'static str> {
|
) -> Result<GLContextWrapper, &'static str> {
|
||||||
Ok(match *self {
|
Ok(match *self {
|
||||||
GLContextFactory::Native(ref handle, ref dispatcher) => {
|
GLContextFactory::Native(ref handle, ref dispatcher) => {
|
||||||
|
@ -63,7 +65,7 @@ impl GLContextFactory {
|
||||||
Some(handle),
|
Some(handle),
|
||||||
dispatcher,
|
dispatcher,
|
||||||
)?)
|
)?)
|
||||||
}
|
},
|
||||||
GLContextFactory::OSMesa(ref handle) => {
|
GLContextFactory::OSMesa(ref handle) => {
|
||||||
GLContextWrapper::OSMesa(GLContext::new_shared_with_dispatcher(
|
GLContextWrapper::OSMesa(GLContext::new_shared_with_dispatcher(
|
||||||
// FIXME(nox): Why are those i32 values?
|
// FIXME(nox): Why are those i32 values?
|
||||||
|
@ -75,7 +77,7 @@ impl GLContextFactory {
|
||||||
Some(handle),
|
Some(handle),
|
||||||
None,
|
None,
|
||||||
)?)
|
)?)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ impl GLContextFactory {
|
||||||
&self,
|
&self,
|
||||||
webgl_version: WebGLVersion,
|
webgl_version: WebGLVersion,
|
||||||
size: Size2D<u32>,
|
size: Size2D<u32>,
|
||||||
attributes: GLContextAttributes
|
attributes: GLContextAttributes,
|
||||||
) -> Result<GLContextWrapper, &'static str> {
|
) -> Result<GLContextWrapper, &'static str> {
|
||||||
Ok(match *self {
|
Ok(match *self {
|
||||||
GLContextFactory::Native(..) => {
|
GLContextFactory::Native(..) => {
|
||||||
|
@ -98,7 +100,7 @@ impl GLContextFactory {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
)?)
|
)?)
|
||||||
}
|
},
|
||||||
GLContextFactory::OSMesa(_) => {
|
GLContextFactory::OSMesa(_) => {
|
||||||
GLContextWrapper::OSMesa(GLContext::new_shared_with_dispatcher(
|
GLContextWrapper::OSMesa(GLContext::new_shared_with_dispatcher(
|
||||||
// FIXME(nox): Why are those i32 values?
|
// FIXME(nox): Why are those i32 values?
|
||||||
|
@ -110,7 +112,7 @@ impl GLContextFactory {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
)?)
|
)?)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +124,6 @@ impl GLContextFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// GLContextWrapper used to abstract NativeGLContext and OSMesaContext types
|
/// GLContextWrapper used to abstract NativeGLContext and OSMesaContext types
|
||||||
pub enum GLContextWrapper {
|
pub enum GLContextWrapper {
|
||||||
Native(GLContext<NativeGLContext>),
|
Native(GLContext<NativeGLContext>),
|
||||||
|
@ -134,10 +135,10 @@ impl GLContextWrapper {
|
||||||
match *self {
|
match *self {
|
||||||
GLContextWrapper::Native(ref ctx) => {
|
GLContextWrapper::Native(ref ctx) => {
|
||||||
ctx.make_current().unwrap();
|
ctx.make_current().unwrap();
|
||||||
}
|
},
|
||||||
GLContextWrapper::OSMesa(ref ctx) => {
|
GLContextWrapper::OSMesa(ref ctx) => {
|
||||||
ctx.make_current().unwrap();
|
ctx.make_current().unwrap();
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,10 +146,10 @@ impl GLContextWrapper {
|
||||||
match *self {
|
match *self {
|
||||||
GLContextWrapper::Native(ref ctx) => {
|
GLContextWrapper::Native(ref ctx) => {
|
||||||
ctx.unbind().unwrap();
|
ctx.unbind().unwrap();
|
||||||
}
|
},
|
||||||
GLContextWrapper::OSMesa(ref ctx) => {
|
GLContextWrapper::OSMesa(ref ctx) => {
|
||||||
ctx.unbind().unwrap();
|
ctx.unbind().unwrap();
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,26 +157,22 @@ impl GLContextWrapper {
|
||||||
&self,
|
&self,
|
||||||
cmd: WebGLCommand,
|
cmd: WebGLCommand,
|
||||||
backtrace: WebGLCommandBacktrace,
|
backtrace: WebGLCommandBacktrace,
|
||||||
state: &mut GLState
|
state: &mut GLState,
|
||||||
) {
|
) {
|
||||||
match *self {
|
match *self {
|
||||||
GLContextWrapper::Native(ref ctx) => {
|
GLContextWrapper::Native(ref ctx) => {
|
||||||
WebGLImpl::apply(ctx, state, cmd, backtrace);
|
WebGLImpl::apply(ctx, state, cmd, backtrace);
|
||||||
}
|
},
|
||||||
GLContextWrapper::OSMesa(ref ctx) => {
|
GLContextWrapper::OSMesa(ref ctx) => {
|
||||||
WebGLImpl::apply(ctx, state, cmd, backtrace);
|
WebGLImpl::apply(ctx, state, cmd, backtrace);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gl(&self) -> &gl::Gl {
|
pub fn gl(&self) -> &gl::Gl {
|
||||||
match *self {
|
match *self {
|
||||||
GLContextWrapper::Native(ref ctx) => {
|
GLContextWrapper::Native(ref ctx) => ctx.gl(),
|
||||||
ctx.gl()
|
GLContextWrapper::OSMesa(ref ctx) => ctx.gl(),
|
||||||
}
|
|
||||||
GLContextWrapper::OSMesa(ref ctx) => {
|
|
||||||
ctx.gl()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,23 +181,29 @@ impl GLContextWrapper {
|
||||||
GLContextWrapper::Native(ref ctx) => {
|
GLContextWrapper::Native(ref ctx) => {
|
||||||
let (real_size, texture_id) = {
|
let (real_size, texture_id) = {
|
||||||
let draw_buffer = ctx.borrow_draw_buffer().unwrap();
|
let draw_buffer = ctx.borrow_draw_buffer().unwrap();
|
||||||
(draw_buffer.size(), draw_buffer.get_bound_texture_id().unwrap())
|
(
|
||||||
|
draw_buffer.size(),
|
||||||
|
draw_buffer.get_bound_texture_id().unwrap(),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let limits = ctx.borrow_limits().clone();
|
let limits = ctx.borrow_limits().clone();
|
||||||
|
|
||||||
(real_size, texture_id, limits)
|
(real_size, texture_id, limits)
|
||||||
}
|
},
|
||||||
GLContextWrapper::OSMesa(ref ctx) => {
|
GLContextWrapper::OSMesa(ref ctx) => {
|
||||||
let (real_size, texture_id) = {
|
let (real_size, texture_id) = {
|
||||||
let draw_buffer = ctx.borrow_draw_buffer().unwrap();
|
let draw_buffer = ctx.borrow_draw_buffer().unwrap();
|
||||||
(draw_buffer.size(), draw_buffer.get_bound_texture_id().unwrap())
|
(
|
||||||
|
draw_buffer.size(),
|
||||||
|
draw_buffer.get_bound_texture_id().unwrap(),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let limits = ctx.borrow_limits().clone();
|
let limits = ctx.borrow_limits().clone();
|
||||||
|
|
||||||
(real_size, texture_id, limits)
|
(real_size, texture_id, limits)
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,11 +212,11 @@ impl GLContextWrapper {
|
||||||
GLContextWrapper::Native(ref mut ctx) => {
|
GLContextWrapper::Native(ref mut ctx) => {
|
||||||
// FIXME(nox): Why are those i32 values?
|
// FIXME(nox): Why are those i32 values?
|
||||||
ctx.resize(size.to_i32())
|
ctx.resize(size.to_i32())
|
||||||
}
|
},
|
||||||
GLContextWrapper::OSMesa(ref mut ctx) => {
|
GLContextWrapper::OSMesa(ref mut ctx) => {
|
||||||
// FIXME(nox): Why are those i32 values?
|
// FIXME(nox): Why are those i32 values?
|
||||||
ctx.resize(size.to_i32())
|
ctx.resize(size.to_i32())
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +225,7 @@ impl GLContextWrapper {
|
||||||
/// It's used in Windows to allow WGL GLContext sharing.
|
/// It's used in Windows to allow WGL GLContext sharing.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MainThreadDispatcher {
|
pub struct MainThreadDispatcher {
|
||||||
compositor_proxy: Arc<Mutex<CompositorProxy>>
|
compositor_proxy: Arc<Mutex<CompositorProxy>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MainThreadDispatcher {
|
impl MainThreadDispatcher {
|
||||||
|
@ -234,6 +237,9 @@ impl MainThreadDispatcher {
|
||||||
}
|
}
|
||||||
impl GLContextDispatcher for MainThreadDispatcher {
|
impl GLContextDispatcher for MainThreadDispatcher {
|
||||||
fn dispatch(&self, f: Box<Fn() + Send>) {
|
fn dispatch(&self, f: Box<Fn() + Send>) {
|
||||||
self.compositor_proxy.lock().unwrap().send(compositor_thread::Msg::Dispatch(f));
|
self.compositor_proxy
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.send(compositor_thread::Msg::Dispatch(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ extern crate euclid;
|
||||||
extern crate fnv;
|
extern crate fnv;
|
||||||
extern crate gleam;
|
extern crate gleam;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
extern crate num_traits;
|
extern crate num_traits;
|
||||||
extern crate offscreen_gl_context;
|
extern crate offscreen_gl_context;
|
||||||
extern crate pixels;
|
extern crate pixels;
|
||||||
|
|
|
@ -2,10 +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/. */
|
||||||
|
|
||||||
|
use canvas_traits::webgl::webgl_channel;
|
||||||
|
use canvas_traits::webgl::DOMToTextureCommand;
|
||||||
use canvas_traits::webgl::{WebGLChan, WebGLContextId, WebGLMsg, WebGLPipeline, WebGLReceiver};
|
use canvas_traits::webgl::{WebGLChan, WebGLContextId, WebGLMsg, WebGLPipeline, WebGLReceiver};
|
||||||
use canvas_traits::webgl::{WebGLSender, WebVRCommand, WebVRRenderHandler};
|
use canvas_traits::webgl::{WebGLSender, WebVRCommand, WebVRRenderHandler};
|
||||||
use canvas_traits::webgl::DOMToTextureCommand;
|
|
||||||
use canvas_traits::webgl::webgl_channel;
|
|
||||||
use crate::gl_context::GLContextFactory;
|
use crate::gl_context::GLContextFactory;
|
||||||
use crate::webgl_thread::{WebGLExternalImageApi, WebGLExternalImageHandler, WebGLThread};
|
use crate::webgl_thread::{WebGLExternalImageApi, WebGLExternalImageHandler, WebGLThread};
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
use euclid::{Transform2D, Point2D, Rect, Size2D};
|
use euclid::{Point2D, Rect, Size2D, Transform2D};
|
||||||
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender};
|
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender};
|
||||||
use serde_bytes::ByteBuf;
|
use serde_bytes::ByteBuf;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -22,7 +22,12 @@ pub struct CanvasId(pub u64);
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub enum CanvasMsg {
|
pub enum CanvasMsg {
|
||||||
Canvas2d(Canvas2dMsg, CanvasId),
|
Canvas2d(Canvas2dMsg, CanvasId),
|
||||||
Create(IpcSender<CanvasId>, Size2D<u32>, webrender_api::RenderApiSender, bool),
|
Create(
|
||||||
|
IpcSender<CanvasId>,
|
||||||
|
Size2D<u32>,
|
||||||
|
webrender_api::RenderApiSender,
|
||||||
|
bool,
|
||||||
|
),
|
||||||
FromLayout(FromLayoutMsg, CanvasId),
|
FromLayout(FromLayoutMsg, CanvasId),
|
||||||
FromScript(FromScriptMsg, CanvasId),
|
FromScript(FromScriptMsg, CanvasId),
|
||||||
Recreate(Size2D<u32>, CanvasId),
|
Recreate(Size2D<u32>, CanvasId),
|
||||||
|
@ -40,8 +45,7 @@ pub enum Canvas2dMsg {
|
||||||
Arc(Point2D<f32>, f32, f32, f32, bool),
|
Arc(Point2D<f32>, f32, f32, f32, bool),
|
||||||
ArcTo(Point2D<f32>, Point2D<f32>, f32),
|
ArcTo(Point2D<f32>, Point2D<f32>, f32),
|
||||||
DrawImage(Option<ByteBuf>, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
DrawImage(Option<ByteBuf>, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
||||||
DrawImageInOther(
|
DrawImageInOther(CanvasId, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
||||||
CanvasId, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
|
||||||
BeginPath,
|
BeginPath,
|
||||||
BezierCurveTo(Point2D<f32>, Point2D<f32>, Point2D<f32>),
|
BezierCurveTo(Point2D<f32>, Point2D<f32>, Point2D<f32>),
|
||||||
ClearRect(Rect<f32>),
|
ClearRect(Rect<f32>),
|
||||||
|
@ -99,12 +103,17 @@ pub struct LinearGradientStyle {
|
||||||
pub y0: f64,
|
pub y0: f64,
|
||||||
pub x1: f64,
|
pub x1: f64,
|
||||||
pub y1: f64,
|
pub y1: f64,
|
||||||
pub stops: Vec<CanvasGradientStop>
|
pub stops: Vec<CanvasGradientStop>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LinearGradientStyle {
|
impl LinearGradientStyle {
|
||||||
pub fn new(x0: f64, y0: f64, x1: f64, y1: f64, stops: Vec<CanvasGradientStop>)
|
pub fn new(
|
||||||
-> LinearGradientStyle {
|
x0: f64,
|
||||||
|
y0: f64,
|
||||||
|
x1: f64,
|
||||||
|
y1: f64,
|
||||||
|
stops: Vec<CanvasGradientStop>,
|
||||||
|
) -> LinearGradientStyle {
|
||||||
LinearGradientStyle {
|
LinearGradientStyle {
|
||||||
x0: x0,
|
x0: x0,
|
||||||
y0: y0,
|
y0: y0,
|
||||||
|
@ -123,12 +132,19 @@ pub struct RadialGradientStyle {
|
||||||
pub x1: f64,
|
pub x1: f64,
|
||||||
pub y1: f64,
|
pub y1: f64,
|
||||||
pub r1: f64,
|
pub r1: f64,
|
||||||
pub stops: Vec<CanvasGradientStop>
|
pub stops: Vec<CanvasGradientStop>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RadialGradientStyle {
|
impl RadialGradientStyle {
|
||||||
pub fn new(x0: f64, y0: f64, r0: f64, x1: f64, y1: f64, r1: f64, stops: Vec<CanvasGradientStop>)
|
pub fn new(
|
||||||
-> RadialGradientStyle {
|
x0: f64,
|
||||||
|
y0: f64,
|
||||||
|
r0: f64,
|
||||||
|
x1: f64,
|
||||||
|
y1: f64,
|
||||||
|
r1: f64,
|
||||||
|
stops: Vec<CanvasGradientStop>,
|
||||||
|
) -> RadialGradientStyle {
|
||||||
RadialGradientStyle {
|
RadialGradientStyle {
|
||||||
x0: x0,
|
x0: x0,
|
||||||
y0: y0,
|
y0: y0,
|
||||||
|
@ -165,7 +181,6 @@ impl SurfaceStyle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub enum FillOrStrokeStyle {
|
pub enum FillOrStrokeStyle {
|
||||||
Color(RGBA),
|
Color(RGBA),
|
||||||
|
@ -256,18 +271,18 @@ impl FromStr for CompositionStyle {
|
||||||
|
|
||||||
fn from_str(string: &str) -> Result<CompositionStyle, ()> {
|
fn from_str(string: &str) -> Result<CompositionStyle, ()> {
|
||||||
match string {
|
match string {
|
||||||
"source-in" => Ok(CompositionStyle::SrcIn),
|
"source-in" => Ok(CompositionStyle::SrcIn),
|
||||||
"source-out" => Ok(CompositionStyle::SrcOut),
|
"source-out" => Ok(CompositionStyle::SrcOut),
|
||||||
"source-over" => Ok(CompositionStyle::SrcOver),
|
"source-over" => Ok(CompositionStyle::SrcOver),
|
||||||
"source-atop" => Ok(CompositionStyle::SrcAtop),
|
"source-atop" => Ok(CompositionStyle::SrcAtop),
|
||||||
"destination-in" => Ok(CompositionStyle::DestIn),
|
"destination-in" => Ok(CompositionStyle::DestIn),
|
||||||
"destination-out" => Ok(CompositionStyle::DestOut),
|
"destination-out" => Ok(CompositionStyle::DestOut),
|
||||||
"destination-over" => Ok(CompositionStyle::DestOver),
|
"destination-over" => Ok(CompositionStyle::DestOver),
|
||||||
"destination-atop" => Ok(CompositionStyle::DestAtop),
|
"destination-atop" => Ok(CompositionStyle::DestAtop),
|
||||||
"copy" => Ok(CompositionStyle::Copy),
|
"copy" => Ok(CompositionStyle::Copy),
|
||||||
"lighter" => Ok(CompositionStyle::Lighter),
|
"lighter" => Ok(CompositionStyle::Lighter),
|
||||||
"xor" => Ok(CompositionStyle::Xor),
|
"xor" => Ok(CompositionStyle::Xor),
|
||||||
_ => Err(())
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,17 +290,17 @@ impl FromStr for CompositionStyle {
|
||||||
impl CompositionStyle {
|
impl CompositionStyle {
|
||||||
pub fn to_str(&self) -> &str {
|
pub fn to_str(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
CompositionStyle::SrcIn => "source-in",
|
CompositionStyle::SrcIn => "source-in",
|
||||||
CompositionStyle::SrcOut => "source-out",
|
CompositionStyle::SrcOut => "source-out",
|
||||||
CompositionStyle::SrcOver => "source-over",
|
CompositionStyle::SrcOver => "source-over",
|
||||||
CompositionStyle::SrcAtop => "source-atop",
|
CompositionStyle::SrcAtop => "source-atop",
|
||||||
CompositionStyle::DestIn => "destination-in",
|
CompositionStyle::DestIn => "destination-in",
|
||||||
CompositionStyle::DestOut => "destination-out",
|
CompositionStyle::DestOut => "destination-out",
|
||||||
CompositionStyle::DestOver => "destination-over",
|
CompositionStyle::DestOver => "destination-over",
|
||||||
CompositionStyle::DestAtop => "destination-atop",
|
CompositionStyle::DestAtop => "destination-atop",
|
||||||
CompositionStyle::Copy => "copy",
|
CompositionStyle::Copy => "copy",
|
||||||
CompositionStyle::Lighter => "lighter",
|
CompositionStyle::Lighter => "lighter",
|
||||||
CompositionStyle::Xor => "xor",
|
CompositionStyle::Xor => "xor",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,22 +329,22 @@ impl FromStr for BlendingStyle {
|
||||||
|
|
||||||
fn from_str(string: &str) -> Result<BlendingStyle, ()> {
|
fn from_str(string: &str) -> Result<BlendingStyle, ()> {
|
||||||
match string {
|
match string {
|
||||||
"multiply" => Ok(BlendingStyle::Multiply),
|
"multiply" => Ok(BlendingStyle::Multiply),
|
||||||
"screen" => Ok(BlendingStyle::Screen),
|
"screen" => Ok(BlendingStyle::Screen),
|
||||||
"overlay" => Ok(BlendingStyle::Overlay),
|
"overlay" => Ok(BlendingStyle::Overlay),
|
||||||
"darken" => Ok(BlendingStyle::Darken),
|
"darken" => Ok(BlendingStyle::Darken),
|
||||||
"lighten" => Ok(BlendingStyle::Lighten),
|
"lighten" => Ok(BlendingStyle::Lighten),
|
||||||
"color-dodge" => Ok(BlendingStyle::ColorDodge),
|
"color-dodge" => Ok(BlendingStyle::ColorDodge),
|
||||||
"color-burn" => Ok(BlendingStyle::ColorBurn),
|
"color-burn" => Ok(BlendingStyle::ColorBurn),
|
||||||
"hard-light" => Ok(BlendingStyle::HardLight),
|
"hard-light" => Ok(BlendingStyle::HardLight),
|
||||||
"soft-light" => Ok(BlendingStyle::SoftLight),
|
"soft-light" => Ok(BlendingStyle::SoftLight),
|
||||||
"difference" => Ok(BlendingStyle::Difference),
|
"difference" => Ok(BlendingStyle::Difference),
|
||||||
"exclusion" => Ok(BlendingStyle::Exclusion),
|
"exclusion" => Ok(BlendingStyle::Exclusion),
|
||||||
"hue" => Ok(BlendingStyle::Hue),
|
"hue" => Ok(BlendingStyle::Hue),
|
||||||
"saturation" => Ok(BlendingStyle::Saturation),
|
"saturation" => Ok(BlendingStyle::Saturation),
|
||||||
"color" => Ok(BlendingStyle::Color),
|
"color" => Ok(BlendingStyle::Color),
|
||||||
"luminosity" => Ok(BlendingStyle::Luminosity),
|
"luminosity" => Ok(BlendingStyle::Luminosity),
|
||||||
_ => Err(())
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,20 +352,20 @@ impl FromStr for BlendingStyle {
|
||||||
impl BlendingStyle {
|
impl BlendingStyle {
|
||||||
pub fn to_str(&self) -> &str {
|
pub fn to_str(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
BlendingStyle::Multiply => "multiply",
|
BlendingStyle::Multiply => "multiply",
|
||||||
BlendingStyle::Screen => "screen",
|
BlendingStyle::Screen => "screen",
|
||||||
BlendingStyle::Overlay => "overlay",
|
BlendingStyle::Overlay => "overlay",
|
||||||
BlendingStyle::Darken => "darken",
|
BlendingStyle::Darken => "darken",
|
||||||
BlendingStyle::Lighten => "lighten",
|
BlendingStyle::Lighten => "lighten",
|
||||||
BlendingStyle::ColorDodge => "color-dodge",
|
BlendingStyle::ColorDodge => "color-dodge",
|
||||||
BlendingStyle::ColorBurn => "color-burn",
|
BlendingStyle::ColorBurn => "color-burn",
|
||||||
BlendingStyle::HardLight => "hard-light",
|
BlendingStyle::HardLight => "hard-light",
|
||||||
BlendingStyle::SoftLight => "soft-light",
|
BlendingStyle::SoftLight => "soft-light",
|
||||||
BlendingStyle::Difference => "difference",
|
BlendingStyle::Difference => "difference",
|
||||||
BlendingStyle::Exclusion => "exclusion",
|
BlendingStyle::Exclusion => "exclusion",
|
||||||
BlendingStyle::Hue => "hue",
|
BlendingStyle::Hue => "hue",
|
||||||
BlendingStyle::Saturation => "saturation",
|
BlendingStyle::Saturation => "saturation",
|
||||||
BlendingStyle::Color => "color",
|
BlendingStyle::Color => "color",
|
||||||
BlendingStyle::Luminosity => "luminosity",
|
BlendingStyle::Luminosity => "luminosity",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,20 @@
|
||||||
|
|
||||||
#![crate_name = "canvas_traits"]
|
#![crate_name = "canvas_traits"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
|
|
||||||
extern crate cssparser;
|
extern crate cssparser;
|
||||||
extern crate euclid;
|
extern crate euclid;
|
||||||
extern crate gleam;
|
extern crate gleam;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
extern crate malloc_size_of;
|
extern crate malloc_size_of;
|
||||||
#[macro_use] extern crate malloc_size_of_derive;
|
#[macro_use]
|
||||||
|
extern crate malloc_size_of_derive;
|
||||||
extern crate offscreen_gl_context;
|
extern crate offscreen_gl_context;
|
||||||
#[macro_use] extern crate serde;
|
#[macro_use]
|
||||||
|
extern crate serde;
|
||||||
extern crate serde_bytes;
|
extern crate serde_bytes;
|
||||||
extern crate servo_config;
|
extern crate servo_config;
|
||||||
extern crate webrender_api;
|
extern crate webrender_api;
|
||||||
|
|
|
@ -11,18 +11,18 @@ use std::borrow::Cow;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
use webrender_api::{DocumentId, ImageKey, PipelineId};
|
use webrender_api::{DocumentId, ImageKey, PipelineId};
|
||||||
|
|
||||||
/// Sender type used in WebGLCommands.
|
/// Helper function that creates a WebGL channel (WebGLSender, WebGLReceiver) to be used in WebGLCommands.
|
||||||
pub use crate::webgl_channel::WebGLSender;
|
pub use crate::webgl_channel::webgl_channel;
|
||||||
|
/// Entry point channel type used for sending WebGLMsg messages to the WebGL renderer.
|
||||||
|
pub use crate::webgl_channel::WebGLChan;
|
||||||
|
/// Entry point type used in a Script Pipeline to get the WebGLChan to be used in that thread.
|
||||||
|
pub use crate::webgl_channel::WebGLPipeline;
|
||||||
/// Receiver type used in WebGLCommands.
|
/// Receiver type used in WebGLCommands.
|
||||||
pub use crate::webgl_channel::WebGLReceiver;
|
pub use crate::webgl_channel::WebGLReceiver;
|
||||||
/// Result type for send()/recv() calls in in WebGLCommands.
|
/// Result type for send()/recv() calls in in WebGLCommands.
|
||||||
pub use crate::webgl_channel::WebGLSendResult;
|
pub use crate::webgl_channel::WebGLSendResult;
|
||||||
/// Helper function that creates a WebGL channel (WebGLSender, WebGLReceiver) to be used in WebGLCommands.
|
/// Sender type used in WebGLCommands.
|
||||||
pub use crate::webgl_channel::webgl_channel;
|
pub use crate::webgl_channel::WebGLSender;
|
||||||
/// Entry point type used in a Script Pipeline to get the WebGLChan to be used in that thread.
|
|
||||||
pub use crate::webgl_channel::WebGLPipeline;
|
|
||||||
/// Entry point channel type used for sending WebGLMsg messages to the WebGL renderer.
|
|
||||||
pub use crate::webgl_channel::WebGLChan;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct WebGLCommandBacktrace {
|
pub struct WebGLCommandBacktrace {
|
||||||
|
@ -134,13 +134,15 @@ impl WebGLMsgSender {
|
||||||
/// Send a WebGLCommand message
|
/// Send a WebGLCommand message
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn send(&self, command: WebGLCommand, backtrace: WebGLCommandBacktrace) -> WebGLSendResult {
|
pub fn send(&self, command: WebGLCommand, backtrace: WebGLCommandBacktrace) -> WebGLSendResult {
|
||||||
self.sender.send(WebGLMsg::WebGLCommand(self.ctx_id, command, backtrace))
|
self.sender
|
||||||
|
.send(WebGLMsg::WebGLCommand(self.ctx_id, command, backtrace))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a WebVRCommand message
|
/// Send a WebVRCommand message
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn send_vr(&self, command: WebVRCommand) -> WebGLSendResult {
|
pub fn send_vr(&self, command: WebVRCommand) -> WebGLSendResult {
|
||||||
self.sender.send(WebGLMsg::WebVRCommand(self.ctx_id, command))
|
self.sender
|
||||||
|
.send(WebGLMsg::WebVRCommand(self.ctx_id, command))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a resize message
|
/// Send a resize message
|
||||||
|
@ -150,7 +152,8 @@ impl WebGLMsgSender {
|
||||||
size: Size2D<u32>,
|
size: Size2D<u32>,
|
||||||
sender: WebGLSender<Result<(), String>>,
|
sender: WebGLSender<Result<(), String>>,
|
||||||
) -> WebGLSendResult {
|
) -> WebGLSendResult {
|
||||||
self.sender.send(WebGLMsg::ResizeContext(self.ctx_id, size, sender))
|
self.sender
|
||||||
|
.send(WebGLMsg::ResizeContext(self.ctx_id, size, sender))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -160,7 +163,8 @@ impl WebGLMsgSender {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn send_update_wr_image(&self, sender: WebGLSender<ImageKey>) -> WebGLSendResult {
|
pub fn send_update_wr_image(&self, sender: WebGLSender<ImageKey>) -> WebGLSendResult {
|
||||||
self.sender.send(WebGLMsg::UpdateWebRenderImage(self.ctx_id, sender))
|
self.sender
|
||||||
|
.send(WebGLMsg::UpdateWebRenderImage(self.ctx_id, sender))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_dom_to_texture(&self, command: DOMToTextureCommand) -> WebGLSendResult {
|
pub fn send_dom_to_texture(&self, command: DOMToTextureCommand) -> WebGLSendResult {
|
||||||
|
@ -290,11 +294,34 @@ pub enum WebGLCommand {
|
||||||
GetTexParameterInt(u32, TexParameterInt, WebGLSender<i32>),
|
GetTexParameterInt(u32, TexParameterInt, WebGLSender<i32>),
|
||||||
TexParameteri(u32, u32, i32),
|
TexParameteri(u32, u32, i32),
|
||||||
TexParameterf(u32, u32, f32),
|
TexParameterf(u32, u32, f32),
|
||||||
DrawArrays { mode: u32, first: i32, count: i32 },
|
DrawArrays {
|
||||||
DrawArraysInstanced { mode: u32, first: i32, count: i32, primcount: i32 },
|
mode: u32,
|
||||||
DrawElements { mode: u32, count: i32, type_: u32, offset: u32 },
|
first: i32,
|
||||||
DrawElementsInstanced { mode: u32, count: i32, type_: u32, offset: u32, primcount: i32 },
|
count: i32,
|
||||||
VertexAttribDivisor { index: u32, divisor: u32 },
|
},
|
||||||
|
DrawArraysInstanced {
|
||||||
|
mode: u32,
|
||||||
|
first: i32,
|
||||||
|
count: i32,
|
||||||
|
primcount: i32,
|
||||||
|
},
|
||||||
|
DrawElements {
|
||||||
|
mode: u32,
|
||||||
|
count: i32,
|
||||||
|
type_: u32,
|
||||||
|
offset: u32,
|
||||||
|
},
|
||||||
|
DrawElementsInstanced {
|
||||||
|
mode: u32,
|
||||||
|
count: i32,
|
||||||
|
type_: u32,
|
||||||
|
offset: u32,
|
||||||
|
primcount: i32,
|
||||||
|
},
|
||||||
|
VertexAttribDivisor {
|
||||||
|
index: u32,
|
||||||
|
divisor: u32,
|
||||||
|
},
|
||||||
GetUniformBool(WebGLProgramId, i32, WebGLSender<bool>),
|
GetUniformBool(WebGLProgramId, i32, WebGLSender<bool>),
|
||||||
GetUniformBool2(WebGLProgramId, i32, WebGLSender<[bool; 2]>),
|
GetUniformBool2(WebGLProgramId, i32, WebGLSender<[bool; 2]>),
|
||||||
GetUniformBool3(WebGLProgramId, i32, WebGLSender<[bool; 3]>),
|
GetUniformBool3(WebGLProgramId, i32, WebGLSender<[bool; 3]>),
|
||||||
|
@ -309,7 +336,11 @@ pub enum WebGLCommand {
|
||||||
GetUniformFloat4(WebGLProgramId, i32, WebGLSender<[f32; 4]>),
|
GetUniformFloat4(WebGLProgramId, i32, WebGLSender<[f32; 4]>),
|
||||||
GetUniformFloat9(WebGLProgramId, i32, WebGLSender<[f32; 9]>),
|
GetUniformFloat9(WebGLProgramId, i32, WebGLSender<[f32; 9]>),
|
||||||
GetUniformFloat16(WebGLProgramId, i32, WebGLSender<[f32; 16]>),
|
GetUniformFloat16(WebGLProgramId, i32, WebGLSender<[f32; 16]>),
|
||||||
InitializeFramebuffer { color: bool, depth: bool, stencil: bool },
|
InitializeFramebuffer {
|
||||||
|
color: bool,
|
||||||
|
depth: bool,
|
||||||
|
stencil: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! define_resource_id_struct {
|
macro_rules! define_resource_id_struct {
|
||||||
|
@ -329,7 +360,6 @@ macro_rules! define_resource_id_struct {
|
||||||
self.0.get()
|
self.0.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +370,8 @@ macro_rules! define_resource_id {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
impl<'de> ::serde::Deserialize<'de> for $name {
|
impl<'de> ::serde::Deserialize<'de> for $name {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where D: ::serde::Deserializer<'de>
|
where
|
||||||
|
D: ::serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let id = u32::deserialize(deserializer)?;
|
let id = u32::deserialize(deserializer)?;
|
||||||
if id == 0 {
|
if id == 0 {
|
||||||
|
@ -353,32 +384,33 @@ macro_rules! define_resource_id {
|
||||||
|
|
||||||
impl ::serde::Serialize for $name {
|
impl ::serde::Serialize for $name {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where S: ::serde::Serializer
|
where
|
||||||
|
S: ::serde::Serializer,
|
||||||
{
|
{
|
||||||
self.get().serialize(serializer)
|
self.get().serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Debug for $name {
|
impl ::std::fmt::Debug for $name {
|
||||||
fn fmt(&self, fmt: &mut ::std::fmt::Formatter)
|
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
|
||||||
-> Result<(), ::std::fmt::Error> {
|
|
||||||
fmt.debug_tuple(stringify!($name))
|
fmt.debug_tuple(stringify!($name))
|
||||||
.field(&self.get())
|
.field(&self.get())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for $name {
|
impl ::std::fmt::Display for $name {
|
||||||
fn fmt(&self, fmt: &mut ::std::fmt::Formatter)
|
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
|
||||||
-> Result<(), ::std::fmt::Error> {
|
|
||||||
write!(fmt, "{}", self.get())
|
write!(fmt, "{}", self.get())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::malloc_size_of::MallocSizeOf for $name {
|
impl ::malloc_size_of::MallocSizeOf for $name {
|
||||||
fn size_of(&self, _ops: &mut ::malloc_size_of::MallocSizeOfOps) -> usize { 0 }
|
fn size_of(&self, _ops: &mut ::malloc_size_of::MallocSizeOfOps) -> usize {
|
||||||
|
0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
define_resource_id!(WebGLBufferId);
|
define_resource_id!(WebGLBufferId);
|
||||||
|
@ -389,8 +421,9 @@ define_resource_id!(WebGLProgramId);
|
||||||
define_resource_id!(WebGLShaderId);
|
define_resource_id!(WebGLShaderId);
|
||||||
define_resource_id!(WebGLVertexArrayId);
|
define_resource_id!(WebGLVertexArrayId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord)]
|
#[derive(
|
||||||
#[derive(PartialEq, PartialOrd, Serialize)]
|
Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize,
|
||||||
|
)]
|
||||||
pub struct WebGLContextId(pub usize);
|
pub struct WebGLContextId(pub usize);
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
||||||
|
@ -423,7 +456,7 @@ pub enum WebVRCommand {
|
||||||
/// Submit the frame to a VR device using the specified texture coordinates.
|
/// Submit the frame to a VR device using the specified texture coordinates.
|
||||||
SubmitFrame(WebVRDeviceId, [f32; 4], [f32; 4]),
|
SubmitFrame(WebVRDeviceId, [f32; 4], [f32; 4]),
|
||||||
/// Stop presenting to a VR device
|
/// Stop presenting to a VR device
|
||||||
Release(WebVRDeviceId)
|
Release(WebVRDeviceId),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trait object that handles WebVR commands.
|
// Trait object that handles WebVR commands.
|
||||||
|
@ -436,7 +469,13 @@ pub trait WebVRRenderHandler: Send {
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub enum DOMToTextureCommand {
|
pub enum DOMToTextureCommand {
|
||||||
/// Attaches a HTMLIFrameElement to a WebGLTexture.
|
/// Attaches a HTMLIFrameElement to a WebGLTexture.
|
||||||
Attach(WebGLContextId, WebGLTextureId, DocumentId, PipelineId, Size2D<i32>),
|
Attach(
|
||||||
|
WebGLContextId,
|
||||||
|
WebGLTextureId,
|
||||||
|
DocumentId,
|
||||||
|
PipelineId,
|
||||||
|
Size2D<i32>,
|
||||||
|
),
|
||||||
/// Releases the HTMLIFrameElement to WebGLTexture attachment.
|
/// Releases the HTMLIFrameElement to WebGLTexture attachment.
|
||||||
Detach(WebGLTextureId),
|
Detach(WebGLTextureId),
|
||||||
/// Lock message used for a correct synchronization with WebRender GL flow.
|
/// Lock message used for a correct synchronization with WebRender GL flow.
|
||||||
|
|
|
@ -15,46 +15,45 @@ pub use crossbeam_channel::*;
|
||||||
use ipc_channel::ipc::IpcReceiver;
|
use ipc_channel::ipc::IpcReceiver;
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub fn route_ipc_receiver_to_new_servo_receiver<T>(ipc_receiver: IpcReceiver<T>) -> Receiver<T>
|
pub fn route_ipc_receiver_to_new_servo_receiver<T>(ipc_receiver: IpcReceiver<T>) -> Receiver<T>
|
||||||
where
|
where
|
||||||
T: for<'de> Deserialize<'de> + Serialize + Send + 'static
|
T: for<'de> Deserialize<'de> + Serialize + Send + 'static,
|
||||||
{
|
{
|
||||||
let (servo_sender, servo_receiver) = channel();
|
let (servo_sender, servo_receiver) = channel();
|
||||||
ROUTER.add_route(
|
ROUTER.add_route(
|
||||||
ipc_receiver.to_opaque(),
|
ipc_receiver.to_opaque(),
|
||||||
Box::new(move |message| {
|
Box::new(move |message| drop(servo_sender.send(message.to::<T>().unwrap()))),
|
||||||
drop(servo_sender.send(message.to::<T>().unwrap()))
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
servo_receiver
|
servo_receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn route_ipc_receiver_to_new_servo_sender<T>(ipc_receiver: IpcReceiver<T>, servo_sender: Sender<T>)
|
pub fn route_ipc_receiver_to_new_servo_sender<T>(
|
||||||
where
|
ipc_receiver: IpcReceiver<T>,
|
||||||
T: for<'de> Deserialize<'de> + Serialize + Send + 'static
|
servo_sender: Sender<T>,
|
||||||
|
) where
|
||||||
|
T: for<'de> Deserialize<'de> + Serialize + Send + 'static,
|
||||||
{
|
{
|
||||||
ROUTER.add_route(
|
ROUTER.add_route(
|
||||||
ipc_receiver.to_opaque(),
|
ipc_receiver.to_opaque(),
|
||||||
Box::new(move |message| {
|
Box::new(move |message| drop(servo_sender.send(message.to::<T>().unwrap()))),
|
||||||
drop(servo_sender.send(message.to::<T>().unwrap()))
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
|
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
|
||||||
let (base_sender, base_receiver) = crossbeam_channel::unbounded::<T>();
|
let (base_sender, base_receiver) = crossbeam_channel::unbounded::<T>();
|
||||||
let is_disconnected = Arc::new(AtomicBool::new(false));
|
let is_disconnected = Arc::new(AtomicBool::new(false));
|
||||||
(Sender::new(base_sender, is_disconnected.clone()),
|
(
|
||||||
Receiver::new(base_receiver, is_disconnected))
|
Sender::new(base_sender, is_disconnected.clone()),
|
||||||
|
Receiver::new(base_receiver, is_disconnected),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum ChannelError {
|
pub enum ChannelError {
|
||||||
ChannelClosedError
|
ChannelClosedError,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Receiver<T> {
|
pub struct Receiver<T> {
|
||||||
|
@ -78,7 +77,10 @@ impl<T> Clone for Receiver<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Receiver<T> {
|
impl<T> Receiver<T> {
|
||||||
pub fn new(receiver: crossbeam_channel::Receiver<T>, is_disconnected: Arc<AtomicBool>) -> Receiver<T> {
|
pub fn new(
|
||||||
|
receiver: crossbeam_channel::Receiver<T>,
|
||||||
|
is_disconnected: Arc<AtomicBool>,
|
||||||
|
) -> Receiver<T> {
|
||||||
Receiver {
|
Receiver {
|
||||||
receiver,
|
receiver,
|
||||||
is_disconnected,
|
is_disconnected,
|
||||||
|
@ -134,7 +136,10 @@ impl<T> Clone for Sender<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Sender<T> {
|
impl<T> Sender<T> {
|
||||||
pub fn new(sender: crossbeam_channel::Sender<T>, is_disconnected: Arc<AtomicBool>) -> Sender<T> {
|
pub fn new(
|
||||||
|
sender: crossbeam_channel::Sender<T>,
|
||||||
|
is_disconnected: Arc<AtomicBool>,
|
||||||
|
) -> Sender<T> {
|
||||||
Sender {
|
Sender {
|
||||||
sender,
|
sender,
|
||||||
is_disconnected,
|
is_disconnected,
|
||||||
|
|
|
@ -36,7 +36,8 @@ fn main() {
|
||||||
.find(|pkg| {
|
.find(|pkg| {
|
||||||
pkg.get("name").and_then(|name| name.as_str()).unwrap_or("") ==
|
pkg.get("name").and_then(|name| name.as_str()).unwrap_or("") ==
|
||||||
"webrender"
|
"webrender"
|
||||||
}).and_then(|pkg| pkg.get("source").and_then(|source| source.as_str()))
|
})
|
||||||
|
.and_then(|pkg| pkg.get("source").and_then(|source| source.as_str()))
|
||||||
.unwrap_or("unknown");
|
.unwrap_or("unknown");
|
||||||
|
|
||||||
let parsed: Vec<&str> = source.split("#").collect();
|
let parsed: Vec<&str> = source.split("#").collect();
|
||||||
|
|
|
@ -2,15 +2,17 @@
|
||||||
* 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/. */
|
||||||
|
|
||||||
use crate::CompositionPipeline;
|
|
||||||
use crate::SendableFrameTree;
|
|
||||||
use crate::compositor_thread::{CompositorProxy, CompositorReceiver};
|
use crate::compositor_thread::{CompositorProxy, CompositorReceiver};
|
||||||
use crate::compositor_thread::{InitialCompositorState, Msg};
|
use crate::compositor_thread::{InitialCompositorState, Msg};
|
||||||
#[cfg(feature = "gleam")]
|
#[cfg(feature = "gleam")]
|
||||||
use crate::gl;
|
use crate::gl;
|
||||||
use crate::touch::{TouchHandler, TouchAction};
|
use crate::touch::{TouchAction, TouchHandler};
|
||||||
use crate::windowing::{self, EmbedderCoordinates, MouseWindowEvent, WebRenderDebugOption, WindowMethods};
|
use crate::windowing::{
|
||||||
use euclid::{TypedPoint2D, TypedVector2D, TypedScale};
|
self, EmbedderCoordinates, MouseWindowEvent, WebRenderDebugOption, WindowMethods,
|
||||||
|
};
|
||||||
|
use crate::CompositionPipeline;
|
||||||
|
use crate::SendableFrameTree;
|
||||||
|
use euclid::{TypedPoint2D, TypedScale, TypedVector2D};
|
||||||
use gfx_traits::Epoch;
|
use gfx_traits::Epoch;
|
||||||
#[cfg(feature = "gleam")]
|
#[cfg(feature = "gleam")]
|
||||||
use image::{DynamicImage, ImageFormat};
|
use image::{DynamicImage, ImageFormat};
|
||||||
|
@ -20,23 +22,23 @@ use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId};
|
||||||
use net_traits::image::base::Image;
|
use net_traits::image::base::Image;
|
||||||
#[cfg(feature = "gleam")]
|
#[cfg(feature = "gleam")]
|
||||||
use net_traits::image::base::PixelFormat;
|
use net_traits::image::base::PixelFormat;
|
||||||
use profile_traits::time::{self as profile_time, ProfilerCategory, profile};
|
use profile_traits::time::{self as profile_time, profile, ProfilerCategory};
|
||||||
|
use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent, TouchEvent};
|
||||||
use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutControlMsg};
|
use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutControlMsg};
|
||||||
use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId};
|
use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId};
|
||||||
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
||||||
use script_traits::CompositorEvent::{MouseMoveEvent, MouseButtonEvent, TouchEvent};
|
|
||||||
use servo_channel::Sender;
|
use servo_channel::Sender;
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use servo_geometry::DeviceIndependentPixel;
|
use servo_geometry::DeviceIndependentPixel;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{File, create_dir_all};
|
use std::fs::{create_dir_all, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
|
||||||
use style_traits::cursor::CursorKind;
|
use style_traits::cursor::CursorKind;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
use style_traits::viewport::ViewportConstraints;
|
||||||
|
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
||||||
use time::{now, precise_time_ns, precise_time_s};
|
use time::{now, precise_time_ns, precise_time_s};
|
||||||
use webrender;
|
use webrender;
|
||||||
use webrender_api::{self, DeviceIntPoint, DevicePoint, HitTestFlags, HitTestResult};
|
use webrender_api::{self, DeviceIntPoint, DevicePoint, HitTestFlags, HitTestResult};
|
||||||
|
@ -498,7 +500,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
(Msg::GetScreenAvailSize(req), ShutdownState::NotShuttingDown) => {
|
(Msg::GetScreenAvailSize(req), ShutdownState::NotShuttingDown) => {
|
||||||
if let Err(e) = req.send(self.embedder_coordinates.screen_avail) {
|
if let Err(e) = req.send(self.embedder_coordinates.screen_avail) {
|
||||||
warn!("Sending response to get screen avail size failed ({:?}).", e);
|
warn!(
|
||||||
|
"Sending response to get screen avail size failed ({:?}).",
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -839,7 +844,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
&mut self,
|
&mut self,
|
||||||
delta: ScrollLocation,
|
delta: ScrollLocation,
|
||||||
cursor: DeviceIntPoint,
|
cursor: DeviceIntPoint,
|
||||||
phase: TouchEventType
|
phase: TouchEventType,
|
||||||
) {
|
) {
|
||||||
match phase {
|
match phase {
|
||||||
TouchEventType::Move => self.on_scroll_window_event(delta, cursor),
|
TouchEventType::Move => self.on_scroll_window_event(delta, cursor),
|
||||||
|
@ -852,11 +857,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_scroll_window_event(
|
fn on_scroll_window_event(&mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint) {
|
||||||
&mut self,
|
|
||||||
scroll_location: ScrollLocation,
|
|
||||||
cursor: DeviceIntPoint
|
|
||||||
) {
|
|
||||||
self.pending_scroll_zoom_events.push(ScrollZoomEvent {
|
self.pending_scroll_zoom_events.push(ScrollZoomEvent {
|
||||||
magnification: 1.0,
|
magnification: 1.0,
|
||||||
scroll_location: scroll_location,
|
scroll_location: scroll_location,
|
||||||
|
@ -1155,15 +1156,19 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
pub fn composite(&mut self) {
|
pub fn composite(&mut self) {
|
||||||
let target = self.composite_target;
|
let target = self.composite_target;
|
||||||
match self.composite_specific_target(target) {
|
match self.composite_specific_target(target) {
|
||||||
Ok(_) => if opts::get().output_file.is_some() || opts::get().exit_after_load {
|
Ok(_) => {
|
||||||
println!("Shutting down the Constellation after generating an output file or exit flag specified");
|
if opts::get().output_file.is_some() || opts::get().exit_after_load {
|
||||||
self.start_shutting_down();
|
println!("Shutting down the Constellation after generating an output file or exit flag specified");
|
||||||
|
self.start_shutting_down();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(e) => if opts::get().is_running_problem_test {
|
Err(e) => {
|
||||||
if e != UnableToComposite::NotReadyToPaintImage(
|
if opts::get().is_running_problem_test {
|
||||||
NotReadyToPaint::WaitingOnConstellation,
|
if e != UnableToComposite::NotReadyToPaintImage(
|
||||||
) {
|
NotReadyToPaint::WaitingOnConstellation,
|
||||||
println!("not ready to composite: {:?}", e);
|
) {
|
||||||
|
println!("not ready to composite: {:?}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1255,7 +1260,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
if let Some(pipeline) = self.pipeline(*id) {
|
if let Some(pipeline) = self.pipeline(*id) {
|
||||||
// and inform the layout thread with the measured paint time.
|
// and inform the layout thread with the measured paint time.
|
||||||
let msg = LayoutControlMsg::PaintMetric(epoch, paint_time);
|
let msg = LayoutControlMsg::PaintMetric(epoch, paint_time);
|
||||||
if let Err(e) = pipeline.layout_chan.send(msg) {
|
if let Err(e) = pipeline.layout_chan.send(msg) {
|
||||||
warn!("Sending PaintMetric message to layout failed ({:?}).", e);
|
warn!("Sending PaintMetric message to layout failed ({:?}).", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1445,7 +1450,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
val.as_ref()
|
val.as_ref()
|
||||||
.map(|dir| dir.join("capture_webrender").join(&capture_id))
|
.map(|dir| dir.join("capture_webrender").join(&capture_id))
|
||||||
.ok()
|
.ok()
|
||||||
}).find(|val| match create_dir_all(&val) {
|
})
|
||||||
|
.find(|val| match create_dir_all(&val) {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Unable to create path '{:?}' for capture: {:?}", &val, err);
|
eprintln!("Unable to create path '{:?}' for capture: {:?}", &val, err);
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
//! Communication with the compositor thread.
|
//! Communication with the compositor thread.
|
||||||
|
|
||||||
use crate::SendableFrameTree;
|
|
||||||
use crate::compositor::CompositingReason;
|
use crate::compositor::CompositingReason;
|
||||||
|
use crate::SendableFrameTree;
|
||||||
use embedder_traits::EventLoopWaker;
|
use embedder_traits::EventLoopWaker;
|
||||||
use gfx_traits::Epoch;
|
use gfx_traits::Epoch;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
|
|
|
@ -29,10 +29,10 @@ extern crate time;
|
||||||
extern crate webrender;
|
extern crate webrender;
|
||||||
extern crate webrender_api;
|
extern crate webrender_api;
|
||||||
|
|
||||||
pub use crate::compositor_thread::CompositorProxy;
|
|
||||||
pub use crate::compositor::IOCompositor;
|
pub use crate::compositor::IOCompositor;
|
||||||
pub use crate::compositor::RenderNotifier;
|
pub use crate::compositor::RenderNotifier;
|
||||||
pub use crate::compositor::ShutdownState;
|
pub use crate::compositor::ShutdownState;
|
||||||
|
pub use crate::compositor_thread::CompositorProxy;
|
||||||
use euclid::TypedSize2D;
|
use euclid::TypedSize2D;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
|
|
@ -2,10 +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/. */
|
||||||
|
|
||||||
use euclid::{TypedPoint2D, TypedVector2D};
|
|
||||||
use euclid::TypedScale;
|
|
||||||
use script_traits::{EventResult, TouchId};
|
|
||||||
use self::TouchState::*;
|
use self::TouchState::*;
|
||||||
|
use euclid::TypedScale;
|
||||||
|
use euclid::{TypedPoint2D, TypedVector2D};
|
||||||
|
use script_traits::{EventResult, TouchId};
|
||||||
use style_traits::DevicePixel;
|
use style_traits::DevicePixel;
|
||||||
|
|
||||||
/// Minimum number of `DeviceIndependentPixel` to begin touch scrolling.
|
/// Minimum number of `DeviceIndependentPixel` to begin touch scrolling.
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::fmt::{Debug, Error, Formatter};
|
||||||
#[cfg(feature = "gleam")]
|
#[cfg(feature = "gleam")]
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use style_traits::DevicePixel;
|
use style_traits::DevicePixel;
|
||||||
use webrender_api::{DeviceIntPoint, DevicePoint, DeviceUintSize, DeviceUintRect, ScrollLocation};
|
use webrender_api::{DeviceIntPoint, DevicePoint, DeviceUintRect, DeviceUintSize, ScrollLocation};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum MouseWindowEvent {
|
pub enum MouseWindowEvent {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::fs::{self, File};
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
|
||||||
use url::{self, Url};
|
use url::{self, Url};
|
||||||
|
|
||||||
/// Global flags for Servo, currently set on the command line.
|
/// Global flags for Servo, currently set on the command line.
|
||||||
|
@ -814,7 +814,8 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
.or_else(|error| {
|
.or_else(|error| {
|
||||||
warn!("URL parsing failed ({:?}).", error);
|
warn!("URL parsing failed ({:?}).", error);
|
||||||
Err(error)
|
Err(error)
|
||||||
}).ok()
|
})
|
||||||
|
.ok()
|
||||||
});
|
});
|
||||||
|
|
||||||
let tile_size: usize = match opt_match.opt_str("s") {
|
let tile_size: usize = match opt_match.opt_str("s") {
|
||||||
|
@ -940,7 +941,8 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
r.parse().unwrap_or_else(|err| {
|
r.parse().unwrap_or_else(|err| {
|
||||||
args_fail(&format!("Error parsing option: --resolution ({})", err))
|
args_fail(&format!("Error parsing option: --resolution ({})", err))
|
||||||
})
|
})
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
TypedSize2D::new(res[0], res[1])
|
TypedSize2D::new(res[0], res[1])
|
||||||
},
|
},
|
||||||
None => TypedSize2D::new(1024, 740),
|
None => TypedSize2D::new(1024, 740),
|
||||||
|
@ -970,7 +972,8 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
.read_to_end(&mut contents)
|
.read_to_end(&mut contents)
|
||||||
.unwrap_or_else(|err| args_fail(&format!("Couldn't read {}: {}", filename, err)));
|
.unwrap_or_else(|err| args_fail(&format!("Couldn't read {}: {}", filename, err)));
|
||||||
(contents, url)
|
(contents, url)
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let do_not_use_native_titlebar = opt_match.opt_present("b") || !PREFS
|
let do_not_use_native_titlebar = opt_match.opt_present("b") || !PREFS
|
||||||
.get("shell.native-titlebar.enabled")
|
.get("shell.native-titlebar.enabled")
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::borrow::ToOwned;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write, stderr};
|
use std::io::{stderr, Read, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
|
@ -192,7 +192,8 @@ fn init_user_prefs(path: &mut PathBuf) {
|
||||||
writeln!(
|
writeln!(
|
||||||
&mut stderr(),
|
&mut stderr(),
|
||||||
"Error opening prefs.json from config directory"
|
"Error opening prefs.json from config directory"
|
||||||
).expect("failed printing to stderr");
|
)
|
||||||
|
.expect("failed printing to stderr");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
extern crate servo_config;
|
extern crate servo_config;
|
||||||
|
|
||||||
use servo_config::opts::{parse_url_or_filename, parse_pref_from_command_line};
|
use servo_config::opts::{parse_pref_from_command_line, parse_url_or_filename};
|
||||||
use servo_config::prefs::{PrefValue, PREFS};
|
use servo_config::prefs::{PrefValue, PREFS};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
extern crate servo_config;
|
extern crate servo_config;
|
||||||
|
|
||||||
use servo_config::basedir;
|
use servo_config::basedir;
|
||||||
use servo_config::prefs::{PREFS, PrefValue, read_prefs};
|
use servo_config::prefs::{read_prefs, PrefValue, PREFS};
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
|
|
|
@ -96,49 +96,61 @@ use canvas::webgl_thread::WebGLThreads;
|
||||||
use canvas_traits::canvas::CanvasId;
|
use canvas_traits::canvas::CanvasId;
|
||||||
use canvas_traits::canvas::CanvasMsg;
|
use canvas_traits::canvas::CanvasMsg;
|
||||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||||
use compositing::SendableFrameTree;
|
|
||||||
use compositing::compositor_thread::CompositorProxy;
|
use compositing::compositor_thread::CompositorProxy;
|
||||||
use compositing::compositor_thread::Msg as ToCompositorMsg;
|
use compositing::compositor_thread::Msg as ToCompositorMsg;
|
||||||
use crate::browsingcontext::{AllBrowsingContextsIterator, BrowsingContext, FullyActiveBrowsingContextsIterator};
|
use compositing::SendableFrameTree;
|
||||||
use crate::browsingcontext::NewBrowsingContextInfo;
|
use crate::browsingcontext::NewBrowsingContextInfo;
|
||||||
|
use crate::browsingcontext::{
|
||||||
|
AllBrowsingContextsIterator, BrowsingContext, FullyActiveBrowsingContextsIterator,
|
||||||
|
};
|
||||||
use crate::event_loop::EventLoop;
|
use crate::event_loop::EventLoop;
|
||||||
use crate::network_listener::NetworkListener;
|
use crate::network_listener::NetworkListener;
|
||||||
use crate::pipeline::{InitialPipelineState, Pipeline};
|
use crate::pipeline::{InitialPipelineState, Pipeline};
|
||||||
use crate::session_history::{JointSessionHistory, NeedsToReload, SessionHistoryChange, SessionHistoryDiff};
|
use crate::session_history::{
|
||||||
|
JointSessionHistory, NeedsToReload, SessionHistoryChange, SessionHistoryDiff,
|
||||||
|
};
|
||||||
use crate::timer_scheduler::TimerScheduler;
|
use crate::timer_scheduler::TimerScheduler;
|
||||||
use debugger;
|
use debugger;
|
||||||
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg};
|
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg};
|
||||||
use embedder_traits::{EmbedderMsg, EmbedderProxy};
|
use embedder_traits::{EmbedderMsg, EmbedderProxy};
|
||||||
use euclid::{Size2D, TypedSize2D, TypedScale};
|
use euclid::{Size2D, TypedScale, TypedSize2D};
|
||||||
use gfx::font_cache_thread::FontCacheThread;
|
use gfx::font_cache_thread::FontCacheThread;
|
||||||
use gfx_traits::Epoch;
|
use gfx_traits::Epoch;
|
||||||
use ipc_channel::{Error as IpcError};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use ipc_channel::ipc::{self, IpcSender, IpcReceiver};
|
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
|
use ipc_channel::Error as IpcError;
|
||||||
use keyboard_types::KeyboardEvent;
|
use keyboard_types::KeyboardEvent;
|
||||||
use layout_traits::LayoutThreadFactory;
|
use layout_traits::LayoutThreadFactory;
|
||||||
use log::{Log, Level, LevelFilter, Metadata, Record};
|
use log::{Level, LevelFilter, Log, Metadata, Record};
|
||||||
use msg::constellation_msg::{BrowsingContextId, PipelineId, HistoryStateId, TopLevelBrowsingContextId};
|
use msg::constellation_msg::{
|
||||||
|
BrowsingContextId, HistoryStateId, PipelineId, TopLevelBrowsingContextId,
|
||||||
|
};
|
||||||
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, TraversalDirection};
|
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, TraversalDirection};
|
||||||
use net_traits::{self, IpcSend, FetchResponseMsg, ResourceThreads};
|
|
||||||
use net_traits::pub_domains::reg_host;
|
use net_traits::pub_domains::reg_host;
|
||||||
use net_traits::request::RequestInit;
|
use net_traits::request::RequestInit;
|
||||||
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
|
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
|
||||||
|
use net_traits::{self, FetchResponseMsg, IpcSend, ResourceThreads};
|
||||||
use profile_traits::mem;
|
use profile_traits::mem;
|
||||||
use profile_traits::time;
|
use profile_traits::time;
|
||||||
use script_traits::{AnimationState, AuxiliaryBrowsingContextLoadInfo, AnimationTickType, CompositorEvent};
|
use script_traits::{webdriver_msg, LogEntry, ScriptToConstellationChan, ServiceWorkerMsg};
|
||||||
use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorMsg, DiscardBrowsingContext};
|
use script_traits::{
|
||||||
|
AnimationState, AnimationTickType, AuxiliaryBrowsingContextLoadInfo, CompositorEvent,
|
||||||
|
};
|
||||||
|
use script_traits::{
|
||||||
|
ConstellationControlMsg, ConstellationMsg as FromCompositorMsg, DiscardBrowsingContext,
|
||||||
|
};
|
||||||
use script_traits::{DocumentActivity, DocumentState, LayoutControlMsg, LoadData};
|
use script_traits::{DocumentActivity, DocumentState, LayoutControlMsg, LoadData};
|
||||||
use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerSchedulerMsg};
|
use script_traits::{
|
||||||
|
IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerSchedulerMsg,
|
||||||
|
};
|
||||||
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
|
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
|
||||||
use script_traits::{LogEntry, ScriptToConstellationChan, ServiceWorkerMsg, webdriver_msg};
|
|
||||||
use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg};
|
use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg};
|
||||||
use script_traits::{WindowSizeData, WindowSizeType};
|
use script_traits::{WindowSizeData, WindowSizeType};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_channel::{Receiver, Sender, channel};
|
use servo_channel::{channel, Receiver, Sender};
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use servo_config::prefs::PREFS;
|
use servo_config::prefs::PREFS;
|
||||||
use servo_rand::{Rng, SeedableRng, ServoRng, random};
|
use servo_rand::{random, Rng, SeedableRng, ServoRng};
|
||||||
use servo_remutex::ReentrantMutex;
|
use servo_remutex::ReentrantMutex;
|
||||||
use servo_url::{Host, ImmutableOrigin, ServoUrl};
|
use servo_url::{Host, ImmutableOrigin, ServoUrl};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
|
@ -149,9 +161,9 @@ use std::process;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use style_traits::CSSPixel;
|
|
||||||
use style_traits::cursor::CursorKind;
|
use style_traits::cursor::CursorKind;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
use style_traits::viewport::ViewportConstraints;
|
||||||
|
use style_traits::CSSPixel;
|
||||||
use webrender_api;
|
use webrender_api;
|
||||||
use webvr_traits::{WebVREvent, WebVRMsg};
|
use webvr_traits::{WebVREvent, WebVRMsg};
|
||||||
|
|
||||||
|
@ -718,9 +730,8 @@ where
|
||||||
match reg_host(&load_data.url) {
|
match reg_host(&load_data.url) {
|
||||||
None => (None, None),
|
None => (None, None),
|
||||||
Some(host) => {
|
Some(host) => {
|
||||||
let event_loop = self
|
let event_loop =
|
||||||
.event_loops.get(&host)
|
self.event_loops.get(&host).and_then(|weak| weak.upgrade());
|
||||||
.and_then(|weak| weak.upgrade());
|
|
||||||
match event_loop {
|
match event_loop {
|
||||||
None => (None, Some(host)),
|
None => (None, Some(host)),
|
||||||
Some(event_loop) => (Some(event_loop.clone()), None),
|
Some(event_loop) => (Some(event_loop.clone()), None),
|
||||||
|
@ -855,7 +866,8 @@ where
|
||||||
is_private,
|
is_private,
|
||||||
is_visible,
|
is_visible,
|
||||||
);
|
);
|
||||||
self.browsing_contexts.insert(browsing_context_id, browsing_context);
|
self.browsing_contexts
|
||||||
|
.insert(browsing_context_id, browsing_context);
|
||||||
|
|
||||||
// If this context is a nested container, attach it to parent pipeline.
|
// If this context is a nested container, attach it to parent pipeline.
|
||||||
if let Some(parent_pipeline_id) = parent_pipeline_id {
|
if let Some(parent_pipeline_id) = parent_pipeline_id {
|
||||||
|
@ -866,7 +878,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_pending_change(&mut self, change: SessionHistoryChange) {
|
fn add_pending_change(&mut self, change: SessionHistoryChange) {
|
||||||
self.handle_load_start_msg(change.top_level_browsing_context_id, change.browsing_context_id);
|
self.handle_load_start_msg(
|
||||||
|
change.top_level_browsing_context_id,
|
||||||
|
change.browsing_context_id,
|
||||||
|
);
|
||||||
self.pending_changes.push(change);
|
self.pending_changes.push(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,14 +1244,22 @@ where
|
||||||
.and_then(|pipeline| self.browsing_contexts.get(&pipeline.browsing_context_id))
|
.and_then(|pipeline| self.browsing_contexts.get(&pipeline.browsing_context_id))
|
||||||
.map(|ctx| (ctx.id, ctx.parent_pipeline_id));
|
.map(|ctx| (ctx.id, ctx.parent_pipeline_id));
|
||||||
if let Err(e) = sender.send(result) {
|
if let Err(e) = sender.send(result) {
|
||||||
warn!("Sending reply to get browsing context info failed ({:?}).", e);
|
warn!(
|
||||||
|
"Sending reply to get browsing context info failed ({:?}).",
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FromScriptMsg::GetTopForBrowsingContext(browsing_context_id, sender) => {
|
FromScriptMsg::GetTopForBrowsingContext(browsing_context_id, sender) => {
|
||||||
let result = self.browsing_contexts.get(&browsing_context_id)
|
let result = self
|
||||||
|
.browsing_contexts
|
||||||
|
.get(&browsing_context_id)
|
||||||
.and_then(|bc| Some(bc.top_level_id));
|
.and_then(|bc| Some(bc.top_level_id));
|
||||||
if let Err(e) = sender.send(result) {
|
if let Err(e) = sender.send(result) {
|
||||||
warn!("Sending reply to get top for browsing context info failed ({:?}).", e);
|
warn!(
|
||||||
|
"Sending reply to get top for browsing context info failed ({:?}).",
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FromScriptMsg::GetChildBrowsingContextId(browsing_context_id, index, sender) => {
|
FromScriptMsg::GetChildBrowsingContextId(browsing_context_id, index, sender) => {
|
||||||
|
@ -1641,11 +1664,14 @@ where
|
||||||
fn handle_new_top_level_browsing_context(
|
fn handle_new_top_level_browsing_context(
|
||||||
&mut self,
|
&mut self,
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
top_level_browsing_context_id: TopLevelBrowsingContextId
|
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||||
) {
|
) {
|
||||||
let window_size = self.window_size.initial_viewport;
|
let window_size = self.window_size.initial_viewport;
|
||||||
let pipeline_id = PipelineId::new();
|
let pipeline_id = PipelineId::new();
|
||||||
let msg = (Some(top_level_browsing_context_id), EmbedderMsg::BrowserCreated(top_level_browsing_context_id));
|
let msg = (
|
||||||
|
Some(top_level_browsing_context_id),
|
||||||
|
EmbedderMsg::BrowserCreated(top_level_browsing_context_id),
|
||||||
|
);
|
||||||
self.embedder_proxy.send(msg);
|
self.embedder_proxy.send(msg);
|
||||||
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
||||||
let load_data = LoadData::new(url.clone(), None, None, None);
|
let load_data = LoadData::new(url.clone(), None, None, None);
|
||||||
|
@ -1655,10 +1681,13 @@ where
|
||||||
|
|
||||||
// Register this new top-level browsing context id as a browser and set
|
// Register this new top-level browsing context id as a browser and set
|
||||||
// its focused browsing context to be itself.
|
// its focused browsing context to be itself.
|
||||||
self.browsers.insert(top_level_browsing_context_id, Browser {
|
self.browsers.insert(
|
||||||
focused_browsing_context_id: browsing_context_id,
|
top_level_browsing_context_id,
|
||||||
session_history: JointSessionHistory::new(),
|
Browser {
|
||||||
});
|
focused_browsing_context_id: browsing_context_id,
|
||||||
|
session_history: JointSessionHistory::new(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
self.new_pipeline(
|
self.new_pipeline(
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
|
@ -1718,11 +1747,12 @@ where
|
||||||
};
|
};
|
||||||
let parent_pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
let parent_pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(browsing_context) => browsing_context.parent_pipeline_id,
|
Some(browsing_context) => browsing_context.parent_pipeline_id,
|
||||||
None => return warn!(
|
None => {
|
||||||
"Subframe {} loaded in closed browsing context {}.",
|
return warn!(
|
||||||
pipeline_id,
|
"Subframe {} loaded in closed browsing context {}.",
|
||||||
browsing_context_id,
|
pipeline_id, browsing_context_id,
|
||||||
),
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let parent_pipeline_id = match parent_pipeline_id {
|
let parent_pipeline_id = match parent_pipeline_id {
|
||||||
Some(parent_pipeline_id) => parent_pipeline_id,
|
Some(parent_pipeline_id) => parent_pipeline_id,
|
||||||
|
@ -1779,7 +1809,8 @@ where
|
||||||
|
|
||||||
let (load_data, is_private) = {
|
let (load_data, is_private) = {
|
||||||
// If no url is specified, reload.
|
// If no url is specified, reload.
|
||||||
let old_pipeline = load_info.old_pipeline_id
|
let old_pipeline = load_info
|
||||||
|
.old_pipeline_id
|
||||||
.and_then(|id| self.pipelines.get(&id));
|
.and_then(|id| self.pipelines.get(&id));
|
||||||
let load_data = load_info.load_data.unwrap_or_else(|| {
|
let load_data = load_info.load_data.unwrap_or_else(|| {
|
||||||
let url = match old_pipeline {
|
let url = match old_pipeline {
|
||||||
|
@ -1792,23 +1823,25 @@ where
|
||||||
});
|
});
|
||||||
|
|
||||||
let is_parent_private = {
|
let is_parent_private = {
|
||||||
let parent_browsing_context_id =
|
let parent_browsing_context_id = match self.pipelines.get(&parent_pipeline_id) {
|
||||||
match self.pipelines.get(&parent_pipeline_id) {
|
Some(pipeline) => pipeline.browsing_context_id,
|
||||||
Some(pipeline) => pipeline.browsing_context_id,
|
None => {
|
||||||
None => return warn!(
|
return warn!(
|
||||||
"Script loaded url in iframe {} in closed parent pipeline {}.",
|
"Script loaded url in iframe {} in closed parent pipeline {}.",
|
||||||
browsing_context_id,
|
browsing_context_id, parent_pipeline_id,
|
||||||
parent_pipeline_id,
|
)
|
||||||
),
|
},
|
||||||
};
|
};
|
||||||
let is_parent_private =
|
let is_parent_private =
|
||||||
match self.browsing_contexts.get(&parent_browsing_context_id) {
|
match self.browsing_contexts.get(&parent_browsing_context_id) {
|
||||||
Some(ctx) => ctx.is_private,
|
Some(ctx) => ctx.is_private,
|
||||||
None => return warn!(
|
None => {
|
||||||
|
return warn!(
|
||||||
"Script loaded url in iframe {} in closed parent browsing context {}.",
|
"Script loaded url in iframe {} in closed parent browsing context {}.",
|
||||||
browsing_context_id,
|
browsing_context_id,
|
||||||
parent_browsing_context_id,
|
parent_browsing_context_id,
|
||||||
),
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
is_parent_private
|
is_parent_private
|
||||||
};
|
};
|
||||||
|
@ -1820,10 +1853,12 @@ where
|
||||||
let (replace, window_size, is_visible) = {
|
let (replace, window_size, is_visible) = {
|
||||||
let browsing_context = match self.browsing_contexts.get(&browsing_context_id) {
|
let browsing_context = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(ctx) => ctx,
|
Some(ctx) => ctx,
|
||||||
None => return warn!(
|
None => {
|
||||||
"Script loaded url in iframe with closed browsing context {}.",
|
return warn!(
|
||||||
browsing_context_id,
|
"Script loaded url in iframe with closed browsing context {}.",
|
||||||
),
|
browsing_context_id,
|
||||||
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let replace = if replace {
|
let replace = if replace {
|
||||||
Some(NeedsToReload::No(browsing_context.pipeline_id))
|
Some(NeedsToReload::No(browsing_context.pipeline_id))
|
||||||
|
@ -1876,19 +1911,22 @@ where
|
||||||
let load_data = LoadData::new(url.clone(), Some(parent_pipeline_id), None, None);
|
let load_data = LoadData::new(url.clone(), Some(parent_pipeline_id), None, None);
|
||||||
|
|
||||||
let (pipeline, is_private, is_visible) = {
|
let (pipeline, is_private, is_visible) = {
|
||||||
let (script_sender, parent_browsing_context_id) =
|
let (script_sender, parent_browsing_context_id) = match self
|
||||||
match self.pipelines.get(&parent_pipeline_id) {
|
.pipelines
|
||||||
Some(pipeline) => (pipeline.event_loop.clone(), pipeline.browsing_context_id),
|
.get(&parent_pipeline_id)
|
||||||
None => return warn!("Script loaded url in closed iframe {}.", parent_pipeline_id),
|
{
|
||||||
};
|
Some(pipeline) => (pipeline.event_loop.clone(), pipeline.browsing_context_id),
|
||||||
|
None => return warn!("Script loaded url in closed iframe {}.", parent_pipeline_id),
|
||||||
|
};
|
||||||
let (is_parent_private, is_parent_visible) =
|
let (is_parent_private, is_parent_visible) =
|
||||||
match self.browsing_contexts.get(&parent_browsing_context_id) {
|
match self.browsing_contexts.get(&parent_browsing_context_id) {
|
||||||
Some(ctx) => (ctx.is_private, ctx.is_visible),
|
Some(ctx) => (ctx.is_private, ctx.is_visible),
|
||||||
None => return warn!(
|
None => {
|
||||||
"New iframe {} loaded in closed parent browsing context {}.",
|
return warn!(
|
||||||
browsing_context_id,
|
"New iframe {} loaded in closed parent browsing context {}.",
|
||||||
parent_browsing_context_id,
|
browsing_context_id, parent_browsing_context_id,
|
||||||
),
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let is_private = is_private || is_parent_private;
|
let is_private = is_private || is_parent_private;
|
||||||
let pipeline = Pipeline::new(
|
let pipeline = Pipeline::new(
|
||||||
|
@ -1923,9 +1961,11 @@ where
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_script_new_auxiliary(&mut self,
|
fn handle_script_new_auxiliary(
|
||||||
load_info: AuxiliaryBrowsingContextLoadInfo,
|
&mut self,
|
||||||
layout_sender: IpcSender<LayoutControlMsg>) {
|
load_info: AuxiliaryBrowsingContextLoadInfo,
|
||||||
|
layout_sender: IpcSender<LayoutControlMsg>,
|
||||||
|
) {
|
||||||
let AuxiliaryBrowsingContextLoadInfo {
|
let AuxiliaryBrowsingContextLoadInfo {
|
||||||
opener_pipeline_id,
|
opener_pipeline_id,
|
||||||
new_top_level_browsing_context_id,
|
new_top_level_browsing_context_id,
|
||||||
|
@ -1942,19 +1982,22 @@ where
|
||||||
let (script_sender, opener_browsing_context_id) =
|
let (script_sender, opener_browsing_context_id) =
|
||||||
match self.pipelines.get(&opener_pipeline_id) {
|
match self.pipelines.get(&opener_pipeline_id) {
|
||||||
Some(pipeline) => (pipeline.event_loop.clone(), pipeline.browsing_context_id),
|
Some(pipeline) => (pipeline.event_loop.clone(), pipeline.browsing_context_id),
|
||||||
None => return warn!(
|
None => {
|
||||||
"Auxiliary loaded url in closed iframe {}.",
|
return warn!(
|
||||||
opener_pipeline_id
|
"Auxiliary loaded url in closed iframe {}.",
|
||||||
),
|
opener_pipeline_id
|
||||||
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let (is_opener_private, is_opener_visible) =
|
let (is_opener_private, is_opener_visible) =
|
||||||
match self.browsing_contexts.get(&opener_browsing_context_id) {
|
match self.browsing_contexts.get(&opener_browsing_context_id) {
|
||||||
Some(ctx) => (ctx.is_private, ctx.is_visible),
|
Some(ctx) => (ctx.is_private, ctx.is_visible),
|
||||||
None => return warn!(
|
None => {
|
||||||
"New auxiliary {} loaded in closed opener browsing context {}.",
|
return warn!(
|
||||||
new_browsing_context_id,
|
"New auxiliary {} loaded in closed opener browsing context {}.",
|
||||||
opener_browsing_context_id,
|
new_browsing_context_id, opener_browsing_context_id,
|
||||||
),
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let pipeline = Pipeline::new(
|
let pipeline = Pipeline::new(
|
||||||
new_pipeline_id,
|
new_pipeline_id,
|
||||||
|
@ -1966,7 +2009,7 @@ where
|
||||||
self.compositor_proxy.clone(),
|
self.compositor_proxy.clone(),
|
||||||
url,
|
url,
|
||||||
is_opener_visible,
|
is_opener_visible,
|
||||||
load_data
|
load_data,
|
||||||
);
|
);
|
||||||
|
|
||||||
(pipeline, is_opener_private, is_opener_visible)
|
(pipeline, is_opener_private, is_opener_visible)
|
||||||
|
@ -1974,10 +2017,13 @@ where
|
||||||
|
|
||||||
assert!(!self.pipelines.contains_key(&new_pipeline_id));
|
assert!(!self.pipelines.contains_key(&new_pipeline_id));
|
||||||
self.pipelines.insert(new_pipeline_id, pipeline);
|
self.pipelines.insert(new_pipeline_id, pipeline);
|
||||||
self.browsers.insert(new_top_level_browsing_context_id, Browser {
|
self.browsers.insert(
|
||||||
focused_browsing_context_id: new_browsing_context_id,
|
new_top_level_browsing_context_id,
|
||||||
session_history: JointSessionHistory::new(),
|
Browser {
|
||||||
});
|
focused_browsing_context_id: new_browsing_context_id,
|
||||||
|
session_history: JointSessionHistory::new(),
|
||||||
|
},
|
||||||
|
);
|
||||||
self.add_pending_change(SessionHistoryChange {
|
self.add_pending_change(SessionHistoryChange {
|
||||||
top_level_browsing_context_id: new_top_level_browsing_context_id,
|
top_level_browsing_context_id: new_top_level_browsing_context_id,
|
||||||
browsing_context_id: new_browsing_context_id,
|
browsing_context_id: new_browsing_context_id,
|
||||||
|
@ -2098,8 +2144,7 @@ where
|
||||||
// against future changes that might break things.
|
// against future changes that might break things.
|
||||||
warn!(
|
warn!(
|
||||||
"Pipeline {} loaded url in closed browsing context {}.",
|
"Pipeline {} loaded url in closed browsing context {}.",
|
||||||
source_id,
|
source_id, browsing_context_id,
|
||||||
browsing_context_id,
|
|
||||||
);
|
);
|
||||||
return None;
|
return None;
|
||||||
},
|
},
|
||||||
|
@ -2448,12 +2493,13 @@ where
|
||||||
|
|
||||||
// TODO: Save the sandbox state so it can be restored here.
|
// TODO: Save the sandbox state so it can be restored here.
|
||||||
let sandbox = IFrameSandboxState::IFrameUnsandboxed;
|
let sandbox = IFrameSandboxState::IFrameUnsandboxed;
|
||||||
let (top_level_id,
|
let (
|
||||||
old_pipeline_id,
|
top_level_id,
|
||||||
parent_pipeline_id,
|
old_pipeline_id,
|
||||||
window_size,
|
parent_pipeline_id,
|
||||||
is_private,
|
window_size,
|
||||||
is_visible
|
is_private,
|
||||||
|
is_visible,
|
||||||
) = match self.browsing_contexts.get(&browsing_context_id) {
|
) = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(ctx) => (
|
Some(ctx) => (
|
||||||
ctx.top_level_id,
|
ctx.top_level_id,
|
||||||
|
@ -2651,18 +2697,19 @@ where
|
||||||
let event = CompositorEvent::KeyboardEvent(event);
|
let event = CompositorEvent::KeyboardEvent(event);
|
||||||
let pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
let pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(ctx) => ctx.pipeline_id,
|
Some(ctx) => ctx.pipeline_id,
|
||||||
None => return warn!(
|
None => {
|
||||||
"Got key event for nonexistent browsing context {}.",
|
return warn!(
|
||||||
browsing_context_id,
|
"Got key event for nonexistent browsing context {}.",
|
||||||
),
|
browsing_context_id,
|
||||||
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let msg = ConstellationControlMsg::SendEvent(pipeline_id, event);
|
let msg = ConstellationControlMsg::SendEvent(pipeline_id, event);
|
||||||
let result = match self.pipelines.get(&pipeline_id) {
|
let result = match self.pipelines.get(&pipeline_id) {
|
||||||
Some(pipeline) => pipeline.event_loop.send(msg),
|
Some(pipeline) => pipeline.event_loop.send(msg),
|
||||||
None => return debug!(
|
None => {
|
||||||
"Pipeline {:?} got key event after closure.",
|
return debug!("Pipeline {:?} got key event after closure.", pipeline_id)
|
||||||
pipeline_id
|
},
|
||||||
),
|
|
||||||
};
|
};
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
self.handle_send_error(pipeline_id, e);
|
self.handle_send_error(pipeline_id, e);
|
||||||
|
@ -2771,10 +2818,12 @@ where
|
||||||
Some(browser) => {
|
Some(browser) => {
|
||||||
browser.focused_browsing_context_id = browsing_context_id;
|
browser.focused_browsing_context_id = browsing_context_id;
|
||||||
},
|
},
|
||||||
None => return warn!(
|
None => {
|
||||||
"Browser {} for focus msg does not exist",
|
return warn!(
|
||||||
top_level_browsing_context_id
|
"Browser {} for focus msg does not exist",
|
||||||
),
|
top_level_browsing_context_id
|
||||||
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Focus parent iframes recursively
|
// Focus parent iframes recursively
|
||||||
|
@ -2784,17 +2833,21 @@ where
|
||||||
fn focus_parent_pipeline(&mut self, browsing_context_id: BrowsingContextId) {
|
fn focus_parent_pipeline(&mut self, browsing_context_id: BrowsingContextId) {
|
||||||
let parent_pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
let parent_pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(ctx) => ctx.parent_pipeline_id,
|
Some(ctx) => ctx.parent_pipeline_id,
|
||||||
None => return warn!(
|
None => {
|
||||||
"Browsing context {:?} focus parent after closure.",
|
return warn!(
|
||||||
browsing_context_id
|
"Browsing context {:?} focus parent after closure.",
|
||||||
),
|
browsing_context_id
|
||||||
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let parent_pipeline_id = match parent_pipeline_id {
|
let parent_pipeline_id = match parent_pipeline_id {
|
||||||
Some(parent_id) => parent_id,
|
Some(parent_id) => parent_id,
|
||||||
None => return debug!(
|
None => {
|
||||||
"Browsing context {:?} focus has no parent.",
|
return debug!(
|
||||||
browsing_context_id
|
"Browsing context {:?} focus has no parent.",
|
||||||
),
|
browsing_context_id
|
||||||
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send a message to the parent of the provided browsing context (if it
|
// Send a message to the parent of the provided browsing context (if it
|
||||||
|
@ -2864,7 +2917,12 @@ where
|
||||||
};
|
};
|
||||||
let parent_pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
let parent_pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(ctx) => ctx.parent_pipeline_id,
|
Some(ctx) => ctx.parent_pipeline_id,
|
||||||
None => return warn!("Visibility change for closed browsing context {:?}.", pipeline_id),
|
None => {
|
||||||
|
return warn!(
|
||||||
|
"Visibility change for closed browsing context {:?}.",
|
||||||
|
pipeline_id
|
||||||
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(parent_pipeline_id) = parent_pipeline_id {
|
if let Some(parent_pipeline_id) = parent_pipeline_id {
|
||||||
|
@ -3294,7 +3352,7 @@ where
|
||||||
|
|
||||||
fn focused_browsing_context_is_descendant_of(
|
fn focused_browsing_context_is_descendant_of(
|
||||||
&self,
|
&self,
|
||||||
browsing_context_id: BrowsingContextId
|
browsing_context_id: BrowsingContextId,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let focused_browsing_context_id = self
|
let focused_browsing_context_id = self
|
||||||
.active_browser_id
|
.active_browser_id
|
||||||
|
@ -3389,11 +3447,12 @@ where
|
||||||
// This is an existing browsing context.
|
// This is an existing browsing context.
|
||||||
None => match self.browsing_contexts.get(&change.browsing_context_id) {
|
None => match self.browsing_contexts.get(&change.browsing_context_id) {
|
||||||
Some(ctx) => ctx.parent_pipeline_id,
|
Some(ctx) => ctx.parent_pipeline_id,
|
||||||
None => return warn!(
|
None => {
|
||||||
"Activated document {} after browsing context {} closure.",
|
return warn!(
|
||||||
change.new_pipeline_id,
|
"Activated document {} after browsing context {} closure.",
|
||||||
change.browsing_context_id,
|
change.new_pipeline_id, change.browsing_context_id,
|
||||||
),
|
)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if let Some(parent_pipeline_id) = parent_pipeline_id {
|
if let Some(parent_pipeline_id) = parent_pipeline_id {
|
||||||
|
@ -3638,12 +3697,14 @@ where
|
||||||
new_size,
|
new_size,
|
||||||
size_type,
|
size_type,
|
||||||
));
|
));
|
||||||
let pipeline_ids = browsing_context.pipelines
|
let pipeline_ids = browsing_context
|
||||||
|
.pipelines
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|pipeline_id| **pipeline_id != pipeline.id);
|
.filter(|pipeline_id| **pipeline_id != pipeline.id);
|
||||||
for id in pipeline_ids {
|
for id in pipeline_ids {
|
||||||
if let Some(pipeline) = self.pipelines.get(&id) {
|
if let Some(pipeline) = self.pipelines.get(&id) {
|
||||||
let _ = pipeline.event_loop
|
let _ = pipeline
|
||||||
|
.event_loop
|
||||||
.send(ConstellationControlMsg::ResizeInactive(
|
.send(ConstellationControlMsg::ResizeInactive(
|
||||||
pipeline.id,
|
pipeline.id,
|
||||||
new_size,
|
new_size,
|
||||||
|
@ -3757,11 +3818,12 @@ where
|
||||||
NeedsToReload::Yes(pipeline_id, load_data),
|
NeedsToReload::Yes(pipeline_id, load_data),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
None => return warn!(
|
None => {
|
||||||
"Discarding pipeline {} after browser {} closure",
|
return warn!(
|
||||||
pipeline_id,
|
"Discarding pipeline {} after browser {} closure",
|
||||||
top_level_browsing_context_id,
|
pipeline_id, top_level_browsing_context_id,
|
||||||
),
|
)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
self.close_pipeline(
|
self.close_pipeline(
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
|
@ -3844,8 +3906,10 @@ where
|
||||||
// Randomly close a pipeline -if --random-pipeline-closure-probability is set
|
// Randomly close a pipeline -if --random-pipeline-closure-probability is set
|
||||||
fn maybe_close_random_pipeline(&mut self) {
|
fn maybe_close_random_pipeline(&mut self) {
|
||||||
match self.random_pipeline_closure {
|
match self.random_pipeline_closure {
|
||||||
Some((ref mut rng, probability)) => if probability <= rng.gen::<f32>() {
|
Some((ref mut rng, probability)) => {
|
||||||
return;
|
if probability <= rng.gen::<f32>() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
@ -3881,7 +3945,8 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
top_level_id: TopLevelBrowsingContextId,
|
top_level_id: TopLevelBrowsingContextId,
|
||||||
) -> &mut JointSessionHistory {
|
) -> &mut JointSessionHistory {
|
||||||
&mut self.browsers
|
&mut self
|
||||||
|
.browsers
|
||||||
.entry(top_level_id)
|
.entry(top_level_id)
|
||||||
// This shouldn't be necessary since `get_joint_session_history` is
|
// This shouldn't be necessary since `get_joint_session_history` is
|
||||||
// invoked for existing browsers but we need this to satisfy the
|
// invoked for existing browsers but we need this to satisfy the
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
//! view of a script thread. When an `EventLoop` is dropped, an `ExitScriptThread`
|
//! view of a script thread. When an `EventLoop` is dropped, an `ExitScriptThread`
|
||||||
//! message is sent to the script thread, asking it to shut down.
|
//! message is sent to the script thread, asking it to shut down.
|
||||||
|
|
||||||
use ipc_channel::Error;
|
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
|
use ipc_channel::Error;
|
||||||
use script_traits::ConstellationControlMsg;
|
use script_traits::ConstellationControlMsg;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
|
@ -53,7 +53,9 @@ mod sandboxing;
|
||||||
mod session_history;
|
mod session_history;
|
||||||
mod timer_scheduler;
|
mod timer_scheduler;
|
||||||
|
|
||||||
pub use crate::constellation::{Constellation, FromCompositorLogger, FromScriptLogger, InitialConstellationState};
|
pub use crate::constellation::{
|
||||||
|
Constellation, FromCompositorLogger, FromScriptLogger, InitialConstellationState,
|
||||||
|
};
|
||||||
pub use crate::pipeline::UnprivilegedPipelineContent;
|
pub use crate::pipeline::UnprivilegedPipelineContent;
|
||||||
#[cfg(all(not(target_os = "windows"), not(target_os = "ios")))]
|
#[cfg(all(not(target_os = "windows"), not(target_os = "ios")))]
|
||||||
pub use crate::sandboxing::content_process_sandbox_profile;
|
pub use crate::sandboxing::content_process_sandbox_profile;
|
||||||
|
|
|
@ -11,10 +11,10 @@ use ipc_channel::ipc;
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use net::http_loader::{set_default_accept, set_default_accept_language};
|
use net::http_loader::{set_default_accept, set_default_accept_language};
|
||||||
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseMsg};
|
|
||||||
use net_traits::{IpcSend, NetworkError, ResourceThreads};
|
|
||||||
use net_traits::request::{Destination, RequestInit};
|
use net_traits::request::{Destination, RequestInit};
|
||||||
use net_traits::response::ResponseInit;
|
use net_traits::response::ResponseInit;
|
||||||
|
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseMsg};
|
||||||
|
use net_traits::{IpcSend, NetworkError, ResourceThreads};
|
||||||
use servo_channel::Sender;
|
use servo_channel::Sender;
|
||||||
|
|
||||||
pub struct NetworkListener {
|
pub struct NetworkListener {
|
||||||
|
@ -113,7 +113,9 @@ impl NetworkListener {
|
||||||
location_url: metadata.location_url.clone(),
|
location_url: metadata.location_url.clone(),
|
||||||
headers: headers.clone().into_inner(),
|
headers: headers.clone().into_inner(),
|
||||||
referrer: metadata.referrer.clone(),
|
referrer: metadata.referrer.clone(),
|
||||||
status_code: metadata.status.as_ref()
|
status_code: metadata
|
||||||
|
.status
|
||||||
|
.as_ref()
|
||||||
.map(|&(code, _)| code)
|
.map(|&(code, _)| code)
|
||||||
.unwrap_or(200),
|
.unwrap_or(200),
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,23 +4,23 @@
|
||||||
|
|
||||||
use bluetooth_traits::BluetoothRequest;
|
use bluetooth_traits::BluetoothRequest;
|
||||||
use canvas_traits::webgl::WebGLPipeline;
|
use canvas_traits::webgl::WebGLPipeline;
|
||||||
|
use compositing::compositor_thread::Msg as CompositorMsg;
|
||||||
use compositing::CompositionPipeline;
|
use compositing::CompositionPipeline;
|
||||||
use compositing::CompositorProxy;
|
use compositing::CompositorProxy;
|
||||||
use compositing::compositor_thread::Msg as CompositorMsg;
|
|
||||||
use crate::event_loop::EventLoop;
|
use crate::event_loop::EventLoop;
|
||||||
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
|
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
|
||||||
use euclid::{TypedSize2D, TypedScale};
|
use euclid::{TypedScale, TypedSize2D};
|
||||||
use gfx::font_cache_thread::FontCacheThread;
|
use gfx::font_cache_thread::FontCacheThread;
|
||||||
use ipc_channel::Error;
|
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
|
use ipc_channel::Error;
|
||||||
use layout_traits::LayoutThreadFactory;
|
use layout_traits::LayoutThreadFactory;
|
||||||
use metrics::PaintTimeMetrics;
|
use metrics::PaintTimeMetrics;
|
||||||
use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId, PipelineNamespaceId};
|
|
||||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||||
|
use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId, PipelineNamespaceId};
|
||||||
use net::image_cache::ImageCacheImpl;
|
use net::image_cache::ImageCacheImpl;
|
||||||
use net_traits::{IpcSend, ResourceThreads};
|
|
||||||
use net_traits::image_cache::ImageCache;
|
use net_traits::image_cache::ImageCache;
|
||||||
|
use net_traits::{IpcSend, ResourceThreads};
|
||||||
use profile_traits::mem as profile_mem;
|
use profile_traits::mem as profile_mem;
|
||||||
use profile_traits::time;
|
use profile_traits::time;
|
||||||
use script_traits::{ConstellationControlMsg, DiscardBrowsingContext, ScriptToConstellationChan};
|
use script_traits::{ConstellationControlMsg, DiscardBrowsingContext, ScriptToConstellationChan};
|
||||||
|
@ -30,7 +30,7 @@ use script_traits::{NewLayoutInfo, SWManagerMsg, SWManagerSenders};
|
||||||
use script_traits::{ScriptThreadFactory, TimerSchedulerMsg, WindowSizeData};
|
use script_traits::{ScriptThreadFactory, TimerSchedulerMsg, WindowSizeData};
|
||||||
use servo_channel::Sender;
|
use servo_channel::Sender;
|
||||||
use servo_config::opts::{self, Opts};
|
use servo_config::opts::{self, Opts};
|
||||||
use servo_config::prefs::{PREFS, Pref};
|
use servo_config::prefs::{Pref, PREFS};
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
@ -240,10 +240,12 @@ impl Pipeline {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Cast to ScriptToDevtoolsControlMsg failed ({}).", e)
|
error!("Cast to ScriptToDevtoolsControlMsg failed ({}).", e)
|
||||||
},
|
},
|
||||||
Ok(message) => if let Err(e) =
|
Ok(message) => {
|
||||||
devtools_chan.send(DevtoolsControlMsg::FromScript(message))
|
if let Err(e) =
|
||||||
{
|
devtools_chan.send(DevtoolsControlMsg::FromScript(message))
|
||||||
warn!("Sending to devtools failed ({:?})", e)
|
{
|
||||||
|
warn!("Sending to devtools failed ({:?})", e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -430,8 +432,7 @@ impl Pipeline {
|
||||||
|
|
||||||
/// Notify the script thread that this pipeline is visible.
|
/// Notify the script thread that this pipeline is visible.
|
||||||
pub fn notify_visibility(&self, is_visible: bool) {
|
pub fn notify_visibility(&self, is_visible: bool) {
|
||||||
let script_msg =
|
let script_msg = ConstellationControlMsg::ChangeFrameVisibilityStatus(self.id, is_visible);
|
||||||
ConstellationControlMsg::ChangeFrameVisibilityStatus(self.id, is_visible);
|
|
||||||
let compositor_msg = CompositorMsg::PipelineVisibilityChanged(self.id, is_visible);
|
let compositor_msg = CompositorMsg::PipelineVisibilityChanged(self.id, is_visible);
|
||||||
let err = self.event_loop.send(script_msg);
|
let err = self.event_loop.send(script_msg);
|
||||||
if let Err(e) = err {
|
if let Err(e) = err {
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::browsingcontext::NewBrowsingContextInfo;
|
use crate::browsingcontext::NewBrowsingContextInfo;
|
||||||
use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId, TopLevelBrowsingContextId};
|
use msg::constellation_msg::{
|
||||||
|
BrowsingContextId, HistoryStateId, PipelineId, TopLevelBrowsingContextId,
|
||||||
|
};
|
||||||
use script_traits::LoadData;
|
use script_traits::LoadData;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::{fmt, mem};
|
|
||||||
use std::cmp::PartialEq;
|
use std::cmp::PartialEq;
|
||||||
|
use std::{fmt, mem};
|
||||||
|
|
||||||
/// Represents the joint session history
|
/// Represents the joint session history
|
||||||
/// https://html.spec.whatwg.org/multipage/#joint-session-history
|
/// https://html.spec.whatwg.org/multipage/#joint-session-history
|
||||||
|
|
|
@ -49,7 +49,8 @@ pub fn start_server(port: u16) -> Sender {
|
||||||
.name("debugger-websocket".to_owned())
|
.name("debugger-websocket".to_owned())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
socket.listen(("127.0.0.1", port)).unwrap();
|
socket.listen(("127.0.0.1", port)).unwrap();
|
||||||
}).expect("Thread spawning failed");
|
})
|
||||||
|
.expect("Thread spawning failed");
|
||||||
while let Some(message) = receiver.recv() {
|
while let Some(message) = receiver.recv() {
|
||||||
match message {
|
match message {
|
||||||
Message::ShutdownServer => {
|
Message::ShutdownServer => {
|
||||||
|
@ -58,7 +59,8 @@ pub fn start_server(port: u16) -> Sender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.shutdown().unwrap();
|
sender.shutdown().unwrap();
|
||||||
}).expect("Thread spawning failed");
|
})
|
||||||
|
.expect("Thread spawning failed");
|
||||||
Sender(sender)
|
Sender(sender)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use crate::actors::object::ObjectActor;
|
use crate::actors::object::ObjectActor;
|
||||||
use crate::protocol::JsonPacketStream;
|
use crate::protocol::JsonPacketStream;
|
||||||
use devtools_traits::{CachedConsoleMessageTypes, DevtoolScriptControlMsg};
|
|
||||||
use devtools_traits::CachedConsoleMessage;
|
use devtools_traits::CachedConsoleMessage;
|
||||||
use devtools_traits::EvaluateJSReply::{ActorValue, BooleanValue, StringValue};
|
use devtools_traits::EvaluateJSReply::{ActorValue, BooleanValue, StringValue};
|
||||||
use devtools_traits::EvaluateJSReply::{NullValue, NumberValue, VoidValue};
|
use devtools_traits::EvaluateJSReply::{NullValue, NumberValue, VoidValue};
|
||||||
|
use devtools_traits::{CachedConsoleMessageTypes, DevtoolScriptControlMsg};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use serde_json::{self, Map, Number, Value};
|
use serde_json::{self, Map, Number, Value};
|
||||||
|
@ -126,7 +126,8 @@ impl Actor for ConsoleActor {
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
message_types,
|
message_types,
|
||||||
chan,
|
chan,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
let messages = port
|
let messages = port
|
||||||
.recv()
|
.recv()
|
||||||
.map_err(|_| ())?
|
.map_err(|_| ())?
|
||||||
|
@ -135,7 +136,8 @@ impl Actor for ConsoleActor {
|
||||||
let json_string = message.encode().unwrap();
|
let json_string = message.encode().unwrap();
|
||||||
let json = serde_json::from_str::<Value>(&json_string).unwrap();
|
let json = serde_json::from_str::<Value>(&json_string).unwrap();
|
||||||
json.as_object().unwrap().to_owned()
|
json.as_object().unwrap().to_owned()
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let msg = GetCachedMessagesReply {
|
let msg = GetCachedMessagesReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
|
@ -196,7 +198,8 @@ impl Actor for ConsoleActor {
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
input.clone(),
|
input.clone(),
|
||||||
chan,
|
chan,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
//TODO: extract conversion into protocol module or some other useful place
|
//TODO: extract conversion into protocol module or some other useful place
|
||||||
let result = match port.recv().map_err(|_| ())? {
|
let result = match port.recv().map_err(|_| ())? {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use crate::protocol::{ActorDescription, Method};
|
|
||||||
use crate::protocol::JsonPacketStream;
|
use crate::protocol::JsonPacketStream;
|
||||||
|
use crate::protocol::{ActorDescription, Method};
|
||||||
use serde_json::{Map, Value};
|
use serde_json::{Map, Value};
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ impl Actor for DeviceActor {
|
||||||
value: SystemInfo {
|
value: SystemInfo {
|
||||||
apptype: "servo".to_string(),
|
apptype: "servo".to_string(),
|
||||||
platformVersion: "63.0".to_string(),
|
platformVersion: "63.0".to_string(),
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
@ -73,12 +73,11 @@ impl DeviceActor {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
)].into_iter()
|
)]
|
||||||
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use crate::protocol::JsonPacketStream;
|
use crate::protocol::JsonPacketStream;
|
||||||
use devtools_traits::{ComputedNodeLayout, DevtoolScriptControlMsg, NodeInfo};
|
|
||||||
use devtools_traits::DevtoolScriptControlMsg::{GetChildren, GetDocumentElement, GetRootNode};
|
use devtools_traits::DevtoolScriptControlMsg::{GetChildren, GetDocumentElement, GetRootNode};
|
||||||
use devtools_traits::DevtoolScriptControlMsg::{GetLayout, ModifyAttribute};
|
use devtools_traits::DevtoolScriptControlMsg::{GetLayout, ModifyAttribute};
|
||||||
|
use devtools_traits::{ComputedNodeLayout, DevtoolScriptControlMsg, NodeInfo};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use serde_json::{self, Map, Value};
|
use serde_json::{self, Map, Value};
|
||||||
|
@ -111,14 +111,16 @@ impl Actor for NodeActor {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|json_mod| {
|
.map(|json_mod| {
|
||||||
serde_json::from_str(&serde_json::to_string(json_mod).unwrap()).unwrap()
|
serde_json::from_str(&serde_json::to_string(json_mod).unwrap()).unwrap()
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
self.script_chan
|
self.script_chan
|
||||||
.send(ModifyAttribute(
|
.send(ModifyAttribute(
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
registry.actor_to_script(target.to_owned()),
|
registry.actor_to_script(target.to_owned()),
|
||||||
modifications,
|
modifications,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
let reply = ModifyAttributeReply { from: self.name() };
|
let reply = ModifyAttributeReply { from: self.name() };
|
||||||
stream.write_json_packet(&reply);
|
stream.write_json_packet(&reply);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
@ -228,7 +230,8 @@ impl NodeInfoToProtocol for NodeInfo {
|
||||||
namespace: attr.namespace,
|
namespace: attr.namespace,
|
||||||
name: attr.name,
|
name: attr.name,
|
||||||
value: attr.value,
|
value: attr.value,
|
||||||
}).collect(),
|
})
|
||||||
|
.collect(),
|
||||||
|
|
||||||
pseudoClassLocks: vec![], //TODO get this data from script
|
pseudoClassLocks: vec![], //TODO get this data from script
|
||||||
|
|
||||||
|
@ -324,7 +327,8 @@ impl Actor for WalkerActor {
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
registry.actor_to_script(target.to_owned()),
|
registry.actor_to_script(target.to_owned()),
|
||||||
tx,
|
tx,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
let children = rx.recv().unwrap().ok_or(())?;
|
let children = rx.recv().unwrap().ok_or(())?;
|
||||||
|
|
||||||
let msg = ChildrenReply {
|
let msg = ChildrenReply {
|
||||||
|
@ -334,7 +338,8 @@ impl Actor for WalkerActor {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|child| {
|
.map(|child| {
|
||||||
child.encode(registry, true, self.script_chan.clone(), self.pipeline)
|
child.encode(registry, true, self.script_chan.clone(), self.pipeline)
|
||||||
}).collect(),
|
})
|
||||||
|
.collect(),
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
};
|
};
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
|
@ -498,7 +503,8 @@ impl Actor for PageStyleActor {
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
registry.actor_to_script(target.to_owned()),
|
registry.actor_to_script(target.to_owned()),
|
||||||
tx,
|
tx,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
let ComputedNodeLayout {
|
let ComputedNodeLayout {
|
||||||
display,
|
display,
|
||||||
position,
|
position,
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct HttpRequest {
|
||||||
struct HttpResponse {
|
struct HttpResponse {
|
||||||
headers: Option<HeaderMap>,
|
headers: Option<HeaderMap>,
|
||||||
status: Option<(StatusCode, String)>,
|
status: Option<(StatusCode, String)>,
|
||||||
body: Option<Vec<u8>>
|
body: Option<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NetworkEventActor {
|
pub struct NetworkEventActor {
|
||||||
|
@ -192,7 +192,10 @@ impl Actor for NetworkEventActor {
|
||||||
let value = &value.to_str().unwrap().to_string();
|
let value = &value.to_str().unwrap().to_string();
|
||||||
rawHeadersString = rawHeadersString + name.as_str() + ":" + &value + "\r\n";
|
rawHeadersString = rawHeadersString + name.as_str() + ":" + &value + "\r\n";
|
||||||
headersSize += name.as_str().len() + value.len();
|
headersSize += name.as_str().len() + value.len();
|
||||||
headers.push(Header { name: name.as_str().to_owned(), value: value.to_owned() });
|
headers.push(Header {
|
||||||
|
name: name.as_str().to_owned(),
|
||||||
|
value: value.to_owned(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
let msg = GetRequestHeadersReply {
|
let msg = GetRequestHeadersReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
|
@ -376,8 +379,13 @@ impl NetworkEventActor {
|
||||||
// TODO: Send the correct values for all these fields.
|
// TODO: Send the correct values for all these fields.
|
||||||
let hSizeOption = self.response.headers.as_ref().map(|headers| headers.len());
|
let hSizeOption = self.response.headers.as_ref().map(|headers| headers.len());
|
||||||
let hSize = hSizeOption.unwrap_or(0);
|
let hSize = hSizeOption.unwrap_or(0);
|
||||||
let (status_code, status_message) = self.response.status.as_ref()
|
let (status_code, status_message) = self
|
||||||
.map_or((0, "".to_owned()), |(code, text)| (code.as_u16(), text.clone()));
|
.response
|
||||||
|
.status
|
||||||
|
.as_ref()
|
||||||
|
.map_or((0, "".to_owned()), |(code, text)| {
|
||||||
|
(code.as_u16(), text.clone())
|
||||||
|
});
|
||||||
// TODO: Send the correct values for remoteAddress and remotePort and http_version.
|
// TODO: Send the correct values for remoteAddress and remotePort and http_version.
|
||||||
ResponseStartMsg {
|
ResponseStartMsg {
|
||||||
httpVersion: "HTTP/1.1".to_owned(),
|
httpVersion: "HTTP/1.1".to_owned(),
|
||||||
|
@ -395,7 +403,7 @@ impl NetworkEventActor {
|
||||||
if let Some(ref headers) = self.response.headers {
|
if let Some(ref headers) = self.response.headers {
|
||||||
mString = match headers.typed_get::<ContentType>() {
|
mString = match headers.typed_get::<ContentType>() {
|
||||||
Some(ct) => ct.to_string(),
|
Some(ct) => ct.to_string(),
|
||||||
_ => "".to_owned()
|
_ => "".to_owned(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// TODO: Set correct values when response's body is sent to the devtools in http_loader.
|
// TODO: Set correct values when response's body is sent to the devtools in http_loader.
|
||||||
|
@ -436,10 +444,9 @@ impl NetworkEventActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_headers(&self) -> RequestHeadersMsg {
|
pub fn request_headers(&self) -> RequestHeadersMsg {
|
||||||
let size = self.request
|
let size = self.request.headers.iter().fold(0, |acc, (name, value)| {
|
||||||
.headers
|
acc + name.as_str().len() + value.len()
|
||||||
.iter()
|
});
|
||||||
.fold(0, |acc, (name, value)| acc + name.as_str().len() + value.len());
|
|
||||||
RequestHeadersMsg {
|
RequestHeadersMsg {
|
||||||
headers: self.request.headers.len(),
|
headers: self.request.headers.len(),
|
||||||
headersSize: size,
|
headersSize: size,
|
||||||
|
@ -449,7 +456,7 @@ impl NetworkEventActor {
|
||||||
pub fn request_cookies(&self) -> RequestCookiesMsg {
|
pub fn request_cookies(&self) -> RequestCookiesMsg {
|
||||||
let cookies_size = match self.request.headers.typed_get::<Cookie>() {
|
let cookies_size = match self.request.headers.typed_get::<Cookie>() {
|
||||||
Some(ref cookie) => cookie.len(),
|
Some(ref cookie) => cookie.len(),
|
||||||
_ => 0
|
_ => 0,
|
||||||
};
|
};
|
||||||
RequestCookiesMsg {
|
RequestCookiesMsg {
|
||||||
cookies: cookies_size,
|
cookies: cookies_size,
|
||||||
|
|
|
@ -106,7 +106,8 @@ impl PerformanceActor {
|
||||||
vec![(
|
vec![(
|
||||||
"type".to_owned(),
|
"type".to_owned(),
|
||||||
Value::String("canCurrentlyRecord".to_owned()),
|
Value::String("canCurrentlyRecord".to_owned()),
|
||||||
)].into_iter()
|
)]
|
||||||
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
response: Value::Object(
|
response: Value::Object(
|
||||||
|
@ -117,7 +118,8 @@ impl PerformanceActor {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
)].into_iter()
|
)]
|
||||||
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -30,4 +30,3 @@ impl StyleSheetsActor {
|
||||||
StyleSheetsActor { name: name }
|
StyleSheetsActor { name: name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ use crate::actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use crate::actors::framerate::FramerateActor;
|
use crate::actors::framerate::FramerateActor;
|
||||||
use crate::actors::memory::{MemoryActor, TimelineMemoryReply};
|
use crate::actors::memory::{MemoryActor, TimelineMemoryReply};
|
||||||
use crate::protocol::JsonPacketStream;
|
use crate::protocol::JsonPacketStream;
|
||||||
use devtools_traits::{PreciseTime, TimelineMarker, TimelineMarkerType};
|
|
||||||
use devtools_traits::DevtoolScriptControlMsg;
|
use devtools_traits::DevtoolScriptControlMsg;
|
||||||
use devtools_traits::DevtoolScriptControlMsg::{DropTimelineMarkers, SetTimelineMarkers};
|
use devtools_traits::DevtoolScriptControlMsg::{DropTimelineMarkers, SetTimelineMarkers};
|
||||||
|
use devtools_traits::{PreciseTime, TimelineMarker, TimelineMarkerType};
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
|
@ -169,7 +169,8 @@ impl TimelineActor {
|
||||||
emitter.send(markers);
|
emitter.send(markers);
|
||||||
|
|
||||||
thread::sleep(Duration::from_millis(DEFAULT_TIMELINE_DATA_PULL_TIMEOUT));
|
thread::sleep(Duration::from_millis(DEFAULT_TIMELINE_DATA_PULL_TIMEOUT));
|
||||||
}).expect("Thread spawning failed");
|
})
|
||||||
|
.expect("Thread spawning failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +196,8 @@ impl Actor for TimelineActor {
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
self.marker_types.clone(),
|
self.marker_types.clone(),
|
||||||
tx,
|
tx,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
*self.stream.borrow_mut() = stream.try_clone().ok();
|
*self.stream.borrow_mut() = stream.try_clone().ok();
|
||||||
|
|
||||||
|
@ -248,7 +250,8 @@ impl Actor for TimelineActor {
|
||||||
.send(DropTimelineMarkers(
|
.send(DropTimelineMarkers(
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
self.marker_types.clone(),
|
self.marker_types.clone(),
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
if let Some(ref actor_name) = *self.framerate_actor.borrow() {
|
if let Some(ref actor_name) = *self.framerate_actor.borrow() {
|
||||||
registry.drop_actor_later(actor_name.clone());
|
registry.drop_actor_later(actor_name.clone());
|
||||||
|
|
|
@ -48,11 +48,11 @@ use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo, LogLevel, Netwo
|
||||||
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use servo_channel::{Receiver, Sender, channel};
|
use servo_channel::{channel, Receiver, Sender};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::net::{Shutdown, TcpListener, TcpStream};
|
use std::net::{Shutdown, TcpListener, TcpStream};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -235,7 +235,17 @@ fn run_server(
|
||||||
let (pipeline, worker_id) = ids;
|
let (pipeline, worker_id) = ids;
|
||||||
|
|
||||||
//TODO: move all this actor creation into a constructor method on BrowsingContextActor
|
//TODO: move all this actor creation into a constructor method on BrowsingContextActor
|
||||||
let (target, console, emulation, inspector, timeline, profiler, performance, styleSheets, thread) = {
|
let (
|
||||||
|
target,
|
||||||
|
console,
|
||||||
|
emulation,
|
||||||
|
inspector,
|
||||||
|
timeline,
|
||||||
|
profiler,
|
||||||
|
performance,
|
||||||
|
styleSheets,
|
||||||
|
thread,
|
||||||
|
) = {
|
||||||
let console = ConsoleActor {
|
let console = ConsoleActor {
|
||||||
name: actors.new_name("console"),
|
name: actors.new_name("console"),
|
||||||
script_chan: script_sender.clone(),
|
script_chan: script_sender.clone(),
|
||||||
|
@ -347,7 +357,8 @@ fn run_server(
|
||||||
LogLevel::Warn => "warn",
|
LogLevel::Warn => "warn",
|
||||||
LogLevel::Error => "error",
|
LogLevel::Error => "error",
|
||||||
_ => "log",
|
_ => "log",
|
||||||
}.to_owned(),
|
}
|
||||||
|
.to_owned(),
|
||||||
timeStamp: precise_time_ns(),
|
timeStamp: precise_time_ns(),
|
||||||
arguments: vec![console_message.message],
|
arguments: vec![console_message.message],
|
||||||
filename: console_message.filename,
|
filename: console_message.filename,
|
||||||
|
@ -373,7 +384,12 @@ fn run_server(
|
||||||
Some(actors.find::<WorkerActor>(actor_name).console.clone())
|
Some(actors.find::<WorkerActor>(actor_name).console.clone())
|
||||||
} else {
|
} else {
|
||||||
let actor_name = (*actor_pipelines).get(&id)?;
|
let actor_name = (*actor_pipelines).get(&id)?;
|
||||||
Some(actors.find::<BrowsingContextActor>(actor_name).console.clone())
|
Some(
|
||||||
|
actors
|
||||||
|
.find::<BrowsingContextActor>(actor_name)
|
||||||
|
.console
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,9 +553,11 @@ fn run_server(
|
||||||
sender_clone
|
sender_clone
|
||||||
.send(DevtoolsControlMsg::FromChrome(
|
.send(DevtoolsControlMsg::FromChrome(
|
||||||
ChromeToDevtoolsControlMsg::AddClient(stream.unwrap()),
|
ChromeToDevtoolsControlMsg::AddClient(stream.unwrap()),
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
}).expect("Thread spawning failed");
|
})
|
||||||
|
.expect("Thread spawning failed");
|
||||||
|
|
||||||
while let Some(msg) = receiver.recv() {
|
while let Some(msg) = receiver.recv() {
|
||||||
match msg {
|
match msg {
|
||||||
|
|
|
@ -24,8 +24,8 @@ extern crate serde;
|
||||||
extern crate servo_url;
|
extern crate servo_url;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
use http::HeaderMap;
|
|
||||||
use http::method::Method;
|
use http::method::Method;
|
||||||
|
use http::HeaderMap;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
|
|
|
@ -55,7 +55,8 @@ pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
&self.#ident
|
&self.#ident
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).into()
|
)
|
||||||
|
.into()
|
||||||
} else {
|
} else {
|
||||||
panic!("#[dom_struct] only applies to structs with named fields");
|
panic!("#[dom_struct] only applies to structs with named fields");
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,9 @@ fn expand_dom_object(input: syn::DeriveInput) -> quote::Tokens {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let mut generics = input.generics.clone();
|
let mut generics = input.generics.clone();
|
||||||
generics
|
generics.params.push(parse_quote!(
|
||||||
.params
|
__T: crate::dom::bindings::reflector::DomObject
|
||||||
.push(parse_quote!(__T: crate::dom::bindings::reflector::DomObject));
|
));
|
||||||
|
|
||||||
let (impl_generics, _, where_clause) = generics.split_for_impl();
|
let (impl_generics, _, where_clause) = generics.split_for_impl();
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
extern crate hashglobe;
|
extern crate hashglobe;
|
||||||
extern crate smallvec;
|
extern crate smallvec;
|
||||||
|
|
||||||
use hashglobe::FailedAllocationError;
|
|
||||||
#[cfg(feature = "known_system_malloc")]
|
#[cfg(feature = "known_system_malloc")]
|
||||||
use hashglobe::alloc;
|
use hashglobe::alloc;
|
||||||
|
use hashglobe::FailedAllocationError;
|
||||||
use smallvec::Array;
|
use smallvec::Array;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
|
@ -9,9 +9,9 @@ use crate::platform::font::{FontHandle, FontTable};
|
||||||
use crate::platform::font_context::FontContextHandle;
|
use crate::platform::font_context::FontContextHandle;
|
||||||
pub use crate::platform::font_list::fallback_font_families;
|
pub use crate::platform::font_list::fallback_font_families;
|
||||||
use crate::platform::font_template::FontTemplateData;
|
use crate::platform::font_template::FontTemplateData;
|
||||||
use crate::text::Shaper;
|
|
||||||
use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore};
|
use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore};
|
||||||
use crate::text::shaping::ShaperMethods;
|
use crate::text::shaping::ShaperMethods;
|
||||||
|
use crate::text::Shaper;
|
||||||
use euclid::{Point2D, Rect, Size2D};
|
use euclid::{Point2D, Rect, Size2D};
|
||||||
use ordered_float::NotNan;
|
use ordered_float::NotNan;
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
|
@ -22,8 +22,8 @@ use std::collections::HashMap;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
|
||||||
use style::computed_values::{font_stretch, font_style, font_variant_caps, font_weight};
|
use style::computed_values::{font_stretch, font_style, font_variant_caps, font_weight};
|
||||||
use style::properties::style_structs::Font as FontStyleStruct;
|
use style::properties::style_structs::Font as FontStyleStruct;
|
||||||
use style::values::computed::font::SingleFontFamily;
|
use style::values::computed::font::SingleFontFamily;
|
||||||
|
@ -254,7 +254,8 @@ impl Font {
|
||||||
TEXT_SHAPING_PERFORMANCE_COUNTER
|
TEXT_SHAPING_PERFORMANCE_COUNTER
|
||||||
.fetch_add((end_time - start_time) as usize, Ordering::Relaxed);
|
.fetch_add((end_time - start_time) as usize, Ordering::Relaxed);
|
||||||
Arc::new(glyphs)
|
Arc::new(glyphs)
|
||||||
}).clone();
|
})
|
||||||
|
.clone();
|
||||||
self.shaper = shaper;
|
self.shaper = shaper;
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -450,7 +451,8 @@ impl FontGroup {
|
||||||
iter::once(FontFamilyDescriptor::default())
|
iter::once(FontFamilyDescriptor::default())
|
||||||
.chain(fallback_font_families(codepoint).into_iter().map(|family| {
|
.chain(fallback_font_families(codepoint).into_iter().map(|family| {
|
||||||
FontFamilyDescriptor::new(FontFamilyName::from(family), FontSearchScope::Local)
|
FontFamilyDescriptor::new(FontFamilyName::from(family), FontSearchScope::Local)
|
||||||
})).filter_map(|family| font_context.font(&self.descriptor, &family))
|
}))
|
||||||
|
.filter_map(|family| font_context.font(&self.descriptor, &family))
|
||||||
.find(predicate)
|
.find(predicate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,22 +7,22 @@ use crate::font::{FontFamilyDescriptor, FontFamilyName, FontSearchScope};
|
||||||
use crate::font_context::FontSource;
|
use crate::font_context::FontSource;
|
||||||
use crate::font_template::{FontTemplate, FontTemplateDescriptor};
|
use crate::font_template::{FontTemplate, FontTemplateDescriptor};
|
||||||
use crate::platform::font_context::FontContextHandle;
|
use crate::platform::font_context::FontContextHandle;
|
||||||
use crate::platform::font_list::SANS_SERIF_FONT_FAMILY;
|
|
||||||
use crate::platform::font_list::for_each_available_family;
|
use crate::platform::font_list::for_each_available_family;
|
||||||
use crate::platform::font_list::for_each_variation;
|
use crate::platform::font_list::for_each_variation;
|
||||||
use crate::platform::font_list::system_default_family;
|
use crate::platform::font_list::system_default_family;
|
||||||
|
use crate::platform::font_list::SANS_SERIF_FONT_FAMILY;
|
||||||
use crate::platform::font_template::FontTemplateData;
|
use crate::platform::font_template::FontTemplateData;
|
||||||
use fontsan;
|
use fontsan;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use net_traits::{CoreResourceThread, FetchResponseMsg, fetch_async};
|
|
||||||
use net_traits::request::{Destination, RequestInit};
|
use net_traits::request::{Destination, RequestInit};
|
||||||
|
use net_traits::{fetch_async, CoreResourceThread, FetchResponseMsg};
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::{fmt, f32, mem, thread};
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::{f32, fmt, mem, thread};
|
||||||
use style::font_face::{EffectiveSources, Source};
|
use style::font_face::{EffectiveSources, Source};
|
||||||
use style::values::computed::font::FamilyName;
|
use style::values::computed::font::FamilyName;
|
||||||
use webrender_api;
|
use webrender_api;
|
||||||
|
@ -434,7 +434,8 @@ impl FontCache {
|
||||||
FontSearchScope::Local => {
|
FontSearchScope::Local => {
|
||||||
self.find_font_in_local_family(&template_descriptor, &family_descriptor.name)
|
self.find_font_in_local_family(&template_descriptor, &family_descriptor.name)
|
||||||
},
|
},
|
||||||
}.map(|t| self.get_font_template_info(t))
|
}
|
||||||
|
.map(|t| self.get_font_template_info(t))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +475,8 @@ impl FontCacheThread {
|
||||||
|
|
||||||
cache.refresh_local_families();
|
cache.refresh_local_families();
|
||||||
cache.run();
|
cache.run();
|
||||||
}).expect("Thread spawning failed");
|
})
|
||||||
|
.expect("Thread spawning failed");
|
||||||
|
|
||||||
FontCacheThread { chan: chan }
|
FontCacheThread { chan: chan }
|
||||||
}
|
}
|
||||||
|
@ -490,7 +492,8 @@ impl FontCacheThread {
|
||||||
LowercaseString::new(&family.name),
|
LowercaseString::new(&family.name),
|
||||||
sources,
|
sources,
|
||||||
sender,
|
sender,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exit(&self) {
|
pub fn exit(&self) {
|
||||||
|
@ -538,7 +541,8 @@ impl FontSource for FontCacheThread {
|
||||||
template_descriptor,
|
template_descriptor,
|
||||||
family_descriptor,
|
family_descriptor,
|
||||||
response_chan,
|
response_chan,
|
||||||
)).expect("failed to send message to font cache thread");
|
))
|
||||||
|
.expect("failed to send message to font cache thread");
|
||||||
|
|
||||||
let reply = response_port.recv();
|
let reply = response_port.recv();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::font::{Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef};
|
use crate::font::{
|
||||||
|
Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef,
|
||||||
|
};
|
||||||
use crate::font_cache_thread::FontTemplateInfo;
|
use crate::font_cache_thread::FontTemplateInfo;
|
||||||
use crate::font_template::FontTemplateDescriptor;
|
use crate::font_template::FontTemplateDescriptor;
|
||||||
use crate::platform::font::FontHandle;
|
use crate::platform::font::FontHandle;
|
||||||
|
@ -133,7 +135,8 @@ impl<S: FontSource> FontContext<S> {
|
||||||
.and_then(|template_info| {
|
.and_then(|template_info| {
|
||||||
self.create_font(template_info, font_descriptor.to_owned())
|
self.create_font(template_info, font_descriptor.to_owned())
|
||||||
.ok()
|
.ok()
|
||||||
}).map(|font| Rc::new(RefCell::new(font)));
|
})
|
||||||
|
.map(|font| Rc::new(RefCell::new(font)));
|
||||||
|
|
||||||
self.font_cache.insert(cache_key, font.clone());
|
self.font_cache.insert(cache_key, font.clone());
|
||||||
font
|
font
|
||||||
|
|
|
@ -8,11 +8,11 @@ use std::fs::File;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use ucd::{Codepoint, UnicodeBlock};
|
use ucd::{Codepoint, UnicodeBlock};
|
||||||
use xml5ever::Attribute;
|
|
||||||
use xml5ever::driver::parse_document;
|
use xml5ever::driver::parse_document;
|
||||||
use xml5ever::rcdom::*;
|
use xml5ever::rcdom::*;
|
||||||
use xml5ever::rcdom::{Node, RcDom};
|
use xml5ever::rcdom::{Node, RcDom};
|
||||||
use xml5ever::tendril::TendrilSink;
|
use xml5ever::tendril::TendrilSink;
|
||||||
|
use xml5ever::Attribute;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref FONT_LIST: FontList = FontList::new();
|
static ref FONT_LIST: FontList = FontList::new();
|
||||||
|
@ -127,7 +127,11 @@ struct FontList {
|
||||||
impl FontList {
|
impl FontList {
|
||||||
fn new() -> FontList {
|
fn new() -> FontList {
|
||||||
// Possible paths containing the font mapping xml file.
|
// Possible paths containing the font mapping xml file.
|
||||||
let paths = ["/etc/fonts.xml", "/system/etc/system_fonts.xml", "/package/etc/fonts.xml"];
|
let paths = [
|
||||||
|
"/etc/fonts.xml",
|
||||||
|
"/system/etc/system_fonts.xml",
|
||||||
|
"/package/etc/fonts.xml",
|
||||||
|
];
|
||||||
|
|
||||||
// Try to load and parse paths until one of them success.
|
// Try to load and parse paths until one of them success.
|
||||||
let mut result = None;
|
let mut result = None;
|
||||||
|
@ -213,7 +217,10 @@ impl FontList {
|
||||||
let alternatives = [
|
let alternatives = [
|
||||||
("sans-serif", "Roboto-Regular.ttf"),
|
("sans-serif", "Roboto-Regular.ttf"),
|
||||||
("Droid Sans", "DroidSans.ttf"),
|
("Droid Sans", "DroidSans.ttf"),
|
||||||
("Lomino", "/system/etc/ml/kali/Fonts/Lomino/Medium/LominoUI_Md.ttf"),
|
(
|
||||||
|
"Lomino",
|
||||||
|
"/system/etc/ml/kali/Fonts/Lomino/Medium/LominoUI_Md.ttf",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
alternatives
|
alternatives
|
||||||
|
@ -225,7 +232,8 @@ impl FontList {
|
||||||
filename: item.1.into(),
|
filename: item.1.into(),
|
||||||
weight: None,
|
weight: None,
|
||||||
}],
|
}],
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// All Android fonts are located in /system/fonts
|
// All Android fonts are located in /system/fonts
|
||||||
|
@ -348,7 +356,8 @@ impl FontList {
|
||||||
.map(|f| Font {
|
.map(|f| Font {
|
||||||
filename: f.clone(),
|
filename: f.clone(),
|
||||||
weight: None,
|
weight: None,
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
if !fonts.is_empty() {
|
if !fonts.is_empty() {
|
||||||
out.push(FontFamily {
|
out.push(FontFamily {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* 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/. */
|
||||||
|
|
||||||
|
use super::c_str_to_string;
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::font::{FontHandleMethods, FontMetrics, FontTableMethods};
|
use crate::font::{FontHandleMethods, FontMetrics, FontTableMethods};
|
||||||
use crate::font::{FontTableTag, FractionalPixel, GPOS, GSUB, KERN};
|
use crate::font::{FontTableTag, FractionalPixel, GPOS, GSUB, KERN};
|
||||||
|
@ -9,6 +10,7 @@ use crate::platform::font_context::FontContextHandle;
|
||||||
use crate::platform::font_template::FontTemplateData;
|
use crate::platform::font_template::FontTemplateData;
|
||||||
use crate::text::glyph::GlyphId;
|
use crate::text::glyph::GlyphId;
|
||||||
use crate::text::util::fixed_to_float;
|
use crate::text::util::fixed_to_float;
|
||||||
|
use freetype::freetype::FT_Sfnt_Tag;
|
||||||
use freetype::freetype::{FT_Done_Face, FT_New_Face, FT_New_Memory_Face};
|
use freetype::freetype::{FT_Done_Face, FT_New_Face, FT_New_Memory_Face};
|
||||||
use freetype::freetype::{FT_F26Dot6, FT_Face, FT_FaceRec};
|
use freetype::freetype::{FT_F26Dot6, FT_Face, FT_FaceRec};
|
||||||
use freetype::freetype::{FT_Get_Char_Index, FT_Get_Postscript_Name};
|
use freetype::freetype::{FT_Get_Char_Index, FT_Get_Postscript_Name};
|
||||||
|
@ -17,18 +19,16 @@ use freetype::freetype::{FT_GlyphSlot, FT_Library, FT_Long, FT_ULong};
|
||||||
use freetype::freetype::{FT_Int32, FT_Kerning_Mode, FT_STYLE_FLAG_ITALIC};
|
use freetype::freetype::{FT_Int32, FT_Kerning_Mode, FT_STYLE_FLAG_ITALIC};
|
||||||
use freetype::freetype::{FT_Load_Glyph, FT_Set_Char_Size};
|
use freetype::freetype::{FT_Load_Glyph, FT_Set_Char_Size};
|
||||||
use freetype::freetype::{FT_SizeRec, FT_Size_Metrics, FT_UInt, FT_Vector};
|
use freetype::freetype::{FT_SizeRec, FT_Size_Metrics, FT_UInt, FT_Vector};
|
||||||
use freetype::freetype::FT_Sfnt_Tag;
|
|
||||||
use freetype::succeeded;
|
use freetype::succeeded;
|
||||||
use freetype::tt_os2::TT_OS2;
|
use freetype::tt_os2::TT_OS2;
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use std::{mem, ptr};
|
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::os::raw::{c_char, c_long};
|
use std::os::raw::{c_char, c_long};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{mem, ptr};
|
||||||
use style::computed_values::font_stretch::T as FontStretch;
|
use style::computed_values::font_stretch::T as FontStretch;
|
||||||
use style::computed_values::font_weight::T as FontWeight;
|
use style::computed_values::font_weight::T as FontWeight;
|
||||||
use style::values::computed::font::FontStyle;
|
use style::values::computed::font::FontStyle;
|
||||||
use super::c_str_to_string;
|
|
||||||
|
|
||||||
// This constant is not present in the freetype
|
// This constant is not present in the freetype
|
||||||
// bindings due to bindgen not handling the way
|
// bindings due to bindgen not handling the way
|
||||||
|
@ -216,7 +216,8 @@ impl FontHandleMethods for FontHandle {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FontStretchKeyword::Normal
|
FontStretchKeyword::Normal
|
||||||
}.compute();
|
}
|
||||||
|
.compute();
|
||||||
FontStretch(NonNegative(percentage))
|
FontStretch(NonNegative(percentage))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use freetype::freetype::FT_MemoryRec_;
|
||||||
use freetype::freetype::FT_New_Library;
|
use freetype::freetype::FT_New_Library;
|
||||||
use freetype::succeeded;
|
use freetype::succeeded;
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||||
use servo_allocator::libc_compat::{malloc, realloc, free};
|
use servo_allocator::libc_compat::{free, malloc, realloc};
|
||||||
use servo_allocator::usable_size;
|
use servo_allocator::usable_size;
|
||||||
use std::os::raw::{c_long, c_void};
|
use std::os::raw::{c_long, c_void};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
|
@ -2,18 +2,20 @@
|
||||||
* 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/. */
|
||||||
|
|
||||||
|
use super::c_str_to_string;
|
||||||
use crate::text::util::is_cjk;
|
use crate::text::util::is_cjk;
|
||||||
use fontconfig::fontconfig::{FcChar8, FcResultMatch, FcSetSystem};
|
use fontconfig::fontconfig::{FcChar8, FcResultMatch, FcSetSystem};
|
||||||
use fontconfig::fontconfig::{FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute};
|
use fontconfig::fontconfig::{FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute};
|
||||||
use fontconfig::fontconfig::{FcDefaultSubstitute, FcFontMatch, FcNameParse, FcPatternGetString};
|
use fontconfig::fontconfig::{FcDefaultSubstitute, FcFontMatch, FcNameParse, FcPatternGetString};
|
||||||
use fontconfig::fontconfig::{FcFontSetDestroy, FcMatchPattern, FcPatternCreate, FcPatternDestroy};
|
use fontconfig::fontconfig::{FcFontSetDestroy, FcMatchPattern, FcPatternCreate, FcPatternDestroy};
|
||||||
use fontconfig::fontconfig::{FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy, FcPatternAddString};
|
use fontconfig::fontconfig::{
|
||||||
|
FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy, FcPatternAddString,
|
||||||
|
};
|
||||||
use fontconfig::fontconfig::{FcObjectSetAdd, FcPatternGetInteger};
|
use fontconfig::fontconfig::{FcObjectSetAdd, FcPatternGetInteger};
|
||||||
use libc;
|
use libc;
|
||||||
use libc::{c_char, c_int};
|
use libc::{c_char, c_int};
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use super::c_str_to_string;
|
|
||||||
|
|
||||||
static FC_FAMILY: &'static [u8] = b"family\0";
|
static FC_FAMILY: &'static [u8] = b"family\0";
|
||||||
static FC_FILE: &'static [u8] = b"file\0";
|
static FC_FILE: &'static [u8] = b"file\0";
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Error};
|
use std::io::{Error, Read};
|
||||||
use webrender_api::NativeFontHandle;
|
use webrender_api::NativeFontHandle;
|
||||||
|
|
||||||
/// Platform specific font representation for Linux.
|
/// Platform specific font representation for Linux.
|
||||||
|
@ -25,7 +25,8 @@ impl fmt::Debug for FontTemplateData {
|
||||||
.field(
|
.field(
|
||||||
"bytes",
|
"bytes",
|
||||||
&self.bytes.as_ref().map(|b| format!("[{} bytes]", b.len())),
|
&self.bytes.as_ref().map(|b| format!("[{} bytes]", b.len())),
|
||||||
).field("identifier", &self.identifier)
|
)
|
||||||
|
.field("identifier", &self.identifier)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,19 @@ use core_foundation::string::UniChar;
|
||||||
use core_graphics::font::CGGlyph;
|
use core_graphics::font::CGGlyph;
|
||||||
use core_graphics::geometry::CGRect;
|
use core_graphics::geometry::CGRect;
|
||||||
use core_text::font::CTFont;
|
use core_text::font::CTFont;
|
||||||
use core_text::font_descriptor::{SymbolicTraitAccessors, TraitAccessors};
|
|
||||||
use core_text::font_descriptor::kCTFontDefaultOrientation;
|
use core_text::font_descriptor::kCTFontDefaultOrientation;
|
||||||
use crate::font::{FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel};
|
use core_text::font_descriptor::{SymbolicTraitAccessors, TraitAccessors};
|
||||||
|
use crate::font::{
|
||||||
|
FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, FractionalPixel,
|
||||||
|
};
|
||||||
use crate::font::{GPOS, GSUB, KERN};
|
use crate::font::{GPOS, GSUB, KERN};
|
||||||
use crate::platform::font_template::FontTemplateData;
|
use crate::platform::font_template::FontTemplateData;
|
||||||
use crate::platform::macos::font_context::FontContextHandle;
|
use crate::platform::macos::font_context::FontContextHandle;
|
||||||
use crate::text::glyph::GlyphId;
|
use crate::text::glyph::GlyphId;
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use std::{fmt, ptr};
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{fmt, ptr};
|
||||||
use style::values::computed::font::{FontStretch, FontStyle, FontWeight};
|
use style::values::computed::font::{FontStretch, FontStyle, FontWeight};
|
||||||
|
|
||||||
const KERN_PAIR_LEN: usize = 6;
|
const KERN_PAIR_LEN: usize = 6;
|
||||||
|
@ -236,8 +238,7 @@ impl FontHandleMethods for FontHandle {
|
||||||
let count: CFIndex = 1;
|
let count: CFIndex = 1;
|
||||||
|
|
||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
self
|
self.ctfont
|
||||||
.ctfont
|
|
||||||
.get_glyphs_for_characters(&characters[0], &mut glyphs[0], count)
|
.get_glyphs_for_characters(&characters[0], &mut glyphs[0], count)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,15 @@ use core_graphics::data_provider::CGDataProvider;
|
||||||
use core_graphics::font::CGFont;
|
use core_graphics::font::CGFont;
|
||||||
use core_text;
|
use core_text;
|
||||||
use core_text::font::CTFont;
|
use core_text::font::CTFont;
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
||||||
use serde::de::{Error, Visitor};
|
use serde::de::{Error, Visitor};
|
||||||
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Error as IoError};
|
use std::io::{Error as IoError, Read};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use webrender_api::NativeFontHandle;
|
use webrender_api::NativeFontHandle;
|
||||||
|
@ -51,7 +51,8 @@ impl fmt::Debug for FontTemplateData {
|
||||||
.font_data
|
.font_data
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|bytes| format!("[{} bytes]", bytes.len())),
|
.map(|bytes| format!("[{} bytes]", bytes.len())),
|
||||||
).finish()
|
)
|
||||||
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +112,8 @@ impl FontTemplateData {
|
||||||
.expect("No URL for Core Text font!")
|
.expect("No URL for Core Text font!")
|
||||||
.get_string()
|
.get_string()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
).expect("Couldn't parse Core Text font URL!")
|
)
|
||||||
|
.expect("Couldn't parse Core Text font URL!")
|
||||||
.as_url()
|
.as_url()
|
||||||
.to_file_path()
|
.to_file_path()
|
||||||
.expect("Core Text font didn't name a path!");
|
.expect("Core Text font didn't name a path!");
|
||||||
|
|
|
@ -23,8 +23,8 @@ use std::sync::Arc;
|
||||||
use style::computed_values::font_stretch::T as StyleFontStretch;
|
use style::computed_values::font_stretch::T as StyleFontStretch;
|
||||||
use style::computed_values::font_weight::T as StyleFontWeight;
|
use style::computed_values::font_weight::T as StyleFontWeight;
|
||||||
use style::values::computed::font::FontStyle as StyleFontStyle;
|
use style::values::computed::font::FontStyle as StyleFontStyle;
|
||||||
use style::values::generics::NonNegative;
|
|
||||||
use style::values::generics::font::FontStyle as GenericFontStyle;
|
use style::values::generics::font::FontStyle as GenericFontStyle;
|
||||||
|
use style::values::generics::NonNegative;
|
||||||
use style::values::specified::font::FontStretchKeyword;
|
use style::values::specified::font::FontStretchKeyword;
|
||||||
use truetype;
|
use truetype;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ struct FontInfo {
|
||||||
|
|
||||||
impl FontInfo {
|
impl FontInfo {
|
||||||
fn new_from_face(face: &FontFace) -> Result<FontInfo, ()> {
|
fn new_from_face(face: &FontFace) -> Result<FontInfo, ()> {
|
||||||
use std::cmp::{min, max};
|
use std::cmp::{max, min};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use truetype::{NamingTable, Value, WindowsMetrics};
|
use truetype::{NamingTable, Value, WindowsMetrics};
|
||||||
|
|
||||||
|
@ -187,7 +187,8 @@ impl FontInfo {
|
||||||
8 => FontStretchKeyword::ExtraExpanded,
|
8 => FontStretchKeyword::ExtraExpanded,
|
||||||
9 => FontStretchKeyword::UltraExpanded,
|
9 => FontStretchKeyword::UltraExpanded,
|
||||||
_ => return Err(()),
|
_ => return Err(()),
|
||||||
}.compute(),
|
}
|
||||||
|
.compute(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let style = if italic_bool {
|
let style = if italic_bool {
|
||||||
|
@ -224,7 +225,8 @@ impl FontInfo {
|
||||||
FontStretch::Expanded => FontStretchKeyword::Expanded,
|
FontStretch::Expanded => FontStretchKeyword::Expanded,
|
||||||
FontStretch::ExtraExpanded => FontStretchKeyword::ExtraExpanded,
|
FontStretch::ExtraExpanded => FontStretchKeyword::ExtraExpanded,
|
||||||
FontStretch::UltraExpanded => FontStretchKeyword::UltraExpanded,
|
FontStretch::UltraExpanded => FontStretchKeyword::UltraExpanded,
|
||||||
}.compute(),
|
}
|
||||||
|
.compute(),
|
||||||
));
|
));
|
||||||
|
|
||||||
Ok(FontInfo {
|
Ok(FontInfo {
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::text::util::unicode_plane;
|
use crate::text::util::unicode_plane;
|
||||||
use dwrote::{Font, FontDescriptor, FontCollection};
|
use dwrote::{Font, FontCollection, FontDescriptor};
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::sync::atomic::{Ordering, AtomicUsize};
|
|
||||||
use ucd::{Codepoint, UnicodeBlock};
|
use ucd::{Codepoint, UnicodeBlock};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
|
@ -24,7 +24,8 @@ impl fmt::Debug for FontTemplateData {
|
||||||
.bytes
|
.bytes
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|bytes| format!("[{} bytes]", bytes.len())),
|
.map(|bytes| format!("[{} bytes]", bytes.len())),
|
||||||
).field("identifier", &self.identifier)
|
)
|
||||||
|
.field("identifier", &self.identifier)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,10 @@ extern crate style;
|
||||||
extern crate webrender_api;
|
extern crate webrender_api;
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use gfx::font::{fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontSearchScope};
|
use gfx::font::{
|
||||||
use gfx::font_cache_thread::{FontTemplates, FontTemplateInfo};
|
fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontSearchScope,
|
||||||
|
};
|
||||||
|
use gfx::font_cache_thread::{FontTemplateInfo, FontTemplates};
|
||||||
use gfx::font_context::{FontContext, FontContextHandle, FontSource};
|
use gfx::font_context::{FontContext, FontContextHandle, FontSource};
|
||||||
use gfx::font_template::FontTemplateDescriptor;
|
use gfx::font_template::FontTemplateDescriptor;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
|
@ -24,7 +26,9 @@ use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps;
|
use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps;
|
||||||
use style::properties::style_structs::Font as FontStyleStruct;
|
use style::properties::style_structs::Font as FontStyleStruct;
|
||||||
use style::values::computed::font::{FamilyName, FamilyNameSyntax, FontFamily, FontFamilyList, FontSize};
|
use style::values::computed::font::{
|
||||||
|
FamilyName, FamilyNameSyntax, FontFamily, FontFamilyList, FontSize,
|
||||||
|
};
|
||||||
use style::values::computed::font::{FontStretch, FontWeight, SingleFontFamily};
|
use style::values::computed::font::{FontStretch, FontWeight, SingleFontFamily};
|
||||||
use style::values::generics::font::FontStyle;
|
use style::values::generics::font::FontStyle;
|
||||||
|
|
||||||
|
@ -119,7 +123,8 @@ fn font_family(names: Vec<&str>) -> FontFamily {
|
||||||
name: Atom::from(name),
|
name: Atom::from(name),
|
||||||
syntax: FamilyNameSyntax::Quoted,
|
syntax: FamilyNameSyntax::Quoted,
|
||||||
})
|
})
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
FontFamily(FontFamilyList::new(names.into_boxed_slice()))
|
FontFamily(FontFamilyList::new(names.into_boxed_slice()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ fn test_font_template_descriptor() {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use style::values::computed::Percentage;
|
|
||||||
use style::values::computed::font::{FontStretch, FontWeight};
|
use style::values::computed::font::{FontStretch, FontWeight};
|
||||||
use style::values::generics::NonNegative;
|
use style::values::computed::Percentage;
|
||||||
use style::values::generics::font::FontStyle;
|
use style::values::generics::font::FontStyle;
|
||||||
|
use style::values::generics::NonNegative;
|
||||||
|
|
||||||
fn descriptor(filename: &str) -> FontTemplateDescriptor {
|
fn descriptor(filename: &str) -> FontTemplateDescriptor {
|
||||||
let mut path: PathBuf = [
|
let mut path: PathBuf = [
|
||||||
|
@ -41,7 +41,8 @@ fn test_font_template_descriptor() {
|
||||||
let mut template = FontTemplate::new(
|
let mut template = FontTemplate::new(
|
||||||
Atom::from(filename),
|
Atom::from(filename),
|
||||||
Some(file.bytes().map(|b| b.unwrap()).collect()),
|
Some(file.bytes().map(|b| b.unwrap()).collect()),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let context = FontContextHandle::new();
|
let context = FontContextHandle::new();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
extern crate gfx;
|
extern crate gfx;
|
||||||
|
|
||||||
use gfx::text::util::{CompressionMode, transform_text};
|
use gfx::text::util::{transform_text, CompressionMode};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_transform_compress_none() {
|
fn test_transform_compress_none() {
|
||||||
|
|
|
@ -10,9 +10,9 @@ use euclid::Point2D;
|
||||||
))]
|
))]
|
||||||
use packed_simd::u32x4;
|
use packed_simd::u32x4;
|
||||||
use range::{self, EachIndex, Range, RangeIndex};
|
use range::{self, EachIndex, Range, RangeIndex};
|
||||||
use std::{fmt, mem, u16};
|
|
||||||
use std::cmp::{Ordering, PartialOrd};
|
use std::cmp::{Ordering, PartialOrd};
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
use std::{fmt, mem, u16};
|
||||||
|
|
||||||
pub use gfx_traits::ByteIndex;
|
pub use gfx_traits::ByteIndex;
|
||||||
|
|
||||||
|
@ -223,16 +223,15 @@ impl<'a> DetailedGlyphStore {
|
||||||
entry_offset, glyphs
|
entry_offset, glyphs
|
||||||
);
|
);
|
||||||
|
|
||||||
/* TODO: don't actually assert this until asserts are compiled
|
// TODO: don't actually assert this until asserts are compiled
|
||||||
in/out based on severity, debug/release, etc. This assertion
|
// in/out based on severity, debug/release, etc. This assertion
|
||||||
would wreck the complexity of the lookup.
|
// would wreck the complexity of the lookup.
|
||||||
|
//
|
||||||
See Rust Issue #3647, #2228, #3627 for related information.
|
// See Rust Issue #3647, #2228, #3627 for related information.
|
||||||
|
//
|
||||||
do self.detail_lookup.borrow |arr| {
|
// do self.detail_lookup.borrow |arr| {
|
||||||
assert !arr.contains(entry)
|
// assert !arr.contains(entry)
|
||||||
}
|
// }
|
||||||
*/
|
|
||||||
|
|
||||||
self.detail_lookup.push(entry);
|
self.detail_lookup.push(entry);
|
||||||
self.detail_buffer.extend_from_slice(glyphs);
|
self.detail_buffer.extend_from_slice(glyphs);
|
||||||
|
@ -541,7 +540,8 @@ impl<'a> GlyphStore {
|
||||||
data_for_glyphs[i].advance,
|
data_for_glyphs[i].advance,
|
||||||
data_for_glyphs[i].offset,
|
data_for_glyphs[i].offset,
|
||||||
)
|
)
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
self.has_detailed_glyphs = true;
|
self.has_detailed_glyphs = true;
|
||||||
self.detail_store
|
self.detail_store
|
||||||
|
|
|
@ -5,15 +5,7 @@
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::font::{ShapingFlags, Font, FontTableMethods, FontTableTag, ShapingOptions, KERN};
|
use crate::font::{Font, FontTableMethods, FontTableTag, ShapingFlags, ShapingOptions, KERN};
|
||||||
use crate::harfbuzz::{HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY};
|
|
||||||
use crate::harfbuzz::{hb_blob_create, hb_face_create_for_tables};
|
|
||||||
use crate::harfbuzz::{hb_buffer_create, hb_font_destroy};
|
|
||||||
use crate::harfbuzz::{hb_buffer_get_glyph_infos, hb_shape};
|
|
||||||
use crate::harfbuzz::{hb_buffer_set_direction, hb_buffer_set_script};
|
|
||||||
use crate::harfbuzz::{hb_buffer_t, hb_codepoint_t, hb_font_funcs_t};
|
|
||||||
use crate::harfbuzz::{hb_face_t, hb_font_t};
|
|
||||||
use crate::harfbuzz::{hb_position_t, hb_tag_t};
|
|
||||||
use crate::harfbuzz::hb_blob_t;
|
use crate::harfbuzz::hb_blob_t;
|
||||||
use crate::harfbuzz::hb_bool_t;
|
use crate::harfbuzz::hb_bool_t;
|
||||||
use crate::harfbuzz::hb_buffer_add_utf8;
|
use crate::harfbuzz::hb_buffer_add_utf8;
|
||||||
|
@ -32,13 +24,21 @@ use crate::harfbuzz::hb_font_set_ppem;
|
||||||
use crate::harfbuzz::hb_font_set_scale;
|
use crate::harfbuzz::hb_font_set_scale;
|
||||||
use crate::harfbuzz::hb_glyph_info_t;
|
use crate::harfbuzz::hb_glyph_info_t;
|
||||||
use crate::harfbuzz::hb_glyph_position_t;
|
use crate::harfbuzz::hb_glyph_position_t;
|
||||||
|
use crate::harfbuzz::{hb_blob_create, hb_face_create_for_tables};
|
||||||
|
use crate::harfbuzz::{hb_buffer_create, hb_font_destroy};
|
||||||
|
use crate::harfbuzz::{hb_buffer_get_glyph_infos, hb_shape};
|
||||||
|
use crate::harfbuzz::{hb_buffer_set_direction, hb_buffer_set_script};
|
||||||
|
use crate::harfbuzz::{hb_buffer_t, hb_codepoint_t, hb_font_funcs_t};
|
||||||
|
use crate::harfbuzz::{hb_face_t, hb_font_t};
|
||||||
|
use crate::harfbuzz::{hb_position_t, hb_tag_t};
|
||||||
|
use crate::harfbuzz::{HB_DIRECTION_LTR, HB_DIRECTION_RTL, HB_MEMORY_MODE_READONLY};
|
||||||
use crate::platform::font::FontTable;
|
use crate::platform::font::FontTable;
|
||||||
use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore};
|
use crate::text::glyph::{ByteIndex, GlyphData, GlyphId, GlyphStore};
|
||||||
use crate::text::shaping::ShaperMethods;
|
use crate::text::shaping::ShaperMethods;
|
||||||
use crate::text::util::{fixed_to_float, float_to_fixed, is_bidi_control};
|
use crate::text::util::{fixed_to_float, float_to_fixed, is_bidi_control};
|
||||||
use euclid::Point2D;
|
use euclid::Point2D;
|
||||||
use std::{char, cmp, ptr};
|
|
||||||
use std::os::raw::{c_char, c_int, c_uint, c_void};
|
use std::os::raw::{c_char, c_int, c_uint, c_void};
|
||||||
|
use std::{char, cmp, ptr};
|
||||||
|
|
||||||
const NO_GLYPH: i32 = -1;
|
const NO_GLYPH: i32 = -1;
|
||||||
const LIGA: u32 = ot_tag!('l', 'i', 'g', 'a');
|
const LIGA: u32 = ot_tag!('l', 'i', 'g', 'a');
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::platform::font_template::FontTemplateData;
|
||||||
use crate::text::glyph::{ByteIndex, GlyphStore};
|
use crate::text::glyph::{ByteIndex, GlyphStore};
|
||||||
use range::Range;
|
use range::Range;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::cmp::{Ordering, max};
|
use std::cmp::{max, Ordering};
|
||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::str::char_is_whitespace;
|
use style::str::char_is_whitespace;
|
||||||
|
@ -380,7 +380,8 @@ impl<'a> TextRun {
|
||||||
);
|
);
|
||||||
remaining -= slice_advance;
|
remaining -= slice_advance;
|
||||||
slice_index
|
slice_index
|
||||||
}).sum()
|
})
|
||||||
|
.sum()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator that will iterate over all slices of glyphs that represent natural
|
/// Returns an iterator that will iterate over all slices of glyphs that represent natural
|
||||||
|
|
|
@ -17,7 +17,7 @@ extern crate serde;
|
||||||
pub mod print_tree;
|
pub mod print_tree;
|
||||||
|
|
||||||
use range::RangeIndex;
|
use range::RangeIndex;
|
||||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
||||||
|
|
||||||
/// A newtype struct for denoting the age of messages; prevents race conditions.
|
/// A newtype struct for denoting the age of messages; prevents race conditions.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||||
|
|
|
@ -20,8 +20,8 @@ use std::fmt;
|
||||||
use std::hash::{BuildHasher, Hash};
|
use std::hash::{BuildHasher, Hash};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
pub use std::collections::hash_map::{Entry, RandomState, Iter as MapIter, IterMut as MapIterMut};
|
pub use std::collections::hash_map::{Entry, Iter as MapIter, IterMut as MapIterMut, RandomState};
|
||||||
pub use std::collections::hash_set::{Iter as SetIter, IntoIter as SetIntoIter};
|
pub use std::collections::hash_set::{IntoIter as SetIntoIter, Iter as SetIter};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct HashMap<K, V, S = RandomState>(StdMap<K, V, S>);
|
pub struct HashMap<K, V, S = RandomState>(StdMap<K, V, S>);
|
||||||
|
|
|
@ -15,13 +15,13 @@ use std::borrow::Borrow;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::fmt::{self, Debug};
|
use std::fmt::{self, Debug};
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
use std::hash::{Hash, BuildHasher};
|
use std::hash::{BuildHasher, Hash};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::mem::{self, replace};
|
use std::mem::{self, replace};
|
||||||
use std::ops::{Deref, Index};
|
use std::ops::{Deref, Index};
|
||||||
|
|
||||||
use super::table::{self, Bucket, EmptyBucket, FullBucket, FullBucketMut, RawTable, SafeHash};
|
|
||||||
use super::table::BucketState::{Empty, Full};
|
use super::table::BucketState::{Empty, Full};
|
||||||
|
use super::table::{self, Bucket, EmptyBucket, FullBucket, FullBucketMut, RawTable, SafeHash};
|
||||||
|
|
||||||
use FailedAllocationError;
|
use FailedAllocationError;
|
||||||
|
|
||||||
|
@ -2214,11 +2214,11 @@ fn assert_covariance() {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_map {
|
mod test_map {
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
use super::HashMap;
|
use self::rand::{thread_rng, Rng};
|
||||||
use super::Entry::{Occupied, Vacant};
|
use super::Entry::{Occupied, Vacant};
|
||||||
|
use super::HashMap;
|
||||||
use super::RandomState;
|
use super::RandomState;
|
||||||
use cell::RefCell;
|
use cell::RefCell;
|
||||||
use self::rand::{thread_rng, Rng};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_zero_capacities() {
|
fn test_zero_capacities() {
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::{Hash, BuildHasher};
|
use std::hash::{BuildHasher, Hash};
|
||||||
use std::iter::{Chain, FromIterator};
|
use std::iter::{Chain, FromIterator};
|
||||||
use std::ops::{BitOr, BitAnd, BitXor, Sub};
|
use std::ops::{BitAnd, BitOr, BitXor, Sub};
|
||||||
|
|
||||||
use super::Recover;
|
|
||||||
use super::hash_map::{self, HashMap, Keys, RandomState};
|
use super::hash_map::{self, HashMap, Keys, RandomState};
|
||||||
|
use super::Recover;
|
||||||
|
|
||||||
// Future Optimization (FIXME!)
|
// Future Optimization (FIXME!)
|
||||||
// =============================
|
// =============================
|
||||||
|
@ -1258,8 +1258,8 @@ fn assert_covariance() {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_set {
|
mod test_set {
|
||||||
use super::HashSet;
|
|
||||||
use super::hash_map::RandomState;
|
use super::hash_map::RandomState;
|
||||||
|
use super::HashSet;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_zero_capacities() {
|
fn test_zero_capacities() {
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use alloc::{alloc, dealloc};
|
use alloc::{alloc, dealloc};
|
||||||
|
use shim::{Shared, Unique};
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::hash::{BuildHasher, Hash, Hasher};
|
use std::hash::{BuildHasher, Hash, Hasher};
|
||||||
use std::marker;
|
use std::marker;
|
||||||
use std::mem::{self, align_of, size_of};
|
use std::mem::{self, align_of, size_of};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use shim::{Unique, Shared};
|
|
||||||
|
|
||||||
use self::BucketState::*;
|
use self::BucketState::*;
|
||||||
use FailedAllocationError;
|
use FailedAllocationError;
|
||||||
|
|
|
@ -11,10 +11,10 @@ use crate::opaque_node::OpaqueNodeMethods;
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg};
|
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
|
use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg};
|
||||||
use servo_channel::Receiver;
|
use servo_channel::Receiver;
|
||||||
use style::animation::{Animation, update_style_for_animation};
|
use style::animation::{update_style_for_animation, Animation};
|
||||||
use style::dom::TElement;
|
use style::dom::TElement;
|
||||||
use style::font_metrics::ServoMetricsProvider;
|
use style::font_metrics::ServoMetricsProvider;
|
||||||
use style::selector_parser::RestyleDamage;
|
use style::selector_parser::RestyleDamage;
|
||||||
|
@ -89,7 +89,10 @@ pub fn update_animation_state<E>(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("update_animation_state({:?}): {:?}", still_running, running_animation);
|
debug!(
|
||||||
|
"update_animation_state({:?}): {:?}",
|
||||||
|
still_running, running_animation
|
||||||
|
);
|
||||||
|
|
||||||
if still_running {
|
if still_running {
|
||||||
animations_still_running.push(running_animation);
|
animations_still_running.push(running_animation);
|
||||||
|
@ -97,11 +100,13 @@ pub fn update_animation_state<E>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Animation::Transition(node, _, ref frame) = running_animation {
|
if let Animation::Transition(node, _, ref frame) = running_animation {
|
||||||
script_chan.send(ConstellationControlMsg::TransitionEnd(
|
script_chan
|
||||||
node.to_untrusted_node_address(),
|
.send(ConstellationControlMsg::TransitionEnd(
|
||||||
frame.property_animation.property_name().into(),
|
node.to_untrusted_node_address(),
|
||||||
frame.duration,
|
frame.property_animation.property_name().into(),
|
||||||
)).unwrap();
|
frame.duration,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
expired_animations
|
expired_animations
|
||||||
|
@ -150,7 +155,8 @@ pub fn update_animation_state<E>(
|
||||||
.send(ConstellationMsg::ChangeRunningAnimationsState(
|
.send(ConstellationMsg::ChangeRunningAnimationsState(
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
animation_state,
|
animation_state,
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Recalculates style for a set of animations. This does *not* run with the DOM
|
/// Recalculates style for a set of animations. This does *not* run with the DOM
|
||||||
|
|
|
@ -27,18 +27,26 @@
|
||||||
|
|
||||||
use app_units::{Au, MAX_AU};
|
use app_units::{Au, MAX_AU};
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
|
use crate::display_list::items::DisplayListSection;
|
||||||
|
use crate::display_list::StackingContextCollectionState;
|
||||||
use crate::display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
|
use crate::display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
|
||||||
use crate::display_list::{DisplayListBuildState, StackingContextCollectionFlags};
|
use crate::display_list::{DisplayListBuildState, StackingContextCollectionFlags};
|
||||||
use crate::display_list::StackingContextCollectionState;
|
|
||||||
use crate::display_list::items::DisplayListSection;
|
|
||||||
use crate::floats::{ClearType, FloatKind, Floats, PlacementInfo};
|
use crate::floats::{ClearType, FloatKind, Floats, PlacementInfo};
|
||||||
use crate::flow::{BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag, GetBaseFlow};
|
use crate::flow::{
|
||||||
use crate::flow::{ImmutableFlowUtils, LateAbsolutePositionInfo, OpaqueFlow, FragmentationContext, FlowFlags};
|
BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag, GetBaseFlow,
|
||||||
|
};
|
||||||
|
use crate::flow::{
|
||||||
|
FlowFlags, FragmentationContext, ImmutableFlowUtils, LateAbsolutePositionInfo, OpaqueFlow,
|
||||||
|
};
|
||||||
use crate::flow_list::FlowList;
|
use crate::flow_list::FlowList;
|
||||||
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow, FragmentFlags};
|
use crate::fragment::{
|
||||||
|
CoordinateSystem, Fragment, FragmentBorderBoxIterator, FragmentFlags, Overflow,
|
||||||
|
};
|
||||||
use crate::incremental::RelayoutMode;
|
use crate::incremental::RelayoutMode;
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
use crate::model::{AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
|
use crate::model::{
|
||||||
|
AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto,
|
||||||
|
};
|
||||||
use crate::sequential;
|
use crate::sequential;
|
||||||
use crate::traversal::PreorderFlowTraversal;
|
use crate::traversal::PreorderFlowTraversal;
|
||||||
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
|
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
|
||||||
|
@ -58,8 +66,8 @@ use style::context::SharedStyleContext;
|
||||||
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
|
|
||||||
use style::values::computed::LengthOrPercentageOrAuto;
|
use style::values::computed::LengthOrPercentageOrAuto;
|
||||||
|
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrNone};
|
||||||
|
|
||||||
/// Information specific to floated blocks.
|
/// Information specific to floated blocks.
|
||||||
#[derive(Clone, Serialize)]
|
#[derive(Clone, Serialize)]
|
||||||
|
@ -1334,7 +1342,8 @@ impl BlockFlow {
|
||||||
self.fragment.style.writing_mode,
|
self.fragment.style.writing_mode,
|
||||||
inline_size_for_float_placement,
|
inline_size_for_float_placement,
|
||||||
block_size + self.fragment.margin.block_start_end(),
|
block_size + self.fragment.margin.block_start_end(),
|
||||||
).convert(
|
)
|
||||||
|
.convert(
|
||||||
self.fragment.style.writing_mode,
|
self.fragment.style.writing_mode,
|
||||||
self.base.floats.writing_mode,
|
self.base.floats.writing_mode,
|
||||||
),
|
),
|
||||||
|
@ -1361,7 +1370,8 @@ impl BlockFlow {
|
||||||
self.base.floats.writing_mode,
|
self.base.floats.writing_mode,
|
||||||
self.base.writing_mode,
|
self.base.writing_mode,
|
||||||
container_size,
|
container_size,
|
||||||
).start;
|
)
|
||||||
|
.start;
|
||||||
let margin_offset = LogicalPoint::new(
|
let margin_offset = LogicalPoint::new(
|
||||||
self.base.writing_mode,
|
self.base.writing_mode,
|
||||||
Au(0),
|
Au(0),
|
||||||
|
@ -2626,7 +2636,8 @@ impl Flow for BlockFlow {
|
||||||
.early_absolute_position_info
|
.early_absolute_position_info
|
||||||
.relative_containing_block_mode,
|
.relative_containing_block_mode,
|
||||||
CoordinateSystem::Own,
|
CoordinateSystem::Own,
|
||||||
).translate(&stacking_context_position.to_vector()),
|
)
|
||||||
|
.translate(&stacking_context_position.to_vector()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,21 +11,28 @@
|
||||||
//! maybe it's an absolute or fixed position thing that hasn't found its containing block yet.
|
//! maybe it's an absolute or fixed position thing that hasn't found its containing block yet.
|
||||||
//! Construction items bubble up the tree from children to parents until they find their homes.
|
//! Construction items bubble up the tree from children to parents until they find their homes.
|
||||||
|
|
||||||
use crate::ServoArc;
|
|
||||||
use crate::block::BlockFlow;
|
use crate::block::BlockFlow;
|
||||||
use crate::context::{LayoutContext, with_thread_local_font_context};
|
use crate::context::{with_thread_local_font_context, LayoutContext};
|
||||||
use crate::data::{LayoutDataFlags, LayoutData};
|
use crate::data::{LayoutData, LayoutDataFlags};
|
||||||
use crate::display_list::items::OpaqueNode;
|
use crate::display_list::items::OpaqueNode;
|
||||||
use crate::flex::FlexFlow;
|
use crate::flex::FlexFlow;
|
||||||
use crate::floats::FloatKind;
|
use crate::floats::FloatKind;
|
||||||
use crate::flow::{AbsoluteDescendants, Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils};
|
use crate::flow::{AbsoluteDescendants, Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils};
|
||||||
use crate::flow::{FlowFlags, MutableFlowUtils, MutableOwnedFlowUtils};
|
use crate::flow::{FlowFlags, MutableFlowUtils, MutableOwnedFlowUtils};
|
||||||
use crate::flow_ref::FlowRef;
|
use crate::flow_ref::FlowRef;
|
||||||
use crate::fragment::{CanvasFragmentInfo, Fragment, FragmentFlags, GeneratedContentInfo, IframeFragmentInfo};
|
use crate::fragment::{
|
||||||
use crate::fragment::{ImageFragmentInfo, InlineAbsoluteFragmentInfo, InlineAbsoluteHypotheticalFragmentInfo};
|
CanvasFragmentInfo, Fragment, FragmentFlags, GeneratedContentInfo, IframeFragmentInfo,
|
||||||
use crate::fragment::{InlineBlockFragmentInfo, MediaFragmentInfo, SpecificFragmentInfo, SvgFragmentInfo};
|
};
|
||||||
use crate::fragment::{TableColumnFragmentInfo, UnscannedTextFragmentInfo, WhitespaceStrippingResult};
|
use crate::fragment::{
|
||||||
use crate::inline::{InlineFlow, InlineFragmentNodeInfo, InlineFragmentNodeFlags};
|
ImageFragmentInfo, InlineAbsoluteFragmentInfo, InlineAbsoluteHypotheticalFragmentInfo,
|
||||||
|
};
|
||||||
|
use crate::fragment::{
|
||||||
|
InlineBlockFragmentInfo, MediaFragmentInfo, SpecificFragmentInfo, SvgFragmentInfo,
|
||||||
|
};
|
||||||
|
use crate::fragment::{
|
||||||
|
TableColumnFragmentInfo, UnscannedTextFragmentInfo, WhitespaceStrippingResult,
|
||||||
|
};
|
||||||
|
use crate::inline::{InlineFlow, InlineFragmentNodeFlags, InlineFragmentNodeInfo};
|
||||||
use crate::linked_list::prepend_from;
|
use crate::linked_list::prepend_from;
|
||||||
use crate::list_item::{ListItemFlow, ListStyleTypeContent};
|
use crate::list_item::{ListItemFlow, ListStyleTypeContent};
|
||||||
use crate::multicol::{MulticolColumnFlow, MulticolFlow};
|
use crate::multicol::{MulticolColumnFlow, MulticolFlow};
|
||||||
|
@ -40,15 +47,18 @@ use crate::table_wrapper::TableWrapperFlow;
|
||||||
use crate::text::TextRunScanner;
|
use crate::text::TextRunScanner;
|
||||||
use crate::traversal::PostorderNodeMutTraversal;
|
use crate::traversal::PostorderNodeMutTraversal;
|
||||||
use crate::wrapper::{LayoutNodeLayoutData, TextContent, ThreadSafeLayoutNodeHelpers};
|
use crate::wrapper::{LayoutNodeLayoutData, TextContent, ThreadSafeLayoutNodeHelpers};
|
||||||
use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data};
|
use crate::ServoArc;
|
||||||
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
use script_layout_interface::wrapper_traits::{
|
||||||
|
PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
|
||||||
|
};
|
||||||
|
use script_layout_interface::{is_image_data, LayoutElementType, LayoutNodeType};
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::collections::LinkedList;
|
use std::collections::LinkedList;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
|
use std::sync::Arc;
|
||||||
use style::computed_values::caption_side::T as CaptionSide;
|
use style::computed_values::caption_side::T as CaptionSide;
|
||||||
use style::computed_values::display::T as Display;
|
use style::computed_values::display::T as Display;
|
||||||
use style::computed_values::empty_cells::T as EmptyCells;
|
use style::computed_values::empty_cells::T as EmptyCells;
|
||||||
|
@ -185,7 +195,8 @@ impl InlineBlockSplit {
|
||||||
predecessors: mem::replace(
|
predecessors: mem::replace(
|
||||||
fragment_accumulator,
|
fragment_accumulator,
|
||||||
InlineFragmentsAccumulator::from_inline_node(node, style_context),
|
InlineFragmentsAccumulator::from_inline_node(node, style_context),
|
||||||
).to_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(style_context),
|
)
|
||||||
|
.to_intermediate_inline_fragments::<ConcreteThreadSafeLayoutNode>(style_context),
|
||||||
flow: flow,
|
flow: flow,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -402,7 +413,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
&self.layout_context,
|
&self.layout_context,
|
||||||
));
|
));
|
||||||
SpecificFragmentInfo::Image(image_info)
|
SpecificFragmentInfo::Image(image_info)
|
||||||
}
|
},
|
||||||
Some(LayoutNodeType::Element(LayoutElementType::HTMLMediaElement)) => {
|
Some(LayoutNodeType::Element(LayoutElementType::HTMLMediaElement)) => {
|
||||||
let data = node.media_data().unwrap();
|
let data = node.media_data().unwrap();
|
||||||
SpecificFragmentInfo::Media(Box::new(MediaFragmentInfo::new(data)))
|
SpecificFragmentInfo::Media(Box::new(MediaFragmentInfo::new(data)))
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//! Data needed by the layout thread.
|
//! Data needed by the layout thread.
|
||||||
|
|
||||||
use crate::display_list::items::{WebRenderImageInfo, OpaqueNode};
|
use crate::display_list::items::{OpaqueNode, WebRenderImageInfo};
|
||||||
use crate::opaque_node::OpaqueNodeMethods;
|
use crate::opaque_node::OpaqueNodeMethods;
|
||||||
use fnv::FnvHasher;
|
use fnv::FnvHasher;
|
||||||
use gfx::font_cache_thread::FontCacheThread;
|
use gfx::font_cache_thread::FontCacheThread;
|
||||||
|
|
|
@ -13,8 +13,8 @@ use style::computed_values::background_clip::single_value::T as BackgroundClip;
|
||||||
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
|
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
|
||||||
use style::properties::style_structs::Background;
|
use style::properties::style_structs::Background;
|
||||||
use style::values::computed::{BackgroundSize, LengthOrPercentageOrAuto};
|
use style::values::computed::{BackgroundSize, LengthOrPercentageOrAuto};
|
||||||
use style::values::generics::NonNegative;
|
|
||||||
use style::values::generics::background::BackgroundSize as GenericBackgroundSize;
|
use style::values::generics::background::BackgroundSize as GenericBackgroundSize;
|
||||||
|
use style::values::generics::NonNegative;
|
||||||
use style::values::specified::background::BackgroundRepeatKeyword;
|
use style::values::specified::background::BackgroundRepeatKeyword;
|
||||||
use webrender_api::BorderRadius;
|
use webrender_api::BorderRadius;
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,14 @@ use crate::display_list::ToLayout;
|
||||||
use euclid::{Rect, SideOffsets2D, Size2D};
|
use euclid::{Rect, SideOffsets2D, Size2D};
|
||||||
use style::computed_values::border_image_outset::T as BorderImageOutset;
|
use style::computed_values::border_image_outset::T as BorderImageOutset;
|
||||||
use style::properties::style_structs::Border;
|
use style::properties::style_structs::Border;
|
||||||
use style::values::Either;
|
use style::values::computed::NumberOrPercentage;
|
||||||
use style::values::computed::{BorderCornerRadius, BorderImageWidth};
|
use style::values::computed::{BorderCornerRadius, BorderImageWidth};
|
||||||
use style::values::computed::{BorderImageSideWidth, LengthOrNumber};
|
use style::values::computed::{BorderImageSideWidth, LengthOrNumber};
|
||||||
use style::values::computed::NumberOrPercentage;
|
use style::values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
|
||||||
use style::values::generics::border::{BorderImageSideWidth as GenericBorderImageSideWidth};
|
|
||||||
use style::values::generics::rect::Rect as StyleRect;
|
use style::values::generics::rect::Rect as StyleRect;
|
||||||
|
use style::values::Either;
|
||||||
use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF};
|
use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF};
|
||||||
use webrender_api::{LayoutSize, LayoutSideOffsets, NormalBorder};
|
use webrender_api::{LayoutSideOffsets, LayoutSize, NormalBorder};
|
||||||
|
|
||||||
/// Computes a border radius size against the containing size.
|
/// Computes a border radius size against the containing size.
|
||||||
///
|
///
|
||||||
|
|
|
@ -12,31 +12,31 @@ use app_units::{Au, AU_PER_PX};
|
||||||
use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg};
|
use canvas_traits::canvas::{CanvasMsg, FromLayoutMsg};
|
||||||
use crate::block::BlockFlow;
|
use crate::block::BlockFlow;
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::ToLayout;
|
|
||||||
use crate::display_list::background::{self, get_cyclic};
|
use crate::display_list::background::{self, get_cyclic};
|
||||||
use crate::display_list::border;
|
use crate::display_list::border;
|
||||||
use crate::display_list::gradient;
|
use crate::display_list::gradient;
|
||||||
use crate::display_list::items::{BaseDisplayItem, BLUR_INFLATION_FACTOR, ClipScrollNode};
|
use crate::display_list::items::{BaseDisplayItem, ClipScrollNode, BLUR_INFLATION_FACTOR};
|
||||||
use crate::display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
|
use crate::display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
|
||||||
use crate::display_list::items::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
|
use crate::display_list::items::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
|
||||||
use crate::display_list::items::{DisplayListSection, CommonDisplayItem};
|
use crate::display_list::items::{CommonDisplayItem, DisplayListSection};
|
||||||
use crate::display_list::items::{IframeDisplayItem, OpaqueNode};
|
use crate::display_list::items::{IframeDisplayItem, OpaqueNode};
|
||||||
use crate::display_list::items::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem};
|
use crate::display_list::items::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem};
|
||||||
use crate::display_list::items::{StackingContext, StackingContextType, StickyFrameData};
|
use crate::display_list::items::{StackingContext, StackingContextType, StickyFrameData};
|
||||||
use crate::display_list::items::{TextOrientation, WebRenderImageInfo};
|
use crate::display_list::items::{TextOrientation, WebRenderImageInfo};
|
||||||
|
use crate::display_list::ToLayout;
|
||||||
use crate::flex::FlexFlow;
|
use crate::flex::FlexFlow;
|
||||||
use crate::flow::{BaseFlow, Flow, FlowFlags};
|
use crate::flow::{BaseFlow, Flow, FlowFlags};
|
||||||
use crate::flow_ref::FlowRef;
|
use crate::flow_ref::FlowRef;
|
||||||
use crate::fragment::{CanvasFragmentSource, CoordinateSystem, Fragment, ScannedTextFragmentInfo};
|
|
||||||
use crate::fragment::SpecificFragmentInfo;
|
use crate::fragment::SpecificFragmentInfo;
|
||||||
|
use crate::fragment::{CanvasFragmentSource, CoordinateSystem, Fragment, ScannedTextFragmentInfo};
|
||||||
use crate::inline::{InlineFlow, InlineFragmentNodeFlags};
|
use crate::inline::{InlineFlow, InlineFragmentNodeFlags};
|
||||||
use crate::list_item::ListItemFlow;
|
use crate::list_item::ListItemFlow;
|
||||||
use crate::model::MaybeAuto;
|
use crate::model::MaybeAuto;
|
||||||
use crate::table_cell::CollapsedBordersForCell;
|
use crate::table_cell::CollapsedBordersForCell;
|
||||||
use euclid::{rect, Point2D, Rect, SideOffsets2D, Size2D, TypedSize2D, Vector2D};
|
use euclid::{rect, Point2D, Rect, SideOffsets2D, Size2D, TypedSize2D, Vector2D};
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use gfx::text::TextRun;
|
|
||||||
use gfx::text::glyph::ByteIndex;
|
use gfx::text::glyph::ByteIndex;
|
||||||
|
use gfx::text::TextRun;
|
||||||
use gfx_traits::{combine_id_with_fragment_type, FragmentType, StackingContextId};
|
use gfx_traits::{combine_id_with_fragment_type, FragmentType, StackingContextId};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
|
@ -56,20 +56,20 @@ use style::computed_values::visibility::T as Visibility;
|
||||||
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect};
|
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect};
|
||||||
use style::properties::{style_structs, ComputedValues};
|
use style::properties::{style_structs, ComputedValues};
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::{Either, RGBA};
|
|
||||||
use style::values::computed::Gradient;
|
|
||||||
use style::values::computed::effects::SimpleShadow;
|
use style::values::computed::effects::SimpleShadow;
|
||||||
use style::values::computed::image::Image as ComputedImage;
|
use style::values::computed::image::Image as ComputedImage;
|
||||||
|
use style::values::computed::Gradient;
|
||||||
use style::values::generics::background::BackgroundSize;
|
use style::values::generics::background::BackgroundSize;
|
||||||
use style::values::generics::image::{GradientKind, Image, PaintWorklet};
|
use style::values::generics::image::{GradientKind, Image, PaintWorklet};
|
||||||
use style::values::generics::ui::Cursor;
|
use style::values::generics::ui::Cursor;
|
||||||
|
use style::values::{Either, RGBA};
|
||||||
|
use style_traits::cursor::CursorKind;
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use style_traits::cursor::CursorKind;
|
|
||||||
use webrender_api::{self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF};
|
use webrender_api::{self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF};
|
||||||
use webrender_api::{ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LayoutRect};
|
use webrender_api::{ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LayoutRect};
|
||||||
use webrender_api::{LayoutSize, LayoutTransform, LayoutVector2D, LineStyle, NinePatchBorder};
|
use webrender_api::{LayoutSize, LayoutTransform, LayoutVector2D, LineStyle, NinePatchBorder};
|
||||||
use webrender_api::{NinePatchBorderSource, NormalBorder, StickyOffsetBounds, ScrollSensitivity};
|
use webrender_api::{NinePatchBorderSource, NormalBorder, ScrollSensitivity, StickyOffsetBounds};
|
||||||
|
|
||||||
fn establishes_containing_block_for_absolute(
|
fn establishes_containing_block_for_absolute(
|
||||||
flags: StackingContextCollectionFlags,
|
flags: StackingContextCollectionFlags,
|
||||||
|
|
|
@ -7,10 +7,10 @@ use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D};
|
||||||
use style::computed_values::image_rendering::T as ImageRendering;
|
use style::computed_values::image_rendering::T as ImageRendering;
|
||||||
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
||||||
use style::computed_values::transform_style::T as TransformStyle;
|
use style::computed_values::transform_style::T as TransformStyle;
|
||||||
use style::values::RGBA;
|
|
||||||
use style::values::computed::{BorderStyle, Filter};
|
use style::values::computed::{BorderStyle, Filter};
|
||||||
use style::values::generics::effects::Filter as GenericFilter;
|
use style::values::generics::effects::Filter as GenericFilter;
|
||||||
use style::values::specified::border::BorderImageRepeatKeyword;
|
use style::values::specified::border::BorderImageRepeatKeyword;
|
||||||
|
use style::values::RGBA;
|
||||||
use webrender_api as wr;
|
use webrender_api as wr;
|
||||||
|
|
||||||
pub trait ToLayout {
|
pub trait ToLayout {
|
||||||
|
|
|
@ -8,11 +8,11 @@ use app_units::Au;
|
||||||
use crate::display_list::ToLayout;
|
use crate::display_list::ToLayout;
|
||||||
use euclid::{Point2D, Size2D, Vector2D};
|
use euclid::{Point2D, Size2D, Vector2D};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::{Angle, GradientItem, LengthOrPercentage, Percentage, Position};
|
|
||||||
use style::values::computed::image::{EndingShape, LineDirection};
|
use style::values::computed::image::{EndingShape, LineDirection};
|
||||||
use style::values::generics::image::{Circle, Ellipse, ShapeExtent};
|
use style::values::computed::{Angle, GradientItem, LengthOrPercentage, Percentage, Position};
|
||||||
use style::values::generics::image::EndingShape as GenericEndingShape;
|
use style::values::generics::image::EndingShape as GenericEndingShape;
|
||||||
use style::values::generics::image::GradientItem as GenericGradientItem;
|
use style::values::generics::image::GradientItem as GenericGradientItem;
|
||||||
|
use style::values::generics::image::{Circle, Ellipse, ShapeExtent};
|
||||||
use style::values::specified::position::{X, Y};
|
use style::values::specified::position::{X, Y};
|
||||||
use webrender_api::{ExtendMode, Gradient, GradientBuilder, GradientStop, RadialGradient};
|
use webrender_api::{ExtendMode, Gradient, GradientBuilder, GradientStop, RadialGradient};
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
//! low-level drawing primitives.
|
//! low-level drawing primitives.
|
||||||
|
|
||||||
use euclid::{SideOffsets2D, TypedRect, Vector2D};
|
use euclid::{SideOffsets2D, TypedRect, Vector2D};
|
||||||
use gfx_traits::{self, StackingContextId};
|
|
||||||
use gfx_traits::print_tree::PrintTree;
|
use gfx_traits::print_tree::PrintTree;
|
||||||
|
use gfx_traits::{self, StackingContextId};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use net_traits::image::base::Image;
|
use net_traits::image::base::Image;
|
||||||
use servo_geometry::MaxRect;
|
use servo_geometry::MaxRect;
|
||||||
|
@ -590,7 +590,8 @@ impl ClippingRegion {
|
||||||
rect: complex.rect.translate(delta),
|
rect: complex.rect.translate(delta),
|
||||||
radii: complex.radii,
|
radii: complex.radii,
|
||||||
mode: complex.mode,
|
mode: complex.mode,
|
||||||
}).collect(),
|
})
|
||||||
|
.collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
use app_units::{Au, MAX_AU};
|
use app_units::{Au, MAX_AU};
|
||||||
use crate::block::{AbsoluteAssignBSizesTraversal, BlockFlow, MarginsMayCollapseFlag};
|
use crate::block::{AbsoluteAssignBSizesTraversal, BlockFlow, MarginsMayCollapseFlag};
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::{DisplayListBuildState, FlexFlowDisplayListBuilding};
|
|
||||||
use crate::display_list::StackingContextCollectionState;
|
use crate::display_list::StackingContextCollectionState;
|
||||||
|
use crate::display_list::{DisplayListBuildState, FlexFlowDisplayListBuilding};
|
||||||
use crate::floats::FloatKind;
|
use crate::floats::FloatKind;
|
||||||
use crate::flow::{Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils, OpaqueFlow, FlowFlags};
|
use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, ImmutableFlowUtils, OpaqueFlow};
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
use crate::model::{AdjoiningMargins, CollapsibleMargins};
|
use crate::model::{AdjoiningMargins, CollapsibleMargins};
|
||||||
|
@ -27,8 +27,10 @@ use style::computed_values::justify_content::T as JustifyContent;
|
||||||
use style::logical_geometry::{Direction, LogicalSize};
|
use style::logical_geometry::{Direction, LogicalSize};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
|
||||||
use style::values::computed::flex::FlexBasis;
|
use style::values::computed::flex::FlexBasis;
|
||||||
|
use style::values::computed::{
|
||||||
|
LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone,
|
||||||
|
};
|
||||||
use style::values::generics::flex::FlexBasis as GenericFlexBasis;
|
use style::values::generics::flex::FlexBasis as GenericFlexBasis;
|
||||||
|
|
||||||
/// The size of an axis. May be a specified size, a min/max
|
/// The size of an axis. May be a specified size, a min/max
|
||||||
|
@ -922,7 +924,8 @@ impl Flow for FlexFlow {
|
||||||
.base
|
.base
|
||||||
.flags
|
.flags
|
||||||
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
|
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
|
||||||
}).map(|(index, flow)| FlexItem::new(index, flow))
|
})
|
||||||
|
.map(|(index, flow)| FlexItem::new(index, flow))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
items.sort_by_key(|item| item.order);
|
items.sort_by_key(|item| item.order);
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::block::{BlockFlow, FormattingContextType};
|
use crate::block::{BlockFlow, FormattingContextType};
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
|
|
||||||
use crate::display_list::items::ClippingAndScrolling;
|
use crate::display_list::items::ClippingAndScrolling;
|
||||||
|
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
|
||||||
use crate::flex::FlexFlow;
|
use crate::flex::FlexFlow;
|
||||||
use crate::floats::{Floats, SpeculatedFloatPlacement};
|
use crate::floats::{Floats, SpeculatedFloatPlacement};
|
||||||
use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
|
use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
|
||||||
|
@ -46,16 +46,16 @@ use crate::table_colgroup::TableColGroupFlow;
|
||||||
use crate::table_row::TableRowFlow;
|
use crate::table_row::TableRowFlow;
|
||||||
use crate::table_rowgroup::TableRowGroupFlow;
|
use crate::table_rowgroup::TableRowGroupFlow;
|
||||||
use crate::table_wrapper::TableWrapperFlow;
|
use crate::table_wrapper::TableWrapperFlow;
|
||||||
use euclid::{Point2D, Vector2D, Rect, Size2D};
|
use euclid::{Point2D, Rect, Size2D, Vector2D};
|
||||||
use gfx_traits::StackingContextId;
|
|
||||||
use gfx_traits::print_tree::PrintTree;
|
use gfx_traits::print_tree::PrintTree;
|
||||||
|
use gfx_traits::StackingContextId;
|
||||||
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||||
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect};
|
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, MaxRect};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter::Zip;
|
use std::iter::Zip;
|
||||||
use std::slice::IterMut;
|
use std::slice::IterMut;
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
|
use std::sync::Arc;
|
||||||
use style::computed_values::clear::T as Clear;
|
use style::computed_values::clear::T as Clear;
|
||||||
use style::computed_values::float::T as Float;
|
use style::computed_values::float::T as Float;
|
||||||
use style::computed_values::overflow_x::T as StyleOverflow;
|
use style::computed_values::overflow_x::T as StyleOverflow;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
use crate::flow::{Flow, FlowClass};
|
use crate::flow::{Flow, FlowClass};
|
||||||
use crate::flow_ref::FlowRef;
|
use crate::flow_ref::FlowRef;
|
||||||
use serde::ser::{Serialize, SerializeSeq, Serializer};
|
use serde::ser::{Serialize, SerializeSeq, Serializer};
|
||||||
use serde_json::{Map, Value, to_value};
|
use serde_json::{to_value, Map, Value};
|
||||||
use std::collections::{LinkedList, linked_list};
|
use std::collections::{linked_list, LinkedList};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -5,24 +5,24 @@
|
||||||
//! The `Fragment` type, which represents the leaves of the layout tree.
|
//! The `Fragment` type, which represents the leaves of the layout tree.
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use canvas_traits::canvas::{CanvasMsg, CanvasId};
|
use canvas_traits::canvas::{CanvasId, CanvasMsg};
|
||||||
use crate::ServoArc;
|
use crate::context::{with_thread_local_font_context, LayoutContext};
|
||||||
use crate::context::{LayoutContext, with_thread_local_font_context};
|
use crate::display_list::items::{ClipScrollNodeIndex, OpaqueNode, BLUR_INFLATION_FACTOR};
|
||||||
use crate::display_list::ToLayout;
|
use crate::display_list::ToLayout;
|
||||||
use crate::display_list::items::{BLUR_INFLATION_FACTOR, ClipScrollNodeIndex, OpaqueNode};
|
|
||||||
use crate::floats::ClearType;
|
use crate::floats::ClearType;
|
||||||
use crate::flow::{GetBaseFlow, ImmutableFlowUtils};
|
use crate::flow::{GetBaseFlow, ImmutableFlowUtils};
|
||||||
use crate::flow_ref::FlowRef;
|
use crate::flow_ref::FlowRef;
|
||||||
use crate::inline::{InlineFragmentNodeFlags, InlineFragmentContext, InlineFragmentNodeInfo};
|
use crate::inline::{InlineFragmentContext, InlineFragmentNodeFlags, InlineFragmentNodeInfo};
|
||||||
use crate::inline::{InlineMetrics, LineMetrics};
|
use crate::inline::{InlineMetrics, LineMetrics};
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
use crate::model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, SizeConstraint};
|
|
||||||
use crate::model::style_length;
|
use crate::model::style_length;
|
||||||
|
use crate::model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, SizeConstraint};
|
||||||
use crate::text;
|
use crate::text;
|
||||||
use crate::text::TextRunScanner;
|
use crate::text::TextRunScanner;
|
||||||
use crate::wrapper::ThreadSafeLayoutNodeHelpers;
|
use crate::wrapper::ThreadSafeLayoutNodeHelpers;
|
||||||
use euclid::{Point2D, Vector2D, Rect, Size2D};
|
use crate::ServoArc;
|
||||||
|
use euclid::{Point2D, Rect, Size2D, Vector2D};
|
||||||
use gfx;
|
use gfx;
|
||||||
use gfx::text::glyph::ByteIndex;
|
use gfx::text::glyph::ByteIndex;
|
||||||
use gfx::text::text_run::{TextRun, TextRunSlice};
|
use gfx::text::text_run::{TextRun, TextRunSlice};
|
||||||
|
@ -32,15 +32,17 @@ use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use net_traits::image::base::{Image, ImageMetadata};
|
use net_traits::image::base::{Image, ImageMetadata};
|
||||||
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||||
use range::*;
|
use range::*;
|
||||||
|
use script_layout_interface::wrapper_traits::{
|
||||||
|
PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
|
||||||
|
};
|
||||||
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource, HTMLMediaData, SVGSVGData};
|
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource, HTMLMediaData, SVGSVGData};
|
||||||
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
|
||||||
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::{f32, fmt};
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cmp::{Ordering, max, min};
|
use std::cmp::{max, min, Ordering};
|
||||||
use std::collections::LinkedList;
|
use std::collections::LinkedList;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::{f32, fmt};
|
||||||
use style::computed_values::border_collapse::T as BorderCollapse;
|
use style::computed_values::border_collapse::T as BorderCollapse;
|
||||||
use style::computed_values::box_sizing::T as BoxSizing;
|
use style::computed_values::box_sizing::T as BoxSizing;
|
||||||
use style::computed_values::clear::T as Clear;
|
use style::computed_values::clear::T as Clear;
|
||||||
|
@ -59,8 +61,8 @@ use style::properties::ComputedValues;
|
||||||
use style::selector_parser::RestyleDamage;
|
use style::selector_parser::RestyleDamage;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::str::char_is_whitespace;
|
use style::str::char_is_whitespace;
|
||||||
use style::values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
|
||||||
use style::values::computed::counters::ContentItem;
|
use style::values::computed::counters::ContentItem;
|
||||||
|
use style::values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
use style::values::generics::box_::{Perspective, VerticalAlign};
|
use style::values::generics::box_::{Perspective, VerticalAlign};
|
||||||
use style::values::generics::transform;
|
use style::values::generics::transform;
|
||||||
use webrender_api::{self, LayoutTransform};
|
use webrender_api::{self, LayoutTransform};
|
||||||
|
@ -416,23 +418,28 @@ impl ImageFragmentInfo {
|
||||||
layout_context: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
) -> ImageFragmentInfo {
|
) -> ImageFragmentInfo {
|
||||||
// First use any image data present in the element...
|
// First use any image data present in the element...
|
||||||
let image_or_metadata = node.image_data().and_then(|(image, metadata)| {
|
let image_or_metadata = node
|
||||||
match (image, metadata) {
|
.image_data()
|
||||||
|
.and_then(|(image, metadata)| match (image, metadata) {
|
||||||
(Some(image), _) => Some(ImageOrMetadata::Image(image)),
|
(Some(image), _) => Some(ImageOrMetadata::Image(image)),
|
||||||
(None, Some(metadata)) => Some(ImageOrMetadata::Metadata(metadata)),
|
(None, Some(metadata)) => Some(ImageOrMetadata::Metadata(metadata)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
|
||||||
}).or_else(|| url.and_then(|url| {
|
|
||||||
// Otherwise query the image cache for anything known about the associated source URL.
|
|
||||||
layout_context.get_or_request_image_or_meta(
|
|
||||||
node.opaque(),
|
|
||||||
url,
|
|
||||||
UsePlaceholder::Yes
|
|
||||||
).map(|result| match result {
|
|
||||||
ImageOrMetadataAvailable::ImageAvailable(i, _) => ImageOrMetadata::Image(i),
|
|
||||||
ImageOrMetadataAvailable::MetadataAvailable(m) => ImageOrMetadata::Metadata(m),
|
|
||||||
})
|
})
|
||||||
}));
|
.or_else(|| {
|
||||||
|
url.and_then(|url| {
|
||||||
|
// Otherwise query the image cache for anything known about the associated source URL.
|
||||||
|
layout_context
|
||||||
|
.get_or_request_image_or_meta(node.opaque(), url, UsePlaceholder::Yes)
|
||||||
|
.map(|result| match result {
|
||||||
|
ImageOrMetadataAvailable::ImageAvailable(i, _) => {
|
||||||
|
ImageOrMetadata::Image(i)
|
||||||
|
},
|
||||||
|
ImageOrMetadataAvailable::MetadataAvailable(m) => {
|
||||||
|
ImageOrMetadata::Metadata(m)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
let current_pixel_density = density.unwrap_or(1f64);
|
let current_pixel_density = density.unwrap_or(1f64);
|
||||||
|
|
||||||
|
@ -452,15 +459,13 @@ impl ImageFragmentInfo {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
Some(ImageOrMetadata::Metadata(m)) => {
|
Some(ImageOrMetadata::Metadata(m)) => (
|
||||||
(
|
None,
|
||||||
None,
|
Some(ImageMetadata {
|
||||||
Some(ImageMetadata {
|
height: (m.height as f64 / current_pixel_density) as u32,
|
||||||
height: (m.height as f64 / current_pixel_density) as u32,
|
width: (m.width as f64 / current_pixel_density) as u32,
|
||||||
width: (m.width as f64 / current_pixel_density) as u32,
|
}),
|
||||||
}),
|
),
|
||||||
)
|
|
||||||
},
|
|
||||||
None => (None, None),
|
None => (None, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1012,7 +1017,7 @@ impl Fragment {
|
||||||
} else {
|
} else {
|
||||||
Au(0)
|
Au(0)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
SpecificFragmentInfo::Media(ref info) => {
|
SpecificFragmentInfo::Media(ref info) => {
|
||||||
if let Some((_, width, _)) = info.current_frame {
|
if let Some((_, width, _)) = info.current_frame {
|
||||||
Au::from_px(width as i32)
|
Au::from_px(width as i32)
|
||||||
|
@ -1042,7 +1047,7 @@ impl Fragment {
|
||||||
} else {
|
} else {
|
||||||
Au(0)
|
Au(0)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
SpecificFragmentInfo::Media(ref info) => {
|
SpecificFragmentInfo::Media(ref info) => {
|
||||||
if let Some((_, _, height)) = info.current_frame {
|
if let Some((_, _, height)) = info.current_frame {
|
||||||
Au::from_px(height as i32)
|
Au::from_px(height as i32)
|
||||||
|
@ -1174,17 +1179,21 @@ impl Fragment {
|
||||||
(_, Ordering::Equal) => (first_isize, first_bsize),
|
(_, Ordering::Equal) => (first_isize, first_bsize),
|
||||||
// When both rectangles grow (smaller than min sizes),
|
// When both rectangles grow (smaller than min sizes),
|
||||||
// Choose the larger one;
|
// Choose the larger one;
|
||||||
(Ordering::Greater, Ordering::Greater) => if first_isize > second_isize {
|
(Ordering::Greater, Ordering::Greater) => {
|
||||||
(first_isize, first_bsize)
|
if first_isize > second_isize {
|
||||||
} else {
|
(first_isize, first_bsize)
|
||||||
(second_isize, second_bsize)
|
} else {
|
||||||
|
(second_isize, second_bsize)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// When both rectangles shrink (larger than max sizes),
|
// When both rectangles shrink (larger than max sizes),
|
||||||
// Choose the smaller one;
|
// Choose the smaller one;
|
||||||
(Ordering::Less, Ordering::Less) => if first_isize > second_isize {
|
(Ordering::Less, Ordering::Less) => {
|
||||||
(second_isize, second_bsize)
|
if first_isize > second_isize {
|
||||||
} else {
|
(second_isize, second_bsize)
|
||||||
(first_isize, first_bsize)
|
} else {
|
||||||
|
(first_isize, first_bsize)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// It does not matter which we choose here, because both sizes
|
// It does not matter which we choose here, because both sizes
|
||||||
// will be clamped to constraint;
|
// will be clamped to constraint;
|
||||||
|
@ -3173,7 +3182,8 @@ impl Fragment {
|
||||||
perspective_origin
|
perspective_origin
|
||||||
.vertical
|
.vertical
|
||||||
.to_used_value(stacking_relative_border_box.size.height),
|
.to_used_value(stacking_relative_border_box.size.height),
|
||||||
).to_layout();
|
)
|
||||||
|
.to_layout();
|
||||||
|
|
||||||
let pre_transform = LayoutTransform::create_translation(
|
let pre_transform = LayoutTransform::create_translation(
|
||||||
perspective_origin.x,
|
perspective_origin.x,
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
//! done in parallel and is therefore a sequential pass that runs on as little of the flow tree
|
//! done in parallel and is therefore a sequential pass that runs on as little of the flow tree
|
||||||
//! as possible.
|
//! as possible.
|
||||||
|
|
||||||
use crate::context::{LayoutContext, with_thread_local_font_context};
|
use crate::context::{with_thread_local_font_context, LayoutContext};
|
||||||
use crate::display_list::items::OpaqueNode;
|
use crate::display_list::items::OpaqueNode;
|
||||||
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
|
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
|
||||||
use crate::fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
|
use crate::fragment::{
|
||||||
|
Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo,
|
||||||
|
};
|
||||||
use crate::text::TextRunScanner;
|
use crate::text::TextRunScanner;
|
||||||
use crate::traversal::InorderFlowTraversal;
|
use crate::traversal::InorderFlowTraversal;
|
||||||
use script_layout_interface::wrapper_traits::PseudoElementType;
|
use script_layout_interface::wrapper_traits::PseudoElementType;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* 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/. */
|
||||||
|
|
||||||
use crate::flow::{FlowFlags, Flow, GetBaseFlow};
|
use crate::flow::{Flow, FlowFlags, GetBaseFlow};
|
||||||
use style::computed_values::float::T as Float;
|
use style::computed_values::float::T as Float;
|
||||||
use style::selector_parser::RestyleDamage;
|
use style::selector_parser::RestyleDamage;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
|
|
|
@ -3,32 +3,32 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use app_units::{Au, MIN_AU};
|
use app_units::{Au, MIN_AU};
|
||||||
use crate::ServoArc;
|
|
||||||
use crate::block::AbsoluteAssignBSizesTraversal;
|
use crate::block::AbsoluteAssignBSizesTraversal;
|
||||||
use crate::context::{LayoutContext, LayoutFontContext};
|
use crate::context::{LayoutContext, LayoutFontContext};
|
||||||
use crate::display_list::{DisplayListBuildState, InlineFlowDisplayListBuilding};
|
|
||||||
use crate::display_list::StackingContextCollectionState;
|
|
||||||
use crate::display_list::items::OpaqueNode;
|
use crate::display_list::items::OpaqueNode;
|
||||||
|
use crate::display_list::StackingContextCollectionState;
|
||||||
|
use crate::display_list::{DisplayListBuildState, InlineFlowDisplayListBuilding};
|
||||||
use crate::floats::{FloatKind, Floats, PlacementInfo};
|
use crate::floats::{FloatKind, Floats, PlacementInfo};
|
||||||
use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag};
|
use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag};
|
||||||
use crate::flow::{FlowFlags, EarlyAbsolutePositionInfo, GetBaseFlow, OpaqueFlow};
|
use crate::flow::{EarlyAbsolutePositionInfo, FlowFlags, GetBaseFlow, OpaqueFlow};
|
||||||
use crate::flow_ref::FlowRef;
|
use crate::flow_ref::FlowRef;
|
||||||
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
|
||||||
use crate::fragment::FragmentFlags;
|
use crate::fragment::FragmentFlags;
|
||||||
use crate::fragment::SpecificFragmentInfo;
|
use crate::fragment::SpecificFragmentInfo;
|
||||||
|
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
use crate::model::IntrinsicISizesContribution;
|
use crate::model::IntrinsicISizesContribution;
|
||||||
use crate::text;
|
use crate::text;
|
||||||
use crate::traversal::PreorderFlowTraversal;
|
use crate::traversal::PreorderFlowTraversal;
|
||||||
|
use crate::ServoArc;
|
||||||
use euclid::{Point2D, Size2D};
|
use euclid::{Point2D, Size2D};
|
||||||
use gfx::font::FontMetrics;
|
use gfx::font::FontMetrics;
|
||||||
use gfx_traits::print_tree::PrintTree;
|
use gfx_traits::print_tree::PrintTree;
|
||||||
use range::{Range, RangeIndex};
|
use range::{Range, RangeIndex};
|
||||||
use script_layout_interface::wrapper_traits::PseudoElementType;
|
use script_layout_interface::wrapper_traits::PseudoElementType;
|
||||||
use std::{fmt, i32, isize, mem};
|
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{fmt, i32, isize, mem};
|
||||||
use style::computed_values::display::T as Display;
|
use style::computed_values::display::T as Display;
|
||||||
use style::computed_values::overflow_x::T as StyleOverflow;
|
use style::computed_values::overflow_x::T as StyleOverflow;
|
||||||
use style::computed_values::position::T as Position;
|
use style::computed_values::position::T as Position;
|
||||||
|
@ -316,7 +316,8 @@ impl LineBreaker {
|
||||||
.map(|fragment| match fragment.specific {
|
.map(|fragment| match fragment.specific {
|
||||||
SpecificFragmentInfo::ScannedText(ref info) => info.run.bidi_level,
|
SpecificFragmentInfo::ScannedText(ref info) => info.run.bidi_level,
|
||||||
_ => para_level,
|
_ => para_level,
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
let mut lines = mem::replace(&mut self.lines, Vec::new());
|
let mut lines = mem::replace(&mut self.lines, Vec::new());
|
||||||
|
|
||||||
|
@ -336,7 +337,8 @@ impl LineBreaker {
|
||||||
let start = FragmentIndex(run.start as isize);
|
let start = FragmentIndex(run.start as isize);
|
||||||
let len = FragmentIndex(run.len() as isize);
|
let len = FragmentIndex(run.len() as isize);
|
||||||
(Range::new(start, len), levels[run.start])
|
(Range::new(start, len), levels[run.start])
|
||||||
}).collect(),
|
})
|
||||||
|
.collect(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1719,7 +1721,8 @@ impl Flow for InlineFlow {
|
||||||
debug_assert!(first_fragment_index < self.fragments.fragments.len());
|
debug_assert!(first_fragment_index < self.fragments.fragments.len());
|
||||||
let first_fragment = &self.fragments.fragments[first_fragment_index];
|
let first_fragment = &self.fragments.fragments[first_fragment_index];
|
||||||
let padding_box_origin = (first_fragment.border_box -
|
let padding_box_origin = (first_fragment.border_box -
|
||||||
first_fragment.style.logical_border_width()).start;
|
first_fragment.style.logical_border_width())
|
||||||
|
.start;
|
||||||
containing_block_positions.push(
|
containing_block_positions.push(
|
||||||
padding_box_origin.to_physical(self.base.writing_mode, container_size),
|
padding_box_origin.to_physical(self.base.writing_mode, container_size),
|
||||||
);
|
);
|
||||||
|
@ -1733,7 +1736,8 @@ impl Flow for InlineFlow {
|
||||||
debug_assert!(first_fragment_index < self.fragments.fragments.len());
|
debug_assert!(first_fragment_index < self.fragments.fragments.len());
|
||||||
let first_fragment = &self.fragments.fragments[first_fragment_index];
|
let first_fragment = &self.fragments.fragments[first_fragment_index];
|
||||||
let padding_box_origin = (first_fragment.border_box -
|
let padding_box_origin = (first_fragment.border_box -
|
||||||
first_fragment.style.logical_border_width()).start;
|
first_fragment.style.logical_border_width())
|
||||||
|
.start;
|
||||||
containing_block_positions.push(
|
containing_block_positions.push(
|
||||||
padding_box_origin.to_physical(self.base.writing_mode, container_size),
|
padding_box_origin.to_physical(self.base.writing_mode, container_size),
|
||||||
);
|
);
|
||||||
|
@ -1878,7 +1882,8 @@ impl Flow for InlineFlow {
|
||||||
relative_containing_block_size,
|
relative_containing_block_size,
|
||||||
relative_containing_block_mode,
|
relative_containing_block_mode,
|
||||||
CoordinateSystem::Own,
|
CoordinateSystem::Own,
|
||||||
).translate(&stacking_context_position.to_vector()),
|
)
|
||||||
|
.translate(&stacking_context_position.to_vector()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::RefCell;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
||||||
|
|
||||||
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None));
|
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None));
|
||||||
|
|
||||||
|
|
|
@ -87,9 +87,9 @@ pub mod traversal;
|
||||||
pub mod wrapper;
|
pub mod wrapper;
|
||||||
|
|
||||||
// For unit tests:
|
// For unit tests:
|
||||||
|
pub use self::data::LayoutData;
|
||||||
pub use crate::fragment::Fragment;
|
pub use crate::fragment::Fragment;
|
||||||
pub use crate::fragment::SpecificFragmentInfo;
|
pub use crate::fragment::SpecificFragmentInfo;
|
||||||
pub use self::data::LayoutData;
|
|
||||||
|
|
||||||
// We can't use servo_arc for everything in layout, because the Flow stuff uses
|
// We can't use servo_arc for everything in layout, because the Flow stuff uses
|
||||||
// weak references.
|
// weak references.
|
||||||
|
|
|
@ -7,13 +7,15 @@
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::block::BlockFlow;
|
use crate::block::BlockFlow;
|
||||||
use crate::context::{LayoutContext, with_thread_local_font_context};
|
use crate::context::{with_thread_local_font_context, LayoutContext};
|
||||||
use crate::display_list::{DisplayListBuildState, ListItemFlowDisplayListBuilding};
|
|
||||||
use crate::display_list::StackingContextCollectionState;
|
use crate::display_list::StackingContextCollectionState;
|
||||||
|
use crate::display_list::{DisplayListBuildState, ListItemFlowDisplayListBuilding};
|
||||||
use crate::floats::FloatKind;
|
use crate::floats::FloatKind;
|
||||||
use crate::flow::{Flow, FlowClass, OpaqueFlow};
|
use crate::flow::{Flow, FlowClass, OpaqueFlow};
|
||||||
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo};
|
|
||||||
use crate::fragment::Overflow;
|
use crate::fragment::Overflow;
|
||||||
|
use crate::fragment::{
|
||||||
|
CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo,
|
||||||
|
};
|
||||||
use crate::generated_content;
|
use crate::generated_content;
|
||||||
use crate::inline::InlineFlow;
|
use crate::inline::InlineFlow;
|
||||||
use euclid::Point2D;
|
use euclid::Point2D;
|
||||||
|
@ -257,7 +259,8 @@ impl Flow for ListItemFlow {
|
||||||
.early_absolute_position_info
|
.early_absolute_position_info
|
||||||
.relative_containing_block_mode,
|
.relative_containing_block_mode,
|
||||||
CoordinateSystem::Own,
|
CoordinateSystem::Own,
|
||||||
).translate(&stacking_context_position.to_vector()),
|
)
|
||||||
|
.translate(&stacking_context_position.to_vector()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ use std::cmp::{max, min};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style::logical_geometry::{LogicalMargin, WritingMode};
|
use style::logical_geometry::{LogicalMargin, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentage};
|
|
||||||
use style::values::computed::LengthOrPercentageOrNone;
|
use style::values::computed::LengthOrPercentageOrNone;
|
||||||
|
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
|
|
||||||
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
/// A collapsible margin. See CSS 2.1 § 8.3.1.
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
@ -505,10 +505,12 @@ pub fn style_length(
|
||||||
) -> MaybeAuto {
|
) -> MaybeAuto {
|
||||||
match container_size {
|
match container_size {
|
||||||
Some(length) => MaybeAuto::from_style(style_length, length),
|
Some(length) => MaybeAuto::from_style(style_length, length),
|
||||||
None => if let LengthOrPercentageOrAuto::Length(length) = style_length {
|
None => {
|
||||||
MaybeAuto::Specified(Au::from(length))
|
if let LengthOrPercentageOrAuto::Length(length) = style_length {
|
||||||
} else {
|
MaybeAuto::Specified(Au::from(length))
|
||||||
MaybeAuto::Auto
|
} else {
|
||||||
|
MaybeAuto::Auto
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -580,19 +582,23 @@ impl SizeConstraint {
|
||||||
) -> SizeConstraint {
|
) -> SizeConstraint {
|
||||||
let mut min_size = match container_size {
|
let mut min_size = match container_size {
|
||||||
Some(container_size) => min_size.to_used_value(container_size),
|
Some(container_size) => min_size.to_used_value(container_size),
|
||||||
None => if let LengthOrPercentage::Length(length) = min_size {
|
None => {
|
||||||
Au::from(length)
|
if let LengthOrPercentage::Length(length) = min_size {
|
||||||
} else {
|
Au::from(length)
|
||||||
Au(0)
|
} else {
|
||||||
|
Au(0)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut max_size = match container_size {
|
let mut max_size = match container_size {
|
||||||
Some(container_size) => max_size.to_used_value(container_size),
|
Some(container_size) => max_size.to_used_value(container_size),
|
||||||
None => if let LengthOrPercentageOrNone::Length(length) = max_size {
|
None => {
|
||||||
Some(Au::from(length))
|
if let LengthOrPercentageOrNone::Length(length) = max_size {
|
||||||
} else {
|
Some(Au::from(length))
|
||||||
None
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// Make sure max size is not smaller than min size.
|
// Make sure max size is not smaller than min size.
|
||||||
|
|
|
@ -5,23 +5,23 @@
|
||||||
//! CSS Multi-column layout http://dev.w3.org/csswg/css-multicol/
|
//! CSS Multi-column layout http://dev.w3.org/csswg/css-multicol/
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::ServoArc;
|
|
||||||
use crate::block::BlockFlow;
|
use crate::block::BlockFlow;
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
|
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
|
||||||
use crate::floats::FloatKind;
|
use crate::floats::FloatKind;
|
||||||
use crate::flow::{Flow, FlowClass, OpaqueFlow, FragmentationContext, GetBaseFlow};
|
use crate::flow::{Flow, FlowClass, FragmentationContext, GetBaseFlow, OpaqueFlow};
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
|
use crate::ServoArc;
|
||||||
use euclid::{Point2D, Vector2D};
|
use euclid::{Point2D, Vector2D};
|
||||||
use gfx_traits::print_tree::PrintTree;
|
use gfx_traits::print_tree::PrintTree;
|
||||||
use std::cmp::{min, max};
|
use std::cmp::{max, min};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::logical_geometry::LogicalSize;
|
use style::logical_geometry::LogicalSize;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::Either;
|
|
||||||
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
use style::values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||||
use style::values::generics::column::ColumnCount;
|
use style::values::generics::column::ColumnCount;
|
||||||
|
use style::values::Either;
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe impl crate::flow::HasBaseFlow for MulticolFlow {}
|
unsafe impl crate::flow::HasBaseFlow for MulticolFlow {}
|
||||||
|
@ -164,7 +164,8 @@ impl Flow for MulticolFlow {
|
||||||
LogicalSize::from_physical(
|
LogicalSize::from_physical(
|
||||||
self.block_flow.base.writing_mode,
|
self.block_flow.base.writing_mode,
|
||||||
ctx.shared_context().viewport_size(),
|
ctx.shared_context().viewport_size(),
|
||||||
).block
|
)
|
||||||
|
.block
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::flow::{Flow, GetBaseFlow};
|
||||||
use crate::flow_ref::FlowRef;
|
use crate::flow_ref::FlowRef;
|
||||||
use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes};
|
use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes};
|
||||||
use crate::traversal::{PostorderFlowTraversal, PreorderFlowTraversal};
|
use crate::traversal::{PostorderFlowTraversal, PreorderFlowTraversal};
|
||||||
use profile_traits::time::{self, TimerMetadata, profile};
|
use profile_traits::time::{self, profile, TimerMetadata};
|
||||||
use rayon;
|
use rayon;
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
|
@ -7,27 +7,29 @@
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::construct::ConstructionResult;
|
use crate::construct::ConstructionResult;
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::IndexableText;
|
|
||||||
use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap};
|
use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap};
|
||||||
|
use crate::display_list::IndexableText;
|
||||||
use crate::flow::{Flow, GetBaseFlow};
|
use crate::flow::{Flow, GetBaseFlow};
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
|
||||||
use crate::inline::InlineFragmentNodeFlags;
|
use crate::inline::InlineFragmentNodeFlags;
|
||||||
use crate::opaque_node::OpaqueNodeMethods;
|
use crate::opaque_node::OpaqueNodeMethods;
|
||||||
use crate::sequential;
|
use crate::sequential;
|
||||||
use crate::wrapper::LayoutNodeLayoutData;
|
use crate::wrapper::LayoutNodeLayoutData;
|
||||||
use euclid::{Point2D, Vector2D, Rect, Size2D};
|
use euclid::{Point2D, Rect, Size2D, Vector2D};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use script_layout_interface::{LayoutElementType, LayoutNodeType};
|
use script_layout_interface::rpc::TextIndexResponse;
|
||||||
use script_layout_interface::StyleData;
|
|
||||||
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC};
|
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC};
|
||||||
use script_layout_interface::rpc::{NodeGeometryResponse, NodeScrollIdResponse};
|
use script_layout_interface::rpc::{NodeGeometryResponse, NodeScrollIdResponse};
|
||||||
use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse, StyleResponse};
|
use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse, StyleResponse};
|
||||||
use script_layout_interface::rpc::TextIndexResponse;
|
use script_layout_interface::wrapper_traits::{
|
||||||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
|
||||||
|
};
|
||||||
|
use script_layout_interface::StyleData;
|
||||||
|
use script_layout_interface::{LayoutElementType, LayoutNodeType};
|
||||||
use script_traits::LayoutMsg as ConstellationMsg;
|
use script_traits::LayoutMsg as ConstellationMsg;
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use std::cmp::{min, max};
|
use std::cmp::{max, min};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use style::computed_values::display::T as Display;
|
use style::computed_values::display::T as Display;
|
||||||
|
@ -35,8 +37,8 @@ use style::computed_values::position::T as Position;
|
||||||
use style::computed_values::visibility::T as Visibility;
|
use style::computed_values::visibility::T as Visibility;
|
||||||
use style::context::{StyleContext, ThreadLocalStyleContext};
|
use style::context::{StyleContext, ThreadLocalStyleContext};
|
||||||
use style::dom::TElement;
|
use style::dom::TElement;
|
||||||
use style::logical_geometry::{WritingMode, BlockFlowDirection, InlineBaseDirection};
|
use style::logical_geometry::{BlockFlowDirection, InlineBaseDirection, WritingMode};
|
||||||
use style::properties::{style_structs, PropertyId, PropertyDeclarationId, LonghandId};
|
use style::properties::{style_structs, LonghandId, PropertyDeclarationId, PropertyId};
|
||||||
use style::selector_parser::PseudoElement;
|
use style::selector_parser::PseudoElement;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use webrender_api::ExternalScrollId;
|
use webrender_api::ExternalScrollId;
|
||||||
|
@ -603,7 +605,7 @@ impl FragmentBorderBoxIterator for ParentOffsetBorderBoxIterator {
|
||||||
// cause this assertion to fail sometimes, so it's
|
// cause this assertion to fail sometimes, so it's
|
||||||
// commented out for now.
|
// commented out for now.
|
||||||
/*assert!(node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT),
|
/*assert!(node.flags.contains(FIRST_FRAGMENT_OF_ELEMENT),
|
||||||
"First fragment of inline node found wasn't its first fragment!");*/
|
"First fragment of inline node found wasn't its first fragment!");*/
|
||||||
|
|
||||||
self.node_offset_box = Some(NodeOffsetBoxInfo {
|
self.node_offset_box = Some(NodeOffsetBoxInfo {
|
||||||
offset: border_box.origin,
|
offset: border_box.origin,
|
||||||
|
@ -840,12 +842,11 @@ where
|
||||||
let applies = true;
|
let applies = true;
|
||||||
|
|
||||||
fn used_value_for_position_property<N: LayoutNode>(
|
fn used_value_for_position_property<N: LayoutNode>(
|
||||||
layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteThreadSafeLayoutElement,
|
layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteThreadSafeLayoutElement,
|
||||||
layout_root: &mut Flow,
|
layout_root: &mut Flow,
|
||||||
requested_node: N,
|
requested_node: N,
|
||||||
longhand_id: LonghandId,
|
longhand_id: LonghandId,
|
||||||
) -> String
|
) -> String {
|
||||||
{
|
|
||||||
let maybe_data = layout_el.borrow_layout_data();
|
let maybe_data = layout_el.borrow_layout_data();
|
||||||
let position = maybe_data.map_or(Point2D::zero(), |data| {
|
let position = maybe_data.map_or(Point2D::zero(), |data| {
|
||||||
match (*data).flow_construction_result {
|
match (*data).flow_construction_result {
|
||||||
|
|
|
@ -8,8 +8,8 @@ use app_units::Au;
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
|
use crate::display_list::{DisplayListBuildState, StackingContextCollectionState};
|
||||||
use crate::floats::SpeculatedFloatPlacement;
|
use crate::floats::SpeculatedFloatPlacement;
|
||||||
use crate::flow::{Flow, ImmutableFlowUtils, FlowFlags, GetBaseFlow};
|
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
|
||||||
use crate::fragment::{FragmentBorderBoxIterator, CoordinateSystem};
|
use crate::fragment::{CoordinateSystem, FragmentBorderBoxIterator};
|
||||||
use crate::generated_content::ResolveGeneratedContent;
|
use crate::generated_content::ResolveGeneratedContent;
|
||||||
use crate::incremental::RelayoutMode;
|
use crate::incremental::RelayoutMode;
|
||||||
use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
|
use crate::traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
|
||||||
|
|
|
@ -9,8 +9,13 @@ use crate::block::{BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer};
|
||||||
use crate::block::{ISizeConstraintInput, ISizeConstraintSolution};
|
use crate::block::{ISizeConstraintInput, ISizeConstraintSolution};
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
|
use crate::display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
|
||||||
use crate::display_list::{DisplayListBuildState, StackingContextCollectionFlags, StackingContextCollectionState};
|
use crate::display_list::{
|
||||||
use crate::flow::{BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, GetBaseFlow, OpaqueFlow};
|
DisplayListBuildState, StackingContextCollectionFlags, StackingContextCollectionState,
|
||||||
|
};
|
||||||
|
use crate::flow::{
|
||||||
|
BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils,
|
||||||
|
OpaqueFlow,
|
||||||
|
};
|
||||||
use crate::flow_list::{FlowListIterator, MutFlowListIterator};
|
use crate::flow_list::{FlowListIterator, MutFlowListIterator};
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
|
@ -25,11 +30,11 @@ use std::{cmp, fmt};
|
||||||
use style::computed_values::{border_collapse, border_spacing, table_layout};
|
use style::computed_values::{border_collapse, border_spacing, table_layout};
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::logical_geometry::LogicalSize;
|
use style::logical_geometry::LogicalSize;
|
||||||
use style::properties::ComputedValues;
|
|
||||||
use style::properties::style_structs::Background;
|
use style::properties::style_structs::Background;
|
||||||
|
use style::properties::ComputedValues;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::CSSFloat;
|
|
||||||
use style::values::computed::LengthOrPercentageOrAuto;
|
use style::values::computed::LengthOrPercentageOrAuto;
|
||||||
|
use style::values::CSSFloat;
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe impl crate::flow::HasBaseFlow for TableFlow {}
|
unsafe impl crate::flow::HasBaseFlow for TableFlow {}
|
||||||
|
|
|
@ -197,7 +197,8 @@ impl Flow for TableCellFlow {
|
||||||
let specified_inline_size = MaybeAuto::from_style(
|
let specified_inline_size = MaybeAuto::from_style(
|
||||||
self.block_flow.fragment.style().content_inline_size(),
|
self.block_flow.fragment.style().content_inline_size(),
|
||||||
Au(0),
|
Au(0),
|
||||||
).specified_or_zero();
|
)
|
||||||
|
.specified_or_zero();
|
||||||
if self
|
if self
|
||||||
.block_flow
|
.block_flow
|
||||||
.base
|
.base
|
||||||
|
|
|
@ -9,7 +9,9 @@ use crate::block::{BlockFlow, ISizeAndMarginsComputer};
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
|
use crate::display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState};
|
||||||
use crate::display_list::{StackingContextCollectionFlags, StackingContextCollectionState};
|
use crate::display_list::{StackingContextCollectionFlags, StackingContextCollectionState};
|
||||||
use crate::flow::{EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, GetBaseFlow, OpaqueFlow};
|
use crate::flow::{
|
||||||
|
EarlyAbsolutePositionInfo, Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils, OpaqueFlow,
|
||||||
|
};
|
||||||
use crate::flow_list::MutFlowListIterator;
|
use crate::flow_list::MutFlowListIterator;
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use crate::layout_debug;
|
use crate::layout_debug;
|
||||||
|
|
|
@ -12,13 +12,17 @@
|
||||||
//! Hereafter this document is referred to as INTRINSIC.
|
//! Hereafter this document is referred to as INTRINSIC.
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use crate::block::{AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput};
|
use crate::block::{
|
||||||
|
AbsoluteNonReplaced, BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput,
|
||||||
|
};
|
||||||
use crate::block::{ISizeConstraintSolution, MarginsMayCollapseFlag};
|
use crate::block::{ISizeConstraintSolution, MarginsMayCollapseFlag};
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::{BlockFlowDisplayListBuilding, DisplayListBuildState, StackingContextCollectionFlags};
|
|
||||||
use crate::display_list::StackingContextCollectionState;
|
use crate::display_list::StackingContextCollectionState;
|
||||||
|
use crate::display_list::{
|
||||||
|
BlockFlowDisplayListBuilding, DisplayListBuildState, StackingContextCollectionFlags,
|
||||||
|
};
|
||||||
use crate::floats::FloatKind;
|
use crate::floats::FloatKind;
|
||||||
use crate::flow::{Flow, FlowClass, ImmutableFlowUtils, FlowFlags, OpaqueFlow};
|
use crate::flow::{Flow, FlowClass, FlowFlags, ImmutableFlowUtils, OpaqueFlow};
|
||||||
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use crate::model::MaybeAuto;
|
use crate::model::MaybeAuto;
|
||||||
use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
|
use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
|
||||||
|
@ -31,8 +35,8 @@ use style::computed_values::{position, table_layout};
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::logical_geometry::{LogicalRect, LogicalSize};
|
use style::logical_geometry::{LogicalRect, LogicalSize};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::CSSFloat;
|
|
||||||
use style::values::computed::LengthOrPercentageOrAuto;
|
use style::values::computed::LengthOrPercentageOrAuto;
|
||||||
|
use style::values::CSSFloat;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize)]
|
#[derive(Clone, Copy, Debug, Serialize)]
|
||||||
pub enum TableLayout {
|
pub enum TableLayout {
|
||||||
|
@ -143,7 +147,8 @@ impl TableWrapperFlow {
|
||||||
);
|
);
|
||||||
total_guess = &total_guess + &guess;
|
total_guess = &total_guess + &guess;
|
||||||
guess
|
guess
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
// Assign inline sizes.
|
// Assign inline sizes.
|
||||||
let selection =
|
let selection =
|
||||||
|
@ -385,7 +390,8 @@ impl Flow for TableWrapperFlow {
|
||||||
size: column_intrinsic_inline_size.minimum_length,
|
size: column_intrinsic_inline_size.minimum_length,
|
||||||
percentage: column_intrinsic_inline_size.percentage,
|
percentage: column_intrinsic_inline_size.percentage,
|
||||||
},
|
},
|
||||||
).collect::<Vec<_>>();
|
)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// Our inline-size was set to the inline-size of the containing block by the flow's parent.
|
// Our inline-size was set to the inline-size of the containing block by the flow's parent.
|
||||||
// Now compute the real value.
|
// Now compute the real value.
|
||||||
|
@ -753,17 +759,17 @@ impl ExcessInlineSizeDistributionInfo {
|
||||||
if !column_intrinsic_inline_size.constrained &&
|
if !column_intrinsic_inline_size.constrained &&
|
||||||
column_intrinsic_inline_size.percentage == 0.0
|
column_intrinsic_inline_size.percentage == 0.0
|
||||||
{
|
{
|
||||||
self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage =
|
self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage = self
|
||||||
self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage +
|
.preferred_inline_size_of_nonconstrained_columns_with_no_percentage +
|
||||||
column_intrinsic_inline_size.preferred;
|
column_intrinsic_inline_size.preferred;
|
||||||
self.count_of_nonconstrained_columns_with_no_percentage += 1
|
self.count_of_nonconstrained_columns_with_no_percentage += 1
|
||||||
}
|
}
|
||||||
if column_intrinsic_inline_size.constrained &&
|
if column_intrinsic_inline_size.constrained &&
|
||||||
column_intrinsic_inline_size.percentage == 0.0
|
column_intrinsic_inline_size.percentage == 0.0
|
||||||
{
|
{
|
||||||
self.preferred_inline_size_of_constrained_columns_with_no_percentage =
|
self.preferred_inline_size_of_constrained_columns_with_no_percentage = self
|
||||||
self.preferred_inline_size_of_constrained_columns_with_no_percentage +
|
.preferred_inline_size_of_constrained_columns_with_no_percentage +
|
||||||
column_intrinsic_inline_size.preferred
|
column_intrinsic_inline_size.preferred
|
||||||
}
|
}
|
||||||
self.total_percentage += column_intrinsic_inline_size.percentage;
|
self.total_percentage += column_intrinsic_inline_size.percentage;
|
||||||
self.column_count += 1
|
self.column_count += 1
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::fragment::{Fragment, ScannedTextFlags};
|
||||||
use crate::fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
|
use crate::fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
|
||||||
use crate::inline::{InlineFragmentNodeFlags, InlineFragments};
|
use crate::inline::{InlineFragmentNodeFlags, InlineFragments};
|
||||||
use crate::linked_list::split_off_head;
|
use crate::linked_list::split_off_head;
|
||||||
use gfx::font::{FontRef, FontMetrics, RunMetrics, ShapingFlags, ShapingOptions};
|
use gfx::font::{FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOptions};
|
||||||
use gfx::text::glyph::ByteIndex;
|
use gfx::text::glyph::ByteIndex;
|
||||||
use gfx::text::text_run::TextRun;
|
use gfx::text::text_run::TextRun;
|
||||||
use gfx::text::util::{self, CompressionMode};
|
use gfx::text::util::{self, CompressionMode};
|
||||||
|
@ -26,11 +26,11 @@ use style::computed_values::text_transform::T as TextTransform;
|
||||||
use style::computed_values::white_space::T as WhiteSpace;
|
use style::computed_values::white_space::T as WhiteSpace;
|
||||||
use style::computed_values::word_break::T as WordBreak;
|
use style::computed_values::word_break::T as WordBreak;
|
||||||
use style::logical_geometry::{LogicalSize, WritingMode};
|
use style::logical_geometry::{LogicalSize, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
|
||||||
use style::properties::style_structs::Font as FontStyleStruct;
|
use style::properties::style_structs::Font as FontStyleStruct;
|
||||||
|
use style::properties::ComputedValues;
|
||||||
use style::values::generics::text::LineHeight;
|
use style::values::generics::text::LineHeight;
|
||||||
use unicode_bidi as bidi;
|
use unicode_bidi as bidi;
|
||||||
use unicode_script::{Script, get_script};
|
use unicode_script::{get_script, Script};
|
||||||
use xi_unicode::LineBreakLeafIter;
|
use xi_unicode::LineBreakLeafIter;
|
||||||
|
|
||||||
/// Returns the concatenated text of a list of unscanned text fragments.
|
/// Returns the concatenated text of a list of unscanned text fragments.
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
use crate::construct::FlowConstructor;
|
use crate::construct::FlowConstructor;
|
||||||
use crate::context::LayoutContext;
|
use crate::context::LayoutContext;
|
||||||
use crate::display_list::DisplayListBuildState;
|
use crate::display_list::DisplayListBuildState;
|
||||||
use crate::flow::{FlowFlags, Flow, GetBaseFlow, ImmutableFlowUtils};
|
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
|
||||||
use crate::wrapper::{GetRawData, LayoutNodeLayoutData};
|
|
||||||
use crate::wrapper::ThreadSafeLayoutNodeHelpers;
|
use crate::wrapper::ThreadSafeLayoutNodeHelpers;
|
||||||
|
use crate::wrapper::{GetRawData, LayoutNodeLayoutData};
|
||||||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
use style::context::{SharedStyleContext, StyleContext};
|
use style::context::{SharedStyleContext, StyleContext};
|
||||||
|
@ -17,8 +17,8 @@ use style::data::ElementData;
|
||||||
use style::dom::{NodeInfo, TElement, TNode};
|
use style::dom::{NodeInfo, TElement, TNode};
|
||||||
use style::selector_parser::RestyleDamage;
|
use style::selector_parser::RestyleDamage;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::traversal::{DomTraversal, recalc_style_at};
|
|
||||||
use style::traversal::PerLevelTraversalData;
|
use style::traversal::PerLevelTraversalData;
|
||||||
|
use style::traversal::{recalc_style_at, DomTraversal};
|
||||||
|
|
||||||
pub struct RecalcStyleAndConstructFlows<'a> {
|
pub struct RecalcStyleAndConstructFlows<'a> {
|
||||||
context: LayoutContext<'a>,
|
context: LayoutContext<'a>,
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
|
|
||||||
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
||||||
use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
|
use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
|
||||||
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
|
||||||
use script_layout_interface::wrapper_traits::GetLayoutData;
|
use script_layout_interface::wrapper_traits::GetLayoutData;
|
||||||
|
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||||
use style::dom::{NodeInfo, TNode};
|
use style::dom::{NodeInfo, TNode};
|
||||||
use style::selector_parser::RestyleDamage;
|
use style::selector_parser::RestyleDamage;
|
||||||
use style::values::computed::counters::ContentItem;
|
use style::values::computed::counters::ContentItem;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue