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

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

Issue 428823002: Use tighter typing in editing: markup (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 448 }
449 449
450 template<typename T> 450 template<typename T>
451 static int textAlignResolvingStartAndEnd(T* style) 451 static int textAlignResolvingStartAndEnd(T* style)
452 { 452 {
453 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe xtAlign), getIdentifierValue(style, CSSPropertyDirection)); 453 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe xtAlign), getIdentifierValue(style, CSSPropertyDirection));
454 } 454 }
455 455
456 void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude) 456 void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude)
457 { 457 {
458 if (isTabSpanTextNode(node)) 458 if (isTabHTMLSpanElementTextNode(node))
459 node = tabSpanElement(node)->parentNode(); 459 node = tabSpanElement(node)->parentNode();
460 else if (isTabSpanElement(node)) 460 else if (isTabHTMLSpanElement(node))
461 node = node->parentNode(); 461 node = node->parentNode();
462 462
463 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS SComputedStyleDeclaration::create(node); 463 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS SComputedStyleDeclaration::create(node);
464 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition); 464 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition);
465 465
466 if (propertiesToInclude == EditingPropertiesInEffect) { 466 if (propertiesToInclude == EditingPropertiesInEffect) {
467 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node)) 467 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node))
468 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt()); 468 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt());
469 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) 469 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect))
470 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t()); 470 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t());
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 739
740 const StylePropertySet* inlineStyle = element->inlineStyle(); 740 const StylePropertySet* inlineStyle = element->inlineStyle();
741 if (!m_mutableStyle || !inlineStyle) 741 if (!m_mutableStyle || !inlineStyle)
742 return false; 742 return false;
743 743
744 unsigned propertyCount = m_mutableStyle->propertyCount(); 744 unsigned propertyCount = m_mutableStyle->propertyCount();
745 for (unsigned i = 0; i < propertyCount; ++i) { 745 for (unsigned i = 0; i < propertyCount; ++i) {
746 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id(); 746 CSSPropertyID propertyID = m_mutableStyle->propertyAt(i).id();
747 747
748 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space. 748 // We don't override whitespace property of a tab span because that woul d collapse the tab into a space.
749 if (propertyID == CSSPropertyWhiteSpace && isTabSpanElement(element)) 749 if (propertyID == CSSPropertyWhiteSpace && isTabHTMLSpanElement(element) )
750 continue; 750 continue;
751 751
752 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(textDecorationPropertyForEditing())) { 752 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyl e->getPropertyCSSValue(textDecorationPropertyForEditing())) {
753 if (!conflictingProperties) 753 if (!conflictingProperties)
754 return true; 754 return true;
755 conflictingProperties->append(CSSPropertyTextDecoration); 755 conflictingProperties->append(CSSPropertyTextDecoration);
756 // Because text-decoration expands to text-decoration-line when CSS3 756 // Because text-decoration expands to text-decoration-line when CSS3
757 // Text Decoration is enabled, we also state it as conflicting. 757 // Text Decoration is enabled, we also state it as conflicting.
758 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) 758 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
759 conflictingProperties->append(CSSPropertyTextDecorationLine); 759 conflictingProperties->append(CSSPropertyTextDecorationLine);
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 1427
1428 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com putedStyle(); 1428 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = position.com putedStyle();
1429 // FIXME: take care of background-color in effect 1429 // FIXME: take care of background-color in effect
1430 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI n(style->style(), computedStyle.get()); 1430 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI n(style->style(), computedStyle.get());
1431 1431
1432 reconcileTextDecorationProperties(mutableStyle.get()); 1432 reconcileTextDecorationProperties(mutableStyle.get());
1433 if (!document->frame()->editor().shouldStyleWithCSS()) 1433 if (!document->frame()->editor().shouldStyleWithCSS())
1434 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc hFontType()); 1434 extractTextStyles(document, mutableStyle.get(), computedStyle->fixedPitc hFontType());
1435 1435
1436 // Changing the whitespace style in a tab span would collapse the tab into a space. 1436 // Changing the whitespace style in a tab span would collapse the tab into a space.
1437 if (isTabSpanTextNode(position.deprecatedNode()) || isTabSpanElement((positi on.deprecatedNode()))) 1437 if (isTabHTMLSpanElementTextNode(position.deprecatedNode()) || isTabHTMLSpan Element((position.deprecatedNode())))
1438 mutableStyle->removeProperty(CSSPropertyWhiteSpace); 1438 mutableStyle->removeProperty(CSSPropertyWhiteSpace);
1439 1439
1440 // If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle. 1440 // If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle.
1441 // FIXME: Shouldn't this be done in getPropertiesNotIn? 1441 // FIXME: Shouldn't this be done in getPropertiesNotIn?
1442 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty le()->getPropertyCSSValue(CSSPropertyDirection)) 1442 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty le()->getPropertyCSSValue(CSSPropertyDirection))
1443 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope rtyValue(CSSPropertyDirection)); 1443 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope rtyValue(CSSPropertyDirection));
1444 1444
1445 // Save the result for later 1445 // Save the result for later
1446 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); 1446 m_cssStyle = mutableStyle->asText().stripWhiteSpace();
1447 } 1447 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 { 1676 {
1677 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1677 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1678 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); 1678 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor);
1679 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1679 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1680 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1680 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1681 } 1681 }
1682 return nullptr; 1682 return nullptr;
1683 } 1683 }
1684 1684
1685 } 1685 }
OLDNEW
« no previous file with comments | « Source/core/editing/CompositeEditCommand.cpp ('k') | Source/core/editing/FormatBlockCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698