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

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

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: (Hopefully) Builds with oilpan now Created 5 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
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
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*, CSSPrimitiveValue*, bool, Legac yFontSizeMode);
152 static bool isTransparentColorValue(CSSValue*); 152 static bool isTransparentColorValue(NullableCSSValue);
153 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); 153 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
154 static bool hasTransparentBackgroundColor(StylePropertySet*); 154 static bool hasTransparentBackgroundColor(StylePropertySet*);
155 static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node*); 155 static NullableCSSValue backgroundColorInEffect(Node*);
156 156
157 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu ivalent> { 157 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu ivalent> {
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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID ); 207 NullableCSSValue value = style->getPropertyCSSValue(m_propertyID);
208 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit iveValue(value.get())->getValueID() == m_primitiveValue->getValueID(); 208 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit iveValue(value)->getValueID() == 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 16 matching lines...) Expand all
235 } 235 }
236 236
237 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const 237 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const
238 { 238 {
239 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) 239 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)
240 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); 240 || style->getPropertyCSSValue(textDecorationPropertyForEditing());
241 } 241 }
242 242
243 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S tylePropertySet* style) const 243 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S tylePropertySet* style) const
244 { 244 {
245 RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSProp ertyWebkitTextDecorationsInEffect); 245 NullableCSSValue styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect);
246 if (!styleValue) 246 if (!styleValue)
247 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing ()); 247 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing ());
248 return matches(element) && styleValue && styleValue->isValueList() && toCSSV alueList(styleValue.get())->hasValue(m_primitiveValue.get()); 248 return matches(element) && styleValue && styleValue->isValueList() && toCSSV alueList(styleValue)->hasValue(CSSValue(*m_primitiveValue.get()));
249 } 249 }
250 250
251 class HTMLAttributeEquivalent : public HTMLElementEquivalent { 251 class HTMLAttributeEquivalent : public HTMLElementEquivalent {
252 public: 252 public:
253 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const HTMLQualifiedName& tagName, const QualifiedName& attrName) 253 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const HTMLQualifiedName& tagName, const QualifiedName& attrName)
254 { 254 {
255 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, tagNam e, attrName)); 255 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, tagNam e, attrName));
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 virtual bool matches(const Element* element) const override { return HTMLEle mentEquivalent::matches(element) && element->hasAttribute(m_attrName); } 262 virtual bool matches(const Element* element) const override { return HTMLEle mentEquivalent::matches(element) && element->hasAttribute(m_attrName); }
263 virtual bool hasAttribute() const override { return true; } 263 virtual bool hasAttribute() const override { return true; }
264 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const ov erride; 264 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const ov erride;
265 virtual void addToStyle(Element*, EditingStyle*) const override; 265 virtual void addToStyle(Element*, EditingStyle*) const override;
266 virtual PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const; 266 virtual 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 RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element); 291 NullableCSSValue value = attributeValueAsCSSValue(element);
292 RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_prope rtyID); 292 NullableCSSValue styleValue = style->getPropertyCSSValue(m_propertyID);
293 293
294 return compareCSSValuePtr(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 (RefPtrWillBeRawPtr<CSSValue> 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 PassRefPtrWillBeRawPtr<CSSValue> HTMLAttributeEquivalent::attributeValueAsCSSVal ue(Element* element) const 303 NullableCSSValue HTMLAttributeEquivalent::attributeValueAsCSSValue(Element* elem ent) 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 virtual PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const override; 322 virtual 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 PassRefPtrWillBeRawPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValu e(Element* element) const 335 NullableCSSValue HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* eleme nt) 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 , m_isMonospaceFont(false) 379 , m_isMonospaceFont(false)
380 , m_fontSizeDelta(NoFontDelta) 380 , m_fontSizeDelta(NoFontDelta)
381 { 381 {
382 setProperty(propertyID, value); 382 setProperty(propertyID, value);
383 } 383 }
384 384
385 EditingStyle::~EditingStyle() 385 EditingStyle::~EditingStyle()
386 { 386 {
387 } 387 }
388 388
389 static RGBA32 cssValueToRGBA(CSSValue* 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 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).g et()); 406 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyColor));
407 } 407 }
408 408
409 static inline RGBA32 getRGBAFontColor(StylePropertySet* style) 409 static inline RGBA32 getRGBAFontColor(StylePropertySet* style)
410 { 410 {
411 return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyColor).get()); 411 return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyColor));
412 } 412 }
413 413
414 static inline RGBA32 getRGBABackgroundColor(CSSStyleDeclaration* style) 414 static inline RGBA32 getRGBABackgroundColor(CSSStyleDeclaration* style)
415 { 415 {
416 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyBackgrou ndColor).get()); 416 return cssValueToRGBA(style->getPropertyCSSValueInternal(CSSPropertyBackgrou ndColor));
417 } 417 }
418 418
419 static inline RGBA32 getRGBABackgroundColor(StylePropertySet* style) 419 static inline RGBA32 getRGBABackgroundColor(StylePropertySet* style)
420 { 420 {
421 return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyBackgroundColor) .get()); 421 return cssValueToRGBA(style->getPropertyCSSValue(CSSPropertyBackgroundColor) );
422 } 422 }
423 423
424 static inline RGBA32 rgbaBackgroundColorInEffect(Node* node) 424 static inline RGBA32 rgbaBackgroundColorInEffect(Node* node)
425 { 425 {
426 return cssValueToRGBA(backgroundColorInEffect(node).get()); 426 return cssValueToRGBA(backgroundColorInEffect(node));
427 } 427 }
428 428
429 static int textAlignResolvingStartAndEnd(int textAlign, int direction) 429 static int textAlignResolvingStartAndEnd(int textAlign, int direction)
430 { 430 {
431 switch (textAlign) { 431 switch (textAlign) {
432 case CSSValueCenter: 432 case CSSValueCenter:
433 case CSSValueWebkitCenter: 433 case CSSValueWebkitCenter:
434 return CSSValueCenter; 434 return CSSValueCenter;
435 case CSSValueJustify: 435 case CSSValueJustify:
436 return CSSValueJustify; 436 return CSSValueJustify;
(...skipping 21 matching lines...) Expand all
458 { 458 {
459 if (isTabHTMLSpanElementTextNode(node)) 459 if (isTabHTMLSpanElementTextNode(node))
460 node = tabSpanElement(node)->parentNode(); 460 node = tabSpanElement(node)->parentNode();
461 else if (isTabHTMLSpanElement(node)) 461 else if (isTabHTMLSpanElement(node))
462 node = node->parentNode(); 462 node = node->parentNode();
463 463
464 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS SComputedStyleDeclaration::create(node); 464 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS SComputedStyleDeclaration::create(node);
465 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition); 465 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition);
466 466
467 if (propertiesToInclude == EditingPropertiesInEffect) { 467 if (propertiesToInclude == EditingPropertiesInEffect) {
468 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node)) 468 if (NullableCSSValue value = backgroundColorInEffect(node))
469 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt()); 469 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt());
470 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) 470 if (NullableCSSValue value = computedStyleAtPosition->getPropertyCSSValu e(CSSPropertyWebkitTextDecorationsInEffect))
471 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t()); 471 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t());
472 } 472 }
473 473
474 if (node && node->ensureComputedStyle()) { 474 if (node && node->ensureComputedStyle()) {
475 const ComputedStyle* computedStyle = node->ensureComputedStyle(); 475 const ComputedStyle* computedStyle = node->ensureComputedStyle();
476 removeTextFillAndStrokeColorsIfNeeded(computedStyle); 476 removeTextFillAndStrokeColorsIfNeeded(computedStyle);
477 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio n.get()); 477 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio n.get());
478 } 478 }
479 479
480 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); 480 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont();
(...skipping 31 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 RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSS PropertyWebkitFontSizeDelta); 522 NullableCSSValue value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebk itFontSizeDelta);
523 if (!value || !value->isPrimitiveValue()) 523 if (!value || !value->isPrimitiveValue())
524 return; 524 return;
525 525
526 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); 526 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 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyUnicodeBidi); 547 NullableCSSValue unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSProper tyUnicodeBidi);
548 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 548 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
549 return false; 549 return false;
550 550
551 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal ueID(); 551 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID() ;
552 if (unicodeBidiValue == CSSValueEmbed) { 552 if (unicodeBidiValue == CSSValueEmbed) {
553 RefPtrWillBeRawPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSV alue(CSSPropertyDirection); 553 NullableCSSValue direction = m_mutableStyle->getPropertyCSSValue(CSSProp ertyDirection);
554 if (!direction || !direction->isPrimitiveValue()) 554 if (!direction || !direction->isPrimitiveValue())
555 return false; 555 return false;
556 556
557 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; 557 writingDirection = toCSSPrimitiveValue(direction)->getValueID() == CSSVa lueLtr ? 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 unsigned propertyCount = nodeStyle->propertyCount(); 650 unsigned propertyCount = nodeStyle->propertyCount();
651 for (unsigned i = 0; i < propertyCount; ++i) 651 for (unsigned i = 0; i < propertyCount; ++i)
652 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); 652 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id());
653 } 653 }
654 654
655 void EditingStyle::collapseTextDecorationProperties() 655 void EditingStyle::collapseTextDecorationProperties()
656 { 656 {
657 if (!m_mutableStyle) 657 if (!m_mutableStyle)
658 return; 658 return;
659 659
660 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPr opertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); 660 NullableCSSValue textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect);
661 if (!textDecorationsInEffect) 661 if (!textDecorationsInEffect)
662 return; 662 return;
663 663
664 if (textDecorationsInEffect->isValueList()) 664 if (textDecorationsInEffect->isValueList())
665 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr opertyForEditing())); 665 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr opertyForEditing()));
666 else 666 else
667 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); 667 m_mutableStyle->removeProperty(textDecorationPropertyForEditing());
668 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 668 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
669 } 669 }
670 670
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 { 947 {
948 if (!m_mutableStyle) 948 if (!m_mutableStyle)
949 return; 949 return;
950 950
951 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o nly removes the editing style. 951 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o nly removes the editing style.
952 // If this function was modified in the future to delete all redundant prope rties, then add a boolean value to indicate 952 // If this function was modified in the future to delete all redundant prope rties, then add a boolean value to indicate
953 // which one of editingStyleAtPosition or computedStyle is called. 953 // which one of editingStyleAtPosition or computedStyle is called.
954 RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::crea te(position, EditingPropertiesInEffect); 954 RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::crea te(position, EditingPropertiesInEffect);
955 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g et(); 955 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g et();
956 956
957 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = nullptr; 957 NullableCSSValue unicodeBidi;
958 RefPtrWillBeRawPtr<CSSValue> direction = nullptr; 958 NullableCSSValue direction;
959 if (shouldPreserveWritingDirection == PreserveWritingDirection) { 959 if (shouldPreserveWritingDirection == PreserveWritingDirection) {
960 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi ); 960 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi );
961 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); 961 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
962 } 962 }
963 963
964 m_mutableStyle->removeEquivalentProperties(styleAtPosition); 964 m_mutableStyle->removeEquivalentProperties(styleAtPosition);
965 965
966 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin gStartAndEnd(styleAtPosition)) 966 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin gStartAndEnd(styleAtPosition))
967 m_mutableStyle->removeProperty(CSSPropertyTextAlign); 967 m_mutableStyle->removeProperty(CSSPropertyTextAlign);
968 968
969 if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(styleAtPositi on)) 969 if (getRGBAFontColor(m_mutableStyle.get()) == getRGBAFontColor(styleAtPositi on))
970 m_mutableStyle->removeProperty(CSSPropertyColor); 970 m_mutableStyle->removeProperty(CSSPropertyColor);
971 971
972 if (hasTransparentBackgroundColor(m_mutableStyle.get()) 972 if (hasTransparentBackgroundColor(m_mutableStyle.get())
973 || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgro undColor).get()) == rgbaBackgroundColorInEffect(position.containerNode())) 973 || cssValueToRGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgro undColor)) == rgbaBackgroundColorInEffect(position.containerNode()))
974 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); 974 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor);
975 975
976 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { 976 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) {
977 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue( unicodeBidi.get())->getValueID()); 977 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue( unicodeBidi)->getValueID());
978 if (direction && direction->isPrimitiveValue()) 978 if (direction && direction->isPrimitiveValue())
979 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu e(direction.get())->getValueID()); 979 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu e(direction)->getValueID());
980 } 980 }
981 } 981 }
982 982
983 void EditingStyle::mergeTypingStyle(Document* document) 983 void EditingStyle::mergeTypingStyle(Document* document)
984 { 984 {
985 ASSERT(document); 985 ASSERT(document);
986 986
987 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document->frame()->selection( ).typingStyle(); 987 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document->frame()->selection( ).typingStyle();
988 if (!typingStyle || typingStyle == this) 988 if (!typingStyle || typingStyle == this)
989 return; 989 return;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) { 1084 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) {
1085 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues, 1085 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues,
1086 EditingStyle::EditingPropertiesInEffect); 1086 EditingStyle::EditingPropertiesInEffect);
1087 } 1087 }
1088 } 1088 }
1089 1089
1090 return wrappingStyle.release(); 1090 return wrappingStyle.release();
1091 } 1091 }
1092 1092
1093 1093
1094 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL ist* valueToMerge) 1094 static void mergeTextDecorationValues(CSSValueList& mergedValue, const CSSValueL ist& valueToMerge)
1095 { 1095 {
1096 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimi tiveValue::createIdentifier(CSSValueUnderline))); 1096 const CSSValue& underline = CSSPrimitiveValue::createIdentifier(CSSValueUnde rline);
1097 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPri mitiveValue::createIdentifier(CSSValueLineThrough))); 1097 const CSSValue& lineThrough = CSSPrimitiveValue::createIdentifier(CSSValueLi neThrough);
1098 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline))
1099 mergedValue->append(underline);
1100 1098
1101 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug h)) 1099 if (valueToMerge.hasValue(underline) && !mergedValue.hasValue(underline))
1102 mergedValue->append(lineThrough); 1100 mergedValue.append(underline);
1101
1102 if (valueToMerge.hasValue(lineThrough) && !mergedValue.hasValue(lineThrough) )
1103 mergedValue.append(lineThrough);
1103 } 1104 }
1104 1105
1105 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride Mode mode) 1106 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride Mode mode)
1106 { 1107 {
1107 if (!style) 1108 if (!style)
1108 return; 1109 return;
1109 1110
1110 if (!m_mutableStyle) { 1111 if (!m_mutableStyle) {
1111 m_mutableStyle = style->mutableCopy(); 1112 m_mutableStyle = style->mutableCopy();
1112 return; 1113 return;
1113 } 1114 }
1114 1115
1115 unsigned propertyCount = style->propertyCount(); 1116 unsigned propertyCount = style->propertyCount();
1116 for (unsigned i = 0; i < propertyCount; ++i) { 1117 for (unsigned i = 0; i < propertyCount; ++i) {
1117 StylePropertySet::PropertyReference property = style->propertyAt(i); 1118 StylePropertySet::PropertyReference property = style->propertyAt(i);
1118 RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue (property.id()); 1119 NullableCSSValue value = m_mutableStyle->getPropertyCSSValue(property.id ());
1119 1120
1120 // text decorations never override values 1121 // text decorations never override values
1121 if ((property.id() == textDecorationPropertyForEditing() || property.id( ) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList( ) && value) { 1122 if ((property.id() == textDecorationPropertyForEditing() || property.id( ) == CSSPropertyWebkitTextDecorationsInEffect) && property.value().isValueList() && value) {
1122 if (value->isValueList()) { 1123 if (value && value->isValueList()) {
1123 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu eList(property.value())); 1124 mergeTextDecorationValues(*toCSSValueList(value), toCSSValueList (property.value()));
1124 continue; 1125 continue;
1125 } 1126 }
1126 value = nullptr; // text-decoration: none is equivalent to not havin g the property 1127 value = nullptr; // text-decoration: none is equivalent to not havin g the property
1127 } 1128 }
1128 1129
1129 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) 1130 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value))
1130 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); 1131 m_mutableStyle->setProperty(property.id(), property.value().cssText( ), property.isImportant());
1131 } 1132 }
1132 } 1133 }
1133 1134
1134 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> styleFromMatchedRulesForE lement(Element* element, unsigned rulesToInclude) 1135 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> styleFromMatchedRulesForE lement(Element* element, unsigned rulesToInclude)
1135 { 1136 {
1136 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create(); 1137 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create();
1137 RefPtrWillBeRawPtr<StyleRuleList> matchedRules = element->document().ensureS tyleResolver().styleRulesForElement(element, rulesToInclude); 1138 RefPtrWillBeRawPtr<StyleRuleList> matchedRules = element->document().ensureS tyleResolver().styleRulesForElement(element, rulesToInclude);
1138 if (matchedRules) { 1139 if (matchedRules) {
1139 for (unsigned i = 0; i < matchedRules->m_list.size(); ++i) 1140 for (unsigned i = 0; i < matchedRules->m_list.size(); ++i)
1140 style->mergeAndOverrideOnConflict(&matchedRules->m_list[i]->properti es()); 1141 style->mergeAndOverrideOnConflict(&matchedRules->m_list[i]->properti es());
(...skipping 20 matching lines...) Expand all
1161 1162
1162 // The property value, if it's a percentage, may not reflect the actual comp uted value. 1163 // The property value, if it's a percentage, may not reflect the actual comp uted value.
1163 // For example: style="height: 1%; overflow: visible;" in quirksmode 1164 // For example: style="height: 1%; overflow: visible;" in quirksmode
1164 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot copy/paste fidelity problem 1165 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot copy/paste fidelity problem
1165 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS SComputedStyleDeclaration::create(element); 1166 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS SComputedStyleDeclaration::create(element);
1166 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle PropertySet::create(); 1167 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle PropertySet::create();
1167 { 1168 {
1168 unsigned propertyCount = m_mutableStyle->propertyCount(); 1169 unsigned propertyCount = m_mutableStyle->propertyCount();
1169 for (unsigned i = 0; i < propertyCount; ++i) { 1170 for (unsigned i = 0; i < propertyCount; ++i) {
1170 StylePropertySet::PropertyReference property = m_mutableStyle->prope rtyAt(i); 1171 StylePropertySet::PropertyReference property = m_mutableStyle->prope rtyAt(i);
1171 CSSValue* value = property.value(); 1172 CSSValue value = property.value();
1172 if (!value->isPrimitiveValue()) 1173 if (!value.isPrimitiveValue())
1173 continue; 1174 continue;
1174 if (toCSSPrimitiveValue(value)->isPercentage()) { 1175 if (toCSSPrimitiveValue(value).isPercentage()) {
1175 if (RefPtrWillBeRawPtr<CSSValue> computedPropertyValue = compute dStyleForElement->getPropertyCSSValue(property.id())) 1176 if (NullableCSSValue computedPropertyValue = computedStyleForEle ment->getPropertyCSSValue(property.id()))
1176 fromComputedStyle->addRespectingCascade(CSSProperty(property .id(), computedPropertyValue)); 1177 fromComputedStyle->addRespectingCascade(CSSProperty(property .id(), *computedPropertyValue));
1177 } 1178 }
1178 } 1179 }
1179 } 1180 }
1180 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); 1181 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get());
1181 } 1182 }
1182 1183
1183 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper tiesFrom, StylePropertySet* style) 1184 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper tiesFrom, StylePropertySet* style)
1184 { 1185 {
1185 unsigned propertyCount = style->propertyCount(); 1186 unsigned propertyCount = style->propertyCount();
1186 Vector<CSSPropertyID> propertiesToRemove(propertyCount); 1187 Vector<CSSPropertyID> propertiesToRemove(propertyCount);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 void EditingStyle::forceInline() 1260 void EditingStyle::forceInline()
1260 { 1261 {
1261 if (!m_mutableStyle) 1262 if (!m_mutableStyle)
1262 m_mutableStyle = MutableStylePropertySet::create(); 1263 m_mutableStyle = MutableStylePropertySet::create();
1263 const bool propertyIsImportant = true; 1264 const bool propertyIsImportant = true;
1264 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant); 1265 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant);
1265 } 1266 }
1266 1267
1267 int EditingStyle::legacyFontSize(Document* document) const 1268 int EditingStyle::legacyFontSize(Document* document) const
1268 { 1269 {
1269 RefPtrWillBeRawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue( CSSPropertyFontSize); 1270 NullableCSSValue cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyF ontSize);
1270 if (!cssValue || !cssValue->isPrimitiveValue()) 1271 if (!cssValue || !cssValue->isPrimitiveValue())
1271 return 0; 1272 return 0;
1272 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get ()), 1273 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue),
1273 m_isMonospaceFont, AlwaysUseLegacyFontSize); 1274 m_isMonospaceFont, AlwaysUseLegacyFontSize);
1274 } 1275 }
1275 1276
1276 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V isibleSelection& selection, bool shouldUseBackgroundColorInEffect) 1277 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V isibleSelection& selection, bool shouldUseBackgroundColorInEffect)
1277 { 1278 {
1278 if (selection.isNone()) 1279 if (selection.isNone())
1279 return nullptr; 1280 return nullptr;
1280 1281
1281 Position position = adjustedSelectionStartForStyleComputation(selection); 1282 Position position = adjustedSelectionStartForStyleComputation(selection);
1282 1283
(...skipping 10 matching lines...) Expand all
1293 return nullptr; 1294 return nullptr;
1294 1295
1295 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi ngStyle::AllProperties); 1296 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi ngStyle::AllProperties);
1296 style->mergeTypingStyle(&element->document()); 1297 style->mergeTypingStyle(&element->document());
1297 1298
1298 // If background color is transparent, traverse parent nodes until we hit a different value or document root 1299 // If background color is transparent, traverse parent nodes until we hit a different value or document root
1299 // Also, if the selection is a range, ignore the background color at the sta rt of selection, 1300 // Also, if the selection is a range, ignore the background color at the sta rt of selection,
1300 // and find the background color of the common ancestor. 1301 // and find the background color of the common ancestor.
1301 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare ntBackgroundColor(style->m_mutableStyle.get()))) { 1302 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare ntBackgroundColor(style->m_mutableStyle.get()))) {
1302 RefPtrWillBeRawPtr<Range> range(selection.toNormalizedRange()); 1303 RefPtrWillBeRawPtr<Range> range(selection.toNormalizedRange());
1303 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(ran ge->commonAncestorContainer())) 1304 if (NullableCSSValue value = backgroundColorInEffect(range->commonAncest orContainer()))
1304 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); 1305 style->setProperty(CSSPropertyBackgroundColor, value->cssText());
1305 } 1306 }
1306 1307
1307 return style; 1308 return style;
1308 } 1309 }
1309 1310
1310 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) 1311 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection& selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings)
1311 { 1312 {
1312 hasNestedOrMultipleEmbeddings = true; 1313 hasNestedOrMultipleEmbeddings = true;
1313 1314
(...skipping 10 matching lines...) Expand all
1324 if (selection.isRange()) { 1325 if (selection.isRange()) {
1325 end = selection.end().upstream(); 1326 end = selection.end().upstream();
1326 1327
1327 ASSERT(end.document()); 1328 ASSERT(end.document());
1328 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); 1329 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE quivalent(), end.parentAnchoredEquivalent())->pastLastNode();
1329 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { 1330 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) {
1330 if (!n->isStyledElement()) 1331 if (!n->isStyledElement())
1331 continue; 1332 continue;
1332 1333
1333 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS tyleDeclaration::create(n); 1334 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS tyleDeclaration::create(n);
1334 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValu e(CSSPropertyUnicodeBidi); 1335 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropert yUnicodeBidi);
1335 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1336 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1336 continue; 1337 continue;
1337 1338
1338 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get()) ->getValueID(); 1339 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getV alueID();
1339 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu eBidiOverride) 1340 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu eBidiOverride)
1340 return NaturalWritingDirection; 1341 return NaturalWritingDirection;
1341 } 1342 }
1342 } 1343 }
1343 1344
1344 if (selection.isCaret()) { 1345 if (selection.isCaret()) {
1345 WritingDirection direction; 1346 WritingDirection direction;
1346 if (typingStyle && typingStyle->textDirection(direction)) { 1347 if (typingStyle && typingStyle->textDirection(direction)) {
1347 hasNestedOrMultipleEmbeddings = false; 1348 hasNestedOrMultipleEmbeddings = false;
1348 return direction; 1349 return direction;
1349 } 1350 }
1350 node = selection.visibleStart().deepEquivalent().deprecatedNode(); 1351 node = selection.visibleStart().deepEquivalent().deprecatedNode();
1351 } 1352 }
1352 1353
1353 // 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 1354 // 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
1354 // to decide. 1355 // to decide.
1355 Node* block = enclosingBlock(node); 1356 Node* block = enclosingBlock(node);
1356 WritingDirection foundDirection = NaturalWritingDirection; 1357 WritingDirection foundDirection = NaturalWritingDirection;
1357 1358
1358 for (; node != block; node = node->parentNode()) { 1359 for (; node != block; node = node->parentNode()) {
1359 if (!node->isStyledElement()) 1360 if (!node->isStyledElement())
1360 continue; 1361 continue;
1361 1362
1362 Element* element = toElement(node); 1363 Element* element = toElement(node);
1363 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle Declaration::create(element); 1364 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle Declaration::create(element);
1364 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CS SPropertyUnicodeBidi); 1365 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi);
1365 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1366 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1366 continue; 1367 continue;
1367 1368
1368 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge tValueID(); 1369 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue ID();
1369 if (unicodeBidiValue == CSSValueNormal) 1370 if (unicodeBidiValue == CSSValueNormal)
1370 continue; 1371 continue;
1371 1372
1372 if (unicodeBidiValue == CSSValueBidiOverride) 1373 if (unicodeBidiValue == CSSValueBidiOverride)
1373 return NaturalWritingDirection; 1374 return NaturalWritingDirection;
1374 1375
1375 ASSERT(unicodeBidiValue == CSSValueEmbed); 1376 ASSERT(unicodeBidiValue == CSSValueEmbed);
1376 RefPtrWillBeRawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSP ropertyDirection); 1377 NullableCSSValue direction = style->getPropertyCSSValue(CSSPropertyDirec tion);
1377 if (!direction || !direction->isPrimitiveValue()) 1378 if (!direction || !direction->isPrimitiveValue())
1378 continue; 1379 continue;
1379 1380
1380 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); 1381 int directionValue = toCSSPrimitiveValue(direction)->getValueID();
1381 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) 1382 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl)
1382 continue; 1383 continue;
1383 1384
1384 if (foundDirection != NaturalWritingDirection) 1385 if (foundDirection != NaturalWritingDirection)
1385 return NaturalWritingDirection; 1386 return NaturalWritingDirection;
1386 1387
1387 // In the range case, make sure that the embedding element persists unti l the end of the range. 1388 // In the range case, make sure that the embedding element persists unti l the end of the range.
1388 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(element )) 1389 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(element ))
1389 return NaturalWritingDirection; 1390 return NaturalWritingDirection;
1390 1391
1391 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; 1392 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection;
1392 } 1393 }
1393 hasNestedOrMultipleEmbeddings = false; 1394 hasNestedOrMultipleEmbeddings = false;
1394 return foundDirection; 1395 return foundDirection;
1395 } 1396 }
1396 1397
1397 DEFINE_TRACE(EditingStyle) 1398 DEFINE_TRACE(EditingStyle)
1398 { 1399 {
1399 visitor->trace(m_mutableStyle); 1400 visitor->trace(m_mutableStyle);
1400 } 1401 }
1401 1402
1402 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) 1403 static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
1403 { 1404 {
1404 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSS Value(CSSPropertyWebkitTextDecorationsInEffect); 1405 NullableCSSValue textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect);
1405 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex tDecorationPropertyForEditing()); 1406 NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationP ropertyForEditing());
1406 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense. 1407 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense.
1407 ASSERT(!textDecorationsInEffect || !textDecoration); 1408 ASSERT(!textDecorationsInEffect || !textDecoration);
1408 if (textDecorationsInEffect) { 1409 if (textDecorationsInEffect) {
1409 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn Effect->cssText()); 1410 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn Effect->cssText());
1410 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 1411 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
1411 textDecoration = textDecorationsInEffect; 1412 textDecoration = textDecorationsInEffect;
1412 } 1413 }
1413 1414
1414 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". 1415 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none".
1415 if (textDecoration && !textDecoration->isValueList()) 1416 if (textDecoration && !textDecoration->isValueList())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1471 }
1471 1472
1472 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); 1473 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle);
1473 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { 1474 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) {
1474 style->removeProperty(CSSPropertyFontStyle); 1475 style->removeProperty(CSSPropertyFontStyle);
1475 m_applyItalic = true; 1476 m_applyItalic = true;
1476 } 1477 }
1477 1478
1478 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect 1479 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect
1479 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList. 1480 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList.
1480 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex tDecorationPropertyForEditing()); 1481 NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationP ropertyForEditing());
1481 if (textDecoration && textDecoration->isValueList()) { 1482 if (textDecoration && textDecoration->isValueList()) {
1482 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP rimitiveValue::createIdentifier(CSSValueUnderline))); 1483 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP rimitiveValue::createIdentifier(CSSValueUnderline)));
1483 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS SPrimitiveValue::createIdentifier(CSSValueLineThrough))); 1484 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS SPrimitiveValue::createIdentifier(CSSValueLineThrough)));
1484 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text Decoration.get())->copy(); 1485 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text Decoration)->copy();
1485 if (newTextDecoration->removeAll(underline)) 1486 if (newTextDecoration->removeAll(CSSValue(*underline)))
1486 m_applyUnderline = true; 1487 m_applyUnderline = true;
1487 if (newTextDecoration->removeAll(lineThrough)) 1488 if (newTextDecoration->removeAll(CSSValue(*lineThrough)))
1488 m_applyLineThrough = true; 1489 m_applyLineThrough = true;
1489 1490
1490 // If trimTextDecorations, delete underline and line-through 1491 // If trimTextDecorations, delete underline and line-through
1491 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration PropertyForEditing()); 1492 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration PropertyForEditing());
1492 } 1493 }
1493 1494
1494 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); 1495 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign);
1495 switch (verticalAlign) { 1496 switch (verticalAlign) {
1496 case CSSValueSub: 1497 case CSSValueSub:
1497 style->removeProperty(CSSPropertyVerticalAlign); 1498 style->removeProperty(CSSPropertyVerticalAlign);
1498 m_applySubscript = true; 1499 m_applySubscript = true;
1499 break; 1500 break;
1500 case CSSValueSuper: 1501 case CSSValueSuper:
1501 style->removeProperty(CSSPropertyVerticalAlign); 1502 style->removeProperty(CSSPropertyVerticalAlign);
1502 m_applySuperscript = true; 1503 m_applySuperscript = true;
1503 break; 1504 break;
1504 } 1505 }
1505 1506
1506 if (style->getPropertyCSSValue(CSSPropertyColor)) { 1507 if (style->getPropertyCSSValue(CSSPropertyColor)) {
1507 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); 1508 m_applyFontColor = Color(getRGBAFontColor(style)).serialized();
1508 style->removeProperty(CSSPropertyColor); 1509 style->removeProperty(CSSPropertyColor);
1509 } 1510 }
1510 1511
1511 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); 1512 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily);
1512 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web kit.org/show_bug.cgi?id=79448 1513 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web kit.org/show_bug.cgi?id=79448
1513 m_applyFontFace.replaceWithLiteral('\'', ""); 1514 m_applyFontFace.replaceWithLiteral('\'', "");
1514 style->removeProperty(CSSPropertyFontFamily); 1515 style->removeProperty(CSSPropertyFontFamily);
1515 1516
1516 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr opertyFontSize)) { 1517 if (NullableCSSValue fontSize = style->getPropertyCSSValue(CSSPropertyFontSi ze)) {
1517 if (!fontSize->isPrimitiveValue()) { 1518 if (!fontSize->isPrimitiveValue()) {
1518 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t he number. Put no font size. 1519 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t he number. Put no font size.
1519 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC SSPrimitiveValue(fontSize.get()), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelV aluesMatch)) { 1520 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC SSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesM atch)) {
1520 m_applyFontSize = String::number(legacyFontSize); 1521 m_applyFontSize = String::number(legacyFontSize);
1521 style->removeProperty(CSSPropertyFontSize); 1522 style->removeProperty(CSSPropertyFontSize);
1522 } 1523 }
1523 } 1524 }
1524 } 1525 }
1525 1526
1526 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr opertID, CSSValue* refTextDecoration) 1527 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr opertyID, NullableCSSValue refTextDecoration)
1527 { 1528 {
1528 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(pro pertID); 1529 NullableCSSValue textDecoration = style->getPropertyCSSValue(propertyID);
1529 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList()) 1530 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
1530 return; 1531 return;
1531 1532
1532 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco ration.get())->copy(); 1533 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco ration)->copy();
1533 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); 1534 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
1534 1535
1535 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) 1536 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++)
1536 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); 1537 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i));
1537 1538
1538 setTextDecorationProperty(style, newTextDecoration.get(), propertID); 1539 setTextDecorationProperty(style, newTextDecoration.get(), propertyID);
1539 } 1540 }
1540 1541
1541 static bool fontWeightIsBold(CSSValue* fontWeight) 1542 static bool fontWeightIsBold(CSSValue fontWeight)
1542 { 1543 {
1543 if (!fontWeight->isPrimitiveValue()) 1544 if (!fontWeight.isPrimitiveValue())
1544 return false; 1545 return false;
1545 1546
1546 // Because b tag can only bold text, there are only two states in plain html : bold and not bold. 1547 // Because b tag can only bold text, there are only two states in plain html : bold and not bold.
1547 // Collapse all other values to either one of these two states for editing p urposes. 1548 // Collapse all other values to either one of these two states for editing p urposes.
1548 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { 1549 switch (toCSSPrimitiveValue(fontWeight).getValueID()) {
1549 case CSSValue100: 1550 case CSSValue100:
1550 case CSSValue200: 1551 case CSSValue200:
1551 case CSSValue300: 1552 case CSSValue300:
1552 case CSSValue400: 1553 case CSSValue400:
1553 case CSSValue500: 1554 case CSSValue500:
1554 case CSSValueNormal: 1555 case CSSValueNormal:
1555 return false; 1556 return false;
1556 case CSSValueBold: 1557 case CSSValueBold:
1557 case CSSValue600: 1558 case CSSValue600:
1558 case CSSValue700: 1559 case CSSValue700:
1559 case CSSValue800: 1560 case CSSValue800:
1560 case CSSValue900: 1561 case CSSValue900:
1561 return true; 1562 return true;
1562 default: 1563 default:
1563 break; 1564 break;
1564 } 1565 }
1565 1566
1566 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter 1567 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter
1567 return false; 1568 return false;
1568 } 1569 }
1569 1570
1570 static bool fontWeightNeedsResolving(CSSValue* fontWeight) 1571 static bool fontWeightNeedsResolving(CSSValue fontWeight)
1571 { 1572 {
1572 if (!fontWeight->isPrimitiveValue()) 1573 if (!fontWeight.isPrimitiveValue())
1573 return true; 1574 return true;
1574 1575
1575 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); 1576 CSSValueID value = toCSSPrimitiveValue(fontWeight).getValueID();
1576 return value == CSSValueLighter || value == CSSValueBolder; 1577 return value == CSSValueLighter || value == CSSValueBolder;
1577 } 1578 }
1578 1579
1579 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) 1580 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
1580 { 1581 {
1581 ASSERT(styleWithRedundantProperties); 1582 ASSERT(styleWithRedundantProperties);
1582 ASSERT(baseStyle); 1583 ASSERT(baseStyle);
1583 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope rties->mutableCopy(); 1584 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope rties->mutableCopy();
1584 1585
1585 result->removeEquivalentProperties(baseStyle); 1586 result->removeEquivalentProperties(baseStyle);
1586 1587
1587 RefPtrWillBeRawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPro pertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect); 1588 NullableCSSValue baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect);
1588 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect.get()); 1589 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect);
1589 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); 1590 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect);
1590 1591
1591 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV alueInternal(CSSPropertyFontWeight)) { 1592 if (NullableCSSValue baseFontWeight = baseStyle->getPropertyCSSValueInternal (CSSPropertyFontWeight)) {
1592 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu e(CSSPropertyFontWeight)) { 1593 if (NullableCSSValue fontWeight = result->getPropertyCSSValue(CSSPropert yFontWeight)) {
1593 if (!fontWeightNeedsResolving(fontWeight.get()) && (fontWeightIsBold (fontWeight.get()) == fontWeightIsBold(baseFontWeight.get()))) 1594 if (!fontWeightNeedsResolving(*fontWeight) && (fontWeightIsBold(*fon tWeight) == fontWeightIsBold(*baseFontWeight)))
1594 result->removeProperty(CSSPropertyFontWeight); 1595 result->removeProperty(CSSPropertyFontWeight);
1595 } 1596 }
1596 } 1597 }
1597 1598
1598 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) 1599 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle))
1599 result->removeProperty(CSSPropertyColor); 1600 result->removeProperty(CSSPropertyColor);
1600 1601
1601 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) 1602 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign)
1602 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) 1603 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle))
1603 result->removeProperty(CSSPropertyTextAlign); 1604 result->removeProperty(CSSPropertyTextAlign);
1604 1605
1605 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) 1606 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle))
1606 result->removeProperty(CSSPropertyBackgroundColor); 1607 result->removeProperty(CSSPropertyBackgroundColor);
1607 1608
1608 return result.release(); 1609 return result.release();
1609 } 1610 }
1610 1611
1611 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) 1612 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
1612 { 1613 {
1613 if (!style) 1614 if (!style)
1614 return CSSValueInvalid; 1615 return CSSValueInvalid;
1615 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); 1616 NullableCSSValue value = style->getPropertyCSSValue(propertyID);
1616 if (!value || !value->isPrimitiveValue()) 1617 if (!value || !value->isPrimitiveValue())
1617 return CSSValueInvalid; 1618 return CSSValueInvalid;
1618 return toCSSPrimitiveValue(value.get())->getValueID(); 1619 return toCSSPrimitiveValue(value)->getValueID();
1619 } 1620 }
1620 1621
1621 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ID) 1622 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ID)
1622 { 1623 {
1623 if (!style) 1624 if (!style)
1624 return CSSValueInvalid; 1625 return CSSValueInvalid;
1625 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValueInternal(prop ertyID); 1626 NullableCSSValue value = style->getPropertyCSSValueInternal(propertyID);
1626 if (!value || !value->isPrimitiveValue()) 1627 if (!value || !value->isPrimitiveValue())
1627 return CSSValueInvalid; 1628 return CSSValueInvalid;
1628 return toCSSPrimitiveValue(value.get())->getValueID(); 1629 return toCSSPrimitiveValue(value)->getValueID();
1629 } 1630 }
1630 1631
1631 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo l isMonospaceFont, LegacyFontSizeMode mode) 1632 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo l isMonospaceFont, LegacyFontSizeMode mode)
1632 { 1633 {
1633 CSSPrimitiveValue::LengthUnitType lengthType; 1634 CSSPrimitiveValue::LengthUnitType lengthType;
1634 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->primitiveType(), leng thType) 1635 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->primitiveType(), leng thType)
1635 && lengthType == CSSPrimitiveValue::UnitTypePixels) { 1636 && lengthType == CSSPrimitiveValue::UnitTypePixels) {
1636 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa ctor(value->primitiveType()); 1637 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa ctor(value->primitiveType());
1637 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion); 1638 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion);
1638 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i sMonospaceFont); 1639 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i sMonospaceFont);
1639 // Use legacy font size only if pixel value matches exactly to that of l egacy font size. 1640 // Use legacy font size only if pixel value matches exactly to that of l egacy font size.
1640 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu ment, legacyFontSize, isMonospaceFont) == pixelFontSize) 1641 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu ment, legacyFontSize, isMonospaceFont) == pixelFontSize)
1641 return legacyFontSize; 1642 return legacyFontSize;
1642 1643
1643 return 0; 1644 return 0;
1644 } 1645 }
1645 1646
1646 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue WebkitXxxLarge) 1647 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue WebkitXxxLarge)
1647 return value->getValueID() - CSSValueXSmall + 1; 1648 return value->getValueID() - CSSValueXSmall + 1;
1648 1649
1649 return 0; 1650 return 0;
1650 } 1651 }
1651 1652
1652 bool isTransparentColorValue(CSSValue* cssValue) 1653 bool isTransparentColorValue(NullableCSSValue cssValue)
1653 { 1654 {
1654 if (!cssValue) 1655 if (!cssValue)
1655 return true; 1656 return true;
1656 if (!cssValue->isPrimitiveValue()) 1657 if (!cssValue->isPrimitiveValue())
1657 return false; 1658 return false;
1658 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); 1659 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue);
1659 if (value->isRGBColor()) 1660 if (value->isRGBColor())
1660 return !alphaChannel(value->getRGBA32Value()); 1661 return !alphaChannel(value->getRGBA32Value());
1661 return value->getValueID() == CSSValueTransparent; 1662 return value->getValueID() == CSSValueTransparent;
1662 } 1663 }
1663 1664
1664 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) 1665 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
1665 { 1666 {
1666 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(C SSPropertyBackgroundColor); 1667 NullableCSSValue cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa ckgroundColor);
1667 return isTransparentColorValue(cssValue.get()); 1668 return isTransparentColorValue(cssValue);
1668 } 1669 }
1669 1670
1670 bool hasTransparentBackgroundColor(StylePropertySet* style) 1671 bool hasTransparentBackgroundColor(StylePropertySet* style)
1671 { 1672 {
1672 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSProper tyBackgroundColor); 1673 NullableCSSValue cssValue = style->getPropertyCSSValue(CSSPropertyBackground Color);
1673 return isTransparentColorValue(cssValue.get()); 1674 return isTransparentColorValue(cssValue);
1674 } 1675 }
1675 1676
1676 PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node* node) 1677 NullableCSSValue backgroundColorInEffect(Node* node)
1677 { 1678 {
1678 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1679 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1679 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); 1680 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor);
1680 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1681 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1681 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1682 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1682 } 1683 }
1683 return nullptr; 1684 return nullptr;
1684 } 1685 }
1685 1686
1686 } 1687 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698