Changeset 153783 in webkit
- Timestamp:
- Aug 7, 2013, 5:02:04 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r153772 r153783 1092 1092 css/StylePropertyShorthand.cpp 1093 1093 css/StyleResolver.cpp 1094 css/StyleResolveTree.cpp 1094 1095 css/StyleRule.cpp 1095 1096 css/StyleRuleImport.cpp -
trunk/Source/WebCore/ChangeLog
r153781 r153783 1 2013-08-07 Antti Koivisto <antti@apple.com> 2 3 Move style recalculation out from Element 4 https://bugs.webkit.org/show_bug.cgi?id=119497 5 6 Reviewed by Andreas Kling. 7 8 Element currently does too much. Element::recalcStyle() and the related functions can be turned into 9 standalone functions that operate on DOM tree. This will also give more freedom for future refactoring, 10 for example making style recalculation non-recursive. 11 12 * WebCore.xcodeproj/project.pbxproj: 13 * css/StyleResolveTree.cpp: Added. 14 (WebCore::Style::determineChange): 15 16 - moved and renamed from Node::diff 17 - factored to use early return style 18 - simplifield the null input logic 19 20 (WebCore::Style::pseudoStyleCacheIsInvalid): 21 22 - moved from Element::pseudoStyleCacheIsInvalid 23 - narrowed to take RenderObject rather than operate on Element 24 25 (WebCore::Style::resolveLocal): 26 27 - split from Element::recalcStyle 28 - factored to use early return style 29 30 (WebCore::Style::resolveTree): 31 32 - moved and renamed from Element::recalcStyle 33 34 * css/StyleResolveTree.h: Added. 35 36 - introcuduce Style namespace for style related classes and functions 37 - move and rename Node::StyleChange -> Style::Change 38 39 * css/StyleResolver.h: 40 (WebCore::StyleResolverParentPusher::StyleResolverParentPusher): 41 (WebCore::StyleResolverParentPusher::push): 42 (WebCore::StyleResolverParentPusher::~StyleResolverParentPusher): 43 44 Moved this stack helper to StyleResolver.h for now since it is needed by both 45 StyleRecalculation and Element. 46 47 * dom/Document.cpp: 48 (WebCore::Document::recalcStyle): 49 (WebCore::Document::updateStyleIfNeeded): 50 (WebCore::Document::updateLayoutIgnorePendingStylesheets): 51 (WebCore::Document::attach): 52 (WebCore::Document::styleResolverChanged): 53 (WebCore::Document::webkitWillEnterFullScreenForElement): 54 * dom/Document.h: 55 * dom/Element.cpp: 56 (WebCore::shouldIgnoreAttributeCase): 57 (WebCore::Element::updatePseudoElement): 58 (WebCore::Element::resetComputedStyle): 59 (WebCore::Element::willRecalcStyle): 60 (WebCore::Element::didRecalcStyle): 61 * dom/Element.h: 62 63 - remove Element::recalcStyle 64 - make a few private functions needed by StyleRecalculation public 65 66 * dom/ElementShadow.cpp: 67 (WebCore::ElementShadow::recalcStyle): 68 * dom/ElementShadow.h: 69 * dom/Node.cpp: 70 * dom/Node.h: 71 72 - remove Node::StyleChange 73 - remove Node::diff 74 75 * dom/PseudoElement.cpp: 76 (WebCore::PseudoElement::didRecalcStyle): 77 * dom/PseudoElement.h: 78 * dom/ShadowRoot.cpp: 79 (WebCore::ShadowRoot::recalcStyle): 80 (WebCore::ShadowRoot::setResetStyleInheritance): 81 * dom/ShadowRoot.h: 82 * dom/Text.cpp: 83 (WebCore::Text::recalcTextStyle): 84 * dom/Text.h: 85 * html/HTMLFormControlElement.cpp: 86 (WebCore::HTMLFormControlElement::didRecalcStyle): 87 * html/HTMLFormControlElement.h: 88 * html/HTMLFrameSetElement.cpp: 89 (WebCore::HTMLFrameSetElement::willRecalcStyle): 90 * html/HTMLFrameSetElement.h: 91 * html/HTMLIFrameElement.cpp: 92 (WebCore::HTMLIFrameElement::didRecalcStyle): 93 * html/HTMLIFrameElement.h: 94 * html/HTMLMediaElement.cpp: 95 (WebCore::HTMLMediaElement::didRecalcStyle): 96 * html/HTMLMediaElement.h: 97 * html/HTMLOptionElement.cpp: 98 (WebCore::HTMLOptionElement::didRecalcStyle): 99 * html/HTMLOptionElement.h: 100 * html/HTMLPlugInImageElement.cpp: 101 (WebCore::HTMLPlugInImageElement::willRecalcStyle): 102 (WebCore::HTMLPlugInImageElement::documentWillSuspendForPageCache): 103 (WebCore::HTMLPlugInImageElement::documentDidResumeFromPageCache): 104 * html/HTMLPlugInImageElement.h: 105 * inspector/InspectorOverlay.cpp: 106 (WebCore::InspectorOverlay::update): 107 * loader/DocumentWriter.cpp: 108 (WebCore::DocumentWriter::reportDataReceived): 109 * page/Frame.cpp: 110 (WebCore::Frame::setPageAndTextZoomFactors): 111 * page/Page.cpp: 112 (WebCore::Page::setPageScaleFactor): 113 * rendering/RenderBlock.cpp: 114 (WebCore::RenderBlock::updateFirstLetterStyle): 115 * svg/SVGElement.cpp: 116 (WebCore::SVGElement::willRecalcStyle): 117 * svg/SVGElement.h: 118 * svg/SVGUseElement.cpp: 119 (WebCore::SVGUseElement::willRecalcStyle): 120 * svg/SVGUseElement.h: 121 1 122 2013-08-07 Mihnea Ovidenie <mihnea@adobe.com> 2 123 -
trunk/Source/WebCore/GNUmakefile.list.am
r153772 r153783 2752 2752 Source/WebCore/css/StyleResolver.cpp \ 2753 2753 Source/WebCore/css/StyleResolver.h \ 2754 Source/WebCore/css/StyleResolveTree.cpp \ 2755 Source/WebCore/css/StyleResolveTree.h \ 2754 2756 Source/WebCore/css/StyleRule.cpp \ 2755 2757 Source/WebCore/css/StyleRule.h \ -
trunk/Source/WebCore/Target.pri
r153772 r153783 334 334 css/StylePropertyShorthand.cpp \ 335 335 css/StyleResolver.cpp \ 336 css/StyleResolveTree.cpp \ 336 337 css/StyleRule.cpp \ 337 338 css/StyleRuleImport.cpp \ … … 1543 1544 css/StylePropertyShorthand.h \ 1544 1545 css/StyleResolver.h \ 1546 css/StyleResolveTree.h \ 1545 1547 css/StyleRule.h \ 1546 1548 css/StyleRuleImport.h \ -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r153772 r153783 9354 9354 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild> 9355 9355 </ClCompile> 9356 <ClCompile Include="..\css\StyleResolveTree.cpp" /> 9356 9357 <ClCompile Include="..\css\StyleRule.cpp" /> 9357 9358 <ClCompile Include="..\css\StyleRuleImport.cpp" /> … … 19867 19868 <ClInclude Include="..\css\StylePropertyShorthand.h" /> 19868 19869 <ClInclude Include="..\css\StyleResolver.h" /> 19870 <ClInclude Include="..\css\StyleResolveTree.h" /> 19869 19871 <ClInclude Include="..\css\StyleRule.h" /> 19870 19872 <ClInclude Include="..\css\StyleRuleImport.h" /> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r153772 r153783 5547 5547 E4D687770ED7AE3D006EA978 /* PurgeableBufferMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D687760ED7AE3D006EA978 /* PurgeableBufferMac.cpp */; }; 5548 5548 E4D687790ED7AE4F006EA978 /* PurgeableBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */; }; 5549 E4DEAA1717A93DC3000E0430 /* StyleResolveTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */; }; 5550 E4DEAA1817A93DC3000E0430 /* StyleResolveTree.h in Headers */ = {isa = PBXBuildFile; fileRef = E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5549 5551 E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */; }; 5550 5552 E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; }; … … 12363 12365 E4D687760ED7AE3D006EA978 /* PurgeableBufferMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PurgeableBufferMac.cpp; sourceTree = "<group>"; }; 12364 12366 E4D687780ED7AE4F006EA978 /* PurgeableBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgeableBuffer.h; sourceTree = "<group>"; }; 12367 E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleResolveTree.cpp; sourceTree = "<group>"; }; 12368 E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleResolveTree.h; sourceTree = "<group>"; }; 12365 12369 E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSheetContents.cpp; sourceTree = "<group>"; }; 12366 12370 E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSheetContents.h; sourceTree = "<group>"; }; … … 19841 19845 E139866115478474001E3F65 /* StyleResolver.cpp */, 19842 19846 E139866215478474001E3F65 /* StyleResolver.h */, 19847 E4DEAA1517A93DC3000E0430 /* StyleResolveTree.cpp */, 19848 E4DEAA1617A93DC3000E0430 /* StyleResolveTree.h */, 19843 19849 E4BBED4A14FCDBA1003F0B98 /* StyleRule.cpp */, 19844 19850 E4BBED4B14FCDBA1003F0B98 /* StyleRule.h */, … … 21417 21423 52CCA9E815E3F64C0053C77F /* DOMDOMNamedFlowCollection.h in Headers */, 21418 21424 52CCA9EA15E3F64C0053C77F /* DOMDOMNamedFlowCollectionInternal.h in Headers */, 21425 E4DEAA1817A93DC3000E0430 /* StyleResolveTree.h in Headers */, 21419 21426 2D9A247415B9C2E300D34527 /* DOMDOMSecurityPolicy.h in Headers */, 21420 21427 2D9A247515B9C2E300D34527 /* DOMDOMSecurityPolicyInternal.h in Headers */, … … 24539 24546 072CA86116CB4DC3008AE131 /* CaptionUserPreferences.cpp in Sources */, 24540 24547 079D086C162F21F900DB8658 /* CaptionUserPreferencesMediaAF.cpp in Sources */, 24548 E4DEAA1717A93DC3000E0430 /* StyleResolveTree.cpp in Sources */, 24541 24549 6550B69D099DF0270090D781 /* CDATASection.cpp in Sources */, 24542 24550 CDA98E0B1603CD6000FEA3B1 /* CDM.cpp in Sources */, -
trunk/Source/WebCore/css/StyleResolver.h
r153748 r153783 678 678 } 679 679 680 class StyleResolverParentPusher { 681 public: 682 StyleResolverParentPusher(Element* parent) 683 : m_parent(parent) 684 , m_pushedStyleResolver(0) 685 { } 686 void push() 687 { 688 if (m_pushedStyleResolver) 689 return; 690 m_pushedStyleResolver = m_parent->document()->ensureStyleResolver(); 691 m_pushedStyleResolver->pushParentElement(m_parent); 692 } 693 ~StyleResolverParentPusher() 694 { 695 if (!m_pushedStyleResolver) 696 return; 697 // This tells us that our pushed style selector is in a bad state, 698 // so we should just bail out in that scenario. 699 ASSERT(m_pushedStyleResolver == m_parent->document()->ensureStyleResolver()); 700 if (m_pushedStyleResolver != m_parent->document()->ensureStyleResolver()) 701 return; 702 m_pushedStyleResolver->popParentElement(m_parent); 703 } 704 705 private: 706 Element* m_parent; 707 StyleResolver* m_pushedStyleResolver; 708 }; 709 680 710 } // namespace WebCore 681 711 -
trunk/Source/WebCore/dom/Document.cpp
r153772 r153783 1743 1743 } 1744 1744 1745 void Document::recalcStyle(Style Change change)1745 void Document::recalcStyle(Style::Change change) 1746 1746 { 1747 1747 // we should not enter style recalc while painting … … 1784 1784 1785 1785 if (m_pendingStyleRecalcShouldForce) 1786 change = Force;1786 change = Style::Force; 1787 1787 1788 1788 // Recalculating the root style (on the document) is not needed in the common case. 1789 if ((change == Force) || (shouldDisplaySeamlesslyWithParent() && (change >=Inherit))) {1789 if ((change == Style::Force) || (shouldDisplaySeamlesslyWithParent() && (change >= Style::Inherit))) { 1790 1790 // style selector may set this again during recalc 1791 1791 m_hasNodesWithPlaceholderStyle = false; 1792 1792 1793 1793 RefPtr<RenderStyle> documentStyle = StyleResolver::styleForDocument(this, m_styleResolver ? m_styleResolver->fontSelector() : 0); 1794 Style Change ch = Node::diff(documentStyle.get(), renderer()->style(), this);1795 if ( ch !=NoChange)1794 Style::Change documentChange = Style::determineChange(documentStyle.get(), renderer()->style(), settings()); 1795 if (documentChange != Style::NoChange) 1796 1796 renderer()->setStyle(documentStyle.release()); 1797 1797 } … … 1801 1801 continue; 1802 1802 Element* element = toElement(n); 1803 if (change >= Inherit || element->childNeedsStyleRecalc() || element->needsStyleRecalc())1804 element->recalcStyle(change);1803 if (change >= Style::Inherit || element->childNeedsStyleRecalc() || element->needsStyleRecalc()) 1804 Style::resolveTree(element, change); 1805 1805 } 1806 1806 … … 1851 1851 1852 1852 AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0); 1853 recalcStyle( NoChange);1853 recalcStyle(Style::NoChange); 1854 1854 } 1855 1855 … … 1917 1917 // may not have had their real style calculated yet. Normally this gets cleaned when style sheets arrive 1918 1918 // but here we need up-to-date style immediately. 1919 recalcStyle( Force);1919 recalcStyle(Style::Force); 1920 1920 } 1921 1921 … … 2025 2025 #endif 2026 2026 2027 recalcStyle( Force);2027 recalcStyle(Style::Force); 2028 2028 2029 2029 RenderObject* render = renderer(); … … 3180 3180 { 3181 3181 AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0); 3182 recalcStyle( Force);3182 recalcStyle(Style::Force); 3183 3183 } 3184 3184 … … 5210 5210 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true); 5211 5211 5212 recalcStyle( Force);5212 recalcStyle(Style::Force); 5213 5213 } 5214 5214 -
trunk/Source/WebCore/dom/Document.h
r153772 r153783 45 45 #include "ScriptExecutionContext.h" 46 46 #include "StringWithDirection.h" 47 #include "StyleResolveTree.h" 47 48 #include "Timer.h" 48 49 #include "TreeScope.h" … … 506 507 PassRefPtr<Text> createEditingTextNode(const String&); 507 508 508 void recalcStyle(Style Change =NoChange);509 void recalcStyle(Style::Change = Style::NoChange); 509 510 bool childNeedsAndNotInStyleRecalc(); 510 511 void updateStyleIfNeeded(); -
trunk/Source/WebCore/dom/Element.cpp
r153772 r153783 108 108 return e && e->document()->isHTMLDocument() && e->isHTMLElement(); 109 109 } 110 111 class StyleResolverParentPusher {112 public:113 StyleResolverParentPusher(Element* parent)114 : m_parent(parent)115 , m_pushedStyleResolver(0)116 {117 }118 void push()119 {120 if (m_pushedStyleResolver)121 return;122 m_pushedStyleResolver = m_parent->document()->ensureStyleResolver();123 m_pushedStyleResolver->pushParentElement(m_parent);124 }125 ~StyleResolverParentPusher()126 {127 128 if (!m_pushedStyleResolver)129 return;130 131 // This tells us that our pushed style selector is in a bad state,132 // so we should just bail out in that scenario.133 ASSERT(m_pushedStyleResolver == m_parent->document()->ensureStyleResolver());134 if (m_pushedStyleResolver != m_parent->document()->ensureStyleResolver())135 return;136 137 m_pushedStyleResolver->popParentElement(m_parent);138 }139 140 private:141 Element* m_parent;142 StyleResolver* m_pushedStyleResolver;143 };144 110 145 111 typedef Vector<RefPtr<Attr> > AttrNodeList; … … 1498 1464 } 1499 1465 1500 bool Element::pseudoStyleCacheIsInvalid(const RenderStyle* currentStyle, RenderStyle* newStyle)1501 {1502 ASSERT(currentStyle == renderStyle());1503 ASSERT(renderer());1504 1505 if (!currentStyle)1506 return false;1507 1508 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles();1509 if (!pseudoStyleCache)1510 return false;1511 1512 size_t cacheSize = pseudoStyleCache->size();1513 for (size_t i = 0; i < cacheSize; ++i) {1514 RefPtr<RenderStyle> newPseudoStyle;1515 PseudoId pseudoId = pseudoStyleCache->at(i)->styleType();1516 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED)1517 newPseudoStyle = renderer()->uncachedFirstLineStyle(newStyle);1518 else1519 newPseudoStyle = renderer()->getUncachedPseudoStyle(PseudoStyleRequest(pseudoId), newStyle, newStyle);1520 if (!newPseudoStyle)1521 return true;1522 if (*newPseudoStyle != *pseudoStyleCache->at(i)) {1523 if (pseudoId < FIRST_INTERNAL_PSEUDOID)1524 newStyle->setHasPseudoStyle(pseudoId);1525 newStyle->addCachedPseudoStyle(newPseudoStyle);1526 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) {1527 // FIXME: We should do an actual diff to determine whether a repaint vs. layout1528 // is needed, but for now just assume a layout will be required. The diff code1529 // in RenderObject::setStyle would need to be factored out so that it could be reused.1530 renderer()->setNeedsLayoutAndPrefWidthsRecalc();1531 }1532 return true;1533 }1534 }1535 return false;1536 }1537 1538 1466 PassRefPtr<RenderStyle> Element::styleForRenderer() 1539 1467 { … … 1544 1472 1545 1473 return document()->ensureStyleResolver()->styleForElement(this); 1546 }1547 1548 void Element::recalcStyle(StyleChange change)1549 {1550 if (hasCustomStyleCallbacks()) {1551 if (!willRecalcStyle(change))1552 return;1553 }1554 1555 // Ref currentStyle in case it would otherwise be deleted when setting the new style in the renderer.1556 RefPtr<RenderStyle> currentStyle(renderStyle());1557 bool hasParentStyle = parentNodeForRenderingAndStyle() ? static_cast<bool>(parentNodeForRenderingAndStyle()->renderStyle()) : false;1558 bool hasDirectAdjacentRules = childrenAffectedByDirectAdjacentRules();1559 bool hasIndirectAdjacentRules = childrenAffectedByForwardPositionalRules();1560 1561 if ((change > NoChange || needsStyleRecalc())) {1562 if (hasRareData())1563 elementRareData()->resetComputedStyle();1564 }1565 if (hasParentStyle && (change >= Inherit || needsStyleRecalc())) {1566 StyleChange localChange = Detach;1567 RefPtr<RenderStyle> newStyle;1568 if (currentStyle) {1569 newStyle = styleForRenderer();1570 localChange = Node::diff(currentStyle.get(), newStyle.get(), document());1571 }1572 if (localChange == Detach) {1573 AttachContext reattachContext;1574 reattachContext.resolvedStyle = newStyle.get();1575 reattach(reattachContext);1576 1577 // attach recalculates the style for all children. No need to do it twice.1578 clearNeedsStyleRecalc();1579 clearChildNeedsStyleRecalc();1580 1581 if (hasCustomStyleCallbacks())1582 didRecalcStyle(change);1583 return;1584 }1585 1586 if (RenderObject* renderer = this->renderer()) {1587 if (localChange != NoChange || pseudoStyleCacheIsInvalid(currentStyle.get(), newStyle.get()) || (change == Force && renderer->requiresForcedStyleRecalcPropagation()) || styleChangeType() == SyntheticStyleChange)1588 renderer->setAnimatableStyle(newStyle.get());1589 else if (needsStyleRecalc()) {1590 // Although no change occurred, we use the new style so that the cousin style sharing code won't get1591 // fooled into believing this style is the same.1592 renderer->setStyleInternal(newStyle.get());1593 }1594 }1595 1596 // If "rem" units are used anywhere in the document, and if the document element's font size changes, then go ahead and force font updating1597 // all the way down the tree. This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).1598 if (document()->styleSheetCollection()->usesRemUnits() && document()->documentElement() == this && localChange != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize()) {1599 // Cached RenderStyles may depend on the re units.1600 if (StyleResolver* styleResolver = document()->styleResolverIfExists())1601 styleResolver->invalidateMatchedPropertiesCache();1602 change = Force;1603 }1604 1605 if (change != Force) {1606 if (styleChangeType() >= FullStyleChange)1607 change = Force;1608 else1609 change = localChange;1610 }1611 }1612 StyleResolverParentPusher parentPusher(this);1613 1614 // FIXME: This does not care about sibling combinators. Will be necessary in XBL2 world.1615 if (ElementShadow* shadow = this->shadow()) {1616 if (change >= Inherit || shadow->childNeedsStyleRecalc() || shadow->needsStyleRecalc()) {1617 parentPusher.push();1618 shadow->recalcStyle(change);1619 }1620 }1621 1622 updatePseudoElement(BEFORE, change);1623 1624 // FIXME: This check is good enough for :hover + foo, but it is not good enough for :hover + foo + bar.1625 // For now we will just worry about the common case, since it's a lot trickier to get the second case right1626 // without doing way too much re-resolution.1627 bool forceCheckOfNextElementSibling = false;1628 bool forceCheckOfAnyElementSibling = false;1629 for (Node *n = firstChild(); n; n = n->nextSibling()) {1630 if (n->isTextNode()) {1631 toText(n)->recalcTextStyle(change);1632 continue;1633 }1634 if (!n->isElementNode())1635 continue;1636 Element* element = toElement(n);1637 bool childRulesChanged = element->needsStyleRecalc() && element->styleChangeType() == FullStyleChange;1638 if ((forceCheckOfNextElementSibling || forceCheckOfAnyElementSibling))1639 element->setNeedsStyleRecalc();1640 if (change >= Inherit || element->childNeedsStyleRecalc() || element->needsStyleRecalc()) {1641 parentPusher.push();1642 element->recalcStyle(change);1643 }1644 forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;1645 forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules);1646 }1647 1648 updatePseudoElement(AFTER, change);1649 1650 clearNeedsStyleRecalc();1651 clearChildNeedsStyleRecalc();1652 1653 if (hasCustomStyleCallbacks())1654 didRecalcStyle(change);1655 1474 } 1656 1475 … … 2492 2311 } 2493 2312 2494 void Element::updatePseudoElement(PseudoId pseudoId, Style Change change)2313 void Element::updatePseudoElement(PseudoId pseudoId, Style::Change change) 2495 2314 { 2496 2315 PseudoElement* existing = pseudoElement(pseudoId); … … 2498 2317 // PseudoElement styles hang off their parent element's style so if we needed 2499 2318 // a style recalc we should Force one on the pseudo. 2500 existing->recalcStyle(needsStyleRecalc() ?Force : change);2319 Style::resolveTree(existing, needsStyleRecalc() ? Style::Force : change); 2501 2320 2502 2321 // Wait until our parent is not displayed or pseudoElementRendererIsNeeded … … 3128 2947 } 3129 2948 3130 bool Element::willRecalcStyle(StyleChange) 2949 void Element::resetComputedStyle() 2950 { 2951 if (!hasRareData()) 2952 return; 2953 elementRareData()->resetComputedStyle(); 2954 } 2955 2956 bool Element::willRecalcStyle(Style::Change) 3131 2957 { 3132 2958 ASSERT(hasCustomStyleCallbacks()); … … 3134 2960 } 3135 2961 3136 void Element::didRecalcStyle(Style Change)2962 void Element::didRecalcStyle(Style::Change) 3137 2963 { 3138 2964 ASSERT(hasCustomStyleCallbacks()); 3139 2965 } 3140 3141 2966 3142 2967 PassRefPtr<RenderStyle> Element::customStyleForRenderer() -
trunk/Source/WebCore/dom/Element.h
r152345 r153783 33 33 #include "ScrollTypes.h" 34 34 #include "SpaceSplitString.h" 35 #include "StyleResolveTree.h" 35 36 36 37 namespace WebCore { … … 415 416 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 416 417 virtual bool rendererIsNeeded(const NodeRenderingContext&); 417 void recalcStyle(StyleChange = NoChange);418 418 void didAffectSelector(AffectedSelectorMask); 419 419 … … 658 658 virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement); 659 659 660 virtual bool willRecalcStyle(Style::Change); 661 virtual void didRecalcStyle(Style::Change); 662 void updatePseudoElement(PseudoId, Style::Change = Style::NoChange); 663 void resetComputedStyle(); 664 660 665 protected: 661 666 Element(const QualifiedName& tagName, Document* document, ConstructionType type) … … 670 675 virtual void removeAllEventListeners() OVERRIDE FINAL; 671 676 672 virtual bool willRecalcStyle(StyleChange);673 virtual void didRecalcStyle(StyleChange);674 677 virtual PassRefPtr<RenderStyle> customStyleForRenderer(); 675 678 … … 693 696 bool isUserActionElementHovered() const; 694 697 695 void updatePseudoElement(PseudoId, StyleChange = NoChange);696 698 PassRefPtr<PseudoElement> createPseudoElementIfNeeded(PseudoId); 697 699 void setPseudoElement(PseudoId, PassRefPtr<PseudoElement>); … … 737 739 virtual void formatForDebugger(char* buffer, unsigned length) const; 738 740 #endif 739 740 bool pseudoStyleCacheIsInvalid(const RenderStyle* currentStyle, RenderStyle* newStyle);741 741 742 742 void cancelFocusAppearanceUpdate(); -
trunk/Source/WebCore/dom/ElementShadow.cpp
r151839 r153783 114 114 } 115 115 116 void ElementShadow::recalcStyle( Node::StyleChange change)116 void ElementShadow::recalcStyle(Style::Change change) 117 117 { 118 118 if (ShadowRoot* root = shadowRoot()) -
trunk/Source/WebCore/dom/ElementShadow.h
r151839 r153783 62 62 bool childNeedsStyleRecalc() const; 63 63 bool needsStyleRecalc() const; 64 void recalcStyle( Node::StyleChange);64 void recalcStyle(Style::Change); 65 65 void removeAllEventListeners(); 66 66 -
trunk/Source/WebCore/dom/Node.cpp
r153772 r153783 321 321 } 322 322 323 Node::StyleChange Node::diff(const RenderStyle* s1, const RenderStyle* s2, Document* doc)324 {325 StyleChange ch = NoInherit;326 EDisplay display1 = s1 ? s1->display() : NONE;327 bool fl1 = s1 && s1->hasPseudoStyle(FIRST_LETTER);328 EDisplay display2 = s2 ? s2->display() : NONE;329 bool fl2 = s2 && s2->hasPseudoStyle(FIRST_LETTER);330 331 // We just detach if a renderer acquires or loses a column-span, since spanning elements332 // typically won't contain much content.333 bool colSpan1 = s1 && s1->columnSpan();334 bool colSpan2 = s2 && s2->columnSpan();335 336 bool specifiesColumns1 = s1 && (!s1->hasAutoColumnCount() || !s1->hasAutoColumnWidth());337 bool specifiesColumns2 = s2 && (!s2->hasAutoColumnCount() || !s2->hasAutoColumnWidth());338 339 if (display1 != display2 || fl1 != fl2 || colSpan1 != colSpan2340 || (specifiesColumns1 != specifiesColumns2 && doc->settings()->regionBasedColumnsEnabled())341 || (s1 && s2 && !s1->contentDataEquivalent(s2)))342 ch = Detach;343 else if (!s1 || !s2)344 ch = Inherit;345 else if (*s1 == *s2)346 ch = NoChange;347 else if (s1->inheritedNotEqual(s2))348 ch = Inherit;349 else if (s1->hasExplicitlyInheritedProperties() || s2->hasExplicitlyInheritedProperties())350 ch = Inherit;351 352 // If the pseudoStyles have changed, we want any StyleChange that is not NoChange353 // because setStyle will do the right thing with anything else.354 if (ch == NoChange && s1->hasAnyPublicPseudoStyles()) {355 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; ch == NoChange && pseudoId < FIRST_INTERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) {356 if (s1->hasPseudoStyle(pseudoId)) {357 RenderStyle* ps2 = s2->getCachedPseudoStyle(pseudoId);358 if (!ps2)359 ch = NoInherit;360 else {361 RenderStyle* ps1 = s1->getCachedPseudoStyle(pseudoId);362 ch = ps1 && *ps1 == *ps2 ? NoChange : NoInherit;363 }364 }365 }366 }367 368 // When text-combine property has been changed, we need to prepare a separate renderer object.369 // When text-combine is on, we use RenderCombineText, otherwise RenderText.370 // https://bugs.webkit.org/show_bug.cgi?id=55069371 if ((s1 && s2) && (s1->hasTextCombine() != s2->hasTextCombine()))372 ch = Detach;373 374 // We need to reattach the node, so that it is moved to the correct RenderFlowThread.375 if ((s1 && s2) && (s1->flowThread() != s2->flowThread()))376 ch = Detach;377 378 // When the region thread has changed, we need to prepare a separate render region object.379 if ((s1 && s2) && (s1->regionThread() != s2->regionThread()))380 ch = Detach;381 382 return ch;383 }384 385 323 void Node::trackForDebugging() 386 324 { -
trunk/Source/WebCore/dom/Node.h
r153772 r153783 169 169 static void dumpStatistics(); 170 170 171 enum StyleChange { NoChange, NoInherit, Inherit, Detach, Force };172 static StyleChange diff(const RenderStyle*, const RenderStyle*, Document*);173 174 171 virtual ~Node(); 175 172 void willBeDeletedFrom(Document*); -
trunk/Source/WebCore/dom/PseudoElement.cpp
r151282 r153783 106 106 } 107 107 108 void PseudoElement::didRecalcStyle(Style Change)108 void PseudoElement::didRecalcStyle(Style::Change) 109 109 { 110 110 if (!renderer()) -
trunk/Source/WebCore/dom/PseudoElement.h
r152347 r153783 61 61 PseudoElement(Element*, PseudoId); 62 62 63 virtual void didRecalcStyle(Style Change) OVERRIDE;63 virtual void didRecalcStyle(Style::Change) OVERRIDE; 64 64 virtual PseudoId customPseudoId() const OVERRIDE { return m_pseudoId; } 65 65 -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r151282 r153783 123 123 } 124 124 125 void ShadowRoot::recalcStyle(Style Change change)125 void ShadowRoot::recalcStyle(Style::Change change) 126 126 { 127 127 // ShadowRoot doesn't support custom callbacks. … … 133 133 for (Node* child = firstChild(); child; child = child->nextSibling()) { 134 134 if (child->isElementNode()) 135 toElement(child)->recalcStyle(change);135 Style::resolveTree(toElement(child), change); 136 136 else if (child->isTextNode()) 137 137 toText(child)->recalcTextStyle(change); … … 162 162 m_resetStyleInheritance = value; 163 163 if (attached() && owner()) 164 owner()->recalcStyle( Force);164 owner()->recalcStyle(Style::Force); 165 165 } 166 166 } -
trunk/Source/WebCore/dom/ShadowRoot.h
r151282 r153783 57 57 virtual ~ShadowRoot(); 58 58 59 void recalcStyle(Style Change);59 void recalcStyle(Style::Change); 60 60 61 61 virtual bool applyAuthorStyles() const OVERRIDE { return m_applyAuthorStyles; } -
trunk/Source/WebCore/dom/Text.cpp
r153548 r153783 283 283 } 284 284 285 void Text::recalcTextStyle(Style Change change)285 void Text::recalcTextStyle(Style::Change change) 286 286 { 287 287 RenderText* renderer = toRenderText(this->renderer()); 288 288 289 if (change != NoChange && renderer)289 if (change != Style::NoChange && renderer) 290 290 renderer->setStyle(document()->ensureStyleResolver()->styleForText(this)); 291 291 -
trunk/Source/WebCore/dom/Text.h
r152320 r153783 25 25 26 26 #include "CharacterData.h" 27 #include "StyleResolveTree.h" 27 28 28 29 namespace WebCore { … … 45 46 PassRefPtr<Text> replaceWholeText(const String&, ExceptionCode&); 46 47 47 void recalcTextStyle(Style Change);48 void recalcTextStyle(Style::Change); 48 49 void createTextRendererIfNeeded(); 49 50 bool textRendererIsNeeded(const NodeRenderingContext&); -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r152218 r153783 301 301 } 302 302 303 void HTMLFormControlElement::didRecalcStyle(Style Change)303 void HTMLFormControlElement::didRecalcStyle(Style::Change) 304 304 { 305 305 // updateFromElement() can cause the selection to change, and in turn -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r151282 r153783 121 121 virtual bool isMouseFocusable() const OVERRIDE; 122 122 123 virtual void didRecalcStyle(Style Change) OVERRIDE;123 virtual void didRecalcStyle(Style::Change) OVERRIDE; 124 124 125 125 virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) OVERRIDE; -
trunk/Source/WebCore/html/HTMLFrameSetElement.cpp
r151282 r153783 201 201 } 202 202 203 bool HTMLFrameSetElement::willRecalcStyle(Style Change)203 bool HTMLFrameSetElement::willRecalcStyle(Style::Change) 204 204 { 205 205 if (needsStyleRecalc() && renderer()) { -
trunk/Source/WebCore/html/HTMLFrameSetElement.h
r151282 r153783 78 78 virtual void defaultEventHandler(Event*); 79 79 80 virtual bool willRecalcStyle(Style Change);80 virtual bool willRecalcStyle(Style::Change) OVERRIDE; 81 81 82 82 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; -
trunk/Source/WebCore/html/HTMLIFrameElement.cpp
r153772 r153783 107 107 } 108 108 109 void HTMLIFrameElement::didRecalcStyle(Style Change styleChange)109 void HTMLIFrameElement::didRecalcStyle(Style::Change styleChange) 110 110 { 111 111 if (!shouldDisplaySeamlessly()) 112 112 return; 113 113 Document* childDocument = contentDocument(); 114 if (styleChange >= Inherit || childDocument->childNeedsStyleRecalc() || childDocument->needsStyleRecalc())114 if (styleChange >= Style::Inherit || childDocument->childNeedsStyleRecalc() || childDocument->needsStyleRecalc()) 115 115 contentDocument()->recalcStyle(styleChange); 116 116 } -
trunk/Source/WebCore/html/HTMLIFrameElement.h
r153772 r153783 45 45 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 46 46 47 virtual void didRecalcStyle(Style Change) OVERRIDE;47 virtual void didRecalcStyle(Style::Change) OVERRIDE; 48 48 }; 49 49 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r153772 r153783 652 652 } 653 653 654 void HTMLMediaElement::didRecalcStyle(Style Change)654 void HTMLMediaElement::didRecalcStyle(Style::Change) 655 655 { 656 656 if (renderer()) -
trunk/Source/WebCore/html/HTMLMediaElement.h
r153772 r153783 437 437 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 438 438 virtual void removedFrom(ContainerNode*) OVERRIDE; 439 virtual void didRecalcStyle(Style Change);440 439 virtual void didRecalcStyle(Style::Change); 440 441 441 virtual void defaultEventHandler(Event*); 442 442 -
trunk/Source/WebCore/html/HTMLOptionElement.cpp
r152211 r153783 324 324 } 325 325 326 void HTMLOptionElement::didRecalcStyle(Style Change)326 void HTMLOptionElement::didRecalcStyle(Style::Change) 327 327 { 328 328 // FIXME: This is nasty, we ask our owner select to repaint even if the new -
trunk/Source/WebCore/html/HTMLOptionElement.h
r152353 r153783 87 87 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE; 88 88 89 void didRecalcStyle(Style Change) OVERRIDE;89 void didRecalcStyle(Style::Change) OVERRIDE; 90 90 91 91 String collectOptionInnerText() const; -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r153145 r153783 225 225 } 226 226 227 bool HTMLPlugInImageElement::willRecalcStyle(Style Change)227 bool HTMLPlugInImageElement::willRecalcStyle(Style::Change) 228 228 { 229 229 // FIXME: Why is this necessary? Manual re-attach is almost always wrong. … … 304 304 m_customStyleForPageCache = RenderStyle::clone(renderStyle); 305 305 m_customStyleForPageCache->setDisplay(NONE); 306 recalcStyle(Force);306 Style::resolveTree(this, Style::Force); 307 307 } 308 308 … … 314 314 if (m_customStyleForPageCache) { 315 315 m_customStyleForPageCache = 0; 316 recalcStyle(Force);316 Style::resolveTree(this, Style::Force); 317 317 } 318 318 -
trunk/Source/WebCore/html/HTMLPlugInImageElement.h
r151947 r153783 127 127 private: 128 128 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE; 129 virtual bool willRecalcStyle(Style Change) OVERRIDE;129 virtual bool willRecalcStyle(Style::Change) OVERRIDE; 130 130 131 131 void didAddUserAgentShadowRoot(ShadowRoot*) OVERRIDE; -
trunk/Source/WebCore/inspector/InspectorOverlay.cpp
r151425 r153783 302 302 303 303 // Position DOM elements. 304 overlayPage()->mainFrame()->document()->recalcStyle( Node::Force);304 overlayPage()->mainFrame()->document()->recalcStyle(Style::Force); 305 305 if (overlayView->needsLayout()) 306 306 overlayView->layout(); -
trunk/Source/WebCore/loader/DocumentWriter.cpp
r149830 r153783 209 209 if (m_decoder->encoding().usesVisualOrdering()) 210 210 m_frame->document()->setVisuallyOrdered(); 211 m_frame->document()->recalcStyle( Node::Force);211 m_frame->document()->recalcStyle(Style::Force); 212 212 } 213 213 -
trunk/Source/WebCore/page/Frame.cpp
r153431 r153783 930 930 m_textZoomFactor = textZoomFactor; 931 931 932 document->recalcStyle( Node::Force);932 document->recalcStyle(Style::Force); 933 933 934 934 for (RefPtr<Frame> child = tree()->firstChild(); child; child = child->tree()->nextSibling()) -
trunk/Source/WebCore/page/Page.cpp
r153704 r153783 780 780 document->renderer()->setNeedsLayout(true); 781 781 782 document->recalcStyle( Node::Force);782 document->recalcStyle(Style::Force); 783 783 784 784 // Transform change on RenderView doesn't trigger repaint on non-composited contents. -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r153781 r153783 6754 6754 ASSERT(firstLetter->isFloating() || firstLetter->isInline()); 6755 6755 6756 if ( Node::diff(firstLetter->style(), pseudoStyle, document()) == Node::Detach) {6756 if (Style::determineChange(firstLetter->style(), pseudoStyle, document()->settings()) == Style::Detach) { 6757 6757 // The first-letter renderer needs to be replaced. Create a new renderer of the right type. 6758 6758 RenderBoxModelObject* newFirstLetter; -
trunk/Source/WebCore/svg/SVGElement.cpp
r152553 r153783 89 89 } 90 90 91 bool SVGElement::willRecalcStyle(Style Change change)91 bool SVGElement::willRecalcStyle(Style::Change change) 92 92 { 93 93 if (!hasSVGRareData() || styleChangeType() == SyntheticStyleChange) … … 95 95 // If the style changes because of a regular property change (not induced by SMIL animations themselves) 96 96 // reset the "computed style without SMIL style properties", so the base value change gets reflected. 97 if (change > NoChange || needsStyleRecalc())97 if (change > Style::NoChange || needsStyleRecalc()) 98 98 svgRareData()->setNeedsOverrideComputedStyleUpdate(); 99 99 return true; -
trunk/Source/WebCore/svg/SVGElement.h
r152346 r153783 150 150 RenderStyle* computedStyle(PseudoId = NOPSEUDO); 151 151 virtual RenderStyle* virtualComputedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return computedStyle(pseudoElementSpecifier); } 152 virtual bool willRecalcStyle(Style Change);152 virtual bool willRecalcStyle(Style::Change); 153 153 154 154 virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; } -
trunk/Source/WebCore/svg/SVGUseElement.cpp
r152963 r153783 270 270 } 271 271 272 bool SVGUseElement::willRecalcStyle(Style Change)272 bool SVGUseElement::willRecalcStyle(Style::Change) 273 273 { 274 274 if (!m_wasInsertedByParser && m_needsShadowTreeRecreation && renderer() && needsStyleRecalc()) -
trunk/Source/WebCore/svg/SVGUseElement.h
r152963 r153783 31 31 #include "SVGNames.h" 32 32 #include "SVGURIReference.h" 33 #include "StyleResolveTree.h" 33 34 34 35 namespace WebCore { … … 67 68 virtual void svgAttributeChanged(const QualifiedName&); 68 69 69 virtual bool willRecalcStyle(Style Change);70 virtual bool willRecalcStyle(Style::Change); 70 71 71 72 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
Note:
See TracChangeset
for help on using the changeset viewer.