mirror of
https://github.com/servo/servo.git
synced 2025-07-30 18:50:36 +01:00
Auto merge of #6185 - luniv:viewport-meta, r=mbrubeck
Implement <meta name=viewport> handling Translate <meta name=viewport> as according to [CSS Device Adaption § 9](http://dev.w3.org/csswg/css-device-adapt/#viewport-meta) Note: as the PR currently stands, handling `<meta name=viewport>` elements always occurs. This is probably not desired for some contexts (e.g. desktop), but I'm unsure of how to conditionally handle elements based on that. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6185) <!-- Reviewable:end -->
This commit is contained in:
commit
a7743052ca
9 changed files with 508 additions and 62 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