WebKit Bugzilla
Attachment 340397 Details for
Bug 185644
: Web Inspector: create a navigation item for toggling the overlay rulers/guides
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
185644.diff (text/plain), 16.08 KB, created by
Devin Rousso
on 2018-05-15 01:17:20 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2018-05-15 01:17:20 PDT
Size:
16.08 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 44947af03a8..002481e78e7 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,13 @@ >+2018-05-15 Devin Rousso <webkit@devinrousso.com> >+ >+ Web Inspector: create a navigation item for toggling the overlay rulers/guides >+ https://bugs.webkit.org/show_bug.cgi?id=185644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/protocol/OverlayTypes.json: >+ * inspector/protocol/Page.json: >+ > 2018-05-15 Devin Rousso <webkit@devinrousso.com> > > Web Inspector: Add rulers and guides >diff --git a/Source/JavaScriptCore/inspector/protocol/OverlayTypes.json b/Source/JavaScriptCore/inspector/protocol/OverlayTypes.json >index e8e45397839..4a6abf164ec 100644 >--- a/Source/JavaScriptCore/inspector/protocol/OverlayTypes.json >+++ b/Source/JavaScriptCore/inspector/protocol/OverlayTypes.json >@@ -97,7 +97,8 @@ > { "name": "pageScaleFactor", "type": "number" }, > { "name": "pageZoomFactor", "type": "number" }, > { "name": "scrollOffset", "$ref": "Point" }, >- { "name": "contentInset", "$ref": "Size" } >+ { "name": "contentInset", "$ref": "Size" }, >+ { "name": "shouldDrawRulers", "type": "boolean" } > ] > } > ] >diff --git a/Source/JavaScriptCore/inspector/protocol/Page.json b/Source/JavaScriptCore/inspector/protocol/Page.json >index 6e8b09f5355..f36bf87043d 100644 >--- a/Source/JavaScriptCore/inspector/protocol/Page.json >+++ b/Source/JavaScriptCore/inspector/protocol/Page.json >@@ -165,6 +165,13 @@ > { "name": "result", "type": "array", "items": { "$ref": "SearchResult" }, "description": "List of search results." } > ] > }, >+ { >+ "name": "setShouldDrawRulers", >+ "description": "Requests that backend draw rulers in the inspector overlay", >+ "parameters": [ >+ { "name": "result", "type": "boolean", "description": "True for showing rulers" } >+ ] >+ }, > { > "name": "setShowPaintRects", > "description": "Requests that backend shows paint rectangles", >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d9acc2349fd..1d7faf0cde2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2018-05-15 Devin Rousso <webkit@devinrousso.com> >+ >+ Web Inspector: create a navigation item for toggling the overlay rulers/guides >+ https://bugs.webkit.org/show_bug.cgi?id=185644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch is purely a visual change for WebInspector, and doesn't affect anything else. >+ >+ * inspector/agents/InspectorPageAgent.h: >+ * inspector/agents/InspectorPageAgent.cpp: >+ (WebCore::InspectorPageAgent::setShouldDrawRulers): >+ >+ * inspector/InspectorOverlay.h: >+ * inspector/InspectorOverlay.cpp: >+ (WebCore::InspectorOverlay::setShouldDrawRulers): >+ (WebCore::InspectorOverlay::reset): >+ >+ * inspector/InspectorOverlayPage.js: >+ (drawNodeHighlight): >+ (drawQuadHighlight): >+ (reset): >+ > 2018-05-15 Devin Rousso <webkit@devinrousso.com> > > Web Inspector: Add rulers and guides >diff --git a/Source/WebCore/inspector/InspectorOverlay.cpp b/Source/WebCore/inspector/InspectorOverlay.cpp >index 6e6655ed67c..6ef46a21bf2 100644 >--- a/Source/WebCore/inspector/InspectorOverlay.cpp >+++ b/Source/WebCore/inspector/InspectorOverlay.cpp >@@ -392,6 +392,16 @@ void InspectorOverlay::showPaintRect(const FloatRect& rect) > forcePaint(); > } > >+void InspectorOverlay::setShouldDrawRulers(bool shouldDrawRulers) >+{ >+ if (m_shouldDrawRulers == shouldDrawRulers) >+ return; >+ >+ m_shouldDrawRulers = shouldDrawRulers; >+ >+ update(); >+} >+ > void InspectorOverlay::updatePaintRectsTimerFired() > { > MonotonicTime now = MonotonicTime::now(); >@@ -742,6 +752,7 @@ void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& scroll > .setPageZoomFactor(m_page.mainFrame().pageZoomFactor()) > .setScrollOffset(buildObjectForPoint(scrollOffset)) > .setContentInset(buildObjectForSize(IntSize(0, m_page.mainFrame().view()->topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset)))) >+ .setShouldDrawRulers(m_shouldDrawRulers) > .release(); > evaluateInOverlay("reset", WTFMove(configObject)); > } >diff --git a/Source/WebCore/inspector/InspectorOverlay.h b/Source/WebCore/inspector/InspectorOverlay.h >index 38ba850f46e..0d554f6ff04 100644 >--- a/Source/WebCore/inspector/InspectorOverlay.h >+++ b/Source/WebCore/inspector/InspectorOverlay.h >@@ -115,6 +115,8 @@ public: > > void setShowingPaintRects(bool); > void showPaintRect(const FloatRect&); >+ >+ void setShouldDrawRulers(bool); > > Node* highlightedNode() const; > >@@ -157,6 +159,7 @@ private: > Timer m_paintRectUpdateTimer; > bool m_indicating {false}; > bool m_showingPaintRects {false}; >+ bool m_shouldDrawRulers {false}; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/inspector/InspectorOverlayPage.js b/Source/WebCore/inspector/InspectorOverlayPage.js >index 714d8a66ab3..6d8d9daf07e 100644 >--- a/Source/WebCore/inspector/InspectorOverlayPage.js >+++ b/Source/WebCore/inspector/InspectorOverlayPage.js >@@ -64,10 +64,12 @@ function drawNodeHighlight(allHighlights) > }); > } > >- _drawRulers({ >- mirrorX: bounds.minY < DATA.contentInset.height + gridSize && bounds.maxY < DATA.viewportSize.height - gridSize, >- mirrorY: bounds.minX < DATA.contentInset.width + gridSize && bounds.maxX < DATA.viewportSize.width - gridSize, >- }); >+ if (DATA.shouldDrawRulers) { >+ _drawRulers({ >+ mirrorX: bounds.minY < DATA.contentInset.height + gridSize && bounds.maxY < DATA.viewportSize.height - gridSize, >+ mirrorY: bounds.minX < DATA.contentInset.width + gridSize && bounds.maxX < DATA.viewportSize.width - gridSize, >+ }); >+ } > > if (allHighlights.length === 1) { > for (let fragment of allHighlights[0].fragments) >@@ -83,10 +85,12 @@ function drawQuadHighlight(highlight) > _drawOutlinedQuad(highlight.quads[0], highlight.contentColor, highlight.contentOutlineColor, bounds); > }); > >- _drawRulers({ >- mirrorX: bounds.minY < DATA.contentInset.height + gridSize && bounds.maxY < DATA.viewportSize.height - gridSize, >- mirrorY: bounds.minX < DATA.contentInset.width + gridSize && bounds.maxX < DATA.viewportSize.width - gridSize, >- }); >+ if (DATA.shouldDrawRulers) { >+ _drawRulers({ >+ mirrorX: bounds.minY < DATA.contentInset.height + gridSize && bounds.maxY < DATA.viewportSize.height - gridSize, >+ mirrorY: bounds.minX < DATA.contentInset.width + gridSize && bounds.maxX < DATA.viewportSize.width - gridSize, >+ }); >+ } > } > > function quadEquals(quad1, quad2) >@@ -121,6 +125,7 @@ function reset(payload) > DATA.pageZoomFactor = payload.pageZoomFactor; > DATA.scrollOffset = payload.scrollOffset; > DATA.contentInset = payload.contentInset; >+ DATA.shouldDrawRulers = payload.shouldDrawRulers; > > window.canvas = document.getElementById("canvas"); > window.paintRectsCanvas = document.getElementById("paintrects-canvas"); >diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >index aee9f585699..cdcb9c48c08 100644 >--- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >@@ -542,6 +542,11 @@ void InspectorPageAgent::searchInResources(ErrorString&, const String& text, con > networkAgent->searchOtherRequests(regex, result); > } > >+void InspectorPageAgent::setShouldDrawRulers(ErrorString&, bool shouldDrawRulers) >+{ >+ m_overlay->setShouldDrawRulers(shouldDrawRulers); >+} >+ > void InspectorPageAgent::setShowPaintRects(ErrorString&, bool show) > { > m_showPaintRects = show; >diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.h b/Source/WebCore/inspector/agents/InspectorPageAgent.h >index 10296b38c7d..5d9d349c197 100644 >--- a/Source/WebCore/inspector/agents/InspectorPageAgent.h >+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.h >@@ -97,6 +97,7 @@ public: > void getResourceContent(ErrorString&, const String& frameId, const String& url, String* content, bool* base64Encoded) final; > void searchInResource(ErrorString&, const String& frameId, const String& url, const String& query, const bool* optionalCaseSensitive, const bool* optionalIsRegex, const String* optionalRequestId, RefPtr<JSON::ArrayOf<Inspector::Protocol::GenericTypes::SearchMatch>>&) final; > void searchInResources(ErrorString&, const String&, const bool* caseSensitive, const bool* isRegex, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::SearchResult>>&) final; >+ void setShouldDrawRulers(ErrorString&, bool) final; > void setShowPaintRects(ErrorString&, bool show) final; > void setEmulatedMedia(ErrorString&, const String&) final; > void getCompositingBordersVisible(ErrorString&, bool* out_param) final; >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 7d35625c1b9..93f78d0da14 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,19 @@ >+2018-05-15 Devin Rousso <webkit@devinrousso.com> >+ >+ Web Inspector: create a navigation item for toggling the overlay rulers/guides >+ https://bugs.webkit.org/show_bug.cgi?id=185644 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Localizations/en.lproj/localizedStrings.js: >+ * UserInterface/Base/Setting.js: >+ * UserInterface/Views/DOMTreeContentView.js: >+ (WI.DOMTreeContentView): >+ (WI.DOMTreeContentView.prototype.get navigationItems): >+ (WI.DOMTreeContentView.prototype.closed): >+ (WI.DOMTreeContentView.prototype._shouldDrawRulersChanged): Added. >+ (WI.DOMTreeContentView.prototype._toggleShouldDrawRulers): Added. >+ > 2018-05-14 Devin Rousso <webkit@devinrousso.com> > > Web Inspector: Canvas tab: don't automatically select a recording when viewing a canvas >diff --git a/Source/WebInspectorUI/UserInterface/Images/Rulers.svg b/Source/WebInspectorUI/UserInterface/Images/Rulers.svg >new file mode 100644 >index 00000000000..65f1b0bc4f9 >--- /dev/null >+++ b/Source/WebInspectorUI/UserInterface/Images/Rulers.svg >@@ -0,0 +1,11 @@ >+<?xml version="1.0" encoding="utf-8"?> >+<!-- Copyright © 2018 Apple Inc. All rights reserved. --> >+<svg xmlns="http://www.w3.org/2000/svg" id="root" version="1.1" viewBox="0 0 16 16"> >+ <polygon points="1.5 1.5 14.5 1.5 14.5 5.5 5.5 5.5 5.5 14.5 1.5 14.5 1.5 1.5" fill="none" stroke="currentColor"/> >+ <line x1="8.5" y1="3" x2="8.5" y2="5" stroke="currentColor"/> >+ <line x1="11.5" y1="3" x2="11.5" y2="5" stroke="currentColor"/> >+ <line x1="5.5" y1="3" x2="5.5" y2="5" stroke="currentColor"/> >+ <line x1="3" y1="11.5" x2="5" y2="11.5" stroke="currentColor"/> >+ <line x1="3" y1="8.5" x2="5" y2="8.5" stroke="currentColor"/> >+ <line x1="3" y1="5.5" x2="5" y2="5.5" stroke="currentColor"/> >+</svg> >diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >index 803d9d41e85..284d62b5c24 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -320,6 +320,7 @@ localizedStrings["Domain"] = "Domain"; > localizedStrings["Done"] = "Done"; > localizedStrings["Download"] = "Download"; > localizedStrings["Download Web Archive"] = "Download Web Archive"; >+localizedStrings["Draw Rulers"] = "Draw Rulers"; > localizedStrings["Duplicate Selector"] = "Duplicate Selector"; > localizedStrings["Duplicate property"] = "Duplicate property"; > localizedStrings["Duplicate property â%sâ.\nClick to delete this property."] = "Duplicate property â%sâ.\nClick to delete this property."; >@@ -481,6 +482,7 @@ localizedStrings["Hide Console"] = "Hide Console"; > localizedStrings["Hide Console (%s)"] = "Hide Console (%s)"; > localizedStrings["Hide Grid"] = "Hide Grid"; > localizedStrings["Hide Path"] = "Hide Path"; >+localizedStrings["Hide Rulers"] = "Hide Rulers"; > localizedStrings["Hide compositing borders"] = "Hide compositing borders"; > localizedStrings["Hide shadow DOM nodes"] = "Hide shadow DOM nodes"; > localizedStrings["Hide the details sidebar (%s)"] = "Hide the details sidebar (%s)"; >diff --git a/Source/WebInspectorUI/UserInterface/Base/Setting.js b/Source/WebInspectorUI/UserInterface/Base/Setting.js >index 09a73be2eb3..086037fdc0b 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Setting.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Setting.js >@@ -121,6 +121,7 @@ WI.settings = { > showImageGrid: new WI.Setting("show-image-grid", false), > showCanvasPath: new WI.Setting("show-canvas-path", false), > selectedNetworkDetailContentViewIdentifier: new WI.Setting("network-detail-content-view-identifier", "preview"), >+ shouldDrawRulers: new WI.Setting("should-draw-rulers", true), > > // Experimental > experimentalEnableLayersTab: new WI.Setting("experimental-enable-layers-tab", false), >diff --git a/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js b/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js >index a6809848167..de0710769de 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js >@@ -54,6 +54,12 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView > this._showPrintStylesButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low; > this._showPrintStylesChanged(); > >+ WI.settings.shouldDrawRulers.addEventListener(WI.Setting.Event.Changed, this._shouldDrawRulersChanged, this); >+ this._shouldDrawRulersButtonNavigationItem = new WI.ActivateButtonNavigationItem("should-draw-rulers", WI.UIString("Draw Rulers"), WI.UIString("Hide Rulers"), "Images/Rulers.svg", 16, 16); >+ this._shouldDrawRulersButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._toggleShouldDrawRulers, this); >+ this._shouldDrawRulersButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low; >+ this._shouldDrawRulersChanged(); >+ > this.element.classList.add("dom-tree"); > this.element.addEventListener("click", this._mouseWasClicked.bind(this), false); > >@@ -92,7 +98,7 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView > > get navigationItems() > { >- let items = [this._showPrintStylesButtonNavigationItem, this._showsShadowDOMButtonNavigationItem]; >+ let items = [this._shouldDrawRulersButtonNavigationItem, this._showPrintStylesButtonNavigationItem, this._showsShadowDOMButtonNavigationItem]; > if (!WI.settings.experimentalEnableLayersTab.value) > items.push(this._compositingBordersButtonNavigationItem, this._paintFlashingButtonNavigationItem); > >@@ -150,6 +156,7 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView > > WI.showPaintRectsSetting.removeEventListener(null, null, this); > WI.showShadowDOMSetting.removeEventListener(null, null, this); >+ WI.settings.shouldDrawRulers.removeEventListener(null, null, this); > WI.debuggerManager.removeEventListener(null, null, this); > WI.domTreeManager.removeEventListener(null, null, this); > WI.domDebuggerManager.removeEventListener(null, null, this); >@@ -567,6 +574,20 @@ WI.DOMTreeContentView = class DOMTreeContentView extends WI.ContentView > this._showPrintStylesChanged(); > } > >+ _shouldDrawRulersChanged() >+ { >+ this._shouldDrawRulersButtonNavigationItem.activated = WI.settings.shouldDrawRulers.value; >+ >+ PageAgent.setShouldDrawRulers(this._shouldDrawRulersButtonNavigationItem.activated); >+ } >+ >+ _toggleShouldDrawRulers(event) >+ { >+ WI.settings.shouldDrawRulers.value = !WI.settings.shouldDrawRulers.value; >+ >+ this._shouldDrawRulersChanged(); >+ } >+ > _showSearchHighlights() > { > console.assert(this._searchIdentifier);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185644
:
340397
|
340454
|
340456
|
340480
|
340544