Title: [107935] trunk/Source/WebCore
Revision
107935
Author
[email protected]
Date
2012-02-16 07:38:42 -0800 (Thu, 16 Feb 2012)

Log Message

Web Inspector: explicitly mark undoable state from the front-end.
https://bugs.webkit.org/show_bug.cgi?id=78716

Reviewed by Vsevolod Vlasov.

* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::toggleProperty):
(WebCore::InspectorCSSAgent::setRuleSelector):
(WebCore::InspectorCSSAgent::addRule):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::setAttributeValue):
(WebCore::InspectorDOMAgent::setAttributesAsText):
(WebCore::InspectorDOMAgent::removeAttribute):
(WebCore::InspectorDOMAgent::removeNode):
(WebCore::InspectorDOMAgent::setNodeName):
(WebCore::InspectorDOMAgent::setOuterHTML):
(WebCore::InspectorDOMAgent::setNodeValue):
(WebCore::InspectorDOMAgent::moveTo):
* inspector/InspectorHistory.cpp:
(WebCore::InspectorHistory::redo):
* inspector/InspectorHistory.h:
(InspectorHistory):
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel.prototype.setRuleSelector.callback):
(WebInspector.CSSStyleModel.prototype.setRuleSelector):
(WebInspector.CSSStyleModel.prototype.addRule.callback):
(WebInspector.CSSStyleModel.prototype.addRule):
(WebInspector.CSSStyleModel.prototype.setStyleSheetText):
(WebInspector.CSSProperty.prototype.setText.callback):
(WebInspector.CSSProperty.prototype.setText):
(WebInspector.CSSProperty.prototype.setDisabled.callback):
(WebInspector.CSSProperty.prototype.setDisabled):
(WebInspector.CSSStyleSheet.prototype.setText):
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMAgent.prototype._markRevision):
(WebInspector.DOMAgent.prototype.get markUndoableState):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107934 => 107935)


--- trunk/Source/WebCore/ChangeLog	2012-02-16 15:36:39 UTC (rev 107934)
+++ trunk/Source/WebCore/ChangeLog	2012-02-16 15:38:42 UTC (rev 107935)
@@ -1,5 +1,44 @@
 2012-02-15  Pavel Feldman  <[email protected]>
 
+        Web Inspector: explicitly mark undoable state from the front-end.
+        https://bugs.webkit.org/show_bug.cgi?id=78716
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::toggleProperty):
+        (WebCore::InspectorCSSAgent::setRuleSelector):
+        (WebCore::InspectorCSSAgent::addRule):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::setAttributeValue):
+        (WebCore::InspectorDOMAgent::setAttributesAsText):
+        (WebCore::InspectorDOMAgent::removeAttribute):
+        (WebCore::InspectorDOMAgent::removeNode):
+        (WebCore::InspectorDOMAgent::setNodeName):
+        (WebCore::InspectorDOMAgent::setOuterHTML):
+        (WebCore::InspectorDOMAgent::setNodeValue):
+        (WebCore::InspectorDOMAgent::moveTo):
+        * inspector/InspectorHistory.cpp:
+        (WebCore::InspectorHistory::redo):
+        * inspector/InspectorHistory.h:
+        (InspectorHistory):
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModel.prototype.setRuleSelector.callback):
+        (WebInspector.CSSStyleModel.prototype.setRuleSelector):
+        (WebInspector.CSSStyleModel.prototype.addRule.callback):
+        (WebInspector.CSSStyleModel.prototype.addRule):
+        (WebInspector.CSSStyleModel.prototype.setStyleSheetText):
+        (WebInspector.CSSProperty.prototype.setText.callback):
+        (WebInspector.CSSProperty.prototype.setText):
+        (WebInspector.CSSProperty.prototype.setDisabled.callback):
+        (WebInspector.CSSProperty.prototype.setDisabled):
+        (WebInspector.CSSStyleSheet.prototype.setText):
+        * inspector/front-end/DOMAgent.js:
+        (WebInspector.DOMAgent.prototype._markRevision):
+        (WebInspector.DOMAgent.prototype.get markUndoableState):
+
+2012-02-15  Pavel Feldman  <[email protected]>
+
         Web Inspector: revert 'modification of DOM upon single click for selected nodes'.
         https://bugs.webkit.org/show_bug.cgi?id=78717
 

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (107934 => 107935)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2012-02-16 15:36:39 UTC (rev 107934)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2012-02-16 15:38:42 UTC (rev 107935)
@@ -711,7 +711,6 @@
     if (success)
         result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId));
     *errorString = InspectorDOMAgent::toErrorString(ec);
