Title: [193041] branches/safari-601-branch/Source/WebInspectorUI
- Revision
- 193041
- Author
- [email protected]
- Date
- 2015-12-03 10:34:26 -0800 (Thu, 03 Dec 2015)
Log Message
Merge r187625. rdar://problem/23221163
Modified Paths
Diff
Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193040 => 193041)
--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog 2015-12-03 18:34:20 UTC (rev 193040)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog 2015-12-03 18:34:26 UTC (rev 193041)
@@ -1,5 +1,31 @@
2015-12-01 Timothy Hatcher <[email protected]>
+ Merge r187625. rdar://problem/23221163
+
+ 2015-07-30 Devin Rousso <[email protected]>
+
+ Web Inspector: Support smart-pasting in the Rules sidebar panel
+ https://bugs.webkit.org/show_bug.cgi?id=147362
+
+ Reviewed by Timothy Hatcher.
+
+ When pasting over the selector, if the pasted text matches CSS rule
+ formatting, replace the selected rule with the selector and text in
+ the pasted data.
+
+ * UserInterface/Models/DOMNodeStyles.js:
+ (WebInspector.DOMNodeStyles.prototype.changeRule.changeCompleted):
+ (WebInspector.DOMNodeStyles.prototype.changeRule.styleChanged):
+ (WebInspector.DOMNodeStyles.prototype.changeRule.changeText):
+ (WebInspector.DOMNodeStyles.prototype.changeRule.ruleSelectorChanged):
+ (WebInspector.DOMNodeStyles.prototype.changeRule):
+ * UserInterface/Views/CSSStyleDeclarationSection.js:
+ (WebInspector.CSSStyleDeclarationSection.prototype._handleSelectorPaste.parseTextForRule):
+ (WebInspector.CSSStyleDeclarationSection.prototype._handleSelectorPaste):
+ (WebInspector.CSSStyleDeclarationSection):
+
+2015-12-01 Timothy Hatcher <[email protected]>
+
Merge r187619. rdar://problem/23221163
2015-07-30 Matt Baker <[email protected]>
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js (193040 => 193041)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js 2015-12-03 18:34:20 UTC (rev 193040)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js 2015-12-03 18:34:26 UTC (rev 193041)
@@ -322,6 +322,52 @@
this._markAsNeedsRefresh();
}
+ changeRule(rule, selector, text)
+ {
+ if (!rule)
+ return;
+
+ selector = selector || "";
+
+ function changeCompleted()
+ {
+ DOMAgent.markUndoableState();
+ this.refresh();
+ }
+
+ function styleChanged(error, stylePayload)
+ {
+ if (error)
+ return;
+
+ changeCompleted.call(this);
+ }
+
+ function changeText(styleId)
+ {
+ // COMPATIBILITY (iOS 6): CSSAgent.setStyleText was not available in iOS 6.
+ if (!text || !text.length || !CSSAgent.setStyleText) {
+ changeCompleted.call(this);
+ return;
+ }
+
+ CSSAgent.setStyleText(styleId, text, styleChanged.bind(this));
+ }
+
+ function ruleSelectorChanged(error, rulePayload)
+ {
+ if (error)
+ return;
+
+ changeText.call(this, rulePayload.style.styleId);
+ }
+
+ this._needsRefresh = true;
+ this._ignoreNextContentDidChangeForStyleSheet = rule.ownerStyleSheet;
+
+ CSSAgent.setRuleSelector(rule.id, selector, ruleSelectorChanged.bind(this));
+ }
+
changeRuleSelector(rule, selector)
{
selector = selector || "";
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js (193040 => 193041)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-12-03 18:34:20 UTC (rev 193040)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js 2015-12-03 18:34:26 UTC (rev 193041)
@@ -52,6 +52,7 @@
this._selectorElement.addEventListener("mouseout", this._handleMouseOut.bind(this));
this._selectorElement.addEventListener("keydown", this._handleKeyDown.bind(this));
this._selectorElement.addEventListener("keyup", this._handleKeyUp.bind(this));
+ this._selectorElement.addEventListener("paste", this._handleSelectorPaste.bind(this));
this._headerElement.appendChild(this._selectorElement);
this._originElement = document.createElement("span");
@@ -399,6 +400,43 @@
return selectorText.trim();
},
+ _handleSelectorPaste: function(event)
+ {
+ if (this._style.type === WebInspector.CSSStyleDeclaration.Type.Inline || !this._style.ownerRule)
+ return;
+
+ if (!event || !event.clipboardData)
+ return;
+
+ var data = ""
+ if (!data)
+ return;
+
+ function parseTextForRule(text)
+ {
+ var containsBraces = /[\{\}]/;
+ if (!containsBraces.test(text))
+ return null;
+
+ var match = text.match(/([^{]+){(.*)}/);
+ if (!match)
+ return null;
+
+ // If the match "body" contains braces, parse that body as if it were a rule.
+ // This will usually happen if the user includes a media query in the copied text.
+ return containsBraces.test(match[2]) ? parseTextForRule(match[2]) : match;
+ }
+
+ var match = parseTextForRule(data);
+ if (!match)
+ return;
+
+ var selector = match[1].trim();
+ this._selectorElement.textContent = selector;
+ this._style.nodeStyles.changeRule(this._style.ownerRule, selector, match[2]);
+ event.preventDefault();
+ },
+
_handleContextMenuEvent: function(event)
{
if (window.getSelection().toString().length)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes