Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(906)

Unified Diff: third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js

Issue 2393763002: [DevTools] Cleanup DOMExtension.js. (Closed)
Patch Set: review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
diff --git a/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js b/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
index 4c1cf24b4f71b55007cabc9c561b55050889f03f..9174e09b04c65098459a8255852b0d057b443b12 100644
--- a/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
+++ b/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
@@ -181,30 +181,6 @@ Element.prototype.isScrolledToBottom = function()
}
/**
- * @param {!Node} fromNode
- * @param {!Node} toNode
- */
-function removeSubsequentNodes(fromNode, toNode)
-{
- for (var node = fromNode; node && node !== toNode;) {
- var nodeToRemove = node;
- node = node.nextSibling;
- nodeToRemove.remove();
- }
-}
-
-/**
- * @param {!Event} event
- * @return {boolean}
- */
-Element.prototype.containsEventPoint = function(event)
-{
- var box = this.getBoundingClientRect();
- return box.left < event.x && event.x < box.right &&
- box.top < event.y && event.y < box.bottom;
-}
-
-/**
* @param {!Array.<string>} nameArray
* @return {?Node}
*/
@@ -338,15 +314,6 @@ Node.prototype.window = function()
return this.ownerDocument.defaultView;
}
-/**
- * @param {string} query
- * @return {?Node}
- */
-Element.prototype.query = function(query)
-{
- return this.ownerDocument.evaluate(query, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
-}
-
Element.prototype.removeChildren = function()
{
if (this.firstChild)
@@ -354,19 +321,6 @@ Element.prototype.removeChildren = function()
}
/**
- * @return {boolean}
- */
-Element.prototype.isInsertionCaretInside = function()
-{
- var selection = this.getComponentSelection();
- // @see crbug.com/602541
- var selectionRange = selection && selection.rangeCount ? selection.getRangeAt(0) : null;
- if (!selectionRange || !selection.isCollapsed)
- return false;
- return selectionRange.startContainer.isSelfOrDescendant(this);
-}
-
-/**
* @param {string} tagName
* @param {string=} customElementType
* @return {!Element}
@@ -378,20 +332,6 @@ function createElement(tagName, customElementType)
}
/**
- * @param {string} type
- * @param {boolean} bubbles
- * @param {boolean} cancelable
- * @return {!Event}
- * @suppressGlobalPropertiesCheck
- */
-function createEvent(type, bubbles, cancelable)
-{
- var event = document.createEvent("Event");
- event.initEvent(type, bubbles, cancelable);
- return event;
-}
-
-/**
* @param {number|string} data
* @return {!Text}
* @suppressGlobalPropertiesCheck
@@ -525,20 +465,6 @@ Element.prototype.totalOffset = function()
}
/**
- * @return {!{left: number, top: number}}
- */
-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 };
-}
-
-/**
* @param {string} childType
* @param {string=} className
* @return {!Element}
@@ -594,52 +520,31 @@ AnchorBox.prototype.equals = function(anchorBox)
}
/**
- * @param {!Window} targetWindow
+ * @param {!Window=} targetWindow
* @return {!AnchorBox}
*/
-Element.prototype.offsetRelativeToWindow = function(targetWindow)
+Element.prototype.boxInWindow = function(targetWindow)
{
- var elementOffset = new AnchorBox();
+ targetWindow = targetWindow || this.ownerDocument.defaultView;
+
+ var anchorBox = new AnchorBox();
var curElement = this;
var curWindow = this.ownerDocument.defaultView;
while (curWindow && curElement) {
- elementOffset.x += curElement.totalOffsetLeft();
- elementOffset.y += curElement.totalOffsetTop();
+ anchorBox.x += curElement.totalOffsetLeft();
+ anchorBox.y += curElement.totalOffsetTop();
if (curWindow === targetWindow)
break;
-
curElement = curWindow.frameElement;
curWindow = curWindow.parent;
}
- return elementOffset;
-}
-
-/**
- * @param {!Window=} targetWindow
- * @return {!AnchorBox}
- */
-Element.prototype.boxInWindow = function(targetWindow)
-{
- targetWindow = targetWindow || this.ownerDocument.defaultView;
-
- var anchorBox = this.offsetRelativeToWindow(window);
- anchorBox.width = Math.min(this.offsetWidth, window.innerWidth - anchorBox.x);
- anchorBox.height = Math.min(this.offsetHeight, window.innerHeight - anchorBox.y);
-
+ anchorBox.width = Math.min(this.offsetWidth, targetWindow.innerWidth - anchorBox.x);
+ anchorBox.height = Math.min(this.offsetHeight, targetWindow.innerHeight - anchorBox.y);
return anchorBox;
}
/**
- * @param {string} text
- */
-Element.prototype.setTextAndTitle = function(text)
-{
- this.textContent = text;
- this.title = text;
-}
-
-/**
* @param {boolean=} preventDefault
*/
Event.prototype.consume = function(preventDefault)
@@ -698,32 +603,6 @@ Element.prototype.selectionLeftOffset = function()
}
/**
- * @this {!HTMLImageElement} element
- * @return {!Promise<!HTMLImageElement>}
- */
-HTMLImageElement.prototype.completePromise = function()
-{
- var element = this;
- if (element.complete)
- return Promise.resolve(element);
- return new Promise(promiseBody);
-
- /**
- * @param {function(!HTMLImageElement)} resolve
- */
- function promiseBody(resolve)
- {
- element.addEventListener("load", oncomplete);
- element.addEventListener("error", oncomplete);
-
- function oncomplete()
- {
- resolve(element);
- }
- }
-}
-
-/**
* @param {...!Node} var_args
*/
Node.prototype.appendChildren = function(var_args)
@@ -907,15 +786,6 @@ Event.prototype.deepElementFromPoint = function()
}
/**
- * @return {?Element}
- */
-Event.prototype.deepActiveElement = function()
-{
- var document = this.target && this.target.ownerDocument;
- return document ? document.deepActiveElement() : null;
-}
-
-/**
* @param {number} x
* @param {number} y
* @return {?Node}
@@ -982,11 +852,6 @@ function isEscKey(event)
return event.keyCode === 27;
}
-function consumeEvent(e)
-{
- e.consume();
-}
-
/**
* @param {function()} callback
* @suppressGlobalPropertiesCheck

Powered by Google App Engine
This is Rietveld 408576698