Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: third_party/WebKit/ManualTests/compositor-worker/sticky/js/dom-util.js

Issue 1547893003: WIP - compositor worker mega patch. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/ManualTests/compositor-worker/sticky/js/dom-util.js
diff --git a/third_party/WebKit/ManualTests/compositor-worker/sticky/js/dom-util.js b/third_party/WebKit/ManualTests/compositor-worker/sticky/js/dom-util.js
new file mode 100644
index 0000000000000000000000000000000000000000..482147c0ace8ed8d2e8dbe4b901a62005eb82fbb
--- /dev/null
+++ b/third_party/WebKit/ManualTests/compositor-worker/sticky/js/dom-util.js
@@ -0,0 +1,39 @@
+function getViewportRect(target) {
+ // Q: What's the correct way to get the scroller bounds (if the scroller is the document)?
+ if (target == document.scrollingElement) {
+ return {
+ left: 0,
+ top: 0,
+ width: window.innerWidth,
+ height: window.innerHeight,
+ right: window.innerWidth,
+ bottom: window.innerHeight
+ };
+ }
+ return target.getBoundingClientRect();
+}
+
+function getContainingBlockElement(node) {
+ if (node.style.position == 'absolute') {
+ do {
+ node = node.parentNode;
+ } while (['absolute', 'fixed', 'relative', 'sticky'].indexOf(getComputedStyle(node).position) == -1);
+ return node || document;
+ }
+ do {
+ node = node.parentNode;
+ } while (['block', 'inline-block', 'list-item', 'run-in', 'table', 'table-cell'].indexOf(getComputedStyle(node).display) == -1);
+ return node || document;
+}
+
+function isScrollable(element) {
+ // Q: Why is scrollHeight > clientHeight on body when document is scrollable node?
+ return element.scrollHeight > element.clientHeight || element == document.scrollingElement;
+}
+
+function getContainingScrollingElement(element) {
+ do {
+ element = getContainingBlockElement(element);
+ } while (element && !isScrollable(element));
+ return element;
+}

Powered by Google App Engine
This is Rietveld 408576698