- Revision
- 214844
- Author
- mattba...@apple.com
- Date
- 2017-04-03 15:09:23 -0700 (Mon, 03 Apr 2017)
Log Message
Web Inspector: Elements tab: show indicators for hidden DOM breakpoints
https://bugs.webkit.org/show_bug.cgi?id=168761
Reviewed by Timothy Hatcher.
* Localizations/en.lproj/localizedStrings.js:
New DOM breakpoint content menu item.
* UserInterface/Views/DOMTreeContentView.css:
(.content-view.dom-tree .tree-outline.dom li .status-image.breakpoint.subtree):
(.content-view.dom-tree .tree-outline.dom li.expanded .status-image.breakpoint.subtree):
New styles for collapsed breakpoint marker.
* UserInterface/Views/DOMTreeElement.js:
(WebInspector.DOMTreeElement):
(WebInspector.DOMTreeElement.prototype.set breakpointStatus):
If the status change indicates the only breakpoint was added or removed,
update subtree breakpoint counts on the element's parent chain.
(WebInspector.DOMTreeElement.prototype.revealAndHighlight):
Reveal the tree element, and add a highlighted line animation
identical to the one used used by TextEditor.
(WebInspector.DOMTreeElement.prototype.subtreeBreakpointCountDidChange):
(WebInspector.DOMTreeElement.prototype.updateSelectionArea):
Selection area should be updated when animating the element highlight.
(WebInspector.DOMTreeElement.prototype.onreveal):
Animate highlight if needed.
(WebInspector.DOMTreeElement.prototype._updateBreakpointStatus):
(WebInspector.DOMTreeElement.prototype._statusImageClicked):
Do nothing when clicking the collapsed breakpoint marker.
(WebInspector.DOMTreeElement.prototype._statusImageContextmenu):
Add "Reveal Breakpoint" menu item. Reveals the first descendant
with at least one breakpoint.
(WebInspector.DOMTreeElement.prototype._highlightAnimationEnd):
* UserInterface/Views/DOMTreeOutline.css:
(@keyframes dom-tree-outline-highlight-fadeout):
(.highlight .selection-area):
Styles for highlight fade animation.
* UserInterface/Views/TreeElement.js:
(WebInspector.TreeElement.prototype.selfOrDescendant):
* UserInterface/Views/TreeOutline.js:
(WebInspector.TreeOutline.prototype.selfOrDescendant):
Find a node matching a predicate.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (214843 => 214844)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-04-03 22:07:46 UTC (rev 214843)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-04-03 22:09:23 UTC (rev 214844)
@@ -1,5 +1,55 @@
2017-04-03 Matt Baker <mattba...@apple.com>
+ Web Inspector: Elements tab: show indicators for hidden DOM breakpoints
+ https://bugs.webkit.org/show_bug.cgi?id=168761
+
+ Reviewed by Timothy Hatcher.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ New DOM breakpoint content menu item.
+
+ * UserInterface/Views/DOMTreeContentView.css:
+ (.content-view.dom-tree .tree-outline.dom li .status-image.breakpoint.subtree):
+ (.content-view.dom-tree .tree-outline.dom li.expanded .status-image.breakpoint.subtree):
+ New styles for collapsed breakpoint marker.
+
+ * UserInterface/Views/DOMTreeElement.js:
+ (WebInspector.DOMTreeElement):
+ (WebInspector.DOMTreeElement.prototype.set breakpointStatus):
+ If the status change indicates the only breakpoint was added or removed,
+ update subtree breakpoint counts on the element's parent chain.
+
+ (WebInspector.DOMTreeElement.prototype.revealAndHighlight):
+ Reveal the tree element, and add a highlighted line animation
+ identical to the one used used by TextEditor.
+
+ (WebInspector.DOMTreeElement.prototype.subtreeBreakpointCountDidChange):
+ (WebInspector.DOMTreeElement.prototype.updateSelectionArea):
+ Selection area should be updated when animating the element highlight.
+ (WebInspector.DOMTreeElement.prototype.onreveal):
+ Animate highlight if needed.
+ (WebInspector.DOMTreeElement.prototype._updateBreakpointStatus):
+ (WebInspector.DOMTreeElement.prototype._statusImageClicked):
+ Do nothing when clicking the collapsed breakpoint marker.
+ (WebInspector.DOMTreeElement.prototype._statusImageContextmenu):
+ Add "Reveal Breakpoint" menu item. Reveals the first descendant
+ with at least one breakpoint.
+
+ (WebInspector.DOMTreeElement.prototype._highlightAnimationEnd):
+
+ * UserInterface/Views/DOMTreeOutline.css:
+ (@keyframes dom-tree-outline-highlight-fadeout):
+ (.highlight .selection-area):
+ Styles for highlight fade animation.
+
+ * UserInterface/Views/TreeElement.js:
+ (WebInspector.TreeElement.prototype.selfOrDescendant):
+ * UserInterface/Views/TreeOutline.js:
+ (WebInspector.TreeOutline.prototype.selfOrDescendant):
+ Find a node matching a predicate.
+
+2017-04-03 Matt Baker <mattba...@apple.com>
+
Web Inspector: DetailsSection should hide header "options" when collapsed
https://bugs.webkit.org/show_bug.cgi?id=170029
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (214843 => 214844)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2017-04-03 22:07:46 UTC (rev 214843)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2017-04-03 22:09:23 UTC (rev 214844)
@@ -682,6 +682,7 @@
localizedStrings["Retained Size"] = "Retained Size";
localizedStrings["Return type for anonymous function"] = "Return type for anonymous function";
localizedStrings["Return type for function: %s"] = "Return type for function: %s";
+localizedStrings["Reveal Breakpoint"] = "Reveal Breakpoint";
localizedStrings["Reveal in DOM Tree"] = "Reveal in DOM Tree";
localizedStrings["Reveal in Debugger Tab"] = "Reveal in Debugger Tab";
localizedStrings["Reveal in Original Resource"] = "Reveal in Original Resource";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.css (214843 => 214844)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.css 2017-04-03 22:07:46 UTC (rev 214843)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.css 2017-04-03 22:09:23 UTC (rev 214844)
@@ -84,3 +84,12 @@
fill: var(--breakpoint-unresolved-disabled-fill-color);
stroke: var(--breakpoint-unresolved-disabled-stroke-color);
}
+
+.content-view.dom-tree .tree-outline.dom li .status-image.breakpoint.subtree {
+ fill: none;
+ opacity: 0.6;
+}
+
+.content-view.dom-tree .tree-outline.dom li.expanded .status-image.breakpoint.subtree {
+ display: none;
+}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (214843 => 214844)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2017-04-03 22:07:46 UTC (rev 214843)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2017-04-03 22:09:23 UTC (rev 214844)
@@ -42,6 +42,10 @@
this._searchQuery = null;
this._expandedChildrenLimit = WebInspector.DOMTreeElement.InitialChildrenLimit;
this._breakpointStatus = WebInspector.DOMTreeElement.BreakpointStatus.None;
+ this._animatingHighlight = false;
+ this._shouldHighlightAfterReveal = false;
+ this._boundHighlightAnimationEnd = this._highlightAnimationEnd.bind(this);
+ this._subtreeBreakpointCount = 0;
this._recentlyModifiedAttributes = [];
this._boundNodeChangedAnimationEnd = this._nodeChangedAnimationEnd.bind(this);
@@ -75,10 +79,40 @@
if (this._breakpointStatus === status)
return;
+ let increment;
+ if (this._breakpointStatus === WebInspector.DOMTreeElement.BreakpointStatus.None)
+ increment = 1;
+ else if (status === WebInspector.DOMTreeElement.BreakpointStatus.None)
+ increment = -1;
+
this._breakpointStatus = status;
this._updateBreakpointStatus();
+
+ if (!increment)
+ return;
+
+ let parentElement = this.parent;
+ while (parentElement && !parentElement.root) {
+ parentElement.subtreeBreakpointCountDidChange(increment);
+ parentElement = parentElement.parent;
+ }
}
+ revealAndHighlight()
+ {
+ if (this._animatingHighlight)
+ return;
+
+ this._shouldHighlightAfterReveal = true;
+ this.reveal();
+ }
+
+ subtreeBreakpointCountDidChange(increment)
+ {
+ this._subtreeBreakpointCount += increment;
+ this._updateBreakpointStatus();
+ }
+
isCloseTag()
{
return this._elementCloseTag;
@@ -298,7 +332,7 @@
return;
// If there's no reason to have a selection area, remove the DOM element.
- let indicatesTreeOutlineState = this.treeOutline && (this.treeOutline.dragOverTreeElement === this || this.treeOutline.selectedTreeElement === this);
+ let indicatesTreeOutlineState = this.treeOutline && (this.treeOutline.dragOverTreeElement === this || this.treeOutline.selectedTreeElement === this || this._animatingHighlight);
if (!this.hovered && !this.pseudoClassesEnabled && !indicatesTreeOutlineState) {
if (this._selectionElement) {
this._selectionElement.remove();
@@ -534,13 +568,26 @@
onreveal()
{
- if (this.listItemElement) {
- var tagSpans = this.listItemElement.getElementsByClassName("html-tag-name");
- if (tagSpans.length)
- tagSpans[0].scrollIntoViewIfNeeded(false);
- else
- this.listItemElement.scrollIntoViewIfNeeded(false);
- }
+ let listItemElement = this.listItemElement;
+ if (!listItemElement)
+ return;
+
+ let tagSpans = listItemElement.getElementsByClassName("html-tag-name");
+ if (tagSpans.length)
+ tagSpans[0].scrollIntoViewIfNeeded(false);
+ else
+ listItemElement.scrollIntoViewIfNeeded(false);
+
+ if (!this._shouldHighlightAfterReveal)
+ return;
+
+ this._shouldHighlightAfterReveal = false;
+ this._animatingHighlight = true;
+
+ this.updateSelectionArea();
+
+ listItemElement.addEventListener("animationend", this._boundHighlightAnimationEnd);
+ listItemElement.classList.add(WebInspector.DOMTreeElement.HighlightStyleClassName);
}
onselect(treeElement, selectedByUser)
@@ -1675,7 +1722,10 @@
if (!listItemElement)
return;
- if (this._breakpointStatus === WebInspector.DOMTreeElement.BreakpointStatus.None) {
+ let hasBreakpoint = this._breakpointStatus !== WebInspector.DOMTreeElement.BreakpointStatus.None;
+ let hasSubtreeBreakpoints = !!this._subtreeBreakpointCount;
+
+ if (!hasBreakpoint && !hasSubtreeBreakpoints) {
if (this._statusImageElement)
this._statusImageElement.remove();
return;
@@ -1689,6 +1739,8 @@
this._statusImageElement.addEventListener("mousedown", (event) => { event.stopPropagation(); });
}
+ this._statusImageElement.classList.toggle("subtree", !hasBreakpoint && hasSubtreeBreakpoints);
+
this.listItemElement.insertBefore(this._statusImageElement, this.listItemElement.firstChild);
let disabled = this._breakpointStatus === WebInspector.DOMTreeElement.BreakpointStatus.DisabledBreakpoint;
@@ -1697,6 +1749,9 @@
_statusImageClicked(event)
{
+ if (this._breakpointStatus === WebInspector.DOMTreeElement.BreakpointStatus.None)
+ return;
+
if (event.button !== 0 || event.ctrlKey)
return;
@@ -1710,11 +1765,39 @@
_statusImageContextmenu(event)
{
- const allowEditing = true;
+ let hasBreakpoint = this._breakpointStatus !== WebInspector.DOMTreeElement.BreakpointStatus.None;
+ let hasSubtreeBreakpoints = !!this._subtreeBreakpointCount;
+ if (!hasBreakpoint && !hasSubtreeBreakpoints)
+ return;
let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
- WebInspector.DOMBreakpointTreeController.appendBreakpointContextMenuItems(contextMenu, this.representedObject, allowEditing);
+ if (hasBreakpoint) {
+ const allowEditing = true;
+ WebInspector.DOMBreakpointTreeController.appendBreakpointContextMenuItems(contextMenu, this.representedObject, allowEditing);
+ return;
+ }
+
+ contextMenu.appendItem(WebInspector.UIString("Reveal Breakpoint"), () => {
+ let breakpointTreeElement = this.selfOrDescendant((treeElement) => treeElement.breakpointStatus && treeElement.breakpointStatus !== WebInspector.DOMTreeElement.BreakpointStatus.None);
+ console.assert(breakpointTreeElement, "Missing breakpoint descendant.", this)
+ if (!breakpointTreeElement)
+ return;
+
+ breakpointTreeElement.revealAndHighlight();
+ });
}
+
+ _highlightAnimationEnd()
+ {
+ let listItemElement = this.listItemElement;
+ if (!listItemElement)
+ return;
+
+ listItemElement.removeEventListener("animationend", this._boundHighlightAnimationEnd);
+ listItemElement.classList.remove(WebInspector.DOMTreeElement.HighlightStyleClassName);
+
+ this._animatingHighlight = false;
+ }
};
WebInspector.DOMTreeElement.InitialChildrenLimit = 500;
@@ -1743,5 +1826,6 @@
DisabledBreakpoint: Symbol("disabled-breakpoint"),
};
+WebInspector.DOMTreeElement.HighlightStyleClassName = "highlight";
WebInspector.DOMTreeElement.SearchHighlightStyleClassName = "search-highlight";
WebInspector.DOMTreeElement.BouncyHighlightStyleClassName = "bouncy-highlight";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css (214843 => 214844)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css 2017-04-03 22:07:46 UTC (rev 214843)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css 2017-04-03 22:09:23 UTC (rev 214844)
@@ -295,3 +295,11 @@
.node-state-changed {
animation: node-state-changed 1s cubic-bezier(0.25, 0, 0.25, 1);
}
+
+@keyframes dom-tree-outline-highlight-fadeout {
+ from { background-color: highlight; }
+}
+
+.highlight .selection-area {
+ animation: "dom-tree-outline-highlight-fadeout" 2s;
+}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js (214843 => 214844)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js 2017-04-03 22:07:46 UTC (rev 214843)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js 2017-04-03 22:09:23 UTC (rev 214844)
@@ -63,6 +63,7 @@
removeChildAtIndex() { return WebInspector.TreeOutline.prototype.removeChildAtIndex.apply(this, arguments); }
removeChildren() { return WebInspector.TreeOutline.prototype.removeChildren.apply(this, arguments); }
removeChildrenRecursive() { return WebInspector.TreeOutline.prototype.removeChildrenRecursive.apply(this, arguments); }
+ selfOrDescendant() { return WebInspector.TreeOutline.prototype.selfOrDescendant.apply(this, arguments); }
get arrowToggleWidth()
{
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js (214843 => 214844)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js 2017-04-03 22:07:46 UTC (rev 214843)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js 2017-04-03 22:09:23 UTC (rev 214844)
@@ -397,6 +397,20 @@
return null;
}
+ selfOrDescendant(predicate)
+ {
+ let treeElements = [this];
+ while (treeElements.length) {
+ let treeElement = treeElements.shift();
+ if (predicate(treeElement))
+ return treeElement;
+
+ treeElements = treeElements.concat(treeElement.children);
+ }
+
+ return false;
+ }
+
findTreeElement(representedObject, isAncestor, getParent)
{
if (!representedObject)