<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[146326] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/146326">146326</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-03-20 04:31:48 -0700 (Wed, 20 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Switch Drawer animation from JavaScript to CSS transitions.
https://bugs.webkit.org/show_bug.cgi?id=112586

This is prerequisite to make Drawer work in overlay mode.

Patch by Dmitry Zvorygin &lt;zvorygin@chromium.org&gt; on 2013-03-20
Reviewed by Vsevolod Vlasov.

* inspector/front-end/Drawer.js:
(WebInspector.Drawer):
(WebInspector.Drawer.prototype.show):
(WebInspector.Drawer.prototype.hide.this.animationFinished):
(WebInspector.Drawer.prototype.hide):
(WebInspector.Drawer.prototype.immediatelyFinishAnimation):
(WebInspector.Drawer.prototype._getAnimationStyles):
* inspector/front-end/UIUtils.js:
* inspector/front-end/inspector.css:
(.animate-slow *):
(.animate #main):
(.animate #floating-status-bar-container):
(.animate #drawer):
(.animate #bottom-status-bar-container &gt; *):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendDrawerjs">trunk/Source/WebCore/inspector/front-end/Drawer.js</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendUIUtilsjs">trunk/Source/WebCore/inspector/front-end/UIUtils.js</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendinspectorcss">trunk/Source/WebCore/inspector/front-end/inspector.css</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (146325 => 146326)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-03-20 11:30:13 UTC (rev 146325)
+++ trunk/Source/WebCore/ChangeLog        2013-03-20 11:31:48 UTC (rev 146326)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2013-03-20  Dmitry Zvorygin  &lt;zvorygin@chromium.org&gt;
+
+        Web Inspector: Switch Drawer animation from JavaScript to CSS transitions.
+        https://bugs.webkit.org/show_bug.cgi?id=112586
+
+        This is prerequisite to make Drawer work in overlay mode.
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/Drawer.js:
+        (WebInspector.Drawer):
+        (WebInspector.Drawer.prototype.show):
+        (WebInspector.Drawer.prototype.hide.this.animationFinished):
+        (WebInspector.Drawer.prototype.hide):
+        (WebInspector.Drawer.prototype.immediatelyFinishAnimation):
+        (WebInspector.Drawer.prototype._getAnimationStyles):
+        * inspector/front-end/UIUtils.js:
+        * inspector/front-end/inspector.css:
+        (.animate-slow *):
+        (.animate #main):
+        (.animate #floating-status-bar-container):
+        (.animate #drawer):
+        (.animate #bottom-status-bar-container &gt; *):
+
</ins><span class="cx"> 2013-03-19  Eugene Klyuchnikov  &lt;eustas@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: [DataGrid] Refactorings.
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendDrawerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/Drawer.js (146325 => 146326)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/Drawer.js        2013-03-20 11:30:13 UTC (rev 146325)
+++ trunk/Source/WebCore/inspector/front-end/Drawer.js        2013-03-20 11:31:48 UTC (rev 146326)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx">     this._drawerContentsElement.className = &quot;drawer-contents&quot;;
</span><span class="cx">     this.element.appendChild(this._drawerContentsElement);
</span><span class="cx">     this._viewStatusBar = document.createElement(&quot;div&quot;);
</span><ins>+    this._viewStatusBar.addEventListener(&quot;webkitTransitionEnd&quot;, this.immediatelyFinishAnimation.bind(this), false);
</ins><span class="cx">     this._bottomStatusBar = document.getElementById(&quot;bottom-status-bar-container&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -94,24 +95,30 @@
</span><span class="cx">             return;
</span><span class="cx">         
</span><span class="cx">         var height = this._constrainHeight(this._savedHeight || this.element.offsetHeight);
</span><del>-        var animations = [
-            {element: this.element, end: {height: height}},
-            {element: this._mainElement, end: {bottom: height}},
-            {element: this._floatingStatusBarContainer, start: {&quot;padding-left&quot;: this._bottomStatusBar.offsetLeft}, end: {&quot;padding-left&quot;: 0}},
-            {element: this._viewStatusBar, start: {opacity: 0}, end: {opacity: 1}}
-        ];
</del><span class="cx"> 
</span><ins>+        this._floatingStatusBarContainer.style.paddingLeft = this._bottomStatusBar.offsetLeft + &quot;px&quot;;
+
+        this._getAnimationStyles(animationType).forEach(document.body.addStyleClass, document.body);
+
</ins><span class="cx">         function animationFinished()
</span><span class="cx">         {
</span><span class="cx">             WebInspector.inspectorView.currentPanel().doResize();
</span><span class="cx">             if (this._view &amp;&amp; this._view.afterShow)
</span><span class="cx">                 this._view.afterShow();
</span><del>-            delete this._currentAnimation;
</del><span class="cx">         }
</span><span class="cx"> 
</span><del>-        this._currentAnimation = WebInspector.animateStyle(animations, this._animationDuration(animationType), animationFinished.bind(this));
</del><ins>+        this._animationFinished = animationFinished.bind(this);
+
+        // Assert that transition will be done and we receive transitionEnd event
+        console.assert(this._viewStatusBar.style.opacity != 1);
+
</ins><span class="cx">         if (animationType === WebInspector.Drawer.AnimationType.Immediately)
</span><del>-            this._currentAnimation.forceComplete();
</del><ins>+            this.immediatelyFinishAnimation();
+
+        this.element.style.height = height + &quot;px&quot;;
+        this._mainElement.style.bottom = height + &quot;px&quot;;
+        this._floatingStatusBarContainer.style.paddingLeft = 0;
+        this._viewStatusBar.style.opacity = 1;
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     hide: function(animationType)
</span><span class="lines">@@ -130,12 +137,7 @@
</span><span class="cx">         WebInspector.inspectorView.currentPanel().statusBarResized();
</span><span class="cx">         document.body.addStyleClass(&quot;drawer-visible&quot;);
</span><span class="cx"> 
</span><del>-        var animations = [
-            {element: this._mainElement, end: {bottom: 0}},
-            {element: this.element, end: {height: 0}},
-            {element: this._floatingStatusBarContainer, start: {&quot;padding-left&quot;: 0}, end: {&quot;padding-left&quot;: this._bottomStatusBar.offsetLeft} },
-            {element: this._viewStatusBar, start: {opacity: 1}, end: {opacity: 0}}
-        ];
</del><ins>+        this._getAnimationStyles(animationType).forEach(document.body.addStyleClass, document.body);
</ins><span class="cx"> 
</span><span class="cx">         function animationFinished()
</span><span class="cx">         {
</span><span class="lines">@@ -146,12 +148,20 @@
</span><span class="cx">             this._bottomStatusBar.appendChild(document.getElementById(&quot;panel-status-bar&quot;));
</span><span class="cx">             this._drawerContentsElement.removeChildren();
</span><span class="cx">             document.body.removeStyleClass(&quot;drawer-visible&quot;);
</span><del>-            delete this._currentAnimation;
</del><span class="cx">         }
</span><span class="cx"> 
</span><del>-        this._currentAnimation = WebInspector.animateStyle(animations, this._animationDuration(animationType), animationFinished.bind(this));
</del><ins>+        this._animationFinished = animationFinished.bind(this);
+
+        // Assert that transition will be done and we receive transitionEnd event
+        console.assert(this._viewStatusBar.style.opacity != 0);
+
</ins><span class="cx">         if (animationType === WebInspector.Drawer.AnimationType.Immediately)
</span><del>-            this._currentAnimation.forceComplete();
</del><ins>+            this.immediatelyFinishAnimation();
+
+        this.element.style.height = 0;
+        this._mainElement.style.bottom = 0;
+        this._floatingStatusBarContainer.style.paddingLeft = this._bottomStatusBar.offsetLeft + &quot;px&quot;;
+        this._viewStatusBar.style.opacity = 0;
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     resize: function()
</span><span class="lines">@@ -168,19 +178,23 @@
</span><span class="cx"> 
</span><span class="cx">     immediatelyFinishAnimation: function()
</span><span class="cx">     {
</span><del>-        if (this._currentAnimation)
-            this._currentAnimation.forceComplete();
</del><ins>+        document.body.removeStyleClass(&quot;animate&quot;);
+        document.body.removeStyleClass(&quot;animate-slow&quot;);
+        if (this._animationFinished) {
+            this._animationFinished();
+            delete this._animationFinished;
+        }
</ins><span class="cx">     },
</span><span class="cx"> 
</span><del>-    _animationDuration: function(animationType)
</del><ins>+    _getAnimationStyles: function(animationType)
</ins><span class="cx">     {
</span><span class="cx">         switch (animationType) {
</span><span class="cx">         case WebInspector.Drawer.AnimationType.Slow:
</span><del>-            return 2000;
</del><ins>+            return [&quot;animate&quot;, &quot;animate-slow&quot;];
</ins><span class="cx">         case WebInspector.Drawer.AnimationType.Normal:
</span><del>-            return 250;
</del><ins>+            return [&quot;animate&quot;];
</ins><span class="cx">         default:
</span><del>-            return 0;
</del><ins>+            return [];
</ins><span class="cx">         }
</span><span class="cx">     },
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendUIUtilsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/UIUtils.js (146325 => 146326)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/UIUtils.js        2013-03-20 11:30:13 UTC (rev 146325)
+++ trunk/Source/WebCore/inspector/front-end/UIUtils.js        2013-03-20 11:31:48 UTC (rev 146326)
</span><span class="lines">@@ -150,111 +150,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebInspector.animateStyle = function(animations, duration, callback)
-{
-    var interval;
-    var complete = 0;
-    var hasCompleted = false;
-
-    const intervalDuration = (1000 / 30); // 30 frames per second.
-    const animationsLength = animations.length;
-    const propertyUnit = {opacity: &quot;&quot;};
-    const defaultUnit = &quot;px&quot;;
-
-    function cubicInOut(t, b, c, d)
-    {
-        if ((t/=d/2) &lt; 1) return c/2*t*t*t + b;
-        return c/2*((t-=2)*t*t + 2) + b;
-    }
-
-    // Pre-process animations.
-    for (var i = 0; i &lt; animationsLength; ++i) {
-        var animation = animations[i];
-        var element = null, start = null, end = null, key = null;
-        for (key in animation) {
-            if (key === &quot;element&quot;)
-                element = animation[key];
-            else if (key === &quot;start&quot;)
-                start = animation[key];
-            else if (key === &quot;end&quot;)
-                end = animation[key];
-        }
-
-        if (!element || !end)
-            continue;
-
-        if (!start) {
-            var computedStyle = element.ownerDocument.defaultView.getComputedStyle(element);
-            start = {};
-            for (key in end)
-                start[key] = parseInt(computedStyle.getPropertyValue(key), 10);
-            animation.start = start;
-        } else
-            for (key in start)
-                element.style.setProperty(key, start[key] + (key in propertyUnit ? propertyUnit[key] : defaultUnit));
-    }
-
-    function animateLoop()
-    {
-        if (hasCompleted)
-            return;
-        
-        // Advance forward.
-        complete += intervalDuration;
-        var next = complete + intervalDuration;
-
-        // Make style changes.
-        for (var i = 0; i &lt; animationsLength; ++i) {
-            var animation = animations[i];
-            var element = animation.element;
-            var start = animation.start;
-            var end = animation.end;
-            if (!element || !end)
-                continue;
-
-            var style = element.style;
-            for (key in end) {
-                var endValue = end[key];
-                if (next &lt; duration) {
-                    var startValue = start[key];
-                    var newValue = cubicInOut(complete, startValue, endValue - startValue, duration);
-                    style.setProperty(key, newValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit));
-                } else
-                    style.setProperty(key, endValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit));
-            }
-        }
-
-        // End condition.
-        if (complete &gt;= duration) {
-            hasCompleted = true;
-            clearInterval(interval);
-            if (callback)
-                callback();
-        }
-    }
-
-    function forceComplete()
-    {
-        if (hasCompleted)
-            return;
-
-        complete = duration;
-        animateLoop();
-    }
-
-    function cancel()
-    {
-        hasCompleted = true;
-        clearInterval(interval);
-    }
-
-    interval = setInterval(animateLoop, intervalDuration);
-    return {
-        cancel: cancel,
-        forceComplete: forceComplete
-    };
-}
-
</del><span class="cx"> WebInspector.isBeingEdited = function(element)
</span><span class="cx"> {
</span><span class="cx">     if (element.hasStyleClass(&quot;text-prompt&quot;) || element.nodeName === &quot;INPUT&quot;)
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendinspectorcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (146325 => 146326)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/inspector.css        2013-03-20 11:30:13 UTC (rev 146325)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css        2013-03-20 11:31:48 UTC (rev 146326)
</span><span class="lines">@@ -598,6 +598,14 @@
</span><span class="cx">     background-color: white;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.animate-slow * {
+    -webkit-transition-duration: 2.5s !important;
+}
+
+.animate #main {
+    -webkit-transition: bottom 250ms linear;
+}
+
</ins><span class="cx"> body.show-toolbar-icons #main {
</span><span class="cx">     top: 56px;
</span><span class="cx"> }
</span><span class="lines">@@ -666,6 +674,10 @@
</span><span class="cx">     height: 24px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.animate #floating-status-bar-container {
+    -webkit-transition: padding 250ms linear;
+}
+
</ins><span class="cx"> body.drawer-visible #floating-status-bar-container {
</span><span class="cx">     display: -webkit-flex;
</span><span class="cx"> }
</span><span class="lines">@@ -910,6 +922,10 @@
</span><span class="cx">     background-color: white;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.animate #drawer {
+    -webkit-transition: height 250ms linear;
+}
+
</ins><span class="cx"> #drawer-contents {
</span><span class="cx">     position: absolute;
</span><span class="cx">     top: 0;
</span><span class="lines">@@ -2522,6 +2538,10 @@
</span><span class="cx">     overflow: hidden;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.animate #bottom-status-bar-container &gt; * {
+    -webkit-transition: opacity 250ms linear;
+}
+
</ins><span class="cx"> .search-status-bar-item {
</span><span class="cx">     display: inline-block;
</span><span class="cx">     cursor: pointer;
</span></span></pre>
</div>
</div>

</body>
</html>