Auto merge of #20041 - paavininanda:mutflags, r=jdm

Added extra bool in Window object to know about its Mutation Observers

<!-- Please describe your changes on the following line: -->
- Added Cell<bool> type variable in Window object to know whether its mutation observers are present/absent
- Added get and set functions for this variable
- Added supporting test files to check for performance

---
<!-- 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 #16936.

<!-- Either: -->
- [x] There are tests for these changes, but these are manual tests for checking correctness of added code

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20041)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-16 12:16:55 -05:00 committed by GitHub
commit 4454e81878
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 1 deletions

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<script>
window.onload = function(){
var script = document.createElement("script");
script.setAttribute("attr", "val");
var start_test = function(targetNode,attr) {
var start = performance.now();
for( val = 1; val <= 1000; val++) {
targetNode.setAttribute(attr, val);
}
var stop = performance.now();
console.log('Time taken:'+ (stop - start)/1000.0);
};
var config = { attributes: true, childList: true };
console.log('Mutation Observer Algorithm performance testing...');
console.log('\nMutation performed without observer ->');
start_test(script,"attr");
console.log('\nMutation performed with observer ->');
var callback = function(mutationsList) {
for(var mutation of mutationsList) {
if (mutation.type == 'childList') {
// Uncomment below line to see changes
// console.log('A child node has been added or removed.');
}
else if (mutation.type == 'attributes') {
// Uncomment below line to see changes
// console.log('The ' + mutation.attributeName + ' attribute was modified.');
}
}
};
var observer = new MutationObserver(callback);
observer.observe(script, config);
start_test(script,"attr");
}
</script>
</body>
</html>