Changeset 109285 in webkit
- Timestamp:
- Feb 29, 2012 5:03:41 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109280 r109285 1 2012-02-29 Andreas Kling <awesomekling@apple.com> 2 3 IsSynchronizingStyleAttributeFlag could be purged. 4 <http://webkit.org/b/79313> 5 6 Reviewed by Anders Carlsson. 7 8 We were using IsSynchronizingStyleAttributeFlag to prevent various things from 9 happening below setAttribute() when serializing the "style" attribute based on 10 an element's inline style. 11 12 Simplify the whole thing by adding a way to set an attribute without triggering 13 any callbacks (a 'notifyChanged' argument to Element::setAttribute().) 14 This removes the need for IsSynchronizingStyleAttributeFlag in the first place 15 and makes StyledElement::updateStyleAttribute() a bit cheaper to boot. 16 17 * dom/Element.cpp: 18 (WebCore::Element::setAttribute): 19 (WebCore::Element::setAttributeInternal): 20 (WebCore::Element::willModifyAttribute): 21 (WebCore::Element::didModifyAttribute): 22 (WebCore::Element::didRemoveAttribute): 23 * dom/Element.h: 24 * dom/Node.h: 25 * dom/StyledElement.cpp: 26 (WebCore::StyledElement::updateStyleAttribute): 27 (WebCore::StyledElement::attributeChanged): 28 * html/HTMLElement.cpp: 29 (WebCore::StyledElement::copyNonAttributeProperties): 30 1 31 2012-02-29 Daniel Cheng <dcheng@chromium.org> 2 32 -
trunk/Source/WebCore/dom/Element.cpp
r109203 r109285 625 625 } 626 626 627 void Element::setAttribute(const QualifiedName& name, const AtomicString& value )628 { 629 setAttributeInternal(ensureUpdatedAttributeData()->getAttributeItemIndex(name), name, value );630 } 631 632 inline void Element::setAttributeInternal(size_t index, const QualifiedName& name, const AtomicString& value )627 void Element::setAttribute(const QualifiedName& name, const AtomicString& value, bool notifyChanged) 628 { 629 setAttributeInternal(ensureUpdatedAttributeData()->getAttributeItemIndex(name), name, value, notifyChanged); 630 } 631 632 inline void Element::setAttributeInternal(size_t index, const QualifiedName& name, const AtomicString& value, bool notifyChanged) 633 633 { 634 634 ElementAttributeData* attributeData = &m_attributeMap->m_attributeData; … … 645 645 } 646 646 647 willModifyAttribute(name, old ? old->value() : nullAtom, value); 647 if (notifyChanged) 648 willModifyAttribute(name, old ? old->value() : nullAtom, value); 648 649 649 650 if (Attr* attrNode = old->attr()) … … 652 653 old->setValue(value); 653 654 654 didModifyAttribute(old); 655 if (notifyChanged) 656 didModifyAttribute(old); 655 657 } 656 658 … … 1940 1942 1941 1943 #if ENABLE(MUTATION_OBSERVERS) 1942 if (!isSynchronizingStyleAttribute()) { 1943 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInterestGroup::createForAttributesMutation(this, name)) 1944 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 1945 } 1944 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInterestGroup::createForAttributesMutation(this, name)) 1945 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 1946 1946 #endif 1947 1947 1948 1948 #if ENABLE(INSPECTOR) 1949 if (!isSynchronizingStyleAttribute()) 1950 InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newValue); 1949 InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newValue); 1951 1950 #endif 1952 1951 } … … 1956 1955 attributeChanged(attr); 1957 1956 1958 if (!isSynchronizingStyleAttribute()) { 1959 InspectorInstrumentation::didModifyDOMAttr(document(), this, attr->name().localName(), attr->value()); 1960 dispatchSubtreeModifiedEvent(); 1961 } 1957 InspectorInstrumentation::didModifyDOMAttr(document(), this, attr->name().localName(), attr->value()); 1958 dispatchSubtreeModifiedEvent(); 1962 1959 } 1963 1960 … … 1972 1969 attr->setValue(savedValue); 1973 1970 1974 if (!isSynchronizingStyleAttribute()) { 1975 InspectorInstrumentation::didRemoveDOMAttr(document(), this, attr->name().localName()); 1976 dispatchSubtreeModifiedEvent(); 1977 } 1971 InspectorInstrumentation::didRemoveDOMAttr(document(), this, attr->name().localName()); 1972 dispatchSubtreeModifiedEvent(); 1978 1973 } 1979 1974 -
trunk/Source/WebCore/dom/Element.h
r109084 r109285 114 114 bool hasAttribute(const QualifiedName&) const; 115 115 const AtomicString& getAttribute(const QualifiedName&) const; 116 void setAttribute(const QualifiedName&, const AtomicString& value );116 void setAttribute(const QualifiedName&, const AtomicString& value, bool notifyChanged = true); 117 117 void removeAttribute(const QualifiedName&); 118 118 … … 430 430 virtual bool childTypeAllowed(NodeType) const; 431 431 432 void setAttributeInternal(size_t index, const QualifiedName&, const AtomicString& value );432 void setAttributeInternal(size_t index, const QualifiedName&, const AtomicString& value, bool notifyChanged = true); 433 433 434 434 #ifndef NDEBUG -
trunk/Source/WebCore/dom/Node.h
r109097 r109285 89 89 typedef int ExceptionCode; 90 90 91 const int nodeStyleChangeShift = 2 3;91 const int nodeStyleChangeShift = 22; 92 92 93 93 // SyntheticStyleChange means that we need to go through the entire style change logic even though … … 655 655 IsParsingChildrenFinishedFlag = 1 << 17, // Element 656 656 IsStyleAttributeValidFlag = 1 << 18, // StyledElement 657 IsSynchronizingStyleAttributeFlag = 1 << 19, // StyledElement658 657 #if ENABLE(SVG) 659 AreSVGAttributesValidFlag = 1 << 20, // Element660 IsSynchronizingSVGAttributesFlag = 1 << 2 1, // SVGElement661 HasSVGRareDataFlag = 1 << 2 2, // SVGElement658 AreSVGAttributesValidFlag = 1 << 19, // Element 659 IsSynchronizingSVGAttributesFlag = 1 << 20, // SVGElement 660 HasSVGRareDataFlag = 1 << 21, // SVGElement 662 661 #endif 663 662 664 663 StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1), 665 664 666 SelfOrAncestorHasDirAutoFlag = 1 << 2 5,667 HasCustomWillOrDidRecalcStyleFlag = 1 << 2 6,668 HasCustomStyleForRendererFlag = 1 << 2 7,669 670 HasNameFlag = 1 << 2 8,671 672 AttributeStyleDirtyFlag = 1 << 31,665 SelfOrAncestorHasDirAutoFlag = 1 << 24, 666 HasCustomWillOrDidRecalcStyleFlag = 1 << 25, 667 HasCustomStyleForRendererFlag = 1 << 26, 668 669 HasNameFlag = 1 << 27, 670 671 AttributeStyleDirtyFlag = 1 << 28, 673 672 674 673 #if ENABLE(SVG) … … 776 775 void setIsStyleAttributeValid() const { setFlag(IsStyleAttributeValidFlag); } 777 776 void clearIsStyleAttributeValid() { clearFlag(IsStyleAttributeValidFlag); } 778 bool isSynchronizingStyleAttribute() const { return getFlag(IsSynchronizingStyleAttributeFlag); }779 void setIsSynchronizingStyleAttribute(bool f) { setFlag(f, IsSynchronizingStyleAttributeFlag); }780 void setIsSynchronizingStyleAttribute() const { setFlag(IsSynchronizingStyleAttributeFlag); }781 void clearIsSynchronizingStyleAttribute() const { clearFlag(IsSynchronizingStyleAttributeFlag); }782 777 783 778 #if ENABLE(SVG) -
trunk/Source/WebCore/dom/StyledElement.cpp
r109149 r109285 51 51 ASSERT(!isStyleAttributeValid()); 52 52 setIsStyleAttributeValid(); 53 setIsSynchronizingStyleAttribute();54 53 if (StylePropertySet* inlineStyle = inlineStyleDecl()) 55 const_cast<StyledElement*>(this)->setAttribute(styleAttr, inlineStyle->asText()); 56 clearIsSynchronizingStyleAttribute(); 54 const_cast<StyledElement*>(this)->setAttribute(styleAttr, inlineStyle->asText(), /*notifyChanged*/ false); 57 55 } 58 56 … … 64 62 void StyledElement::attributeChanged(Attribute* attr) 65 63 { 66 if (!(attr->name() == styleAttr && isSynchronizingStyleAttribute())) 67 parseAttribute(attr); 64 parseAttribute(attr); 68 65 69 66 if (isPresentationAttribute(attr->name())) { -
trunk/Source/WebCore/html/HTMLElement.cpp
r109251 r109285 1115 1115 1116 1116 setIsStyleAttributeValid(source->isStyleAttributeValid()); 1117 setIsSynchronizingStyleAttribute(source->isSynchronizingStyleAttribute()); 1118 1117 1119 1118 Element::copyNonAttributeProperties(sourceElement); 1120 1119 }
Note: See TracChangeset
for help on using the changeset viewer.