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

Side by Side Diff: Source/core/editing/EditingStyle.cpp

Issue 1183023003: Move (copy/remove)BlockProperties out of MutableStylePropertySet (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « Source/core/css/StylePropertySet.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc.
3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::copy() const 587 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::copy() const
588 { 588 {
589 RefPtrWillBeRawPtr<EditingStyle> copy = EditingStyle::create(); 589 RefPtrWillBeRawPtr<EditingStyle> copy = EditingStyle::create();
590 if (m_mutableStyle) 590 if (m_mutableStyle)
591 copy->m_mutableStyle = m_mutableStyle->mutableCopy(); 591 copy->m_mutableStyle = m_mutableStyle->mutableCopy();
592 copy->m_isMonospaceFont = m_isMonospaceFont; 592 copy->m_isMonospaceFont = m_isMonospaceFont;
593 copy->m_fontSizeDelta = m_fontSizeDelta; 593 copy->m_fontSizeDelta = m_fontSizeDelta;
594 return copy; 594 return copy;
595 } 595 }
596 596
597 // This is the list of CSS properties that apply specially to block-level elemen ts.
598 static const CSSPropertyID staticBlockProperties[] = {
599 CSSPropertyOrphans,
600 CSSPropertyOverflow, // This can be also be applied to replaced elements
601 CSSPropertyWebkitColumnCount,
602 CSSPropertyWebkitColumnGap,
603 CSSPropertyWebkitColumnRuleColor,
604 CSSPropertyWebkitColumnRuleStyle,
605 CSSPropertyWebkitColumnRuleWidth,
606 CSSPropertyWebkitColumnBreakBefore,
607 CSSPropertyWebkitColumnBreakAfter,
608 CSSPropertyWebkitColumnBreakInside,
609 CSSPropertyWebkitColumnWidth,
610 CSSPropertyPageBreakAfter,
611 CSSPropertyPageBreakBefore,
612 CSSPropertyPageBreakInside,
613 CSSPropertyTextAlign,
614 CSSPropertyTextAlignLast,
615 CSSPropertyTextIndent,
616 CSSPropertyTextJustify,
617 CSSPropertyWidows
618 };
619
620 static const Vector<CSSPropertyID>& blockPropertiesVector()
621 {
622 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
623 if (properties.isEmpty())
624 CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticBlockPro perties, WTF_ARRAY_LENGTH(staticBlockProperties), properties);
625 return properties;
626 }
627
597 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveBlockProperti es() 628 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveBlockProperti es()
598 { 629 {
599 RefPtrWillBeRawPtr<EditingStyle> blockProperties = EditingStyle::create(); 630 RefPtrWillBeRawPtr<EditingStyle> blockProperties = EditingStyle::create();
600 if (!m_mutableStyle) 631 if (!m_mutableStyle)
601 return blockProperties; 632 return blockProperties;
602 633
603 blockProperties->m_mutableStyle = m_mutableStyle->copyBlockProperties(); 634 blockProperties->m_mutableStyle = m_mutableStyle->copyPropertiesInSet(blockP ropertiesVector());
604 m_mutableStyle->removeBlockProperties(); 635 removeBlockProperties();
605 636
606 return blockProperties; 637 return blockProperties;
607 } 638 }
608 639
609 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveTextDirection () 640 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveTextDirection ()
610 { 641 {
611 RefPtrWillBeRawPtr<EditingStyle> textDirection = EditingStyle::create(); 642 RefPtrWillBeRawPtr<EditingStyle> textDirection = EditingStyle::create();
612 textDirection->m_mutableStyle = MutableStylePropertySet::create(); 643 textDirection->m_mutableStyle = MutableStylePropertySet::create();
613 textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueE mbed, m_mutableStyle->propertyIsImportant(CSSPropertyUnicodeBidi)); 644 textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueE mbed, m_mutableStyle->propertyIsImportant(CSSPropertyUnicodeBidi));
614 textDirection->m_mutableStyle->setProperty(CSSPropertyDirection, m_mutableSt yle->getPropertyValue(CSSPropertyDirection), 645 textDirection->m_mutableStyle->setProperty(CSSPropertyDirection, m_mutableSt yle->getPropertyValue(CSSPropertyDirection),
615 m_mutableStyle->propertyIsImportant(CSSPropertyDirection)); 646 m_mutableStyle->propertyIsImportant(CSSPropertyDirection));
616 647
617 m_mutableStyle->removeProperty(CSSPropertyUnicodeBidi); 648 m_mutableStyle->removeProperty(CSSPropertyUnicodeBidi);
618 m_mutableStyle->removeProperty(CSSPropertyDirection); 649 m_mutableStyle->removeProperty(CSSPropertyDirection);
619 650
620 return textDirection; 651 return textDirection;
621 } 652 }
622 653
623 void EditingStyle::removeBlockProperties() 654 void EditingStyle::removeBlockProperties()
624 { 655 {
625 if (!m_mutableStyle) 656 if (!m_mutableStyle)
626 return; 657 return;
627 658
628 m_mutableStyle->removeBlockProperties(); 659 m_mutableStyle->removePropertiesInSet(blockPropertiesVector().data(), blockP ropertiesVector().size());
rune 2015/06/16 06:46:59 I thought removePropertiesFromSet sounded better.
Timothy Loh 2015/06/17 01:31:43 I didn't really look at the names since I was just
629 } 660 }
630 661
631 void EditingStyle::removeStyleAddedByElement(Element* element) 662 void EditingStyle::removeStyleAddedByElement(Element* element)
632 { 663 {
633 if (!element || !element->parentNode()) 664 if (!element || !element->parentNode())
634 return; 665 return;
635 RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromCo mputedStyle(CSSComputedStyleDeclaration::create(element->parentNode()), AllEditi ngProperties); 666 RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromCo mputedStyle(CSSComputedStyleDeclaration::create(element->parentNode()), AllEditi ngProperties);
636 RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComp utedStyle(CSSComputedStyleDeclaration::create(element), AllEditingProperties); 667 RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComp utedStyle(CSSComputedStyleDeclaration::create(element), AllEditingProperties);
637 nodeStyle->removeEquivalentProperties(parentStyle.get()); 668 nodeStyle->removeEquivalentProperties(parentStyle.get());
638 m_mutableStyle->removeEquivalentProperties(nodeStyle.get()); 669 m_mutableStyle->removeEquivalentProperties(nodeStyle.get());
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 { 1708 {
1678 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1709 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1679 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); 1710 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor);
1680 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1711 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1681 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1712 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1682 } 1713 }
1683 return nullptr; 1714 return nullptr;
1684 } 1715 }
1685 1716
1686 } 1717 }
OLDNEW
« no previous file with comments | « Source/core/css/StylePropertySet.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698