Reviewers: pfeldman,
Description:
Devtools: Replace split widget rAF animation with web animation
The current split widget animation overflows content over other widgets.
This change replaces the animation implementation with a native web
animation.
Please review this at
https://codereview.chromium.org/1156953002/
Base URL: svn://
svn.chromium.org/blink/trunk
Affected files (+11, -50 lines):
M Source/devtools/front_end/ui/SplitWidget.js
M Source/devtools/front_end/ui/splitWidget.css
Index: Source/devtools/front_end/ui/SplitWidget.js
diff --git a/Source/devtools/front_end/ui/SplitWidget.js
b/Source/devtools/front_end/ui/SplitWidget.js
index
592e2a1227e47dd1c39aa0fc2c032daf8c9cc28a..a779861bbb9116854535f76600e01029bb4ade68
100644
--- a/Source/devtools/front_end/ui/SplitWidget.js
+++ b/Source/devtools/front_end/ui/SplitWidget.js
@@ -508,7 +508,6 @@ WebInspector.SplitWidget.prototype = {
*/
_animate: function(reverse, callback)
{
- var animationTime = 50;
this._animationCallback = callback;
var animatedMarginPropertyName;
@@ -518,52 +517,14 @@ WebInspector.SplitWidget.prototype = {
animatedMarginPropertyName =
this._secondIsSidebar ? "margin-bottom" : "margin-top";
var marginFrom = reverse ? "0" : "-" +
WebInspector.zoomManager.dipToCSS(this._sidebarSizeDIP) + "px";
- var marginTo = reverse ? "-" +
WebInspector.zoomManager.dipToCSS(this._sidebarSizeDIP) + "px" : "0";
-
- // This order of things is important.
- // 1. Resize main element early and force layout.
- this.contentElement.style.setProperty(animatedMarginPropertyName,
marginFrom);
- if (!reverse) {
- suppressUnused(this._mainElement.offsetWidth);
- suppressUnused(this._sidebarElement.offsetWidth);
- }
-
- // 2. Issue onresize to the sidebar element, its size won't change.
- if (!reverse)
- this._sidebarWidget.doResize();
-
- // 3. Configure and run animation
- this.contentElement.style.setProperty("transition",
animatedMarginPropertyName + " " + animationTime + "ms linear");
+ var marginTo = reverse ? "-" +
WebInspector.zoomManager.dipToCSS(this._sidebarSizeDIP) + "px" : "0";
- var boundAnimationFrame;
- var startTime;
- /**
- * @this {WebInspector.SplitWidget}
- */
- function animationFrame()
- {
- delete this._animationFrameHandle;
-
- if (!startTime) {
- // Kick animation on first frame.
-
this.contentElement.style.setProperty(animatedMarginPropertyName, marginTo);
- startTime = window.performance.now();
- } else if (window.performance.now() < startTime +
animationTime) {
- // Process regular animation frame.
- if (this._mainWidget)
- this._mainWidget.doResize();
- } else {
- // Complete animation.
- this._cancelAnimation();
- if (this._mainWidget)
- this._mainWidget.doResize();
-
this.dispatchEventToListeners(WebInspector.SplitWidget.Events.SidebarSizeChanged,
this.sidebarSize());
- return;
- }
- this._animationFrameHandle =
this.contentElement.window().requestAnimationFrame(boundAnimationFrame);
- }
- boundAnimationFrame = animationFrame.bind(this);
- this._animationFrameHandle =
this.contentElement.window().requestAnimationFrame(boundAnimationFrame);
+ this.contentElement.style.setProperty(animatedMarginPropertyName,
marginTo);
+ var keyframes = [{}, {}];
+ keyframes[0][animatedMarginPropertyName] = marginFrom;
+ keyframes[1][animatedMarginPropertyName] = marginTo;
+ var player = this.contentElement.animate(keyframes, { duration:
150, easing: "cubic-bezier(0, 0, 0.2, 1)" });
+ player.onfinish = this._cancelAnimation.bind(this);
},
_cancelAnimation: function()
@@ -574,10 +535,6 @@ WebInspector.SplitWidget.prototype = {
this.contentElement.style.removeProperty("margin-left");
this.contentElement.style.removeProperty("transition");
- if (this._animationFrameHandle) {
-
this.contentElement.window().cancelAnimationFrame(this._animationFrameHandle);
- delete this._animationFrameHandle;
- }
if (this._animationCallback) {
this._animationCallback();
delete this._animationCallback;
Index: Source/devtools/front_end/ui/splitWidget.css
diff --git a/Source/devtools/front_end/ui/splitWidget.css
b/Source/devtools/front_end/ui/splitWidget.css
index
113b8b787967ca2439ee894ca91f626f9148183b..817013fc0424431f589e0a500763834cac4843af
100644
--- a/Source/devtools/front_end/ui/splitWidget.css
+++ b/Source/devtools/front_end/ui/splitWidget.css
@@ -26,6 +26,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+:host {
+ overflow: hidden;
+}
+
.shadow-split-widget {
display: flex;
overflow: hidden;