mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
add iframe support
This commit is contained in:
parent
93368a2bf3
commit
bd5526de94
8 changed files with 59 additions and 47 deletions
|
@ -82,25 +82,23 @@ impl CompositorLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_frame_tree(frame_tree: SendableFrameTree, tile_size: uint, max_mem: Option<uint>) -> CompositorLayer {
|
pub fn from_frame_tree(frame_tree: SendableFrameTree,
|
||||||
|
tile_size: uint,
|
||||||
|
max_mem: Option<uint>) -> CompositorLayer {
|
||||||
let SendableFrameTree { pipeline, children } = frame_tree;
|
let SendableFrameTree { pipeline, children } = frame_tree;
|
||||||
CompositorLayer {
|
let mut layer = CompositorLayer::new(pipeline, None, tile_size, max_mem);
|
||||||
pipeline: pipeline,
|
layer.children = (do children.consume_iter().transform |child| {
|
||||||
page_size: None,
|
let SendableChildFrameTree { frame_tree, rect } = child;
|
||||||
scroll_offset: Point2D(0f32, 0f32),
|
let container = @mut ContainerLayer();
|
||||||
children: (do children.consume_iter().transform |child| {
|
container.scissor = rect;
|
||||||
let SendableChildFrameTree { frame_tree, rect } = child;
|
CompositorLayerChild {
|
||||||
let container = @mut ContainerLayer();
|
child: ~CompositorLayer::from_frame_tree(frame_tree,
|
||||||
container.scissor = rect;
|
tile_size,
|
||||||
CompositorLayerChild {
|
max_mem),
|
||||||
child: ~CompositorLayer::from_frame_tree(frame_tree, tile_size, max_mem),
|
container: container,
|
||||||
container: container,
|
}
|
||||||
}
|
}).collect();
|
||||||
}).collect(),
|
layer
|
||||||
quadtree: NoTree(tile_size, max_mem),
|
|
||||||
root_layer: @mut ContainerLayer(),
|
|
||||||
hidden: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the layer by as relative specified amount in page coordinates. Does not change
|
// Move the layer by as relative specified amount in page coordinates. Does not change
|
||||||
|
@ -188,7 +186,8 @@ impl CompositorLayer {
|
||||||
let mut redisplay: bool;
|
let mut redisplay: bool;
|
||||||
{ // block here to prevent double mutable borrow of self
|
{ // block here to prevent double mutable borrow of self
|
||||||
let quadtree = match self.quadtree {
|
let quadtree = match self.quadtree {
|
||||||
NoTree(_, _) => fail!("CompositorLayer: cannot get buffer request, no quadtree initialized"),
|
NoTree(_, _) => fail!("CompositorLayer: cannot get buffer request for %?,
|
||||||
|
no quadtree initialized", self.pipeline.id),
|
||||||
Tree(ref mut quadtree) => quadtree,
|
Tree(ref mut quadtree) => quadtree,
|
||||||
};
|
};
|
||||||
let (request, r) = quadtree.get_tile_rects_page(rect, scale);
|
let (request, r) = quadtree.get_tile_rects_page(rect, scale);
|
||||||
|
|
|
@ -402,24 +402,27 @@ impl Constellation {
|
||||||
let mut already_sent = HashSet::new();
|
let mut already_sent = HashSet::new();
|
||||||
|
|
||||||
// If the subframe is in the current frame tree, the compositor needs the new size
|
// If the subframe is in the current frame tree, the compositor needs the new size
|
||||||
let source_frame = self.current_frame().unwrap().find_mut(pipeline_id);
|
for current_frame in self.current_frame().iter() {
|
||||||
for source_frame in source_frame.iter() {
|
debug!("Constellation: Sending size for frame in current frame tree.");
|
||||||
for child_frame_tree in source_frame.children.mut_iter() {
|
let source_frame = current_frame.find_mut(pipeline_id);
|
||||||
let pipeline = &child_frame_tree.frame_tree.pipeline;
|
for source_frame.iter().advance |source_frame| {
|
||||||
if pipeline.subpage_id.expect("Constellation: child frame does not have a
|
for child_frame_tree in source_frame.children.mut_iter() {
|
||||||
subpage id. This should not be possible.") == subpage_id {
|
let pipeline = &child_frame_tree.frame_tree.pipeline;
|
||||||
child_frame_tree.rect = Some(rect.clone());
|
if pipeline.subpage_id.expect("Constellation: child frame does not have a
|
||||||
let Rect { size: Size2D { width, height }, _ } = rect;
|
subpage id. This should not be possible.") == subpage_id {
|
||||||
pipeline.script_chan.send(SendEventMsg(pipeline.id.clone(),
|
child_frame_tree.rect = Some(rect.clone());
|
||||||
ResizeEvent(width as uint,
|
let Rect { size: Size2D { width, height }, _ } = rect;
|
||||||
height as uint)));
|
pipeline.script_chan.send(SendEventMsg(pipeline.id.clone(),
|
||||||
self.compositor_chan.send(ResizeLayer(pipeline.id, rect.size));
|
ResizeEvent(width as uint,
|
||||||
already_sent.insert(pipeline.id.clone());
|
height as uint)));
|
||||||
break;
|
self.compositor_chan.send(ResizeLayer(pipeline.id, rect.size));
|
||||||
|
already_sent.insert(pipeline.id.clone());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Go through the navigation context and tell each associated pipeline to resize.
|
// Traverse the navigation context and pending frames and tell each associated pipeline to resize.
|
||||||
let frame_trees: ~[@mut FrameTree] = {
|
let frame_trees: ~[@mut FrameTree] = {
|
||||||
let matching_navi_frames = self.navigation_context.find_all(pipeline_id);
|
let matching_navi_frames = self.navigation_context.find_all(pipeline_id);
|
||||||
let matching_pending_frames = do self.pending_frames.iter().filter_map |frame_change| {
|
let matching_pending_frames = do self.pending_frames.iter().filter_map |frame_change| {
|
||||||
|
|
|
@ -17,7 +17,7 @@ use geom::point::Point2D;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
use gfx::display_list::DisplayList;
|
use gfx::display_list::DisplayList;
|
||||||
use gfx::geometry::Au;
|
use gfx::geometry::{Au, to_frac_px};
|
||||||
use gfx::geometry;
|
use gfx::geometry;
|
||||||
use servo_util::tree::TreeNodeRef;
|
use servo_util::tree::TreeNodeRef;
|
||||||
|
|
||||||
|
@ -379,8 +379,10 @@ impl BlockFlowData {
|
||||||
box.with_model(|model| model.noncontent_height())
|
box.with_model(|model| model.noncontent_height())
|
||||||
};
|
};
|
||||||
do self.common.node.with_mut_iframe_element |iframe_element| {
|
do self.common.node.with_mut_iframe_element |iframe_element| {
|
||||||
iframe_element.size.get_mut_ref().set_rect(Rect(Point2D(x.to_f32(), y.to_f32()),
|
iframe_element.size.get_mut_ref().set_rect(Rect(Point2D(to_frac_px(x) as f32,
|
||||||
Size2D(w.to_f32(), h.to_f32())));
|
to_frac_px(y) as f32),
|
||||||
|
Size2D(to_frac_px(w) as f32,
|
||||||
|
to_frac_px(h) as f32)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,6 +295,9 @@ impl FloatFlowData {
|
||||||
list: &Cell<DisplayList<E>>)
|
list: &Cell<DisplayList<E>>)
|
||||||
-> bool {
|
-> bool {
|
||||||
|
|
||||||
|
if self.common.node.is_iframe_element() {
|
||||||
|
println("float iframe");
|
||||||
|
}
|
||||||
let abs_rect = Rect(self.common.abs_position, self.common.position.size);
|
let abs_rect = Rect(self.common.abs_position, self.common.position.size);
|
||||||
if !abs_rect.intersects(dirty) {
|
if !abs_rect.intersects(dirty) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -755,6 +755,10 @@ impl InlineFlowData {
|
||||||
list: &Cell<DisplayList<E>>)
|
list: &Cell<DisplayList<E>>)
|
||||||
-> bool {
|
-> bool {
|
||||||
|
|
||||||
|
if self.common.node.is_iframe_element() {
|
||||||
|
println("inline iframe");
|
||||||
|
}
|
||||||
|
|
||||||
let abs_rect = Rect(self.common.abs_position, self.common.position.size);
|
let abs_rect = Rect(self.common.abs_position, self.common.position.size);
|
||||||
if !abs_rect.intersects(dirty) {
|
if !abs_rect.intersects(dirty) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,7 +44,6 @@ use newcss::stylesheet::Stylesheet;
|
||||||
|
|
||||||
use js::jsapi::{JSContext, JSObject};
|
use js::jsapi::{JSContext, JSObject};
|
||||||
|
|
||||||
use std::util::replace;
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::comm;
|
use std::comm;
|
||||||
use std::str::eq_slice;
|
use std::str::eq_slice;
|
||||||
|
|
|
@ -7,26 +7,28 @@ use dom::document::AbstractDocument;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::windowproxy::WindowProxy;
|
use dom::windowproxy::WindowProxy;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
|
use geom::rect::Rect;
|
||||||
|
|
||||||
use servo_msg::constellation_msg::SubpageId;
|
use servo_msg::constellation_msg::{ConstellationChan, FrameRectMsg, PipelineId, SubpageId};
|
||||||
|
|
||||||
use std::comm::ChanOne;
|
use std::comm::ChanOne;
|
||||||
use extra::url::Url;
|
use extra::url::Url;
|
||||||
|
use std::util::replace;
|
||||||
|
|
||||||
pub struct HTMLIFrameElement {
|
pub struct HTMLIFrameElement {
|
||||||
parent: HTMLElement,
|
parent: HTMLElement,
|
||||||
frame: Option<Url>,
|
frame: Option<Url>,
|
||||||
size: Option<IframeSize>,
|
size: Option<IFrameSize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IframeSize {
|
struct IFrameSize {
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
subpage_id: SubpageId,
|
subpage_id: SubpageId,
|
||||||
future_chan: Option<ChanOne<Size2D<uint>>>,
|
future_chan: Option<ChanOne<Size2D<uint>>>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IframeSize {
|
impl IFrameSize {
|
||||||
pub fn set_rect(&mut self, rect: Rect<f32>) {
|
pub fn set_rect(&mut self, rect: Rect<f32>) {
|
||||||
let future_chan = replace(&mut self.future_chan, None);
|
let future_chan = replace(&mut self.future_chan, None);
|
||||||
do future_chan.map_consume |future_chan| {
|
do future_chan.map_consume |future_chan| {
|
||||||
|
|
|
@ -30,7 +30,7 @@ use dom::htmlanchorelement::HTMLAnchorElement;
|
||||||
use dom::htmlbodyelement::HTMLBodyElement;
|
use dom::htmlbodyelement::HTMLBodyElement;
|
||||||
use dom::htmlcanvaselement::HTMLCanvasElement;
|
use dom::htmlcanvaselement::HTMLCanvasElement;
|
||||||
use dom::htmlhrelement::HTMLHRElement;
|
use dom::htmlhrelement::HTMLHRElement;
|
||||||
use dom::htmliframeelement::HTMLIFrameElement;
|
use dom::htmliframeelement::{IFrameSize, HTMLIFrameElement};
|
||||||
use dom::htmlimageelement::HTMLImageElement;
|
use dom::htmlimageelement::HTMLImageElement;
|
||||||
use dom::htmlmetaelement::HTMLMetaElement;
|
use dom::htmlmetaelement::HTMLMetaElement;
|
||||||
use dom::htmlolistelement::HTMLOListElement;
|
use dom::htmlolistelement::HTMLOListElement;
|
||||||
|
@ -253,7 +253,7 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
|
||||||
handle_element!(cx, tag, "ul", HTMLUListElementTypeId, HTMLUListElement, []);
|
handle_element!(cx, tag, "ul", HTMLUListElementTypeId, HTMLUListElement, []);
|
||||||
|
|
||||||
handle_element!(cx, tag, "img", HTMLImageElementTypeId, HTMLImageElement, [(image: None)]);
|
handle_element!(cx, tag, "img", HTMLImageElementTypeId, HTMLImageElement, [(image: None)]);
|
||||||
handle_element!(cx, tag, "iframe", HTMLIframeElementTypeId, HTMLIframeElement, [(frame: None), (size: None)]);
|
handle_element!(cx, tag, "iframe", HTMLIframeElementTypeId, HTMLIFrameElement, [(frame: None), (size: None)]);
|
||||||
|
|
||||||
handle_element!(cx, tag, "h1", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading1)]);
|
handle_element!(cx, tag, "h1", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading1)]);
|
||||||
handle_element!(cx, tag, "h2", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading2)]);
|
handle_element!(cx, tag, "h2", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading2)]);
|
||||||
|
@ -395,7 +395,7 @@ pub fn parse_html(cx: *JSContext,
|
||||||
unsafe { (*page).id }
|
unsafe { (*page).id }
|
||||||
};
|
};
|
||||||
|
|
||||||
iframe_element.size = Some(IframeSize {
|
iframe_element.size = Some(IFrameSize {
|
||||||
pipeline_id: pipeline_id,
|
pipeline_id: pipeline_id,
|
||||||
subpage_id: subpage_id,
|
subpage_id: subpage_id,
|
||||||
future_chan: Some(chan),
|
future_chan: Some(chan),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue