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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/share_dialog.js

Issue 2702423002: Detect webview size change by motion instead of expected size. (Closed)
Patch Set: Remove unused binding. Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/ui/share_dialog.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/share_dialog.js b/ui/file_manager/file_manager/foreground/js/ui/share_dialog.js
index 25cb653f3e90fbdaee07925fb51abcd26c74c59c..aed9a1998a38fe90be7e8a7ea6ec7251742c048c 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/share_dialog.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/share_dialog.js
@@ -29,6 +29,13 @@ function ShareDialog(parentNode) {
ShareDialog.FAILURE_TIMEOUT = 20000;
/**
+ * Polling interval for detecting the end of resizing animation.
+ * @type {number}
+ * @const
+ */
+ShareDialog.WEBVIEW_CHECKSIZE_INTERVAL = 200;
+
+/**
* The result of opening the dialog.
* @enum {string}
* @const
@@ -151,22 +158,32 @@ ShareDialog.prototype.onResized = function(width, height, callback) {
this.webViewWrapper_.style.width = width + 'px';
this.webViewWrapper_.style.height = height + 'px';
- // Wait sending 'resizeComplete' event until the latest size can be obtained
- // in the WebView.
- var checkSize = function() {
+ // Wait sending 'resizeComplete' event until the size of the WebView
+ // stabilizes. This is a workaround for crbug.com/693416.
+ // TODO(yamaguchi): Detect animation end by the absolute size to distinguish
+ // it from frame drops.
+ /**
+ * @param {number} previousWidth Width in pixels.
+ * @param {number} previousHeight Height in pixels.
+ */
+ var checkSize = function(previousWidth, previousHeight) {
this.webView_.executeScript({
code: "[document.documentElement.clientWidth," +
" document.documentElement.clientHeight];"
}, function(results) {
- if (results[0][0] === width && results[0][1] === height) {
+ var newWidth = results[0][0];
+ var newHeight = results[0][1];
+ if (newWidth === previousWidth && newHeight === previousHeight) {
callback();
} else {
- setTimeout(checkSize, 50);
+ setTimeout(checkSize.bind(null, newWidth, newHeight),
+ ShareDialog.WEBVIEW_CHECKSIZE_INTERVAL);
}
}.bind(this));
}.bind(this);
- setTimeout(checkSize, 0);
+ setTimeout(checkSize.bind(null, -1, -1),
+ ShareDialog.WEBVIEW_CHECKSIZE_INTERVAL);
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698