Diff
Modified: trunk/LayoutTests/ChangeLog (108234 => 108235)
--- trunk/LayoutTests/ChangeLog 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/LayoutTests/ChangeLog 2012-02-20 13:11:40 UTC (rev 108235)
@@ -1,3 +1,13 @@
+2012-02-20 Alexander Pavlov <[email protected]>
+
+ Web Inspector: DOMAttrModified should not be fired if the attribute value remains the same
+ https://bugs.webkit.org/show_bug.cgi?id=79025
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/elements/set-attribute-expected.txt:
+ * inspector/elements/set-attribute.html:
+
2012-02-20 Yosifumi Inoue <[email protected]>
[Forms] Spin buttons of number input type should fire both input and change event
Modified: trunk/LayoutTests/inspector/elements/set-attribute-expected.txt (108234 => 108235)
--- trunk/LayoutTests/inspector/elements/set-attribute-expected.txt 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/LayoutTests/inspector/elements/set-attribute-expected.txt 2012-02-20 13:11:40 UTC (rev 108235)
@@ -9,6 +9,10 @@
===== On attribute set =====
<div id="node" name="value"></div>
+Running: testAttributeSameValueNotUpdated
+===== On attribute modified (should be 'newValue') =====
+ <div id="node" name="newValue"></div>
+
Running: testAttributeRemoved
=== On attribute removed ===
<div id="node"></div>
Modified: trunk/LayoutTests/inspector/elements/set-attribute.html (108234 => 108235)
--- trunk/LayoutTests/inspector/elements/set-attribute.html 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/LayoutTests/inspector/elements/set-attribute.html 2012-02-20 13:11:40 UTC (rev 108235)
@@ -46,6 +46,22 @@
InspectorTest.evaluateInPage("setAttribute('name', 'value')");
},
+ function testAttributeSameValueNotUpdated(next)
+ {
+ function callback()
+ {
+ InspectorTest.addResult("===== On attribute modified (should be 'newValue') =====");
+ InspectorTest.dumpElementsTree(targetNode);
+ WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events.AttrModified, callback);
+ next();
+ }
+ WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.AttrModified, callback);
+ // Setting the same property value should not result in the AttrModified event.
+ InspectorTest.evaluateInPage("setAttribute('name', 'value')");
+ InspectorTest.evaluateInPage("setAttribute('name', 'value')");
+ InspectorTest.evaluateInPage("setAttribute('name', 'newValue')");
+ },
+
function testAttributeRemoved(next)
{
function callback()
Modified: trunk/Source/WebCore/ChangeLog (108234 => 108235)
--- trunk/Source/WebCore/ChangeLog 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/Source/WebCore/ChangeLog 2012-02-20 13:11:40 UTC (rev 108235)
@@ -1,3 +1,25 @@
+2012-02-20 Alexander Pavlov <[email protected]>
+
+ Web Inspector: DOMAttrModified should not be fired if the attribute value remains the same
+ https://bugs.webkit.org/show_bug.cgi?id=79025
+
+ Reviewed by Pavel Feldman.
+
+ * dom/Element.cpp:
+ (WebCore::Element::willModifyAttribute):
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::InspectorDOMAgent):
+ (WebCore::InspectorDOMAgent::willModifyDOMAttr):
+ (WebCore):
+ (WebCore::InspectorDOMAgent::didModifyDOMAttr):
+ * inspector/InspectorDOMAgent.h:
+ (InspectorDOMAgent):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl):
+ * inspector/InspectorInstrumentation.h:
+ (InspectorInstrumentation):
+ (WebCore::InspectorInstrumentation::willModifyDOMAttr):
+
2012-02-20 Kwonjin Jeong <[email protected]>
Correct a typo error in ScrollingCoordinator.h
Modified: trunk/Source/WebCore/dom/Element.cpp (108234 => 108235)
--- trunk/Source/WebCore/dom/Element.cpp 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-02-20 13:11:40 UTC (rev 108235)
@@ -2005,7 +2005,7 @@
#if ENABLE(INSPECTOR)
if (!isSynchronizingStyleAttribute())
- InspectorInstrumentation::willModifyDOMAttr(document(), this);
+ InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newValue);
#endif
}
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (108234 => 108235)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-02-20 13:11:40 UTC (rev 108235)
@@ -197,6 +197,7 @@
, m_domListener(0)
, m_lastNodeId(1)
, m_searchingForNode(false)
+ , m_suppressAttributeModifiedEvent(false)
{
}
@@ -1401,8 +1402,18 @@
unbind(node, &m_documentNodeToIdMap);
}
+void InspectorDOMAgent::willModifyDOMAttr(Element* element, const AtomicString& oldValue, const AtomicString& newValue)
+{
+ m_suppressAttributeModifiedEvent = (oldValue == newValue);
+}
+
void InspectorDOMAgent::didModifyDOMAttr(Element* element, const AtomicString& name, const AtomicString& value)
{
+ bool shouldSuppressEvent = m_suppressAttributeModifiedEvent;
+ m_suppressAttributeModifiedEvent = false;
+ if (shouldSuppressEvent)
+ return;
+
int id = boundNodeId(element);
// If node is not mapped yet -> ignore the event.
if (!id)
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.h (108234 => 108235)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2012-02-20 13:11:40 UTC (rev 108235)
@@ -161,6 +161,7 @@
void didInsertDOMNode(Node*);
void didRemoveDOMNode(Node*);
+ void willModifyDOMAttr(Element*, const AtomicString& oldValue, const AtomicString& newValue);
void didModifyDOMAttr(Element*, const AtomicString& name, const AtomicString& value);
void didRemoveDOMAttr(Element*, const AtomicString& name);
void styleAttributeInvalidated(const Vector<Element*>& elements);
@@ -250,6 +251,7 @@
bool m_searchingForNode;
OwnPtr<InspectorHistory> m_history;
OwnPtr<DOMEditor> m_domEditor;
+ bool m_suppressAttributeModifiedEvent;
};
#endif // ENABLE(INSPECTOR)
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (108234 => 108235)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2012-02-20 13:11:40 UTC (rev 108235)
@@ -154,11 +154,13 @@
domAgent->didRemoveDOMNode(node);
}
-void InspectorInstrumentation::willModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element)
+void InspectorInstrumentation::willModifyDOMAttrImpl(InstrumentingAgents* instrumentingAgents, Element* element, const AtomicString& oldValue, const AtomicString& newValue)
{
#if ENABLE(_javascript__DEBUGGER)
if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents->inspectorDOMDebuggerAgent())
domDebuggerAgent->willModifyDOMAttr(element);
+ if (InspectorDOMAgent* domAgent = instrumentingAgents->inspectorDOMAgent())
+ domAgent->willModifyDOMAttr(element, oldValue, newValue);
#endif
}
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (108234 => 108235)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2012-02-20 13:00:22 UTC (rev 108234)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2012-02-20 13:11:40 UTC (rev 108235)
@@ -85,7 +85,7 @@
static void willInsertDOMNode(Document*, Node*, Node* parent);
static void didInsertDOMNode(Document*, Node*);
static void willRemoveDOMNode(Document*, Node*);
- static void willModifyDOMAttr(Document*, Element*);
+ static void willModifyDOMAttr(Document*, Element*, const AtomicString& oldValue, const AtomicString& newValue);
static void didModifyDOMAttr(Document*, Element*, const AtomicString& name, const AtomicString& value);
static void didRemoveDOMAttr(Document*, Element*, const AtomicString& name);
static void characterDataModified(Document*, CharacterData*);
@@ -235,7 +235,7 @@
static void didInsertDOMNodeImpl(InstrumentingAgents*, Node*);
static void willRemoveDOMNodeImpl(InstrumentingAgents*, Node*);
static void didRemoveDOMNodeImpl(InstrumentingAgents*, Node*);
- static void willModifyDOMAttrImpl(InstrumentingAgents*, Element*);
+ static void willModifyDOMAttrImpl(InstrumentingAgents*, Element*, const AtomicString& oldValue, const AtomicString& newValue);
static void didModifyDOMAttrImpl(InstrumentingAgents*, Element*, const AtomicString& name, const AtomicString& value);
static void didRemoveDOMAttrImpl(InstrumentingAgents*, Element*, const AtomicString& name);
static void characterDataModifiedImpl(InstrumentingAgents*, CharacterData*);
@@ -424,12 +424,12 @@
#endif
}
-inline void InspectorInstrumentation::willModifyDOMAttr(Document* document, Element* element)
+inline void InspectorInstrumentation::willModifyDOMAttr(Document* document, Element* element, const AtomicString& oldValue, const AtomicString& newValue)
{
#if ENABLE(INSPECTOR)
FAST_RETURN_IF_NO_FRONTENDS(void());
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
- willModifyDOMAttrImpl(instrumentingAgents, element);
+ willModifyDOMAttrImpl(instrumentingAgents, element, oldValue, newValue);
#endif
}