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

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

Issue 16415007: Cleanup usage of CSSPropertyID and CSSValueID inside Blink. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/EditingStyle.h ('k') | Source/core/editing/markup.cpp » ('j') | 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV aluesMatch }; 131 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV aluesMatch };
132 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool should UseFixedFontDefaultSize, LegacyFontSizeMode); 132 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool should UseFixedFontDefaultSize, LegacyFontSizeMode);
133 static bool isTransparentColorValue(CSSValue*); 133 static bool isTransparentColorValue(CSSValue*);
134 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); 134 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
135 static bool hasTransparentBackgroundColor(StylePropertySet*); 135 static bool hasTransparentBackgroundColor(StylePropertySet*);
136 static PassRefPtr<CSSValue> backgroundColorInEffect(Node*); 136 static PassRefPtr<CSSValue> backgroundColorInEffect(Node*);
137 137
138 class HTMLElementEquivalent { 138 class HTMLElementEquivalent {
139 WTF_MAKE_FAST_ALLOCATED; 139 WTF_MAKE_FAST_ALLOCATED;
140 public: 140 public:
141 static PassOwnPtr<HTMLElementEquivalent> create(CSSPropertyID propertyID, in t primitiveValue, const QualifiedName& tagName) 141 static PassOwnPtr<HTMLElementEquivalent> create(CSSPropertyID propertyID, CS SValueID primitiveValue, const QualifiedName& tagName)
142 { 142 {
143 return adoptPtr(new HTMLElementEquivalent(propertyID, primitiveValue, ta gName)); 143 return adoptPtr(new HTMLElementEquivalent(propertyID, primitiveValue, ta gName));
144 } 144 }
145 145
146 virtual ~HTMLElementEquivalent() { } 146 virtual ~HTMLElementEquivalent() { }
147 virtual bool matches(const Element* element) const { return !m_tagName || el ement->hasTagName(*m_tagName); } 147 virtual bool matches(const Element* element) const { return !m_tagName || el ement->hasTagName(*m_tagName); }
148 virtual bool hasAttribute() const { return false; } 148 virtual bool hasAttribute() const { return false; }
149 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re turn style->getPropertyCSSValue(m_propertyID); } 149 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re turn style->getPropertyCSSValue(m_propertyID); }
150 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; 150 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const;
151 virtual void addToStyle(Element*, EditingStyle*) const; 151 virtual void addToStyle(Element*, EditingStyle*) const;
152 152
153 protected: 153 protected:
154 HTMLElementEquivalent(CSSPropertyID); 154 HTMLElementEquivalent(CSSPropertyID);
155 HTMLElementEquivalent(CSSPropertyID, const QualifiedName& tagName); 155 HTMLElementEquivalent(CSSPropertyID, const QualifiedName& tagName);
156 HTMLElementEquivalent(CSSPropertyID, int primitiveValue, const QualifiedName & tagName); 156 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const Qualif iedName& tagName);
157 const CSSPropertyID m_propertyID; 157 const CSSPropertyID m_propertyID;
158 const RefPtr<CSSPrimitiveValue> m_primitiveValue; 158 const RefPtr<CSSPrimitiveValue> m_primitiveValue;
159 const QualifiedName* m_tagName; // We can store a pointer because HTML tag n ames are const global. 159 const QualifiedName* m_tagName; // We can store a pointer because HTML tag n ames are const global.
160 }; 160 };
161 161
162 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id) 162 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id)
163 : m_propertyID(id) 163 : m_propertyID(id)
164 , m_tagName(0) 164 , m_tagName(0)
165 { 165 {
166 } 166 }
167 167
168 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const QualifiedNa me& tagName) 168 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const QualifiedNa me& tagName)
169 : m_propertyID(id) 169 : m_propertyID(id)
170 , m_tagName(&tagName) 170 , m_tagName(&tagName)
171 { 171 {
172 } 172 }
173 173
174 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, int primitiveValu e, const QualifiedName& tagName) 174 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit iveValue, const QualifiedName& tagName)
175 : m_propertyID(id) 175 : m_propertyID(id)
176 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) 176 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue))
177 , m_tagName(&tagName) 177 , m_tagName(&tagName)
178 { 178 {
179 ASSERT(primitiveValue != CSSValueInvalid); 179 ASSERT(primitiveValue != CSSValueInvalid);
180 } 180 }
181 181
182 bool HTMLElementEquivalent::valueIsPresentInStyle(Element* element, StylePropert ySet* style) const 182 bool HTMLElementEquivalent::valueIsPresentInStyle(Element* element, StylePropert ySet* style) const
183 { 183 {
184 RefPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID); 184 RefPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID);
185 return matches(element) && value && value->isPrimitiveValue() && static_cast <CSSPrimitiveValue*>(value.get())->getIdent() == m_primitiveValue->getIdent(); 185 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit iveValue(value.get())->getValueID() == m_primitiveValue->getValueID();
186 } 186 }
187 187
188 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const 188 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const
189 { 189 {
190 style->setProperty(m_propertyID, m_primitiveValue->cssText()); 190 style->setProperty(m_propertyID, m_primitiveValue->cssText());
191 } 191 }
192 192
193 class HTMLTextDecorationEquivalent : public HTMLElementEquivalent { 193 class HTMLTextDecorationEquivalent : public HTMLElementEquivalent {
194 public: 194 public:
195 static PassOwnPtr<HTMLElementEquivalent> create(int primitiveValue, const Qu alifiedName& tagName) 195 static PassOwnPtr<HTMLElementEquivalent> create(CSSValueID primitiveValue, c onst QualifiedName& tagName)
196 { 196 {
197 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName )); 197 return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName ));
198 } 198 }
199 virtual bool propertyExistsInStyle(const StylePropertySet*) const; 199 virtual bool propertyExistsInStyle(const StylePropertySet*) const;
200 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const; 200 virtual bool valueIsPresentInStyle(Element*, StylePropertySet*) const;
201 201
202 private: 202 private:
203 HTMLTextDecorationEquivalent(int primitiveValue, const QualifiedName& tagNam e); 203 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName);
204 }; 204 };
205 205
206 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(int primitiveValue, c onst QualifiedName& tagName) 206 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const QualifiedName& tagName)
207 : HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName) 207 : HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName)
208 // m_propertyID is used in HTMLElementEquivalent::addToStyle 208 // m_propertyID is used in HTMLElementEquivalent::addToStyle
209 { 209 {
210 } 210 }
211 211
212 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const 212 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const
213 { 213 {
214 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration); 214 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration);
215 } 215 }
216 216
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 516
517 bool EditingStyle::textDirection(WritingDirection& writingDirection) const 517 bool EditingStyle::textDirection(WritingDirection& writingDirection) const
518 { 518 {
519 if (!m_mutableStyle) 519 if (!m_mutableStyle)
520 return false; 520 return false;
521 521
522 RefPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSProper tyUnicodeBidi); 522 RefPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSProper tyUnicodeBidi);
523 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 523 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
524 return false; 524 return false;
525 525
526 int unicodeBidiValue = static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->g etIdent(); 526 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal ueID();
527 if (unicodeBidiValue == CSSValueEmbed) { 527 if (unicodeBidiValue == CSSValueEmbed) {
528 RefPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSValue(CSSProp ertyDirection); 528 RefPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSValue(CSSProp ertyDirection);
529 if (!direction || !direction->isPrimitiveValue()) 529 if (!direction || !direction->isPrimitiveValue())
530 return false; 530 return false;
531 531
532 writingDirection = static_cast<CSSPrimitiveValue*>(direction.get())->get Ident() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirecti on; 532 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
533 533
534 return true; 534 return true;
535 } 535 }
536 536
537 if (unicodeBidiValue == CSSValueNormal) { 537 if (unicodeBidiValue == CSSValueNormal) {
538 writingDirection = NaturalWritingDirection; 538 writingDirection = NaturalWritingDirection;
539 return true; 539 return true;
540 } 540 }
541 541
542 return false; 542 return false;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 m_mutableStyle->removeProperty(CSSPropertyTextAlign); 946 m_mutableStyle->removeProperty(CSSPropertyTextAlign);
947 947
948 if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(styleAtPositi on)) 948 if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(styleAtPositi on))
949 m_mutableStyle->removeProperty(CSSPropertyColor); 949 m_mutableStyle->removeProperty(CSSPropertyColor);
950 950
951 if (hasTransparentBackgroundColor(m_mutableStyle.get()) 951 if (hasTransparentBackgroundColor(m_mutableStyle.get())
952 || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgro undColor).get()) == rgbaBackgroundColorInEffect(position.containerNode())) 952 || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgro undColor).get()) == rgbaBackgroundColorInEffect(position.containerNode()))
953 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); 953 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor);
954 954
955 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { 955 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) {
956 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, static_cast<CSSValue ID>(toCSSPrimitiveValue(unicodeBidi.get())->getIdent())); 956 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue( unicodeBidi.get())->getValueID());
957 if (direction && direction->isPrimitiveValue()) 957 if (direction && direction->isPrimitiveValue())
958 m_mutableStyle->setProperty(CSSPropertyDirection, static_cast<CSSVal ueID>(toCSSPrimitiveValue(direction.get())->getIdent())); 958 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu e(direction.get())->getValueID());
959 } 959 }
960 } 960 }
961 961
962 void EditingStyle::mergeTypingStyle(Document* document) 962 void EditingStyle::mergeTypingStyle(Document* document)
963 { 963 {
964 ASSERT(document); 964 ASSERT(document);
965 965
966 RefPtr<EditingStyle> typingStyle = document->frame()->selection()->typingSty le(); 966 RefPtr<EditingStyle> typingStyle = document->frame()->selection()->typingSty le();
967 if (!typingStyle || typingStyle == this) 967 if (!typingStyle || typingStyle == this)
968 return; 968 return;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 Node* pastLast = Range::create(end.document(), position.parentAnchoredEq uivalent(), end.parentAnchoredEquivalent())->pastLastNode(); 1266 Node* pastLast = Range::create(end.document(), position.parentAnchoredEq uivalent(), end.parentAnchoredEquivalent())->pastLastNode();
1267 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(n)) { 1267 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(n)) {
1268 if (!n->isStyledElement()) 1268 if (!n->isStyledElement())
1269 continue; 1269 continue;
1270 1270
1271 RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclarat ion::create(n); 1271 RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclarat ion::create(n);
1272 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropert yUnicodeBidi); 1272 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropert yUnicodeBidi);
1273 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1273 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1274 continue; 1274 continue;
1275 1275
1276 int unicodeBidiValue = static_cast<CSSPrimitiveValue*>(unicodeBidi.g et())->getIdent(); 1276 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get()) ->getValueID();
1277 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu eBidiOverride) 1277 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu eBidiOverride)
1278 return NaturalWritingDirection; 1278 return NaturalWritingDirection;
1279 } 1279 }
1280 } 1280 }
1281 1281
1282 if (selection.isCaret()) { 1282 if (selection.isCaret()) {
1283 WritingDirection direction; 1283 WritingDirection direction;
1284 if (typingStyle && typingStyle->textDirection(direction)) { 1284 if (typingStyle && typingStyle->textDirection(direction)) {
1285 hasNestedOrMultipleEmbeddings = false; 1285 hasNestedOrMultipleEmbeddings = false;
1286 return direction; 1286 return direction;
1287 } 1287 }
1288 node = selection.visibleStart().deepEquivalent().deprecatedNode(); 1288 node = selection.visibleStart().deepEquivalent().deprecatedNode();
1289 } 1289 }
1290 1290
1291 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position 1291 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position
1292 // to decide. 1292 // to decide.
1293 Node* block = enclosingBlock(node); 1293 Node* block = enclosingBlock(node);
1294 WritingDirection foundDirection = NaturalWritingDirection; 1294 WritingDirection foundDirection = NaturalWritingDirection;
1295 1295
1296 for (; node != block; node = node->parentNode()) { 1296 for (; node != block; node = node->parentNode()) {
1297 if (!node->isStyledElement()) 1297 if (!node->isStyledElement())
1298 continue; 1298 continue;
1299 1299
1300 RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration: :create(node); 1300 RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration: :create(node);
1301 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi); 1301 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi);
1302 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1302 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1303 continue; 1303 continue;
1304 1304
1305 int unicodeBidiValue = static_cast<CSSPrimitiveValue*>(unicodeBidi.get() )->getIdent(); 1305 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge tValueID();
1306 if (unicodeBidiValue == CSSValueNormal) 1306 if (unicodeBidiValue == CSSValueNormal)
1307 continue; 1307 continue;
1308 1308
1309 if (unicodeBidiValue == CSSValueBidiOverride) 1309 if (unicodeBidiValue == CSSValueBidiOverride)
1310 return NaturalWritingDirection; 1310 return NaturalWritingDirection;
1311 1311
1312 ASSERT(unicodeBidiValue == CSSValueEmbed); 1312 ASSERT(unicodeBidiValue == CSSValueEmbed);
1313 RefPtr<CSSValue> direction = style->getPropertyCSSValue(CSSPropertyDirec tion); 1313 RefPtr<CSSValue> direction = style->getPropertyCSSValue(CSSPropertyDirec tion);
1314 if (!direction || !direction->isPrimitiveValue()) 1314 if (!direction || !direction->isPrimitiveValue())
1315 continue; 1315 continue;
1316 1316
1317 int directionValue = static_cast<CSSPrimitiveValue*>(direction.get())->g etIdent(); 1317 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID();
1318 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) 1318 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl)
1319 continue; 1319 continue;
1320 1320
1321 if (foundDirection != NaturalWritingDirection) 1321 if (foundDirection != NaturalWritingDirection)
1322 return NaturalWritingDirection; 1322 return NaturalWritingDirection;
1323 1323
1324 // In the range case, make sure that the embedding element persists unti l the end of the range. 1324 // In the range case, make sure that the embedding element persists unti l the end of the range.
1325 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(node)) 1325 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(node))
1326 return NaturalWritingDirection; 1326 return NaturalWritingDirection;
1327 1327
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 1474
1475 static bool fontWeightIsBold(CSSValue* fontWeight) 1475 static bool fontWeightIsBold(CSSValue* fontWeight)
1476 { 1476 {
1477 if (!fontWeight) 1477 if (!fontWeight)
1478 return false; 1478 return false;
1479 if (!fontWeight->isPrimitiveValue()) 1479 if (!fontWeight->isPrimitiveValue())
1480 return false; 1480 return false;
1481 1481
1482 // Because b tag can only bold text, there are only two states in plain html : bold and not bold. 1482 // Because b tag can only bold text, there are only two states in plain html : bold and not bold.
1483 // Collapse all other values to either one of these two states for editing p urposes. 1483 // Collapse all other values to either one of these two states for editing p urposes.
1484 switch (static_cast<CSSPrimitiveValue*>(fontWeight)->getIdent()) { 1484 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) {
1485 case CSSValue100: 1485 case CSSValue100:
1486 case CSSValue200: 1486 case CSSValue200:
1487 case CSSValue300: 1487 case CSSValue300:
1488 case CSSValue400: 1488 case CSSValue400:
1489 case CSSValue500: 1489 case CSSValue500:
1490 case CSSValueNormal: 1490 case CSSValueNormal:
1491 return false; 1491 return false;
1492 case CSSValueBold: 1492 case CSSValueBold:
1493 case CSSValue600: 1493 case CSSValue600:
1494 case CSSValue700: 1494 case CSSValue700:
1495 case CSSValue800: 1495 case CSSValue800:
1496 case CSSValue900: 1496 case CSSValue900:
1497 return true; 1497 return true;
1498 default:
1499 break;
1498 } 1500 }
1499 1501
1500 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter 1502 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter
1501 return false; 1503 return false;
1502 } 1504 }
1503 1505
1504 static bool fontWeightIsBold(CSSStyleDeclaration* style) 1506 static bool fontWeightIsBold(CSSStyleDeclaration* style)
1505 { 1507 {
1506 ASSERT(style); 1508 ASSERT(style);
1507 RefPtr<CSSValue> fontWeight = style->getPropertyCSSValueInternal(CSSProperty FontWeight); 1509 RefPtr<CSSValue> fontWeight = style->getPropertyCSSValueInternal(CSSProperty FontWeight);
(...skipping 28 matching lines...) Expand all
1536 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) 1538 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign)
1537 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) 1539 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle))
1538 result->removeProperty(CSSPropertyTextAlign); 1540 result->removeProperty(CSSPropertyTextAlign);
1539 1541
1540 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) 1542 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle))
1541 result->removeProperty(CSSPropertyBackgroundColor); 1543 result->removeProperty(CSSPropertyBackgroundColor);
1542 1544
1543 return result.release(); 1545 return result.release();
1544 } 1546 }
1545 1547
1546 int getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) 1548 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
1547 { 1549 {
1548 if (!style) 1550 if (!style)
1549 return 0; 1551 return CSSValueInvalid;
1550 RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); 1552 RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID);
1551 if (!value || !value->isPrimitiveValue()) 1553 if (!value || !value->isPrimitiveValue())
1552 return 0; 1554 return CSSValueInvalid;
1553 return static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); 1555 return toCSSPrimitiveValue(value.get())->getValueID();
1554 } 1556 }
1555 1557
1556 int getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID propertyID) 1558 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ID)
1557 { 1559 {
1558 if (!style) 1560 if (!style)
1559 return 0; 1561 return CSSValueInvalid;
1560 RefPtr<CSSValue> value = style->getPropertyCSSValueInternal(propertyID); 1562 RefPtr<CSSValue> value = style->getPropertyCSSValueInternal(propertyID);
1561 if (!value || !value->isPrimitiveValue()) 1563 if (!value || !value->isPrimitiveValue())
1562 return 0; 1564 return CSSValueInvalid;
1563 return static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); 1565 return toCSSPrimitiveValue(value.get())->getValueID();
1564 } 1566 }
1565 1567
1566 static bool isCSSValueLength(CSSPrimitiveValue* value) 1568 static bool isCSSValueLength(CSSPrimitiveValue* value)
1567 { 1569 {
1568 return value->isFontIndependentLength(); 1570 return value->isFontIndependentLength();
1569 } 1571 }
1570 1572
1571 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo l shouldUseFixedFontDefaultSize, LegacyFontSizeMode mode) 1573 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo l shouldUseFixedFontDefaultSize, LegacyFontSizeMode mode)
1572 { 1574 {
1573 if (isCSSValueLength(value)) { 1575 if (isCSSValueLength(value)) {
1574 int pixelFontSize = value->getIntValue(CSSPrimitiveValue::CSS_PX); 1576 int pixelFontSize = value->getIntValue(CSSPrimitiveValue::CSS_PX);
1575 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, s houldUseFixedFontDefaultSize); 1577 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, s houldUseFixedFontDefaultSize);
1576 // Use legacy font size only if pixel value matches exactly to that of l egacy font size. 1578 // Use legacy font size only if pixel value matches exactly to that of l egacy font size.
1577 int cssPrimitiveEquivalent = legacyFontSize - 1 + CSSValueXSmall; 1579 int cssPrimitiveEquivalent = legacyFontSize - 1 + CSSValueXSmall;
1578 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu ment, cssPrimitiveEquivalent, shouldUseFixedFontDefaultSize) == pixelFontSize) 1580 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu ment, cssPrimitiveEquivalent, shouldUseFixedFontDefaultSize) == pixelFontSize)
1579 return legacyFontSize; 1581 return legacyFontSize;
1580 1582
1581 return 0; 1583 return 0;
1582 } 1584 }
1583 1585
1584 if (CSSValueXSmall <= value->getIdent() && value->getIdent() <= CSSValueWebk itXxxLarge) 1586 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue WebkitXxxLarge)
1585 return value->getIdent() - CSSValueXSmall + 1; 1587 return value->getValueID() - CSSValueXSmall + 1;
1586 1588
1587 return 0; 1589 return 0;
1588 } 1590 }
1589 1591
1590 bool isTransparentColorValue(CSSValue* cssValue) 1592 bool isTransparentColorValue(CSSValue* cssValue)
1591 { 1593 {
1592 if (!cssValue) 1594 if (!cssValue)
1593 return true; 1595 return true;
1594 if (!cssValue->isPrimitiveValue()) 1596 if (!cssValue->isPrimitiveValue())
1595 return false; 1597 return false;
1596 CSSPrimitiveValue* value = static_cast<CSSPrimitiveValue*>(cssValue); 1598 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue);
1597 if (value->isRGBColor()) 1599 if (value->isRGBColor())
1598 return !alphaChannel(value->getRGBA32Value()); 1600 return !alphaChannel(value->getRGBA32Value());
1599 return value->getIdent() == CSSValueTransparent; 1601 return value->getValueID() == CSSValueTransparent;
1600 } 1602 }
1601 1603
1602 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) 1604 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
1603 { 1605 {
1604 RefPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa ckgroundColor); 1606 RefPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa ckgroundColor);
1605 return isTransparentColorValue(cssValue.get()); 1607 return isTransparentColorValue(cssValue.get());
1606 } 1608 }
1607 1609
1608 bool hasTransparentBackgroundColor(StylePropertySet* style) 1610 bool hasTransparentBackgroundColor(StylePropertySet* style)
1609 { 1611 {
1610 RefPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackground Color); 1612 RefPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackground Color);
1611 return isTransparentColorValue(cssValue.get()); 1613 return isTransparentColorValue(cssValue.get());
1612 } 1614 }
1613 1615
1614 PassRefPtr<CSSValue> backgroundColorInEffect(Node* node) 1616 PassRefPtr<CSSValue> backgroundColorInEffect(Node* node)
1615 { 1617 {
1616 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1618 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1617 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); 1619 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor);
1618 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1620 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1619 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1621 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1620 } 1622 }
1621 return 0; 1623 return 0;
1622 } 1624 }
1623 1625
1624 } 1626 }
OLDNEW
« no previous file with comments | « Source/core/editing/EditingStyle.h ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698