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

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

Issue 22353004: background-color and text-decoration are not preserved when merging paragraphs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 4 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/editing/EditingStyle.h ('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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 RefPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle( CSSComputedStyleDeclaration::create(node->parentNode()), AllEditingProperties); 630 RefPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle( CSSComputedStyleDeclaration::create(node->parentNode()), AllEditingProperties);
631 RefPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CS SComputedStyleDeclaration::create(node), AllEditingProperties); 631 RefPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CS SComputedStyleDeclaration::create(node), AllEditingProperties);
632 nodeStyle->removeEquivalentProperties(parentStyle->ensureCSSStyleDeclaration ()); 632 nodeStyle->removeEquivalentProperties(parentStyle->ensureCSSStyleDeclaration ());
633 633
634 unsigned propertyCount = nodeStyle->propertyCount(); 634 unsigned propertyCount = nodeStyle->propertyCount();
635 for (unsigned i = 0; i < propertyCount; ++i) 635 for (unsigned i = 0; i < propertyCount; ++i)
636 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); 636 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id());
637 } 637 }
638 638
639 void EditingStyle::removeNonEditingProperties()
640 {
641 if (m_mutableStyle)
642 m_mutableStyle = copyEditingProperties(m_mutableStyle.get());
643 }
644
645 void EditingStyle::collapseTextDecorationProperties() 639 void EditingStyle::collapseTextDecorationProperties()
646 { 640 {
647 if (!m_mutableStyle) 641 if (!m_mutableStyle)
648 return; 642 return;
649 643
650 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect); 644 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect);
651 if (!textDecorationsInEffect) 645 if (!textDecorationsInEffect)
652 return; 646 return;
653 647
654 if (textDecorationsInEffect->isValueList()) 648 if (textDecorationsInEffect->isValueList())
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 } 987 }
994 } 988 }
995 989
996 static inline bool elementMatchesAndPropertyIsNotInInlineStyleDecl(const HTMLEle mentEquivalent* equivalent, const Element* element, 990 static inline bool elementMatchesAndPropertyIsNotInInlineStyleDecl(const HTMLEle mentEquivalent* equivalent, const Element* element,
997 EditingStyle::CSSPropertyOverrideMode mode, StylePropertySet* style) 991 EditingStyle::CSSPropertyOverrideMode mode, StylePropertySet* style)
998 { 992 {
999 return equivalent->matches(element) && (!element->inlineStyle() || !equivale nt->propertyExistsInStyle(element->inlineStyle())) 993 return equivalent->matches(element) && (!element->inlineStyle() || !equivale nt->propertyExistsInStyle(element->inlineStyle()))
1000 && (mode == EditingStyle::OverrideValues || !equivalent->propertyExistsI nStyle(style)); 994 && (mode == EditingStyle::OverrideValues || !equivalent->propertyExistsI nStyle(style));
1001 } 995 }
1002 996
997 static PassRefPtr<MutableStylePropertySet> extractEditingProperties(const StyleP ropertySet* style, EditingStyle::PropertiesToInclude propertiesToInclude)
998 {
999 if (!style)
1000 return 0;
1001
1002 switch (propertiesToInclude) {
1003 case EditingStyle::AllProperties:
1004 case EditingStyle::EditingPropertiesInEffect:
1005 return copyEditingProperties(style, AllEditingProperties);
1006 case EditingStyle::OnlyEditingInheritableProperties:
1007 return copyEditingProperties(style, OnlyInheritableEditingProperties);
1008 }
1009
1010 ASSERT_NOT_REACHED();
1011 return 0;
1012 }
1013
1003 void EditingStyle::mergeInlineAndImplicitStyleOfElement(Element* element, CSSPro pertyOverrideMode mode, PropertiesToInclude propertiesToInclude) 1014 void EditingStyle::mergeInlineAndImplicitStyleOfElement(Element* element, CSSPro pertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
1004 { 1015 {
1005 RefPtr<EditingStyle> styleFromRules = EditingStyle::create(); 1016 RefPtr<EditingStyle> styleFromRules = EditingStyle::create();
1006 styleFromRules->mergeStyleFromRulesForSerialization(element); 1017 styleFromRules->mergeStyleFromRulesForSerialization(element);
1007 styleFromRules->removeNonEditingProperties(); 1018 styleFromRules->m_mutableStyle = extractEditingProperties(styleFromRules->m_ mutableStyle.get(), propertiesToInclude);
1008 mergeStyle(styleFromRules->m_mutableStyle.get(), mode); 1019 mergeStyle(styleFromRules->m_mutableStyle.get(), mode);
1009 1020
1010 mergeInlineStyleOfElement(element, mode, propertiesToInclude); 1021 mergeInlineStyleOfElement(element, mode, propertiesToInclude);
1011 1022
1012 const Vector<OwnPtr<HTMLElementEquivalent> >& elementEquivalents = htmlEleme ntEquivalents(); 1023 const Vector<OwnPtr<HTMLElementEquivalent> >& elementEquivalents = htmlEleme ntEquivalents();
1013 for (size_t i = 0; i < elementEquivalents.size(); ++i) { 1024 for (size_t i = 0; i < elementEquivalents.size(); ++i) {
1014 if (elementMatchesAndPropertyIsNotInInlineStyleDecl(elementEquivalents[i ].get(), element, mode, m_mutableStyle.get())) 1025 if (elementMatchesAndPropertyIsNotInInlineStyleDecl(elementEquivalents[i ].get(), element, mode, m_mutableStyle.get()))
1015 elementEquivalents[i]->addToStyle(element, this); 1026 elementEquivalents[i]->addToStyle(element, this);
1016 } 1027 }
1017 1028
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 { 1632 {
1622 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1633 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1623 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); 1634 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor);
1624 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1635 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1625 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1636 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1626 } 1637 }
1627 return 0; 1638 return 0;
1628 } 1639 }
1629 1640
1630 } 1641 }
OLDNEW
« no previous file with comments | « Source/core/editing/EditingStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698