-    m_domAgent->history()->markUndoableState();
 }
 
 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<InspectorObject>& fullRuleId, const String& selector, RefPtr<InspectorObject>& result)
@@ -731,7 +730,6 @@
 
     if (success)
         result = inspectorStyleSheet->buildObjectForRule(inspectorStyleSheet->ruleForId(compoundId));
-    m_domAgent->history()->markUndoableState();
 }
 
 void InspectorCSSAgent::addRule(ErrorString* errorString, const int contextNodeId, const String& selector, RefPtr<InspectorObject>& result)
@@ -758,7 +756,6 @@
     InspectorCSSId ruleId = rawAction->newRuleId();
     CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId);
     result = inspectorStyleSheet->buildObjectForRule(rule);
-    m_domAgent->history()->markUndoableState();
 }
 
 void InspectorCSSAgent::getSupportedCSSProperties(ErrorString*, RefPtr<InspectorArray>& cssProperties)

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (107934 => 107935)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-02-16 15:36:39 UTC (rev 107934)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-02-16 15:38:42 UTC (rev 107935)
@@ -538,7 +538,6 @@
         return;
 
     m_domEditor->setAttribute(element, name, value, errorString);
-    m_history->markUndoableState();
 }
 
 void InspectorDOMAgent::setAttributesAsText(ErrorString* errorString, int elementId, const String& text, const String* const name)
@@ -569,7 +568,6 @@
     Element* childElement = toElement(child);
     if (!childElement->hasAttributes() && name) {
         m_domEditor->removeAttribute(element, *name, errorString);
-        m_history->markUndoableState();
         return;
     }
 
@@ -585,8 +583,6 @@
 
     if (!foundOriginalAttribute && name && !name->stripWhiteSpace().isEmpty())
         m_domEditor->removeAttribute(element, *name, errorString);
-
-    m_history->markUndoableState();
 }
 
 void InspectorDOMAgent::removeAttribute(ErrorString* errorString, int elementId, const String& name)
@@ -596,7 +592,6 @@
         return;
 
     m_domEditor->removeAttribute(element, name, errorString);
-    m_history->markUndoableState();
 }
 
 void InspectorDOMAgent::removeNode(ErrorString* errorString, int nodeId)
@@ -612,7 +607,6 @@
     }
 
     m_domEditor->removeChild(parentNode, node, errorString);
-    m_history->markUndoableState();
 }
 
 void InspectorDOMAgent::setNodeName(ErrorString* errorString, int nodeId, const String& tagName, int* newId)
@@ -644,7 +638,6 @@
         return;
     if (!m_domEditor->removeChild(parent, oldNode, errorString))
         return;
-    m_history->markUndoableState();
 
     *newId = pushNodePathToFrontend(newElem.get());
     if (m_childrenRequested.contains(nodeId))
@@ -681,7 +674,6 @@
     Node* newNode = 0;
     if (!m_domEditor->setOuterHTML(node, outerHTML, &newNode, errorString))
         return;
-    m_history->markUndoableState();
 
     if (!newNode) {
         // The only child node has been deleted.
@@ -707,7 +699,6 @@
     }
 
     m_domEditor->replaceWholeText(toText(node), value, errorString);
-    m_history->markUndoableState();
 }
 
 void InspectorDOMAgent::getEventListenersForNode(ErrorString*, int nodeId, RefPtr<InspectorArray>& listenersArray)
@@ -1067,7 +1058,6 @@
 
     if (!m_domEditor->insertBefore(targetElement, node, anchorNode, errorString))
         return;
-    m_history->markUndoableState();
 
     *newNodeId = pushNodePathToFrontend(node);
 }

Modified: trunk/Source/WebCore/inspector/InspectorHistory.cpp (107934 => 107935)


