mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Handle <meta name=viewport> elements when added to document
This commit is contained in:
parent
61f7a0a1ee
commit
d0ace58452
6 changed files with 107 additions and 5 deletions
|
@ -78,8 +78,9 @@ use style::media_queries::{Device, MediaQueryList, MediaType};
|
|||
use style::properties::longhands::{display, position};
|
||||
use style::properties::style_structs;
|
||||
use style::selector_matching::Stylist;
|
||||
use style::stylesheets::{CSSRuleIteratorExt, Origin, Stylesheet};
|
||||
use style::stylesheets::{CSSRule, CSSRuleIteratorExt, Origin, Stylesheet};
|
||||
use style::values::AuExtensionMethods;
|
||||
use style::viewport::ViewportRule;
|
||||
use url::Url;
|
||||
use util::geometry::{MAX_RECT, ZERO_POINT};
|
||||
use util::ipc::OptionalIpcSender;
|
||||
|
@ -618,6 +619,9 @@ impl LayoutTask {
|
|||
possibly_locked_rw_data)
|
||||
}
|
||||
Msg::SetQuirksMode => self.handle_set_quirks_mode(possibly_locked_rw_data),
|
||||
Msg::AddMetaViewport(translated_rule) => {
|
||||
self.handle_add_meta_viewport(translated_rule, possibly_locked_rw_data)
|
||||
}
|
||||
Msg::GetRPC(response_chan) => {
|
||||
response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as
|
||||
Box<LayoutRPC + Send>).unwrap();
|
||||
|
@ -823,6 +827,19 @@ impl LayoutTask {
|
|||
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
|
||||
}
|
||||
|
||||
fn handle_add_meta_viewport<'a>(&'a self,
|
||||
translated_rule: ViewportRule,
|
||||
possibly_locked_rw_data:
|
||||
&mut Option<MutexGuard<'a, LayoutTaskData>>)
|
||||
{
|
||||
let mut rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
||||
rw_data.stylist.add_stylesheet(Stylesheet {
|
||||
rules: vec![CSSRule::Viewport(translated_rule)],
|
||||
origin: Origin::Author
|
||||
});
|
||||
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
|
||||
}
|
||||
|
||||
/// Sets quirks mode for the document, causing the quirks mode stylesheet to be loaded.
|
||||
fn handle_set_quirks_mode<'a>(&'a self,
|
||||
possibly_locked_rw_data:
|
||||
|
@ -1657,4 +1674,3 @@ fn get_root_flow_background_color(flow: &mut Flow) -> AzColor {
|
|||
.resolve_color(kid_block_flow.fragment.style.get_background().background_color)
|
||||
.to_gfx_color()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue