Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp

Issue 1858753003: Remove RawPtr from core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // We are allowed to leave the highest ancestor with unicode-bidi unsplit if it is unicode-bidi: embed and direction: allowedDirection. 475 // We are allowed to leave the highest ancestor with unicode-bidi unsplit if it is unicode-bidi: embed and direction: allowedDirection.
476 // In that case, we return the unsplit ancestor. Otherwise, we return 0. 476 // In that case, we return the unsplit ancestor. Otherwise, we return 0.
477 Element* block = enclosingBlock(node); 477 Element* block = enclosingBlock(node);
478 if (!block) 478 if (!block)
479 return 0; 479 return 0;
480 480
481 ContainerNode* highestAncestorWithUnicodeBidi = nullptr; 481 ContainerNode* highestAncestorWithUnicodeBidi = nullptr;
482 ContainerNode* nextHighestAncestorWithUnicodeBidi = nullptr; 482 ContainerNode* nextHighestAncestorWithUnicodeBidi = nullptr;
483 int highestAncestorUnicodeBidi = 0; 483 int highestAncestorUnicodeBidi = 0;
484 for (ContainerNode* n = node->parentNode(); n != block; n = n->parentNode()) { 484 for (ContainerNode* n = node->parentNode(); n != block; n = n->parentNode()) {
485 int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create (n).get(), CSSPropertyUnicodeBidi); 485 int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create (n), CSSPropertyUnicodeBidi);
486 if (unicodeBidi && unicodeBidi != CSSValueNormal) { 486 if (unicodeBidi && unicodeBidi != CSSValueNormal) {
487 highestAncestorUnicodeBidi = unicodeBidi; 487 highestAncestorUnicodeBidi = unicodeBidi;
488 nextHighestAncestorWithUnicodeBidi = highestAncestorWithUnicodeBidi; 488 nextHighestAncestorWithUnicodeBidi = highestAncestorWithUnicodeBidi;
489 highestAncestorWithUnicodeBidi = n; 489 highestAncestorWithUnicodeBidi = n;
490 } 490 }
491 } 491 }
492 492
493 if (!highestAncestorWithUnicodeBidi) 493 if (!highestAncestorWithUnicodeBidi)
494 return 0; 494 return 0;
495 495
(...skipping 29 matching lines...) Expand all
525 { 525 {
526 Element* block = enclosingBlock(node); 526 Element* block = enclosingBlock(node);
527 if (!block) 527 if (!block)
528 return; 528 return;
529 529
530 for (ContainerNode* n = node->parentNode(); n != block && n != unsplitAncest or; n = n->parentNode()) { 530 for (ContainerNode* n = node->parentNode(); n != block && n != unsplitAncest or; n = n->parentNode()) {
531 if (!n->isStyledElement()) 531 if (!n->isStyledElement())
532 continue; 532 continue;
533 533
534 Element* element = toElement(n); 534 Element* element = toElement(n);
535 int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create (element).get(), CSSPropertyUnicodeBidi); 535 int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create (element), CSSPropertyUnicodeBidi);
536 if (!unicodeBidi || unicodeBidi == CSSValueNormal) 536 if (!unicodeBidi || unicodeBidi == CSSValueNormal)
537 continue; 537 continue;
538 538
539 // FIXME: This code should really consider the mapped attribute 'dir', t he inline style declaration, 539 // FIXME: This code should really consider the mapped attribute 'dir', t he inline style declaration,
540 // and all matching style rules in order to determine how to best set th e unicode-bidi property to 'normal'. 540 // and all matching style rules in order to determine how to best set th e unicode-bidi property to 'normal'.
541 // For now, it assumes that if the 'dir' attribute is present, then remo ving it will suffice, and 541 // For now, it assumes that if the 'dir' attribute is present, then remo ving it will suffice, and
542 // otherwise it sets the property in the inline style declaration. 542 // otherwise it sets the property in the inline style declaration.
543 if (element->hasAttribute(dirAttr)) { 543 if (element->hasAttribute(dirAttr)) {
544 // FIXME: If this is a BDO element, we should probably just remove i t if it has no 544 // FIXME: If this is a BDO element, we should probably just remove i t if it has no
545 // other attributes, like we (should) do with B and I elements. 545 // other attributes, like we (should) do with B and I elements.
546 removeElementAttribute(element, dirAttr); 546 removeElementAttribute(element, dirAttr);
547 } else { 547 } else {
548 RawPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty (element->inlineStyle()); 548 RawPtr<MutableStylePropertySet> inlineStyle = copyStyleOrCreateEmpty (element->inlineStyle());
549 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal); 549 inlineStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueNormal);
550 inlineStyle->removeProperty(CSSPropertyDirection); 550 inlineStyle->removeProperty(CSSPropertyDirection);
551 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asTex t())); 551 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asTex t()));
552 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) { 552 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) {
553 removeNodePreservingChildren(element, editingState); 553 removeNodePreservingChildren(element, editingState);
554 if (editingState->isAborted()) 554 if (editingState->isAborted())
555 return; 555 return;
556 } 556 }
557 } 557 }
558 } 558 }
559 } 559 }
560 560
561 static HTMLElement* highestEmbeddingAncestor(Node* startNode, Node* enclosingNod e) 561 static HTMLElement* highestEmbeddingAncestor(Node* startNode, Node* enclosingNod e)
562 { 562 {
563 for (Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) { 563 for (Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) {
564 if (n->isHTMLElement() 564 if (n->isHTMLElement()
565 && EditingStyle::isEmbedOrIsolate(getIdentifierValue(CSSComputedStyl eDeclaration::create(n).get(), CSSPropertyUnicodeBidi))) { 565 && EditingStyle::isEmbedOrIsolate(getIdentifierValue(CSSComputedStyl eDeclaration::create(n), CSSPropertyUnicodeBidi))) {
566 return toHTMLElement(n); 566 return toHTMLElement(n);
567 } 567 }
568 } 568 }
569 569
570 return 0; 570 return 0;
571 } 571 }
572 572
573 void ApplyStyleCommand::applyInlineStyle(EditingStyle* style, EditingState* edit ingState) 573 void ApplyStyleCommand::applyInlineStyle(EditingStyle* style, EditingState* edit ingState)
574 { 574 {
575 RawPtr<ContainerNode> startDummySpanAncestor = nullptr; 575 RawPtr<ContainerNode> startDummySpanAncestor = nullptr;
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 1654
1655 if (m_styledInlineElement && addStyledElement == AddStyledElement) 1655 if (m_styledInlineElement && addStyledElement == AddStyledElement)
1656 surroundNodeRangeWithElement(startNode, endNode, m_styledInlineElement-> cloneElementWithoutChildren(), editingState); 1656 surroundNodeRangeWithElement(startNode, endNode, m_styledInlineElement-> cloneElementWithoutChildren(), editingState);
1657 } 1657 }
1658 1658
1659 float ApplyStyleCommand::computedFontSize(Node* node) 1659 float ApplyStyleCommand::computedFontSize(Node* node)
1660 { 1660 {
1661 if (!node) 1661 if (!node)
1662 return 0; 1662 return 0;
1663 1663
1664 RawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::cre ate(node); 1664 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create(nod e);
1665 if (!style) 1665 if (!style)
1666 return 0; 1666 return 0;
1667 1667
1668 RawPtr<CSSPrimitiveValue> value = static_pointer_cast<CSSPrimitiveValue>(sty le->getPropertyCSSValue(CSSPropertyFontSize)); 1668 CSSPrimitiveValue* value = toCSSPrimitiveValue(style->getPropertyCSSValue(CS SPropertyFontSize));
1669 if (!value) 1669 if (!value)
1670 return 0; 1670 return 0;
1671 1671
1672 ASSERT(value->typeWithCalcResolved() == CSSPrimitiveValue::UnitType::Pixels) ; 1672 ASSERT(value->typeWithCalcResolved() == CSSPrimitiveValue::UnitType::Pixels) ;
1673 return value->getFloatValue(); 1673 return value->getFloatValue();
1674 } 1674 }
1675 1675
1676 void ApplyStyleCommand::joinChildTextNodes(ContainerNode* node, const Position& start, const Position& end) 1676 void ApplyStyleCommand::joinChildTextNodes(ContainerNode* node, const Position& start, const Position& end)
1677 { 1677 {
1678 if (!node) 1678 if (!node)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 DEFINE_TRACE(ApplyStyleCommand) 1713 DEFINE_TRACE(ApplyStyleCommand)
1714 { 1714 {
1715 visitor->trace(m_style); 1715 visitor->trace(m_style);
1716 visitor->trace(m_start); 1716 visitor->trace(m_start);
1717 visitor->trace(m_end); 1717 visitor->trace(m_end);
1718 visitor->trace(m_styledInlineElement); 1718 visitor->trace(m_styledInlineElement);
1719 CompositeEditCommand::trace(visitor); 1719 CompositeEditCommand::trace(visitor);
1720 } 1720 }
1721 1721
1722 } // namespace blink 1722 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingStyle.cpp ('k') | third_party/WebKit/Source/wtf/LeakAnnotations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698