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

Side by Side Diff: sky/engine/core/dom/Element.cpp

Issue 840223006: Don't queue mutation records when attributes don't change value. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/tests/mutation-observer/observe-options-attributes.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 626
627 if (index == kNotFound) { 627 if (index == kNotFound) {
628 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute ); 628 appendAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute );
629 return; 629 return;
630 } 630 }
631 631
632 const Attribute& existingAttribute = elementData()->attributes().at(index); 632 const Attribute& existingAttribute = elementData()->attributes().at(index);
633 QualifiedName existingAttributeName = existingAttribute.name(); 633 QualifiedName existingAttributeName = existingAttribute.name();
634 634
635 if (newValue == existingAttribute.value())
636 return;
637
635 if (!inSynchronizationOfLazyAttribute) 638 if (!inSynchronizationOfLazyAttribute)
636 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne wValue); 639 willModifyAttribute(existingAttributeName, existingAttribute.value(), ne wValue);
637 640
638 if (newValue != existingAttribute.value()) 641 ensureUniqueElementData().attributes().at(index).setValue(newValue);
639 ensureUniqueElementData().attributes().at(index).setValue(newValue);
640 642
641 if (!inSynchronizationOfLazyAttribute) 643 if (!inSynchronizationOfLazyAttribute)
642 attributeChanged(existingAttributeName, newValue); 644 attributeChanged(existingAttributeName, newValue);
643 } 645 }
644 646
645 void Element::attributeChanged(const QualifiedName& name, const AtomicString& ne wValue, AttributeModificationReason reason) 647 void Element::attributeChanged(const QualifiedName& name, const AtomicString& ne wValue, AttributeModificationReason reason)
646 { 648 {
647 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) { 649 if (ElementShadow* parentElementShadow = shadowWhereNodeCanBeDistributed(*th is)) {
648 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue)) 650 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow , name, newValue))
649 parentElementShadow->setNeedsDistributionRecalc(); 651 parentElementShadow->setNeedsDistributionRecalc();
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 ASSERT(oldId != newId); 1526 ASSERT(oldId != newId);
1525 1527
1526 if (!oldId.isEmpty()) 1528 if (!oldId.isEmpty())
1527 scope.removeElementById(oldId, this); 1529 scope.removeElementById(oldId, this);
1528 if (!newId.isEmpty()) 1530 if (!newId.isEmpty())
1529 scope.addElementById(newId, this); 1531 scope.addElementById(newId, this);
1530 } 1532 }
1531 1533
1532 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) 1534 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
1533 { 1535 {
1534 if (name == HTMLNames::idAttr) { 1536 if (name == HTMLNames::idAttr)
1535 updateId(oldValue, newValue); 1537 updateId(oldValue, newValue);
1536 }
1537 1538
1538 if (oldValue != newValue) { 1539 if (inActiveDocument() && styleChangeType() < SubtreeStyleChange && affected ByAttributeSelector(name.localName()))
1539 if (inActiveDocument() && styleChangeType() < SubtreeStyleChange && affe ctedByAttributeSelector(name.localName())) 1540 setNeedsStyleRecalc(LocalStyleChange);
1540 setNeedsStyleRecalc(LocalStyleChange);
1541 1541
1542 if (isUpgradedCustomElement()) 1542 if (isUpgradedCustomElement())
1543 CustomElement::attributeDidChange(this, name.localName(), oldValue, newValue); 1543 CustomElement::attributeDidChange(this, name.localName(), oldValue, newV alue);
1544 }
1545 1544
1546 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(*this, name)) 1545 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(*this, name))
1547 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 1546 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
1548 } 1547 }
1549 1548
1550 static bool needsURLResolutionForInlineStyle(const Element& element, const Docum ent& oldDocument, const Document& newDocument) 1549 static bool needsURLResolutionForInlineStyle(const Element& element, const Docum ent& oldDocument, const Document& newDocument)
1551 { 1550 {
1552 if (oldDocument == newDocument) 1551 if (oldDocument == newDocument)
1553 return false; 1552 return false;
1554 if (oldDocument.baseURL() == newDocument.baseURL()) 1553 if (oldDocument.baseURL() == newDocument.baseURL())
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 return false; 1831 return false;
1833 if (treeScope().scopedStyleResolver().features().hasSelectorForId(idValue)) 1832 if (treeScope().scopedStyleResolver().features().hasSelectorForId(idValue))
1834 return true; 1833 return true;
1835 // Host rules could also have effects. 1834 // Host rules could also have effects.
1836 if (ShadowRoot* shadowRoot = this->shadowRoot()) 1835 if (ShadowRoot* shadowRoot = this->shadowRoot())
1837 return shadowRoot->scopedStyleResolver().features().hasSelectorForId(idV alue); 1836 return shadowRoot->scopedStyleResolver().features().hasSelectorForId(idV alue);
1838 return false; 1837 return false;
1839 } 1838 }
1840 1839
1841 } // namespace blink 1840 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/tests/mutation-observer/observe-options-attributes.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698