mirror of
https://github.com/servo/servo.git
synced 2025-06-10 09:33:13 +00:00
Merge in servo/master
This commit is contained in:
commit
19686acdec
78 changed files with 2000 additions and 989 deletions
|
@ -274,8 +274,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.change_page_title(pipeline_id, title);
|
self.change_page_title(pipeline_id, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
(Msg::ChangePageLoadData(frame_id, load_data), ShutdownState::NotShuttingDown) => {
|
(Msg::ChangePageUrl(frame_id, url), ShutdownState::NotShuttingDown) => {
|
||||||
self.change_page_load_data(frame_id, load_data);
|
self.change_page_url(frame_id, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
(Msg::PaintMsgDiscarded, ShutdownState::NotShuttingDown) => {
|
(Msg::PaintMsgDiscarded, ShutdownState::NotShuttingDown) => {
|
||||||
|
@ -441,8 +441,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn change_page_load_data(&mut self, _: FrameId, load_data: LoadData) {
|
fn change_page_url(&mut self, _: FrameId, url: Url) {
|
||||||
self.window.set_page_load_data(load_data);
|
self.window.set_page_url(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn all_pipelines_in_idle_paint_state(&self) -> bool {
|
fn all_pipelines_in_idle_paint_state(&self) -> bool {
|
||||||
|
|
|
@ -20,8 +20,9 @@ use layers::layers::LayerBufferSet;
|
||||||
use pipeline::CompositionPipeline;
|
use pipeline::CompositionPipeline;
|
||||||
use msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
|
use msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
|
||||||
use msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy};
|
use msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy};
|
||||||
use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId};
|
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||||
|
use url::Url;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::PagePx;
|
use util::geometry::PagePx;
|
||||||
use util::memory::MemoryProfilerChan;
|
use util::memory::MemoryProfilerChan;
|
||||||
|
@ -200,8 +201,8 @@ pub enum Msg {
|
||||||
ChangePaintState(PipelineId, PaintState),
|
ChangePaintState(PipelineId, PaintState),
|
||||||
/// Alerts the compositor that the current page has changed its title.
|
/// Alerts the compositor that the current page has changed its title.
|
||||||
ChangePageTitle(PipelineId, Option<String>),
|
ChangePageTitle(PipelineId, Option<String>),
|
||||||
/// Alerts the compositor that the current page has changed its load data (including URL).
|
/// Alerts the compositor that the current page has changed its URL.
|
||||||
ChangePageLoadData(FrameId, LoadData),
|
ChangePageUrl(FrameId, Url),
|
||||||
/// Alerts the compositor that a `PaintMsg` has been discarded.
|
/// Alerts the compositor that a `PaintMsg` has been discarded.
|
||||||
PaintMsgDiscarded,
|
PaintMsgDiscarded,
|
||||||
/// Replaces the current frame tree, typically called during main frame navigation.
|
/// Replaces the current frame tree, typically called during main frame navigation.
|
||||||
|
@ -237,7 +238,7 @@ impl Debug for Msg {
|
||||||
Msg::ChangeReadyState(..) => write!(f, "ChangeReadyState"),
|
Msg::ChangeReadyState(..) => write!(f, "ChangeReadyState"),
|
||||||
Msg::ChangePaintState(..) => write!(f, "ChangePaintState"),
|
Msg::ChangePaintState(..) => write!(f, "ChangePaintState"),
|
||||||
Msg::ChangePageTitle(..) => write!(f, "ChangePageTitle"),
|
Msg::ChangePageTitle(..) => write!(f, "ChangePageTitle"),
|
||||||
Msg::ChangePageLoadData(..) => write!(f, "ChangePageLoadData"),
|
Msg::ChangePageUrl(..) => write!(f, "ChangePageUrl"),
|
||||||
Msg::PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"),
|
Msg::PaintMsgDiscarded(..) => write!(f, "PaintMsgDiscarded"),
|
||||||
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
|
||||||
Msg::CreateRootLayerForPipeline(..) => write!(f, "CreateRootLayerForPipeline"),
|
Msg::CreateRootLayerForPipeline(..) => write!(f, "CreateRootLayerForPipeline"),
|
||||||
|
|
|
@ -334,9 +334,9 @@ impl NavigationContext {
|
||||||
/// compositor of the new URLs.
|
/// compositor of the new URLs.
|
||||||
fn set_current(&mut self, new_frame: Rc<FrameTree>, compositor_proxy: &mut CompositorProxy) {
|
fn set_current(&mut self, new_frame: Rc<FrameTree>, compositor_proxy: &mut CompositorProxy) {
|
||||||
self.current = Some(new_frame.clone());
|
self.current = Some(new_frame.clone());
|
||||||
compositor_proxy.send(CompositorMsg::ChangePageLoadData(
|
compositor_proxy.send(CompositorMsg::ChangePageUrl(
|
||||||
new_frame.id,
|
new_frame.id,
|
||||||
new_frame.pipeline.borrow().load_data.clone()));
|
new_frame.pipeline.borrow().url.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,8 +407,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.window_size,
|
self.window_size,
|
||||||
script_pipeline,
|
script_pipeline,
|
||||||
load_data.clone());
|
load_data);
|
||||||
pipe.load();
|
|
||||||
Rc::new(pipe)
|
Rc::new(pipe)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,7 +762,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
source Id of ScriptLoadedURLInIFrameMsg does have an associated pipeline in
|
source Id of ScriptLoadedURLInIFrameMsg does have an associated pipeline in
|
||||||
constellation. This should be impossible.").clone();
|
constellation. This should be impossible.").clone();
|
||||||
|
|
||||||
let source_url = source_pipeline.load_data.url.clone();
|
let source_url = source_pipeline.url.clone();
|
||||||
|
|
||||||
let same_script = (source_url.host() == url.host() &&
|
let same_script = (source_url.host() == url.host() &&
|
||||||
source_url.port() == url.port()) &&
|
source_url.port() == url.port()) &&
|
||||||
|
@ -876,7 +875,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
};
|
};
|
||||||
|
|
||||||
for frame in destination_frame.iter() {
|
for frame in destination_frame.iter() {
|
||||||
frame.pipeline.borrow().load();
|
frame.pipeline.borrow().activate();
|
||||||
frame.pipeline.borrow().thaw();
|
frame.pipeline.borrow().thaw();
|
||||||
}
|
}
|
||||||
self.send_frame_tree_and_grant_paint_permission(destination_frame);
|
self.send_frame_tree_and_grant_paint_permission(destination_frame);
|
||||||
|
|
|
@ -113,7 +113,7 @@ impl CompositorEventListener for NullCompositor {
|
||||||
Msg::PaintMsgDiscarded(..) |
|
Msg::PaintMsgDiscarded(..) |
|
||||||
Msg::ScrollTimeout(..) |
|
Msg::ScrollTimeout(..) |
|
||||||
Msg::ChangePageTitle(..) |
|
Msg::ChangePageTitle(..) |
|
||||||
Msg::ChangePageLoadData(..) |
|
Msg::ChangePageUrl(..) |
|
||||||
Msg::KeyEvent(..) |
|
Msg::KeyEvent(..) |
|
||||||
Msg::SetCursor(..) => {}
|
Msg::SetCursor(..) => {}
|
||||||
Msg::PaintTaskExited(..) => {}
|
Msg::PaintTaskExited(..) => {}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType};
|
||||||
use net::image_cache_task::ImageCacheTask;
|
use net::image_cache_task::ImageCacheTask;
|
||||||
use net::resource_task::ResourceTask;
|
use net::resource_task::ResourceTask;
|
||||||
use net::storage_task::StorageTask;
|
use net::storage_task::StorageTask;
|
||||||
|
use url::Url;
|
||||||
use util::time::TimeProfilerChan;
|
use util::time::TimeProfilerChan;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{Receiver, channel};
|
use std::sync::mpsc::{Receiver, channel};
|
||||||
|
@ -29,8 +30,8 @@ pub struct Pipeline {
|
||||||
pub paint_chan: PaintChan,
|
pub paint_chan: PaintChan,
|
||||||
pub layout_shutdown_port: Receiver<()>,
|
pub layout_shutdown_port: Receiver<()>,
|
||||||
pub paint_shutdown_port: Receiver<()>,
|
pub paint_shutdown_port: Receiver<()>,
|
||||||
/// Load data corresponding to the most recently-loaded page.
|
/// URL corresponding to the most recently-loaded page.
|
||||||
pub load_data: LoadData,
|
pub url: Url,
|
||||||
/// The title of the most recently-loaded page.
|
/// The title of the most recently-loaded page.
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -88,7 +89,8 @@ impl Pipeline {
|
||||||
storage_task.clone(),
|
storage_task.clone(),
|
||||||
image_cache_task.clone(),
|
image_cache_task.clone(),
|
||||||
devtools_chan,
|
devtools_chan,
|
||||||
window_size);
|
window_size,
|
||||||
|
load_data.clone());
|
||||||
ScriptControlChan(script_chan)
|
ScriptControlChan(script_chan)
|
||||||
}
|
}
|
||||||
Some(spipe) => {
|
Some(spipe) => {
|
||||||
|
@ -97,6 +99,7 @@ impl Pipeline {
|
||||||
new_pipeline_id: id,
|
new_pipeline_id: id,
|
||||||
subpage_id: parent.expect("script_pipeline != None but subpage_id == None").1,
|
subpage_id: parent.expect("script_pipeline != None but subpage_id == None").1,
|
||||||
layout_chan: ScriptTaskFactory::clone_layout_channel(None::<&mut STF>, &layout_pair),
|
layout_chan: ScriptTaskFactory::clone_layout_channel(None::<&mut STF>, &layout_pair),
|
||||||
|
load_data: load_data.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ScriptControlChan(ref chan) = spipe.script_chan;
|
let ScriptControlChan(ref chan) = spipe.script_chan;
|
||||||
|
@ -135,7 +138,7 @@ impl Pipeline {
|
||||||
paint_chan,
|
paint_chan,
|
||||||
layout_shutdown_port,
|
layout_shutdown_port,
|
||||||
paint_shutdown_port,
|
paint_shutdown_port,
|
||||||
load_data)
|
load_data.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(id: PipelineId,
|
pub fn new(id: PipelineId,
|
||||||
|
@ -145,7 +148,7 @@ impl Pipeline {
|
||||||
paint_chan: PaintChan,
|
paint_chan: PaintChan,
|
||||||
layout_shutdown_port: Receiver<()>,
|
layout_shutdown_port: Receiver<()>,
|
||||||
paint_shutdown_port: Receiver<()>,
|
paint_shutdown_port: Receiver<()>,
|
||||||
load_data: LoadData)
|
url: Url)
|
||||||
-> Pipeline {
|
-> Pipeline {
|
||||||
Pipeline {
|
Pipeline {
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -155,16 +158,14 @@ impl Pipeline {
|
||||||
paint_chan: paint_chan,
|
paint_chan: paint_chan,
|
||||||
layout_shutdown_port: layout_shutdown_port,
|
layout_shutdown_port: layout_shutdown_port,
|
||||||
paint_shutdown_port: paint_shutdown_port,
|
paint_shutdown_port: paint_shutdown_port,
|
||||||
load_data: load_data,
|
url: url,
|
||||||
title: None,
|
title: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load(&self) {
|
pub fn activate(&self) {
|
||||||
let ScriptControlChan(ref chan) = self.script_chan;
|
let ScriptControlChan(ref chan) = self.script_chan;
|
||||||
chan.send(ConstellationControlMsg::Load(self.id,
|
chan.send(ConstellationControlMsg::Activate(self.id)).unwrap();
|
||||||
self.parent,
|
|
||||||
self.load_data.clone())).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn grant_paint_permission(&self) {
|
pub fn grant_paint_permission(&self) {
|
||||||
|
|
|
@ -12,7 +12,8 @@ use geom::size::TypedSize2D;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use layers::platform::surface::NativeGraphicsMetadata;
|
use layers::platform::surface::NativeGraphicsMetadata;
|
||||||
use msg::compositor_msg::{PaintState, ReadyState};
|
use msg::compositor_msg::{PaintState, ReadyState};
|
||||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers, LoadData};
|
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||||
|
use url::Url;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::ScreenPx;
|
use util::geometry::ScreenPx;
|
||||||
use std::fmt::{Error, Formatter, Debug};
|
use std::fmt::{Error, Formatter, Debug};
|
||||||
|
@ -105,7 +106,7 @@ pub trait WindowMethods {
|
||||||
/// Sets the page title for the current page.
|
/// Sets the page title for the current page.
|
||||||
fn set_page_title(&self, title: Option<String>);
|
fn set_page_title(&self, title: Option<String>);
|
||||||
/// Sets the load data for the current page.
|
/// Sets the load data for the current page.
|
||||||
fn set_page_load_data(&self, load_data: LoadData);
|
fn set_page_url(&self, url: Url);
|
||||||
/// Called when the browser is done loading a frame.
|
/// Called when the browser is done loading a frame.
|
||||||
fn load_end(&self);
|
fn load_end(&self);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,9 @@ use util::smallvec::{SmallVec, SmallVec8};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use style::computed_values::{border_style, cursor, filter, image_rendering, mix_blend_mode};
|
||||||
|
use style::computed_values::{pointer_events};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::computed_values::{border_style, cursor, filter, mix_blend_mode, pointer_events};
|
|
||||||
|
|
||||||
// It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for
|
// It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for
|
||||||
// layout to use.
|
// layout to use.
|
||||||
|
@ -763,6 +764,10 @@ pub struct ImageDisplayItem {
|
||||||
/// the bounds of this display item, then the image will be repeated in the appropriate
|
/// the bounds of this display item, then the image will be repeated in the appropriate
|
||||||
/// direction to tile the entire bounds.
|
/// direction to tile the entire bounds.
|
||||||
pub stretch_size: Size2D<Au>,
|
pub stretch_size: Size2D<Au>,
|
||||||
|
|
||||||
|
/// The algorithm we should use to stretch the image. See `image_rendering` in CSS-IMAGES-3 §
|
||||||
|
/// 5.3.
|
||||||
|
pub image_rendering: image_rendering::T,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Paints a gradient.
|
/// Paints a gradient.
|
||||||
|
@ -937,7 +942,9 @@ impl DisplayItem {
|
||||||
bounds.origin.y = bounds.origin.y + y_offset;
|
bounds.origin.y = bounds.origin.y + y_offset;
|
||||||
bounds.size = image_item.stretch_size;
|
bounds.size = image_item.stretch_size;
|
||||||
|
|
||||||
paint_context.draw_image(&bounds, image_item.image.clone());
|
paint_context.draw_image(&bounds,
|
||||||
|
image_item.image.clone(),
|
||||||
|
image_item.image_rendering.clone());
|
||||||
|
|
||||||
x_offset = x_offset + image_item.stretch_size.width;
|
x_offset = x_offset + image_item.stretch_size.width;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ use std::mem;
|
||||||
use std::num::Float;
|
use std::num::Float;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::computed_values::{border_style, filter, mix_blend_mode};
|
use style::computed_values::{border_style, filter, image_rendering, mix_blend_mode};
|
||||||
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT};
|
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT};
|
||||||
use util::opts;
|
use util::opts;
|
||||||
use util::range::Range;
|
use util::range::Range;
|
||||||
|
@ -127,7 +127,10 @@ impl<'a> PaintContext<'a> {
|
||||||
self.draw_target.pop_clip();
|
self.draw_target.pop_clip();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_image(&self, bounds: &Rect<Au>, image: Arc<Box<Image>>) {
|
pub fn draw_image(&self,
|
||||||
|
bounds: &Rect<Au>,
|
||||||
|
image: Arc<Box<Image>>,
|
||||||
|
image_rendering: image_rendering::T) {
|
||||||
let size = Size2D(image.width as i32, image.height as i32);
|
let size = Size2D(image.width as i32, image.height as i32);
|
||||||
let (pixel_width, pixels, source_format) = match image.pixels {
|
let (pixel_width, pixels, source_format) = match image.pixels {
|
||||||
PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8),
|
PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8),
|
||||||
|
@ -146,7 +149,17 @@ impl<'a> PaintContext<'a> {
|
||||||
let source_rect = Rect(Point2D(0.0, 0.0),
|
let source_rect = Rect(Point2D(0.0, 0.0),
|
||||||
Size2D(image.width as AzFloat, image.height as AzFloat));
|
Size2D(image.width as AzFloat, image.height as AzFloat));
|
||||||
let dest_rect = bounds.to_azure_rect();
|
let dest_rect = bounds.to_azure_rect();
|
||||||
let draw_surface_options = DrawSurfaceOptions::new(Filter::Linear, true);
|
|
||||||
|
// TODO(pcwalton): According to CSS-IMAGES-3 § 5.3, nearest-neighbor interpolation is a
|
||||||
|
// conforming implementation of `crisp-edges`, but it is not the best we could do.
|
||||||
|
// Something like Scale2x would be ideal.
|
||||||
|
let draw_surface_options = match image_rendering {
|
||||||
|
image_rendering::T::Auto => DrawSurfaceOptions::new(Filter::Linear, true),
|
||||||
|
image_rendering::T::CrispEdges | image_rendering::T::Pixelated => {
|
||||||
|
DrawSurfaceOptions::new(Filter::Point, true)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let draw_options = DrawOptions::new(1.0, 0);
|
let draw_options = DrawOptions::new(1.0, 0);
|
||||||
draw_target_ref.draw_surface(azure_surface,
|
draw_target_ref.draw_surface(azure_surface,
|
||||||
dest_rect,
|
dest_rect,
|
||||||
|
|
|
@ -52,14 +52,16 @@ use geom::{Point2D, Rect, Size2D};
|
||||||
use gfx::display_list::{ClippingRegion, DisplayList};
|
use gfx::display_list::{ClippingRegion, DisplayList};
|
||||||
use rustc_serialize::{Encoder, Encodable};
|
use rustc_serialize::{Encoder, Encodable};
|
||||||
use msg::compositor_msg::LayerId;
|
use msg::compositor_msg::LayerId;
|
||||||
|
use msg::constellation_msg::ConstellationChan;
|
||||||
use servo_util::geometry::{Au, MAX_AU};
|
use servo_util::geometry::{Au, MAX_AU};
|
||||||
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
||||||
use servo_util::opts;
|
use servo_util::opts;
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use style::computed_values::{overflow_x, overflow_y, position, box_sizing, display, float};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
use style::computed_values::{overflow, position, box_sizing, display, float};
|
use style::values::computed::{LengthOrPercentageOrNone};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Information specific to floated blocks.
|
/// Information specific to floated blocks.
|
||||||
|
@ -1431,7 +1433,10 @@ impl BlockFlow {
|
||||||
display::T::inline_block => {
|
display::T::inline_block => {
|
||||||
FormattingContextType::Other
|
FormattingContextType::Other
|
||||||
}
|
}
|
||||||
_ if style.get_box().overflow != overflow::T::visible => FormattingContextType::Block,
|
_ if style.get_box().overflow_x != overflow_x::T::visible ||
|
||||||
|
style.get_box().overflow_y != overflow_y::T(overflow_x::T::visible) => {
|
||||||
|
FormattingContextType::Block
|
||||||
|
}
|
||||||
_ => FormattingContextType::None,
|
_ => FormattingContextType::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1915,6 +1920,10 @@ impl Flow for BlockFlow {
|
||||||
CoordinateSystem::Parent)
|
CoordinateSystem::Parent)
|
||||||
.translate(stacking_context_position));
|
.translate(stacking_context_position));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_compositor_layers(&self, constellation_chan: ConstellationChan) {
|
||||||
|
self.fragment.remove_compositor_layers(constellation_chan);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for BlockFlow {
|
impl fmt::Debug for BlockFlow {
|
||||||
|
|
|
@ -233,6 +233,20 @@ impl<'a> FlowConstructor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_flow_construction_result(&self, node: &ThreadSafeLayoutNode, result: ConstructionResult) {
|
||||||
|
match result {
|
||||||
|
ConstructionResult::None => {
|
||||||
|
let mut layout_data_ref = node.mutate_layout_data();
|
||||||
|
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
||||||
|
layout_data.remove_compositor_layers(self.layout_context.shared.constellation_chan.clone());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
node.set_flow_construction_result(result);
|
||||||
|
}
|
||||||
|
|
||||||
/// Builds the `ImageFragmentInfo` for the given image. This is out of line to guide inlining.
|
/// Builds the `ImageFragmentInfo` for the given image. This is out of line to guide inlining.
|
||||||
fn build_fragment_info_for_image(&mut self, node: &ThreadSafeLayoutNode, url: Option<Url>)
|
fn build_fragment_info_for_image(&mut self, node: &ThreadSafeLayoutNode, url: Option<Url>)
|
||||||
-> SpecificFragmentInfo {
|
-> SpecificFragmentInfo {
|
||||||
|
@ -381,7 +395,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
// If kid_flow is TableCaptionFlow, kid_flow should be added under
|
// If kid_flow is TableCaptionFlow, kid_flow should be added under
|
||||||
// TableWrapperFlow.
|
// TableWrapperFlow.
|
||||||
if flow.is_table() && kid_flow.is_table_caption() {
|
if flow.is_table() && kid_flow.is_table_caption() {
|
||||||
kid.set_flow_construction_result(ConstructionResult::Flow(kid_flow,
|
self.set_flow_construction_result(&kid, ConstructionResult::Flow(kid_flow,
|
||||||
Descendants::new()))
|
Descendants::new()))
|
||||||
} else if flow.need_anonymous_flow(&*kid_flow) {
|
} else if flow.need_anonymous_flow(&*kid_flow) {
|
||||||
consecutive_siblings.push(kid_flow)
|
consecutive_siblings.push(kid_flow)
|
||||||
|
@ -562,7 +576,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
// box, so don't construct them.
|
// box, so don't construct them.
|
||||||
if node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement))) {
|
if node.type_id() == Some(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement))) {
|
||||||
for kid in node.children() {
|
for kid in node.children() {
|
||||||
kid.set_flow_construction_result(ConstructionResult::None)
|
self.set_flow_construction_result(&kid, ConstructionResult::None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Fragment::new_from_specific_info(
|
Some(Fragment::new_from_specific_info(
|
||||||
|
@ -692,7 +706,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
fn build_fragments_for_replaced_inline_content(&mut self, node: &ThreadSafeLayoutNode)
|
fn build_fragments_for_replaced_inline_content(&mut self, node: &ThreadSafeLayoutNode)
|
||||||
-> ConstructionResult {
|
-> ConstructionResult {
|
||||||
for kid in node.children() {
|
for kid in node.children() {
|
||||||
kid.set_flow_construction_result(ConstructionResult::None)
|
self.set_flow_construction_result(&kid, ConstructionResult::None)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this node is ignorable whitespace, bail out now.
|
// If this node is ignorable whitespace, bail out now.
|
||||||
|
@ -1046,7 +1060,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
-> ConstructionResult {
|
-> ConstructionResult {
|
||||||
// CSS 2.1 § 17.2.1. Treat all child fragments of a `table-column` as `display: none`.
|
// CSS 2.1 § 17.2.1. Treat all child fragments of a `table-column` as `display: none`.
|
||||||
for kid in node.children() {
|
for kid in node.children() {
|
||||||
kid.set_flow_construction_result(ConstructionResult::None)
|
self.set_flow_construction_result(&kid, ConstructionResult::None)
|
||||||
}
|
}
|
||||||
|
|
||||||
let specific = SpecificFragmentInfo::TableColumn(TableColumnFragmentInfo::new(node));
|
let specific = SpecificFragmentInfo::TableColumn(TableColumnFragmentInfo::new(node));
|
||||||
|
@ -1174,15 +1188,15 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
// results of children.
|
// results of children.
|
||||||
(display::T::none, _, _) => {
|
(display::T::none, _, _) => {
|
||||||
for child in node.children() {
|
for child in node.children() {
|
||||||
child.set_flow_construction_result(ConstructionResult::None);
|
self.set_flow_construction_result(&child, ConstructionResult::None);
|
||||||
}
|
}
|
||||||
node.set_flow_construction_result(ConstructionResult::None);
|
self.set_flow_construction_result(node, ConstructionResult::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
(display::T::table, float_value, _) => {
|
(display::T::table, float_value, _) => {
|
||||||
let construction_result = self.build_flow_for_table_wrapper(node, float_value);
|
let construction_result = self.build_flow_for_table_wrapper(node, float_value);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Absolutely positioned elements will have computed value of
|
// Absolutely positioned elements will have computed value of
|
||||||
|
@ -1193,13 +1207,14 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
// below.
|
// below.
|
||||||
(display::T::block, _, position::T::absolute) |
|
(display::T::block, _, position::T::absolute) |
|
||||||
(_, _, position::T::fixed) => {
|
(_, _, position::T::fixed) => {
|
||||||
node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node))
|
let construction_result = self.build_flow_for_nonfloated_block(node);
|
||||||
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// List items contribute their own special flows.
|
// List items contribute their own special flows.
|
||||||
(display::T::list_item, float_value, _) => {
|
(display::T::list_item, float_value, _) => {
|
||||||
node.set_flow_construction_result(self.build_flow_for_list_item(node,
|
let construction_result = self.build_flow_for_list_item(node, float_value);
|
||||||
float_value))
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inline items that are absolutely-positioned contribute inline fragment construction
|
// Inline items that are absolutely-positioned contribute inline fragment construction
|
||||||
|
@ -1207,7 +1222,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
(display::T::inline, _, position::T::absolute) => {
|
(display::T::inline, _, position::T::absolute) => {
|
||||||
let construction_result =
|
let construction_result =
|
||||||
self.build_fragment_for_absolutely_positioned_inline(node);
|
self.build_fragment_for_absolutely_positioned_inline(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inline items contribute inline fragment construction results.
|
// Inline items contribute inline fragment construction results.
|
||||||
|
@ -1215,31 +1230,31 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
// FIXME(pcwalton, #3307): This is not sufficient to handle floated generated content.
|
// FIXME(pcwalton, #3307): This is not sufficient to handle floated generated content.
|
||||||
(display::T::inline, float::T::none, _) => {
|
(display::T::inline, float::T::none, _) => {
|
||||||
let construction_result = self.build_fragments_for_inline(node);
|
let construction_result = self.build_fragments_for_inline(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inline-block items contribute inline fragment construction results.
|
// Inline-block items contribute inline fragment construction results.
|
||||||
(display::T::inline_block, float::T::none, _) => {
|
(display::T::inline_block, float::T::none, _) => {
|
||||||
let construction_result = self.build_fragment_for_inline_block(node);
|
let construction_result = self.build_fragment_for_inline_block(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
(display::T::table_caption, _, _) => {
|
(display::T::table_caption, _, _) => {
|
||||||
let construction_result = self.build_flow_for_table_caption(node);
|
let construction_result = self.build_flow_for_table_caption(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
(display::T::table_column_group, _, _) => {
|
(display::T::table_column_group, _, _) => {
|
||||||
let construction_result = self.build_flow_for_table_colgroup(node);
|
let construction_result = self.build_flow_for_table_colgroup(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
(display::T::table_column, _, _) => {
|
(display::T::table_column, _, _) => {
|
||||||
let construction_result = self.build_fragments_for_table_column(node);
|
let construction_result = self.build_fragments_for_table_column(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
|
@ -1247,19 +1262,19 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
(display::T::table_header_group, _, _) |
|
(display::T::table_header_group, _, _) |
|
||||||
(display::T::table_footer_group, _, _) => {
|
(display::T::table_footer_group, _, _) => {
|
||||||
let construction_result = self.build_flow_for_table_rowgroup(node);
|
let construction_result = self.build_flow_for_table_rowgroup(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
(display::T::table_row, _, _) => {
|
(display::T::table_row, _, _) => {
|
||||||
let construction_result = self.build_flow_for_table_row(node);
|
let construction_result = self.build_flow_for_table_row(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
(display::T::table_cell, _, _) => {
|
(display::T::table_cell, _, _) => {
|
||||||
let construction_result = self.build_flow_for_table_cell(node);
|
let construction_result = self.build_flow_for_table_cell(node);
|
||||||
node.set_flow_construction_result(construction_result)
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block flows that are not floated contribute block flow construction results.
|
// Block flows that are not floated contribute block flow construction results.
|
||||||
|
@ -1268,14 +1283,15 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
// properties separately.
|
// properties separately.
|
||||||
|
|
||||||
(_, float::T::none, _) => {
|
(_, float::T::none, _) => {
|
||||||
node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node))
|
let construction_result = self.build_flow_for_nonfloated_block(node);
|
||||||
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Floated flows contribute float flow construction results.
|
// Floated flows contribute float flow construction results.
|
||||||
(_, float_value, _) => {
|
(_, float_value, _) => {
|
||||||
let float_kind = FloatKind::from_property(float_value);
|
let float_kind = FloatKind::from_property(float_value);
|
||||||
node.set_flow_construction_result(
|
let construction_result = self.build_flow_for_floated_block(node, float_kind);
|
||||||
self.build_flow_for_floated_block(node, float_kind))
|
self.set_flow_construction_result(node, construction_result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,13 +1346,6 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
||||||
let mut layout_data_ref = self.mutate_layout_data();
|
let mut layout_data_ref = self.mutate_layout_data();
|
||||||
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
||||||
|
|
||||||
match result {
|
|
||||||
ConstructionResult::None => {
|
|
||||||
layout_data.clear();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let dst = self.get_construction_result(layout_data);
|
let dst = self.get_construction_result(layout_data);
|
||||||
|
|
||||||
*dst = result;
|
*dst = result;
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
|
|
||||||
#![allow(unsafe_blocks)]
|
#![allow(unsafe_blocks)]
|
||||||
|
|
||||||
use construct::ConstructionResult;
|
use construct::{ConstructionItem, ConstructionResult};
|
||||||
use incremental::RestyleDamage;
|
use incremental::RestyleDamage;
|
||||||
|
use msg::constellation_msg::ConstellationChan;
|
||||||
use parallel::DomParallelInfo;
|
use parallel::DomParallelInfo;
|
||||||
use wrapper::{LayoutNode, TLayoutNode};
|
|
||||||
|
|
||||||
use script::dom::node::SharedLayoutData;
|
use script::dom::node::SharedLayoutData;
|
||||||
use script::layout_interface::LayoutChan;
|
use script::layout_interface::LayoutChan;
|
||||||
use std::mem;
|
|
||||||
use std::cell::{Ref, RefMut};
|
use std::cell::{Ref, RefMut};
|
||||||
use style::properties::ComputedValues;
|
use std::mem;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use style::properties::ComputedValues;
|
||||||
|
use wrapper::{LayoutNode, TLayoutNode};
|
||||||
|
|
||||||
/// Data that layout associates with a node.
|
/// Data that layout associates with a node.
|
||||||
pub struct PrivateLayoutData {
|
pub struct PrivateLayoutData {
|
||||||
|
@ -72,8 +72,26 @@ pub struct LayoutDataWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutDataWrapper {
|
impl LayoutDataWrapper {
|
||||||
pub fn clear(&self) {
|
pub fn remove_compositor_layers(&self, constellation_chan: ConstellationChan) {
|
||||||
// TODO: Clear items related to this node, e.g. compositor layers
|
match self.data.flow_construction_result {
|
||||||
|
ConstructionResult::None => {}
|
||||||
|
ConstructionResult::Flow(ref flow_ref, _) => {
|
||||||
|
flow_ref.remove_compositor_layers(constellation_chan);
|
||||||
|
}
|
||||||
|
ConstructionResult::ConstructionItem(ref construction_item) => {
|
||||||
|
match construction_item {
|
||||||
|
&ConstructionItem::InlineFragments(ref inline_fragments) => {
|
||||||
|
for fragment in inline_fragments.fragments.iter() {
|
||||||
|
fragment.remove_compositor_layers(constellation_chan.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&ConstructionItem::Whitespace(..) => {}
|
||||||
|
&ConstructionItem::TableColumnFragment(ref fragment) => {
|
||||||
|
fragment.remove_compositor_layers(constellation_chan.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use fragment::{CoordinateSystem, Fragment, IframeFragmentInfo, ImageFragmentInfo
|
||||||
use fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo};
|
use fragment::{ScannedTextFragmentInfo, SpecificFragmentInfo};
|
||||||
use inline::InlineFlow;
|
use inline::InlineFlow;
|
||||||
use list_item::ListItemFlow;
|
use list_item::ListItemFlow;
|
||||||
use model;
|
use model::{self, MaybeAuto};
|
||||||
use opaque_node::OpaqueNodeMethods;
|
use opaque_node::OpaqueNodeMethods;
|
||||||
|
|
||||||
use geom::{Point2D, Rect, Size2D, SideOffsets2D};
|
use geom::{Point2D, Rect, Size2D, SideOffsets2D};
|
||||||
|
@ -32,8 +32,7 @@ use gfx::display_list::{GradientStop, ImageDisplayItem, LineDisplayItem};
|
||||||
use gfx::display_list::{OpaqueNode, SolidColorDisplayItem};
|
use gfx::display_list::{OpaqueNode, SolidColorDisplayItem};
|
||||||
use gfx::display_list::{StackingContext, TextDisplayItem, TextOrientation};
|
use gfx::display_list::{StackingContext, TextDisplayItem, TextOrientation};
|
||||||
use gfx::paint_task::{PaintLayer, THREAD_TINT_COLORS};
|
use gfx::paint_task::{PaintLayer, THREAD_TINT_COLORS};
|
||||||
use png;
|
use png::{self, PixelsByColorType};
|
||||||
use png::PixelsByColorType;
|
|
||||||
use msg::compositor_msg::ScrollPolicy;
|
use msg::compositor_msg::ScrollPolicy;
|
||||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||||
use msg::constellation_msg::ConstellationChan;
|
use msg::constellation_msg::ConstellationChan;
|
||||||
|
@ -42,15 +41,16 @@ use servo_util::cursor::Cursor;
|
||||||
use servo_util::geometry::{self, Au, ZERO_POINT, to_px, to_frac_px};
|
use servo_util::geometry::{self, Au, ZERO_POINT, to_px, to_frac_px};
|
||||||
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
||||||
use servo_util::opts;
|
use servo_util::opts;
|
||||||
|
use std::cmp;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
use std::num::Float;
|
use std::num::Float;
|
||||||
use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection};
|
use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection};
|
||||||
use style::values::computed::{Image, LinearGradient, LengthOrPercentage};
|
use style::values::computed::{Image, LinearGradient, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
use style::values::RGBA;
|
use style::values::RGBA;
|
||||||
use style::computed_values::filter::Filter;
|
use style::computed_values::filter::Filter;
|
||||||
use style::computed_values::{background_attachment, background_repeat, border_style, overflow};
|
use style::computed_values::{background_attachment, background_repeat, background_size};
|
||||||
use style::computed_values::{position, visibility};
|
use style::computed_values::{border_style, image_rendering, overflow_x, position, visibility};
|
||||||
use style::properties::style_structs::Border;
|
use style::properties::style_structs::Border;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use std::num::ToPrimitive;
|
use std::num::ToPrimitive;
|
||||||
|
@ -93,6 +93,14 @@ pub trait FragmentDisplayListBuilding {
|
||||||
absolute_bounds: &Rect<Au>,
|
absolute_bounds: &Rect<Au>,
|
||||||
clip: &ClippingRegion);
|
clip: &ClippingRegion);
|
||||||
|
|
||||||
|
/// Computes the background size for an image with the given background area according to the
|
||||||
|
/// rules in CSS-BACKGROUNDS § 3.9.
|
||||||
|
fn compute_background_image_size(&self,
|
||||||
|
style: &ComputedValues,
|
||||||
|
bounds: &Rect<Au>,
|
||||||
|
image: &png::Image)
|
||||||
|
-> Size2D<Au>;
|
||||||
|
|
||||||
/// Adds the display items necessary to paint the background image of this fragment to the
|
/// Adds the display items necessary to paint the background image of this fragment to the
|
||||||
/// display list at the appropriate stacking level.
|
/// display list at the appropriate stacking level.
|
||||||
fn build_display_list_for_background_image(&self,
|
fn build_display_list_for_background_image(&self,
|
||||||
|
@ -326,6 +334,59 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compute_background_image_size(&self,
|
||||||
|
style: &ComputedValues,
|
||||||
|
bounds: &Rect<Au>,
|
||||||
|
image: &png::Image)
|
||||||
|
-> Size2D<Au> {
|
||||||
|
// If `image_aspect_ratio` < `bounds_aspect_ratio`, the image is tall; otherwise, it is
|
||||||
|
// wide.
|
||||||
|
let image_aspect_ratio = (image.width as f64) / (image.height as f64);
|
||||||
|
let bounds_aspect_ratio = bounds.size.width.to_subpx() / bounds.size.height.to_subpx();
|
||||||
|
let intrinsic_size = Size2D(Au::from_px(image.width as int),
|
||||||
|
Au::from_px(image.height as int));
|
||||||
|
match (style.get_background().background_size.clone(),
|
||||||
|
image_aspect_ratio < bounds_aspect_ratio) {
|
||||||
|
(background_size::T::Contain, false) | (background_size::T::Cover, true) => {
|
||||||
|
Size2D(bounds.size.width,
|
||||||
|
Au::from_frac_px(bounds.size.width.to_subpx() / image_aspect_ratio))
|
||||||
|
}
|
||||||
|
|
||||||
|
(background_size::T::Contain, true) | (background_size::T::Cover, false) => {
|
||||||
|
Size2D(Au::from_frac_px(bounds.size.height.to_subpx() * image_aspect_ratio),
|
||||||
|
bounds.size.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
(background_size::T::Explicit(background_size::ExplicitSize {
|
||||||
|
width,
|
||||||
|
height: LengthOrPercentageOrAuto::Auto,
|
||||||
|
}), _) => {
|
||||||
|
let width = MaybeAuto::from_style(width, bounds.size.width)
|
||||||
|
.specified_or_default(intrinsic_size.width);
|
||||||
|
Size2D(width, Au::from_frac_px(width.to_subpx() / image_aspect_ratio))
|
||||||
|
}
|
||||||
|
|
||||||
|
(background_size::T::Explicit(background_size::ExplicitSize {
|
||||||
|
width: LengthOrPercentageOrAuto::Auto,
|
||||||
|
height
|
||||||
|
}), _) => {
|
||||||
|
let height = MaybeAuto::from_style(height, bounds.size.height)
|
||||||
|
.specified_or_default(intrinsic_size.height);
|
||||||
|
Size2D(Au::from_frac_px(height.to_subpx() * image_aspect_ratio), height)
|
||||||
|
}
|
||||||
|
|
||||||
|
(background_size::T::Explicit(background_size::ExplicitSize {
|
||||||
|
width,
|
||||||
|
height
|
||||||
|
}), _) => {
|
||||||
|
Size2D(MaybeAuto::from_style(width, bounds.size.width)
|
||||||
|
.specified_or_default(intrinsic_size.width),
|
||||||
|
MaybeAuto::from_style(height, bounds.size.height)
|
||||||
|
.specified_or_default(intrinsic_size.height))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn build_display_list_for_background_image(&self,
|
fn build_display_list_for_background_image(&self,
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
display_list: &mut DisplayList,
|
display_list: &mut DisplayList,
|
||||||
|
@ -349,16 +410,16 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
};
|
};
|
||||||
debug!("(building display list) building background image");
|
debug!("(building display list) building background image");
|
||||||
|
|
||||||
let image_width = Au::from_px(image.width as int);
|
// Use `background-size` to get the size.
|
||||||
let image_height = Au::from_px(image.height as int);
|
|
||||||
let mut bounds = *absolute_bounds;
|
let mut bounds = *absolute_bounds;
|
||||||
|
let image_size = self.compute_background_image_size(style, &bounds, &**image);
|
||||||
|
|
||||||
// Clip.
|
// Clip.
|
||||||
//
|
//
|
||||||
// TODO: Check the bounds to see if a clip item is actually required.
|
// TODO: Check the bounds to see if a clip item is actually required.
|
||||||
let clip = clip.clone().intersect_rect(&bounds);
|
let clip = clip.clone().intersect_rect(&bounds);
|
||||||
|
|
||||||
// Use background-attachment to get the initial virtual origin
|
// Use `background-attachment` to get the initial virtual origin
|
||||||
let (virtual_origin_x, virtual_origin_y) = match background.background_attachment {
|
let (virtual_origin_x, virtual_origin_y) = match background.background_attachment {
|
||||||
background_attachment::T::scroll => {
|
background_attachment::T::scroll => {
|
||||||
(absolute_bounds.origin.x, absolute_bounds.origin.y)
|
(absolute_bounds.origin.x, absolute_bounds.origin.y)
|
||||||
|
@ -368,11 +429,11 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use background-position to get the offset
|
// Use `background-position` to get the offset.
|
||||||
let horizontal_position = model::specified(background.background_position.horizontal,
|
let horizontal_position = model::specified(background.background_position.horizontal,
|
||||||
bounds.size.width - image_width);
|
bounds.size.width - image_size.width);
|
||||||
let vertical_position = model::specified(background.background_position.vertical,
|
let vertical_position = model::specified(background.background_position.vertical,
|
||||||
bounds.size.height - image_height);
|
bounds.size.height - image_size.height);
|
||||||
|
|
||||||
let abs_x = virtual_origin_x + horizontal_position;
|
let abs_x = virtual_origin_x + horizontal_position;
|
||||||
let abs_y = virtual_origin_y + vertical_position;
|
let abs_y = virtual_origin_y + vertical_position;
|
||||||
|
@ -382,26 +443,34 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
background_repeat::T::no_repeat => {
|
background_repeat::T::no_repeat => {
|
||||||
bounds.origin.x = abs_x;
|
bounds.origin.x = abs_x;
|
||||||
bounds.origin.y = abs_y;
|
bounds.origin.y = abs_y;
|
||||||
bounds.size.width = image_width;
|
bounds.size.width = image_size.width;
|
||||||
bounds.size.height = image_height;
|
bounds.size.height = image_size.height;
|
||||||
}
|
}
|
||||||
background_repeat::T::repeat_x => {
|
background_repeat::T::repeat_x => {
|
||||||
bounds.origin.y = abs_y;
|
bounds.origin.y = abs_y;
|
||||||
bounds.size.height = image_height;
|
bounds.size.height = image_size.height;
|
||||||
ImageFragmentInfo::tile_image(&mut bounds.origin.x, &mut bounds.size.width,
|
ImageFragmentInfo::tile_image(&mut bounds.origin.x,
|
||||||
abs_x, image.width);
|
&mut bounds.size.width,
|
||||||
|
abs_x,
|
||||||
|
image_size.width.to_nearest_px() as u32);
|
||||||
}
|
}
|
||||||
background_repeat::T::repeat_y => {
|
background_repeat::T::repeat_y => {
|
||||||
bounds.origin.x = abs_x;
|
bounds.origin.x = abs_x;
|
||||||
bounds.size.width = image_width;
|
bounds.size.width = image_size.width;
|
||||||
ImageFragmentInfo::tile_image(&mut bounds.origin.y, &mut bounds.size.height,
|
ImageFragmentInfo::tile_image(&mut bounds.origin.y,
|
||||||
abs_y, image.height);
|
&mut bounds.size.height,
|
||||||
|
abs_y,
|
||||||
|
image_size.height.to_nearest_px() as u32);
|
||||||
}
|
}
|
||||||
background_repeat::T::repeat => {
|
background_repeat::T::repeat => {
|
||||||
ImageFragmentInfo::tile_image(&mut bounds.origin.x, &mut bounds.size.width,
|
ImageFragmentInfo::tile_image(&mut bounds.origin.x,
|
||||||
abs_x, image.width);
|
&mut bounds.size.width,
|
||||||
ImageFragmentInfo::tile_image(&mut bounds.origin.y, &mut bounds.size.height,
|
abs_x,
|
||||||
abs_y, image.height);
|
image_size.width.to_nearest_px() as u32);
|
||||||
|
ImageFragmentInfo::tile_image(&mut bounds.origin.y,
|
||||||
|
&mut bounds.size.height,
|
||||||
|
abs_y,
|
||||||
|
image_size.height.to_nearest_px() as u32);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -413,8 +482,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
Cursor::DefaultCursor),
|
Cursor::DefaultCursor),
|
||||||
clip),
|
clip),
|
||||||
image: image.clone(),
|
image: image.clone(),
|
||||||
stretch_size: Size2D(Au::from_px(image.width as int),
|
stretch_size: Size2D(image_size.width, image_size.height),
|
||||||
Au::from_px(image.height as int)),
|
image_rendering: style.get_effects().image_rendering.clone(),
|
||||||
}), level);
|
}), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,6 +981,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
(*clip).clone()),
|
(*clip).clone()),
|
||||||
image: image.clone(),
|
image: image.clone(),
|
||||||
stretch_size: stacking_relative_content_box.size,
|
stretch_size: stacking_relative_content_box.size,
|
||||||
|
image_rendering: self.style.get_effects().image_rendering.clone(),
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
// No image data at all? Do nothing.
|
// No image data at all? Do nothing.
|
||||||
|
@ -947,6 +1017,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
pixels: PixelsByColorType::RGBA8(canvas_data),
|
pixels: PixelsByColorType::RGBA8(canvas_data),
|
||||||
}),
|
}),
|
||||||
stretch_size: stacking_relative_content_box.size,
|
stretch_size: stacking_relative_content_box.size,
|
||||||
|
image_rendering: image_rendering::T::Auto,
|
||||||
};
|
};
|
||||||
|
|
||||||
display_list.content.push_back(DisplayItem::ImageClass(canvas_display_item));
|
display_list.content.push_back(DisplayItem::ImageClass(canvas_display_item));
|
||||||
|
@ -991,17 +1062,37 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account for style-specified `clip`.
|
// Account for style-specified `clip`.
|
||||||
let current_clip = self.calculate_style_specified_clip(current_clip,
|
let mut current_clip = self.calculate_style_specified_clip(current_clip,
|
||||||
stacking_relative_border_box);
|
stacking_relative_border_box);
|
||||||
|
|
||||||
// Only clip if `overflow` tells us to.
|
// Clip according to the values of `overflow-x` and `overflow-y`.
|
||||||
match self.style.get_box().overflow {
|
//
|
||||||
overflow::T::hidden | overflow::T::auto | overflow::T::scroll => {
|
// TODO(pcwalton): Support scrolling.
|
||||||
// Create a new clip rect.
|
// FIXME(pcwalton): This may be more complex than it needs to be, since it seems to be
|
||||||
current_clip.intersect_rect(stacking_relative_border_box)
|
// impossible with the computed value rules as they are to have `overflow-x: visible` with
|
||||||
|
// `overflow-y: <scrolling>` or vice versa!
|
||||||
|
match self.style.get_box().overflow_x {
|
||||||
|
overflow_x::T::hidden | overflow_x::T::auto | overflow_x::T::scroll => {
|
||||||
|
let mut bounds = current_clip.bounding_rect();
|
||||||
|
let max_x = cmp::min(bounds.max_x(), stacking_relative_border_box.max_x());
|
||||||
|
bounds.origin.x = cmp::max(bounds.origin.x, stacking_relative_border_box.origin.x);
|
||||||
|
bounds.size.width = max_x - bounds.origin.x;
|
||||||
|
current_clip = current_clip.intersect_rect(&bounds)
|
||||||
}
|
}
|
||||||
_ => current_clip,
|
_ => {}
|
||||||
}
|
}
|
||||||
|
match self.style.get_box().overflow_y.0 {
|
||||||
|
overflow_x::T::hidden | overflow_x::T::auto | overflow_x::T::scroll => {
|
||||||
|
let mut bounds = current_clip.bounding_rect();
|
||||||
|
let max_y = cmp::min(bounds.max_y(), stacking_relative_border_box.max_y());
|
||||||
|
bounds.origin.y = cmp::max(bounds.origin.y, stacking_relative_border_box.origin.y);
|
||||||
|
bounds.size.height = max_y - bounds.origin.y;
|
||||||
|
current_clip = current_clip.intersect_rect(&bounds)
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
current_clip
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_display_list_for_text_fragment(&self,
|
fn build_display_list_for_text_fragment(&self,
|
||||||
|
|
|
@ -49,6 +49,7 @@ use wrapper::ThreadSafeLayoutNode;
|
||||||
use geom::{Point2D, Rect, Size2D};
|
use geom::{Point2D, Rect, Size2D};
|
||||||
use gfx::display_list::ClippingRegion;
|
use gfx::display_list::ClippingRegion;
|
||||||
use rustc_serialize::{Encoder, Encodable};
|
use rustc_serialize::{Encoder, Encodable};
|
||||||
|
use msg::constellation_msg::ConstellationChan;
|
||||||
use msg::compositor_msg::LayerId;
|
use msg::compositor_msg::LayerId;
|
||||||
use servo_util::geometry::{Au, ZERO_RECT};
|
use servo_util::geometry::{Au, ZERO_RECT};
|
||||||
use servo_util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
use servo_util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
|
||||||
|
@ -312,6 +313,9 @@ pub trait Flow: fmt::Debug + Sync {
|
||||||
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
|
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
|
||||||
/// the new style. This can only succeed if the flow has exactly one fragment.
|
/// the new style. This can only succeed if the flow has exactly one fragment.
|
||||||
fn repair_style(&mut self, new_style: &Arc<ComputedValues>);
|
fn repair_style(&mut self, new_style: &Arc<ComputedValues>);
|
||||||
|
|
||||||
|
/// Remove any compositor layers associated with this flow
|
||||||
|
fn remove_compositor_layers(&self, _: ConstellationChan) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base access
|
// Base access
|
||||||
|
|
|
@ -30,7 +30,7 @@ use gfx::text::glyph::CharIndex;
|
||||||
use gfx::text::text_run::{TextRun, TextRunSlice};
|
use gfx::text::text_run::{TextRun, TextRunSlice};
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use rustc_serialize::{Encodable, Encoder};
|
use rustc_serialize::{Encodable, Encoder};
|
||||||
use msg::constellation_msg::{PipelineId, SubpageId};
|
use msg::constellation_msg::{ConstellationChan, Msg, PipelineId, SubpageId};
|
||||||
use net::image::holder::ImageHolder;
|
use net::image::holder::ImageHolder;
|
||||||
use net::local_image_cache::LocalImageCache;
|
use net::local_image_cache::LocalImageCache;
|
||||||
use servo_util::geometry::{self, Au, ZERO_POINT};
|
use servo_util::geometry::{self, Au, ZERO_POINT};
|
||||||
|
@ -982,10 +982,11 @@ impl Fragment {
|
||||||
fn style_specified_intrinsic_inline_size(&self) -> IntrinsicISizesContribution {
|
fn style_specified_intrinsic_inline_size(&self) -> IntrinsicISizesContribution {
|
||||||
let flags = self.quantities_included_in_intrinsic_inline_size();
|
let flags = self.quantities_included_in_intrinsic_inline_size();
|
||||||
let style = self.style();
|
let style = self.style();
|
||||||
let specified = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED) {
|
let (min_inline_size, specified) = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED) {
|
||||||
MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero()
|
(model::specified(style.min_inline_size(), Au(0)),
|
||||||
|
MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero())
|
||||||
} else {
|
} else {
|
||||||
Au(0)
|
(Au(0), Au(0))
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME(#2261, pcwalton): This won't work well for inlines: is this OK?
|
// FIXME(#2261, pcwalton): This won't work well for inlines: is this OK?
|
||||||
|
@ -993,7 +994,7 @@ impl Fragment {
|
||||||
|
|
||||||
IntrinsicISizesContribution {
|
IntrinsicISizesContribution {
|
||||||
content_intrinsic_sizes: IntrinsicISizes {
|
content_intrinsic_sizes: IntrinsicISizes {
|
||||||
minimum_inline_size: specified,
|
minimum_inline_size: min_inline_size,
|
||||||
preferred_inline_size: specified,
|
preferred_inline_size: specified,
|
||||||
},
|
},
|
||||||
surrounding_size: surrounding_inline_size,
|
surrounding_size: surrounding_inline_size,
|
||||||
|
@ -1721,7 +1722,8 @@ impl Fragment {
|
||||||
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
SpecificFragmentInfo::InlineBlock(ref mut info) => {
|
||||||
let block_flow = info.flow_ref.as_block();
|
let block_flow = info.flow_ref.as_block();
|
||||||
self.border_box.size.inline =
|
self.border_box.size.inline =
|
||||||
block_flow.base.intrinsic_inline_sizes.preferred_inline_size;
|
max(block_flow.base.intrinsic_inline_sizes.minimum_inline_size,
|
||||||
|
block_flow.base.intrinsic_inline_sizes.preferred_inline_size);
|
||||||
block_flow.base.block_container_inline_size = self.border_box.size.inline;
|
block_flow.base.block_container_inline_size = self.border_box.size.inline;
|
||||||
}
|
}
|
||||||
SpecificFragmentInfo::ScannedText(ref info) => {
|
SpecificFragmentInfo::ScannedText(ref info) => {
|
||||||
|
@ -2058,6 +2060,23 @@ impl Fragment {
|
||||||
// box too.
|
// box too.
|
||||||
overflow
|
overflow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove any compositor layers associated with this fragment - it is being
|
||||||
|
/// removed from the tree or had its display property set to none.
|
||||||
|
/// TODO(gw): This just hides the compositor layer for now. In the future
|
||||||
|
/// it probably makes sense to provide a hint to the compositor whether
|
||||||
|
/// the layers should be destroyed to free memory.
|
||||||
|
pub fn remove_compositor_layers(&self, constellation_chan: ConstellationChan) {
|
||||||
|
match self.specific {
|
||||||
|
SpecificFragmentInfo::Iframe(ref iframe_info) => {
|
||||||
|
let ConstellationChan(ref chan) = constellation_chan;
|
||||||
|
chan.send(Msg::FrameRect(iframe_info.pipeline_id,
|
||||||
|
iframe_info.subpage_id,
|
||||||
|
Rect::zero())).unwrap();
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Fragment {
|
impl fmt::Debug for Fragment {
|
||||||
|
|
|
@ -34,7 +34,7 @@ use std::mem;
|
||||||
use std::num::ToPrimitive;
|
use std::num::ToPrimitive;
|
||||||
use std::ops::{Add, Sub, Mul, Div, Rem, Neg, Shl, Shr, Not, BitOr, BitAnd, BitXor};
|
use std::ops::{Add, Sub, Mul, Div, Rem, Neg, Shl, Shr, Not, BitOr, BitAnd, BitXor};
|
||||||
use std::u16;
|
use std::u16;
|
||||||
use style::computed_values::{overflow, text_align, text_justify, text_overflow, vertical_align};
|
use style::computed_values::{overflow_x, text_align, text_justify, text_overflow, vertical_align};
|
||||||
use style::computed_values::{white_space};
|
use style::computed_values::{white_space};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -653,8 +653,8 @@ impl LineBreaker {
|
||||||
let available_inline_size = self.pending_line.green_zone.inline -
|
let available_inline_size = self.pending_line.green_zone.inline -
|
||||||
self.pending_line.bounds.size.inline - indentation;
|
self.pending_line.bounds.size.inline - indentation;
|
||||||
match (fragment.style().get_inheritedtext().text_overflow,
|
match (fragment.style().get_inheritedtext().text_overflow,
|
||||||
fragment.style().get_box().overflow) {
|
fragment.style().get_box().overflow_x) {
|
||||||
(text_overflow::T::clip, _) | (_, overflow::T::visible) => {}
|
(text_overflow::T::clip, _) | (_, overflow_x::T::visible) => {}
|
||||||
(text_overflow::T::ellipsis, _) => {
|
(text_overflow::T::ellipsis, _) => {
|
||||||
need_ellipsis = fragment.border_box.size.inline > available_inline_size;
|
need_ellipsis = fragment.border_box.size.inline > available_inline_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,9 @@ pub struct LayoutTask {
|
||||||
//// The channel to send messages to ourself.
|
//// The channel to send messages to ourself.
|
||||||
pub chan: LayoutChan,
|
pub chan: LayoutChan,
|
||||||
|
|
||||||
|
/// The channel on which messages can be sent to the constellation.
|
||||||
|
pub constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the script task.
|
/// The channel on which messages can be sent to the script task.
|
||||||
pub script_chan: ScriptControlChan,
|
pub script_chan: ScriptControlChan,
|
||||||
|
|
||||||
|
@ -274,6 +277,7 @@ impl LayoutTask {
|
||||||
pipeline_port: pipeline_port,
|
pipeline_port: pipeline_port,
|
||||||
chan: chan,
|
chan: chan,
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
|
constellation_chan: constellation_chan.clone(),
|
||||||
paint_chan: paint_chan,
|
paint_chan: paint_chan,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
resource_task: resource_task,
|
resource_task: resource_task,
|
||||||
|
@ -414,7 +418,7 @@ impl LayoutTask {
|
||||||
},
|
},
|
||||||
Msg::ReapLayoutData(dead_layout_data) => {
|
Msg::ReapLayoutData(dead_layout_data) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
LayoutTask::handle_reap_layout_data(dead_layout_data)
|
self.handle_reap_layout_data(dead_layout_data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Msg::PrepareToExit(response_chan) => {
|
Msg::PrepareToExit(response_chan) => {
|
||||||
|
@ -443,7 +447,7 @@ impl LayoutTask {
|
||||||
match self.port.recv().unwrap() {
|
match self.port.recv().unwrap() {
|
||||||
Msg::ReapLayoutData(dead_layout_data) => {
|
Msg::ReapLayoutData(dead_layout_data) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
LayoutTask::handle_reap_layout_data(dead_layout_data)
|
self.handle_reap_layout_data(dead_layout_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Msg::ExitNow(exit_type) => {
|
Msg::ExitNow(exit_type) => {
|
||||||
|
@ -940,9 +944,9 @@ impl LayoutTask {
|
||||||
|
|
||||||
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
|
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
|
||||||
/// because the struct type is transmuted to a different type on the script side.
|
/// because the struct type is transmuted to a different type on the script side.
|
||||||
unsafe fn handle_reap_layout_data(layout_data: LayoutData) {
|
unsafe fn handle_reap_layout_data(&self, layout_data: LayoutData) {
|
||||||
let layout_data_wrapper: LayoutDataWrapper = mem::transmute(layout_data);
|
let layout_data_wrapper: LayoutDataWrapper = mem::transmute(layout_data);
|
||||||
layout_data_wrapper.clear();
|
layout_data_wrapper.remove_compositor_layers(self.constellation_chan.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns profiling information which is passed to the time profiler.
|
/// Returns profiling information which is passed to the time profiler.
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
use dom::bindings::codegen::Bindings::DOMRectBinding::{DOMRectMethods};
|
use dom::bindings::codegen::Bindings::DOMRectBinding::{DOMRectMethods};
|
||||||
use dom::bindings::codegen::Bindings::ElementBinding::{ElementMethods};
|
use dom::bindings::codegen::Bindings::ElementBinding::{ElementMethods};
|
||||||
use dom::node::{Node, NodeHelpers};
|
use dom::node::{Node, NodeHelpers};
|
||||||
use dom::window::{ScriptHelpers};
|
use dom::window::{WindowHelpers, ScriptHelpers};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::document::DocumentHelpers;
|
use dom::document::DocumentHelpers;
|
||||||
use page::Page;
|
use page::Page;
|
||||||
|
@ -24,8 +24,7 @@ use std::rc::Rc;
|
||||||
|
|
||||||
pub fn handle_evaluate_js(page: &Rc<Page>, pipeline: PipelineId, eval: String, reply: Sender<EvaluateJSReply>){
|
pub fn handle_evaluate_js(page: &Rc<Page>, pipeline: PipelineId, eval: String, reply: Sender<EvaluateJSReply>){
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let frame = page.frame();
|
let window = page.window().root();
|
||||||
let window = frame.as_ref().unwrap().window.root();
|
|
||||||
let cx = window.r().get_cx();
|
let cx = window.r().get_cx();
|
||||||
let rval = window.r().evaluate_js_on_global_with_result(eval.as_slice());
|
let rval = window.r().evaluate_js_on_global_with_result(eval.as_slice());
|
||||||
|
|
||||||
|
@ -49,8 +48,7 @@ pub fn handle_evaluate_js(page: &Rc<Page>, pipeline: PipelineId, eval: String, r
|
||||||
|
|
||||||
pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
|
pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let frame = page.frame();
|
let document = page.document().root();
|
||||||
let document = frame.as_ref().unwrap().document.root();
|
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(document.r());
|
let node: JSRef<Node> = NodeCast::from_ref(document.r());
|
||||||
reply.send(node.summarize()).unwrap();
|
reply.send(node.summarize()).unwrap();
|
||||||
|
@ -58,8 +56,7 @@ pub fn handle_get_root_node(page: &Rc<Page>, pipeline: PipelineId, reply: Sender
|
||||||
|
|
||||||
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
|
pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply: Sender<NodeInfo>) {
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let frame = page.frame();
|
let document = page.document().root();
|
||||||
let document = frame.as_ref().unwrap().document.root();
|
|
||||||
let document_element = document.r().GetDocumentElement().root().unwrap();
|
let document_element = document.r().GetDocumentElement().root().unwrap();
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(document_element.r());
|
let node: JSRef<Node> = NodeCast::from_ref(document_element.r());
|
||||||
|
@ -68,8 +65,7 @@ pub fn handle_get_document_element(page: &Rc<Page>, pipeline: PipelineId, reply:
|
||||||
|
|
||||||
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Temporary<Node> {
|
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Temporary<Node> {
|
||||||
let page = get_page(&*page, pipeline);
|
let page = get_page(&*page, pipeline);
|
||||||
let frame = page.frame();
|
let document = page.document().root();
|
||||||
let document = frame.as_ref().unwrap().document.root();
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(document.r());
|
let node: JSRef<Node> = NodeCast::from_ref(document.r());
|
||||||
|
|
||||||
for candidate in node.traverse_preorder() {
|
for candidate in node.traverse_preorder() {
|
||||||
|
@ -110,5 +106,6 @@ pub fn handle_modify_attribute(page: &Rc<Page>, pipeline: PipelineId, node_id: S
|
||||||
|
|
||||||
pub fn handle_wants_live_notifications(page: &Rc<Page>, pipeline_id: PipelineId, send_notifications: bool) {
|
pub fn handle_wants_live_notifications(page: &Rc<Page>, pipeline_id: PipelineId, send_notifications: bool) {
|
||||||
let page = get_page(&*page, pipeline_id);
|
let page = get_page(&*page, pipeline_id);
|
||||||
page.devtools_wants_updates.set(send_notifications);
|
let window = page.window().root();
|
||||||
|
window.r().set_devtools_wants_updates(send_notifications);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4643,7 +4643,6 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::bindings::proxyhandler::{fill_property_descriptor, get_expando_object}',
|
'dom::bindings::proxyhandler::{fill_property_descriptor, get_expando_object}',
|
||||||
'dom::bindings::proxyhandler::{get_property_descriptor}',
|
'dom::bindings::proxyhandler::{get_property_descriptor}',
|
||||||
'dom::bindings::str::ByteString',
|
'dom::bindings::str::ByteString',
|
||||||
'page::JSPageInfo',
|
|
||||||
'libc',
|
'libc',
|
||||||
'util::str::DOMString',
|
'util::str::DOMString',
|
||||||
'std::borrow::ToOwned',
|
'std::borrow::ToOwned',
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::conversions::FromJSValConvertible;
|
||||||
use dom::bindings::js::{JS, JSRef, Root, Unrooted};
|
use dom::bindings::js::{JS, JSRef, Root, Unrooted};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::workerglobalscope::{WorkerGlobalScope, WorkerGlobalScopeHelpers};
|
use dom::workerglobalscope::{WorkerGlobalScope, WorkerGlobalScopeHelpers};
|
||||||
use dom::window;
|
use dom::window::{self, WindowHelpers};
|
||||||
use script_task::ScriptChan;
|
use script_task::ScriptChan;
|
||||||
|
|
||||||
use net::resource_task::ResourceTask;
|
use net::resource_task::ResourceTask;
|
||||||
|
@ -84,7 +84,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
/// Get the `ResourceTask` for this global scope.
|
/// Get the `ResourceTask` for this global scope.
|
||||||
pub fn resource_task(&self) -> ResourceTask {
|
pub fn resource_task(&self) -> ResourceTask {
|
||||||
match *self {
|
match *self {
|
||||||
GlobalRef::Window(ref window) => window.page().resource_task.clone(),
|
GlobalRef::Window(ref window) => window.resource_task().clone(),
|
||||||
GlobalRef::Worker(ref worker) => worker.resource_task().clone(),
|
GlobalRef::Worker(ref worker) => worker.resource_task().clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -727,7 +727,7 @@ impl<'a, T> Clone for JSRef<'a, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> PartialEq for JSRef<'a, T> {
|
impl<'a, 'b, T> PartialEq<JSRef<'b, T>> for JSRef<'a, T> {
|
||||||
fn eq(&self, other: &JSRef<T>) -> bool {
|
fn eq(&self, other: &JSRef<T>) -> bool {
|
||||||
self.ptr == other.ptr
|
self.ptr == other.ptr
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,14 +71,12 @@ impl BrowserContext {
|
||||||
fn create_window_proxy(&mut self) {
|
fn create_window_proxy(&mut self) {
|
||||||
let win = self.active_window().root();
|
let win = self.active_window().root();
|
||||||
let win = win.r();
|
let win = win.r();
|
||||||
let page = win.page();
|
|
||||||
let js_info = page.js_info();
|
|
||||||
|
|
||||||
let WindowProxyHandler(handler) = js_info.as_ref().unwrap().dom_static.windowproxy_handler;
|
let WindowProxyHandler(handler) = win.windowproxy_handler();
|
||||||
assert!(!handler.is_null());
|
assert!(!handler.is_null());
|
||||||
|
|
||||||
let parent = win.reflector().get_jsobject();
|
let parent = win.reflector().get_jsobject();
|
||||||
let cx = js_info.as_ref().unwrap().js_context.ptr;
|
let cx = win.get_cx();
|
||||||
let wrapper = with_compartment(cx, parent, || unsafe {
|
let wrapper = with_compartment(cx, parent, || unsafe {
|
||||||
WrapperNew(cx, parent, handler)
|
WrapperNew(cx, parent, handler)
|
||||||
});
|
});
|
||||||
|
|
|
@ -151,7 +151,7 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn LineTo(self, x: f64, y: f64) {
|
fn LineTo(self, x: f64, y: f64) {
|
||||||
self.renderer.send(CanvasMsg::LineTo(Point2D(x as f32, y as f32)));
|
self.renderer.send(CanvasMsg::LineTo(Point2D(x as f32, y as f32))).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn BezierCurveTo(self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, x: f64, y: f64) {
|
fn BezierCurveTo(self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, x: f64, y: f64) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::ConsoleBinding::ConsoleMethods;
|
||||||
use dom::bindings::global::{GlobalRef, GlobalField};
|
use dom::bindings::global::{GlobalRef, GlobalField};
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||||
|
use dom::window::WindowHelpers;
|
||||||
use devtools_traits::{DevtoolsControlMsg, ConsoleMessage};
|
use devtools_traits::{DevtoolsControlMsg, ConsoleMessage};
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
||||||
|
@ -66,8 +67,8 @@ fn propagate_console_msg(console: &JSRef<Console>, console_message: ConsoleMessa
|
||||||
let global = console.global.root();
|
let global = console.global.root();
|
||||||
match global.r() {
|
match global.r() {
|
||||||
GlobalRef::Window(window_ref) => {
|
GlobalRef::Window(window_ref) => {
|
||||||
let pipelineId = window_ref.page().id;
|
let pipelineId = window_ref.pipeline();
|
||||||
console.global.root().r().as_window().page().devtools_chan.as_ref().map(|chan| {
|
console.global.root().r().as_window().devtools_chan().as_ref().map(|chan| {
|
||||||
chan.send(DevtoolsControlMsg::SendConsoleMessage(
|
chan.send(DevtoolsControlMsg::SendConsoleMessage(
|
||||||
pipelineId, console_message.clone())).unwrap();
|
pipelineId, console_message.clone())).unwrap();
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@ use dom::document::DocumentHelpers;
|
||||||
use dom::element::{Element, ElementHelpers, StylePriority};
|
use dom::element::{Element, ElementHelpers, StylePriority};
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{window_from_node, document_from_node, NodeDamage, Node};
|
use dom::node::{window_from_node, document_from_node, NodeDamage, Node};
|
||||||
use dom::window::Window;
|
use dom::window::{Window, WindowHelpers};
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
use style::properties::{is_supported_property, longhands_from_shorthand, parse_style_attribute};
|
use style::properties::{is_supported_property, longhands_from_shorthand, parse_style_attribute};
|
||||||
|
@ -221,10 +221,8 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
||||||
|
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
let window = window_from_node(owner.r()).root();
|
let window = window_from_node(owner.r()).root();
|
||||||
let window = window.r();
|
|
||||||
let page = window.page();
|
|
||||||
let decl_block = parse_style_attribute(synthesized_declaration.as_slice(),
|
let decl_block = parse_style_attribute(synthesized_declaration.as_slice(),
|
||||||
&page.get_url());
|
&window.r().get_url());
|
||||||
|
|
||||||
// Step 7
|
// Step 7
|
||||||
if decl_block.normal.len() == 0 {
|
if decl_block.normal.len() == 0 {
|
||||||
|
@ -270,10 +268,8 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
||||||
|
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
let window = window_from_node(owner.r()).root();
|
let window = window_from_node(owner.r()).root();
|
||||||
let window = window.r();
|
|
||||||
let page = window.page();
|
|
||||||
let decl_block = parse_style_attribute(property.as_slice(),
|
let decl_block = parse_style_attribute(property.as_slice(),
|
||||||
&page.get_url());
|
&window.r().get_url());
|
||||||
let element: JSRef<Element> = ElementCast::from_ref(owner.r());
|
let element: JSRef<Element> = ElementCast::from_ref(owner.r());
|
||||||
|
|
||||||
// Step 5
|
// Step 5
|
||||||
|
|
|
@ -11,7 +11,6 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|
||||||
use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast};
|
use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, TextCast, ElementCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, TextCast, ElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast};
|
||||||
|
@ -59,12 +58,14 @@ use dom::treewalker::TreeWalker;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::{Window, WindowHelpers};
|
use dom::window::{Window, WindowHelpers};
|
||||||
|
|
||||||
|
use layout_interface::{HitTestResponse, MouseOverResponse};
|
||||||
use msg::compositor_msg::ScriptListener;
|
use msg::compositor_msg::ScriptListener;
|
||||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||||
use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL};
|
use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL};
|
||||||
use net::resource_task::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl};
|
use net::resource_task::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl};
|
||||||
use net::cookie_storage::CookieSource::NonHTTP;
|
use net::cookie_storage::CookieSource::NonHTTP;
|
||||||
use script_task::Runnable;
|
use script_task::Runnable;
|
||||||
|
use script_traits::UntrustedNodeAddress;
|
||||||
use util::namespace;
|
use util::namespace;
|
||||||
use util::str::{DOMString, split_html_space_chars};
|
use util::str::{DOMString, split_html_space_chars};
|
||||||
use layout_interface::{ReflowGoal, ReflowQueryType};
|
use layout_interface::{ReflowGoal, ReflowQueryType};
|
||||||
|
@ -201,6 +202,8 @@ pub trait DocumentHelpers<'a> {
|
||||||
fn register_named_element(self, element: JSRef<Element>, id: Atom);
|
fn register_named_element(self, element: JSRef<Element>, id: Atom);
|
||||||
fn load_anchor_href(self, href: DOMString);
|
fn load_anchor_href(self, href: DOMString);
|
||||||
fn find_fragment_node(self, fragid: DOMString) -> Option<Temporary<Element>>;
|
fn find_fragment_node(self, fragid: DOMString) -> Option<Temporary<Element>>;
|
||||||
|
fn hit_test(self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress>;
|
||||||
|
fn get_nodes_under_mouse(self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress>;
|
||||||
fn set_ready_state(self, state: DocumentReadyState);
|
fn set_ready_state(self, state: DocumentReadyState);
|
||||||
fn get_focused_element(self) -> Option<Temporary<Element>>;
|
fn get_focused_element(self) -> Option<Temporary<Element>>;
|
||||||
fn begin_focus_transaction(self);
|
fn begin_focus_transaction(self);
|
||||||
|
@ -241,7 +244,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
let browser_context = browser_context.as_ref().unwrap();
|
let browser_context = browser_context.as_ref().unwrap();
|
||||||
let active_document = browser_context.active_document().root();
|
let active_document = browser_context.active_document().root();
|
||||||
|
|
||||||
if self.clone() != active_document.r() {
|
if self != active_document.r() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// FIXME: It should also check whether the browser context is top-level or not
|
// FIXME: It should also check whether the browser context is top-level or not
|
||||||
|
@ -264,7 +267,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
Quirks => {
|
Quirks => {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
let LayoutChan(ref layout_chan) = window.page().layout_chan;
|
let LayoutChan(ref layout_chan) = window.layout_chan();
|
||||||
layout_chan.send(Msg::SetQuirksMode).unwrap();
|
layout_chan.send(Msg::SetQuirksMode).unwrap();
|
||||||
}
|
}
|
||||||
NoQuirks | LimitedQuirks => {}
|
NoQuirks | LimitedQuirks => {}
|
||||||
|
@ -377,6 +380,44 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hit_test(self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress> {
|
||||||
|
let root = self.GetDocumentElement().root();
|
||||||
|
let root = match root.r() {
|
||||||
|
Some(root) => root,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
let root = NodeCast::from_ref(root);
|
||||||
|
let win = self.window.root();
|
||||||
|
let address = match win.r().layout().hit_test(root.to_trusted_node_address(), *point) {
|
||||||
|
Ok(HitTestResponse(node_address)) => {
|
||||||
|
Some(node_address)
|
||||||
|
}
|
||||||
|
Err(()) => {
|
||||||
|
debug!("layout query error");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
address
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_nodes_under_mouse(self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress> {
|
||||||
|
let root = self.GetDocumentElement().root();
|
||||||
|
let root = match root.r() {
|
||||||
|
Some(root) => root,
|
||||||
|
None => return vec!(),
|
||||||
|
};
|
||||||
|
let root: JSRef<Node> = NodeCast::from_ref(root);
|
||||||
|
let win = self.window.root();
|
||||||
|
match win.r().layout().mouse_over(root.to_trusted_node_address(), *point) {
|
||||||
|
Ok(MouseOverResponse(node_address)) => {
|
||||||
|
node_address
|
||||||
|
}
|
||||||
|
Err(()) => {
|
||||||
|
vec!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/dom.html#current-document-readiness
|
// https://html.spec.whatwg.org/multipage/dom.html#current-document-readiness
|
||||||
fn set_ready_state(self, state: DocumentReadyState) {
|
fn set_ready_state(self, state: DocumentReadyState) {
|
||||||
self.ready_state.set(state);
|
self.ready_state.set(state);
|
||||||
|
@ -416,7 +457,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
/// Sends this document's title to the compositor.
|
/// Sends this document's title to the compositor.
|
||||||
fn send_title_to_compositor(self) {
|
fn send_title_to_compositor(self) {
|
||||||
let window = self.window().root();
|
let window = self.window().root();
|
||||||
window.r().page().send_title_to_compositor();
|
window.r().compositor().set_title(window.r().pipeline(), Some(self.Title()));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dirty_all_nodes(self) {
|
fn dirty_all_nodes(self) {
|
||||||
|
@ -428,10 +469,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
|
|
||||||
fn handle_click_event(self, js_runtime: *mut JSRuntime, _button: uint, point: Point2D<f32>) {
|
fn handle_click_event(self, js_runtime: *mut JSRuntime, _button: uint, point: Point2D<f32>) {
|
||||||
debug!("ClickEvent: clicked at {:?}", point);
|
debug!("ClickEvent: clicked at {:?}", point);
|
||||||
let window = self.window.root();
|
let node = match self.hit_test(&point) {
|
||||||
let window = window.r();
|
|
||||||
let page = window.page();
|
|
||||||
let node = match page.hit_test(&point) {
|
|
||||||
Some(node_address) => {
|
Some(node_address) => {
|
||||||
debug!("node address is {:?}", node_address.0);
|
debug!("node address is {:?}", node_address.0);
|
||||||
node::from_untrusted_node_address(js_runtime, node_address)
|
node::from_untrusted_node_address(js_runtime, node_address)
|
||||||
|
@ -460,48 +498,40 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
match *page.frame() {
|
self.begin_focus_transaction();
|
||||||
Some(ref frame) => {
|
|
||||||
let window = frame.window.root();
|
|
||||||
let doc = window.r().Document().root();
|
|
||||||
doc.r().begin_focus_transaction();
|
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-click
|
let window = self.window.root();
|
||||||
let x = point.x as i32;
|
|
||||||
let y = point.y as i32;
|
|
||||||
let event = MouseEvent::new(window.r(),
|
|
||||||
"click".to_owned(),
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
Some(window.r()),
|
|
||||||
0i32,
|
|
||||||
x, y, x, y,
|
|
||||||
false, false, false, false,
|
|
||||||
0i16,
|
|
||||||
None).root();
|
|
||||||
let event: JSRef<Event> = EventCast::from_ref(event.r());
|
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#trusted-events
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-click
|
||||||
event.set_trusted(true);
|
let x = point.x as i32;
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html#run-authentic-click-activation-steps
|
let y = point.y as i32;
|
||||||
el.authentic_click_activation(event);
|
let event = MouseEvent::new(window.r(),
|
||||||
|
"click".to_owned(),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
Some(window.r()),
|
||||||
|
0i32,
|
||||||
|
x, y, x, y,
|
||||||
|
false, false, false, false,
|
||||||
|
0i16,
|
||||||
|
None).root();
|
||||||
|
let event: JSRef<Event> = EventCast::from_ref(event.r());
|
||||||
|
|
||||||
doc.r().commit_focus_transaction();
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#trusted-events
|
||||||
window.r().flush_layout(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery);
|
event.set_trusted(true);
|
||||||
}
|
// https://html.spec.whatwg.org/multipage/interaction.html#run-authentic-click-activation-steps
|
||||||
None => {}
|
el.authentic_click_activation(event);
|
||||||
}
|
|
||||||
|
self.commit_focus_transaction();
|
||||||
|
window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return need force reflow or not
|
/// Return need force reflow or not
|
||||||
fn handle_mouse_move_event(self, js_runtime: *mut JSRuntime, point: Point2D<f32>,
|
fn handle_mouse_move_event(self, js_runtime: *mut JSRuntime, point: Point2D<f32>,
|
||||||
prev_mouse_over_targets: &mut Vec<JS<Node>>) -> bool {
|
prev_mouse_over_targets: &mut Vec<JS<Node>>) -> bool {
|
||||||
let window = self.window.root();
|
|
||||||
let window = window.r();
|
|
||||||
let page = window.page();
|
|
||||||
let mut needs_reflow = false;
|
let mut needs_reflow = false;
|
||||||
// Build a list of elements that are currently under the mouse.
|
// Build a list of elements that are currently under the mouse.
|
||||||
let mouse_over_addresses = page.get_nodes_under_mouse(&point);
|
let mouse_over_addresses = self.get_nodes_under_mouse(&point);
|
||||||
let mouse_over_targets: Vec<JS<Node>> = mouse_over_addresses.iter()
|
let mouse_over_targets: Vec<JS<Node>> = mouse_over_addresses.iter()
|
||||||
.filter_map(|node_address| {
|
.filter_map(|node_address| {
|
||||||
let node = node::from_untrusted_node_address(js_runtime, *node_address);
|
let node = node::from_untrusted_node_address(js_runtime, *node_address);
|
||||||
|
@ -534,27 +564,24 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
let top_most_node =
|
let top_most_node =
|
||||||
node::from_untrusted_node_address(js_runtime, mouse_over_addresses[0]).root();
|
node::from_untrusted_node_address(js_runtime, mouse_over_addresses[0]).root();
|
||||||
|
|
||||||
if let Some(ref frame) = *page.frame() {
|
let x = point.x.to_i32().unwrap_or(0);
|
||||||
let window = frame.window.root();
|
let y = point.y.to_i32().unwrap_or(0);
|
||||||
|
|
||||||
let x = point.x.to_i32().unwrap_or(0);
|
let window = self.window.root();
|
||||||
let y = point.y.to_i32().unwrap_or(0);
|
let mouse_event = MouseEvent::new(window.r(),
|
||||||
|
"mousemove".to_owned(),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
Some(window.r()),
|
||||||
|
0i32,
|
||||||
|
x, y, x, y,
|
||||||
|
false, false, false, false,
|
||||||
|
0i16,
|
||||||
|
None).root();
|
||||||
|
|
||||||
let mouse_event = MouseEvent::new(window.r(),
|
let event: JSRef<Event> = EventCast::from_ref(mouse_event.r());
|
||||||
"mousemove".to_owned(),
|
let target: JSRef<EventTarget> = EventTargetCast::from_ref(top_most_node.r());
|
||||||
true,
|
event.fire(target);
|
||||||
true,
|
|
||||||
Some(window.r()),
|
|
||||||
0i32,
|
|
||||||
x, y, x, y,
|
|
||||||
false, false, false, false,
|
|
||||||
0i16,
|
|
||||||
None).root();
|
|
||||||
|
|
||||||
let event: JSRef<Event> = EventCast::from_ref(mouse_event.r());
|
|
||||||
let target: JSRef<EventTarget> = EventTargetCast::from_ref(top_most_node.r());
|
|
||||||
event.fire(target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the current mouse over targets for next frame
|
// Store the current mouse over targets for next frame
|
||||||
|
@ -637,7 +664,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
window.r().flush_layout(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery);
|
window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>) {
|
fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>) {
|
||||||
|
@ -1259,7 +1286,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
fn Location(self) -> Temporary<Location> {
|
fn Location(self) -> Temporary<Location> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
self.location.or_init(|| Location::new(window, window.page_clone()))
|
self.location.or_init(|| Location::new(window))
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-parentnode-children
|
// http://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
|
@ -1298,10 +1325,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
return Err(Security);
|
return Err(Security);
|
||||||
}
|
}
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let window = window.r();
|
|
||||||
let page = window.page();
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
let _ = page.resource_task.send(GetCookiesForUrl(url, tx, NonHTTP));
|
let _ = window.r().resource_task().send(GetCookiesForUrl(url, tx, NonHTTP));
|
||||||
let cookies = rx.recv().unwrap();
|
let cookies = rx.recv().unwrap();
|
||||||
Ok(cookies.unwrap_or("".to_owned()))
|
Ok(cookies.unwrap_or("".to_owned()))
|
||||||
}
|
}
|
||||||
|
@ -1314,9 +1339,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
return Err(Security);
|
return Err(Security);
|
||||||
}
|
}
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let window = window.r();
|
let _ = window.r().resource_task().send(SetCookiesForUrl(url, cookie, NonHTTP));
|
||||||
let page = window.page();
|
|
||||||
let _ = page.resource_task.send(SetCookiesForUrl(url, cookie, NonHTTP));
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::js::{JS, JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||||
use dom::document::{Document, DocumentHelpers, IsHTMLDocument};
|
use dom::document::{Document, DocumentHelpers, IsHTMLDocument};
|
||||||
use dom::document::DocumentSource;
|
use dom::document::DocumentSource;
|
||||||
use dom::window::Window;
|
use dom::window::{Window, WindowHelpers};
|
||||||
use parse::html::{HTMLInput, parse_html};
|
use parse::html::{HTMLInput, parse_html};
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ use dom::eventtarget::{EventTarget, EventTargetTypeId, EventTargetHelpers};
|
||||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
use dom::window::WindowHelpers;
|
||||||
|
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
use util::str::{self, DOMString};
|
use util::str::{self, DOMString};
|
||||||
|
|
|
@ -26,6 +26,7 @@ use dom::htmlmediaelement::HTMLMediaElementTypeId;
|
||||||
use dom::htmltablecellelement::HTMLTableCellElementTypeId;
|
use dom::htmltablecellelement::HTMLTableCellElementTypeId;
|
||||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
use dom::window::WindowHelpers;
|
||||||
|
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is wrong. https://html.spec.whatwg.org/multipage/forms.html#planned-navigation
|
// This is wrong. https://html.spec.whatwg.org/multipage/forms.html#planned-navigation
|
||||||
win.r().script_chan().send(ScriptMsg::TriggerLoad(win.r().page().id, load_data)).unwrap();
|
win.r().script_chan().send(ScriptMsg::TriggerLoad(win.r().pipeline(), load_data)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_form_dataset<'b>(self, submitter: Option<FormSubmitter<'b>>) -> Vec<FormDatum> {
|
fn get_form_dataset<'b>(self, submitter: Option<FormSubmitter<'b>>) -> Vec<FormDatum> {
|
||||||
|
|
|
@ -20,8 +20,8 @@ use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||||
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||||
use dom::urlhelper::UrlHelper;
|
use dom::urlhelper::UrlHelper;
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
use dom::window::Window;
|
use dom::window::{Window, WindowHelpers};
|
||||||
use page::{IterablePage, Page};
|
use page::IterablePage;
|
||||||
|
|
||||||
use msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan};
|
use msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan};
|
||||||
use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
|
use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
|
||||||
|
@ -62,7 +62,7 @@ pub trait HTMLIFrameElementHelpers {
|
||||||
fn get_url(self) -> Option<Url>;
|
fn get_url(self) -> Option<Url>;
|
||||||
/// http://www.whatwg.org/html/#process-the-iframe-attributes
|
/// http://www.whatwg.org/html/#process-the-iframe-attributes
|
||||||
fn process_the_iframe_attributes(self);
|
fn process_the_iframe_attributes(self);
|
||||||
fn generate_new_subpage_id(self, page: &Page) -> (SubpageId, Option<SubpageId>);
|
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
||||||
|
@ -78,15 +78,16 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
UrlParser::new().base_url(&window.r().page().get_url())
|
UrlParser::new().base_url(&window.r().get_url())
|
||||||
.parse(url.as_slice()).ok()
|
.parse(url.as_slice()).ok()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_new_subpage_id(self, page: &Page) -> (SubpageId, Option<SubpageId>) {
|
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>) {
|
||||||
let old_subpage_id = self.subpage_id.get();
|
let old_subpage_id = self.subpage_id.get();
|
||||||
let subpage_id = page.get_next_subpage_id();
|
let win = window_from_node(self).root();
|
||||||
|
let subpage_id = win.r().get_next_subpage_id();
|
||||||
self.subpage_id.set(Some(subpage_id));
|
self.subpage_id.set(Some(subpage_id));
|
||||||
(subpage_id, old_subpage_id)
|
(subpage_id, old_subpage_id)
|
||||||
}
|
}
|
||||||
|
@ -105,14 +106,13 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
||||||
|
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
let page = window.page();
|
let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id();
|
||||||
let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id(page);
|
|
||||||
|
|
||||||
self.containing_page_pipeline_id.set(Some(page.id));
|
self.containing_page_pipeline_id.set(Some(window.pipeline()));
|
||||||
|
|
||||||
let ConstellationChan(ref chan) = page.constellation_chan;
|
let ConstellationChan(ref chan) = window.constellation_chan();
|
||||||
chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(url,
|
chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(url,
|
||||||
page.id,
|
window.pipeline(),
|
||||||
new_subpage_id,
|
new_subpage_id,
|
||||||
old_subpage_id,
|
old_subpage_id,
|
||||||
sandboxed)).unwrap();
|
sandboxed)).unwrap();
|
||||||
|
@ -172,14 +172,10 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
let children = window.page().children.borrow();
|
let children = window.page().children.borrow();
|
||||||
let child = children.iter().find(|child| {
|
children.iter().find(|page| {
|
||||||
child.subpage_id.unwrap() == subpage_id
|
let window = page.window().root();
|
||||||
});
|
window.r().subpage() == Some(subpage_id)
|
||||||
child.and_then(|page| {
|
}).map(|page| page.window())
|
||||||
page.frame.borrow().as_ref().map(|frame| {
|
|
||||||
Temporary::new(frame.window.clone())
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +185,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
Some(self_url) => self_url,
|
Some(self_url) => self_url,
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
let win_url = window_from_node(self).root().r().page().get_url();
|
let win_url = window_from_node(self).root().r().get_url();
|
||||||
|
|
||||||
if UrlHelper::SameOrigin(&self_url, &win_url) {
|
if UrlHelper::SameOrigin(&self_url, &win_url) {
|
||||||
Some(window.r().Document())
|
Some(window.r().Document())
|
||||||
|
|
|
@ -17,6 +17,7 @@ use dom::element::ElementTypeId;
|
||||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||||
use dom::node::{Node, NodeTypeId, NodeHelpers, NodeDamage, window_from_node};
|
use dom::node::{Node, NodeTypeId, NodeHelpers, NodeDamage, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
use dom::window::WindowHelpers;
|
||||||
use net::image_cache_task;
|
use net::image_cache_task;
|
||||||
use util::geometry::to_px;
|
use util::geometry::to_px;
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
|
|
@ -17,6 +17,7 @@ use dom::element::ElementTypeId;
|
||||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||||
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
use dom::window::WindowHelpers;
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::{LayoutChan, Msg};
|
||||||
use util::str::{DOMString, HTML_SPACE_CHARACTERS};
|
use util::str::{DOMString, HTML_SPACE_CHARACTERS};
|
||||||
|
|
||||||
|
@ -130,9 +131,9 @@ impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
|
||||||
fn handle_stylesheet_url(self, href: &str) {
|
fn handle_stylesheet_url(self, href: &str) {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
match UrlParser::new().base_url(&window.page().get_url()).parse(href) {
|
match UrlParser::new().base_url(&window.get_url()).parse(href) {
|
||||||
Ok(url) => {
|
Ok(url) => {
|
||||||
let LayoutChan(ref layout_chan) = window.page().layout_chan;
|
let LayoutChan(ref layout_chan) = window.layout_chan();
|
||||||
layout_chan.send(Msg::LoadStylesheet(url)).unwrap();
|
layout_chan.send(Msg::LoadStylesheet(url)).unwrap();
|
||||||
}
|
}
|
||||||
Err(e) => debug!("Parsing url {} failed: {}", href, e)
|
Err(e) => debug!("Parsing url {} failed: {}", href, e)
|
||||||
|
|
|
@ -25,7 +25,7 @@ use dom::element::ElementTypeId;
|
||||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||||
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node, CloneChildrenFlag};
|
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node, CloneChildrenFlag};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
use dom::window::ScriptHelpers;
|
use dom::window::{WindowHelpers, ScriptHelpers};
|
||||||
use script_task::{ScriptMsg, Runnable};
|
use script_task::{ScriptMsg, Runnable};
|
||||||
|
|
||||||
use encoding::all::UTF_8;
|
use encoding::all::UTF_8;
|
||||||
|
@ -214,8 +214,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
|
||||||
// Step 14.
|
// Step 14.
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let window = window.r();
|
let window = window.r();
|
||||||
let page = window.page();
|
let base_url = window.get_url();
|
||||||
let base_url = page.get_url();
|
|
||||||
|
|
||||||
let load = match element.get_attribute(ns!(""), &atom!("src")).root() {
|
let load = match element.get_attribute(ns!(""), &atom!("src")).root() {
|
||||||
// Step 14.
|
// Step 14.
|
||||||
|
@ -243,7 +242,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
|
||||||
// state of the element's `crossorigin` content attribute, the origin being
|
// state of the element's `crossorigin` content attribute, the origin being
|
||||||
// the origin of the script element's node document, and the default origin
|
// the origin of the script element's node document, and the default origin
|
||||||
// behaviour set to taint.
|
// behaviour set to taint.
|
||||||
ScriptOrigin::External(load_whole_resource(&page.resource_task, url))
|
ScriptOrigin::External(load_whole_resource(&window.resource_task(), url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,6 +12,7 @@ use dom::element::ElementTypeId;
|
||||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||||
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
use dom::window::WindowHelpers;
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::{LayoutChan, Msg};
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
use style::stylesheets::{Origin, Stylesheet};
|
use style::stylesheets::{Origin, Stylesheet};
|
||||||
|
@ -52,11 +53,11 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
|
||||||
|
|
||||||
let win = window_from_node(node).root();
|
let win = window_from_node(node).root();
|
||||||
let win = win.r();
|
let win = win.r();
|
||||||
let url = win.page().get_url();
|
let url = win.get_url();
|
||||||
|
|
||||||
let data = node.GetTextContent().expect("Element.textContent must be a string");
|
let data = node.GetTextContent().expect("Element.textContent must be a string");
|
||||||
let sheet = Stylesheet::from_str(data.as_slice(), url, Origin::Author);
|
let sheet = Stylesheet::from_str(data.as_slice(), url, Origin::Author);
|
||||||
let LayoutChan(ref layout_chan) = win.page().layout_chan;
|
let LayoutChan(ref layout_chan) = win.layout_chan();
|
||||||
layout_chan.send(Msg::AddStylesheet(sheet)).unwrap();
|
layout_chan.send(Msg::AddStylesheet(sheet)).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,33 +5,31 @@
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding;
|
use dom::bindings::codegen::Bindings::LocationBinding;
|
||||||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::{JS, JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||||
use dom::urlhelper::UrlHelper;
|
use dom::urlhelper::UrlHelper;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use dom::window::WindowHelpers;
|
use dom::window::WindowHelpers;
|
||||||
use page::Page;
|
|
||||||
|
|
||||||
use util::str::DOMString;
|
use util::str::DOMString;
|
||||||
|
use url::Url;
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct Location {
|
pub struct Location {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
page: Rc<Page>,
|
window: JS<Window>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Location {
|
impl Location {
|
||||||
fn new_inherited(page: Rc<Page>) -> Location {
|
fn new_inherited(window: JSRef<Window>) -> Location {
|
||||||
Location {
|
Location {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
page: page
|
window: JS::from_rooted(window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: JSRef<Window>, page: Rc<Page>) -> Temporary<Location> {
|
pub fn new(window: JSRef<Window>) -> Temporary<Location> {
|
||||||
reflect_dom_object(box Location::new_inherited(page),
|
reflect_dom_object(box Location::new_inherited(window),
|
||||||
GlobalRef::Window(window),
|
GlobalRef::Window(window),
|
||||||
LocationBinding::Wrap)
|
LocationBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
@ -40,11 +38,11 @@ impl Location {
|
||||||
impl<'a> LocationMethods for JSRef<'a, Location> {
|
impl<'a> LocationMethods for JSRef<'a, Location> {
|
||||||
// https://html.spec.whatwg.org/multipage/browsers.html#dom-location-assign
|
// https://html.spec.whatwg.org/multipage/browsers.html#dom-location-assign
|
||||||
fn Assign(self, url: DOMString) {
|
fn Assign(self, url: DOMString) {
|
||||||
self.page.frame().as_ref().unwrap().window.root().r().load_url(url);
|
self.window.root().r().load_url(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Href(self) -> DOMString {
|
fn Href(self) -> DOMString {
|
||||||
UrlHelper::Href(&self.page.get_url())
|
UrlHelper::Href(&self.get_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Stringify(self) -> DOMString {
|
fn Stringify(self) -> DOMString {
|
||||||
|
@ -52,11 +50,21 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Search(self) -> DOMString {
|
fn Search(self) -> DOMString {
|
||||||
UrlHelper::Search(&self.page.get_url())
|
UrlHelper::Search(&self.get_url())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Hash(self) -> DOMString {
|
fn Hash(self) -> DOMString {
|
||||||
UrlHelper::Hash(&self.page.get_url())
|
UrlHelper::Hash(&self.get_url())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait PrivateLocationHelpers {
|
||||||
|
fn get_url(self) -> Url;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> PrivateLocationHelpers for JSRef<'a, Location> {
|
||||||
|
fn get_url(self) -> Url {
|
||||||
|
let window = self.window.root();
|
||||||
|
window.r().get_url()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ macro_rules! make_url_or_base_getter(
|
||||||
fn $attr(self) -> DOMString {
|
fn $attr(self) -> DOMString {
|
||||||
use dom::element::{Element, AttributeHandlers};
|
use dom::element::{Element, AttributeHandlers};
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
|
use dom::window::WindowHelpers;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||||
|
|
|
@ -41,7 +41,7 @@ use dom::nodelist::NodeList;
|
||||||
use dom::processinginstruction::ProcessingInstruction;
|
use dom::processinginstruction::ProcessingInstruction;
|
||||||
use dom::text::Text;
|
use dom::text::Text;
|
||||||
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
||||||
use dom::window::Window;
|
use dom::window::{Window, WindowHelpers};
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
use layout_interface::{LayoutChan, Msg};
|
use layout_interface::{LayoutChan, Msg};
|
||||||
use devtools_traits::NodeInfo;
|
use devtools_traits::NodeInfo;
|
||||||
|
@ -409,7 +409,7 @@ pub trait NodeHelpers<'a> {
|
||||||
fn child_elements(self) -> ChildElementIterator<'a>;
|
fn child_elements(self) -> ChildElementIterator<'a>;
|
||||||
fn following_siblings(self) -> NodeChildrenIterator<'a>;
|
fn following_siblings(self) -> NodeChildrenIterator<'a>;
|
||||||
fn is_in_doc(self) -> bool;
|
fn is_in_doc(self) -> bool;
|
||||||
fn is_inclusive_ancestor_of(self, parent: JSRef<'a, Node>) -> bool; // FIXME: See #3960
|
fn is_inclusive_ancestor_of(self, parent: JSRef<Node>) -> bool;
|
||||||
fn is_parent_of(self, child: JSRef<Node>) -> bool;
|
fn is_parent_of(self, child: JSRef<Node>) -> bool;
|
||||||
|
|
||||||
fn type_id(self) -> NodeTypeId;
|
fn type_id(self) -> NodeTypeId;
|
||||||
|
@ -490,9 +490,18 @@ pub trait NodeHelpers<'a> {
|
||||||
|
|
||||||
fn get_unique_id(self) -> String;
|
fn get_unique_id(self) -> String;
|
||||||
fn summarize(self) -> NodeInfo;
|
fn summarize(self) -> NodeInfo;
|
||||||
|
|
||||||
|
fn teardown(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
|
fn teardown(self) {
|
||||||
|
self.layout_data.dispose();
|
||||||
|
for kid in self.children() {
|
||||||
|
kid.teardown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Dumps the subtree rooted at this node, for debugging.
|
/// Dumps the subtree rooted at this node, for debugging.
|
||||||
fn dump(self) {
|
fn dump(self) {
|
||||||
self.dump_indent(0);
|
self.dump_indent(0);
|
||||||
|
@ -715,7 +724,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_inclusive_ancestor_of(self, parent: JSRef<'a, Node>) -> bool {
|
fn is_inclusive_ancestor_of(self, parent: JSRef<Node>) -> bool {
|
||||||
self == parent || parent.ancestors().any(|ancestor| ancestor == self)
|
self == parent || parent.ancestors().any(|ancestor| ancestor == self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,11 +746,11 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bounding_content_box(self) -> Rect<Au> {
|
fn get_bounding_content_box(self) -> Rect<Au> {
|
||||||
window_from_node(self).root().r().page().content_box_query(self.to_trusted_node_address())
|
window_from_node(self).root().r().content_box_query(self.to_trusted_node_address())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_content_boxes(self) -> Vec<Rect<Au>> {
|
fn get_content_boxes(self) -> Vec<Rect<Au>> {
|
||||||
window_from_node(self).root().r().page().content_boxes_query(self.to_trusted_node_address())
|
window_from_node(self).root().r().content_boxes_query(self.to_trusted_node_address())
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
// http://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||||
|
@ -1376,7 +1385,7 @@ impl Node {
|
||||||
|
|
||||||
// Step 7-8.
|
// Step 7-8.
|
||||||
let reference_child = match child {
|
let reference_child = match child {
|
||||||
Some(child) if child.clone() == node => node.next_sibling().map(|node| node.root().get_unsound_ref_forever()),
|
Some(child) if child == node => node.next_sibling().map(|node| node.root().get_unsound_ref_forever()),
|
||||||
_ => child
|
_ => child
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1946,7 +1955,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok if not caught by previous error checks.
|
// Ok if not caught by previous error checks.
|
||||||
if node.clone() == child {
|
if node == child {
|
||||||
return Ok(Temporary::from_rooted(child));
|
return Ok(Temporary::from_rooted(child));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2106,7 +2115,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-node-comparedocumentposition
|
// http://dom.spec.whatwg.org/#dom-node-comparedocumentposition
|
||||||
fn CompareDocumentPosition(self, other: JSRef<Node>) -> u16 {
|
fn CompareDocumentPosition(self, other: JSRef<Node>) -> u16 {
|
||||||
if self.clone() == other { // FIXME: See issue #3960
|
if self == other {
|
||||||
// step 2.
|
// step 2.
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,6 +38,7 @@ partial interface CSSStyleDeclaration {
|
||||||
[TreatNullAs=EmptyString] attribute DOMString backgroundRepeat;
|
[TreatNullAs=EmptyString] attribute DOMString backgroundRepeat;
|
||||||
[TreatNullAs=EmptyString] attribute DOMString backgroundImage;
|
[TreatNullAs=EmptyString] attribute DOMString backgroundImage;
|
||||||
[TreatNullAs=EmptyString] attribute DOMString backgroundAttachment;
|
[TreatNullAs=EmptyString] attribute DOMString backgroundAttachment;
|
||||||
|
[TreatNullAs=EmptyString] attribute DOMString backgroundSize;
|
||||||
|
|
||||||
[TreatNullAs=EmptyString] attribute DOMString border;
|
[TreatNullAs=EmptyString] attribute DOMString border;
|
||||||
[TreatNullAs=EmptyString] attribute DOMString borderColor;
|
[TreatNullAs=EmptyString] attribute DOMString borderColor;
|
||||||
|
@ -103,6 +104,8 @@ partial interface CSSStyleDeclaration {
|
||||||
[TreatNullAs=EmptyString] attribute DOMString listStyleImage;
|
[TreatNullAs=EmptyString] attribute DOMString listStyleImage;
|
||||||
|
|
||||||
[TreatNullAs=EmptyString] attribute DOMString overflow;
|
[TreatNullAs=EmptyString] attribute DOMString overflow;
|
||||||
|
[TreatNullAs=EmptyString] attribute DOMString overflowX;
|
||||||
|
[TreatNullAs=EmptyString] attribute DOMString overflowY;
|
||||||
[TreatNullAs=EmptyString] attribute DOMString overflowWrap;
|
[TreatNullAs=EmptyString] attribute DOMString overflowWrap;
|
||||||
|
|
||||||
[TreatNullAs=EmptyString] attribute DOMString tableLayout;
|
[TreatNullAs=EmptyString] attribute DOMString tableLayout;
|
||||||
|
@ -171,4 +174,6 @@ partial interface CSSStyleDeclaration {
|
||||||
[TreatNullAs=EmptyString] attribute DOMString maxWidth;
|
[TreatNullAs=EmptyString] attribute DOMString maxWidth;
|
||||||
|
|
||||||
[TreatNullAs=EmptyString] attribute DOMString zIndex;
|
[TreatNullAs=EmptyString] attribute DOMString zIndex;
|
||||||
|
|
||||||
|
[TreatNullAs=EmptyString] attribute DOMString imageRendering;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,50 +8,59 @@ use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding;
|
use dom::bindings::codegen::Bindings::WindowBinding;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
use dom::bindings::codegen::InheritTypes::{NodeCast, EventTargetCast};
|
||||||
use dom::bindings::global::global_object_for_js_object;
|
use dom::bindings::global::global_object_for_js_object;
|
||||||
use dom::bindings::error::{report_pending_exception, Fallible};
|
use dom::bindings::error::{report_pending_exception, Fallible};
|
||||||
use dom::bindings::error::Error::InvalidCharacter;
|
use dom::bindings::error::Error::InvalidCharacter;
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::{MutNullableJS, JSRef, Temporary};
|
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalRootable, RootedReference};
|
||||||
use dom::bindings::utils::Reflectable;
|
use dom::bindings::utils::{GlobalStaticData, Reflectable, WindowProxyHandler};
|
||||||
use dom::browsercontext::BrowserContext;
|
use dom::browsercontext::BrowserContext;
|
||||||
use dom::console::Console;
|
use dom::console::Console;
|
||||||
use dom::document::Document;
|
use dom::document::{Document, DocumentHelpers};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||||
use dom::location::Location;
|
use dom::location::Location;
|
||||||
use dom::navigator::Navigator;
|
use dom::navigator::Navigator;
|
||||||
use dom::node::window_from_node;
|
use dom::node::{window_from_node, Node, TrustedNodeAddress, NodeHelpers};
|
||||||
use dom::performance::Performance;
|
use dom::performance::Performance;
|
||||||
use dom::screen::Screen;
|
use dom::screen::Screen;
|
||||||
use dom::storage::Storage;
|
use dom::storage::Storage;
|
||||||
use layout_interface::{ReflowGoal, ReflowQueryType};
|
use layout_interface::{ReflowGoal, ReflowQueryType, LayoutRPC, LayoutChan, Reflow, Msg};
|
||||||
|
use layout_interface::{ContentBoxResponse, ContentBoxesResponse};
|
||||||
use page::Page;
|
use page::Page;
|
||||||
use script_task::{TimerSource, ScriptChan};
|
use script_task::{TimerSource, ScriptChan};
|
||||||
use script_task::ScriptMsg;
|
use script_task::ScriptMsg;
|
||||||
use script_traits::ScriptControlChan;
|
use script_traits::ScriptControlChan;
|
||||||
use timers::{IsInterval, TimerId, TimerManager, TimerCallback};
|
use timers::{IsInterval, TimerId, TimerManager, TimerCallback};
|
||||||
|
|
||||||
|
use devtools_traits::DevtoolsControlChan;
|
||||||
use msg::compositor_msg::ScriptListener;
|
use msg::compositor_msg::ScriptListener;
|
||||||
use msg::constellation_msg::LoadData;
|
use msg::constellation_msg::{LoadData, PipelineId, SubpageId, ConstellationChan, WindowSizeData};
|
||||||
use net::image_cache_task::ImageCacheTask;
|
use net::image_cache_task::ImageCacheTask;
|
||||||
|
use net::resource_task::ResourceTask;
|
||||||
use net::storage_task::StorageTask;
|
use net::storage_task::StorageTask;
|
||||||
|
use util::geometry::{self, Au, MAX_RECT};
|
||||||
use util::str::{DOMString,HTML_SPACE_CHARACTERS};
|
use util::str::{DOMString,HTML_SPACE_CHARACTERS};
|
||||||
|
|
||||||
|
use geom::{Point2D, Rect, Size2D};
|
||||||
use js::jsapi::JS_EvaluateUCScript;
|
use js::jsapi::JS_EvaluateUCScript;
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
use js::jsapi::{JS_GC, JS_GetRuntime};
|
use js::jsapi::{JS_GC, JS_GetRuntime};
|
||||||
use js::jsval::{JSVal, UndefinedValue};
|
use js::jsval::{JSVal, UndefinedValue};
|
||||||
use js::rust::with_compartment;
|
use js::rust::{Cx, with_compartment};
|
||||||
use url::{Url, UrlParser};
|
use url::{Url, UrlParser};
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD};
|
use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD};
|
||||||
use std::cell::{Ref, RefMut};
|
use std::cell::{Cell, Ref, RefMut};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
use std::mem;
|
||||||
|
use std::num::Float;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::sync::mpsc::{channel, Receiver};
|
||||||
|
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
|
||||||
use time;
|
use time;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -71,18 +80,80 @@ pub struct Window {
|
||||||
screen: MutNullableJS<Screen>,
|
screen: MutNullableJS<Screen>,
|
||||||
session_storage: MutNullableJS<Storage>,
|
session_storage: MutNullableJS<Storage>,
|
||||||
timers: TimerManager,
|
timers: TimerManager,
|
||||||
|
|
||||||
|
/// For providing instructions to an optional devtools server.
|
||||||
|
devtools_chan: Option<DevtoolsControlChan>,
|
||||||
|
|
||||||
|
/// A flag to indicate whether the developer tools have requested live updates of
|
||||||
|
/// page changes.
|
||||||
|
devtools_wants_updates: Cell<bool>,
|
||||||
|
|
||||||
|
next_subpage_id: Cell<SubpageId>,
|
||||||
|
|
||||||
|
/// Pending resize event, if any.
|
||||||
|
resize_event: Cell<Option<WindowSizeData>>,
|
||||||
|
|
||||||
|
/// Pipeline id associated with this page.
|
||||||
|
id: PipelineId,
|
||||||
|
|
||||||
|
/// Subpage id associated with this page, if any.
|
||||||
|
subpage_id: Option<SubpageId>,
|
||||||
|
|
||||||
|
/// Unique id for last reflow request; used for confirming completion reply.
|
||||||
|
last_reflow_id: Cell<uint>,
|
||||||
|
|
||||||
|
/// Global static data related to the DOM.
|
||||||
|
dom_static: GlobalStaticData,
|
||||||
|
|
||||||
|
/// The JavaScript context.
|
||||||
|
js_context: DOMRefCell<Option<Rc<Cx>>>,
|
||||||
|
|
||||||
|
/// A handle for communicating messages to the layout task.
|
||||||
|
layout_chan: LayoutChan,
|
||||||
|
|
||||||
|
/// A handle to perform RPC calls into the layout, quickly.
|
||||||
|
layout_rpc: Box<LayoutRPC+'static>,
|
||||||
|
|
||||||
|
/// The port that we will use to join layout. If this is `None`, then layout is not running.
|
||||||
|
layout_join_port: DOMRefCell<Option<Receiver<()>>>,
|
||||||
|
|
||||||
|
/// The current size of the window, in pixels.
|
||||||
|
window_size: Cell<WindowSizeData>,
|
||||||
|
|
||||||
|
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
||||||
|
resource_task: ResourceTask,
|
||||||
|
|
||||||
|
/// A handle for communicating messages to the storage task.
|
||||||
|
storage_task: StorageTask,
|
||||||
|
|
||||||
|
/// A handle for communicating messages to the constellation task.
|
||||||
|
constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
|
/// Pending scroll to fragment event, if any
|
||||||
|
fragment_name: DOMRefCell<Option<String>>,
|
||||||
|
|
||||||
|
/// An enlarged rectangle around the page contents visible in the viewport, used
|
||||||
|
/// to prevent creating display list items for content that is far away from the viewport.
|
||||||
|
page_clip_rect: Cell<Rect<Au>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn get_cx(&self) -> *mut JSContext {
|
pub fn get_cx(&self) -> *mut JSContext {
|
||||||
let js_info = self.page().js_info();
|
self.js_context.borrow().as_ref().unwrap().ptr
|
||||||
(*js_info.as_ref().unwrap().js_context).ptr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn script_chan(&self) -> Box<ScriptChan+Send> {
|
pub fn script_chan(&self) -> Box<ScriptChan+Send> {
|
||||||
self.script_chan.clone()
|
self.script_chan.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pipeline(&self) -> PipelineId {
|
||||||
|
self.id.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn subpage(&self) -> Option<SubpageId> {
|
||||||
|
self.subpage_id.clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn control_chan<'a>(&'a self) -> &'a ScriptControlChan {
|
pub fn control_chan<'a>(&'a self) -> &'a ScriptControlChan {
|
||||||
&self.control_chan
|
&self.control_chan
|
||||||
}
|
}
|
||||||
|
@ -103,16 +174,8 @@ impl Window {
|
||||||
&*self.page
|
&*self.page
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_clone(&self) -> Rc<Page> {
|
|
||||||
self.page.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_url(&self) -> Url {
|
|
||||||
self.page().get_url()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn storage_task(&self) -> StorageTask {
|
pub fn storage_task(&self) -> StorageTask {
|
||||||
self.page().storage_task.clone()
|
self.storage_task.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,12 +260,11 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Close(self) {
|
fn Close(self) {
|
||||||
self.script_chan.send(ScriptMsg::ExitWindow(self.page.id.clone())).unwrap();
|
self.script_chan.send(ScriptMsg::ExitWindow(self.id.clone())).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Document(self) -> Temporary<Document> {
|
fn Document(self) -> Temporary<Document> {
|
||||||
let frame = self.page().frame();
|
self.browser_context().as_ref().unwrap().active_document()
|
||||||
Temporary::new(frame.as_ref().unwrap().document.clone())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Location(self) -> Temporary<Location> {
|
fn Location(self) -> Temporary<Location> {
|
||||||
|
@ -230,7 +292,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
IsInterval::NonInterval,
|
IsInterval::NonInterval,
|
||||||
TimerSource::FromWindow(self.page.id.clone()),
|
TimerSource::FromWindow(self.id.clone()),
|
||||||
self.script_chan.clone())
|
self.script_chan.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +301,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
IsInterval::NonInterval,
|
IsInterval::NonInterval,
|
||||||
TimerSource::FromWindow(self.page.id.clone()),
|
TimerSource::FromWindow(self.id.clone()),
|
||||||
self.script_chan.clone())
|
self.script_chan.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +314,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
IsInterval::Interval,
|
IsInterval::Interval,
|
||||||
TimerSource::FromWindow(self.page.id.clone()),
|
TimerSource::FromWindow(self.id.clone()),
|
||||||
self.script_chan.clone())
|
self.script_chan.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +323,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
args,
|
args,
|
||||||
timeout,
|
timeout,
|
||||||
IsInterval::Interval,
|
IsInterval::Interval,
|
||||||
TimerSource::FromWindow(self.page.id.clone()),
|
TimerSource::FromWindow(self.id.clone()),
|
||||||
self.script_chan.clone())
|
self.script_chan.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,10 +392,34 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait WindowHelpers {
|
pub trait WindowHelpers {
|
||||||
fn flush_layout(self, goal: ReflowGoal, query: ReflowQueryType);
|
fn clear_js_context(self);
|
||||||
|
fn clear_js_context_for_script_deallocation(self);
|
||||||
fn init_browser_context(self, doc: JSRef<Document>, frame_element: Option<JSRef<Element>>);
|
fn init_browser_context(self, doc: JSRef<Document>, frame_element: Option<JSRef<Element>>);
|
||||||
fn load_url(self, href: DOMString);
|
fn load_url(self, href: DOMString);
|
||||||
fn handle_fire_timer(self, timer_id: TimerId);
|
fn handle_fire_timer(self, timer_id: TimerId);
|
||||||
|
fn reflow(self, goal: ReflowGoal, query_type: ReflowQueryType);
|
||||||
|
fn join_layout(self);
|
||||||
|
fn layout(&self) -> &LayoutRPC;
|
||||||
|
fn content_box_query(self, content_box_request: TrustedNodeAddress) -> Rect<Au>;
|
||||||
|
fn content_boxes_query(self, content_boxes_request: TrustedNodeAddress) -> Vec<Rect<Au>>;
|
||||||
|
fn handle_reflow_complete_msg(self, reflow_id: uint);
|
||||||
|
fn handle_resize_inactive_msg(self, new_size: WindowSizeData);
|
||||||
|
fn set_fragment_name(self, fragment: Option<String>);
|
||||||
|
fn steal_fragment_name(self) -> Option<String>;
|
||||||
|
fn set_window_size(self, size: WindowSizeData);
|
||||||
|
fn window_size(self) -> WindowSizeData;
|
||||||
|
fn get_url(self) -> Url;
|
||||||
|
fn resource_task(self) -> ResourceTask;
|
||||||
|
fn devtools_chan(self) -> Option<DevtoolsControlChan>;
|
||||||
|
fn layout_chan(self) -> LayoutChan;
|
||||||
|
fn constellation_chan(self) -> ConstellationChan;
|
||||||
|
fn windowproxy_handler(self) -> WindowProxyHandler;
|
||||||
|
fn get_next_subpage_id(self) -> SubpageId;
|
||||||
|
fn layout_is_idle(self) -> bool;
|
||||||
|
fn set_resize_event(self, event: WindowSizeData);
|
||||||
|
fn steal_resize_event(self) -> Option<WindowSizeData>;
|
||||||
|
fn set_page_clip_rect_with_new_viewport(self, viewport: Rect<f32>) -> bool;
|
||||||
|
fn set_devtools_wants_updates(self, value: bool);
|
||||||
fn IndexedGetter(self, _index: u32, _found: &mut bool) -> Option<Temporary<Window>>;
|
fn IndexedGetter(self, _index: u32, _found: &mut bool) -> Option<Temporary<Window>>;
|
||||||
fn thaw(self);
|
fn thaw(self);
|
||||||
fn freeze(self);
|
fn freeze(self);
|
||||||
|
@ -373,8 +459,131 @@ impl<'a, T: Reflectable> ScriptHelpers for JSRef<'a, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WindowHelpers for JSRef<'a, Window> {
|
impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
fn flush_layout(self, goal: ReflowGoal, query: ReflowQueryType) {
|
fn clear_js_context(self) {
|
||||||
self.page().flush_layout(goal, query);
|
let document = self.Document().root();
|
||||||
|
NodeCast::from_ref(document.r()).teardown();
|
||||||
|
|
||||||
|
*self.js_context.borrow_mut() = None;
|
||||||
|
*self.browser_context.borrow_mut() = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unsafe_blocks)]
|
||||||
|
fn clear_js_context_for_script_deallocation(self) {
|
||||||
|
unsafe {
|
||||||
|
*self.js_context.borrow_for_script_deallocation() = None;
|
||||||
|
*self.browser_context.borrow_for_script_deallocation() = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reflows the page if it's possible to do so and the page is dirty. This method will wait
|
||||||
|
/// for the layout thread to complete (but see the `TODO` below). If there is no window size
|
||||||
|
/// yet, the page is presumed invisible and no reflow is performed.
|
||||||
|
///
|
||||||
|
/// TODO(pcwalton): Only wait for style recalc, since we have off-main-thread layout.
|
||||||
|
fn reflow(self, goal: ReflowGoal, query_type: ReflowQueryType) {
|
||||||
|
let document = self.Document().root();
|
||||||
|
let root = document.r().GetDocumentElement().root();
|
||||||
|
let root = match root.r() {
|
||||||
|
Some(root) => root,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
debug!("script: performing reflow for goal {:?}", goal);
|
||||||
|
|
||||||
|
let root: JSRef<Node> = NodeCast::from_ref(root);
|
||||||
|
if !root.get_has_dirty_descendants() {
|
||||||
|
debug!("root has no dirty descendants; avoiding reflow");
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("script: performing reflow for goal {:?}", goal);
|
||||||
|
|
||||||
|
// Layout will let us know when it's done.
|
||||||
|
let (join_chan, join_port) = channel();
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
||||||
|
*layout_join_port = Some(join_port);
|
||||||
|
}
|
||||||
|
|
||||||
|
let last_reflow_id = &self.last_reflow_id;
|
||||||
|
last_reflow_id.set(last_reflow_id.get() + 1);
|
||||||
|
|
||||||
|
let window_size = self.window_size.get();
|
||||||
|
|
||||||
|
// Send new document and relevant styles to layout.
|
||||||
|
let reflow = box Reflow {
|
||||||
|
document_root: root.to_trusted_node_address(),
|
||||||
|
url: self.get_url(),
|
||||||
|
iframe: self.subpage_id.is_some(),
|
||||||
|
goal: goal,
|
||||||
|
window_size: window_size,
|
||||||
|
script_chan: self.control_chan.clone(),
|
||||||
|
script_join_chan: join_chan,
|
||||||
|
id: last_reflow_id.get(),
|
||||||
|
query_type: query_type,
|
||||||
|
page_clip_rect: self.page_clip_rect.get(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let LayoutChan(ref chan) = self.layout_chan;
|
||||||
|
chan.send(Msg::Reflow(reflow)).unwrap();
|
||||||
|
|
||||||
|
debug!("script: layout forked");
|
||||||
|
|
||||||
|
self.join_layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME(cgaebel): join_layout is racey. What if the compositor triggers a
|
||||||
|
// reflow between the "join complete" message and returning from this
|
||||||
|
// function?
|
||||||
|
|
||||||
|
/// Sends a ping to layout and waits for the response. The response will arrive when the
|
||||||
|
/// layout task has finished any pending request messages.
|
||||||
|
fn join_layout(self) {
|
||||||
|
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
||||||
|
if let Some(join_port) = mem::replace(&mut *layout_join_port, None) {
|
||||||
|
match join_port.try_recv() {
|
||||||
|
Err(Empty) => {
|
||||||
|
info!("script: waiting on layout");
|
||||||
|
join_port.recv().unwrap();
|
||||||
|
}
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(Disconnected) => {
|
||||||
|
panic!("Layout task failed while script was waiting for a result.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("script: layout joined")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn layout(&self) -> &LayoutRPC {
|
||||||
|
&*self.layout_rpc
|
||||||
|
}
|
||||||
|
|
||||||
|
fn content_box_query(self, content_box_request: TrustedNodeAddress) -> Rect<Au> {
|
||||||
|
self.reflow(ReflowGoal::ForScriptQuery, ReflowQueryType::ContentBoxQuery(content_box_request));
|
||||||
|
self.join_layout(); //FIXME: is this necessary, or is layout_rpc's mutex good enough?
|
||||||
|
let ContentBoxResponse(rect) = self.layout_rpc.content_box();
|
||||||
|
rect
|
||||||
|
}
|
||||||
|
|
||||||
|
fn content_boxes_query(self, content_boxes_request: TrustedNodeAddress) -> Vec<Rect<Au>> {
|
||||||
|
self.reflow(ReflowGoal::ForScriptQuery, ReflowQueryType::ContentBoxesQuery(content_boxes_request));
|
||||||
|
self.join_layout(); //FIXME: is this necessary, or is layout_rpc's mutex good enough?
|
||||||
|
let ContentBoxesResponse(rects) = self.layout_rpc.content_boxes();
|
||||||
|
rects
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_reflow_complete_msg(self, reflow_id: uint) {
|
||||||
|
let last_reflow_id = self.last_reflow_id.get();
|
||||||
|
if last_reflow_id == reflow_id {
|
||||||
|
*self.layout_join_port.borrow_mut() = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_resize_inactive_msg(self, new_size: WindowSizeData) {
|
||||||
|
self.window_size.set(new_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_browser_context(self, doc: JSRef<Document>, frame_element: Option<JSRef<Element>>) {
|
fn init_browser_context(self, doc: JSRef<Document>, frame_element: Option<JSRef<Element>>) {
|
||||||
|
@ -383,26 +592,117 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
|
|
||||||
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
||||||
fn load_url(self, href: DOMString) {
|
fn load_url(self, href: DOMString) {
|
||||||
let base_url = self.page().get_url();
|
let base_url = self.get_url();
|
||||||
debug!("current page url is {}", base_url);
|
debug!("current page url is {}", base_url);
|
||||||
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
|
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
|
||||||
// FIXME: handle URL parse errors more gracefully.
|
// FIXME: handle URL parse errors more gracefully.
|
||||||
let url = url.unwrap();
|
let url = url.unwrap();
|
||||||
match url.fragment {
|
match url.fragment {
|
||||||
Some(fragment) => {
|
Some(fragment) => {
|
||||||
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment)).unwrap();
|
self.script_chan.send(ScriptMsg::TriggerFragment(self.id, fragment)).unwrap();
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url))).unwrap();
|
self.script_chan.send(ScriptMsg::TriggerLoad(self.id, LoadData::new(url))).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_fire_timer(self, timer_id: TimerId) {
|
fn handle_fire_timer(self, timer_id: TimerId) {
|
||||||
self.timers.fire_timer(timer_id, self);
|
self.timers.fire_timer(timer_id, self);
|
||||||
self.flush_layout(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery);
|
self.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_fragment_name(self, fragment: Option<String>) {
|
||||||
|
*self.fragment_name.borrow_mut() = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn steal_fragment_name(self) -> Option<String> {
|
||||||
|
self.fragment_name.borrow_mut().take()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_window_size(self, size: WindowSizeData) {
|
||||||
|
self.window_size.set(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn window_size(self) -> WindowSizeData {
|
||||||
|
self.window_size.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_url(self) -> Url {
|
||||||
|
let doc = self.Document().root();
|
||||||
|
doc.r().url()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resource_task(self) -> ResourceTask {
|
||||||
|
self.resource_task.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn devtools_chan(self) -> Option<DevtoolsControlChan> {
|
||||||
|
self.devtools_chan.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn layout_chan(self) -> LayoutChan {
|
||||||
|
self.layout_chan.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn constellation_chan(self) -> ConstellationChan {
|
||||||
|
self.constellation_chan.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn windowproxy_handler(self) -> WindowProxyHandler {
|
||||||
|
WindowProxyHandler(self.dom_static.windowproxy_handler.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_next_subpage_id(self) -> SubpageId {
|
||||||
|
let subpage_id = self.next_subpage_id.get();
|
||||||
|
let SubpageId(id_num) = subpage_id;
|
||||||
|
self.next_subpage_id.set(SubpageId(id_num + 1));
|
||||||
|
subpage_id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn layout_is_idle(self) -> bool {
|
||||||
|
self.layout_join_port.borrow().is_none()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_resize_event(self, event: WindowSizeData) {
|
||||||
|
self.resize_event.set(Some(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn steal_resize_event(self) -> Option<WindowSizeData> {
|
||||||
|
let event = self.resize_event.get();
|
||||||
|
self.resize_event.set(None);
|
||||||
|
event
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_page_clip_rect_with_new_viewport(self, viewport: Rect<f32>) -> bool {
|
||||||
|
// We use a clipping rectangle that is five times the size of the of the viewport,
|
||||||
|
// so that we don't collect display list items for areas too far outside the viewport,
|
||||||
|
// but also don't trigger reflows every time the viewport changes.
|
||||||
|
static VIEWPORT_EXPANSION: f32 = 2.0; // 2 lengths on each side plus original length is 5 total.
|
||||||
|
let proposed_clip_rect = geometry::f32_rect_to_au_rect(
|
||||||
|
viewport.inflate(viewport.size.width * VIEWPORT_EXPANSION,
|
||||||
|
viewport.size.height * VIEWPORT_EXPANSION));
|
||||||
|
let clip_rect = self.page_clip_rect.get();
|
||||||
|
if proposed_clip_rect == clip_rect {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let had_clip_rect = clip_rect != MAX_RECT;
|
||||||
|
if had_clip_rect && !should_move_clip_rect(clip_rect, viewport) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.page_clip_rect.set(proposed_clip_rect);
|
||||||
|
|
||||||
|
// If we didn't have a clip rect, the previous display doesn't need rebuilding
|
||||||
|
// because it was built for infinite clip (MAX_RECT).
|
||||||
|
had_clip_rect
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_devtools_wants_updates(self, value: bool) {
|
||||||
|
self.devtools_wants_updates.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/browsers.html#accessing-other-browsing-contexts
|
// https://html.spec.whatwg.org/multipage/browsers.html#accessing-other-browsing-contexts
|
||||||
fn IndexedGetter(self, _index: u32, _found: &mut bool) -> Option<Temporary<Window>> {
|
fn IndexedGetter(self, _index: u32, _found: &mut bool) -> Option<Temporary<Window>> {
|
||||||
None
|
None
|
||||||
|
@ -419,13 +719,28 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn new(cx: *mut JSContext,
|
pub fn new(js_context: Rc<Cx>,
|
||||||
page: Rc<Page>,
|
page: Rc<Page>,
|
||||||
script_chan: Box<ScriptChan+Send>,
|
script_chan: Box<ScriptChan+Send>,
|
||||||
control_chan: ScriptControlChan,
|
control_chan: ScriptControlChan,
|
||||||
compositor: Box<ScriptListener+'static>,
|
compositor: Box<ScriptListener+'static>,
|
||||||
image_cache_task: ImageCacheTask)
|
image_cache_task: ImageCacheTask,
|
||||||
|
resource_task: ResourceTask,
|
||||||
|
storage_task: StorageTask,
|
||||||
|
devtools_chan: Option<DevtoolsControlChan>,
|
||||||
|
constellation_chan: ConstellationChan,
|
||||||
|
layout_chan: LayoutChan,
|
||||||
|
id: PipelineId,
|
||||||
|
subpage_id: Option<SubpageId>,
|
||||||
|
window_size: WindowSizeData)
|
||||||
-> Temporary<Window> {
|
-> Temporary<Window> {
|
||||||
|
let layout_rpc: Box<LayoutRPC> = {
|
||||||
|
let (rpc_send, rpc_recv) = channel();
|
||||||
|
let LayoutChan(ref lchan) = layout_chan;
|
||||||
|
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
|
||||||
|
rpc_recv.recv().unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let win = box Window {
|
let win = box Window {
|
||||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Window),
|
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Window),
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
|
@ -435,6 +750,7 @@ impl Window {
|
||||||
page: page,
|
page: page,
|
||||||
navigator: Default::default(),
|
navigator: Default::default(),
|
||||||
image_cache_task: image_cache_task,
|
image_cache_task: image_cache_task,
|
||||||
|
devtools_chan: devtools_chan,
|
||||||
browser_context: DOMRefCell::new(None),
|
browser_context: DOMRefCell::new(None),
|
||||||
performance: Default::default(),
|
performance: Default::default(),
|
||||||
navigation_start: time::get_time().sec as u64,
|
navigation_start: time::get_time().sec as u64,
|
||||||
|
@ -442,8 +758,43 @@ impl Window {
|
||||||
screen: Default::default(),
|
screen: Default::default(),
|
||||||
session_storage: Default::default(),
|
session_storage: Default::default(),
|
||||||
timers: TimerManager::new(),
|
timers: TimerManager::new(),
|
||||||
|
id: id,
|
||||||
|
subpage_id: subpage_id,
|
||||||
|
dom_static: GlobalStaticData::new(),
|
||||||
|
js_context: DOMRefCell::new(Some(js_context.clone())),
|
||||||
|
resource_task: resource_task,
|
||||||
|
storage_task: storage_task,
|
||||||
|
constellation_chan: constellation_chan,
|
||||||
|
page_clip_rect: Cell::new(MAX_RECT),
|
||||||
|
fragment_name: DOMRefCell::new(None),
|
||||||
|
last_reflow_id: Cell::new(0),
|
||||||
|
resize_event: Cell::new(None),
|
||||||
|
next_subpage_id: Cell::new(SubpageId(0)),
|
||||||
|
layout_chan: layout_chan,
|
||||||
|
layout_rpc: layout_rpc,
|
||||||
|
layout_join_port: DOMRefCell::new(None),
|
||||||
|
window_size: Cell::new(window_size),
|
||||||
|
devtools_wants_updates: Cell::new(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
WindowBinding::Wrap(cx, win)
|
WindowBinding::Wrap(js_context.ptr, win)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool{
|
||||||
|
let clip_rect = Rect(Point2D(geometry::to_frac_px(clip_rect.origin.x) as f32,
|
||||||
|
geometry::to_frac_px(clip_rect.origin.y) as f32),
|
||||||
|
Size2D(geometry::to_frac_px(clip_rect.size.width) as f32,
|
||||||
|
geometry::to_frac_px(clip_rect.size.height) as f32));
|
||||||
|
|
||||||
|
// We only need to move the clip rect if the viewport is getting near the edge of
|
||||||
|
// our preexisting clip rect. We use half of the size of the viewport as a heuristic
|
||||||
|
// for "close."
|
||||||
|
static VIEWPORT_SCROLL_MARGIN_SIZE: f32 = 0.5;
|
||||||
|
let viewport_scroll_margin = new_viewport.size * VIEWPORT_SCROLL_MARGIN_SIZE;
|
||||||
|
|
||||||
|
(clip_rect.origin.x - new_viewport.origin.x).abs() <= viewport_scroll_margin.width ||
|
||||||
|
(clip_rect.max_x() - new_viewport.max_x()).abs() <= viewport_scroll_margin.width ||
|
||||||
|
(clip_rect.origin.y - new_viewport.origin.y).abs() <= viewport_scroll_margin.height ||
|
||||||
|
(clip_rect.max_y() - new_viewport.max_y()).abs() <= viewport_scroll_margin.height
|
||||||
|
}
|
||||||
|
|
|
@ -3,107 +3,39 @@
|
||||||
* 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 dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use dom::bindings::js::{JS, Temporary, Unrooted};
|
||||||
use dom::bindings::codegen::InheritTypes::NodeCast;
|
|
||||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable};
|
|
||||||
use dom::bindings::utils::GlobalStaticData;
|
|
||||||
use dom::document::{Document, DocumentHelpers};
|
use dom::document::{Document, DocumentHelpers};
|
||||||
use dom::element::Element;
|
use dom::node::NodeHelpers;
|
||||||
use dom::node::{Node, NodeHelpers};
|
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use devtools_traits::DevtoolsControlChan;
|
|
||||||
use layout_interface::{
|
|
||||||
ContentBoxResponse, ContentBoxesResponse,
|
|
||||||
HitTestResponse, LayoutChan, LayoutRPC, MouseOverResponse, Msg, Reflow,
|
|
||||||
ReflowGoal, ReflowQueryType,
|
|
||||||
TrustedNodeAddress
|
|
||||||
};
|
|
||||||
use script_traits::{UntrustedNodeAddress, ScriptControlChan};
|
|
||||||
|
|
||||||
use geom::{Point2D, Rect, Size2D};
|
|
||||||
use js::rust::Cx;
|
|
||||||
use msg::compositor_msg::ScriptListener;
|
|
||||||
use msg::constellation_msg::{ConstellationChan, WindowSizeData};
|
|
||||||
use msg::constellation_msg::{PipelineId, SubpageId};
|
use msg::constellation_msg::{PipelineId, SubpageId};
|
||||||
use net::resource_task::ResourceTask;
|
|
||||||
use net::storage_task::StorageTask;
|
|
||||||
use util::geometry::{Au, MAX_RECT};
|
|
||||||
use util::geometry;
|
|
||||||
use util::str::DOMString;
|
|
||||||
use util::smallvec::SmallVec;
|
use util::smallvec::SmallVec;
|
||||||
use std::cell::{Cell, Ref, RefMut};
|
use std::cell::Cell;
|
||||||
use std::sync::mpsc::{channel, Receiver};
|
|
||||||
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
|
|
||||||
use std::mem::replace;
|
|
||||||
use std::num::Float;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
/// Encapsulates a handle to a frame and its associated layout information.
|
/// Encapsulates a handle to a frame in a frame tree.
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
/// Pipeline id associated with this page.
|
/// Pipeline id associated with this page.
|
||||||
pub id: PipelineId,
|
id: PipelineId,
|
||||||
|
|
||||||
/// Subpage id associated with this page, if any.
|
/// Subpage id associated with this page, if any.
|
||||||
pub subpage_id: Option<SubpageId>,
|
subpage_id: Option<SubpageId>,
|
||||||
|
|
||||||
/// Unique id for last reflow request; used for confirming completion reply.
|
/// The outermost frame containing the document and window.
|
||||||
pub last_reflow_id: Cell<uint>,
|
frame: DOMRefCell<Option<Frame>>,
|
||||||
|
|
||||||
/// The outermost frame containing the document, window, and page URL.
|
/// Cached copy of the most recent url loaded by the script, after all redirections.
|
||||||
pub frame: DOMRefCell<Option<Frame>>,
|
|
||||||
|
|
||||||
/// A handle for communicating messages to the layout task.
|
|
||||||
pub layout_chan: LayoutChan,
|
|
||||||
|
|
||||||
/// A handle to perform RPC calls into the layout, quickly.
|
|
||||||
layout_rpc: Box<LayoutRPC+'static>,
|
|
||||||
|
|
||||||
/// The port that we will use to join layout. If this is `None`, then layout is not running.
|
|
||||||
pub layout_join_port: DOMRefCell<Option<Receiver<()>>>,
|
|
||||||
|
|
||||||
/// The current size of the window, in pixels.
|
|
||||||
pub window_size: Cell<WindowSizeData>,
|
|
||||||
|
|
||||||
js_info: DOMRefCell<Option<JSPageInfo>>,
|
|
||||||
|
|
||||||
/// Cached copy of the most recent url loaded by the script
|
|
||||||
/// TODO(tkuehn): this currently does not follow any particular caching policy
|
/// TODO(tkuehn): this currently does not follow any particular caching policy
|
||||||
/// and simply caches pages forever (!). The bool indicates if reflow is required
|
/// and simply caches pages forever (!).
|
||||||
/// when reloading.
|
url: Url,
|
||||||
url: DOMRefCell<Option<(Url, bool)>>,
|
|
||||||
|
|
||||||
next_subpage_id: Cell<SubpageId>,
|
/// Indicates if reflow is required when reloading.
|
||||||
|
needs_reflow: Cell<bool>,
|
||||||
/// Pending resize event, if any.
|
|
||||||
pub resize_event: Cell<Option<WindowSizeData>>,
|
|
||||||
|
|
||||||
/// Pending scroll to fragment event, if any
|
|
||||||
pub fragment_name: DOMRefCell<Option<String>>,
|
|
||||||
|
|
||||||
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
|
||||||
pub resource_task: ResourceTask,
|
|
||||||
|
|
||||||
/// A handle for communicating messages to the storage task.
|
|
||||||
pub storage_task: StorageTask,
|
|
||||||
|
|
||||||
/// A handle for communicating messages to the constellation task.
|
|
||||||
pub constellation_chan: ConstellationChan,
|
|
||||||
|
|
||||||
// Child Pages.
|
// Child Pages.
|
||||||
pub children: DOMRefCell<Vec<Rc<Page>>>,
|
pub children: DOMRefCell<Vec<Rc<Page>>>,
|
||||||
|
|
||||||
/// An enlarged rectangle around the page contents visible in the viewport, used
|
|
||||||
/// to prevent creating display list items for content that is far away from the viewport.
|
|
||||||
pub page_clip_rect: Cell<Rect<Au>>,
|
|
||||||
|
|
||||||
/// A flag to indicate whether the developer tools have requested live updates of
|
|
||||||
/// page changes.
|
|
||||||
pub devtools_wants_updates: Cell<bool>,
|
|
||||||
|
|
||||||
/// For providing instructions to an optional devtools server.
|
|
||||||
pub devtools_chan: Option<DevtoolsControlChan>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PageIterator {
|
pub struct PageIterator {
|
||||||
|
@ -133,70 +65,27 @@ impl IterablePage for Rc<Page> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
pub fn new(id: PipelineId, subpage_id: Option<SubpageId>,
|
pub fn new(id: PipelineId, subpage_id: Option<SubpageId>, url: Url) -> Page {
|
||||||
layout_chan: LayoutChan,
|
|
||||||
window_size: WindowSizeData,
|
|
||||||
resource_task: ResourceTask,
|
|
||||||
storage_task: StorageTask,
|
|
||||||
constellation_chan: ConstellationChan,
|
|
||||||
js_context: Rc<Cx>,
|
|
||||||
devtools_chan: Option<DevtoolsControlChan>) -> Page {
|
|
||||||
let js_info = JSPageInfo {
|
|
||||||
dom_static: GlobalStaticData::new(),
|
|
||||||
js_context: js_context,
|
|
||||||
};
|
|
||||||
let layout_rpc: Box<LayoutRPC> = {
|
|
||||||
let (rpc_send, rpc_recv) = channel();
|
|
||||||
let LayoutChan(ref lchan) = layout_chan;
|
|
||||||
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
|
|
||||||
rpc_recv.recv().unwrap()
|
|
||||||
};
|
|
||||||
Page {
|
Page {
|
||||||
id: id,
|
id: id,
|
||||||
subpage_id: subpage_id,
|
subpage_id: subpage_id,
|
||||||
frame: DOMRefCell::new(None),
|
frame: DOMRefCell::new(None),
|
||||||
layout_chan: layout_chan,
|
url: url,
|
||||||
layout_rpc: layout_rpc,
|
needs_reflow: Cell::new(true),
|
||||||
layout_join_port: DOMRefCell::new(None),
|
|
||||||
window_size: Cell::new(window_size),
|
|
||||||
js_info: DOMRefCell::new(Some(js_info)),
|
|
||||||
url: DOMRefCell::new(None),
|
|
||||||
next_subpage_id: Cell::new(SubpageId(0)),
|
|
||||||
resize_event: Cell::new(None),
|
|
||||||
fragment_name: DOMRefCell::new(None),
|
|
||||||
last_reflow_id: Cell::new(0),
|
|
||||||
resource_task: resource_task,
|
|
||||||
storage_task: storage_task,
|
|
||||||
constellation_chan: constellation_chan,
|
|
||||||
children: DOMRefCell::new(vec!()),
|
children: DOMRefCell::new(vec!()),
|
||||||
page_clip_rect: Cell::new(MAX_RECT),
|
|
||||||
devtools_wants_updates: Cell::new(false),
|
|
||||||
devtools_chan: devtools_chan,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush_layout(&self, goal: ReflowGoal, query: ReflowQueryType) {
|
pub fn window(&self) -> Temporary<Window> {
|
||||||
let frame = self.frame();
|
Temporary::new(self.frame.borrow().as_ref().unwrap().window.clone())
|
||||||
let window = frame.as_ref().unwrap().window.root();
|
|
||||||
self.reflow(goal, window.r().control_chan().clone(), &mut **window.r().compositor(), query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout(&self) -> &LayoutRPC {
|
pub fn window_for_script_dealloation(&self) -> Unrooted<Window> {
|
||||||
&*self.layout_rpc
|
Unrooted::from_js(self.frame.borrow().as_ref().unwrap().window)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn content_box_query(&self, content_box_request: TrustedNodeAddress) -> Rect<Au> {
|
pub fn document(&self) -> Temporary<Document> {
|
||||||
self.flush_layout(ReflowGoal::ForScriptQuery, ReflowQueryType::ContentBoxQuery(content_box_request));
|
Temporary::new(self.frame.borrow().as_ref().unwrap().document.clone())
|
||||||
self.join_layout(); //FIXME: is this necessary, or is layout_rpc's mutex good enough?
|
|
||||||
let ContentBoxResponse(rect) = self.layout_rpc.content_box();
|
|
||||||
rect
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn content_boxes_query(&self, content_boxes_request: TrustedNodeAddress) -> Vec<Rect<Au>> {
|
|
||||||
self.flush_layout(ReflowGoal::ForScriptQuery, ReflowQueryType::ContentBoxesQuery(content_boxes_request));
|
|
||||||
self.join_layout(); //FIXME: is this necessary, or is layout_rpc's mutex good enough?
|
|
||||||
let ContentBoxesResponse(rects) = self.layout_rpc.content_boxes();
|
|
||||||
rects
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// must handle root case separately
|
// must handle root case separately
|
||||||
|
@ -218,49 +107,6 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_page_clip_rect_with_new_viewport(&self, viewport: Rect<f32>) -> bool {
|
|
||||||
// We use a clipping rectangle that is five times the size of the of the viewport,
|
|
||||||
// so that we don't collect display list items for areas too far outside the viewport,
|
|
||||||
// but also don't trigger reflows every time the viewport changes.
|
|
||||||
static VIEWPORT_EXPANSION: f32 = 2.0; // 2 lengths on each side plus original length is 5 total.
|
|
||||||
let proposed_clip_rect = geometry::f32_rect_to_au_rect(
|
|
||||||
viewport.inflate(viewport.size.width * VIEWPORT_EXPANSION,
|
|
||||||
viewport.size.height * VIEWPORT_EXPANSION));
|
|
||||||
let clip_rect = self.page_clip_rect.get();
|
|
||||||
if proposed_clip_rect == clip_rect {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let had_clip_rect = clip_rect != MAX_RECT;
|
|
||||||
if had_clip_rect && !should_move_clip_rect(clip_rect, viewport) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.page_clip_rect.set(proposed_clip_rect);
|
|
||||||
|
|
||||||
// If we didn't have a clip rect, the previous display doesn't need rebuilding
|
|
||||||
// because it was built for infinite clip (MAX_RECT).
|
|
||||||
had_clip_rect
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_title_to_compositor(&self) {
|
|
||||||
match *self.frame() {
|
|
||||||
None => {}
|
|
||||||
Some(ref frame) => {
|
|
||||||
let window = frame.window.root();
|
|
||||||
let document = frame.document.root();
|
|
||||||
window.r().compositor().set_title(self.id, Some(document.r().Title()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dirty_all_nodes(&self) {
|
|
||||||
match *self.frame.borrow() {
|
|
||||||
None => {}
|
|
||||||
Some(ref frame) => frame.document.root().r().dirty_all_nodes(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for PageIterator {
|
impl Iterator for PageIterator {
|
||||||
|
@ -280,198 +126,15 @@ impl Iterator for PageIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
pub fn mut_js_info<'a>(&'a self) -> RefMut<'a, Option<JSPageInfo>> {
|
pub fn set_reflow_status(&self, status: bool) -> bool {
|
||||||
self.js_info.borrow_mut()
|
let old = self.needs_reflow.get();
|
||||||
|
self.needs_reflow.set(status);
|
||||||
|
old
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn unsafe_mut_js_info<'a>(&'a self) -> &'a mut Option<JSPageInfo> {
|
pub fn set_frame(&self, frame: Option<Frame>) {
|
||||||
self.js_info.borrow_for_script_deallocation()
|
*self.frame.borrow_mut() = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn js_info<'a>(&'a self) -> Ref<'a, Option<JSPageInfo>> {
|
|
||||||
self.js_info.borrow()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn url<'a>(&'a self) -> Ref<'a, Option<(Url, bool)>> {
|
|
||||||
self.url.borrow()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn mut_url<'a>(&'a self) -> RefMut<'a, Option<(Url, bool)>> {
|
|
||||||
self.url.borrow_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn frame<'a>(&'a self) -> Ref<'a, Option<Frame>> {
|
|
||||||
self.frame.borrow()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn mut_frame<'a>(&'a self) -> RefMut<'a, Option<Frame>> {
|
|
||||||
self.frame.borrow_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_next_subpage_id(&self) -> SubpageId {
|
|
||||||
let subpage_id = self.next_subpage_id.get();
|
|
||||||
let SubpageId(id_num) = subpage_id;
|
|
||||||
self.next_subpage_id.set(SubpageId(id_num + 1));
|
|
||||||
subpage_id
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_url(&self) -> Url {
|
|
||||||
self.url().as_ref().unwrap().0.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME(cgaebel): join_layout is racey. What if the compositor triggers a
|
|
||||||
// reflow between the "join complete" message and returning from this
|
|
||||||
// function?
|
|
||||||
|
|
||||||
/// Sends a ping to layout and waits for the response. The response will arrive when the
|
|
||||||
/// layout task has finished any pending request messages.
|
|
||||||
fn join_layout(&self) {
|
|
||||||
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
|
||||||
if let Some(join_port) = replace(&mut *layout_join_port, None) {
|
|
||||||
match join_port.try_recv() {
|
|
||||||
Err(Empty) => {
|
|
||||||
info!("script: waiting on layout");
|
|
||||||
join_port.recv().unwrap();
|
|
||||||
}
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(Disconnected) => {
|
|
||||||
panic!("Layout task failed while script was waiting for a result.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("script: layout joined")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reflows the page if it's possible to do so and the page is dirty. This method will wait
|
|
||||||
/// for the layout thread to complete (but see the `TODO` below). If there is no window size
|
|
||||||
/// yet, the page is presumed invisible and no reflow is performed.
|
|
||||||
///
|
|
||||||
/// TODO(pcwalton): Only wait for style recalc, since we have off-main-thread layout.
|
|
||||||
pub fn reflow(&self,
|
|
||||||
goal: ReflowGoal,
|
|
||||||
script_chan: ScriptControlChan,
|
|
||||||
_: &mut ScriptListener,
|
|
||||||
query_type: ReflowQueryType) {
|
|
||||||
let root = match *self.frame() {
|
|
||||||
None => return,
|
|
||||||
Some(ref frame) => {
|
|
||||||
frame.document.root().r().GetDocumentElement()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let root = match root.root() {
|
|
||||||
None => return,
|
|
||||||
Some(root) => root,
|
|
||||||
};
|
|
||||||
|
|
||||||
debug!("script: performing reflow for goal {:?}", goal);
|
|
||||||
|
|
||||||
let root: JSRef<Node> = NodeCast::from_ref(root.r());
|
|
||||||
if !root.get_has_dirty_descendants() {
|
|
||||||
debug!("root has no dirty descendants; avoiding reflow");
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("script: performing reflow for goal {:?}", goal);
|
|
||||||
|
|
||||||
// Layout will let us know when it's done.
|
|
||||||
let (join_chan, join_port) = channel();
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
|
||||||
*layout_join_port = Some(join_port);
|
|
||||||
}
|
|
||||||
|
|
||||||
let last_reflow_id = &self.last_reflow_id;
|
|
||||||
last_reflow_id.set(last_reflow_id.get() + 1);
|
|
||||||
|
|
||||||
let window_size = self.window_size.get();
|
|
||||||
|
|
||||||
// Send new document and relevant styles to layout.
|
|
||||||
let reflow = box Reflow {
|
|
||||||
document_root: root.to_trusted_node_address(),
|
|
||||||
url: self.get_url(),
|
|
||||||
iframe: self.subpage_id.is_some(),
|
|
||||||
goal: goal,
|
|
||||||
window_size: window_size,
|
|
||||||
script_chan: script_chan,
|
|
||||||
script_join_chan: join_chan,
|
|
||||||
id: last_reflow_id.get(),
|
|
||||||
query_type: query_type,
|
|
||||||
page_clip_rect: self.page_clip_rect.get(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let LayoutChan(ref chan) = self.layout_chan;
|
|
||||||
chan.send(Msg::Reflow(reflow)).unwrap();
|
|
||||||
|
|
||||||
debug!("script: layout forked");
|
|
||||||
|
|
||||||
self.join_layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Attempt to find a named element in this page's document.
|
|
||||||
pub fn find_fragment_node(&self, fragid: DOMString) -> Option<Temporary<Element>> {
|
|
||||||
let document = self.frame().as_ref().unwrap().document.root();
|
|
||||||
document.r().find_fragment_node(fragid)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn hit_test(&self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress> {
|
|
||||||
let frame = self.frame();
|
|
||||||
let document = frame.as_ref().unwrap().document.root();
|
|
||||||
let root = match document.r().GetDocumentElement().root() {
|
|
||||||
None => return None,
|
|
||||||
Some(root) => root,
|
|
||||||
};
|
|
||||||
let root: JSRef<Node> = NodeCast::from_ref(root.r());
|
|
||||||
let address = match self.layout().hit_test(root.to_trusted_node_address(), *point) {
|
|
||||||
Ok(HitTestResponse(node_address)) => {
|
|
||||||
Some(node_address)
|
|
||||||
}
|
|
||||||
Err(()) => {
|
|
||||||
debug!("layout query error");
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
address
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_nodes_under_mouse(&self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress> {
|
|
||||||
let mut results = vec!();
|
|
||||||
let frame = self.frame();
|
|
||||||
let document = frame.as_ref().unwrap().document.root();
|
|
||||||
match document.r().GetDocumentElement().root() {
|
|
||||||
Some(root) => {
|
|
||||||
let root: JSRef<Node> = NodeCast::from_ref(root.r());
|
|
||||||
match self.layout().mouse_over(root.to_trusted_node_address(), *point) {
|
|
||||||
Ok(MouseOverResponse(node_addresses)) => {
|
|
||||||
results = node_addresses;
|
|
||||||
}
|
|
||||||
Err(()) => {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
results
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool{
|
|
||||||
let clip_rect = Rect(Point2D(geometry::to_frac_px(clip_rect.origin.x) as f32,
|
|
||||||
geometry::to_frac_px(clip_rect.origin.y) as f32),
|
|
||||||
Size2D(geometry::to_frac_px(clip_rect.size.width) as f32,
|
|
||||||
geometry::to_frac_px(clip_rect.size.height) as f32));
|
|
||||||
|
|
||||||
// We only need to move the clip rect if the viewport is getting near the edge of
|
|
||||||
// our preexisting clip rect. We use half of the size of the viewport as a heuristic
|
|
||||||
// for "close."
|
|
||||||
static VIEWPORT_SCROLL_MARGIN_SIZE: f32 = 0.5;
|
|
||||||
let viewport_scroll_margin = new_viewport.size * VIEWPORT_SCROLL_MARGIN_SIZE;
|
|
||||||
|
|
||||||
(clip_rect.origin.x - new_viewport.origin.x).abs() <= viewport_scroll_margin.width ||
|
|
||||||
(clip_rect.max_x() - new_viewport.max_x()).abs() <= viewport_scroll_margin.width ||
|
|
||||||
(clip_rect.origin.y - new_viewport.origin.y).abs() <= viewport_scroll_margin.height ||
|
|
||||||
(clip_rect.max_y() - new_viewport.max_y()).abs() <= viewport_scroll_margin.height
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information for one frame in the browsing context.
|
/// Information for one frame in the browsing context.
|
||||||
|
@ -483,12 +146,3 @@ pub struct Frame {
|
||||||
/// The window object for this frame.
|
/// The window object for this frame.
|
||||||
pub window: JS<Window>,
|
pub window: JS<Window>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encapsulation of the javascript information associated with each frame.
|
|
||||||
#[jstraceable]
|
|
||||||
pub struct JSPageInfo {
|
|
||||||
/// Global static data related to the DOM.
|
|
||||||
pub dom_static: GlobalStaticData,
|
|
||||||
/// The JavaScript context.
|
|
||||||
pub js_context: Rc<Cx>,
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,12 +48,13 @@ pub struct NewLayoutInfo {
|
||||||
pub new_pipeline_id: PipelineId,
|
pub new_pipeline_id: PipelineId,
|
||||||
pub subpage_id: SubpageId,
|
pub subpage_id: SubpageId,
|
||||||
pub layout_chan: Box<Any+Send>, // opaque reference to a LayoutChannel
|
pub layout_chan: Box<Any+Send>, // opaque reference to a LayoutChannel
|
||||||
|
pub load_data: LoadData,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Messages sent from the constellation to the script task
|
/// Messages sent from the constellation to the script task
|
||||||
pub enum ConstellationControlMsg {
|
pub enum ConstellationControlMsg {
|
||||||
/// Loads a new URL on the specified pipeline.
|
/// Reactivate an existing pipeline.
|
||||||
Load(PipelineId, Option<(PipelineId, SubpageId)>, LoadData),
|
Activate(PipelineId),
|
||||||
/// Gives a channel and ID to a layout task, as well as the ID of that layout's parent
|
/// Gives a channel and ID to a layout task, as well as the ID of that layout's parent
|
||||||
AttachLayout(NewLayoutInfo),
|
AttachLayout(NewLayoutInfo),
|
||||||
/// Window resized. Sends a DOM event eventually, but first we combine events.
|
/// Window resized. Sends a DOM event eventually, but first we combine events.
|
||||||
|
@ -111,7 +112,8 @@ pub trait ScriptTaskFactory {
|
||||||
storage_task: StorageTask,
|
storage_task: StorageTask,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
devtools_chan: Option<DevtoolsControlChan>,
|
devtools_chan: Option<DevtoolsControlChan>,
|
||||||
window_size: WindowSizeData)
|
window_size: WindowSizeData,
|
||||||
|
load_data: LoadData)
|
||||||
where C: ScriptListener + Send;
|
where C: ScriptListener + Send;
|
||||||
fn create_layout_channel(_phantom: Option<&mut Self>) -> OpaqueScriptLayoutChannel;
|
fn create_layout_channel(_phantom: Option<&mut Self>) -> OpaqueScriptLayoutChannel;
|
||||||
fn clone_layout_channel(_phantom: Option<&mut Self>, pair: &OpaqueScriptLayoutChannel)
|
fn clone_layout_channel(_phantom: Option<&mut Self>, pair: &OpaqueScriptLayoutChannel)
|
||||||
|
|
1
components/servo/Cargo.lock
generated
1
components/servo/Cargo.lock
generated
|
@ -389,6 +389,7 @@ dependencies = [
|
||||||
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"time 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -676,8 +676,77 @@ pub mod longhands {
|
||||||
|
|
||||||
|
|
||||||
// CSS 2.1, Section 11 - Visual effects
|
// CSS 2.1, Section 11 - Visual effects
|
||||||
// FIXME: Implement scrolling for `scroll` and `auto` (#2742).
|
|
||||||
${single_keyword("overflow", "visible hidden scroll auto")}
|
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
|
||||||
|
<%self:single_keyword_computed name="overflow-x" values="visible hidden scroll auto">
|
||||||
|
use values::computed::{Context, ToComputedValue};
|
||||||
|
|
||||||
|
pub fn compute_with_other_overflow_direction(value: SpecifiedValue,
|
||||||
|
other_direction: SpecifiedValue)
|
||||||
|
-> computed_value::T {
|
||||||
|
// CSS-OVERFLOW 3 states "Otherwise, if one cascaded values is one of the scrolling
|
||||||
|
// values and the other is `visible`, then computed values are the cascaded values with
|
||||||
|
// `visible` changed to `auto`."
|
||||||
|
match (value, other_direction) {
|
||||||
|
(SpecifiedValue::visible, SpecifiedValue::hidden) |
|
||||||
|
(SpecifiedValue::visible, SpecifiedValue::scroll) |
|
||||||
|
(SpecifiedValue::visible, SpecifiedValue::auto) => computed_value::T::auto,
|
||||||
|
_ => value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
type ComputedValue = computed_value::T;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
||||||
|
compute_with_other_overflow_direction(*self, context.overflow_y.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%self:single_keyword_computed>
|
||||||
|
|
||||||
|
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
|
||||||
|
<%self:longhand name="overflow-y">
|
||||||
|
use super::overflow_x;
|
||||||
|
use values::computed::{Context, ToComputedValue};
|
||||||
|
|
||||||
|
use cssparser::ToCss;
|
||||||
|
use text_writer::{self, TextWriter};
|
||||||
|
|
||||||
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
|
|
||||||
|
impl ToCss for SpecifiedValue {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
|
self.0.to_css(dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod computed_value {
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub struct T(pub super::super::overflow_x::computed_value::T);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
type ComputedValue = computed_value::T;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
||||||
|
let computed_value::T(this) = *self;
|
||||||
|
computed_value::T(overflow_x::compute_with_other_overflow_direction(
|
||||||
|
this,
|
||||||
|
context.overflow_x))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
|
computed_value::T(overflow_x::get_initial_value())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||||
|
overflow_x::parse(context, input).map(|value| SpecifiedValue(value))
|
||||||
|
}
|
||||||
|
</%self:longhand>
|
||||||
|
|
||||||
|
|
||||||
${switch_to_style_struct("InheritedBox")}
|
${switch_to_style_struct("InheritedBox")}
|
||||||
|
|
||||||
|
@ -1004,6 +1073,126 @@ pub mod longhands {
|
||||||
|
|
||||||
${single_keyword("background-attachment", "scroll fixed")}
|
${single_keyword("background-attachment", "scroll fixed")}
|
||||||
|
|
||||||
|
<%self:longhand name="background-size">
|
||||||
|
use cssparser::{ToCss, Token};
|
||||||
|
use std::ascii::AsciiExt;
|
||||||
|
use text_writer::{self, TextWriter};
|
||||||
|
use values::computed::{Context, ToComputedValue};
|
||||||
|
|
||||||
|
pub mod computed_value {
|
||||||
|
use values::computed::LengthOrPercentageOrAuto;
|
||||||
|
|
||||||
|
#[derive(PartialEq, Clone, Debug)]
|
||||||
|
pub struct ExplicitSize {
|
||||||
|
pub width: LengthOrPercentageOrAuto,
|
||||||
|
pub height: LengthOrPercentageOrAuto,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Clone, Debug)]
|
||||||
|
pub enum T {
|
||||||
|
Explicit(ExplicitSize),
|
||||||
|
Cover,
|
||||||
|
Contain,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
|
pub struct SpecifiedExplicitSize {
|
||||||
|
pub width: specified::LengthOrPercentageOrAuto,
|
||||||
|
pub height: specified::LengthOrPercentageOrAuto,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for SpecifiedExplicitSize {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
|
try!(self.width.to_css(dest));
|
||||||
|
try!(dest.write_str(" "));
|
||||||
|
self.height.to_css(dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
|
pub enum SpecifiedValue {
|
||||||
|
Explicit(SpecifiedExplicitSize),
|
||||||
|
Cover,
|
||||||
|
Contain,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for SpecifiedValue {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
|
match *self {
|
||||||
|
SpecifiedValue::Explicit(ref size) => size.to_css(dest),
|
||||||
|
SpecifiedValue::Cover => dest.write_str("cover"),
|
||||||
|
SpecifiedValue::Contain => dest.write_str("contain"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
type ComputedValue = computed_value::T;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, context: &computed::Context) -> computed_value::T {
|
||||||
|
match *self {
|
||||||
|
SpecifiedValue::Explicit(ref size) => {
|
||||||
|
computed_value::T::Explicit(computed_value::ExplicitSize {
|
||||||
|
width: size.width.to_computed_value(context),
|
||||||
|
height: size.height.to_computed_value(context),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
SpecifiedValue::Cover => computed_value::T::Cover,
|
||||||
|
SpecifiedValue::Contain => computed_value::T::Contain,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
|
computed_value::T::Explicit(computed_value::ExplicitSize {
|
||||||
|
width: computed::LengthOrPercentageOrAuto::Auto,
|
||||||
|
height: computed::LengthOrPercentageOrAuto::Auto,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||||
|
let width;
|
||||||
|
if let Ok(value) = input.try(|input| {
|
||||||
|
match input.next() {
|
||||||
|
Err(_) => Err(()),
|
||||||
|
Ok(Token::Ident(ref ident)) if ident.as_slice()
|
||||||
|
.eq_ignore_ascii_case("cover") => {
|
||||||
|
Ok(SpecifiedValue::Cover)
|
||||||
|
}
|
||||||
|
Ok(Token::Ident(ref ident)) if ident.as_slice()
|
||||||
|
.eq_ignore_ascii_case("contain") => {
|
||||||
|
Ok(SpecifiedValue::Contain)
|
||||||
|
}
|
||||||
|
Ok(_) => Err(()),
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
return Ok(value)
|
||||||
|
} else {
|
||||||
|
width = try!(specified::LengthOrPercentageOrAuto::parse(input))
|
||||||
|
}
|
||||||
|
|
||||||
|
let height;
|
||||||
|
if let Ok(value) = input.try(|input| {
|
||||||
|
match input.next() {
|
||||||
|
Err(_) => Ok(specified::LengthOrPercentageOrAuto::Auto),
|
||||||
|
Ok(_) => Err(()),
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
height = value
|
||||||
|
} else {
|
||||||
|
height = try!(specified::LengthOrPercentageOrAuto::parse(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(SpecifiedValue::Explicit(SpecifiedExplicitSize {
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
</%self:longhand>
|
||||||
|
|
||||||
${new_style_struct("Color", is_inherited=True)}
|
${new_style_struct("Color", is_inherited=True)}
|
||||||
|
|
||||||
<%self:raw_longhand name="color">
|
<%self:raw_longhand name="color">
|
||||||
|
@ -2346,6 +2535,62 @@ pub mod longhands {
|
||||||
"""normal multiply screen overlay darken lighten color-dodge
|
"""normal multiply screen overlay darken lighten color-dodge
|
||||||
color-burn hard-light soft-light difference exclusion hue
|
color-burn hard-light soft-light difference exclusion hue
|
||||||
saturation color luminosity""")}
|
saturation color luminosity""")}
|
||||||
|
|
||||||
|
<%self:longhand name="image-rendering">
|
||||||
|
use values::computed::{Context, ToComputedValue};
|
||||||
|
|
||||||
|
pub mod computed_value {
|
||||||
|
use cssparser::ToCss;
|
||||||
|
use text_writer::{self, TextWriter};
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
pub enum T {
|
||||||
|
Auto,
|
||||||
|
CrispEdges,
|
||||||
|
Pixelated,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for T {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
|
match *self {
|
||||||
|
T::Auto => dest.write_str("auto"),
|
||||||
|
T::CrispEdges => dest.write_str("crisp-edges"),
|
||||||
|
T::Pixelated => dest.write_str("pixelated"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type SpecifiedValue = computed_value::T;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
|
computed_value::T::Auto
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||||
|
// According to to CSS-IMAGES-3, `optimizespeed` and `optimizequality` are synonyms for
|
||||||
|
// `auto`.
|
||||||
|
match_ignore_ascii_case! {
|
||||||
|
try!(input.expect_ident()),
|
||||||
|
"auto" => Ok(computed_value::T::Auto),
|
||||||
|
"optimizespeed" => Ok(computed_value::T::Auto),
|
||||||
|
"optimizequality" => Ok(computed_value::T::Auto),
|
||||||
|
"crisp-edges" => Ok(computed_value::T::CrispEdges),
|
||||||
|
"pixelated" => Ok(computed_value::T::Pixelated)
|
||||||
|
_ => Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
type ComputedValue = computed_value::T;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, _: &Context) -> computed_value::T {
|
||||||
|
*self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%self:longhand>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2438,14 +2683,15 @@ pub mod shorthands {
|
||||||
|
|
||||||
// TODO: other background-* properties
|
// TODO: other background-* properties
|
||||||
<%self:shorthand name="background"
|
<%self:shorthand name="background"
|
||||||
sub_properties="background-color background-position background-repeat background-attachment background-image">
|
sub_properties="background-color background-position background-repeat background-attachment background-image background-size">
|
||||||
use properties::longhands::{background_color, background_position, background_repeat,
|
use properties::longhands::{background_color, background_position, background_repeat};
|
||||||
background_attachment, background_image};
|
use properties::longhands::{background_attachment, background_image, background_size};
|
||||||
|
|
||||||
let mut color = None;
|
let mut color = None;
|
||||||
let mut image = None;
|
let mut image = None;
|
||||||
let mut position = None;
|
let mut position = None;
|
||||||
let mut repeat = None;
|
let mut repeat = None;
|
||||||
|
let mut size = None;
|
||||||
let mut attachment = None;
|
let mut attachment = None;
|
||||||
let mut any = false;
|
let mut any = false;
|
||||||
|
|
||||||
|
@ -2454,6 +2700,13 @@ pub mod shorthands {
|
||||||
if let Ok(value) = input.try(|input| background_position::parse(context, input)) {
|
if let Ok(value) = input.try(|input| background_position::parse(context, input)) {
|
||||||
position = Some(value);
|
position = Some(value);
|
||||||
any = true;
|
any = true;
|
||||||
|
|
||||||
|
// Parse background size, if applicable.
|
||||||
|
size = input.try(|input| {
|
||||||
|
try!(input.expect_delim('/'));
|
||||||
|
background_size::parse(context, input)
|
||||||
|
}).ok();
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2495,6 +2748,7 @@ pub mod shorthands {
|
||||||
background_position: position,
|
background_position: position,
|
||||||
background_repeat: repeat,
|
background_repeat: repeat,
|
||||||
background_attachment: attachment,
|
background_attachment: attachment,
|
||||||
|
background_size: size,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
@ -2830,6 +3084,16 @@ pub mod shorthands {
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
</%self:shorthand>
|
</%self:shorthand>
|
||||||
|
|
||||||
|
<%self:shorthand name="overflow" sub_properties="overflow-x overflow-y">
|
||||||
|
use properties::longhands::{overflow_x, overflow_y};
|
||||||
|
|
||||||
|
let overflow = try!(overflow_x::parse(context, input));
|
||||||
|
Ok(Longhands {
|
||||||
|
overflow_x: Some(overflow),
|
||||||
|
overflow_y: Some(overflow_y::SpecifiedValue(overflow)),
|
||||||
|
})
|
||||||
|
</%self:shorthand>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3474,6 +3738,8 @@ pub fn cascade(applicable_declarations: &[DeclarationBlock<Vec<PropertyDeclarati
|
||||||
display: longhands::display::get_initial_value(),
|
display: longhands::display::get_initial_value(),
|
||||||
color: inherited_style.get_color().color,
|
color: inherited_style.get_color().color,
|
||||||
text_decoration: longhands::text_decoration::get_initial_value(),
|
text_decoration: longhands::text_decoration::get_initial_value(),
|
||||||
|
overflow_x: longhands::overflow_x::get_initial_value(),
|
||||||
|
overflow_y: longhands::overflow_y::get_initial_value(),
|
||||||
positioned: false,
|
positioned: false,
|
||||||
floated: false,
|
floated: false,
|
||||||
border_top_present: false,
|
border_top_present: false,
|
||||||
|
@ -3528,6 +3794,12 @@ pub fn cascade(applicable_declarations: &[DeclarationBlock<Vec<PropertyDeclarati
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PropertyDeclaration::OverflowX(ref value) => {
|
||||||
|
context.overflow_x = get_specified!(get_box, overflow_x, value);
|
||||||
|
}
|
||||||
|
PropertyDeclaration::OverflowY(ref value) => {
|
||||||
|
context.overflow_y = get_specified!(get_box, overflow_y, value);
|
||||||
|
}
|
||||||
PropertyDeclaration::Float(ref value) => {
|
PropertyDeclaration::Float(ref value) => {
|
||||||
context.floated = get_specified!(get_box, float, value)
|
context.floated = get_specified!(get_box, float, value)
|
||||||
!= longhands::float::SpecifiedValue::none;
|
!= longhands::float::SpecifiedValue::none;
|
||||||
|
|
|
@ -435,6 +435,7 @@ fn test_parse_stylesheet() {
|
||||||
],
|
],
|
||||||
declarations: PropertyDeclarationBlock {
|
declarations: PropertyDeclarationBlock {
|
||||||
normal: Arc::new(vec![
|
normal: Arc::new(vec![
|
||||||
|
PropertyDeclaration::BackgroundSize(DeclaredValue::Initial),
|
||||||
PropertyDeclaration::BackgroundImage(DeclaredValue::Initial),
|
PropertyDeclaration::BackgroundImage(DeclaredValue::Initial),
|
||||||
PropertyDeclaration::BackgroundAttachment(DeclaredValue::Initial),
|
PropertyDeclaration::BackgroundAttachment(DeclaredValue::Initial),
|
||||||
PropertyDeclaration::BackgroundRepeat(DeclaredValue::Initial),
|
PropertyDeclaration::BackgroundRepeat(DeclaredValue::Initial),
|
||||||
|
|
|
@ -690,6 +690,8 @@ pub mod computed {
|
||||||
pub font_size: longhands::font_size::computed_value::T,
|
pub font_size: longhands::font_size::computed_value::T,
|
||||||
pub root_font_size: longhands::font_size::computed_value::T,
|
pub root_font_size: longhands::font_size::computed_value::T,
|
||||||
pub display: longhands::display::computed_value::T,
|
pub display: longhands::display::computed_value::T,
|
||||||
|
pub overflow_x: longhands::overflow_x::computed_value::T,
|
||||||
|
pub overflow_y: longhands::overflow_y::computed_value::T,
|
||||||
pub positioned: bool,
|
pub positioned: bool,
|
||||||
pub floated: bool,
|
pub floated: bool,
|
||||||
pub border_top_present: bool,
|
pub border_top_present: bool,
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
use libc::{c_char,c_int,c_void,size_t};
|
use libc::{c_char,c_int,c_void,size_t};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
use std::iter::AdditiveIterator;
|
use std::iter::AdditiveIterator;
|
||||||
use std::old_io::timer::sleep;
|
use std::old_io::timer::sleep;
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
|
|
1
ports/cef/Cargo.lock
generated
1
ports/cef/Cargo.lock
generated
|
@ -392,6 +392,7 @@ dependencies = [
|
||||||
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"time 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"url 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use layers::platform::surface::NativeGraphicsMetadata;
|
||||||
use libc::{c_char, c_void};
|
use libc::{c_char, c_void};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyModifiers};
|
||||||
use msg::compositor_msg::{ReadyState, PaintState};
|
use msg::compositor_msg::{ReadyState, PaintState};
|
||||||
use msg::constellation_msg::LoadData;
|
use std_url::Url;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::ScreenPx;
|
use util::geometry::ScreenPx;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -286,7 +286,7 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_page_load_data(&self, load_data: LoadData) {
|
fn set_page_url(&self, url: Url) {
|
||||||
let browser = self.cef_browser.borrow();
|
let browser = self.cef_browser.borrow();
|
||||||
let browser = match *browser {
|
let browser = match *browser {
|
||||||
None => return,
|
None => return,
|
||||||
|
@ -294,7 +294,7 @@ impl WindowMethods for Window {
|
||||||
};
|
};
|
||||||
let frame = browser.get_main_frame();
|
let frame = browser.get_main_frame();
|
||||||
let frame = frame.downcast();
|
let frame = frame.downcast();
|
||||||
*frame.url.borrow_mut() = load_data.url.to_string()
|
*frame.url.borrow_mut() = url.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_key(&self, _: Key, _: KeyModifiers) {
|
fn handle_key(&self, _: Key, _: KeyModifiers) {
|
||||||
|
|
|
@ -43,3 +43,4 @@ git = "https://github.com/servo/rust-egl"
|
||||||
time = "0.1.12"
|
time = "0.1.12"
|
||||||
bitflags = "*"
|
bitflags = "*"
|
||||||
libc = "*"
|
libc = "*"
|
||||||
|
url = "*"
|
|
@ -22,6 +22,7 @@ extern crate msg;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
extern crate util;
|
extern crate util;
|
||||||
extern crate egl;
|
extern crate egl;
|
||||||
|
extern crate url;
|
||||||
|
|
||||||
use compositing::windowing::WindowEvent;
|
use compositing::windowing::WindowEvent;
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
|
|
|
@ -15,10 +15,10 @@ use layers::platform::surface::NativeGraphicsMetadata;
|
||||||
use msg::constellation_msg;
|
use msg::constellation_msg;
|
||||||
use msg::constellation_msg::Key;
|
use msg::constellation_msg::Key;
|
||||||
use msg::compositor_msg::{PaintState, ReadyState};
|
use msg::compositor_msg::{PaintState, ReadyState};
|
||||||
use msg::constellation_msg::LoadData;
|
|
||||||
use NestedEventLoopListener;
|
use NestedEventLoopListener;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{channel, Sender};
|
use std::sync::mpsc::{channel, Sender};
|
||||||
|
use url::Url;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::ScreenPx;
|
use util::geometry::ScreenPx;
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ impl WindowMethods for Window {
|
||||||
self.window.set_title(&title);
|
self.window.set_title(&title);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_page_load_data(&self, _: LoadData) {
|
fn set_page_url(&self, _: Url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_end(&self) {
|
fn load_end(&self) {
|
||||||
|
@ -657,7 +657,7 @@ impl WindowMethods for Window {
|
||||||
fn set_page_title(&self, _: Option<String>) {
|
fn set_page_title(&self, _: Option<String>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_page_load_data(&self, _: LoadData) {
|
fn set_page_url(&self, _: Url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_end(&self) {
|
fn load_end(&self) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern crate msg;
|
||||||
extern crate gleam;
|
extern crate gleam;
|
||||||
extern crate layers;
|
extern crate layers;
|
||||||
extern crate egl;
|
extern crate egl;
|
||||||
|
extern crate url;
|
||||||
|
|
||||||
use util::opts;
|
use util::opts;
|
||||||
use servo::Browser;
|
use servo::Browser;
|
||||||
|
|
|
@ -13,7 +13,6 @@ use layers::platform::surface::NativeGraphicsMetadata;
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use msg::compositor_msg::{ReadyState, PaintState};
|
use msg::compositor_msg::{ReadyState, PaintState};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyModifiers};
|
||||||
use msg::constellation_msg::LoadData;
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -22,6 +21,7 @@ use std::mem::size_of;
|
||||||
use std::mem::zeroed;
|
use std::mem::zeroed;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
use url::Url;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::ScreenPx;
|
use util::geometry::ScreenPx;
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
|
@ -804,7 +804,7 @@ impl WindowMethods for Window {
|
||||||
fn set_page_title(&self, _: Option<String>) {
|
fn set_page_title(&self, _: Option<String>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_page_load_data(&self, _: LoadData) {
|
fn set_page_url(&self, _: Url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_end(&self) {
|
fn load_end(&self) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ class CommandBase(object):
|
||||||
if self.context.bootstrapped:
|
if self.context.bootstrapped:
|
||||||
return
|
return
|
||||||
|
|
||||||
subprocess.check_call(["git", "submodule", "sync"])
|
subprocess.check_call(["git", "submodule", "--quiet", "sync", "--recursive"])
|
||||||
submodules = subprocess.check_output(["git", "submodule", "status"])
|
submodules = subprocess.check_output(["git", "submodule", "status"])
|
||||||
for line in submodules.split('\n'):
|
for line in submodules.split('\n'):
|
||||||
components = line.strip().split(' ')
|
components = line.strip().split(' ')
|
||||||
|
|
BIN
tests/ref/2x4.png
Normal file
BIN
tests/ref/2x4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 171 B |
BIN
tests/ref/4x2.png
Normal file
BIN
tests/ref/4x2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 180 B |
BIN
tests/ref/background_size.png
Normal file
BIN
tests/ref/background_size.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 510 B |
62
tests/ref/background_size_a.html
Normal file
62
tests/ref/background_size_a.html
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
section {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
#tall {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
#wide {
|
||||||
|
left: 40px;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
image-rendering: -moz-crisp-edges; /* for comparison with Firefox */
|
||||||
|
image-rendering: pixelated;
|
||||||
|
}
|
||||||
|
#tall div {
|
||||||
|
background-image: url(2x4.png);
|
||||||
|
}
|
||||||
|
#wide div {
|
||||||
|
background-image: url(4x2.png);
|
||||||
|
}
|
||||||
|
.a {
|
||||||
|
background-size: 40px 20px;
|
||||||
|
}
|
||||||
|
.b {
|
||||||
|
background-size: 40px 40px;
|
||||||
|
}
|
||||||
|
.c {
|
||||||
|
background-size: 40px;
|
||||||
|
}
|
||||||
|
.d {
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
.e {
|
||||||
|
background-size: contain;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section id=tall>
|
||||||
|
<div class=a></div>
|
||||||
|
<div class=b></div>
|
||||||
|
<div class=c></div>
|
||||||
|
<div class=d></div>
|
||||||
|
<div class=e></div>
|
||||||
|
</section>
|
||||||
|
<section id=wide>
|
||||||
|
<div class=a></div>
|
||||||
|
<div class=b></div>
|
||||||
|
<div class=c></div>
|
||||||
|
<div class=d></div>
|
||||||
|
<div class=e></div>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
19
tests/ref/background_size_ref.html
Normal file
19
tests/ref/background_size_ref.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
img {
|
||||||
|
image-rendering: -moz-crisp-edges; /* for comparison with Firefox */
|
||||||
|
image-rendering: pixelated;
|
||||||
|
}
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<img src=background_size.png>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
28
tests/ref/background_size_shorthand_a.html
Normal file
28
tests/ref/background_size_shorthand_a.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Tests that the `background-size` shorthand works. -->
|
||||||
|
<style>
|
||||||
|
section {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
border: solid black 1px;
|
||||||
|
}
|
||||||
|
#a {
|
||||||
|
background: 10px 10px / 80px 80px url(rust_logo.png) no-repeat;
|
||||||
|
}
|
||||||
|
#b {
|
||||||
|
background: url(rust_logo.png) 10px 10px / 80px 80px no-repeat;
|
||||||
|
}
|
||||||
|
#c {
|
||||||
|
background: no-repeat url(rust_logo.png) 10px 10px / 80px 80px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section id=a> </section>
|
||||||
|
<section id=b> </section>
|
||||||
|
<section id=c> </section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
23
tests/ref/background_size_shorthand_ref.html
Normal file
23
tests/ref/background_size_shorthand_ref.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Tests that the `background-size` shorthand works. -->
|
||||||
|
<style>
|
||||||
|
section {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
border: solid black 1px;
|
||||||
|
background-image: url(rust_logo.png);
|
||||||
|
background-position: 10px 10px;
|
||||||
|
background-size: 80px 80px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section> </section>
|
||||||
|
<section> </section>
|
||||||
|
<section> </section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
@ -139,6 +139,8 @@ fragment=top != ../html/acid2.html acid2_ref.html
|
||||||
== iframe/overflow.html iframe/overflow_ref.html
|
== iframe/overflow.html iframe/overflow_ref.html
|
||||||
== iframe/positioning_margin.html iframe/positioning_margin_ref.html
|
== iframe/positioning_margin.html iframe/positioning_margin_ref.html
|
||||||
== iframe/hide_and_show.html iframe/hide_and_show_ref.html
|
== iframe/hide_and_show.html iframe/hide_and_show_ref.html
|
||||||
|
== iframe/hide_layers1.html iframe/hide_layers_ref.html
|
||||||
|
== iframe/hide_layers2.html iframe/hide_layers_ref.html
|
||||||
|
|
||||||
== floated_generated_content_a.html floated_generated_content_b.html
|
== floated_generated_content_a.html floated_generated_content_b.html
|
||||||
== inline_block_margin_a.html inline_block_margin_ref.html
|
== inline_block_margin_a.html inline_block_margin_ref.html
|
||||||
|
@ -146,6 +148,7 @@ fragment=top != ../html/acid2.html acid2_ref.html
|
||||||
== inline_block_baseline_a.html inline_block_baseline_ref.html
|
== inline_block_baseline_a.html inline_block_baseline_ref.html
|
||||||
== inline_block_parent_width.html inline_block_parent_width_ref.html
|
== inline_block_parent_width.html inline_block_parent_width_ref.html
|
||||||
== inline_block_parent_width_percentage.html inline_block_parent_width_ref.html
|
== inline_block_parent_width_percentage.html inline_block_parent_width_ref.html
|
||||||
|
== inline_block_overflow.html inline_block_overflow_ref.html
|
||||||
== float_table_a.html float_table_ref.html
|
== float_table_a.html float_table_ref.html
|
||||||
== table_containing_block_a.html table_containing_block_ref.html
|
== table_containing_block_a.html table_containing_block_ref.html
|
||||||
== link_style_order.html link_style_order_ref.html
|
== link_style_order.html link_style_order_ref.html
|
||||||
|
@ -157,6 +160,7 @@ fragment=top != ../html/acid2.html acid2_ref.html
|
||||||
== img_block_display_a.html img_block_display_ref.html
|
== img_block_display_a.html img_block_display_ref.html
|
||||||
== after_block_iteration.html after_block_iteration_ref.html
|
== after_block_iteration.html after_block_iteration_ref.html
|
||||||
== inline_block_percentage_height_a.html inline_block_percentage_height_ref.html
|
== inline_block_percentage_height_a.html inline_block_percentage_height_ref.html
|
||||||
|
== inline_block_min_width.html inline_block_min_width_ref.html
|
||||||
== percentage_height_float_a.html percentage_height_float_ref.html
|
== percentage_height_float_a.html percentage_height_float_ref.html
|
||||||
== img_block_maxwidth_a.html img_block_maxwidth_ref.html
|
== img_block_maxwidth_a.html img_block_maxwidth_ref.html
|
||||||
== img_block_maxwidth_b.html img_block_maxwidth_ref.html
|
== img_block_maxwidth_b.html img_block_maxwidth_ref.html
|
||||||
|
@ -255,6 +259,11 @@ fragment=top != ../html/acid2.html acid2_ref.html
|
||||||
== canvas_lineto_a.html canvas_lineto_ref.html
|
== canvas_lineto_a.html canvas_lineto_ref.html
|
||||||
!= text_decoration_smoke_a.html text_decoration_smoke_ref.html
|
!= text_decoration_smoke_a.html text_decoration_smoke_ref.html
|
||||||
== hide_after_create.html hide_after_create_ref.html
|
== hide_after_create.html hide_after_create_ref.html
|
||||||
|
== overflow_xy_a.html overflow_xy_ref.html
|
||||||
== text_shadow_simple_a.html text_shadow_simple_ref.html
|
== text_shadow_simple_a.html text_shadow_simple_ref.html
|
||||||
== text_shadow_decorations_a.html text_shadow_decorations_ref.html
|
== text_shadow_decorations_a.html text_shadow_decorations_ref.html
|
||||||
== text_shadow_blur_a.html text_shadow_blur_ref.html
|
== text_shadow_blur_a.html text_shadow_blur_ref.html
|
||||||
|
!= image_rendering_auto_a.html image_rendering_pixelated_a.html
|
||||||
|
== image_rendering_pixelated_a.html image_rendering_pixelated_ref.html
|
||||||
|
== background_size_a.html background_size_ref.html
|
||||||
|
== background_size_shorthand_a.html background_size_shorthand_ref.html
|
||||||
|
|
20
tests/ref/iframe/hide_layers1.html
Normal file
20
tests/ref/iframe/hide_layers1.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<style type="text/css">
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<iframe id="iframe" src="data:text/html,%3Cspan%3EJust%20a%20simple%20little%20iframe.%3C%2Fspan%3E"></iframe>
|
||||||
|
</body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.onload = function() {
|
||||||
|
document.getElementById("iframe").classList.add("hidden");
|
||||||
|
document.documentElement.classList.remove("reftest-wait");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</html>
|
18
tests/ref/iframe/hide_layers2.html
Normal file
18
tests/ref/iframe/hide_layers2.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<iframe id="iframe" src="data:text/html,%3Cspan%3EJust%20a%20simple%20little%20iframe.%3C%2Fspan%3E"></iframe>
|
||||||
|
</body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.onload = function() {
|
||||||
|
var iframe = document.getElementById("iframe");
|
||||||
|
iframe.parentNode.removeChild(iframe);
|
||||||
|
document.documentElement.classList.remove("reftest-wait");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</html>
|
10
tests/ref/iframe/hide_layers_ref.html
Normal file
10
tests/ref/iframe/hide_layers_ref.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
11
tests/ref/image_rendering_auto_a.html
Normal file
11
tests/ref/image_rendering_auto_a.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Tests that `image-rendering: auto` uses bilinear filtering. -->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<img width=100 height=50 src=4x2.png>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
20
tests/ref/image_rendering_pixelated_a.html
Normal file
20
tests/ref/image_rendering_pixelated_a.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Tests that `image-rendering: pixelated` causes nearest-neighbor interpolation to be used. -->
|
||||||
|
<style>
|
||||||
|
img {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
image-rendering: -moz-crisp-edges; /* for testing in Firefox */
|
||||||
|
image-rendering: pixelated;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<img width=100 height=50 src=4x2.png>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
40
tests/ref/image_rendering_pixelated_ref.html
Normal file
40
tests/ref/image_rendering_pixelated_ref.html
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Tests that `image-rendering: pixelated` causes nearest-neighbor interpolation to be used. -->
|
||||||
|
<style>
|
||||||
|
section {
|
||||||
|
position: absolute;
|
||||||
|
width: 50px;
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
#a, #d {
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
#b, #c {
|
||||||
|
background: blue;
|
||||||
|
}
|
||||||
|
#a, #b {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
#c, #d {
|
||||||
|
top: 25px;
|
||||||
|
}
|
||||||
|
#a, #c {
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
#b, #d {
|
||||||
|
left: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section id=a></section>
|
||||||
|
<section id=b></section>
|
||||||
|
<section id=c></section>
|
||||||
|
<section id=d></section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
26
tests/ref/inline_block_min_width.html
Normal file
26
tests/ref/inline_block_min_width.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 200px;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
.red {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
.green {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="red"></div><div class="green"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
25
tests/ref/inline_block_min_width_ref.html
Normal file
25
tests/ref/inline_block_min_width_ref.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
display: inline-block;
|
||||||
|
width: 200px;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
.red {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
.green {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="red"></div><div class="green"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
6
tests/ref/inline_block_overflow.html
Normal file
6
tests/ref/inline_block_overflow.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
a<span style="display: inline-block; overflow: hidden">b</span>
|
||||||
|
</body>
|
||||||
|
</html>
|
6
tests/ref/inline_block_overflow_ref.html
Normal file
6
tests/ref/inline_block_overflow_ref.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
ab
|
||||||
|
</body>
|
||||||
|
</html>
|
36
tests/ref/overflow_xy_a.html
Normal file
36
tests/ref/overflow_xy_a.html
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Tests that `overflow-x` and `overflow-y` work. -->
|
||||||
|
<style>
|
||||||
|
section {
|
||||||
|
position: absolute;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
#x {
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: visible; /* computes to `auto` */
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
#y {
|
||||||
|
overflow: hidden;
|
||||||
|
top: 200px;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
position: absolute;
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background: green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section id=x><div></div></section>
|
||||||
|
<section id=y><div></div></section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
29
tests/ref/overflow_xy_ref.html
Normal file
29
tests/ref/overflow_xy_ref.html
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- Tests that `overflow-x` and `overflow-y` work. -->
|
||||||
|
<style>
|
||||||
|
section {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
background: green;
|
||||||
|
}
|
||||||
|
#x {
|
||||||
|
top: 0;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
#y {
|
||||||
|
top: 200px;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section id=x></section>
|
||||||
|
<section id=y></section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ struct Reftest {
|
||||||
name: String,
|
name: String,
|
||||||
kind: ReftestKind,
|
kind: ReftestKind,
|
||||||
files: [Path; 2],
|
files: [Path; 2],
|
||||||
id: uint,
|
id: usize,
|
||||||
servo_args: Vec<String>,
|
servo_args: Vec<String>,
|
||||||
render_mode: RenderMode,
|
render_mode: RenderMode,
|
||||||
is_flaky: bool,
|
is_flaky: bool,
|
||||||
|
@ -145,7 +145,7 @@ struct TestLine<'a> {
|
||||||
file_right: &'a str,
|
file_right: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_lists(file: &Path, servo_args: &[String], render_mode: RenderMode, id_offset: uint) -> Vec<TestDescAndFn> {
|
fn parse_lists(file: &Path, servo_args: &[String], render_mode: RenderMode, id_offset: usize) -> Vec<TestDescAndFn> {
|
||||||
let mut tests = Vec::new();
|
let mut tests = Vec::new();
|
||||||
let contents = File::open_mode(file, io::Open, io::Read)
|
let contents = File::open_mode(file, io::Open, io::Read)
|
||||||
.and_then(|mut f| f.read_to_string())
|
.and_then(|mut f| f.read_to_string())
|
||||||
|
@ -240,7 +240,7 @@ fn make_test(reftest: Reftest) -> TestDescAndFn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capture(reftest: &Reftest, side: uint) -> (u32, u32, Vec<u8>) {
|
fn capture(reftest: &Reftest, side: usize) -> (u32, u32, Vec<u8>) {
|
||||||
let png_filename = format!("/tmp/servo-reftest-{:06}-{}.png", reftest.id, side);
|
let png_filename = format!("/tmp/servo-reftest-{:06}-{}.png", reftest.id, side);
|
||||||
let mut command = Command::new(os::self_exe_path().unwrap().join("servo"));
|
let mut command = Command::new(os::self_exe_path().unwrap().join("servo"));
|
||||||
command
|
command
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[base_multiple.html]
|
[base_multiple.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
|
expected: ERROR
|
||||||
[The attributes of the a element must be affected by the first base element]
|
[The attributes of the a element must be affected by the first base element]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
[move_iframe_in_dom_03.html]
|
||||||
|
type: testharness
|
||||||
|
expected: TIMEOUT
|
Loading…
Add table
Add a link
Reference in a new issue