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

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

Issue 22378004: Replace error-prone value with check from CSSProperty (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase after text-decoration patch revert 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "core/editing/htmlediting.h" 51 #include "core/editing/htmlediting.h"
52 #include "core/html/HTMLFontElement.h" 52 #include "core/html/HTMLFontElement.h"
53 #include "core/page/Frame.h" 53 #include "core/page/Frame.h"
54 #include "core/page/RuntimeCSSEnabled.h" 54 #include "core/page/RuntimeCSSEnabled.h"
55 #include "core/rendering/style/RenderStyle.h" 55 #include "core/rendering/style/RenderStyle.h"
56 56
57 namespace WebCore { 57 namespace WebCore {
58 58
59 // Editing style properties must be preserved during editing operation. 59 // Editing style properties must be preserved during editing operation.
60 // e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph. 60 // e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph.
61 // NOTE: Use editingProperties() to respect runtime enabling of properties. 61 // NOTE: Use either allEditingProperties() or inheritableEditingProperties() to
62 static const unsigned nonInheritedStaticPropertiesCount = 2; 62 // respect runtime enabling of properties.
63
64 static const CSSPropertyID staticEditingProperties[] = { 63 static const CSSPropertyID staticEditingProperties[] = {
65 // NOTE: inheritableEditingProperties depends on these two properties being first.
66 // If you change this list, make sure to update nonInheritedPropertyCount.
67 CSSPropertyBackgroundColor, 64 CSSPropertyBackgroundColor,
68 CSSPropertyTextDecoration,
69
70 // CSS inheritable properties
71 CSSPropertyColor, 65 CSSPropertyColor,
72 CSSPropertyFontFamily, 66 CSSPropertyFontFamily,
73 CSSPropertyFontSize, 67 CSSPropertyFontSize,
74 CSSPropertyFontStyle, 68 CSSPropertyFontStyle,
75 CSSPropertyFontVariant, 69 CSSPropertyFontVariant,
76 CSSPropertyFontWeight, 70 CSSPropertyFontWeight,
77 CSSPropertyLetterSpacing, 71 CSSPropertyLetterSpacing,
78 CSSPropertyLineHeight, 72 CSSPropertyLineHeight,
79 CSSPropertyOrphans, 73 CSSPropertyOrphans,
80 CSSPropertyTextAlign, 74 CSSPropertyTextAlign,
75 CSSPropertyTextDecoration,
81 CSSPropertyTextIndent, 76 CSSPropertyTextIndent,
82 CSSPropertyTextTransform, 77 CSSPropertyTextTransform,
83 CSSPropertyWhiteSpace, 78 CSSPropertyWhiteSpace,
84 CSSPropertyWidows, 79 CSSPropertyWidows,
85 CSSPropertyWordSpacing, 80 CSSPropertyWordSpacing,
86 CSSPropertyWebkitTextDecorationsInEffect, 81 CSSPropertyWebkitTextDecorationsInEffect,
87 CSSPropertyWebkitTextFillColor, 82 CSSPropertyWebkitTextFillColor,
88 CSSPropertyWebkitTextStrokeColor, 83 CSSPropertyWebkitTextStrokeColor,
89 CSSPropertyWebkitTextStrokeWidth, 84 CSSPropertyWebkitTextStrokeWidth,
90 }; 85 };
91 86
92 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies }; 87 enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingPropert ies };
93 88
94 static const Vector<CSSPropertyID>& allEditingProperties() 89 static const Vector<CSSPropertyID>& allEditingProperties()
95 { 90 {
96 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); 91 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
97 if (properties.isEmpty()) 92 if (properties.isEmpty())
98 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties); 93 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties);
99 return properties; 94 return properties;
100 } 95 }
101 96
102 static const Vector<CSSPropertyID>& inheritableEditingProperties() 97 static const Vector<CSSPropertyID>& inheritableEditingProperties()
103 { 98 {
104 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); 99 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
105 if (properties.isEmpty()) 100 if (properties.isEmpty()) {
106 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingPrope rties) - nonInheritedStaticPropertiesCount, properties); 101 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingPro perties, WTF_ARRAY_LENGTH(staticEditingProperties), properties);
102 for (size_t index = 0; index < properties.size();) {
103 if (!CSSProperty::isInheritedProperty(properties[index])) {
104 properties.remove(index);
105 continue;
106 }
107 ++index;
108 }
109 }
107 return properties; 110 return properties;
108 } 111 }
109 112
110 template <class StyleDeclarationType> 113 template <class StyleDeclarationType>
111 static PassRefPtr<MutableStylePropertySet> copyEditingProperties(StyleDeclaratio nType* style, EditingPropertiesType type = OnlyInheritableEditingProperties) 114 static PassRefPtr<MutableStylePropertySet> copyEditingProperties(StyleDeclaratio nType* style, EditingPropertiesType type = OnlyInheritableEditingProperties)
112 { 115 {
113 if (type == AllEditingProperties) 116 if (type == AllEditingProperties)
114 return style->copyPropertiesInSet(allEditingProperties()); 117 return style->copyPropertiesInSet(allEditingProperties());
115 return style->copyPropertiesInSet(inheritableEditingProperties()); 118 return style->copyPropertiesInSet(inheritableEditingProperties());
116 } 119 }
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 { 1635 {
1633 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1636 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1634 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); 1637 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor);
1635 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1638 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1636 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1639 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1637 } 1640 }
1638 return 0; 1641 return 0;
1639 } 1642 }
1640 1643
1641 } 1644 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698