Changeset 134367 in webkit
- Timestamp:
- Nov 12, 2012 10:50:15 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r134352 r134367 1 2012-11-12 Shinya Kawanaka <shinyak@chromium.org> 2 3 Changing id, className, or attribute should invalidate distribution 4 https://bugs.webkit.org/show_bug.cgi?id=100738 5 6 Reviewed by Dimitri Glazkov. 7 8 We have test cases that id/class/attribute is changed, and thier reprojection cases. 9 10 * fast/dom/shadow/distribution-attribute-modified-expected.html: Added. 11 * fast/dom/shadow/distribution-attribute-modified.html: Added. 12 * fast/dom/shadow/distribution-className-modified-expected.html: Added. 13 * fast/dom/shadow/distribution-className-modified.html: Added. 14 * fast/dom/shadow/distribution-id-modified-expected.html: Added. 15 * fast/dom/shadow/distribution-id-modified.html: Added. 16 * fast/dom/shadow/reprojection-attribute-modified-expected.html: Added. 17 * fast/dom/shadow/reprojection-attribute-modified.html: Added. 18 * fast/dom/shadow/reprojection-className-modified-expected.html: Added. 19 * fast/dom/shadow/reprojection-className-modified.html: Added. 20 * fast/dom/shadow/reprojection-id-modified-expected.html: Added. 21 * fast/dom/shadow/reprojection-id-modified.html: Added. 22 1 23 2012-11-10 Dirk Schulze <krit@webkit.org> 2 24 -
trunk/PerformanceTests/ChangeLog
r133657 r134367 1 2012-11-12 Shinya Kawanaka <shinyak@chromium.org> 2 3 Changing id, className, or attribute should invalidate distribution 4 https://bugs.webkit.org/show_bug.cgi?id=100738 5 6 Reviewed by Dimitri Glazkov. 7 8 Added test code to modify id/class/attribute. 9 10 * DOM/ModifyAttribute.html: Added. 11 * DOM/resources/dom-perf/modify-attribute.js: Added. 12 (ModifyAttribute.CreateElementToSetUp): 13 (ModifyAttribute.ModifyId): 14 (ModifyAttribute.ModifyClass): 15 (ModifyAttribute.ModifyTitle): 16 1 17 2012-11-06 Adam Barth <abarth@webkit.org> 2 18 -
trunk/Source/WebCore/ChangeLog
r134364 r134367 1 2012-11-12 Shinya Kawanaka <shinyak@chromium.org> 2 3 Changing id, className, or attribute should invalidate distribution 4 https://bugs.webkit.org/show_bug.cgi?id=100738 5 6 Reviewed by Dimitri Glazkov. 7 8 When id, className, or attribute is changed, we might have to invalidate distribution. 9 However, we don't want to do useless invalidation. So we consult with the RuleFeatureSet of ElementShadow, 10 and invalidate distribution only if necessary. 11 12 When className is changed, we can share a lot of code between invalidating distribution and invalidating style. 13 So we made checkNeedsStyleInvalidationForClassChange a template method, and share it. 14 15 Also we've measured how this patch makes changing attribute slow. By converting checkNeedsStyleInvalidationForClassChange 16 to template, actually this improves the performance of changing attribute code. I've measured each code 3 times. 17 18 DOM/ModifyAttribute.html 19 Before this patch: 20 median stdev min max [ms] 21 1st 115.62 0.67 114.75 117.00 22 2nd 115.08 1.13 113.25 117.58 23 3rd 114.75 1.16 113.42 117.83 24 25 After this patch: 26 median stdev min max [ms] 27 1st 102.55 0.95 101.25 104.50 28 2nd 103.10 0.86 102.20 100.95 29 3rd 103.30 1.05 102.10 106.65 30 31 Tests: fast/dom/shadow/distribution-attribute-modified.html 32 fast/dom/shadow/distribution-className-modified.html 33 fast/dom/shadow/distribution-id-modified.html 34 fast/dom/shadow/reprojection-attribute-modified.html 35 fast/dom/shadow/reprojection-className-modified.html 36 fast/dom/shadow/reprojection-id-modified.html 37 38 * dom/Element.cpp: 39 (WebCore::Element::attributeChanged): 40 (WebCore::HasSelectorForClassStyleFunctor::HasSelectorForClassStyleFunctor): 41 (HasSelectorForClassStyleFunctor): 42 (WebCore::HasSelectorForClassStyleFunctor::operator()): Returns true if StyleResolver::hasSelectorForClass returns true. 43 (WebCore): 44 (WebCore::HasSelectorForClassDistributionFunctor::HasSelectorForClassDistributionFunctor): 45 (HasSelectorForClassDistributionFunctor): 46 (WebCore::HasSelectorForClassDistributionFunctor::operator()): Returns true if ElementShadow::hasSelectorForClass returns true. 47 (WebCore::checkFunctorForClassChange): 48 (WebCore::checkNeedsStyleInvalidationForClassChange): Extacted the implementation to checkFunctorForClassChange. 49 (WebCore::checkNeedsDistributionInvalidationForClassChange): 50 (WebCore::Element::classAttributeChanged): 51 1 52 2012-11-12 Joe Mason <jmason@rim.com> 2 53 -
trunk/Source/WebCore/dom/Element.cpp
r134163 r134367 54 54 #include "HTMLParserIdioms.h" 55 55 #include "HTMLTableRowsCollection.h" 56 #include "InsertionPoint.h" 56 57 #include "InspectorInstrumentation.h" 57 58 #include "MutationObserverInterestGroup.h" … … 764 765 765 766 StyleResolver* styleResolver = document()->styleResolverIfExists(); 767 ElementShadow* elementShadow = shadowOfParentForDistribution(this); 768 if (elementShadow) 769 elementShadow->ensureSelectFeatureSetCollected(); 770 766 771 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeType() < FullStyleChange; 767 772 bool shouldInvalidateStyle = false; 773 bool shouldInvalidateDistribution = false; 768 774 769 775 if (isIdAttributeName(name)) { … … 773 779 attributeData()->setIdForStyleResolution(newId); 774 780 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyleInvalidationForIdChange(oldId, newId, styleResolver); 781 shouldInvalidateDistribution |= elementShadow && !oldId.isEmpty() && elementShadow->selectRuleFeatureSet().hasSelectorForId(oldId); 782 shouldInvalidateDistribution |= elementShadow && !newId.isEmpty() && elementShadow->selectRuleFeatureSet().hasSelectorForId(newId); 775 783 } 776 784 } else if (name == HTMLNames::nameAttr) … … 780 788 781 789 shouldInvalidateStyle |= testShouldInvalidateStyle && styleResolver->hasSelectorForAttribute(name.localName()); 790 shouldInvalidateDistribution |= elementShadow && elementShadow->selectRuleFeatureSet().hasSelectorForAttribute(name.localName()); 782 791 783 792 invalidateNodeListCachesInAncestors(&name, this); … … 785 794 if (shouldInvalidateStyle) 786 795 setNeedsStyleRecalc(); 787 796 if (shouldInvalidateDistribution) 797 elementShadow->invalidateDistribution(); 798 788 799 if (AXObjectCache::accessibilityEnabled()) 789 800 document()->axObjectCache()->handleAttributeChanged(name, this); … … 823 834 } 824 835 825 static bool checkNeedsStyleInvalidationForClassChange(const SpaceSplitString& changedClasses, StyleResolver* styleResolver) 836 struct HasSelectorForClassStyleFunctor { 837 explicit HasSelectorForClassStyleFunctor(StyleResolver* resolver) 838 : styleResolver(resolver) 839 { } 840 841 bool operator()(const AtomicString& className) const 842 { 843 return styleResolver->hasSelectorForClass(className); 844 } 845 846 StyleResolver* styleResolver; 847 }; 848 849 struct HasSelectorForClassDistributionFunctor { 850 explicit HasSelectorForClassDistributionFunctor(ElementShadow* elementShadow) 851 : elementShadow(elementShadow) 852 { } 853 854 bool operator()(const AtomicString& className) const 855 { 856 return elementShadow->selectRuleFeatureSet().hasSelectorForClass(className); 857 } 858 859 ElementShadow* elementShadow; 860 }; 861 862 template<typename Functor> 863 static bool checkFunctorForClassChange(const SpaceSplitString& changedClasses, Functor functor) 826 864 { 827 865 unsigned changedSize = changedClasses.size(); 828 866 for (unsigned i = 0; i < changedSize; ++i) { 829 if ( styleResolver->hasSelectorForClass(changedClasses[i]))867 if (functor(changedClasses[i])) 830 868 return true; 831 869 } … … 833 871 } 834 872 835 static bool checkNeedsStyleInvalidationForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, StyleResolver* styleResolver) 873 template<typename Functor> 874 static bool checkFunctorForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Functor functor) 836 875 { 837 876 unsigned oldSize = oldClasses.size(); 838 877 if (!oldSize) 839 return check NeedsStyleInvalidationForClassChange(newClasses, styleResolver);878 return checkFunctorForClassChange(newClasses, functor); 840 879 BitVector remainingClassBits; 841 880 remainingClassBits.ensureSize(oldSize); … … 849 888 } 850 889 } 851 if ( styleResolver->hasSelectorForClass(newClasses[i]))890 if (functor(newClasses[i])) 852 891 return true; 853 892 } … … 856 895 if (remainingClassBits.quickGet(i)) 857 896 continue; 858 if ( styleResolver->hasSelectorForClass(oldClasses[i]))897 if (functor(oldClasses[i])) 859 898 return true; 860 899 } 861 900 return false; 901 } 902 903 static inline bool checkNeedsStyleInvalidationForClassChange(const SpaceSplitString& changedClasses, StyleResolver* styleResolver) 904 { 905 return checkFunctorForClassChange(changedClasses, HasSelectorForClassStyleFunctor(styleResolver)); 906 } 907 908 static inline bool checkNeedsStyleInvalidationForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, StyleResolver* styleResolver) 909 { 910 return checkFunctorForClassChange(oldClasses, newClasses, HasSelectorForClassStyleFunctor(styleResolver)); 911 } 912 913 static inline bool checkNeedsDistributionInvalidationForClassChange(const SpaceSplitString& changedClasses, ElementShadow* elementShadow) 914 { 915 return checkFunctorForClassChange(changedClasses, HasSelectorForClassDistributionFunctor(elementShadow)); 916 } 917 918 static inline bool checkNeedsDistributionInvalidationForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, ElementShadow* elementShadow) 919 { 920 return checkFunctorForClassChange(oldClasses, newClasses, HasSelectorForClassDistributionFunctor(elementShadow)); 862 921 } 863 922 … … 867 926 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeType() < FullStyleChange; 868 927 bool shouldInvalidateStyle = false; 928 929 ElementShadow* elementShadow = shadowOfParentForDistribution(this); 930 if (elementShadow) 931 elementShadow->ensureSelectFeatureSetCollected(); 932 bool shouldInvalidateDistribution = false; 869 933 870 934 if (classStringHasClassName(newClassString)) { … … 877 941 const SpaceSplitString& newClasses = attributeData->classNames(); 878 942 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyleInvalidationForClassChange(oldClasses, newClasses, styleResolver); 943 shouldInvalidateDistribution = elementShadow && checkNeedsDistributionInvalidationForClassChange(oldClasses, newClasses, elementShadow); 879 944 } else if (const ElementAttributeData* attributeData = this->attributeData()) { 880 945 const SpaceSplitString& oldClasses = attributeData->classNames(); 881 946 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyleInvalidationForClassChange(oldClasses, styleResolver); 882 947 shouldInvalidateDistribution = elementShadow && checkNeedsDistributionInvalidationForClassChange(oldClasses, elementShadow); 883 948 attributeData->clearClass(); 884 949 } … … 889 954 if (shouldInvalidateStyle) 890 955 setNeedsStyleRecalc(); 956 if (shouldInvalidateDistribution) 957 elementShadow->invalidateDistribution(); 891 958 } 892 959
Note: See TracChangeset
for help on using the changeset viewer.