From: apavlov@chromium.org Date: Mon, 20 Feb 2012 13:11:40 +0000 (+0000) Subject: Web Inspector: DOMAttrModified should not be fired if the attribute value remains... X-Git-Tag: 070512121124~12400 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19e021e069a309d9d102635008b135e91068fc2b;p=profile%2Fivi%2Fwebkit-efl.git 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. Source/WebCore: * 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): LayoutTests: * inspector/elements/set-attribute-expected.txt: * inspector/elements/set-attribute.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108235 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 10b2a0d..bb42acb 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2012-02-20 Alexander Pavlov + + 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 [Forms] Spin buttons of number input type should fire both input and change event diff --git a/LayoutTests/inspector/elements/set-attribute-expected.txt b/LayoutTests/inspector/elements/set-attribute-expected.txt index b2c1497..4521ad5 100644 --- a/LayoutTests/inspector/elements/set-attribute-expected.txt +++ b/LayoutTests/inspector/elements/set-attribute-expected.txt @@ -9,6 +9,10 @@ Running: testAttributeUpdated ===== On attribute set =====
+Running: testAttributeSameValueNotUpdated +===== On attribute modified (should be 'newValue') ===== +
+ Running: testAttributeRemoved === On attribute removed ===
diff --git a/LayoutTests/inspector/elements/set-attribute.html b/LayoutTests/inspector/elements/set-attribute.html index 164c252..130a7b0 100644 --- a/LayoutTests/inspector/elements/set-attribute.html +++ b/LayoutTests/inspector/elements/set-attribute.html @@ -46,6 +46,22 @@ function test() 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() diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index ebd946b..3c3aa53 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,25 @@ +2012-02-20 Alexander Pavlov + + 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 Correct a typo error in ScrollingCoordinator.h diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp index 4fc4d86..23010a0 100644 --- a/Source/WebCore/dom/Element.cpp +++ b/Source/WebCore/dom/Element.cpp @@ -2005,7 +2005,7 @@ void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& #if ENABLE(INSPECTOR) if (!isSynchronizingStyleAttribute()) - InspectorInstrumentation::willModifyDOMAttr(document(), this); + InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newValue); #endif } diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index 6ea68a5..e9a10d0 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -197,6 +197,7 @@ InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, I , m_domListener(0) , m_lastNodeId(1) , m_searchingForNode(false) + , m_suppressAttributeModifiedEvent(false) { } @@ -1401,8 +1402,18 @@ void InspectorDOMAgent::didRemoveDOMNode(Node* node) 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) diff --git a/Source/WebCore/inspector/InspectorDOMAgent.h b/Source/WebCore/inspector/InspectorDOMAgent.h index 6b8337b..e45d463 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.h +++ b/Source/WebCore/inspector/InspectorDOMAgent.h @@ -161,6 +161,7 @@ public: 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& elements); @@ -250,6 +251,7 @@ private: bool m_searchingForNode; OwnPtr m_history; OwnPtr m_domEditor; + bool m_suppressAttributeModifiedEvent; }; #endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp index 95d6f30..ab94944 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.cpp +++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp @@ -154,11 +154,13 @@ void InspectorInstrumentation::didRemoveDOMNodeImpl(InstrumentingAgents* instrum 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 } diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h index da7dfe0..a14ca20 100644 --- a/Source/WebCore/inspector/InspectorInstrumentation.h +++ b/Source/WebCore/inspector/InspectorInstrumentation.h @@ -85,7 +85,7 @@ public: 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 @@ private: 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 @@ inline void InspectorInstrumentation::willRemoveDOMNode(Document* document, Node #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 }