-
shinyak@chromium.org authored
https://bugs.webkit.org/show_bug.cgi?id=100738 Reviewed by Dimitri Glazkov. PerformanceTests: Added test code to modify id/class/attribute. * DOM/ModifyAttribute.html: Added. * DOM/resources/dom-perf/modify-attribute.js: Added. (ModifyAttribute.CreateElementToSetUp): (ModifyAttribute.ModifyId): (ModifyAttribute.ModifyClass): (ModifyAttribute.ModifyTitle): Source/WebCore: When id, className, or attribute is changed, we might have to invalidate distribution. However, we don't want to do useless invalidation. So we consult with the RuleFeatureSet of ElementShadow, and invalidate distribution only if necessary. When className is changed, we can share a lot of code between invalidating distribution and invalidating style. So we made checkNeedsStyleInvalidationForClassChange a template method, and share it. Also we've measured how this patch makes changing attribute slow. By converting checkNeedsStyleInvalidationForClassChange to template, actually this improves the performance of changing attribute code. I've measured each code 3 times. DOM/ModifyAttribute.html Before this patch: median stdev min max [ms] 1st 115.62 0.67 114.75 117.00 2nd 115.08 1.13 113.25 117.58 3rd 114.75 1.16 113.42 117.83 After this patch: median stdev min max [ms] 1st 102.55 0.95 101.25 104.50 2nd 103.10 0.86 102.20 100.95 3rd 103.30 1.05 102.10 106.65 Tests: fast/dom/shadow/distribution-attribute-modified.html fast/dom/shadow/distribution-className-modified.html fast/dom/shadow/distribution-id-modified.html fast/dom/shadow/reprojection-attribute-modified.html fast/dom/shadow/reprojection-className-modified.html fast/dom/shadow/reprojection-id-modified.html * dom/Element.cpp: (WebCore::Element::attributeChanged): (WebCore::HasSelectorForClassStyleFunctor::HasSelectorForClassStyleFunctor): (HasSelectorForClassStyleFunctor): (WebCore::HasSelectorForClassStyleFunctor::operator()): Returns true if StyleResolver::hasSelectorForClass returns true. (WebCore): (WebCore::HasSelectorForClassDistributionFunctor::HasSelectorForClassDistributionFunctor): (HasSelectorForClassDistributionFunctor): (WebCore::HasSelectorForClassDistributionFunctor::operator()): Returns true if ElementShadow::hasSelectorForClass returns true. (WebCore::checkFunctorForClassChange): (WebCore::checkNeedsStyleInvalidationForClassChange): Extacted the implementation to checkFunctorForClassChange. (WebCore::checkNeedsDistributionInvalidationForClassChange): (WebCore::Element::classAttributeChanged): LayoutTests: We have test cases that id/class/attribute is changed, and thier reprojection cases. * fast/dom/shadow/distribution-attribute-modified-expected.html: Added. * fast/dom/shadow/distribution-attribute-modified.html: Added. * fast/dom/shadow/distribution-className-modified-expected.html: Added. * fast/dom/shadow/distribution-className-modified.html: Added. * fast/dom/shadow/distribution-id-modified-expected.html: Added. * fast/dom/shadow/distribution-id-modified.html: Added. * fast/dom/shadow/reprojection-attribute-modified-expected.html: Added. * fast/dom/shadow/reprojection-attribute-modified.html: Added. * fast/dom/shadow/reprojection-className-modified-expected.html: Added. * fast/dom/shadow/reprojection-className-modified.html: Added. * fast/dom/shadow/reprojection-id-modified-expected.html: Added. * fast/dom/shadow/reprojection-id-modified.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@134367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
f2bd9cb5