• antti@apple.com's avatar
    Create render tree lazily · 4942ea58
    antti@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=120685
    
    Source/WebCore: 
    
    Reviewed by Andreas Kling.
    
    We currently recompute style and construct renderer for each DOM node immediately after they are added to 
    the tree. This is often inefficient as the style may change immediately afterwards and the work needs to be
    redone. 
            
    With this patch we always compute style and construct render tree lazily, either on style recalc timer or
    synchronously when they are needed. It also removes the 'attached' bit. If document has render tree then
    all nodes are conceptually "attached" even if this happens lazily.
            
    The patch slightly changes behavior of implicit CSS transitions. A synchronous style change during parsing
    may not trigger the animation anymore as laziness means we don't see anything changing. This matches Firefox
    and Chrome in our test cases.
            
    * WebCore.exp.in:
    * bindings/js/JSNodeCustom.cpp:
    (WebCore::JSNode::insertBefore):
    (WebCore::JSNode::replaceChild):
    (WebCore::JSNode::appendChild):
            
        All attaching is now lazy, remove AttachLazily.
    
    * css/CSSComputedStyleDeclaration.cpp:
    (WebCore::ComputedStyleExtractor::propertyValue):
            
        SVG renderers with !isValid() have empty display property value for some reason. Keep the behavior.
    
    * dom/ContainerNode.cpp:
    (WebCore::ContainerNode::insertBefore):
    (WebCore::ContainerNode::parserInsertBefore):
    (WebCore::ContainerNode::replaceChild):
    (WebCore::ContainerNode::appendChild):
    (WebCore::ContainerNode::parserAppendChild):
    (WebCore::ContainerNode::updateTreeAfterInsertion):
    * dom/ContainerNode.h:
    * dom/Document.cpp:
    (WebCore::Document::~Document):
    (WebCore::Document::updateStyleIfNeeded):
    (WebCore::Document::createRenderTree):
    (WebCore::Document::destroyRenderTree):
            
        Remove attach bit maintenance.
    
    (WebCore::Document::webkitDidExitFullScreenForElement):
            
        Do lazy render tree reconstruction after returning from full screen. That is the only reliable way
        to get the render tree back to decent shape.
    
    * dom/Element.cpp:
    (WebCore::Element::isFocusable):
            
        Remove pointless !renderer()->needsLayout() assert.
    
    (WebCore::Element::addShadowRoot):
    (WebCore::Element::childShouldCreateRenderer):
    (WebCore::Element::resetComputedStyle):
            
        Take care to reset computed style in all descendants. attachRenderTree no longer does this.
    
    * dom/Element.h:
    * dom/Node.cpp:
    (WebCore::Node::insertBefore):
    (WebCore::Node::replaceChild):
    (WebCore::Node::appendChild):
    (WebCore::Node::setNeedsStyleRecalc):
            
        Propagate ReconstructRenderTree.
    
    (WebCore::Node::attached):
            
        Emulate the behavior of old attached bit for now so existing code calling this mostly stays working.
    
    * dom/Node.h:
            
        Add new ReconstructRenderTree value for StyleChangeType.
    
    * dom/Range.cpp:
    (WebCore::Range::isPointInRange):
    (WebCore::Range::comparePoint):
    (WebCore::Range::compareNode):
    (WebCore::Range::intersectsNode):
    * editing/AppendNodeCommand.cpp:
    (WebCore::AppendNodeCommand::doApply):
    * editing/CompositeEditCommand.cpp:
    (WebCore::CompositeEditCommand::canRebalance):
    * editing/InsertNodeBeforeCommand.cpp:
    (WebCore::InsertNodeBeforeCommand::doApply):
    * html/HTMLDetailsElement.cpp:
    (WebCore::HTMLDetailsElement::didAddUserAgentShadowRoot):
    * html/HTMLDocument.cpp:
    (WebCore::HTMLDocument::activeElement):
    * html/HTMLElement.cpp:
    (WebCore::HTMLElement::setInnerText):
            
        TextControlInnerTextElement always preserves newline even if it doesn't have style yet.
    
    (WebCore::HTMLElement::supportsFocus):
    * html/HTMLEmbedElement.cpp:
    (WebCore::HTMLEmbedElement::parseAttribute):
    * html/HTMLFormControlElement.cpp:
    (WebCore::shouldAutofocus):
            
        Don't autofocus until we have renderer.
    
    * html/HTMLFormControlElementWithState.cpp:
    (WebCore::HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState):
    * html/HTMLFrameElementBase.cpp:
    (WebCore::HTMLFrameElementBase::didNotifySubtreeInsertions):
    * html/HTMLInputElement.cpp:
    (WebCore::HTMLInputElement::updateType):
            
        Lazy render tree construction.
    
    (WebCore::HTMLInputElement::parseAttribute):
    (WebCore::HTMLInputElement::defaultEventHandler):
    * html/HTMLMediaElement.cpp:
    (WebCore::HTMLMediaElement::parseAttribute):
    * html/HTMLObjectElement.cpp:
    (WebCore::HTMLObjectElement::parseAttribute):
    * html/HTMLSummaryElement.cpp:
    (WebCore::HTMLSummaryElement::didAddUserAgentShadowRoot):
    * html/parser/HTMLConstructionSite.cpp:
    (WebCore::executeTask):
            
        Don't attach renderer after construction.
    
    * html/parser/HTMLTreeBuilder.cpp:
    (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
    * html/shadow/ContentDistributor.cpp:
    (WebCore::ContentDistributor::invalidateDistribution):
    * html/shadow/InsertionPoint.cpp:
    (WebCore::InsertionPoint::willAttachRenderers):
    (WebCore::InsertionPoint::willDetachRenderers):
    * html/shadow/MediaControlElements.cpp:
    (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
    * html/shadow/MediaControls.cpp:
    (WebCore::MediaControls::createTextTrackDisplay):
    * html/shadow/MediaControlsApple.cpp:
    (WebCore::MediaControlsApple::createControls):
    * html/track/TextTrackCue.cpp:
    (WebCore::TextTrackCue::getDisplayTree):
    * loader/PlaceholderDocument.cpp:
    (WebCore::PlaceholderDocument::createRenderTree):
    * loader/cache/CachedResourceLoader.cpp:
    (WebCore::CachedResourceLoader::preload):
    * style/StyleResolveTree.cpp:
    (WebCore::Style::attachTextRenderer):
    (WebCore::Style::detachTextRenderer):
            
        Remove attached bit maintenance.
    
    (WebCore::Style::attachChildren):
    (WebCore::Style::attachShadowRoot):
    (WebCore::Style::attachRenderTree):
    (WebCore::Style::detachShadowRoot):
    (WebCore::Style::detachRenderTree):
    (WebCore::Style::resolveLocal):
    * svg/SVGTests.cpp:
    (WebCore::SVGTests::handleAttributeChange):
            
        Make lazy.
    
    * testing/Internals.cpp:
    (WebCore::Internals::attached):
    (WebCore::Internals::elementRenderTreeAsText):
    (WebCore::Internals::markerAt):
    (WebCore::Internals::nodesFromRect):
    
    LayoutTests: 
    
    Reviewed by Andreas Kling.
            
    Most of these are non-visible render tree dump changes (they become simpler).
    
    * editing/selection/click-on-head-margin-expected.txt:
    * fast/css-generated-content/before-content-continuation-chain-expected.txt:
    * fast/css/transition-color-unspecified.html:
    * fast/dom/adopt-node-crash-2-expected.txt:
    * fast/dom/modify-node-and-while-in-the-callback-too-crash-expected.txt:
    * fast/forms/radio/radio_checked_dynamic-expected.txt:
    * fast/frames/lots-of-iframes-expected.txt:
    * fast/frames/sandboxed-iframe-autofocus-denied-expected.txt:
    * fast/table/table-row-style-not-updated-with-after-content-expected.txt:
    * fullscreen/full-screen-render-inline-expected.txt:
    * fullscreen/parent-flow-inline-with-block-child-expected.txt:
    * platform/mac/editing/inserting/break-blockquote-after-delete-expected.txt:
    * platform/mac/fast/css-generated-content/table-row-group-to-inline-expected.txt:
    * platform/mac/fast/dynamic/011-expected.txt:
    * platform/mac/fast/forms/formmove3-expected.txt:
    * platform/mac/fast/forms/preserveFormDuringResidualStyle-expected.txt:
    * platform/mac/fast/invalid/001-expected.txt:
    * platform/mac/fast/invalid/003-expected.txt:
    * platform/mac/fast/invalid/004-expected.txt:
    * platform/mac/fast/invalid/007-expected.txt:
    * platform/mac/fast/invalid/019-expected.txt:
    * platform/mac/fast/multicol/span/span-as-immediate-child-generated-content-expected.txt:
    * platform/mac/fast/multicol/span/span-as-immediate-columns-child-dynamic-expected.txt:
    * platform/mac/fast/multicol/span/span-as-nested-columns-child-dynamic-expected.txt:
    * platform/mac/fast/ruby/ruby-base-merge-block-children-crash-expected.txt:
    * platform/mac/tables/mozilla/bugs/bug113235-1-expected.txt:
    * platform/mac/tables/mozilla/bugs/bug647-expected.txt:
    * platform/mac/tables/mozilla/other/wa_table_tr_align-expected.txt:
    * plugins/plugin-remove-readystatechange-expected.txt:
    * svg/custom/system-language-crash-expected.txt:
    * transitions/equivalent-background-image-no-transition.html:
    * transitions/repeated-firing-background-color.html:
    * transitions/transition-duration-cleared-in-transitionend-crash.html:
    
        Adopt a few transition test cases to new behavior.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    4942ea58
Name
Last commit
Last update
..
npruntime Loading commit data...
resources Loading commit data...
script-tests Loading commit data...
snapshotting Loading commit data...
access-after-page-destroyed-2-expected.txt Loading commit data...
access-after-page-destroyed-2.html Loading commit data...
access-after-page-destroyed-expected.txt Loading commit data...
access-after-page-destroyed.html Loading commit data...
attach-during-destroy-expected.txt Loading commit data...
attach-during-destroy.html Loading commit data...
change-widget-and-click-crash-expected.txt Loading commit data...
change-widget-and-click-crash.html Loading commit data...
clicking-missing-plugin-fires-delegate-expected.txt Loading commit data...
clicking-missing-plugin-fires-delegate.html Loading commit data...
crash-restoring-plugin-page-from-page-cache-expected.txt Loading commit data...
crash-restoring-plugin-page-from-page-cache.html Loading commit data...
createScriptableObject-before-start-expected.txt Loading commit data...
createScriptableObject-before-start.html Loading commit data...
destroy-during-npp-new-expected.txt Loading commit data...
destroy-during-npp-new-object-with-fallback-content-expected.txt Loading commit data...
destroy-during-npp-new-object-with-fallback-content.html Loading commit data...
destroy-during-npp-new.html Loading commit data...
destroy-on-setwindow-expected.txt Loading commit data...
destroy-on-setwindow.html Loading commit data...
destroy-plugin-from-callback-expected.txt Loading commit data...
destroy-plugin-from-callback.html Loading commit data...
destroy-reentry-expected.txt Loading commit data...
destroy-reentry.html Loading commit data...
destroy-stream-twice-expected.txt Loading commit data...
destroy-stream-twice.html Loading commit data...
document-open-expected.txt Loading commit data...
document-open.html Loading commit data...
embed-attributes-setting-expected.txt Loading commit data...
embed-attributes-setting.html Loading commit data...
embed-attributes-style.html Loading commit data...
embed-inside-object-expected.txt Loading commit data...
embed-inside-object.html Loading commit data...
embed-prefers-plugins-for-images-expected.txt Loading commit data...
embed-prefers-plugins-for-images.html Loading commit data...
evaluate-js-after-removing-plugin-element-expected.txt Loading commit data...
evaluate-js-after-removing-plugin-element.html Loading commit data...
focus-expected.txt Loading commit data...
focus.html Loading commit data...
form-value-expected.txt Loading commit data...
form-value.html Loading commit data...
frameset-with-plugin-frame-expected.txt Loading commit data...
frameset-with-plugin-frame.html Loading commit data...
fullscreen-plugins-dont-reload-expected.txt Loading commit data...
fullscreen-plugins-dont-reload.html Loading commit data...
get-empty-url-expected.txt Loading commit data...
get-empty-url.html Loading commit data...
get-file-url-expected.txt Loading commit data...
get-file-url.html Loading commit data...
get-javascript-url-expected.txt Loading commit data...
get-javascript-url.html Loading commit data...
get-targeted-javascript-url-expected.txt Loading commit data...
get-targeted-javascript-url.html Loading commit data...
get-url-notify-with-url-that-fails-to-load-expected.txt Loading commit data...
get-url-notify-with-url-that-fails-to-load.html Loading commit data...
get-url-that-the-resource-load-delegate-will-disallow-expected.txt Loading commit data...
get-url-that-the-resource-load-delegate-will-disallow.html Loading commit data...
get-url-with-blank-target-expected.txt Loading commit data...
get-url-with-blank-target.html Loading commit data...
get-url-with-iframe-target-expected.txt Loading commit data...
get-url-with-iframe-target.html Loading commit data...
get-url-with-javascript-destroying-plugin-expected.txt Loading commit data...
get-url-with-javascript-destroying-plugin.html Loading commit data...
get-url-with-javascript-url-expected.txt Loading commit data...
get-url-with-javascript-url.html Loading commit data...
get-user-agent-with-null-npp-from-npp-new-expected.txt Loading commit data...
get-user-agent-with-null-npp-from-npp-new.html Loading commit data...
geturl-replace-query-expected.txt Loading commit data...
geturl-replace-query.html Loading commit data...
geturlnotify-during-document-teardown-expected.txt Loading commit data...
geturlnotify-during-document-teardown.html Loading commit data...
hidden-iframe-with-swf-plugin-expected.txt Loading commit data...
hidden-iframe-with-swf-plugin.html Loading commit data...
iframe-plugin-bgcolor-expected.txt Loading commit data...
iframe-plugin-bgcolor.html Loading commit data...
iframe-shims-expected.txt Loading commit data...
iframe-shims.html Loading commit data...
inner-html-display-none-expected.txt Loading commit data...
inner-html-display-none.html Loading commit data...
instance-available-before-stylesheets-loaded-expected.txt Loading commit data...
instance-available-before-stylesheets-loaded-object-expected.txt Loading commit data...
instance-available-before-stylesheets-loaded-object.html Loading commit data...
instance-available-before-stylesheets-loaded.html Loading commit data...
invalid-mime-with-valid-extension-shows-missing-plugin-expected.txt Loading commit data...
invalid-mime-with-valid-extension-shows-missing-plugin.html Loading commit data...
js-from-destroy-expected.txt Loading commit data...
js-from-destroy.html Loading commit data...
keyboard-events-expected.txt Loading commit data...
keyboard-events.html Loading commit data...
layout-in-beforeload-listener-affects-plugin-loading-expected.txt Loading commit data...
layout-in-beforeload-listener-affects-plugin-loading.html Loading commit data...
missing-plugin-expected.txt Loading commit data...
missing-plugin.html Loading commit data...
mouse-click-iframe-to-plugin-expected.txt Loading commit data...
mouse-click-iframe-to-plugin.html Loading commit data...
mouse-click-plugin-clears-selection.html Loading commit data...
mouse-events-expected.txt Loading commit data...
mouse-events-fixedpos-expected.txt Loading commit data...
mouse-events-fixedpos.html Loading commit data...
mouse-events.html Loading commit data...
mouse-move-over-plugin-in-frame-expected.txt Loading commit data...
mouse-move-over-plugin-in-frame.html Loading commit data...
multiple-plugins-expected.txt Loading commit data...
multiple-plugins.html Loading commit data...
navigator-mimeTypes-length-expected.txt Loading commit data...
navigator-mimeTypes-length.html Loading commit data...
navigator-plugins-disabled-expected.txt Loading commit data...
navigator-plugins-disabled.html Loading commit data...
navigator-plugins-expected.txt Loading commit data...
navigator-plugins.html Loading commit data...
nested-plugin-objects-expected.txt Loading commit data...
nested-plugin-objects.html Loading commit data...
netscape-destroy-plugin-script-objects-expected.txt Loading commit data...
netscape-destroy-plugin-script-objects.html Loading commit data...
netscape-dom-access-and-reload-expected.txt Loading commit data...
netscape-dom-access-and-reload.html Loading commit data...
netscape-dom-access.html Loading commit data...
netscape-plugin-map-data-to-src-expected.txt Loading commit data...
netscape-plugin-map-data-to-src.html Loading commit data...
netscape-plugin-page-cache-works-expected.txt Loading commit data...
netscape-plugin-page-cache-works.html Loading commit data...
netscape-plugin-property-access-exception-expected.txt Loading commit data...
netscape-plugin-property-access-exception.html Loading commit data...
netscape-plugin-setwindow-size-2-expected.txt Loading commit data...
netscape-plugin-setwindow-size-2.html Loading commit data...
netscape-plugin-setwindow-size-expected.txt Loading commit data...
netscape-plugin-setwindow-size.html Loading commit data...
no-mime-with-valid-extension-expected.txt Loading commit data...
no-mime-with-valid-extension.html Loading commit data...
npobject-js-wrapper-destroyed-after-plugin-unload-expected.txt Loading commit data...
npobject-js-wrapper-destroyed-after-plugin-unload.html Loading commit data...
npp-new-fails-expected.txt Loading commit data...
npp-new-fails.html Loading commit data...
npp-set-window-called-during-destruction-expected.txt Loading commit data...
npp-set-window-called-during-destruction.html Loading commit data...
null-npp-getvalue-pointer-expected.txt Loading commit data...
null-npp-getvalue-pointer.html Loading commit data...
object-embed-plugin-scripting-expected.txt Loading commit data...
object-embed-plugin-scripting.html Loading commit data...
object-onfocus-mutation-crash-expected.txt Loading commit data...
object-onfocus-mutation-crash.html Loading commit data...
open-and-close-window-with-plugin-expected.txt Loading commit data...
open-and-close-window-with-plugin.html Loading commit data...
override-node-method-expected.txt Loading commit data...
override-node-method.html Loading commit data...
pass-different-npp-struct-expected.txt Loading commit data...
pass-different-npp-struct.html Loading commit data...
plugin-clip-subframe-expected.txt Loading commit data...
plugin-clip-subframe.html Loading commit data...
plugin-document-back-forward-expected.txt Loading commit data...
plugin-document-back-forward.html Loading commit data...
plugin-document-load-prevented-userscript-expected.txt Loading commit data...
plugin-document-load-prevented-userscript.html Loading commit data...
plugin-document-willSendRequest-null-expected.txt Loading commit data...
plugin-document-willSendRequest-null.html Loading commit data...
plugin-initiate-popup-window.html Loading commit data...
plugin-javascript-access.html Loading commit data...
plugin-remove-readystatechange-expected.txt Loading commit data...
plugin-remove-readystatechange.html Loading commit data...
plugin-remove-subframe-expected.txt Loading commit data...
plugin-remove-subframe.html Loading commit data...
private-browsing-mode-2-expected.txt Loading commit data...
private-browsing-mode-2.html Loading commit data...
private-browsing-mode-expected.txt Loading commit data...
private-browsing-mode.html Loading commit data...
quicktime-plugin-replacement-expected.txt Loading commit data...
quicktime-plugin-replacement.html Loading commit data...
reentrant-update-widget-positions-expected.txt Loading commit data...
reentrant-update-widget-positions.html Loading commit data...
refcount-leaks-expected.txt Loading commit data...
refcount-leaks.html Loading commit data...
reloadplugins-and-pages-expected.txt Loading commit data...
reloadplugins-and-pages.html Loading commit data...
reloadplugins-no-pages-expected.txt Loading commit data...
reloadplugins-no-pages.html Loading commit data...
resize-from-plugin-expected.txt Loading commit data...
resize-from-plugin.html Loading commit data...
return-error-from-new-stream-callback-in-full-frame-plugin-expected.txt Loading commit data...
return-error-from-new-stream-callback-in-full-frame-plugin.html Loading commit data...
return-error-from-new-stream-doesnt-invoke-destroy-stream-expected.txt Loading commit data...
return-error-from-new-stream-doesnt-invoke-destroy-stream.html Loading commit data...
return-negative-one-from-write-expected.txt Loading commit data...
return-negative-one-from-write.html Loading commit data...
return-npobject-expected.txt Loading commit data...
return-npobject.html Loading commit data...
script-object-invoke-expected.txt Loading commit data...
script-object-invoke.html Loading commit data...
set-status-expected.txt Loading commit data...
set-status.html Loading commit data...
snapshot-appearance-expected.html Loading commit data...
snapshot-appearance.html Loading commit data...
unavailable-plugin-indicator-obscurity-expected.txt Loading commit data...
unavailable-plugin-indicator-obscurity.html Loading commit data...
update-widgets-crash-expected.txt Loading commit data...
update-widgets-crash.html Loading commit data...
window-open-expected.txt Loading commit data...
window-open.html Loading commit data...
windowless_plugin_paint_test-expected.txt Loading commit data...
windowless_plugin_paint_test.html Loading commit data...