WebCore:
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 May 2008 08:05:12 +0000 (08:05 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 May 2008 08:05:12 +0000 (08:05 +0000)
commit1353b18a94104f3e3446f57a6ed5c80e97e58289
tree7afa17ac83e996c92b84407a3036e60965dfa0f3
parentb3acbfd8a00b0fbae9adb66d7e5720a6e108778c
WebCore:

2008-05-29  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Dave Hyatt.

        - speed up DHTML using lazy style resolution and rendere creation

        This change introduces the concept of "lazy attach" - when a node
        is lazy attached, then instead of resolving style and creating a
        renderer right away, we just mark it as needing a style recalc.

        The patch makes use of this mechanism when inserting nodes directly
        using DOM APIs from script. For now this is only done for the
        JavaScript language binding but could also be done for other
        bindings in the future.

        Lazy attach helps some common DHTML patterns - when a node is
        added to the DOM, and then subsequently changed in a
        style-affecting way, this causes an extra style recalc. This is a
        fairly common pattern so it is better to be lazy.

        * bindings/js/JSNodeCustom.cpp:
        (WebCore::JSNode::insertBefore): Request lazy attach.
        (WebCore::JSNode::replaceChild): ditto
        (WebCore::JSNode::appendChild): ditto
        * dom/ContainerNode.cpp:
        (WebCore::ContainerNode::insertBefore): Support lazy attach.
        (WebCore::ContainerNode::replaceChild): ditto
        (WebCore::ContainerNode::appendChild): ditto
        (WebCore::ContainerNode::detach): Clear "changed child" bit if still set.
        * dom/ContainerNode.h:
        * dom/Element.cpp:
        (WebCore::Element::recalcStyle): Adjusted to properly reattach a
        lazy-attached node.
        * dom/Node.cpp:
        (WebCore::Node::insertBefore): Extra parameter for lazy attach
        (still doesn't do anything).
        (WebCore::Node::replaceChild): ditto
        (WebCore::Node::appendChild): ditto
        (WebCore::Node::setChanged): Unrelated but obvious optimization -
        stop marking ancestor as having a changed child once we already reach
        an ancestor so marked.
        (WebCore::outermostLazyAttachedAncestor): Helper function for lazyAttach.
        (WebCore::Node::lazyAttach): Implement lazy attach.
        (WebCore::Node::canLazyAttach): Virtual method - true for most nodes.
        * dom/Node.h:
        * dom/Text.cpp:
        (WebCore::Text::recalcStyle): Properly handle the case of a reattached node.
        * html/HTMLEmbedElement.h:
        (WebCore::HTMLEmbedElement::canLazyAttach): Refuse lazy attach, since
        plugins and frames do important work at rederer creation time.
        * html/HTMLFrameElementBase.h:
        (WebCore::HTMLFrameElementBase::canLazyAttach): Refuse lazy attach, since
        plugins and frames do important work at rederer creation time.
        * html/HTMLFrameSetElement.cpp:
        (WebCore::HTMLFrameSetElement::recalcStyle): Change order so that
        reattach works properly.
        * html/HTMLObjectElement.h:
        (WebCore::HTMLObjectElement::canLazyAttach): Refuse lazy attach, since
        plugins and frames do important work at rederer creation time.
        * html/HTMLOptGroupElement.cpp:
        (WebCore::HTMLOptGroupElement::insertBefore): Pass along extra param.
        (WebCore::HTMLOptGroupElement::replaceChild): ditto
        (WebCore::HTMLOptGroupElement::appendChild): ditto
        * html/HTMLOptGroupElement.h:
        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::insertBefore): Pass along extra param.
        (WebCore::HTMLSelectElement::replaceChild): ditto
        (WebCore::HTMLSelectElement::appendChild): ditto
        * html/HTMLSelectElement.h:
        * svg/SVGLocatable.cpp:
        (WebCore::SVGLocatable::getBBox): Add missing updateLayout call.
        * svg/SVGTextContentElement.cpp:
        (WebCore::SVGTextContentElement::getNumberOfChars): ditto
        (WebCore::SVGTextContentElement::getComputedTextLength): ditto
        (WebCore::SVGTextContentElement::getSubStringLength): ditto
        (WebCore::SVGTextContentElement::getStartPositionOfChar): ditto
        (WebCore::SVGTextContentElement::getEndPositionOfChar): ditto
        (WebCore::SVGTextContentElement::getExtentOfChar): ditto
        (WebCore::SVGTextContentElement::getRotationOfChar): ditto
        (WebCore::SVGTextContentElement::getCharNumAtPosition): ditto

LayoutTests:

2008-05-29  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Dave Hyatt.

        - Test cases for this change: "speed up DHTML using lazy style resolution and rendere creation"

        * http/tests/misc/acid3-expected.txt:
        * platform/mac/fast/dynamic/insert-before-table-part-in-continuation-expected.checksum:
        * platform/mac/fast/dynamic/insert-before-table-part-in-continuation-expected.png:
        * platform/mac/fast/dynamic/insert-before-table-part-in-continuation-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34193 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/misc/acid3-expected.txt
LayoutTests/platform/mac/fast/dynamic/insert-before-table-part-in-continuation-expected.checksum
LayoutTests/platform/mac/fast/dynamic/insert-before-table-part-in-continuation-expected.png
LayoutTests/platform/mac/fast/dynamic/insert-before-table-part-in-continuation-expected.txt
WebCore/ChangeLog
WebCore/bindings/js/JSNodeCustom.cpp
WebCore/dom/ContainerNode.cpp
WebCore/dom/ContainerNode.h
WebCore/dom/Element.cpp
WebCore/dom/Node.cpp
WebCore/dom/Node.h
WebCore/dom/Text.cpp
WebCore/html/HTMLEmbedElement.h
WebCore/html/HTMLFrameElementBase.h
WebCore/html/HTMLFrameSetElement.cpp
WebCore/html/HTMLObjectElement.h
WebCore/html/HTMLOptGroupElement.cpp
WebCore/html/HTMLOptGroupElement.h
WebCore/html/HTMLSelectElement.cpp
WebCore/html/HTMLSelectElement.h
WebCore/svg/SVGLocatable.cpp
WebCore/svg/SVGTextContentElement.cpp