Constrain the viewport & zoom when reflowing

This commit is contained in:
James Gilbertson 2015-03-24 23:46:47 -06:00
parent 8977316d3e
commit 138596e861
13 changed files with 100 additions and 13 deletions

View file

@ -33,6 +33,7 @@ use std::io::{self, Write};
use std::marker::PhantomData;
use std::mem::replace;
use std::sync::mpsc::{Sender, Receiver, channel};
use style::viewport::ViewportConstraints;
use url::Url;
use util::cursor::Cursor;
use util::geometry::PagePx;
@ -417,6 +418,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.handle_webdriver_command_msg(pipeline_id,
command);
}
ConstellationMsg::ViewportConstrained(pipeline_id, constraints) => {
debug!("constellation got viewport-constrained event message");
self.handle_viewport_constrained_msg(pipeline_id, constraints);
}
}
true
}
@ -912,6 +917,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.window_size = new_size;
}
/// Handle updating actual viewport / zoom due to @viewport rules
fn handle_viewport_constrained_msg(&mut self, pipeline_id: PipelineId, constraints: ViewportConstraints) {
self.compositor_proxy.send(CompositorMsg::ViewportConstrained(pipeline_id, constraints));
}
// Close a frame (and all children)
fn close_frame(&mut self, frame_id: FrameId, exit_mode: ExitPipelineMode) {
let frame = self.frames.remove(&frame_id).unwrap();