aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-07-17 20:46:24 -0700
committerGitHub <noreply@github.com>2016-07-17 20:46:24 -0700
commitd87ea67bf2efec45368d3e48634c6c16de7486ff (patch)
treea306245f8288b20434a677eeceb5bdfb391417d4 /components/script
parentf5c60e8c5aec34a1a6ff6c61f1174a7c93158159 (diff)
parentf754cacbd53c47c63639e1d1226812427ef1eaad (diff)
downloadservo-d87ea67bf2efec45368d3e48634c6c16de7486ff.tar.gz
servo-d87ea67bf2efec45368d3e48634c6c16de7486ff.zip
Auto merge of #11890 - shinglyu:viewport-percent-recalc, r=mbrubeck
Bug 10104 - Only restyle nodes that uses viewport percentage units on viewport size change <!-- Please describe your changes on the following line: --> Bug 10104 - Only restyle nodes that uses viewport percentage units on viewport size change --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #10104 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11890) <!-- Reviewable:end -->
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) }
}