Move style recalculation out from Element
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Aug 2013 12:02:04 +0000 (12:02 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Aug 2013 12:02:04 +0000 (12:02 +0000)
commit25ade4bb53a5f73a1221bcd6493889b6c51aae00
treea47872190a30eb0a155178c21cab89194e2fc0b7
parent0f5e412b3d7d3fc570ba5e9498e44b089c87118d
Move style recalculation out from Element
https://bugs.webkit.org/show_bug.cgi?id=119497

Reviewed by Andreas Kling.

Element currently does too much. Element::recalcStyle() and the related functions can be turned into
standalone functions that operate on DOM tree. This will also give more freedom for future refactoring,
for example making style recalculation non-recursive.

* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolveTree.cpp: Added.
(WebCore::Style::determineChange):

    - moved and renamed from Node::diff
    - factored to use early return style
    - simplifield the null input logic

(WebCore::Style::pseudoStyleCacheIsInvalid):

    - moved from Element::pseudoStyleCacheIsInvalid
    - narrowed to take RenderObject rather than operate on Element

(WebCore::Style::resolveLocal):

    - split from Element::recalcStyle
    - factored to use early return style

(WebCore::Style::resolveTree):

    - moved and renamed from Element::recalcStyle

* css/StyleResolveTree.h: Added.

    - introcuduce Style namespace for style related classes and functions
    - move and rename Node::StyleChange -> Style::Change

* css/StyleResolver.h:
(WebCore::StyleResolverParentPusher::StyleResolverParentPusher):
(WebCore::StyleResolverParentPusher::push):
(WebCore::StyleResolverParentPusher::~StyleResolverParentPusher):

    Moved this stack helper to StyleResolver.h for now since it is needed by both
    StyleRecalculation and Element.

* dom/Document.cpp:
(WebCore::Document::recalcStyle):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::updateLayoutIgnorePendingStylesheets):
(WebCore::Document::attach):
(WebCore::Document::styleResolverChanged):
(WebCore::Document::webkitWillEnterFullScreenForElement):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::shouldIgnoreAttributeCase):
(WebCore::Element::updatePseudoElement):
(WebCore::Element::resetComputedStyle):
(WebCore::Element::willRecalcStyle):
(WebCore::Element::didRecalcStyle):
* dom/Element.h:

    - remove Element::recalcStyle
    - make a few private functions needed by StyleRecalculation public

* dom/ElementShadow.cpp:
(WebCore::ElementShadow::recalcStyle):
* dom/ElementShadow.h:
* dom/Node.cpp:
* dom/Node.h:

    - remove Node::StyleChange
    - remove Node::diff

* dom/PseudoElement.cpp:
(WebCore::PseudoElement::didRecalcStyle):
* dom/PseudoElement.h:
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::recalcStyle):
(WebCore::ShadowRoot::setResetStyleInheritance):
* dom/ShadowRoot.h:
* dom/Text.cpp:
(WebCore::Text::recalcTextStyle):
* dom/Text.h:
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::didRecalcStyle):
* html/HTMLFormControlElement.h:
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::willRecalcStyle):
* html/HTMLFrameSetElement.h:
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::didRecalcStyle):
* html/HTMLIFrameElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::didRecalcStyle):
* html/HTMLMediaElement.h:
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::didRecalcStyle):
* html/HTMLOptionElement.h:
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::willRecalcStyle):
(WebCore::HTMLPlugInImageElement::documentWillSuspendForPageCache):
(WebCore::HTMLPlugInImageElement::documentDidResumeFromPageCache):
* html/HTMLPlugInImageElement.h:
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::update):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::reportDataReceived):
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):
* page/Page.cpp:
(WebCore::Page::setPageScaleFactor):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateFirstLetterStyle):
* svg/SVGElement.cpp:
(WebCore::SVGElement::willRecalcStyle):
* svg/SVGElement.h:
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::willRecalcStyle):
* svg/SVGUseElement.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/StyleResolveTree.cpp [new file with mode: 0644]
Source/WebCore/css/StyleResolveTree.h [new file with mode: 0644]
Source/WebCore/css/StyleResolver.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/ElementShadow.cpp
Source/WebCore/dom/ElementShadow.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/PseudoElement.cpp
Source/WebCore/dom/PseudoElement.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/Text.cpp
Source/WebCore/dom/Text.h
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLFrameSetElement.cpp
Source/WebCore/html/HTMLFrameSetElement.h
Source/WebCore/html/HTMLIFrameElement.cpp
Source/WebCore/html/HTMLIFrameElement.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLOptionElement.h
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/DocumentWriter.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGElement.h
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/SVGUseElement.h