Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Issue 2568333004: SELECT element: Do not update popup content if CharacterData or attribute value is not changed. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
index 2bfe488d7989e61865b059a5c649ee2de87bbb41..1603002f0deb1d735efc48acd80db7e3ba27c3dd 100644
--- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -42,6 +42,7 @@
#include "core/dom/MutationCallback.h"
#include "core/dom/MutationObserver.h"
#include "core/dom/MutationObserverInit.h"
+#include "core/dom/MutationRecord.h"
#include "core/dom/NodeComputedStyle.h"
#include "core/dom/NodeListsNodeData.h"
#include "core/dom/NodeTraversal.h"
@@ -1967,13 +1968,24 @@ class HTMLSelectElement::PopupUpdater : public MutationCallback {
void dispose() { m_observer->disconnect(); }
private:
- void call(const HeapVector<Member<MutationRecord>>&,
+ void call(const HeapVector<Member<MutationRecord>>& records,
MutationObserver*) override {
// We disconnect the MutationObserver when a popuup is closed. However
// MutationObserver can call back after disconnection.
if (!m_select->popupIsVisible())
return;
- m_select->didMutateSubtree();
+ for (const auto& record : records) {
+ if (record->type() == "attributes") {
+ const Element& element = *toElement(record->target());
+ if (record->oldValue() == element.getAttribute(record->attributeName()))
+ continue;
+ } else if (record->type() == "characterData") {
+ if (record->oldValue() == record->target()->nodeValue())
+ continue;
+ }
+ m_select->didMutateSubtree();
+ return;
+ }
}
ExecutionContext* getExecutionContext() const override {
@@ -1995,9 +2007,11 @@ HTMLSelectElement::PopupUpdater::PopupUpdater(HTMLSelectElement& select)
filter.append(String("selected"));
filter.append(String("value"));
MutationObserverInit init;
+ init.setAttributeOldValue(true);
init.setAttributes(true);
init.setAttributeFilter(filter);
init.setCharacterData(true);
+ init.setCharacterDataOldValue(true);
init.setChildList(true);
init.setSubtree(true);
m_observer->observe(&select, init, ASSERT_NO_EXCEPTION);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698