mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
dom: Calculate the viewport size of iframes when they are first added to the tree.
This commit is contained in:
parent
38e4ae0833
commit
fd260f78c8
10 changed files with 72 additions and 11 deletions
|
@ -28,7 +28,6 @@ use crate::dom::windowproxy::WindowProxy;
|
|||
use crate::script_thread::ScriptThread;
|
||||
use crate::task_source::TaskSource;
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::Size2D;
|
||||
use html5ever::{LocalName, Prefix};
|
||||
use ipc_channel::ipc;
|
||||
use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
|
||||
|
@ -173,6 +172,13 @@ impl HTMLIFrameElement {
|
|||
replace: replace,
|
||||
};
|
||||
|
||||
let window_size = WindowSizeData {
|
||||
initial_viewport: window
|
||||
.inner_window_dimensions_query(browsing_context_id)
|
||||
.unwrap_or_default(),
|
||||
device_pixel_ratio: window.device_pixel_ratio(),
|
||||
};
|
||||
|
||||
match nav_type {
|
||||
NavigationType::InitialAboutBlank => {
|
||||
let (pipeline_sender, pipeline_receiver) = ipc::channel().unwrap();
|
||||
|
@ -198,13 +204,7 @@ impl HTMLIFrameElement {
|
|||
opener: None,
|
||||
load_data: load_data,
|
||||
pipeline_port: pipeline_receiver,
|
||||
window_size: WindowSizeData {
|
||||
initial_viewport: {
|
||||
let rect = self.upcast::<Node>().bounding_content_box_or_zero();
|
||||
Size2D::new(rect.size.width.to_f32_px(), rect.size.height.to_f32_px())
|
||||
},
|
||||
device_pixel_ratio: window.device_pixel_ratio(),
|
||||
},
|
||||
window_size,
|
||||
};
|
||||
|
||||
self.pipeline_id.set(Some(new_pipeline_id));
|
||||
|
|
|
@ -89,7 +89,7 @@ use js::jsval::{JSVal, NullValue};
|
|||
use js::rust::wrappers::JS_DefineProperty;
|
||||
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
|
||||
use media::WindowGLContext;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||
use net_traits::image_cache::{ImageCache, ImageResponder, ImageResponse};
|
||||
use net_traits::image_cache::{PendingImageId, PendingImageResponse};
|
||||
use net_traits::storage_thread::StorageType;
|
||||
|
@ -1829,6 +1829,16 @@ impl Window {
|
|||
DOMString::from(resolved)
|
||||
}
|
||||
|
||||
pub fn inner_window_dimensions_query(
|
||||
&self,
|
||||
browsing_context: BrowsingContextId,
|
||||
) -> Option<Size2D<f32, CSSPixel>> {
|
||||
if !self.layout_reflow(QueryMsg::InnerWindowDimensionsQuery(browsing_context)) {
|
||||
return None;
|
||||
}
|
||||
self.layout_rpc.inner_window_dimensions()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn offset_parent_query(&self, node: &Node) -> (Option<DomRoot<Element>>, UntypedRect<Au>) {
|
||||
if !self.layout_reflow(QueryMsg::OffsetParentQuery(node.to_opaque())) {
|
||||
|
@ -2359,6 +2369,7 @@ fn debug_reflow_events(id: PipelineId, reflow_goal: &ReflowGoal, reason: &Reflow
|
|||
&QueryMsg::StyleQuery(_n) => "\tStyleQuery",
|
||||
&QueryMsg::TextIndexQuery(..) => "\tTextIndexQuery",
|
||||
&QueryMsg::ElementInnerTextQuery(_) => "\tElementInnerTextQuery",
|
||||
&QueryMsg::InnerWindowDimensionsQuery(_) => "\tInnerWindowDimensionsQuery",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue