Changeset 199054 in webkit
- Timestamp:
- Apr 5, 2016, 3:29:31 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r199034 r199054 1 2016-04-05 Antti Koivisto <antti@apple.com> 2 3 Use RenderTreeUpdater for text node mutations 4 https://bugs.webkit.org/show_bug.cgi?id=156107 5 6 Reviewed by Andreas Kling. 7 8 Mostly just revert non-rendered whitespace related changes from the earlier patches. 9 10 * editing/style/remove-underline-from-stylesheet-expected.txt: 11 * editing/style/typing-style-003-expected.txt: 12 * platform/ios-simulator/editing/style/typing-style-003-expected.txt: Removed. 13 * platform/mac-wk2/editing/mac/spelling/autocorrection-contraction-expected.txt: 14 * platform/mac/editing/inserting/editable-html-element-expected.txt: 15 * platform/mac/editing/inserting/editing-empty-divs-expected.txt: 16 * platform/mac/editing/inserting/insert-at-end-02-expected.txt: 17 * platform/mac/editing/pasteboard/4989774-expected.txt: 18 * platform/mac/editing/selection/4983858-expected.txt: 19 1 20 2016-04-04 Zalan Bujtas <zalan@apple.com> 2 21 -
trunk/LayoutTests/editing/mac/spelling/autocorrection-contraction-expected.txt
r198943 r199054 280 280 text run at (0,0) width 154: "would' wouldn't" 281 281 text run at (153,0) width 7: " " 282 caret: position 16 of child 0 {#text} of child 6{DIV} of child 3 {DIV} of body282 caret: position 16 of child 0 {#text} of child 5 {DIV} of child 3 {DIV} of body -
trunk/LayoutTests/editing/mac/spelling/autocorrection-removing-underline-after-paste-expected.txt
r198943 r199054 83 83 RenderBlock {DIV} at (14,70) size 756x28 84 84 RenderBR {BR} at (0,0) size 0x28 85 caret: position 0 of child 0 {BR} of child 5{DIV} of child 5 {DIV} of body85 caret: position 0 of child 0 {BR} of child 4 {DIV} of child 5 {DIV} of body -
trunk/LayoutTests/editing/mac/spelling/autocorrection-removing-underline-expected.txt
r198943 r199054 79 79 RenderBlock {DIV} at (14,42) size 756x28 80 80 RenderBR {BR} at (0,0) size 0x28 81 caret: position 0 of child 0 {BR} of child 3{DIV} of child 5 {DIV} of body81 caret: position 0 of child 0 {BR} of child 2 {DIV} of child 5 {DIV} of body -
trunk/LayoutTests/editing/mac/spelling/autocorrection-simple-expected.txt
r198943 r199054 138 138 RenderText {#text} at (0,0) size 138x28 139 139 text run at (0,0) width 138: "the notational," 140 caret: position 15 of child 0 {#text} of child 3{DIV} of child 7 {DIV} of body140 caret: position 15 of child 0 {#text} of child 2 {DIV} of child 7 {DIV} of body -
trunk/LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt
r198943 r199054 77 77 | "<#selection-anchor>xxxxxx<#selection-focus>" 78 78 | " xxxxxx" 79 | "80 "81 79 | <span> 82 80 | id="test" -
trunk/LayoutTests/editing/style/typing-style-003-expected.txt
r198943 r199054 53 53 xxxxxxxxxxxxxxx 54 54 execTypeCharacterCommand: x <span id="test"></span> 55 execTypeCharacterCommand: xx 56 execTypeCharacterCommand: xxx 57 execBoldCommand: xxx 58 execTypeCharacterCommand: xxx<b>x</b> 55 execTypeCharacterCommand: xx<span id="test"></span> 56 execTypeCharacterCommand: xxx<span id="test"></span> 57 execBoldCommand: xxx<span id="test"></span> 58 execTypeCharacterCommand: xxx<b>x</b><span id="test"></span> 59 59 execTypeCharacterCommand: xxx<b>xx</b><span id="test"></span> 60 60 execTypeCharacterCommand: xxx<b>xxx</b><span id="test"></span> -
trunk/LayoutTests/fast/dom/beforeload/remove-bad-object-in-beforeload-listener-expected.txt
r198943 r199054 2 2 3 3 PASS 4 -
trunk/LayoutTests/fast/dom/beforeload/remove-flash-in-beforeload-listener-expected.txt
r198943 r199054 2 2 3 3 PASS 4 -
trunk/LayoutTests/platform/mac-wk2/editing/mac/spelling/autocorrection-contraction-expected.txt
r198943 r199054 260 260 text run at (0,0) width 166: "wouldn' wouldn't" 261 261 text run at (165,0) width 7: " " 262 caret: position 17 of child 0 {#text} of child 6{DIV} of child 3 {DIV} of body262 caret: position 17 of child 0 {#text} of child 5 {DIV} of child 3 {DIV} of body -
trunk/LayoutTests/platform/mac/editing/inserting/editable-html-element-expected.txt
r198943 r199054 23 23 text run at (766,18) width 5: " " 24 24 text run at (0,36) width 132: "block flow element)." 25 RenderText {#text} at (0,0) size 0x0 25 26 RenderBlock {DIV} at (0,54) size 784x18 26 27 RenderBR {BR} at (0,0) size 0x18 -
trunk/LayoutTests/platform/mac/editing/inserting/editing-empty-divs-expected.txt
r198943 r199054 66 66 RenderText {#text} at (1,1) size 8x18 67 67 text run at (1,1) width 8: "c" 68 RenderText {#text} at (0,0) size 0x0 68 69 RenderBlock {P} at (0,268) size 784x18 69 70 RenderText {#text} at (0,0) size 240x18 … … 81 82 RenderText {#text} at (0,0) size 8x18 82 83 text run at (0,0) width 8: "c" 84 RenderText {#text} at (0,0) size 0x0 83 85 RenderBlock {P} at (1,35) size 706x0 84 86 caret: position 1 of child 0 {#text} of child 21 {DIV} of body -
trunk/LayoutTests/platform/mac/editing/inserting/insert-at-end-02-expected.txt
r198943 r199054 30 30 RenderText {#text} at (0,0) size 8x18 31 31 text run at (0,0) width 8: "x" 32 RenderText {#text} at (0,0) size 0x0 32 33 caret: position 1 of child 5 {#text} of child 5 {DIV} of body -
trunk/LayoutTests/platform/mac/editing/pasteboard/4989774-expected.txt
r198943 r199054 13 13 text run at (735,103) width 5: " " 14 14 text run at (0,121) width 364: "several pictures above all in the same line/paragraph." 15 RenderText {#text} at (0,0) size 0x0 16 RenderText {#text} at (0,0) size 0x0 15 17 caret: position 164 of child 4 {#text} of body -
trunk/LayoutTests/platform/mac/editing/selection/4983858-expected.txt
r198943 r199054 11 11 text run at (780,0) width 4: " " 12 12 text run at (0,18) width 165: "below should be selected:" 13 RenderText {#text} at (0,0) size 0x0 13 14 RenderBlock {DIV} at (0,36) size 784x18 14 15 RenderText {#text} at (0,0) size 22x18 -
trunk/LayoutTests/plugins/focus-expected.txt
r198943 r199054 25 25 26 26 Fallback contents. Fallback contents. Fallback contents. 27 -
trunk/Source/WebCore/ChangeLog
r199053 r199054 1 2016-04-05 Antti Koivisto <antti@apple.com> 2 3 Use RenderTreeUpdater for text node mutations 4 https://bugs.webkit.org/show_bug.cgi?id=156107 5 6 Reviewed by Andreas Kling. 7 8 Use the new mechanism for updating render tree after text node content changes. 9 10 * dom/CharacterData.cpp: 11 (WebCore::CharacterData::parserAppendData): 12 (WebCore::CharacterData::setDataAndUpdate): 13 * dom/Text.cpp: 14 (WebCore::Text::createWithLengthLimit): 15 (WebCore::Text::updateRendererAfterContentChange): 16 17 Update using RenderTreeUpdater. 18 19 (WebCore::Text::formatForDebugger): 20 * dom/Text.h: 21 (WebCore::Text::Text): 22 * style/StyleTreeResolver.cpp: 23 (WebCore::Style::TreeResolver::styleForElement): 24 (WebCore::Style::resetStyleForNonRenderedDescendants): 25 (WebCore::Style::TreeResolver::resolveElement): 26 (WebCore::Style::elementImplicitVisibility): 27 (WebCore::Style::invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded): Deleted. 28 (WebCore::Style::textRendererIsNeeded): Deleted. 29 (WebCore::Style::createTextRendererIfNeeded): Deleted. 30 (WebCore::Style::attachTextRenderer): Deleted. 31 (WebCore::Style::detachTextRenderer): Deleted. 32 (WebCore::Style::updateTextRendererAfterContentChange): Deleted. 33 (WebCore::Style::resolveTextNode): Deleted. 34 35 Kill the old code paths. 36 37 * style/StyleTreeResolver.h: 38 1 39 2016-04-05 Hunseop Jeong <hs85.jeong@samsung.com> 2 40 -
trunk/Source/WebCore/dom/CharacterData.cpp
r195264 r199054 33 33 #include "RenderText.h" 34 34 #include "StyleInheritedData.h" 35 #include "StyleTreeResolver.h"36 35 #include "TextBreakIterator.h" 37 36 #include <wtf/Ref.h> … … 90 89 91 90 ASSERT(!renderer() || is<Text>(*this)); 92 if (is<Text>(*this) )93 Style::updateTextRendererAfterContentChange(downcast<Text>(*this),oldLength, 0);91 if (is<Text>(*this) && parentNode()) 92 downcast<Text>(*this).updateRendererAfterContentChange(oldLength, 0); 94 93 95 94 document().incDOMTreeVersion(); … … 189 188 190 189 ASSERT(!renderer() || is<Text>(*this)); 191 if (is<Text>(*this) )192 Style::updateTextRendererAfterContentChange(downcast<Text>(*this),offsetOfReplacedData, oldLength);190 if (is<Text>(*this) && parentNode()) 191 downcast<Text>(*this).updateRendererAfterContentChange(offsetOfReplacedData, oldLength); 193 192 194 193 if (is<ProcessingInstruction>(*this)) -
trunk/Source/WebCore/dom/Text.cpp
r195264 r199054 27 27 #include "RenderSVGInlineText.h" 28 28 #include "RenderText.h" 29 #include "RenderTreeUpdater.h" 29 30 #include "SVGElement.h" 30 31 #include "SVGNames.h" … … 33 34 #include "StyleInheritedData.h" 34 35 #include "StyleResolver.h" 36 #include "StyleUpdate.h" 35 37 #include "TextNodeTraversal.h" 36 38 #include <wtf/CheckedArithmetic.h> … … 217 219 return result; 218 220 } 221 222 void Text::updateRendererAfterContentChange(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData) 223 { 224 ASSERT(parentNode()); 225 if (styleChangeType() == ReconstructRenderTree) 226 return; 227 228 auto textUpdate = std::make_unique<Style::Update>(document()); 229 textUpdate->addText(*this); 230 231 RenderTreeUpdater renderTreeUpdater(document()); 232 renderTreeUpdater.commit(WTFMove(textUpdate)); 233 234 if (auto* renderer = this->renderer()) 235 renderer->setTextWithOffset(data(), offsetOfReplacedData, lengthOfReplacedData); 236 } 237 219 238 220 239 #if ENABLE(TREE_DEBUGGING) -
trunk/Source/WebCore/dom/Text.h
r197566 r199054 54 54 RenderText* renderer() const; 55 55 56 void updateRendererAfterContentChange(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData); 57 56 58 protected: 57 59 Text(Document& document, const String& data, ConstructionType type) -
trunk/Source/WebCore/style/RenderTreeUpdater.cpp
r199008 r199054 91 91 ASSERT(&m_document == &styleUpdate->document()); 92 92 93 if (!m_document.shouldCreateRenderers() )93 if (!m_document.shouldCreateRenderers() || !m_document.renderView()) 94 94 return; 95 95 -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r198990 r199054 51 51 namespace Style { 52 52 53 static void attachTextRenderer(Text&, RenderTreePosition&);54 static void resolveTextNode(Text&, RenderTreePosition&);55 56 53 class SelectorFilterPusher { 57 54 public: … … 180 177 } 181 178 182 static void invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(Node& current)183 {184 // FIXME: This needs to traverse in composed tree order.185 186 // This function finds sibling text renderers where the results of textRendererIsNeeded may have changed as a result of187 // the current node gaining or losing the renderer. This can only affect white space text nodes.188 for (Node* sibling = current.nextSibling(); sibling; sibling = sibling->nextSibling()) {189 if (sibling->needsStyleRecalc())190 return;191 if (is<Element>(*sibling)) {192 // Text renderers beyond rendered elements can't be affected.193 if (!sibling->renderer() || RenderTreePosition::isRendererReparented(*sibling->renderer()))194 continue;195 return;196 }197 if (!is<Text>(*sibling))198 continue;199 Text& textSibling = downcast<Text>(*sibling);200 if (!textSibling.containsOnlyWhitespace())201 continue;202 textSibling.setNeedsStyleRecalc();203 }204 }205 206 static bool textRendererIsNeeded(const Text& textNode, const RenderTreePosition& renderTreePosition)207 {208 const RenderElement& parentRenderer = renderTreePosition.parent();209 if (!parentRenderer.canHaveChildren())210 return false;211 if (parentRenderer.element() && !parentRenderer.element()->childShouldCreateRenderer(textNode))212 return false;213 if (textNode.isEditingText())214 return true;215 if (!textNode.length())216 return false;217 if (!textNode.containsOnlyWhitespace())218 return true;219 // This text node has nothing but white space. We may still need a renderer in some cases.220 if (parentRenderer.isTable() || parentRenderer.isTableRow() || parentRenderer.isTableSection() || parentRenderer.isRenderTableCol() || parentRenderer.isFrameSet())221 return false;222 if (parentRenderer.style().preserveNewline()) // pre/pre-wrap/pre-line always make renderers.223 return true;224 225 RenderObject* previousRenderer = renderTreePosition.previousSiblingRenderer(textNode);226 if (previousRenderer && previousRenderer->isBR()) // <span><br/> <br/></span>227 return false;228 229 if (parentRenderer.isRenderInline()) {230 // <span><div/> <div/></span>231 if (previousRenderer && !previousRenderer->isInline())232 return false;233 } else {234 if (parentRenderer.isRenderBlock() && !parentRenderer.childrenInline() && (!previousRenderer || !previousRenderer->isInline()))235 return false;236 237 RenderObject* first = parentRenderer.firstChild();238 while (first && first->isFloatingOrOutOfFlowPositioned())239 first = first->nextSibling();240 RenderObject* nextRenderer = renderTreePosition.nextSiblingRenderer(textNode);241 if (!first || nextRenderer == first) {242 // Whitespace at the start of a block just goes away. Don't even make a render object for this text.243 return false;244 }245 }246 return true;247 }248 249 static void createTextRendererIfNeeded(Text& textNode, RenderTreePosition& renderTreePosition)250 {251 ASSERT(!textNode.renderer());252 253 if (!textRendererIsNeeded(textNode, renderTreePosition))254 return;255 256 auto newRenderer = textNode.createTextRenderer(renderTreePosition.parent().style());257 ASSERT(newRenderer);258 259 renderTreePosition.computeNextSibling(textNode);260 261 if (!renderTreePosition.canInsert(*newRenderer))262 return;263 264 // Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style265 // for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.266 newRenderer->setFlowThreadState(renderTreePosition.parent().flowThreadState());267 268 textNode.setRenderer(newRenderer.get());269 renderTreePosition.insert(*newRenderer.leakPtr());270 }271 272 void attachTextRenderer(Text& textNode, RenderTreePosition& renderTreePosition)273 {274 createTextRendererIfNeeded(textNode, renderTreePosition);275 276 textNode.clearNeedsStyleRecalc();277 }278 279 179 void detachTextRenderer(Text& textNode) 280 180 { … … 282 182 textNode.renderer()->destroyAndCleanupAnonymousWrappers(); 283 183 textNode.setRenderer(0); 284 }285 286 void updateTextRendererAfterContentChange(Text& textNode, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData)287 {288 auto* renderingParentNode = composedTreeAncestors(textNode).first();289 if (!renderingParentNode || !renderingParentNode->renderer())290 return;291 292 bool hadRenderer = textNode.renderer();293 294 RenderTreePosition renderTreePosition(*renderingParentNode->renderer());295 resolveTextNode(textNode, renderTreePosition);296 297 if (hadRenderer && textNode.renderer())298 textNode.renderer()->setTextWithOffset(textNode.data(), offsetOfReplacedData, lengthOfReplacedData);299 184 } 300 185 … … 446 331 } 447 332 448 void resolveTextNode(Text& text, RenderTreePosition& renderTreePosition)449 {450 text.clearNeedsStyleRecalc();451 452 bool hasRenderer = text.renderer();453 bool needsRenderer = textRendererIsNeeded(text, renderTreePosition);454 if (hasRenderer) {455 if (needsRenderer)456 return;457 detachTextRenderer(text);458 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text);459 return;460 }461 if (!needsRenderer)462 return;463 attachTextRenderer(text, renderTreePosition);464 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text);465 }466 467 333 #if PLATFORM(IOS) 468 334 static EVisibility elementImplicitVisibility(const Element* element) -
trunk/Source/WebCore/style/StyleTreeResolver.h
r198943 r199054 113 113 void detachTextRenderer(Text&); 114 114 115 void updateTextRendererAfterContentChange(Text&, unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);116 117 115 void queuePostResolutionCallback(std::function<void ()>); 118 116 bool postResolutionCallbacksAreSuspended(); -
trunk/Source/WebCore/style/StyleUpdate.cpp
r198943 r199054 64 64 { 65 65 ASSERT(!m_elements.contains(&element)); 66 ASSERT( !parent ||composedTreeAncestors(element).first() == parent);66 ASSERT(composedTreeAncestors(element).first() == parent); 67 67 68 68 addPossibleRoot(parent); … … 73 73 { 74 74 ASSERT(!m_texts.contains(&text)); 75 ASSERT( !parent ||composedTreeAncestors(text).first() == parent);75 ASSERT(composedTreeAncestors(text).first() == parent); 76 76 77 77 addPossibleRoot(parent); 78 78 m_texts.add(&text); 79 } 80 81 void Update::addText(Text& text) 82 { 83 addText(text, composedTreeAncestors(text).first()); 79 84 } 80 85 -
trunk/Source/WebCore/style/StyleUpdate.h
r198943 r199054 67 67 void addElement(Element&, Element* parent, ElementUpdate&); 68 68 void addText(Text&, Element* parent); 69 void addText(Text&); 69 70 70 71 private:
Note:
See TracChangeset
for help on using the changeset viewer.