aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorShing Lyu <shing.lyu@gmail.com>2016-06-22 16:44:04 +0800
committerShing Lyu <shing.lyu@gmail.com>2016-07-18 11:01:42 +0800
commitf754cacbd53c47c63639e1d1226812427ef1eaad (patch)
tree4572aa2e175f5f081537e4022c9500583b6560c6 /components/script
parente7a55ae55ee0091095b8a460b3088440f352dd2e (diff)
downloadservo-f754cacbd53c47c63639e1d1226812427ef1eaad.tar.gz
servo-f754cacbd53c47c63639e1d1226812427ef1eaad.zip
Only restyle viewport-relative nodes on viewport size change
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/node.rs4
-rw-r--r--components/script/layout_wrapper.rs19
2 files changed, 21 insertions, 2 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 5cb2ac540c4..37495be3ba3 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -159,7 +159,9 @@ bitflags! {
const SEQUENTIALLY_FOCUSABLE = 0x20,
/// Whether any ancestor is a fragmentation container
- const CAN_BE_FRAGMENTED = 0x40
+ const CAN_BE_FRAGMENTED = 0x40,
+ #[doc = "Specifies whether this node needs to be dirted when viewport size changed."]
+ const DIRTY_ON_VIEWPORT_SIZE_CHANGE = 0x80
}
}
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index ebc2da9c529..78a6b1a2f71 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -36,7 +36,7 @@ use dom::bindings::js::LayoutJS;
use dom::characterdata::LayoutCharacterDataHelpers;
use dom::document::{Document, LayoutDocumentHelpers};
use dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers};
-use dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY};
+use dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY, DIRTY_ON_VIEWPORT_SIZE_CHANGE};
use dom::node::{Node, LayoutNodeHelpers};
use dom::text::Text;
use gfx_traits::ByteIndex;
@@ -193,6 +193,23 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
self.node.set_flag(HAS_DIRTY_DESCENDANTS, value)
}
+ fn needs_dirty_on_viewport_size_changed(&self) -> bool {
+ unsafe { self.node.get_flag(DIRTY_ON_VIEWPORT_SIZE_CHANGE) }
+ }
+
+ unsafe fn set_dirty_on_viewport_size_changed(&self) {
+ self.node.set_flag(DIRTY_ON_VIEWPORT_SIZE_CHANGE, true);
+ }
+
+ fn set_descendants_dirty_on_viewport_size_changed(&self) {
+ for ref child in self.children() {
+ unsafe {
+ child.set_dirty_on_viewport_size_changed();
+ }
+ child.set_descendants_dirty_on_viewport_size_changed();
+ }
+ }
+
fn can_be_fragmented(&self) -> bool {
unsafe { self.node.get_flag(CAN_BE_FRAGMENTED) }
}