Changeset 276133 in webkit
- Timestamp:
- Apr 16, 2021, 4:09:40 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
editing/ApplyStyleCommand.cpp (modified) (36 diffs)
-
editing/ApplyStyleCommand.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r276131 r276133 1 2021-04-16 Ryosuke Niwa <rniwa@webkit.org> 2 3 Deploy Ref/RefPtr in ApplyStyleCommand 4 https://bugs.webkit.org/show_bug.cgi?id=224662 5 6 Reviewed by Antti Koivisto. 7 8 Deployed smart pointers in ApplyStyleCommand. Also deployed ScriptDisallowedScope around the code 9 which accesses the render tree in ApplyStyleCommand::applyInlineStyleToPushDown. 10 11 * editing/ApplyStyleCommand.cpp: 12 (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): 13 (WebCore::dummySpanAncestorForNode): 14 (WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans): 15 (WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi): 16 (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock): 17 (WebCore::highestEmbeddingAncestor): 18 (WebCore::ApplyStyleCommand::applyInlineStyle): 19 (WebCore::ApplyStyleCommand::fixRangeAndApplyInlineStyle): 20 (WebCore::containsNonEditableRegion): 21 (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange): 22 (WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun): 23 (WebCore::ApplyStyleCommand::highestAncestorWithConflictingInlineStyle): 24 (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown): 25 (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode): 26 (WebCore::ApplyStyleCommand::removeInlineStyle): 27 (WebCore::ApplyStyleCommand::mergeStartWithPreviousIfIdentical): 28 (WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical): 29 (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement): 30 (WebCore::ApplyStyleCommand::applyInlineStyleChange): 31 (WebCore::ApplyStyleCommand::joinChildTextNodes): 32 * editing/ApplyStyleCommand.h: 33 1 34 2021-04-16 Ryosuke Niwa <rniwa@webkit.org> 2 35 -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r274865 r276133 44 44 #include "RenderObject.h" 45 45 #include "RenderText.h" 46 #include "ScriptDisallowedScope.h" 46 47 #include "StyleProperties.h" 47 48 #include "StyleResolver.h" … … 345 346 // If the end node is before the start node (can only happen if the end node is 346 347 // an ancestor of the start node), we gather nodes up to the next sibling of the end node 347 Node*beyondEnd;348 RefPtr<Node> beyondEnd; 348 349 ASSERT(start.deprecatedNode()); 349 350 ASSERT(end.deprecatedNode()); … … 354 355 355 356 start = start.upstream(); // Move upstream to ensure we do not add redundant spans. 356 Node* startNode = start.deprecatedNode();357 auto startNode = makeRefPtr(start.deprecatedNode()); 357 358 358 359 // Make sure we're not already at the end or the next NodeTraversal::next() will traverse past it. … … 369 370 // Store away font size before making any changes to the document. 370 371 // This ensures that changes to one node won't effect another. 371 HashMap< Node*, float> startingFontSizes;372 for ( Node*node = startNode; node != beyondEnd; node = NodeTraversal::next(*node)) {372 HashMap<Ref<Node>, float> startingFontSizes; 373 for (auto node = startNode; node != beyondEnd; node = NodeTraversal::next(*node)) { 373 374 ASSERT(node); 374 startingFontSizes.set( node, computedFontSize(node));375 startingFontSizes.set(*node, computedFontSize(node.get())); 375 376 } 376 377 377 378 // These spans were added by us. If empty after font size changes, they can be removed. 378 379 Vector<Ref<HTMLElement>> unstyledSpans; 379 380 Node* lastStyledNode = nullptr;380 381 RefPtr<Node> lastStyledNode; 381 382 bool reachedEnd = false; 382 for (auto node = makeRefPtr(startNode); node != beyondEnd && !reachedEnd; node = NodeTraversal::next(*node)) {383 for (auto node = startNode; node != beyondEnd && !reachedEnd; node = NodeTraversal::next(*node)) { 383 384 ASSERT(node); 384 385 RefPtr<HTMLElement> element; … … 392 393 // text node. To make this possible, add a style span to surround this text node. 393 394 auto span = createStyleSpanElement(document()); 394 if (!surroundNodeRangeWithElement(*node, *node, span .copyRef()))395 if (!surroundNodeRangeWithElement(*node, *node, span)) 395 396 continue; 396 reachedEnd = node->isDescendantOf(beyondEnd );397 reachedEnd = node->isDescendantOf(beyondEnd.get()); 397 398 element = WTFMove(span); 398 399 } else { … … 400 401 continue; 401 402 } 402 lastStyledNode = node .get();403 lastStyledNode = node; 403 404 404 405 RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element->inlineStyle()); … … 425 426 } 426 427 427 static ContainerNode* dummySpanAncestorForNode( constNode* node)428 { 429 while (node && (!is<Element>(*node) || !isStyleSpanOrSpanWithOnlyStyleAttribute(downcast<Element>(*node))))430 node = node->parentNode();431 432 return node ? node->parentNode() : nullptr;428 static ContainerNode* dummySpanAncestorForNode(Node* node) 429 { 430 RefPtr<Node> currentNode = node; 431 while (currentNode && (!is<Element>(*currentNode) || !isStyleSpanOrSpanWithOnlyStyleAttribute(downcast<Element>(*currentNode)))) 432 currentNode = currentNode->parentNode(); 433 return currentNode ? currentNode->parentNode() : nullptr; 433 434 } 434 435 … … 443 444 // all the children of the dummy's parent 444 445 445 Vector< Element*> toRemove;446 Vector<Ref<Element>> toRemove; 446 447 for (auto& child : childrenOfType<Element>(*dummySpanAncestor)) { 447 448 if (isSpanWithoutAttributesOrUnstyledStyleSpan(child)) 448 toRemove.append( &child);449 toRemove.append(child); 449 450 } 450 451 451 452 for (auto& element : toRemove) 452 removeNodePreservingChildren( *element);453 } 454 455 HTMLElement*ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool before, WritingDirection allowedDirection)453 removeNodePreservingChildren(element.get()); 454 } 455 456 RefPtr<HTMLElement> ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool before, WritingDirection allowedDirection) 456 457 { 457 458 // We are allowed to leave the highest ancestor with unicode-bidi unsplit if it is unicode-bidi: embed and direction: allowedDirection. 458 459 // In that case, we return the unsplit ancestor. Otherwise, we return 0. 459 Element* block = enclosingBlock(node);460 auto block = makeRefPtr(enclosingBlock(node)); 460 461 if (!block || block == node) 461 return 0;462 463 Node* highestAncestorWithUnicodeBidi = nullptr;464 Node* nextHighestAncestorWithUnicodeBidi = nullptr;462 return nullptr; 463 464 RefPtr<Node> highestAncestorWithUnicodeBidi; 465 RefPtr<Node> nextHighestAncestorWithUnicodeBidi; 465 466 int highestAncestorUnicodeBidi = 0; 466 for ( Node* n = node->parentNode(); n != block; n = n->parentNode()) {467 int unicodeBidi = toIdentifier(ComputedStyleExtractor( n).propertyValue(CSSPropertyUnicodeBidi));467 for (auto ancestor = makeRefPtr(node->parentNode()); ancestor != block; ancestor = ancestor->parentNode()) { 468 int unicodeBidi = toIdentifier(ComputedStyleExtractor(ancestor.get()).propertyValue(CSSPropertyUnicodeBidi)); 468 469 if (unicodeBidi && unicodeBidi != CSSValueNormal) { 469 470 highestAncestorUnicodeBidi = unicodeBidi; 470 471 nextHighestAncestorWithUnicodeBidi = highestAncestorWithUnicodeBidi; 471 highestAncestorWithUnicodeBidi = n;472 highestAncestorWithUnicodeBidi = ancestor; 472 473 } 473 474 } 474 475 475 476 if (!highestAncestorWithUnicodeBidi) 476 return 0;477 478 HTMLElement* unsplitAncestor = nullptr;477 return nullptr; 478 479 RefPtr<HTMLElement> unsplitAncestor; 479 480 480 481 if (allowedDirection != WritingDirection::Natural && highestAncestorUnicodeBidi != CSSValueBidiOverride && is<HTMLElement>(*highestAncestorWithUnicodeBidi)) { 481 auto highestAncestorDirection = EditingStyle::create(highestAncestorWithUnicodeBidi , EditingStyle::AllProperties)->textDirection();482 auto highestAncestorDirection = EditingStyle::create(highestAncestorWithUnicodeBidi.get(), EditingStyle::AllProperties)->textDirection(); 482 483 if (highestAncestorDirection && *highestAncestorDirection == allowedDirection) { 483 484 if (!nextHighestAncestorWithUnicodeBidi) 484 return downcast<HTMLElement>(highestAncestorWithUnicodeBidi);485 486 unsplitAncestor = downcast<HTMLElement>(highestAncestorWithUnicodeBidi);485 return static_pointer_cast<HTMLElement>(WTFMove(highestAncestorWithUnicodeBidi)); 486 487 unsplitAncestor = static_pointer_cast<HTMLElement>(highestAncestorWithUnicodeBidi); 487 488 highestAncestorWithUnicodeBidi = nextHighestAncestorWithUnicodeBidi; 488 489 } … … 499 500 currentNode = parent; 500 501 } 502 501 503 return unsplitAncestor; 502 504 } … … 504 506 void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsplitAncestor) 505 507 { 506 Element* block = enclosingBlock(node);508 auto block = makeRefPtr(enclosingBlock(node)); 507 509 if (!block || block == node) 508 510 return; 509 511 510 Node* parent = nullptr; 511 for (Node* ancestor = node->parentNode(); ancestor != block && ancestor != unsplitAncestor; ancestor = parent) { 512 for (RefPtr<Node> ancestor = node->parentNode(), parent; ancestor != block && ancestor != unsplitAncestor; ancestor = parent) { 512 513 parent = ancestor->parentNode(); 513 514 if (!is<StyledElement>(*ancestor)) … … 528 529 removeNodeAttribute(element, dirAttr); 529 530 } else { 530 RefPtr<MutableStyleProperties>inlineStyle = copyStyleOrCreateEmpty(element.inlineStyle());531 auto inlineStyle = copyStyleOrCreateEmpty(element.inlineStyle()); 531 532 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); 532 533 inlineStyle->removeProperty(CSSPropertyDirection); … … 538 539 } 539 540 540 static Node*highestEmbeddingAncestor(Node* startNode, Node* enclosingNode)541 { 542 for ( Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) {543 if ( n->isHTMLElement() && toIdentifier(ComputedStyleExtractor(n).propertyValue(CSSPropertyUnicodeBidi)) == CSSValueEmbed)544 return n;545 } 546 547 return 0;541 static RefPtr<Node> highestEmbeddingAncestor(Node* startNode, Node* enclosingNode) 542 { 543 for (auto currentNode = makeRefPtr(startNode); currentNode && currentNode != enclosingNode; currentNode = currentNode->parentNode()) { 544 if (currentNode->isHTMLElement() && toIdentifier(ComputedStyleExtractor(currentNode.get()).propertyValue(CSSPropertyUnicodeBidi)) == CSSValueEmbed) 545 return currentNode; 546 } 547 548 return nullptr; 548 549 } 549 550 … … 602 603 if (textDirection.hasValue()) { 603 604 // Leave alone an ancestor that provides the desired single level embedding, if there is one. 604 auto *startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.deprecatedNode(), true, *textDirection);605 auto *endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.deprecatedNode(), false, *textDirection);606 removeEmbeddingUpToEnclosingBlock(start.deprecatedNode(), startUnsplitAncestor );607 removeEmbeddingUpToEnclosingBlock(end.deprecatedNode(), endUnsplitAncestor );605 auto startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.deprecatedNode(), true, *textDirection); 606 auto endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.deprecatedNode(), false, *textDirection); 607 removeEmbeddingUpToEnclosingBlock(start.deprecatedNode(), startUnsplitAncestor.get()); 608 removeEmbeddingUpToEnclosingBlock(end.deprecatedNode(), endUnsplitAncestor.get()); 608 609 609 610 // Avoid removing the dir attribute and the unicode-bidi and direction properties from the unsplit ancestors. 610 611 Position embeddingRemoveStart = removeStart; 611 612 if (startUnsplitAncestor && nodeFullySelected(*startUnsplitAncestor, removeStart, end)) 612 embeddingRemoveStart = positionInParentAfterNode(startUnsplitAncestor );613 embeddingRemoveStart = positionInParentAfterNode(startUnsplitAncestor.get()); 613 614 614 615 Position embeddingRemoveEnd = end; 615 616 if (endUnsplitAncestor && nodeFullySelected(*endUnsplitAncestor, removeStart, end)) 616 embeddingRemoveEnd = positionInParentBeforeNode(endUnsplitAncestor ).downstream();617 embeddingRemoveEnd = positionInParentBeforeNode(endUnsplitAncestor.get()).downstream(); 617 618 618 619 if (embeddingRemoveEnd != removeStart || embeddingRemoveEnd != end) { … … 653 654 if (textDirection.hasValue()) { 654 655 // Avoid applying the unicode-bidi and direction properties beneath ancestors that already have them. 655 Node*embeddingStartNode = highestEmbeddingAncestor(start.deprecatedNode(), enclosingBlock(start.deprecatedNode()));656 Node*embeddingEndNode = highestEmbeddingAncestor(end.deprecatedNode(), enclosingBlock(end.deprecatedNode()));656 auto embeddingStartNode = highestEmbeddingAncestor(start.deprecatedNode(), enclosingBlock(start.deprecatedNode())); 657 auto embeddingEndNode = highestEmbeddingAncestor(end.deprecatedNode(), enclosingBlock(end.deprecatedNode())); 657 658 658 659 if (embeddingStartNode || embeddingEndNode) { 659 Position embeddingApplyStart = embeddingStartNode ? positionInParentAfterNode(embeddingStartNode ) : start;660 Position embeddingApplyEnd = embeddingEndNode ? positionInParentBeforeNode(embeddingEndNode ) : end;660 Position embeddingApplyStart = embeddingStartNode ? positionInParentAfterNode(embeddingStartNode.get()) : start; 661 Position embeddingApplyEnd = embeddingEndNode ? positionInParentBeforeNode(embeddingEndNode.get()) : end; 661 662 ASSERT(embeddingApplyStart.isNotNull() && embeddingApplyEnd.isNotNull()); 662 663 … … 681 682 void ApplyStyleCommand::fixRangeAndApplyInlineStyle(EditingStyle& style, const Position& start, const Position& end) 682 683 { 683 Node* startNode = start.deprecatedNode();684 auto startNode = makeRefPtr(start.deprecatedNode()); 684 685 685 686 if (start.deprecatedEditingOffset() >= caretMaxOffset(*startNode)) { 686 687 startNode = NodeTraversal::next(*startNode); 687 if (!startNode || end < firstPositionInOrBeforeNode(startNode ))688 if (!startNode || end < firstPositionInOrBeforeNode(startNode.get())) 688 689 return; 689 690 } 690 691 691 Node* pastEndNode = end.deprecatedNode();692 auto pastEndNode = makeRefPtr(end.deprecatedNode()); 692 693 if (end.deprecatedEditingOffset() >= caretMaxOffset(*pastEndNode)) 693 694 pastEndNode = NodeTraversal::nextSkippingChildren(*pastEndNode); … … 703 704 // to generate <font color="blue" size="4">hello</font> instead of <font color="blue"><font size="4">hello</font></font> 704 705 auto range = *makeSimpleRange(start, end); 705 auto * editableRoot = startNode->rootEditableElement();706 auto editableRoot = makeRefPtr(startNode->rootEditableElement()); 706 707 if (startNode != editableRoot) { 707 708 while (editableRoot && startNode->parentNode() != editableRoot && isNodeVisiblyContainedWithin(*startNode->parentNode(), range)) … … 709 710 } 710 711 711 applyInlineStyleToNodeRange(style, *startNode, pastEndNode );712 applyInlineStyleToNodeRange(style, *startNode, pastEndNode.get()); 712 713 } 713 714 … … 717 718 return true; 718 719 719 Node* sibling = NodeTraversal::nextSkippingChildren(node);720 for ( Node* descendant = node.firstChild(); descendant && descendant != sibling; descendant = NodeTraversal::next(*descendant)) {720 auto sibling = makeRefPtr(NodeTraversal::nextSkippingChildren(node)); 721 for (auto descendant = makeRefPtr(node.firstChild()); descendant && descendant != sibling; descendant = NodeTraversal::next(*descendant)) { 721 722 if (!descendant->hasEditableStyle()) 722 723 return true; … … 772 773 HTMLElement& element = downcast<HTMLElement>(*node); 773 774 RefPtr<MutableStyleProperties> inlineStyle = copyStyleOrCreateEmpty(element.inlineStyle()); 774 if ( MutableStyleProperties* otherStyle = style.style())775 if (auto otherStyle = makeRefPtr(style.style())) 775 776 inlineStyle->mergeAndOverrideOnConflict(*otherStyle); 776 777 setNodeAttribute(element, styleAttr, inlineStyle->asText()); … … 791 792 } 792 793 793 Node* runStart = node.get();794 Node* runEnd = node.get();795 Node* sibling = node->nextSibling();796 while (sibling && sibling != pastEndNode && !sibling->contains(pastEndNode) && (!isBlock(sibling ) || sibling->hasTagName(brTag)) && !containsNonEditableRegion(*sibling)) {794 auto runStart = node; 795 auto runEnd = node; 796 auto sibling = makeRefPtr(node->nextSibling()); 797 while (sibling && sibling != pastEndNode && !sibling->contains(pastEndNode) && (!isBlock(sibling.get()) || sibling->hasTagName(brTag)) && !containsNonEditableRegion(*sibling)) { 797 798 runEnd = sibling; 798 799 sibling = runEnd->nextSibling(); … … 800 801 next = NodeTraversal::nextSkippingChildren(*runEnd); 801 802 802 Node* pastEndNode = NodeTraversal::nextSkippingChildren(*runEnd);803 if (!shouldApplyInlineStyleToRun(style, runStart , pastEndNode))803 auto pastEndNode = makeRefPtr(NodeTraversal::nextSkippingChildren(*runEnd)); 804 if (!shouldApplyInlineStyleToRun(style, runStart.get(), pastEndNode.get())) 804 805 continue; 805 806 806 runs.append(InlineRunToApplyStyle(runStart , runEnd, pastEndNode));807 runs.append(InlineRunToApplyStyle(runStart.get(), runEnd.get(), pastEndNode.get())); 807 808 } 808 809 … … 836 837 ASSERT(runStart); 837 838 838 for ( Node* node = runStart; node && node != pastEndNode; node = NodeTraversal::next(*node)) {839 for (auto node = makeRefPtr(runStart); node && node != pastEndNode; node = NodeTraversal::next(*node)) { 839 840 if (node->hasChildNodes()) 840 841 continue; … … 842 843 if (!style.styleIsPresentInComputedStyleOfNode(*node)) 843 844 return true; 844 if (m_styledInlineElement && !enclosingElementWithTag(positionBeforeNode(node ), m_styledInlineElement->tagQName()))845 if (m_styledInlineElement && !enclosingElementWithTag(positionBeforeNode(node.get()), m_styledInlineElement->tagQName())) 845 846 return true; 846 847 } … … 962 963 } 963 964 964 HTMLElement*ApplyStyleCommand::highestAncestorWithConflictingInlineStyle(EditingStyle& style, Node* node)965 RefPtr<HTMLElement> ApplyStyleCommand::highestAncestorWithConflictingInlineStyle(EditingStyle& style, Node* node) 965 966 { 966 967 if (!node) 967 968 return nullptr; 968 969 969 HTMLElement* result = nullptr;970 Node* unsplittableElement = unsplittableElementForPosition(firstPositionInOrBeforeNode(node));971 972 for ( Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {970 RefPtr<HTMLElement> result; 971 auto unsplittableElement = makeRefPtr(unsplittableElementForPosition(firstPositionInOrBeforeNode(node))); 972 973 for (auto ancestor = makeRefPtr(node); ancestor; ancestor = ancestor->parentNode()) { 973 974 if (is<HTMLElement>(*ancestor) && shouldRemoveInlineStyleFromElement(style, downcast<HTMLElement>(*ancestor))) 974 result = downcast<HTMLElement>(ancestor);975 result = static_pointer_cast<HTMLElement>(ancestor); 975 976 // Should stop at the editable root (cannot cross editing boundary) and 976 977 // also stop at the unsplittable element to be consistent with other UAs … … 1002 1003 } 1003 1004 1004 if (node.renderer()->isText() && static_cast<RenderText*>(node.renderer())->isAllCollapsibleWhitespace()) 1005 return; 1006 if (node.renderer()->isBR() && !node.renderer()->style().preserveNewline()) 1007 return; 1005 { 1006 ScriptDisallowedScope::InMainThread scriptDisallowedScope; 1007 1008 if (node.renderer()->isText() && static_cast<RenderText*>(node.renderer())->isAllCollapsibleWhitespace()) 1009 return; 1010 if (node.renderer()->isBR() && !node.renderer()->style().preserveNewline()) 1011 return; 1012 } 1008 1013 1009 1014 // We can't wrap node with the styled element here because new styled element will never be removed if we did. … … 1015 1020 void ApplyStyleCommand::pushDownInlineStyleAroundNode(EditingStyle& style, Node* targetNode) 1016 1021 { 1017 HTMLElement*highestAncestor = highestAncestorWithConflictingInlineStyle(style, targetNode);1022 auto highestAncestor = highestAncestorWithConflictingInlineStyle(style, targetNode); 1018 1023 if (!highestAncestor) 1019 1024 return; … … 1077 1082 // Move it to the next deep quivalent position to avoid removing the style from this node. 1078 1083 // e.g. if pushDownStart was at Position("hello", 5) in <b>hello<div>world</div></b>, we want Position("world", 0) instead. 1079 auto * pushDownStartContainer = pushDownStart.containerNode();1084 auto pushDownStartContainer = makeRefPtr(pushDownStart.containerNode()); 1080 1085 if (is<Text>(pushDownStartContainer) && static_cast<unsigned>(pushDownStart.computeOffsetInContainerNode()) == downcast<Text>(*pushDownStartContainer).length()) 1081 1086 pushDownStart = nextVisuallyDistinctCandidate(pushDownStart); … … 1083 1088 // Move it to the previous deep equivalent position to avoid removing the style from this node. 1084 1089 Position pushDownEnd = end.upstream(); 1085 auto * pushDownEndContainer = pushDownEnd.containerNode();1090 auto pushDownEndContainer = makeRefPtr(pushDownEnd.containerNode()); 1086 1091 if (is<Text>(pushDownEndContainer) && !pushDownEnd.computeOffsetInContainerNode()) 1087 1092 pushDownEnd = previousVisuallyDistinctCandidate(pushDownEnd); … … 1244 1249 bool ApplyStyleCommand::mergeStartWithPreviousIfIdentical(const Position& start, const Position& end) 1245 1250 { 1246 auto * startNode = start.containerNode();1251 auto startNode = makeRefPtr(start.containerNode()); 1247 1252 if (start.computeOffsetInContainerNode()) 1248 1253 return false; 1249 1254 1250 if (isAtomicNode(startNode )) {1255 if (isAtomicNode(startNode.get())) { 1251 1256 // note: prior siblings could be unrendered elements. it's silly to miss the 1252 1257 // merge opportunity just for that. … … 1257 1262 } 1258 1263 1259 auto * previousSibling = startNode->previousSibling();1264 auto previousSibling = makeRefPtr(startNode->previousSibling()); 1260 1265 if (!previousSibling || !areIdenticalElements(*startNode, *previousSibling)) 1261 1266 return false; … … 1270 1275 unsigned startOffset = startChild->computeNodeIndex(); 1271 1276 unsigned endOffset = end.deprecatedEditingOffset() + (startNode == end.deprecatedNode() ? startOffset : 0); 1272 updateStartEnd({ startNode , startOffset, Position::PositionIsOffsetInAnchor },1277 updateStartEnd({ startNode.get(), startOffset, Position::PositionIsOffsetInAnchor }, 1273 1278 { end.deprecatedNode(), endOffset, Position::PositionIsOffsetInAnchor }); 1274 1279 return true; … … 1277 1282 bool ApplyStyleCommand::mergeEndWithNextIfIdentical(const Position& start, const Position& end) 1278 1283 { 1279 Node* endNode = end.containerNode();1280 1281 if (isAtomicNode(endNode )) {1284 auto endNode = makeRefPtr(end.containerNode()); 1285 1286 if (isAtomicNode(endNode.get())) { 1282 1287 int endOffset = end.computeOffsetInContainerNode(); 1283 if (offsetIsBeforeLastNodeOffset(endOffset, endNode ) || end.deprecatedNode()->nextSibling())1288 if (offsetIsBeforeLastNodeOffset(endOffset, endNode.get()) || end.deprecatedNode()->nextSibling()) 1284 1289 return false; 1285 1290 … … 1290 1295 return false; 1291 1296 1292 Node* nextSibling = endNode->nextSibling();1297 auto nextSibling = makeRefPtr(endNode->nextSibling()); 1293 1298 if (!nextSibling || !areIdenticalElements(*endNode, *nextSibling)) 1294 1299 return false; … … 1337 1342 1338 1343 if (is<Element>(previousSibling) && previousSibling->hasEditableStyle()) { 1339 auto * mergedElement = previousSibling->nextSibling();1344 auto mergedElement = makeRefPtr(previousSibling->nextSibling()); 1340 1345 ASSERT(mergedElement); 1341 1346 if (mergedElement->hasEditableStyle() && areIdenticalElements(*previousSibling, *mergedElement)) … … 1400 1405 1401 1406 // Find appropriate font and span elements top-down. 1402 HTMLFontElement* fontContainer = nullptr;1403 HTMLElement* styleContainer = nullptr;1407 RefPtr<HTMLFontElement> fontContainer; 1408 RefPtr<HTMLElement> styleContainer; 1404 1409 while (startNode == endNode) { 1405 1410 if (is<HTMLElement>(*startNode)) { … … 1498 1503 1499 1504 for (auto& childText : textNodes) { 1500 Node* next = childText->nextSibling();1505 auto next = makeRefPtr(childText->nextSibling()); 1501 1506 if (!is<Text>(next)) 1502 1507 continue; -
trunk/Source/WebCore/editing/ApplyStyleCommand.h
r274865 r276133 83 83 bool removeImplicitlyStyledElement(EditingStyle&, HTMLElement&, InlineStyleRemovalMode, EditingStyle* extractedStyle); 84 84 bool removeCSSStyle(EditingStyle&, HTMLElement&, InlineStyleRemovalMode = RemoveIfNeeded, EditingStyle* extractedStyle = nullptr); 85 HTMLElement*highestAncestorWithConflictingInlineStyle(EditingStyle&, Node*);85 RefPtr<HTMLElement> highestAncestorWithConflictingInlineStyle(EditingStyle&, Node*); 86 86 void applyInlineStyleToPushDown(Node&, EditingStyle*); 87 87 void pushDownInlineStyleAroundNode(EditingStyle&, Node*); … … 114 114 void joinChildTextNodes(Node*, const Position& start, const Position& end); 115 115 116 HTMLElement*splitAncestorsWithUnicodeBidi(Node*, bool before, WritingDirection allowedDirection);116 RefPtr<HTMLElement> splitAncestorsWithUnicodeBidi(Node*, bool before, WritingDirection allowedDirection); 117 117 void removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsplitAncestor); 118 118
Note:
See TracChangeset
for help on using the changeset viewer.