<!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>[20710] branches/WebInspectorRefresh/WebKit/WebInspector</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20710">20710</a></dd>
<dt>Author</dt> <dd>thatcher</dd>
<dt>Date</dt> <dd>2007-04-04 20:43:43 -0700 (Wed, 04 Apr 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>Keep our own copy of AppleScrollbar.js and AppleScrollArea.js, copied /System/Library/WidgetResources/AppleClasses.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorWebInspectorm">branches/WebInspectorRefresh/WebKit/WebInspector/WebInspector.m</a></li>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorwebInspectorinspectorhtml">branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorwebInspectorAppleScrollAreajs">branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollArea.js</a></li>
<li><a href="#branchesWebInspectorRefreshWebKitWebInspectorwebInspectorAppleScrollbarjs">branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollbar.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 (20709 => 20710)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/WebInspector.m        2007-04-05 01:05:49 UTC (rev 20709)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/WebInspector.m        2007-04-05 03:43:43 UTC (rev 20710)
</span><span class="lines">@@ -138,7 +138,8 @@
</span><span class="cx">
</span><span class="cx"> [window setContentView:_private->webView];
</span><span class="cx">
</span><del>- NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"inspector" ofType:@"html" inDirectory:@"webInspector"];
</del><ins>+// NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"inspector" ofType:@"html" inDirectory:@"webInspector"];
+ NSString *path = @"/Users/timothy/Work/Safari-TOT/OpenSource/WebKit/WebInspector/webInspector/inspector.html";
</ins><span class="cx"> [[_private->webView mainFrame] loadRequest:[[[NSURLRequest alloc] initWithURL:[NSURL fileURLWithPath:path]] autorelease]];
</span><span class="cx">
</span><span class="cx"> [self setWindow:window];
</span></span></pre></div>
<a id="branchesWebInspectorRefreshWebKitWebInspectorwebInspectorAppleScrollAreajs"></a>
<div class="addfile"><h4>Added: branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollArea.js (0 => 20710)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollArea.js         (rev 0)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollArea.js        2007-04-05 03:43:43 UTC (rev 20710)
</span><span class="lines">@@ -0,0 +1,346 @@
</span><ins>+/*
+© Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software and the associated images located in
+/System/Library/WidgetResources/AppleClasses/ (collectively "Apple Software")
+are supplied to you by Apple Computer, Inc. (“Apple”) in consideration of your
+agreement to the following terms. Your use, installation and/or redistribution
+of this Apple Software constitutes acceptance of these terms. If you do not
+agree with these terms, please do not use, install, or redistribute this Apple
+Software.
+
+In consideration of your agreement to abide by the following terms, and subject
+to these terms, Apple grants you a personal, non-exclusive license, under
+Apple’s copyrights in the Apple Software, to use, reproduce, and redistribute
+the Apple Software, in text form (for JavaScript files) or binary form (for
+associated images), for the sole purpose of creating Dashboard widgets for Mac
+OS X.
+
+If you redistribute the Apple Software, you must retain this entire notice and
+the warranty disclaimers and limitation of liability provisions (last two
+paragraphs below) in all such redistributions of the Apple Software.
+
+You may not use the name, trademarks, service marks or logos of Apple to endorse
+or promote products that include the Apple Software without the prior written
+permission of Apple. Except as expressly stated in this notice, no other rights
+or licenses, express or implied, are granted by Apple herein, including but not
+limited to any patent rights that may be infringed by your products that
+incorporate the Apple Software or by other works in which the Apple Software may
+be incorporated.
+
+The Apple Software is provided on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
+NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
+REGARDING THE APPPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION
+WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, AND/OR DISTRIBUTION OF THE
+APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * AppleScrollArea Constructor
+ * content is the element containing the display to be scrolled.
+ * Any additional arguments will be added as scrollbars using this.addScrollbar.
+ */
+function AppleScrollArea(content)
+{
+        /* Objects */
+        this.content = content;
+        
+        /* public properties */
+        // These are read-write. Set them as needed.
+        this.scrollsVertically = true;
+        this.scrollsHorizontally = true;
+        this.singlepressScrollPixels = 10;
+        
+        // These are read-only.
+        this.viewHeight = 0;
+        this.viewToContentHeightRatio = 1.0;
+        this.viewWidth = 0;
+        this.viewToContentWidthRatio = 1.0;
+
+        /* Internal Objects */
+        this._scrollbars = new Array();
+        
+        // For JavaScript event handlers
+        var _self = this;
+        
+        /*
+         * Privileged methods
+         * These event handlers need to be here because within an event handler,
+         * "this" refers to the element which called the event, rather than the
+         * class instance.
+         */        
+        this._refreshHandler = function() { _self.refresh(); };
+        this._keyPressedHandler = function() { _self.keyPressed(event); };
+        this._mousewheelScrollHandler = function(event) { _self.mousewheelScroll(event); };
+
+ // Set up the style for the content element just to be certain
+        this.content.style.overflow = "hidden";
+        this.content.scrollTop = 0;
+        this.content.scrollLeft = 0;
+        
+        // Add event listeners
+        this.content.addEventListener("mousewheel", this._mousewheelScrollHandler, true);
+        
+        this.refresh();
+        
+        // Add any scrollbars
+        var c = arguments.length;
+        for (var i = 1; i < c; ++i)
+        {
+                this.addScrollbar(arguments[i]);
+        }
+}
+
+AppleScrollArea.prototype.addScrollbar = function(scrollbar)
+{
+        scrollbar.setScrollArea(this);
+        this._scrollbars.push(scrollbar);
+        scrollbar.refresh();
+}
+
+AppleScrollArea.prototype.removeScrollbar = function(scrollbar)
+{
+        var scrollbars = this._scrollbars;
+        var c = scrollbars.length;
+        for (var i = 0; i < c; ++i)
+        {
+                if (scrollbars[i] == scrollbar)
+                {
+                        scrollbars.splice(i, 1);
+                        break;
+                }
+        }
+}
+
+AppleScrollArea.prototype.remove = function()
+{
+        this.content.removeEventListener("mousewheel", this._mousewheelScrollHandler, true);
+        
+        var scrollbars = this._scrollbars;
+        var c = scrollbars.length;
+        for (var i = 0; i < c; ++i)
+        {
+                scrollbars[i].setScrollArea(null);
+        }
+}
+
+/*
+ * refresh() member function
+ * Refresh the current scrollbar position and size.
+ * This should be called whenever the content element changes.
+ */
+AppleScrollArea.prototype.refresh = function()
+{        
+        // get the current actual view height. Float because we divide.
+        var style = document.defaultView.getComputedStyle(this.content, '');
+        if (style)
+        {
+         this.viewHeight = parseFloat(style.getPropertyValue("height"));
+         this.viewWidth = parseFloat(style.getPropertyValue("width"));
+ }
+ else
+ {
+ this.viewHeight = 0;
+ this.viewWidth = 0;
+ }
+        
+        
+        if (this.content.scrollHeight > this.viewHeight)
+        {
+                this.viewToContentHeightRatio = this.viewHeight / this.content.scrollHeight;
+                this.verticalScrollTo(this.content.scrollTop);
+        }
+        else
+        {
+                this.viewToContentHeightRatio = 1.0;
+                this.verticalScrollTo(0);
+        }
+        
+        if (this.content.scrollWidth > this.viewWidth)
+        {
+                this.viewToContentWidthRatio = this.viewWidth / this.content.scrollWidth;
+                this.horizontalScrollTo(this.content.scrollLeft);
+        }
+        else
+        {
+                this.viewToContentWidthRatio = 1.0;
+                this.horizontalScrollTo(0);
+        }
+        
+        var scrollbars = this._scrollbars;
+        var c = scrollbars.length;
+        for (var i = 0; i < c; ++i)
+        {
+                scrollbars[i].refresh();
+        }
+}
+
+/*
+ * focus() member function.
+ * Tell the scrollarea that it is in focus. It will capture keyPressed events
+ * and if they are arrow keys scroll accordingly.
+ */
+AppleScrollArea.prototype.focus = function()
+{
+        document.addEventListener("keypress", this._keyPressedHandler, true);
+}
+
+/*
+ * blur() member function.
+ * Tell the scrollarea that it is no longer in focus. It will cease capturing
+ * keypress events.
+ */
+AppleScrollArea.prototype.blur = function()
+{
+        document.removeEventListener("keypress", this._keyPressedHandler, true);
+}
+
+
+/*
+ * reveal(element) member function.
+ * Pass in an Element which is contained within the content element.
+ * The content will then be scrolled to reveal that element.
+ */
+AppleScrollArea.prototype.reveal = function(element)
+{
+        var offsetY = 0;
+        var obj = element;
+        do
+        {
+                offsetY += obj.offsetTop;
+                obj = obj.offsetParent;
+        } while (obj && obj != this.content);
+        
+        var offsetX = 0;
+        obj = element;
+        do
+        {
+                offsetX += obj.offsetLeft;
+                obj = obj.offsetParent;
+        } while (obj && obj != this.content);
+        
+        this.verticalScrollTo(offsetY);
+        this.horizontalScrollTo(offsetX);
+}
+
+
+AppleScrollArea.prototype.verticalScrollTo = function(new_content_top)
+{
+        if (!this.scrollsVertically)
+                return;
+        
+        var bottom = this.content.scrollHeight - this.viewHeight;
+        
+        if (new_content_top < 0)
+        {
+                new_content_top = 0;
+        }
+        else if (new_content_top > bottom)
+        {
+                new_content_top = bottom;
+        }
+        
+        this.content.scrollTop = new_content_top;
+        
+        var scrollbars = this._scrollbars;
+        var c = scrollbars.length;
+        for (var i = 0; i < c; ++i)
+        {
+                scrollbars[i].verticalHasScrolled();
+        }
+}
+
+AppleScrollArea.prototype.horizontalScrollTo = function(new_content_left)
+{
+        if (!this.scrollsHorizontally)
+                return;
+        
+        var right = this.content_width - this.viewWidth;
+        
+        if (new_content_left < 0)
+        {
+                new_content_left = 0;
+        }
+        else if (new_content_left > right)
+        {
+                new_content_left = right;
+        }
+        
+        this.content.scrollLeft = new_content_left;
+        
+        var scrollbars = this._scrollbars;
+        var c = scrollbars.length;
+        for (var i = 0; i < c; ++i)
+        {
+                scrollbars[i].horizontalHasScrolled();
+        }
+}
+
+/*********************
+ * Keypressed events
+ */
+AppleScrollArea.prototype.keyPressed = function(event)
+{
+        var handled = true;
+        
+        if (event.altKey)
+                return;
+        if (event.shiftKey)
+                return;
+        
+        switch (event.keyIdentifier)
+        {
+                case "Home":
+                        this.verticalScrollTo(0);
+                        break;
+                case "End":
+                        this.verticalScrollTo(this.content.scrollHeight - this.viewHeight);
+                        break;
+                case "Up":
+                        this.verticalScrollTo(this.content.scrollTop - this.singlepressScrollPixels);
+                        break;
+                case "Down":
+                        this.verticalScrollTo(this.content.scrollTop + this.singlepressScrollPixels);
+                        break;
+                case "PageUp":
+                        this.verticalScrollTo(this.content.scrollTop - this.viewHeight);
+                        break;
+                case "PageDown":
+                        this.verticalScrollTo(this.content.scrollTop + this.viewHeight);
+                        break;
+                case "Left":
+                        this.horizontalScrollTo(this.content.scrollLeft - this.singlepressScrollPixels);
+                        break;
+                case "Right":
+                        this.horizontalScrollTo(this.content.scrollLeft + this.singlepressScrollPixels);
+                        break;
+                default:
+                        handled = false;
+        }
+        
+        if (handled)
+        {
+                event.stopPropagation();
+                event.preventDefault();
+        }
+}
+
+/*********************
+ * Scrollwheel events
+ */
+AppleScrollArea.prototype.mousewheelScroll = function(event)
+{
+        var deltaScroll = event.wheelDelta / 120 * this.singlepressScrollPixels;
+        this.verticalScrollTo(this.content.scrollTop - deltaScroll);
+
+        event.stopPropagation();
+        event.preventDefault();
+}
</ins><span class="cx">Property changes on: branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollArea.js
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: allow-tabs
</span><span class="cx"> + 1
</span></span></pre></div>
<a id="branchesWebInspectorRefreshWebKitWebInspectorwebInspectorAppleScrollbarjs"></a>
<div class="addfile"><h4>Added: branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollbar.js (0 => 20710)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollbar.js         (rev 0)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollbar.js        2007-04-05 03:43:43 UTC (rev 20710)
</span><span class="lines">@@ -0,0 +1,776 @@
</span><ins>+/*
+© Copyright 2005 Apple Computer, Inc. All rights reserved.
+
+IMPORTANT: This Apple software and the associated images located in
+/System/Library/WidgetResources/AppleClasses/ (collectively "Apple Software")
+are supplied to you by Apple Computer, Inc. (“Apple”) in consideration of your
+agreement to the following terms. Your use, installation and/or redistribution
+of this Apple Software constitutes acceptance of these terms. If you do not
+agree with these terms, please do not use, install, or redistribute this Apple
+Software.
+
+In consideration of your agreement to abide by the following terms, and subject
+to these terms, Apple grants you a personal, non-exclusive license, under
+Apple’s copyrights in the Apple Software, to use, reproduce, and redistribute
+the Apple Software, in text form (for JavaScript files) or binary form (for
+associated images), for the sole purpose of creating Dashboard widgets for Mac
+OS X.
+
+If you redistribute the Apple Software, you must retain this entire notice and
+the warranty disclaimers and limitation of liability provisions (last two
+paragraphs below) in all such redistributions of the Apple Software.
+
+You may not use the name, trademarks, service marks or logos of Apple to endorse
+or promote products that include the Apple Software without the prior written
+permission of Apple. Except as expressly stated in this notice, no other rights
+or licenses, express or implied, are granted by Apple herein, including but not
+limited to any patent rights that may be infringed by your products that
+incorporate the Apple Software or by other works in which the Apple Software may
+be incorporated.
+
+The Apple Software is provided on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
+NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
+REGARDING THE APPPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION
+WITH YOUR PRODUCTS.
+
+IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, AND/OR DISTRIBUTION OF THE
+APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function AppleScrollbar(scrollbar)
+{
+}
+
+/*
+ * _init() member function
+ * Initialize the scrollbar.
+ * pre: this.scrollbar
+ * post: this._thumb, this._track + event handlers
+ */
+AppleScrollbar.prototype._init = function()
+{
+        var style = null;
+        var element = null;
+                
+        // Scrollbar Track
+        this._track = document.createElement("div");
+        style = this._track.style;
+        // fill our containing div
+        style.height = "100%";
+        style.width = "100%";
+        this.scrollbar.appendChild(this._track);
+        
+        // Scrollbar Track Top
+        element = document.createElement("div");
+        element.style.position = "absolute";
+        this._setObjectStart(element, 0);
+        this._track.appendChild(element);
+        
+        // Scrollbar Track Middle
+        element = document.createElement("div");
+        element.style.position = "absolute";
+        this._track.appendChild(element);
+        
+        // Scrollbar Track Bottom
+        element = document.createElement("div");
+        element.style.position = "absolute";
+        this._setObjectEnd(element, 0);
+        this._track.appendChild(element);
+        
+        // Scrollbar Thumb
+        this._thumb = document.createElement("div");
+        style = this._thumb.style;
+        style.position = "absolute";
+        this._setObjectSize(this._thumb, this.minThumbSize); // default size
+        this._track.appendChild(this._thumb);
+        
+        // Scrollbar Thumb Top
+        element = document.createElement("div");
+        element.style.position = "absolute";
+        this._setObjectStart(element, 0);
+        this._thumb.appendChild(element);
+        
+        // Scrollbar Thumb Middle
+        element = document.createElement("div");
+        element.style.position = "absolute";
+        this._thumb.appendChild(element);
+        
+        // Scrollbar Thumb Bottom
+        element = document.createElement("div");
+        element.style.position = "absolute";
+        this._setObjectEnd(element, 0);
+        this._thumb.appendChild(element);
+        
+        // Set up styles
+        this.setSize(this.size);
+        
+        this.setTrackStart(this.trackStartPath, this.trackStartLength);
+        this.setTrackMiddle(this.trackMiddlePath);
+        this.setTrackEnd(this.trackEndPath, this.trackEndLength);
+        this.setThumbStart(this.thumbStartPath, this.thumbStartLength);
+        this.setThumbMiddle(this.thumbMiddlePath);
+        this.setThumbEnd(this.thumbEndPath, this.thumbEndLength);
+        
+        // hide the thumb until we refresh
+        this._thumb.style.display = "none";
+        
+        // Add event listeners
+        this._track.addEventListener("mousedown", this._mousedownTrackHandler, false);
+        this._thumb.addEventListener("mousedown", this._mousedownThumbHandler, false);
+        
+        // ScrollArea will fire a refresh for us
+}
+
+AppleScrollbar.prototype.remove = function()
+{
+        this.scrollbar.removeChild(this._track);
+}
+
+// Capture events that we don't handle but also don't want getting through
+AppleScrollbar.prototype._captureEvent = function(event)
+{
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+/*********************
+ * Thumb scroll events
+ */
+AppleScrollbar.prototype._mousedownThumb = function(event)
+{
+        // temporary event listeners
+        document.addEventListener("mousemove", this._mousemoveThumbHandler, true);
+        document.addEventListener("mouseup", this._mouseupThumbHandler, true);
+        document.addEventListener("mouseover", this._captureEventHandler, true);
+        document.addEventListener("mouseout", this._captureEventHandler, true);
+        
+        this._thumbStart_temp = this._getMousePosition(event);
+        
+        this._scroll_thumbStartPos = this._getThumbStartPos();
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+AppleScrollbar.prototype._mousemoveThumb = function(event)
+{
+        var delta = this._getMousePosition(event) - this._thumbStart_temp;
+        
+        var new_pos = this._scroll_thumbStartPos + delta;
+        this.scrollTo(this._contentPositionForThumbPosition(new_pos));
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+AppleScrollbar.prototype._mouseupThumb = function(event)
+{
+        // remove temporary event handlers
+        document.removeEventListener("mousemove", this._mousemoveThumbHandler, true);
+        document.removeEventListener("mouseup", this._mouseupThumbHandler, true);
+        document.removeEventListener("mouseover", this._captureEventHandler, true);
+        document.removeEventListener("mouseout", this._captureEventHandler, true);
+        
+        // remove temporary properties
+        delete this._thumbStart_temp;
+        delete this._scroll_thumbStartPos;
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+/*********************
+ * Track scroll events
+ */
+AppleScrollbar.prototype._mousedownTrack = function(event)
+{
+        this._track_mouse_temp = this._getMousePosition(event) - this._trackOffset;
+        
+        if (event.altKey)
+        {
+                this.scrollTo(this._contentPositionForThumbPosition(this._track_mouse_temp - (this._thumbLength / 2)));
+                delete this._track_mouse_temp;
+        }
+        else
+        {
+                this._track_scrolling = true;
+                
+                // temporary event handlers
+                this._track.addEventListener("mousemove", this._mousemoveTrackHandler, true);
+                this._track.addEventListener("mouseover", this._mouseoverTrackHandler, true);
+                this._track.addEventListener("mouseout", this._mouseoutTrackHandler, true);
+                document.addEventListener("mouseup", this._mouseupTrackHandler, true);
+                
+                this._trackScrollOnePage(this);
+                this._track_timer = setInterval(this._trackScrollDelay, 500, this);
+        }
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+AppleScrollbar.prototype._trackScrollDelay = function(self)
+{
+        if (!self._track_scrolling) return;
+        
+        clearInterval(self._track_timer);
+        
+        self._trackScrollOnePage(self);
+        self._track_timer = setInterval(self._trackScrollOnePage, 150, self);
+}
+
+AppleScrollbar.prototype._mousemoveTrack = function(event)
+{
+        this._track_mouse_temp = this._getMousePosition(event) - this._trackOffset;
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+AppleScrollbar.prototype._mouseoverTrack = function(event)
+{
+        this._track_mouse_temp = this._getMousePosition(event) - this._trackOffset;
+        this._track_scrolling = true;
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+AppleScrollbar.prototype._mouseoutTrack = function(event)
+{
+        this._track_scrolling = false;
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+AppleScrollbar.prototype._mouseupTrack = function(event)
+{
+        clearInterval(this._track_timer);
+        
+        // clear temporary event handlers
+        this._track.removeEventListener("mousemove", this._mousemoveTrackHandler, true);
+        this._track.removeEventListener("mouseover", this._mouseoverTrackHandler, true);
+        this._track.removeEventListener("mouseout", this._mouseoutTrackHandler, true);
+        document.removeEventListener("mouseup", this._mouseupTrackHandler, true);
+        
+        // remove temporary properties
+        delete this._track_mouse_temp;
+        delete this._track_scrolling;
+        delete this._track_timer;
+        
+        event.stopPropagation();
+        event.preventDefault();
+}
+
+AppleScrollbar.prototype._trackScrollOnePage = function(self)
+{
+        // this is called from setInterval, so we need a ptr to this
+        
+        if (!self._track_scrolling) return;
+        
+        var deltaScroll = Math.round(self._trackLength * self._getViewToContentRatio());
+        
+        if (self._track_mouse_temp < self._thumbStart)
+                self.scrollByThumbDelta(-deltaScroll);
+        else if (self._track_mouse_temp > (self._thumbStart + self._thumbLength))
+                self.scrollByThumbDelta(deltaScroll);
+}
+
+/*
+ * setScrollArea(scrollarea)
+ * Sets the AppleScrollArea this scrollbar is using.
+ */
+AppleScrollbar.prototype.setScrollArea = function(scrollarea)
+{
+        // if we already have a scrollarea, remove the mousewheel handler
+        if (this.scrollarea)
+        {
+                this.scrollbar.removeEventListener("mousewheel", this.scrollarea._mousewheelScrollHandler, true);
+        }
+        
+        this.scrollarea = scrollarea;
+        
+        // add mousewheel handler
+        this.scrollbar.addEventListener("mousewheel", this.scrollarea._mousewheelScrollHandler, true);
+}
+
+/*
+ * refresh()
+ * Refresh the scrollbar size and thumb position
+ */
+AppleScrollbar.prototype.refresh = function()
+{
+        this._trackOffset = this._computeTrackOffset();
+        this._trackLength = this._computeTrackLength();
+        
+        var ratio = this._getViewToContentRatio();
+        
+        if (ratio >= 1.0 || !this._canScroll())
+        {
+                if (this.autohide)
+                {
+                        // hide the scrollbar, all content is visible
+                        this.hide();
+                }
+                
+                // hide the thumb
+                this._thumb.style.display = "none";
+                this.scrollbar.style.appleDashboardRegion = "none";
+        }
+        else
+        {
+                this._thumbLength = Math.max(Math.round(this._trackLength * ratio), this.minThumbSize);
+                this._numScrollablePixels = this._trackLength - this._thumbLength - (2 * this.padding);
+                
+                this._setObjectLength(this._thumb, this._thumbLength);
+                                
+                // show the thumb
+                this._thumb.style.display = "block";
+                this.scrollbar.style.appleDashboardRegion = "dashboard-region(control rectangle)";
+                
+                this.show();
+        }
+        
+        // Make sure position is updated appropriately
+        this.verticalHasScrolled();
+        this.horizontalHasScrolled();
+}
+
+AppleScrollbar.prototype.setAutohide = function(autohide)
+{
+        this.autohide = autohide;
+        
+        // hide the scrollbar if necessary
+        if (this._getViewToContentRatio() >= 1.0 && autohide)
+        {
+                this.hide();
+        }
+        else
+        {
+                this.show();
+        }
+}
+
+AppleScrollbar.prototype.hide = function()
+{
+        this._track.style.display = "none";
+        this.hidden = true;
+}
+
+AppleScrollbar.prototype.show = function()
+{
+        this._track.style.display = "block";
+        this.hidden = false;
+}
+
+AppleScrollbar.prototype.setSize = function(size)
+{
+        this.size = size;
+        
+        this._setObjectSize(this.scrollbar, size);
+        this._setObjectSize(this._track.children[1], size);
+        this._setObjectSize(this._thumb.children[1], size);
+}
+
+AppleScrollbar.prototype.setTrackStart = function(imgpath, length)
+{
+        this.trackStartPath = imgpath;
+        this.trackStartLength = length;
+
+        var element = this._track.children[0];
+        element.style.background = "url(" + imgpath + ") no-repeat top left";
+        this._setObjectLength(element, length);
+        this._setObjectSize(element, this.size);
+        this._setObjectStart(this._track.children[1], length);
+}
+
+AppleScrollbar.prototype.setTrackMiddle = function(imgpath)
+{
+        this.trackMiddlePath = imgpath;
+
+        this._track.children[1].style.background = "url(" + imgpath + ") " + this._repeatType + " top left";
+}
+
+AppleScrollbar.prototype.setTrackEnd = function(imgpath, length)
+{
+        this.trackEndPath = imgpath;
+        this.trackEndLength = length;
+
+        var element = this._track.children[2];
+        element.style.background = "url(" + imgpath + ") no-repeat top left";
+        this._setObjectLength(element, length);
+        this._setObjectSize(element, this.size);
+        this._setObjectEnd(this._track.children[1], length);
+}
+
+AppleScrollbar.prototype.setThumbStart = function(imgpath, length)
+{
+        this.thumbStartPath = imgpath;
+        this.thumbStartLength = length;
+        
+        var element = this._thumb.children[0];
+        element.style.background = "url(" + imgpath + ") no-repeat top left";
+        this._setObjectLength(element, length);
+        this._setObjectSize(element, this.size);
+        this._setObjectStart(this._thumb.children[1], length);
+}
+
+AppleScrollbar.prototype.setThumbMiddle = function(imgpath)
+{
+        this.thumbMiddlePath = imgpath;
+        
+        this._thumb.children[1].style.background = "url(" + imgpath + ") " + this._repeatType + " top left";
+}
+
+AppleScrollbar.prototype.setThumbEnd = function(imgpath, length)
+{
+        this.thumbEndPath = imgpath;
+        this.thumbEndLength = length;
+
+        var element = this._thumb.children[2];
+        element.style.background = "url(" + imgpath + ") no-repeat top left";
+        this._setObjectLength(element, length);
+        this._setObjectSize(element, this.size);
+        this._setObjectEnd(this._thumb.children[1], length);
+}
+
+AppleScrollbar.prototype._contentPositionForThumbPosition = function(thumb_pos)
+{
+        // if we're currently displaying all content, we don't want it outside the view
+        if (this._getViewToContentRatio() >= 1.0)
+        {
+                return 0;
+        }
+        else
+        {
+                return (thumb_pos - this.padding) * ((this._getContentLength() - this._getViewLength()) / this._numScrollablePixels);
+        }
+}
+
+AppleScrollbar.prototype._thumbPositionForContentPosition = function(page_pos)
+{
+        // if we're currently displaying all content, we don't want it outside the view
+        if (this._getViewToContentRatio() >= 1.0)
+        {
+                return this.padding;
+        }
+        else
+        {
+                var result = this.padding - -(page_pos / ((this._getContentLength() - this._getViewLength()) / this._numScrollablePixels));
+                if (isNaN(result))
+                        result = 0;
+                return result;
+        }
+}
+
+AppleScrollbar.prototype.scrollByThumbDelta = function(deltaScroll)
+{
+        if (deltaScroll == 0)
+                return;
+        
+        this.scrollTo(this._contentPositionForThumbPosition(this._thumbStart + deltaScroll));
+}
+
+
+/*******************************************************************************
+ * AppleVerticalScrollbar
+ * Implementation of AppleScrollbar
+ *
+ *
+ */
+
+function AppleVerticalScrollbar(scrollbar)
+{
+        /* Objects */
+        this.scrollarea = null;
+        this.scrollbar = scrollbar;
+        
+        /* public properties */
+        // These are read-write. Set them as needed.
+        this.minThumbSize = 28;
+        this.padding = -1;
+        
+        // These are read-only. Use the setter functions to set them.
+        this.autohide = true;
+        this.hidden = true;
+        this.size = 19; // width
+        this.trackStartPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_track_vtop.png";
+        this.trackStartLength = 18; // height
+        this.trackMiddlePath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_track_vmid.png";
+        this.trackEndPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_track_vbottom.png";
+        this.trackEndLength = 18; // height
+        this.thumbStartPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_thumb_vtop.png";
+        this.thumbStartLength = 9; // height
+        this.thumbMiddlePath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_thumb_vmid.png";
+        this.thumbEndPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_thumb_vbottom.png";
+        this.thumbEndLength = 9; // height
+
+        /* Internal objects */
+        this._track = null;
+        this._thumb = null;
+        
+        /* Dimensions */
+        // these only need to be set during refresh()
+        this._trackOffset = 0;
+        this._trackLength = 0;
+        this._numScrollablePixels = 0;
+        this._thumbLength = 0;
+        this._repeatType = "repeat-y";
+        
+        // these change as the content is scrolled
+        this._thumbStart = this.padding;
+        
+        // For JavaScript event handlers
+        var _self = this;
+        
+        this._captureEventHandler = function(event) { _self._captureEvent(event); };
+        this._mousedownThumbHandler = function(event) { _self._mousedownThumb(event); };
+        this._mousemoveThumbHandler = function(event) { _self._mousemoveThumb(event); };
+        this._mouseupThumbHandler = function(event) { _self._mouseupThumb(event); };
+        this._mousedownTrackHandler = function(event) { _self._mousedownTrack(event); };
+        this._mousemoveTrackHandler = function(event) { _self._mousemoveTrack(event); };
+        this._mouseoverTrackHandler = function(event) { _self._mouseoverTrack(event); };
+        this._mouseoutTrackHandler = function(event) { _self._mouseoutTrack(event); };
+        this._mouseupTrackHandler = function(event) { _self._mouseupTrack(event); };
+        
+        this._init();
+}
+
+// Inherit from AppleScrollbar
+AppleVerticalScrollbar.prototype = new AppleScrollbar(null);
+
+
+/*********************
+ * Orientation-specific functions.
+ * These helper functions return vertical values.
+ */
+AppleVerticalScrollbar.prototype.scrollTo = function(pos)
+{
+        this.scrollarea.verticalScrollTo(pos);
+}
+
+AppleVerticalScrollbar.prototype._setObjectSize = function(object, size)
+{ object.style.width = size + "px"; }
+
+AppleVerticalScrollbar.prototype._setObjectLength = function(object, length)
+{ object.style.height = length + "px"; }
+
+AppleVerticalScrollbar.prototype._setObjectStart = function(object, start)
+{ object.style.top = start + "px"; }
+
+AppleVerticalScrollbar.prototype._setObjectEnd = function(object, end)
+{ object.style.bottom = end + "px"; }
+
+AppleVerticalScrollbar.prototype._getMousePosition = function(event)
+{
+        if (event != undefined)
+                return event.y;
+        else
+                return 0;
+}
+        
+AppleVerticalScrollbar.prototype._getThumbStartPos = function()
+{
+        return parseInt(document.defaultView.getComputedStyle(this._thumb, '').getPropertyValue("top"), 10);
+}
+
+AppleVerticalScrollbar.prototype._computeTrackOffset = function()
+{
+        // get the absolute top of the track
+        var obj = this.scrollbar;
+        var curtop = 0;
+        while (obj.offsetParent)
+        {
+                curtop += obj.offsetTop;
+                obj = obj.offsetParent;
+        }
+        
+        return curtop;
+}
+
+AppleVerticalScrollbar.prototype._computeTrackLength = function()
+{
+        // get the current actual track height
+        var style = document.defaultView.getComputedStyle(this.scrollbar, '');
+        return style ? parseInt(style.getPropertyValue("height"), 10) : 0;
+}
+
+AppleVerticalScrollbar.prototype._getViewToContentRatio = function()
+{ return this.scrollarea.viewToContentHeightRatio; }
+
+AppleVerticalScrollbar.prototype._getContentLength = function()
+{ return this.scrollarea.content.scrollHeight; }
+
+AppleVerticalScrollbar.prototype._getViewLength = function()
+{ return this.scrollarea.viewHeight; }
+
+AppleVerticalScrollbar.prototype._canScroll = function()
+{ return this.scrollarea.scrollsVertically; }
+
+
+AppleVerticalScrollbar.prototype.verticalHasScrolled = function()
+{
+        var new_thumb_pos = this._thumbPositionForContentPosition(this.scrollarea.content.scrollTop);
+        this._thumbStart = new_thumb_pos;
+        this._thumb.style.top = new_thumb_pos + "px";
+}
+
+AppleVerticalScrollbar.prototype.horizontalHasScrolled = function()
+{
+}
+
+
+
+/*******************************************************************************
+* AppleHorizontalScrollbar
+* Implementation of AppleScrollbar
+*
+*
+*/
+
+function AppleHorizontalScrollbar(scrollbar)
+{
+        /* Objects */
+        this.scrollarea = null;
+        this.scrollbar = scrollbar;
+        
+        /* public properties */
+        // These are read-write. Set them as needed.
+        this.minThumbSize = 28;
+        this.padding = -1;
+        
+        // These are read-only. Use the setter functions to set them.
+        this.autohide = true;
+        this.hidden = true;
+        this.size = 19; // height
+        this.trackStartPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_track_hleft.png";
+        this.trackStartLength = 18; // width
+        this.trackMiddlePath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_track_hmid.png";
+        this.trackEndPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_track_hright.png";
+        this.trackEndLength = 18; // width
+        this.thumbStartPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_thumb_hleft.png";
+        this.thumbStartLength = 9; // width
+        this.thumbMiddlePath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_thumb_hmid.png";
+        this.thumbEndPath = "file:///System/Library/WidgetResources/AppleClasses/Images/scroll_thumb_hright.png";
+        this.thumbEndLength = 9; // width
+        
+        /* Internal objects */
+        this._track = null;
+        this._thumb = null;
+        
+        /* Dimensions */
+        // these only need to be set during refresh()
+        this._trackOffset = 0;
+        this._trackLength = 0;
+        this._numScrollablePixels = 0;
+        this._thumbLength = 0;
+        this._repeatType = "repeat-x";
+        
+        // these change as the content is scrolled
+        this._thumbStart = this.padding;
+        
+        // For JavaScript event handlers
+        var _self = this;
+        
+        this._captureEventHandler = function(event) { _self._captureEvent(event); };
+        this._mousedownThumbHandler = function(event) { _self._mousedownThumb(event); };
+        this._mousemoveThumbHandler = function(event) { _self._mousemoveThumb(event); };
+        this._mouseupThumbHandler = function(event) { _self._mouseupThumb(event); };
+        this._mousedownTrackHandler = function(event) { _self._mousedownTrack(event); };
+        this._mousemoveTrackHandler = function(event) { _self._mousemoveTrack(event); };
+        this._mouseoverTrackHandler = function(event) { _self._mouseoverTrack(event); };
+        this._mouseoutTrackHandler = function(event) { _self._mouseoutTrack(event); };
+        this._mouseupTrackHandler = function(event) { _self._mouseupTrack(event); };
+        
+        this._init();
+}
+
+// Inherit from AppleScrollbar
+AppleHorizontalScrollbar.prototype = new AppleScrollbar(null);
+
+
+/*********************
+* Orientation-specific functions.
+* These helper functions return vertical values.
+*/
+AppleHorizontalScrollbar.prototype.scrollTo = function(pos)
+{
+        this.scrollarea.horizontalScrollTo(pos);
+}
+
+AppleHorizontalScrollbar.prototype._setObjectSize = function(object, size)
+{ object.style.height = size + "px"; }
+
+AppleHorizontalScrollbar.prototype._setObjectLength = function(object, length)
+{ object.style.width = length + "px"; }
+
+AppleHorizontalScrollbar.prototype._setObjectStart = function(object, start)
+{ object.style.left = start + "px"; }
+
+AppleHorizontalScrollbar.prototype._setObjectEnd = function(object, end)
+{ object.style.right = end + "px"; }
+
+AppleHorizontalScrollbar.prototype._getMousePosition = function(event)
+{
+        if (event != undefined)
+                return event.x;
+        else
+                return 0;
+}
+
+AppleHorizontalScrollbar.prototype._getThumbStartPos = function()
+{
+        return parseInt(document.defaultView.getComputedStyle(this._thumb, '').getPropertyValue("left"), 10);
+}
+
+AppleHorizontalScrollbar.prototype._computeTrackOffset = function()
+{
+        // get the absolute top of the track
+        var obj = this.scrollbar;
+        var curtop = 0;
+        while (obj.offsetParent)
+        {
+                curtop += obj.offsetLeft;
+                obj = obj.offsetParent;
+        }
+        
+        return curtop;
+}
+
+AppleHorizontalScrollbar.prototype._computeTrackLength = function()
+{
+        // get the current actual track height
+        var style = document.defaultView.getComputedStyle(this.scrollbar, '');
+        return style ? parseInt(style.getPropertyValue("width"), 10) : 0;
+}
+
+AppleHorizontalScrollbar.prototype._getViewToContentRatio = function()
+{ return this.scrollarea.viewToContentWidthRatio; }
+
+AppleHorizontalScrollbar.prototype._getContentLength = function()
+{ return this.scrollarea.content.scrollWidth; }
+
+AppleHorizontalScrollbar.prototype._getViewLength = function()
+{ return this.scrollarea.viewWidth; }
+
+AppleHorizontalScrollbar.prototype._canScroll = function()
+{ return this.scrollarea.scrollsHorizontally; }
+
+
+AppleHorizontalScrollbar.prototype.verticalHasScrolled = function()
+{
+}
+
+AppleHorizontalScrollbar.prototype.horizontalHasScrolled = function()
+{
+        var new_thumb_pos = this._thumbPositionForContentPosition(this.scrollarea.content.scrollLeft);
+        this._thumbStart = new_thumb_pos;
+        this._thumb.style.left = new_thumb_pos + "px";
+}
</ins><span class="cx">Property changes on: branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/AppleScrollbar.js
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: allow-tabs
</span><span class="cx"> + 1
</span></span></pre></div>
<a id="branchesWebInspectorRefreshWebKitWebInspectorwebInspectorinspectorhtml"></a>
<div class="modfile"><h4>Modified: branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html (20709 => 20710)</h4>
<pre class="diff"><span>
<span class="info">--- branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html        2007-04-05 01:05:49 UTC (rev 20709)
+++ branches/WebInspectorRefresh/WebKit/WebInspector/webInspector/inspector.html        2007-04-05 03:43:43 UTC (rev 20710)
</span><span class="lines">@@ -30,8 +30,8 @@
</span><span class="cx"> <head>
</span><span class="cx"> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</span><span class="cx"> <title>Web Inspector</title>
</span><del>- <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleScrollbar.js"></script>
- <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleScrollArea.js"></script>
</del><ins>+ <script type="text/javascript" src="AppleScrollbar.js"></script>
+ <script type="text/javascript" src="AppleScrollArea.js"></script>
</ins><span class="cx"> <script type="text/javascript" src="inspector.js"></script>
</span><span class="cx"> <link rel="stylesheet" type="text/css" href="inspector.css" />
</span><span class="cx"> </head>
</span></span></pre>
</div>
</div>
</body>
</html>