Bug 381422 - Cannot click on overlay scrollbar on Mac Lion
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
index c4b4bb1..0d685de 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
@@ -1012,6 +1012,9 @@
 			}
 		}
 	};
+	
+	/* There is no way of getting the overlay scroll bar width */
+	var overlayScrollWidth = 15;
 
 	/**
 	 * @class This object describes the options for the text view.
@@ -3223,6 +3226,7 @@
 			var oldX = this._hScroll;
 			var oldY = this._vScroll;
 			if (oldX !== scroll.x || oldY !== scroll.y) {
+				this._checkOverlayScroll();
 				this._hScroll = scroll.x;
 				this._vScroll = scroll.y;
 				this._commitIME();
@@ -4048,6 +4052,24 @@
 			};
 			return {lineHeight: lineHeight, largestFontStyle: style, lineTrim: trim, viewPadding: pad, scrollWidth: scrollWidth, invalid: invalid};
 		},
+		_checkOverlayScroll: function() {
+			if (!util.isMac) { return; }
+			var that = this;
+			var window = this._getWindow();
+			if (this._overlayScrollTimer) {
+				window.clearTimeout(this._overlayScrollTimer);
+			}
+			var check = function() {
+				var over = that._isOverOverlayScroll();
+				if (over.vertical || over.horizontal) {
+					that._overlayScrollTimer = window.setTimeout(check, 200);
+				} else {
+					that._overlayScrollTimer = undefined;
+					that._update();
+				}
+			};
+			this._overlayScrollTimer = window.setTimeout(check, 200);
+		},
 		_clearSelection: function (direction) {
 			var selection = this._getSelection();
 			if (selection.isEmpty()) { return false; }
@@ -4296,7 +4318,7 @@
 			index = index === undefined || index < 0 || index > length ? length : index;
 			var cell = row.insertCell(index);
 			cell.vAlign = "top"; //$NON-NLS-0$
-			cell.style.verticalAlign = "top";
+			cell.style.verticalAlign = "top"; //$NON-NLS-0$
 			cell.style.borderWidth = "0px"; //$NON-NLS-0$
 			cell.style.margin = "0px"; //$NON-NLS-0$
 			cell.style.padding = "0px"; //$NON-NLS-0$
@@ -5092,6 +5114,18 @@
 			this._createActions();
 			this._createView();
 		},
+		_isOverOverlayScroll: function() {
+			if (!util.isMac) {
+				return {};
+			}
+			var rect = this._viewDiv.getBoundingClientRect();
+			var x = this._lastMouseMoveX;
+			var y = this._lastMouseMoveY;
+			return {
+				vertical: rect.top <= y && y < rect.bottom && rect.right - overlayScrollWidth <= x && x < rect.right,
+				horizontal: rect.bottom - overlayScrollWidth <= y && y < rect.bottom && rect.left <= x && x < rect.right
+			};
+		},
 		_modifyContent: function(e, updateCaret) {
 			if (this._readonly && !e._code) {
 				return;
@@ -6177,8 +6211,9 @@
 				}
 				clipDiv.style.left = clipLeft + "px"; //$NON-NLS-0$
 				clipDiv.style.top = clipTop + "px"; //$NON-NLS-0$
-				clipDiv.style.right = (parentWidth - clipWidth - clipLeft) + "px"; //$NON-NLS-0$
-				clipDiv.style.bottom = (parentHeight - clipHeight - clipTop) + "px"; //$NON-NLS-0$
+				var over = this._isOverOverlayScroll();
+				clipDiv.style.right = (parentWidth - clipWidth - clipLeft + (this._overlayScrollTimer && over.vertical ? overlayScrollWidth : 0)) + "px"; //$NON-NLS-0$
+				clipDiv.style.bottom = (parentHeight - clipHeight - clipTop + (this._overlayScrollTimer && over.horizontal ? overlayScrollWidth : 0)) + "px"; //$NON-NLS-0$
 				clientDiv.style.left = clientLeft + "px"; //$NON-NLS-0$
 				clientDiv.style.top = clientTop + "px"; //$NON-NLS-0$
 				clientDiv.style.width = scrollWidth + "px"; //$NON-NLS-0$