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

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

Issue 1249553002: CSSValue Immediates: Add move operators to CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_3_tagged_ptrs_with_copy_ops_mv_operators_ref_primvalue
Patch Set: Rebase Created 5 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/ApplyStyleCommand.cpp ('k') | Source/core/editing/EditorCommand.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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS tyle(PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style, EditingPropertie sType type = OnlyInheritableEditingProperties) 142 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS tyle(PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style, EditingPropertie sType type = OnlyInheritableEditingProperties)
143 { 143 {
144 if (!style) 144 if (!style)
145 return MutableStylePropertySet::create(); 145 return MutableStylePropertySet::create();
146 return copyEditingProperties(style.get(), type); 146 return copyEditingProperties(style.get(), type);
147 } 147 }
148 148
149 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); 149 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
150 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV aluesMatch }; 150 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV aluesMatch };
151 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac yFontSizeMode); 151 static int legacyFontSizeFromCSSValue(Document*, const CSSPrimitiveValue&, bool, LegacyFontSizeMode);
152 static bool isTransparentColorValue(const NullableCSSValue&); 152 static bool isTransparentColorValue(const NullableCSSValue&);
153 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); 153 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
154 static bool hasTransparentBackgroundColor(StylePropertySet*); 154 static bool hasTransparentBackgroundColor(StylePropertySet*);
155 static NullableCSSValue backgroundColorInEffect(Node*); 155 static NullableCSSValue backgroundColorInEffect(Node*);
156 156
157 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu ivalent> { 157 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollectedFinalized<HTMLE lementEquivalent> {
158 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent); 158 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent);
159 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); 159 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent);
160 public: 160 public:
161 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) 161 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName)
162 { 162 {
163 return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiv eValue, tagName)); 163 return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiv eValue, tagName));
164 } 164 }
165 165
166 virtual bool matches(const Element* element) const { return !m_tagName || el ement->hasTagName(*m_tagName); } 166 virtual bool matches(const Element* element) const { return !m_tagName || el ement->hasTagName(*m_tagName); }
167 virtual bool hasAttribute() const { return false; } 167 virtual bool hasAttribute() const { return false; }
168 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re turn style->getPropertyCSSValue(m_propertyID); } 168 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re turn (bool)style->getPropertyCSSValue(m_propertyID); }
169 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const; 169 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const;
170 virtual void addToStyle(Element*, EditingStyle*) const; 170 virtual void addToStyle(Element*, EditingStyle*) const;
171 171
172 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_primitiveValue); } 172 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_primitiveValue); }
173 173
174 protected: 174 protected:
175 HTMLElementEquivalent(CSSPropertyID); 175 HTMLElementEquivalent(CSSPropertyID);
176 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName); 176 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName);
177 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu alifiedName& tagName); 177 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu alifiedName& tagName);
178 const CSSPropertyID m_propertyID; 178 const CSSPropertyID m_propertyID;
179 const RefPtrWillBeMember<CSSPrimitiveValue> m_primitiveValue; 179 const NullableCSSValue m_primitiveValue;
180 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t ag names are const global. 180 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t ag names are const global.
181 }; 181 };
182 182
183 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); 183 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent);
184 184
185 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id) 185 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id)
186 : m_propertyID(id) 186 : m_propertyID(id)
187 , m_tagName(0) 187 , m_tagName(0)
188 { 188 {
189 } 189 }
190 190
191 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi edName& tagName) 191 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi edName& tagName)
192 : m_propertyID(id) 192 : m_propertyID(id)
193 , m_tagName(&tagName) 193 , m_tagName(&tagName)
194 { 194 {
195 } 195 }
196 196
197 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit iveValue, const HTMLQualifiedName& tagName) 197 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit iveValue, const HTMLQualifiedName& tagName)
198 : m_propertyID(id) 198 : m_propertyID(id)
199 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) 199 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue))
200 , m_tagName(&tagName) 200 , m_tagName(&tagName)
201 { 201 {
202 ASSERT(primitiveValue != CSSValueInvalid); 202 ASSERT(primitiveValue != CSSValueInvalid);
203 } 203 }
204 204
205 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro pertySet* style) const 205 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro pertySet* style) const
206 { 206 {
207 NullableCSSValue value = style->getPropertyCSSValue(m_propertyID); 207 const NullableCSSValue &value = style->getPropertyCSSValue(m_propertyID);
208 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit iveValue(value)->getValueID() == m_primitiveValue->getValueID(); 208 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit iveValue(value).getValueID() == toCSSPrimitiveValue(m_primitiveValue).getValueID ();
209 } 209 }
210 210
211 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const 211 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const
212 { 212 {
213 style->setProperty(m_propertyID, m_primitiveValue->cssText()); 213 style->setProperty(m_propertyID, m_primitiveValue->cssText());
214 } 214 }
215 215
216 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { 216 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent {
217 public: 217 public:
218 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSValueID primi tiveValue, const HTMLQualifiedName& tagName) 218 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSValueID primi tiveValue, const HTMLQualifiedName& tagName)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 256 }
257 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName) 257 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName)
258 { 258 {
259 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, attrNa me)); 259 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, attrNa me));
260 } 260 }
261 261
262 bool matches(const Element* element) const override { return HTMLElementEqui valent::matches(element) && element->hasAttribute(m_attrName); } 262 bool matches(const Element* element) const override { return HTMLElementEqui valent::matches(element) && element->hasAttribute(m_attrName); }
263 bool hasAttribute() const override { return true; } 263 bool hasAttribute() const override { return true; }
264 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override; 264 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override;
265 void addToStyle(Element*, EditingStyle*) const override; 265 void addToStyle(Element*, EditingStyle*) const override;
266 virtual NullableCSSValue attributeValueAsCSSValue(Element*) const; 266 virtual const NullableCSSValue attributeValueAsCSSValue(Element*) const;
267 inline const QualifiedName& attributeName() const { return m_attrName; } 267 inline const QualifiedName& attributeName() const { return m_attrName; }
268 268
269 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); } 269 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); }
270 270
271 protected: 271 protected:
272 HTMLAttributeEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName, con st QualifiedName& attrName); 272 HTMLAttributeEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName, con st QualifiedName& attrName);
273 HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& attrName); 273 HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& attrName);
274 const QualifiedName& m_attrName; // We can store a reference because HTML at tribute names are const global. 274 const QualifiedName& m_attrName; // We can store a reference because HTML at tribute names are const global.
275 }; 275 };
276 276
277 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const HTMLQua lifiedName& tagName, const QualifiedName& attrName) 277 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const HTMLQua lifiedName& tagName, const QualifiedName& attrName)
278 : HTMLElementEquivalent(id, tagName) 278 : HTMLElementEquivalent(id, tagName)
279 , m_attrName(attrName) 279 , m_attrName(attrName)
280 { 280 {
281 } 281 }
282 282
283 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi edName& attrName) 283 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi edName& attrName)
284 : HTMLElementEquivalent(id) 284 : HTMLElementEquivalent(id)
285 , m_attrName(attrName) 285 , m_attrName(attrName)
286 { 286 {
287 } 287 }
288 288
289 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP ropertySet* style) const 289 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP ropertySet* style) const
290 { 290 {
291 NullableCSSValue value = attributeValueAsCSSValue(element); 291 const NullableCSSValue& value = attributeValueAsCSSValue(element);
292 NullableCSSValue styleValue = style->getPropertyCSSValue(m_propertyID); 292 const NullableCSSValue& styleValue = style->getPropertyCSSValue(m_propertyID );
293 293
294 return value == styleValue; 294 return value == styleValue;
295 } 295 }
296 296
297 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style) const 297 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style) const
298 { 298 {
299 if (NullableCSSValue value = attributeValueAsCSSValue(element)) 299 if (NullableCSSValue value = attributeValueAsCSSValue(element))
300 style->setProperty(m_propertyID, value->cssText()); 300 style->setProperty(m_propertyID, value->cssText());
301 } 301 }
302 302
303 NullableCSSValue HTMLAttributeEquivalent::attributeValueAsCSSValue(Element* elem ent) const 303 const NullableCSSValue HTMLAttributeEquivalent::attributeValueAsCSSValue(Element * element) const
304 { 304 {
305 ASSERT(element); 305 ASSERT(element);
306 const AtomicString& value = element->getAttribute(m_attrName); 306 const AtomicString& value = element->getAttribute(m_attrName);
307 if (value.isNull()) 307 if (value.isNull())
308 return nullptr; 308 return nullptr;
309 309
310 RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = nullptr; 310 RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = nullptr;
311 dummyStyle = MutableStylePropertySet::create(); 311 dummyStyle = MutableStylePropertySet::create();
312 dummyStyle->setProperty(m_propertyID, value); 312 dummyStyle->setProperty(m_propertyID, value);
313 return dummyStyle->getPropertyCSSValue(m_propertyID); 313 return dummyStyle->getPropertyCSSValue(m_propertyID);
314 } 314 }
315 315
316 class HTMLFontSizeEquivalent final : public HTMLAttributeEquivalent { 316 class HTMLFontSizeEquivalent final : public HTMLAttributeEquivalent {
317 public: 317 public:
318 static PassOwnPtrWillBeRawPtr<HTMLFontSizeEquivalent> create() 318 static PassOwnPtrWillBeRawPtr<HTMLFontSizeEquivalent> create()
319 { 319 {
320 return adoptPtrWillBeNoop(new HTMLFontSizeEquivalent()); 320 return adoptPtrWillBeNoop(new HTMLFontSizeEquivalent());
321 } 321 }
322 NullableCSSValue attributeValueAsCSSValue(Element*) const override; 322 const NullableCSSValue attributeValueAsCSSValue(Element*) const override;
323 323
324 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); } 324 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); }
325 325
326 private: 326 private:
327 HTMLFontSizeEquivalent(); 327 HTMLFontSizeEquivalent();
328 }; 328 };
329 329
330 HTMLFontSizeEquivalent::HTMLFontSizeEquivalent() 330 HTMLFontSizeEquivalent::HTMLFontSizeEquivalent()
331 : HTMLAttributeEquivalent(CSSPropertyFontSize, HTMLNames::fontTag, HTMLNames ::sizeAttr) 331 : HTMLAttributeEquivalent(CSSPropertyFontSize, HTMLNames::fontTag, HTMLNames ::sizeAttr)
332 { 332 {
333 } 333 }
334 334
335 NullableCSSValue HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* eleme nt) const 335 const NullableCSSValue HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* element) const
336 { 336 {
337 ASSERT(element); 337 ASSERT(element);
338 const AtomicString& value = element->getAttribute(m_attrName); 338 const AtomicString& value = element->getAttribute(m_attrName);
339 if (value.isNull()) 339 if (value.isNull())
340 return nullptr; 340 return nullptr;
341 CSSValueID size; 341 CSSValueID size;
342 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) 342 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size))
343 return nullptr; 343 return nullptr;
344 return CSSPrimitiveValue::createIdentifier(size); 344 return CSSPrimitiveValue::createIdentifier(size);
345 } 345 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 EditingStyle::~EditingStyle() 385 EditingStyle::~EditingStyle()
386 { 386 {
387 } 387 }
388 388
389 static RGBA32 cssValueToRGBA(NullableCSSValue colorValue) 389 static RGBA32 cssValueToRGBA(NullableCSSValue colorValue)
390 { 390 {
391 if (!colorValue || !colorValue->isPrimitiveValue()) 391 if (!colorValue || !colorValue->isPrimitiveValue())
392 return Color::transparent; 392 return Color::transparent;
393 393
394 CSSPrimitiveValue* primitiveColor = toCSSPrimitiveValue(colorValue); 394 const CSSPrimitiveValue& primitiveColor = toCSSPrimitiveValue(colorValue);
395 if (primitiveColor->isRGBColor()) 395 if (primitiveColor.isRGBColor())
396 return primitiveColor->getRGBA32Value(); 396 return primitiveColor.getRGBA32Value();
397 397
398 RGBA32 rgba = 0; 398 RGBA32 rgba = 0;
399 // FIXME: Why ignore the return value? 399 // FIXME: Why ignore the return value?
400 CSSParser::parseColor(rgba, colorValue->cssText()); 400 CSSParser::parseColor(rgba, colorValue->cssText());
401 return rgba; 401 return rgba;
402 } 402 }
403 403
404 static inline RGBA32 getRGBAFontColor(CSSStyleDeclaration* style) 404 static inline RGBA32 getRGBAFontColor(CSSStyleDeclaration* style)
405 { 405 {
406 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor)); 406 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 if (!m_mutableStyle) 512 if (!m_mutableStyle)
513 return; 513 return;
514 514
515 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) { 515 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) {
516 // Explicit font size overrides any delta. 516 // Explicit font size overrides any delta.
517 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); 517 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
518 return; 518 return;
519 } 519 }
520 520
521 // Get the adjustment amount out of the style. 521 // Get the adjustment amount out of the style.
522 NullableCSSValue value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebk itFontSizeDelta); 522 const NullableCSSValue& value = m_mutableStyle->getPropertyCSSValue(CSSPrope rtyWebkitFontSizeDelta);
523 if (!value || !value->isPrimitiveValue()) 523 if (!value || !value->isPrimitiveValue())
524 return; 524 return;
525 525
526 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 526 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
527 527
528 // Only PX handled now. If we handle more types in the future, perhaps 528 // Only PX handled now. If we handle more types in the future, perhaps
529 // a switch statement here would be more appropriate. 529 // a switch statement here would be more appropriate.
530 if (!primitiveValue->isPx()) 530 if (!primitiveValue.isPx())
531 return; 531 return;
532 532
533 m_fontSizeDelta = primitiveValue->getFloatValue(); 533 m_fontSizeDelta = primitiveValue.getFloatValue();
534 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); 534 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
535 } 535 }
536 536
537 bool EditingStyle::isEmpty() const 537 bool EditingStyle::isEmpty() const
538 { 538 {
539 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta == NoFontDelta; 539 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta == NoFontDelta;
540 } 540 }
541 541
542 bool EditingStyle::textDirection(WritingDirection& writingDirection) const 542 bool EditingStyle::textDirection(WritingDirection& writingDirection) const
543 { 543 {
544 if (!m_mutableStyle) 544 if (!m_mutableStyle)
545 return false; 545 return false;
546 546
547 NullableCSSValue unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSProper tyUnicodeBidi); 547 const NullableCSSValue& unicodeBidi = m_mutableStyle->getPropertyCSSValue(CS SPropertyUnicodeBidi);
548 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 548 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
549 return false; 549 return false;
550 550
551 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID() ; 551 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi).getValueID();
552 if (unicodeBidiValue == CSSValueEmbed) { 552 if (unicodeBidiValue == CSSValueEmbed) {
553 NullableCSSValue direction = m_mutableStyle->getPropertyCSSValue(CSSProp ertyDirection); 553 const NullableCSSValue& direction = m_mutableStyle->getPropertyCSSValue( CSSPropertyDirection);
554 if (!direction || !direction->isPrimitiveValue()) 554 if (!direction || !direction->isPrimitiveValue())
555 return false; 555 return false;
556 556
557 writingDirection = toCSSPrimitiveValue(direction)->getValueID() == CSSVa lueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; 557 writingDirection = toCSSPrimitiveValue(direction).getValueID() == CSSVal ueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
558 558
559 return true; 559 return true;
560 } 560 }
561 561
562 if (unicodeBidiValue == CSSValueNormal) { 562 if (unicodeBidiValue == CSSValueNormal) {
563 writingDirection = NaturalWritingDirection; 563 writingDirection = NaturalWritingDirection;
564 return true; 564 return true;
565 } 565 }
566 566
567 return false; 567 return false;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 unsigned propertyCount = nodeStyle->propertyCount(); 681 unsigned propertyCount = nodeStyle->propertyCount();
682 for (unsigned i = 0; i < propertyCount; ++i) 682 for (unsigned i = 0; i < propertyCount; ++i)
683 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); 683 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id());
684 } 684 }
685 685
686 void EditingStyle::collapseTextDecorationProperties() 686 void EditingStyle::collapseTextDecorationProperties()
687 { 687 {
688 if (!m_mutableStyle) 688 if (!m_mutableStyle)
689 return; 689 return;
690 690
691 NullableCSSValue textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect); 691 const NullableCSSValue& textDecorationsInEffect = m_mutableStyle->getPropert yCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
692 if (!textDecorationsInEffect) 692 if (!textDecorationsInEffect)
693 return; 693 return;
694 694
695 if (textDecorationsInEffect->isValueList()) 695 if (textDecorationsInEffect->isValueList())
696 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr opertyForEditing())); 696 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr opertyForEditing()));
697 else 697 else
698 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); 698 m_mutableStyle->removeProperty(textDecorationPropertyForEditing());
699 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 699 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
700 } 700 }
701 701
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 m_mutableStyle->removeProperty(CSSPropertyTextAlign); 998 m_mutableStyle->removeProperty(CSSPropertyTextAlign);
999 999
1000 if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(styleAtPositi on)) 1000 if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(styleAtPositi on))
1001 m_mutableStyle->removeProperty(CSSPropertyColor); 1001 m_mutableStyle->removeProperty(CSSPropertyColor);
1002 1002
1003 if (hasTransparentBackgroundColor(m_mutableStyle.get()) 1003 if (hasTransparentBackgroundColor(m_mutableStyle.get())
1004 || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgro undColor)) == rgbaBackgroundColorInEffect(position.containerNode())) 1004 || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgro undColor)) == rgbaBackgroundColorInEffect(position.containerNode()))
1005 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); 1005 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor);
1006 1006
1007 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { 1007 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) {
1008 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue( unicodeBidi)->getValueID()); 1008 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue( unicodeBidi).getValueID());
1009 if (direction && direction->isPrimitiveValue()) 1009 if (direction && direction->isPrimitiveValue())
1010 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu e(direction)->getValueID()); 1010 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu e(direction).getValueID());
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 void EditingStyle::mergeTypingStyle(Document* document) 1014 void EditingStyle::mergeTypingStyle(Document* document)
1015 { 1015 {
1016 ASSERT(document); 1016 ASSERT(document);
1017 1017
1018 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document->frame()->selection( ).typingStyle(); 1018 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document->frame()->selection( ).typingStyle();
1019 if (!typingStyle || typingStyle == this) 1019 if (!typingStyle || typingStyle == this)
1020 return; 1020 return;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues, 1117 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues,
1118 EditingStyle::EditingPropertiesInEffect); 1118 EditingStyle::EditingPropertiesInEffect);
1119 } 1119 }
1120 } 1120 }
1121 1121
1122 return wrappingStyle.release(); 1122 return wrappingStyle.release();
1123 } 1123 }
1124 1124
1125 static void mergeTextDecorationValues(CSSValueList& mergedValue, const CSSValueL ist& valueToMerge) 1125 static void mergeTextDecorationValues(CSSValueList& mergedValue, const CSSValueL ist& valueToMerge)
1126 { 1126 {
1127 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimi tiveValue::createIdentifier(CSSValueUnderline))); 1127 CSSPrimitiveValue underline = CSSPrimitiveValue::createIdentifier(CSSValueUn derline);
1128 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPri mitiveValue::createIdentifier(CSSValueLineThrough))); 1128 CSSPrimitiveValue lineThrough = CSSPrimitiveValue::createIdentifier(CSSValue LineThrough);
1129 1129
1130 if (valueToMerge.hasValue(CSSValue(*underline)) && !mergedValue.hasValue(CSS Value(*underline))) 1130 if (valueToMerge.hasValue(underline) && !mergedValue.hasValue(underline))
1131 mergedValue.append(CSSValue(*underline)); 1131 mergedValue.append(underline);
1132 1132
1133 if (valueToMerge.hasValue(CSSValue(*lineThrough)) && !mergedValue.hasValue(C SSValue(*lineThrough))) 1133 if (valueToMerge.hasValue(lineThrough) && !mergedValue.hasValue(lineThrough) )
1134 mergedValue.append(CSSValue(*lineThrough)); 1134 mergedValue.append(lineThrough);
1135 } 1135 }
1136 1136
1137 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride Mode mode) 1137 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride Mode mode)
1138 { 1138 {
1139 if (!style) 1139 if (!style)
1140 return; 1140 return;
1141 1141
1142 if (!m_mutableStyle) { 1142 if (!m_mutableStyle) {
1143 m_mutableStyle = style->mutableCopy(); 1143 m_mutableStyle = style->mutableCopy();
1144 return; 1144 return;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 void EditingStyle::forceInline() 1291 void EditingStyle::forceInline()
1292 { 1292 {
1293 if (!m_mutableStyle) 1293 if (!m_mutableStyle)
1294 m_mutableStyle = MutableStylePropertySet::create(); 1294 m_mutableStyle = MutableStylePropertySet::create();
1295 const bool propertyIsImportant = true; 1295 const bool propertyIsImportant = true;
1296 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant); 1296 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant);
1297 } 1297 }
1298 1298
1299 int EditingStyle::legacyFontSize(Document* document) const 1299 int EditingStyle::legacyFontSize(Document* document) const
1300 { 1300 {
1301 NullableCSSValue cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyF ontSize); 1301 const NullableCSSValue& cssValue = m_mutableStyle->getPropertyCSSValue(CSSPr opertyFontSize);
1302 if (!cssValue || !cssValue->isPrimitiveValue()) 1302 if (!cssValue || !cssValue->isPrimitiveValue())
1303 return 0; 1303 return 0;
1304 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue), 1304 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue),
1305 m_isMonospaceFont, AlwaysUseLegacyFontSize); 1305 m_isMonospaceFont, AlwaysUseLegacyFontSize);
1306 } 1306 }
1307 1307
1308 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V isibleSelection& selection, bool shouldUseBackgroundColorInEffect) 1308 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V isibleSelection& selection, bool shouldUseBackgroundColorInEffect)
1309 { 1309 {
1310 if (selection.isNone()) 1310 if (selection.isNone())
1311 return nullptr; 1311 return nullptr;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); 1360 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE quivalent(), end.parentAnchoredEquivalent())->pastLastNode();
1361 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { 1361 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) {
1362 if (!n->isStyledElement()) 1362 if (!n->isStyledElement())
1363 continue; 1363 continue;
1364 1364
1365 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS tyleDeclaration::create(n); 1365 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS tyleDeclaration::create(n);
1366 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropert yUnicodeBidi); 1366 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropert yUnicodeBidi);
1367 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1367 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1368 continue; 1368 continue;
1369 1369
1370 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getV alueID(); 1370 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi).getVa lueID();
1371 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu eBidiOverride) 1371 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu eBidiOverride)
1372 return NaturalWritingDirection; 1372 return NaturalWritingDirection;
1373 } 1373 }
1374 } 1374 }
1375 1375
1376 if (selection.isCaret()) { 1376 if (selection.isCaret()) {
1377 WritingDirection direction; 1377 WritingDirection direction;
1378 if (typingStyle && typingStyle->textDirection(direction)) { 1378 if (typingStyle && typingStyle->textDirection(direction)) {
1379 hasNestedOrMultipleEmbeddings = false; 1379 hasNestedOrMultipleEmbeddings = false;
1380 return direction; 1380 return direction;
1381 } 1381 }
1382 node = selection.visibleStart().deepEquivalent().deprecatedNode(); 1382 node = selection.visibleStart().deepEquivalent().deprecatedNode();
1383 } 1383 }
1384 1384
1385 // 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 1385 // 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
1386 // to decide. 1386 // to decide.
1387 Node* block = enclosingBlock(node); 1387 Node* block = enclosingBlock(node);
1388 WritingDirection foundDirection = NaturalWritingDirection; 1388 WritingDirection foundDirection = NaturalWritingDirection;
1389 1389
1390 for (; node != block; node = node->parentNode()) { 1390 for (; node != block; node = node->parentNode()) {
1391 if (!node->isStyledElement()) 1391 if (!node->isStyledElement())
1392 continue; 1392 continue;
1393 1393
1394 Element* element = toElement(node); 1394 Element* element = toElement(node);
1395 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle Declaration::create(element); 1395 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle Declaration::create(element);
1396 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi); 1396 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi);
1397 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1397 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1398 continue; 1398 continue;
1399 1399
1400 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue ID(); 1400 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi).getValueI D();
1401 if (unicodeBidiValue == CSSValueNormal) 1401 if (unicodeBidiValue == CSSValueNormal)
1402 continue; 1402 continue;
1403 1403
1404 if (unicodeBidiValue == CSSValueBidiOverride) 1404 if (unicodeBidiValue == CSSValueBidiOverride)
1405 return NaturalWritingDirection; 1405 return NaturalWritingDirection;
1406 1406
1407 ASSERT(unicodeBidiValue == CSSValueEmbed); 1407 ASSERT(unicodeBidiValue == CSSValueEmbed);
1408 NullableCSSValue direction = style->getPropertyCSSValue(CSSPropertyDirec tion); 1408 NullableCSSValue direction = style->getPropertyCSSValue(CSSPropertyDirec tion);
1409 if (!direction || !direction->isPrimitiveValue()) 1409 if (!direction || !direction->isPrimitiveValue())
1410 continue; 1410 continue;
1411 1411
1412 int directionValue = toCSSPrimitiveValue(direction)->getValueID(); 1412 int directionValue = toCSSPrimitiveValue(direction).getValueID();
1413 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) 1413 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl)
1414 continue; 1414 continue;
1415 1415
1416 if (foundDirection != NaturalWritingDirection) 1416 if (foundDirection != NaturalWritingDirection)
1417 return NaturalWritingDirection; 1417 return NaturalWritingDirection;
1418 1418
1419 // In the range case, make sure that the embedding element persists unti l the end of the range. 1419 // In the range case, make sure that the embedding element persists unti l the end of the range.
1420 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(element )) 1420 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(element ))
1421 return NaturalWritingDirection; 1421 return NaturalWritingDirection;
1422 1422
1423 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; 1423 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection;
1424 } 1424 }
1425 hasNestedOrMultipleEmbeddings = false; 1425 hasNestedOrMultipleEmbeddings = false;
1426 return foundDirection; 1426 return foundDirection;
1427 } 1427 }
1428 1428
1429 DEFINE_TRACE(EditingStyle) 1429 DEFINE_TRACE(EditingStyle)
1430 { 1430 {
1431 visitor->trace(m_mutableStyle); 1431 visitor->trace(m_mutableStyle);
1432 } 1432 }
1433 1433
1434 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) 1434 static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
1435 { 1435 {
1436 NullableCSSValue textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect); 1436 const NullableCSSValue& textDecorationsInEffect = style->getPropertyCSSValue (CSSPropertyWebkitTextDecorationsInEffect);
1437 NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationP ropertyForEditing()); 1437 NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationP ropertyForEditing());
1438 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense. 1438 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense.
1439 ASSERT(!textDecorationsInEffect || !textDecoration); 1439 ASSERT(!textDecorationsInEffect || !textDecoration);
1440 if (textDecorationsInEffect) { 1440 if (textDecorationsInEffect) {
1441 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn Effect->cssText()); 1441 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn Effect->cssText());
1442 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 1442 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
1443 textDecoration = textDecorationsInEffect; 1443 textDecoration = textDecorationsInEffect;
1444 } 1444 }
1445 1445
1446 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". 1446 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none".
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 } 1502 }
1503 1503
1504 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); 1504 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle);
1505 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { 1505 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) {
1506 style->removeProperty(CSSPropertyFontStyle); 1506 style->removeProperty(CSSPropertyFontStyle);
1507 m_applyItalic = true; 1507 m_applyItalic = true;
1508 } 1508 }
1509 1509
1510 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect 1510 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect
1511 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList. 1511 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList.
1512 NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationP ropertyForEditing()); 1512 const NullableCSSValue& textDecoration = style->getPropertyCSSValue(textDeco rationPropertyForEditing());
1513 if (textDecoration && textDecoration->isValueList()) { 1513 if (textDecoration && textDecoration->isValueList()) {
1514 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP rimitiveValue::createIdentifier(CSSValueUnderline))); 1514 CSSPrimitiveValue underline = CSSPrimitiveValue::createIdentifier(CSSVal ueUnderline);
1515 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS SPrimitiveValue::createIdentifier(CSSValueLineThrough))); 1515 CSSPrimitiveValue lineThrough = CSSPrimitiveValue::createIdentifier(CSSV alueLineThrough);
1516 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text Decoration)->copy(); 1516 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text Decoration)->copy();
1517 if (newTextDecoration->removeAll(CSSValue(*underline))) 1517 if (newTextDecoration->removeAll(underline))
1518 m_applyUnderline = true; 1518 m_applyUnderline = true;
1519 if (newTextDecoration->removeAll(CSSValue(*lineThrough))) 1519 if (newTextDecoration->removeAll(lineThrough))
1520 m_applyLineThrough = true; 1520 m_applyLineThrough = true;
1521 1521
1522 // If trimTextDecorations, delete underline and line-through 1522 // If trimTextDecorations, delete underline and line-through
1523 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration PropertyForEditing()); 1523 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration PropertyForEditing());
1524 } 1524 }
1525 1525
1526 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); 1526 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign);
1527 switch (verticalAlign) { 1527 switch (verticalAlign) {
1528 case CSSValueSub: 1528 case CSSValueSub:
1529 style->removeProperty(CSSPropertyVerticalAlign); 1529 style->removeProperty(CSSPropertyVerticalAlign);
1530 m_applySubscript = true; 1530 m_applySubscript = true;
1531 break; 1531 break;
1532 case CSSValueSuper: 1532 case CSSValueSuper:
1533 style->removeProperty(CSSPropertyVerticalAlign); 1533 style->removeProperty(CSSPropertyVerticalAlign);
1534 m_applySuperscript = true; 1534 m_applySuperscript = true;
1535 break; 1535 break;
1536 } 1536 }
1537 1537
1538 if (style->getPropertyCSSValue(CSSPropertyColor)) { 1538 if (style->getPropertyCSSValue(CSSPropertyColor)) {
1539 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); 1539 m_applyFontColor = Color(getRGBAFontColor(style)).serialized();
1540 style->removeProperty(CSSPropertyColor); 1540 style->removeProperty(CSSPropertyColor);
1541 } 1541 }
1542 1542
1543 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); 1543 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily);
1544 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web kit.org/show_bug.cgi?id=79448 1544 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web kit.org/show_bug.cgi?id=79448
1545 m_applyFontFace.replaceWithLiteral('\'', ""); 1545 m_applyFontFace.replaceWithLiteral('\'', "");
1546 style->removeProperty(CSSPropertyFontFamily); 1546 style->removeProperty(CSSPropertyFontFamily);
1547 1547
1548 if (NullableCSSValue fontSize = style->getPropertyCSSValue(CSSPropertyFontSi ze)) { 1548 if (const NullableCSSValue& fontSize = style->getPropertyCSSValue(CSSPropert yFontSize)) {
1549 if (!fontSize->isPrimitiveValue()) { 1549 if (!fontSize->isPrimitiveValue()) {
1550 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t he number. Put no font size. 1550 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t he number. Put no font size.
1551 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC SSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesM atch)) { 1551 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC SSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesM atch)) {
1552 m_applyFontSize = String::number(legacyFontSize); 1552 m_applyFontSize = String::number(legacyFontSize);
1553 style->removeProperty(CSSPropertyFontSize); 1553 style->removeProperty(CSSPropertyFontSize);
1554 } 1554 }
1555 } 1555 }
1556 } 1556 }
1557 1557
1558 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr opertyID, NullableCSSValue refTextDecoration) 1558 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr opertyID, NullableCSSValue refTextDecoration)
1559 { 1559 {
1560 NullableCSSValue textDecoration = style->getPropertyCSSValue(propertyID); 1560 const NullableCSSValue& textDecoration = style->getPropertyCSSValue(property ID);
1561 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList()) 1561 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
1562 return; 1562 return;
1563 1563
1564 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco ration)->copy(); 1564 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco ration)->copy();
1565 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); 1565 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
1566 1566
1567 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) 1567 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++)
1568 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); 1568 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i));
1569 1569
1570 setTextDecorationProperty(style, newTextDecoration.get(), propertyID); 1570 setTextDecorationProperty(style, newTextDecoration.get(), propertyID);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 ASSERT(baseStyle); 1614 ASSERT(baseStyle);
1615 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope rties->mutableCopy(); 1615 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope rties->mutableCopy();
1616 1616
1617 result->removeEquivalentProperties(baseStyle); 1617 result->removeEquivalentProperties(baseStyle);
1618 1618
1619 NullableCSSValue baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); 1619 NullableCSSValue baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect);
1620 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect); 1620 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect);
1621 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect); 1621 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect);
1622 1622
1623 if (NullableCSSValue baseFontWeight = baseStyle->getPropertyCSSValueInternal (CSSPropertyFontWeight)) { 1623 if (NullableCSSValue baseFontWeight = baseStyle->getPropertyCSSValueInternal (CSSPropertyFontWeight)) {
1624 if (NullableCSSValue fontWeight = result->getPropertyCSSValue(CSSPropert yFontWeight)) { 1624 if (const NullableCSSValue& fontWeight = result->getPropertyCSSValue(CSS PropertyFontWeight)) {
1625 if (!fontWeightNeedsResolving(*fontWeight) && (fontWeightIsBold(*fon tWeight) == fontWeightIsBold(*baseFontWeight))) 1625 if (!fontWeightNeedsResolving(*fontWeight) && (fontWeightIsBold(*fon tWeight) == fontWeightIsBold(*baseFontWeight)))
1626 result->removeProperty(CSSPropertyFontWeight); 1626 result->removeProperty(CSSPropertyFontWeight);
1627 } 1627 }
1628 } 1628 }
1629 1629
1630 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) 1630 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle))
1631 result->removeProperty(CSSPropertyColor); 1631 result->removeProperty(CSSPropertyColor);
1632 1632
1633 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) 1633 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign)
1634 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) 1634 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle))
1635 result->removeProperty(CSSPropertyTextAlign); 1635 result->removeProperty(CSSPropertyTextAlign);
1636 1636
1637 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) 1637 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle))
1638 result->removeProperty(CSSPropertyBackgroundColor); 1638 result->removeProperty(CSSPropertyBackgroundColor);
1639 1639
1640 return result.release(); 1640 return result.release();
1641 } 1641 }
1642 1642
1643 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) 1643 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
1644 { 1644 {
1645 if (!style) 1645 if (!style)
1646 return CSSValueInvalid; 1646 return CSSValueInvalid;
1647 NullableCSSValue value = style->getPropertyCSSValue(propertyID); 1647 const NullableCSSValue& value = style->getPropertyCSSValue(propertyID);
1648 if (!value || !value->isPrimitiveValue()) 1648 if (!value || !value->isPrimitiveValue())
1649 return CSSValueInvalid; 1649 return CSSValueInvalid;
1650 return toCSSPrimitiveValue(value)->getValueID(); 1650 return toCSSPrimitiveValue(value).getValueID();
1651 } 1651 }
1652 1652
1653 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ID) 1653 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ID)
1654 { 1654 {
1655 if (!style) 1655 if (!style)
1656 return CSSValueInvalid; 1656 return CSSValueInvalid;
1657 NullableCSSValue value = style->getPropertyCSSValueInternal(propertyID); 1657 NullableCSSValue value = style->getPropertyCSSValueInternal(propertyID);
1658 if (!value || !value->isPrimitiveValue()) 1658 if (!value || !value->isPrimitiveValue())
1659 return CSSValueInvalid; 1659 return CSSValueInvalid;
1660 return toCSSPrimitiveValue(value)->getValueID(); 1660 return toCSSPrimitiveValue(value).getValueID();
1661 } 1661 }
1662 1662
1663 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo l isMonospaceFont, LegacyFontSizeMode mode) 1663 int legacyFontSizeFromCSSValue(Document* document, const CSSPrimitiveValue& valu e, bool isMonospaceFont, LegacyFontSizeMode mode)
1664 { 1664 {
1665 CSSPrimitiveValue::LengthUnitType lengthType; 1665 CSSPrimitiveValue::LengthUnitType lengthType;
1666 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->primitiveType(), leng thType) 1666 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value.primitiveType(), lengt hType)
1667 && lengthType == CSSPrimitiveValue::UnitTypePixels) { 1667 && lengthType == CSSPrimitiveValue::UnitTypePixels) {
1668 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa ctor(value->primitiveType()); 1668 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa ctor(value.primitiveType());
1669 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion); 1669 int pixelFontSize = clampTo<int>(value.getDoubleValue() * conversion);
1670 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i sMonospaceFont); 1670 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i sMonospaceFont);
1671 // Use legacy font size only if pixel value matches exactly to that of l egacy font size. 1671 // Use legacy font size only if pixel value matches exactly to that of l egacy font size.
1672 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu ment, legacyFontSize, isMonospaceFont) == pixelFontSize) 1672 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu ment, legacyFontSize, isMonospaceFont) == pixelFontSize)
1673 return legacyFontSize; 1673 return legacyFontSize;
1674 1674
1675 return 0; 1675 return 0;
1676 } 1676 }
1677 1677
1678 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue WebkitXxxLarge) 1678 if (CSSValueXSmall <= value.getValueID() && value.getValueID() <= CSSValueWe bkitXxxLarge)
1679 return value->getValueID() - CSSValueXSmall + 1; 1679 return value.getValueID() - CSSValueXSmall + 1;
1680 1680
1681 return 0; 1681 return 0;
1682 } 1682 }
1683 1683
1684 bool isTransparentColorValue(const NullableCSSValue& cssValue) 1684 bool isTransparentColorValue(const NullableCSSValue& cssValue)
1685 { 1685 {
1686 if (!cssValue) 1686 if (!cssValue)
1687 return true; 1687 return true;
1688 if (!cssValue->isPrimitiveValue()) 1688 if (!cssValue->isPrimitiveValue())
1689 return false; 1689 return false;
1690 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); 1690 const CSSPrimitiveValue& value = toCSSPrimitiveValue(cssValue);
1691 if (value->isRGBColor()) 1691 if (value.isRGBColor())
1692 return !alphaChannel(value->getRGBA32Value()); 1692 return !alphaChannel(value.getRGBA32Value());
1693 return value->getValueID() == CSSValueTransparent; 1693 return value.getValueID() == CSSValueTransparent;
1694 } 1694 }
1695 1695
1696 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) 1696 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
1697 { 1697 {
1698 NullableCSSValue cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa ckgroundColor); 1698 NullableCSSValue cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa ckgroundColor);
1699 return isTransparentColorValue(cssValue); 1699 return isTransparentColorValue(cssValue);
1700 } 1700 }
1701 1701
1702 bool hasTransparentBackgroundColor(StylePropertySet* style) 1702 bool hasTransparentBackgroundColor(StylePropertySet* style)
1703 { 1703 {
1704 NullableCSSValue cssValue = style->getPropertyCSSValue(CSSPropertyBackground Color); 1704 const NullableCSSValue& cssValue = style->getPropertyCSSValue(CSSPropertyBac kgroundColor);
1705 return isTransparentColorValue(cssValue); 1705 return isTransparentColorValue(cssValue);
1706 } 1706 }
1707 1707
1708 NullableCSSValue backgroundColorInEffect(Node* node) 1708 NullableCSSValue backgroundColorInEffect(Node* node)
1709 { 1709 {
1710 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1710 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1711 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); 1711 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor);
1712 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1712 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1713 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1713 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1714 } 1714 }
1715 return nullptr; 1715 return nullptr;
1716 } 1716 }
1717 1717
1718 } 1718 }
OLDNEW
« no previous file with comments | « Source/core/editing/ApplyStyleCommand.cpp ('k') | Source/core/editing/EditorCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698