<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[20717] branches/WebInspectorRefresh/WebKit/WebInspector</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20717">20717</a></dd>
<dt>Author</dt> <dd>thatcher</dd>
<dt>Date</dt> <dd>2007-04-04 23:04:34 -0700 (Wed, 04 Apr 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move the tree splitter resize code down into JavaScript. Some other cleanup work.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorWebInspectorm">branches/WebInspectorRefresh/WebKit/WebInspector/WebInspector.m</a></li>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorWebInspectorInternalh">branches/WebInspectorRefresh/WebKit/WebInspector/WebInspectorInternal.h</a></li>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorwebInspectorinspectorhtml">branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html</a></li>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorwebInspectorinspectorjs">branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesWebInspectorRefreshWebKitWebInspectorWebInspectorm"></a>
<div class="modfile"><h4>Modified: branches/WebInspectorRefresh/WebKit/WebInspector/WebInspector.m (20716 => 20717)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/WebInspector.m        2007-04-05 05:24:58 UTC (rev 20716)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/WebInspector.m        2007-04-05 06:04:34 UTC (rev 20717)
</span><span class="lines">@@ -337,64 +337,6 @@
</span><span class="cx">     NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseUp location:[currentEvent locationInWindow] modifierFlags:[currentEvent modifierFlags] timestamp:[currentEvent timestamp] windowNumber:[[currentEvent window] windowNumber] context:[currentEvent context] eventNumber:[currentEvent eventNumber] clickCount:[currentEvent clickCount] pressure:[currentEvent pressure]];
</span><span class="cx">     [[[[_private-&gt;webView mainFrame] frameView] documentView] mouseUp:event];
</span><span class="cx"> }
</span><del>-
-- (void)resizeTopArea
-{
-    NSWindow *window = [self window];
-    NSEvent *event = [window currentEvent];
-    NSPoint lastLocation = [window convertBaseToScreen:[event locationInWindow]];
-    NSRect lastFrame = [window frame];
-    NSSize minSize = [window minSize];
-    NSSize maxSize = [window maxSize];
-    BOOL mouseUpOccurred = NO;
-
-    DOMHTMLElement *topArea = (DOMHTMLElement *)[_private-&gt;domDocument getElementById:@&quot;top&quot;];
-    DOMHTMLElement *splitter = (DOMHTMLElement *)[_private-&gt;domDocument getElementById:@&quot;splitter&quot;];
-    DOMHTMLElement *bottomArea = (DOMHTMLElement *)[_private-&gt;domDocument getElementById:@&quot;bottom&quot;];
-
-    while (!mouseUpOccurred) {
-        // set mouseUp flag here, but process location of event before exiting from loop, leave mouseUp in queue
-        event = [window nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask) untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES];
-
-        if ([event type] == NSLeftMouseUp)
-            mouseUpOccurred = YES;
-
-        NSPoint newLocation = [window convertBaseToScreen:[event locationInWindow]];
-        if (NSEqualPoints(newLocation, lastLocation))
-            continue;
-
-        NSRect proposedRect = lastFrame;
-        long delta = newLocation.y - lastLocation.y;
-        proposedRect.size.height -= delta;
-        proposedRect.origin.y += delta;
-
-        if (proposedRect.size.height &lt; minSize.height) {
-            proposedRect.origin.y -= minSize.height - proposedRect.size.height;
-            proposedRect.size.height = minSize.height;
-        } else if (proposedRect.size.height &gt; maxSize.height) {
-            proposedRect.origin.y -= maxSize.height - proposedRect.size.height;
-            proposedRect.size.height = maxSize.height;
-        }
-
-        NSString *newValue = [NSString stringWithFormat:@&quot;%dpx&quot;, [topArea clientHeight] - delta];
-        [[topArea style] setProperty:@&quot;height&quot; value:newValue priority:@&quot;&quot;];
-
-        newValue = [NSString stringWithFormat:@&quot;%dpx&quot;, [splitter offsetTop] - delta];
-        [[splitter style] setProperty:@&quot;top&quot; value:newValue priority:@&quot;&quot;];
-
-        newValue = [NSString stringWithFormat:@&quot;%dpx&quot;, [bottomArea offsetTop] - delta];
-        [[bottomArea style] setProperty:@&quot;top&quot; value:newValue priority:@&quot;&quot;];
-
-        [window setFrame:proposedRect display:YES];
-        lastLocation = newLocation;
-        lastFrame = proposedRect;
-
-        [self _updateTreeScrollbar];
-    }
-
-    // post the mouse up event back to the queue so the WebView can get it
-    [window postEvent:event atStart:YES];
-}
</del><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #pragma mark -
</span><span class="lines">@@ -453,27 +395,14 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_update
</span><span class="cx"> {
</span><del>-    if (_private-&gt;webViewLoaded) {
-        if ([self focusedDOMNode]) {
-            [[_private-&gt;webView windowScriptObject] callWebScriptMethod:@&quot;toggleNoSelection&quot; withArguments:[NSArray arrayWithObject:[NSNumber numberWithBool:NO]]];
-            [[_private-&gt;webView windowScriptObject] callWebScriptMethod:@&quot;updatePanes&quot; withArguments:nil];
-        } else
-            [[_private-&gt;webView windowScriptObject] callWebScriptMethod:@&quot;toggleNoSelection&quot; withArguments:[NSArray arrayWithObject:[NSNumber numberWithBool:YES]]];
-    }
</del><ins>+    if (_private-&gt;webViewLoaded)
+        [[_private-&gt;webView windowScriptObject] callWebScriptMethod:@&quot;updatePanes&quot; withArguments:nil];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_updateRoot
</span><span class="cx"> {
</span><del>-    if (!_private-&gt;webViewLoaded)
-        return;
-
-    [[_private-&gt;webView windowScriptObject] callWebScriptMethod:@&quot;updateTreeOutline&quot; withArguments:nil];
-}
-
-- (void)_updateTreeScrollbar
-{
</del><span class="cx">     if (_private-&gt;webViewLoaded)
</span><del>-        [[_private-&gt;webView windowScriptObject] evaluateWebScript:@&quot;treeOutlineScrollArea.refresh()&quot;];
</del><ins>+        [[_private-&gt;webView windowScriptObject] callWebScriptMethod:@&quot;updateTreeOutline&quot; withArguments:nil];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_updateSystemColors
</span></span></pre></div>
<a id="branchesWebInspectorRefreshWebKitWebInspectorWebInspectorInternalh"></a>
<div class="modfile"><h4>Modified: branches/WebInspectorRefresh/WebKit/WebInspector/WebInspectorInternal.h (20716 => 20717)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/WebInspectorInternal.h        2007-04-05 05:24:58 UTC (rev 20716)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/WebInspectorInternal.h        2007-04-05 06:04:34 UTC (rev 20717)
</span><span class="lines">@@ -30,11 +30,11 @@
</span><span class="cx"> 
</span><span class="cx"> #import &lt;Foundation/NSObject.h&gt;
</span><span class="cx"> #import &lt;WebKit/WebInspector.h&gt;
</span><del>-#import &lt;WebKit/DOMCore.h&gt;
</del><ins>+#import &lt;WebKit/DOMNode.h&gt;
</ins><span class="cx"> 
</span><ins>+@class DOMHTMLDocument;
</ins><span class="cx"> @class WebView;
</span><span class="cx"> @class WebFrame;
</span><del>-@class DOMHTMLDocument;
</del><span class="cx"> @class WebNodeHighlight;
</span><span class="cx"> 
</span><span class="cx"> @interface WebInspectorPrivate : NSObject
</span><span class="lines">@@ -61,8 +61,6 @@
</span><span class="cx"> - (void)_update;
</span><span class="cx"> - (void)_updateRoot;
</span><span class="cx"> - (void)_updateSystemColors;
</span><del>-- (void)_updateTreeScrollbar;
-- (void)_webFrameDetached:(WebFrame *)frame;
</del><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface DOMNode (DOMNodeInspectorAdditions)
</span></span></pre></div>
<a id="branchesWebInspectorRefreshWebKitWebInspectorwebInspectorinspectorhtml"></a>
<div class="modfile"><h4>Modified: branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html (20716 => 20717)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html        2007-04-05 05:24:58 UTC (rev 20716)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html        2007-04-05 06:04:34 UTC (rev 20717)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx">         &lt;div id=&quot;treeOutlineScrollbar&quot;&gt;&lt;/div&gt;
</span><span class="cx">     &lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><del>-&lt;div id=&quot;splitter&quot; onmousedown=&quot;Inspector.resizeTopArea()&quot;&gt;&lt;hr size=&quot;2&quot; /&gt;&lt;/div&gt;
</del><ins>+&lt;div id=&quot;splitter&quot;&gt;&lt;hr size=&quot;2&quot; /&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;div id=&quot;bottom&quot;&gt;
</span><span class="cx">     &lt;div id=&quot;tabs&quot;&gt;
</span><span class="cx">         &lt;button class=&quot;left&quot; id=&quot;nodeButton&quot; onclick=&quot;switchPane('node')&quot;&gt;Node&lt;/button&gt;
</span></span></pre></div>
<a id="branchesWebInspectorRefreshWebKitWebInspectorwebInspectorinspectorjs"></a>
<div class="modfile"><h4>Modified: branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.js (20716 => 20717)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.js        2007-04-05 05:24:58 UTC (rev 20716)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.js        2007-04-05 06:04:34 UTC (rev 20717)
</span><span class="lines">@@ -513,6 +513,7 @@
</span><span class="cx">     window.addEventListener(&quot;resize&quot;, refreshScrollbars, true);
</span><span class="cx">     document.addEventListener(&quot;click&quot;, changeFocus, true);
</span><span class="cx">     document.addEventListener(&quot;keypress&quot;, documentKeypress, true);
</span><ins>+    document.getElementById(&quot;splitter&quot;).addEventListener(&quot;mousedown&quot;, topAreaResizeDragStart, true);
</ins><span class="cx"> 
</span><span class="cx">     currentFocusElement = document.getElementById(&quot;tree&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -851,6 +852,8 @@
</span><span class="cx">     treeOutline.treeRoot = true;
</span><span class="cx">     treeOutline.innerText = &quot;&quot;; // clear the existing tree
</span><span class="cx"> 
</span><ins>+    treeOutlineScrollArea.refresh();
+
</ins><span class="cx">     if (!rootNode)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -983,6 +986,7 @@
</span><span class="cx"> {
</span><span class="cx">     for (var i = 0; i &lt; tabNames.length; i++)
</span><span class="cx">         paneUpdateState[tabNames[i]] = false;
</span><ins>+    toggleNoSelection((Inspector.focusedDOMNode() ? false : true));
</ins><span class="cx">     if (noSelection)
</span><span class="cx">         return;
</span><span class="cx">     eval(&quot;update&quot; + currentPane.charAt(0).toUpperCase() + currentPane.substr(1) + &quot;Pane()&quot;);    
</span><span class="lines">@@ -1527,3 +1531,57 @@
</span><span class="cx"> 
</span><span class="cx">     jsPropertiesScrollArea.refresh();
</span><span class="cx"> }
</span><ins>+
+function dividerDragStart(element, dividerDrag, dividerDragEnd, event, cursor) 
+{
+    element.dragging = true;
+    element.dragLastY = event.clientY + window.scrollY;
+    element.dragLastX = event.clientX + window.scrollX;
+    document.addEventListener(&quot;mousemove&quot;, dividerDrag, true);
+    document.addEventListener(&quot;mouseup&quot;, dividerDragEnd, true);
+    document.body.style.cursor = cursor;
+    event.preventDefault();
+}
+
+function dividerDragEnd(element, dividerDrag, dividerDragEnd, event) 
+{
+    element.dragging = false;
+    document.removeEventListener(&quot;mousemove&quot;, dividerDrag, true);
+    document.removeEventListener(&quot;mouseup&quot;, dividerDragEnd, true);
+    document.body.style.removeProperty(&quot;cursor&quot;);
+}
+
+function topAreaResizeDragStart(event) 
+{
+    dividerDragStart(document.getElementById(&quot;splitter&quot;), topAreaResizeDrag, topAreaResizeDragEnd, event, &quot;row-resize&quot;);
+}
+
+function topAreaResizeDrag(event) 
+{
+    var element = document.getElementById(&quot;splitter&quot;);
+    if (element.dragging == true) {
+        var y = event.clientY + window.scrollY;
+        var delta = element.dragLastY - y;
+        element.dragLastY = y;
+
+        var top = document.getElementById(&quot;top&quot;);
+        top.style.height = (top.clientHeight - delta) + &quot;px&quot;;
+
+        var splitter = document.getElementById(&quot;splitter&quot;);
+        splitter.style.top = (splitter.offsetTop - delta) + &quot;px&quot;;
+
+        var bottom = document.getElementById(&quot;bottom&quot;);
+        bottom.style.top = (bottom.offsetTop - delta) + &quot;px&quot;;
+
+        window.resizeBy(0, (delta * -1));
+
+        treeOutlineScrollArea.refresh();
+
+        event.preventDefault();
+    }
+}
+
+function topAreaResizeDragEnd(event) 
+{
+    dividerDragEnd(document.getElementById(&quot;splitter&quot;), topAreaResizeDrag, topAreaResizeDragEnd, event);
+}
</ins></span></pre>
</div>
</div>

</body>
</html>