LayoutTests:
Reviewed by Maciej.
- test for http://bugs.webkit.org/show_bug.cgi?id=13602
Amazon product pages keep repainting over and over again
* fast/dom/HTMLElement/set-inner-outer-optimization-expected.txt: Added.
* fast/dom/HTMLElement/set-inner-outer-optimization.html: Added.
* editing/execCommand/copy-without-selection.html: Added missing preventDefault calls
to prevent this from being a double-paste test.
* fast/css/first-letter-detach-expected.checksum: Updated.
* fast/css/first-letter-detach-expected.png: Updated.
* fast/css/first-letter-detach-expected.txt: Updated.
* fast/css/first-letter-detach.html: Updated to test three different ways of setting the
text of the first-letter element; setInnerHTML and two other ways.
* fast/events/updateLayoutForHitTest-expected.txt: Updated result that changed slightly
due to setInnerHTML improvement.
* fast/forms/textarea-setinnerhtml-expected.txt: Ditto.
WebCore:
Reviewed by Maciej.
- fix http://bugs.webkit.org/show_bug.cgi?id=13602
Amazon product pages keep repainting over and over again
- fix first-letter when the text of the affected text node is changed
Optimize setInnerHTML, setOuterHTML, and setInnerText so they don't change the DOM at all
if they don't need to.
Test: fast/dom/HTMLElement/set-inner-outer-optimization.html
Test: fast/css/first-letter-detach.html
* html/HTMLElement.cpp:
(WebCore::equal): Added. Helper function that compares two Text nodes or two NamedAttrMap
attribute maps.
(WebCore::shallowEqual): Added. Helper function that compares two Element nodes or two
arbitrary nodes.
(WebCore::childrenAreEqual): Added. Helper functions that compare children of nodes.
(WebCore::hasOneChild): Added. Helper function.
(WebCore::hasOneTextChild): Added. Helper function.
(WebCore::replaceChildrenWithFragment): Added. Helper function used by setInnerHTML and
setInnerText. Optimizes the cases where all the nodes are the same, where both the current
and the new content are single text nodes, and where the current content is a single node
that can be replaced with replaceChild.
(WebCore::replaceChildrenWithText): Added. Helper function used by setInnerText. Optimizes
the case where the current content is a single text node or a single node that can be
replaced with replaceChild.
(WebCore::HTMLElement::setInnerHTML): Changed to call replaceChildrenWithFragment.
(WebCore::HTMLElement::setOuterHTML): Added special case to optimize when the new content
exactly matches the current node.
(WebCore::HTMLElement::setInnerText): Changed to call replaceChildrenWithText in a few
cases instead of doing removeChildren/appendChild. Changed code that was using
DeprecatedString to instead use String. Changed general case to use a document fragment
and replaceChildrenWithFragment.
* dom/CharacterData.cpp: (WebCore::CharacterData::dispatchModifiedEvent):
Fixed bug where we would not dispatch the DOMSubtreeModified event unless someone
was registered for the DOMCharacterDataModified event. Caused trouble in the test.
* rendering/RenderBlock.cpp: (WebCore::RenderBlock::updateFirstLetter): Set first-letter
after the setStyle call so calls to setTextInternal inside setStyle don't clear it.
* rendering/RenderText.h: Made setTextInternal virtual so that RenderTextFragment can do
appropriate work when the text changes.
* rendering/RenderTextFragment.h: Added an override of setTextInternal. Removed the
firstLetter parameter to the constructor and made it a separate setter. Also changed
m_generatedContentStr to m_contentString to match the getter function.
* rendering/RenderTextFragment.cpp:
(WebCore::RenderTextFragment::RenderTextFragment): Removed firstLetter parameter.
(WebCore::RenderTextFragment::setTextInternal): When the text changes, destroy the
first-letter node and reset the fragment values so that RenderBlock::updateFirstLetter,
which will run during layout, will create a new first-letter child. Otherwise we end up
with the first letter of the old text.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/RenderText.h b/WebCore/rendering/RenderText.h
index 8cab1e9..834fec6 100644
--- a/WebCore/rendering/RenderText.h
+++ b/WebCore/rendering/RenderText.h
@@ -127,7 +127,7 @@
int allowTabs() const { return !style()->collapseWhiteSpace(); }
protected:
- void setTextInternal(PassRefPtr<StringImpl>);
+ virtual void setTextInternal(PassRefPtr<StringImpl>);
virtual void calcPrefWidths(int leadWidth);
private: