+2012-02-01 Brian Grinstead <briangrinstead@gmail.com>
+
+ Web Inspector: Add changes for Spectrum colorpicker
+ https://bugs.webkit.org/show_bug.cgi?id=75454
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/front-end/Color.js:
+ (WebInspector.Color.fromRGB):
+ * inspector/front-end/utilities.js:
+ (Element.prototype.totalOffsetLeft):
+ (Element.prototype.totalOffsetTop):
+ (Element.prototype.totalOffset):
+ (Element.prototype.scrollOffset):
+ ():
+
2012-02-08 Alexander Pavlov <apavlov@chromium.org>
Web Inspector: Avoid an avalanche of "class" attribute modifications in WatchExpressionsSidebarPane
return new WebInspector.Color("rgba(" + r + "," + g + "," + b + "," + (typeof a === "undefined" ? 1 : a) + ")");
}
+WebInspector.Color.fromRGB = function(r, g, b)
+{
+ return new WebInspector.Color("rgb(" + r + "," + g + "," + b + ")");
+}
+
WebInspector.Color.prototype = {
/**
* @return {string}
*/
Element.prototype.totalOffsetLeft = function()
{
- var total = 0;
- for (var element = this; element; element = element.offsetParent) {
- total += element.offsetLeft
- if (this !== element)
- total += element.clientLeft - element.scrollLeft;
- }
-
- return total;
+ return this.totalOffset().left;
}
/**
*/
Element.prototype.totalOffsetTop = function()
{
- var total = 0;
+ return this.totalOffset().top;
+
+}
+
+Element.prototype.totalOffset = function()
+{
+ var totalLeft = 0;
+ var totalTop = 0;
+
for (var element = this; element; element = element.offsetParent) {
- total += element.offsetTop
- if (this !== element)
- total += element.clientTop - element.scrollTop;
+ totalLeft += element.offsetLeft;
+ totalTop += element.offsetTop;
+ if (this !== element) {
+ totalLeft += element.clientLeft - element.scrollLeft;
+ totalTop += element.clientTop - element.scrollTop;
+ }
}
-
- return total;
+
+ return { left: totalLeft, top: totalTop };
+}
+
+Element.prototype.scrollOffset = function()
+{
+ var curLeft = 0;
+ var curTop = 0;
+ for (var element = this; element; element = element.scrollParent) {
+ curLeft += element.scrollLeft;
+ curTop += element.scrollTop;
+ }
+ return { left: curLeft, top: curTop };
}
/**
return event.keyCode !== 229 && event.keyIdentifier === "Enter";
}
+function stopPropagation(e)
+{
+ e.stopPropagation();
+}
+
/**
* @param {Element} element
* @param {number} offset