--- trunk/Source/WebCore/inspector/InspectorHistory.cpp	2012-02-16 15:36:39 UTC (rev 107934)
+++ trunk/Source/WebCore/inspector/InspectorHistory.cpp	2012-02-16 15:38:42 UTC (rev 107935)
@@ -134,7 +134,7 @@
     while (m_afterLastActionIndex < m_history.size()) {
         Action* action = ""
         if (!action->redo(ec)) {
-            m_history.resize(m_afterLastActionIndex);
+            m_history.clear();
             return false;
         }
         ++m_afterLastActionIndex;

Modified: trunk/Source/WebCore/inspector/InspectorHistory.h (107934 => 107935)


--- trunk/Source/WebCore/inspector/InspectorHistory.h	2012-02-16 15:36:39 UTC (rev 107934)
+++ trunk/Source/WebCore/inspector/InspectorHistory.h	2012-02-16 15:38:42 UTC (rev 107935)
@@ -78,7 +78,6 @@
     void reset();
 
 private:
-    void dump();
     Vector<OwnPtr<Action> > m_history;
     size_t m_afterLastActionIndex;
 };

Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (107934 => 107935)


--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-02-16 15:36:39 UTC (rev 107934)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-02-16 15:38:42 UTC (rev 107935)
@@ -191,6 +191,7 @@
             if (error)
                 failureCallback();
             else {
+                WebInspector.domAgent.markUndoableState();
                 var ownerDocumentId = this._ownerDocumentId(nodeId);
                 if (ownerDocumentId)
                     WebInspector.domAgent.querySelectorAll(ownerDocumentId, newSelector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
@@ -235,6 +236,7 @@
                 // Invalid syntax for a selector
                 failureCallback();
             } else {
+                WebInspector.domAgent.markUndoableState();
                 var ownerDocumentId = this._ownerDocumentId(nodeId);
                 if (ownerDocumentId)
                     WebInspector.domAgent.querySelectorAll(ownerDocumentId, selector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
@@ -284,13 +286,14 @@
         function callback(error)
         {
             this._pendingCommandsMajorState.pop();
+            if (!error && majorChange)
+                WebInspector.domAgent.markUndoableState();
+            
             if (!error && userCallback)
                 userCallback(error);
         }
         this._pendingCommandsMajorState.push(majorChange);
         CSSAgent.setStyleSheetText(styleSheetId, newText, callback.bind(this));
-        if (majorChange)
-            DOMAgent.markUndoableState();
     },
 
     _undoRedoRequested: function()
@@ -629,6 +632,8 @@
         {
             WebInspector.cssModel._pendingCommandsMajorState.pop();
             if (!error) {
+                if (majorChange)
+                    WebInspector.domAgent.markUndoableState();
                 this.text = propertyText;
                 var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
                 var newProperty = style.allProperties[this.index];
@@ -652,8 +657,6 @@
         // An index past all the properties adds a new property to the style.
         WebInspector.cssModel._pendingCommandsMajorState.push(majorChange);
         CSSAgent.setPropertyText(this.ownerStyle.id, this.index, propertyText, this.index < this.ownerStyle.pastLastSourcePropertyIndex(), callback.bind(this));
-        if (majorChange)
-            DOMAgent.markUndoableState();
     },
 
     setValue: function(newValue, majorChange, userCallback)
@@ -677,6 +680,7 @@
                     userCallback(null);
                 return;
             }
+            WebInspector.domAgent.markUndoableState();
             if (userCallback) {
                 var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
                 userCallback(style);
@@ -760,6 +764,9 @@
     {
         function callback(error)
         {
+            if (!error)
+                WebInspector.domAgent.markUndoableState();
+
             WebInspector.cssModel._pendingCommandsMajorState.pop();
             if (userCallback)
                 userCallback(error);

Modified: trunk/Source/WebCore/inspector/front-end/DOMAgent.js (107934 => 107935)


--- trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2012-02-16 15:36:39 UTC (rev 107934)
+++ trunk/Source/WebCore/inspector/front-end/DOMAgent.js	2012-02-16 15:38:42 UTC (rev 107935)
@@ -1117,6 +1117,9 @@
     {
         function wrapperFunction(error)
         {
+            if (!error)
+                this.markUndoableState();
+
             if (callback)
                 callback.apply(this, arguments);
             if (error || !WebInspector.experimentsSettings.freeFlowDOMEditing.isEnabled())
@@ -1163,6 +1166,11 @@
         DOMAgent.setTouchEmulationEnabled(WebInspector.settings.emulateTouchEvents.get());
     },
 
+    markUndoableState: function()
+    {
+        DOMAgent.markUndoableState();
+    },
+
     /**
      * @param {function(?Protocol.Error)=} callback
      */
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to