| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPr
opertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); | 691 NullableCSSValue textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal
ue(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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 { | 978 { |
| 979 if (!m_mutableStyle) | 979 if (!m_mutableStyle) |
| 980 return; | 980 return; |
| 981 | 981 |
| 982 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. | 982 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. |
| 983 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate | 983 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate |
| 984 // which one of editingStyleAtPosition or computedStyle is called. | 984 // which one of editingStyleAtPosition or computedStyle is called. |
| 985 RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::crea
te(position, EditingPropertiesInEffect); | 985 RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::crea
te(position, EditingPropertiesInEffect); |
| 986 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); | 986 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); |
| 987 | 987 |
| 988 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = nullptr; | 988 NullableCSSValue unicodeBidi; |
| 989 RefPtrWillBeRawPtr<CSSValue> direction = nullptr; | 989 NullableCSSValue direction; |
| 990 if (shouldPreserveWritingDirection == PreserveWritingDirection) { | 990 if (shouldPreserveWritingDirection == PreserveWritingDirection) { |
| 991 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); | 991 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); |
| 992 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); | 992 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); |
| 993 } | 993 } |
| 994 | 994 |
| 995 m_mutableStyle->removeEquivalentProperties(styleAtPosition); | 995 m_mutableStyle->removeEquivalentProperties(styleAtPosition); |
| 996 | 996 |
| 997 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) | 997 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) |
| 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).get()) == 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.get())->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.get())->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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) { | 1115 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) { |
| 1116 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node),
EditingStyle::DoNotOverrideValues, | 1116 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node),
EditingStyle::DoNotOverrideValues, |
| 1117 EditingStyle::EditingPropertiesInEffect); | 1117 EditingStyle::EditingPropertiesInEffect); |
| 1118 } | 1118 } |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 return wrappingStyle.release(); | 1121 return wrappingStyle.release(); |
| 1122 } | 1122 } |
| 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 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimi
tiveValue::createIdentifier(CSSValueUnderline))); |
| 1128 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPri
mitiveValue::createIdentifier(CSSValueLineThrough))); | 1128 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPri
mitiveValue::createIdentifier(CSSValueLineThrough))); |
| 1129 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) | |
| 1130 mergedValue->append(underline); | |
| 1131 | 1129 |
| 1132 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug
h)) | 1130 if (valueToMerge.hasValue(CSSValue(*underline)) && !mergedValue.hasValue(CSS
Value(*underline))) |
| 1133 mergedValue->append(lineThrough); | 1131 mergedValue.append(CSSValue(*underline)); |
| 1132 |
| 1133 if (valueToMerge.hasValue(CSSValue(*lineThrough)) && !mergedValue.hasValue(C
SSValue(*lineThrough))) |
| 1134 mergedValue.append(CSSValue(*lineThrough)); |
| 1134 } | 1135 } |
| 1135 | 1136 |
| 1136 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) | 1137 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) |
| 1137 { | 1138 { |
| 1138 if (!style) | 1139 if (!style) |
| 1139 return; | 1140 return; |
| 1140 | 1141 |
| 1141 if (!m_mutableStyle) { | 1142 if (!m_mutableStyle) { |
| 1142 m_mutableStyle = style->mutableCopy(); | 1143 m_mutableStyle = style->mutableCopy(); |
| 1143 return; | 1144 return; |
| 1144 } | 1145 } |
| 1145 | 1146 |
| 1146 unsigned propertyCount = style->propertyCount(); | 1147 unsigned propertyCount = style->propertyCount(); |
| 1147 for (unsigned i = 0; i < propertyCount; ++i) { | 1148 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1148 StylePropertySet::PropertyReference property = style->propertyAt(i); | 1149 StylePropertySet::PropertyReference property = style->propertyAt(i); |
| 1149 RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue
(property.id()); | 1150 NullableCSSValue value = m_mutableStyle->getPropertyCSSValue(property.id
()); |
| 1150 | 1151 |
| 1151 // text decorations never override values | 1152 // text decorations never override values |
| 1152 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList(
) && value) { | 1153 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value().isValueList()
&& value) { |
| 1153 if (value->isValueList()) { | 1154 if (value && value->isValueList()) { |
| 1154 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu
eList(property.value())); | 1155 mergeTextDecorationValues(*toCSSValueList(value), toCSSValueList
(property.value())); |
| 1155 continue; | 1156 continue; |
| 1156 } | 1157 } |
| 1157 value = nullptr; // text-decoration: none is equivalent to not havin
g the property | 1158 value = nullptr; // text-decoration: none is equivalent to not havin
g the property |
| 1158 } | 1159 } |
| 1159 | 1160 |
| 1160 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) | 1161 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) |
| 1161 m_mutableStyle->setProperty(property.id(), property.value()->cssText
(), property.isImportant()); | 1162 m_mutableStyle->setProperty(property.id(), property.value().cssText(
), property.isImportant()); |
| 1162 } | 1163 } |
| 1163 } | 1164 } |
| 1164 | 1165 |
| 1165 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> styleFromMatchedRulesForE
lement(Element* element, unsigned rulesToInclude) | 1166 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> styleFromMatchedRulesForE
lement(Element* element, unsigned rulesToInclude) |
| 1166 { | 1167 { |
| 1167 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet:
:create(); | 1168 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet:
:create(); |
| 1168 RefPtrWillBeRawPtr<StyleRuleList> matchedRules = element->document().ensureS
tyleResolver().styleRulesForElement(element, rulesToInclude); | 1169 RefPtrWillBeRawPtr<StyleRuleList> matchedRules = element->document().ensureS
tyleResolver().styleRulesForElement(element, rulesToInclude); |
| 1169 if (matchedRules) { | 1170 if (matchedRules) { |
| 1170 for (unsigned i = 0; i < matchedRules->m_list.size(); ++i) | 1171 for (unsigned i = 0; i < matchedRules->m_list.size(); ++i) |
| 1171 style->mergeAndOverrideOnConflict(&matchedRules->m_list[i]->properti
es()); | 1172 style->mergeAndOverrideOnConflict(&matchedRules->m_list[i]->properti
es()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1192 | 1193 |
| 1193 // The property value, if it's a percentage, may not reflect the actual comp
uted value. | 1194 // The property value, if it's a percentage, may not reflect the actual comp
uted value. |
| 1194 // For example: style="height: 1%; overflow: visible;" in quirksmode | 1195 // For example: style="height: 1%; overflow: visible;" in quirksmode |
| 1195 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot
copy/paste fidelity problem | 1196 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot
copy/paste fidelity problem |
| 1196 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS
SComputedStyleDeclaration::create(element); | 1197 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS
SComputedStyleDeclaration::create(element); |
| 1197 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle
PropertySet::create(); | 1198 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle
PropertySet::create(); |
| 1198 { | 1199 { |
| 1199 unsigned propertyCount = m_mutableStyle->propertyCount(); | 1200 unsigned propertyCount = m_mutableStyle->propertyCount(); |
| 1200 for (unsigned i = 0; i < propertyCount; ++i) { | 1201 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1201 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); | 1202 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); |
| 1202 CSSValue* value = property.value(); | 1203 CSSValue value = property.value(); |
| 1203 if (!value->isPrimitiveValue()) | 1204 if (!value.isPrimitiveValue()) |
| 1204 continue; | 1205 continue; |
| 1205 if (toCSSPrimitiveValue(value)->isPercentage()) { | 1206 if (toCSSPrimitiveValue(value).isPercentage()) { |
| 1206 if (RefPtrWillBeRawPtr<CSSValue> computedPropertyValue = compute
dStyleForElement->getPropertyCSSValue(property.id())) | 1207 if (NullableCSSValue computedPropertyValue = computedStyleForEle
ment->getPropertyCSSValue(property.id())) |
| 1207 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), computedPropertyValue)); | 1208 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), *computedPropertyValue)); |
| 1208 } | 1209 } |
| 1209 } | 1210 } |
| 1210 } | 1211 } |
| 1211 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); | 1212 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); |
| 1212 } | 1213 } |
| 1213 | 1214 |
| 1214 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) | 1215 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) |
| 1215 { | 1216 { |
| 1216 unsigned propertyCount = style->propertyCount(); | 1217 unsigned propertyCount = style->propertyCount(); |
| 1217 Vector<CSSPropertyID> propertiesToRemove(propertyCount); | 1218 Vector<CSSPropertyID> propertiesToRemove(propertyCount); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 void EditingStyle::forceInline() | 1291 void EditingStyle::forceInline() |
| 1291 { | 1292 { |
| 1292 if (!m_mutableStyle) | 1293 if (!m_mutableStyle) |
| 1293 m_mutableStyle = MutableStylePropertySet::create(); | 1294 m_mutableStyle = MutableStylePropertySet::create(); |
| 1294 const bool propertyIsImportant = true; | 1295 const bool propertyIsImportant = true; |
| 1295 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); | 1296 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); |
| 1296 } | 1297 } |
| 1297 | 1298 |
| 1298 int EditingStyle::legacyFontSize(Document* document) const | 1299 int EditingStyle::legacyFontSize(Document* document) const |
| 1299 { | 1300 { |
| 1300 RefPtrWillBeRawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(
CSSPropertyFontSize); | 1301 NullableCSSValue cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyF
ontSize); |
| 1301 if (!cssValue || !cssValue->isPrimitiveValue()) | 1302 if (!cssValue || !cssValue->isPrimitiveValue()) |
| 1302 return 0; | 1303 return 0; |
| 1303 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get
()), | 1304 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue), |
| 1304 m_isMonospaceFont, AlwaysUseLegacyFontSize); | 1305 m_isMonospaceFont, AlwaysUseLegacyFontSize); |
| 1305 } | 1306 } |
| 1306 | 1307 |
| 1307 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V
isibleSelection& selection, bool shouldUseBackgroundColorInEffect) | 1308 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V
isibleSelection& selection, bool shouldUseBackgroundColorInEffect) |
| 1308 { | 1309 { |
| 1309 if (selection.isNone()) | 1310 if (selection.isNone()) |
| 1310 return nullptr; | 1311 return nullptr; |
| 1311 | 1312 |
| 1312 Position position = adjustedSelectionStartForStyleComputation(selection); | 1313 Position position = adjustedSelectionStartForStyleComputation(selection); |
| 1313 | 1314 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1324 return nullptr; | 1325 return nullptr; |
| 1325 | 1326 |
| 1326 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi
ngStyle::AllProperties); | 1327 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi
ngStyle::AllProperties); |
| 1327 style->mergeTypingStyle(&element->document()); | 1328 style->mergeTypingStyle(&element->document()); |
| 1328 | 1329 |
| 1329 // If background color is transparent, traverse parent nodes until we hit a
different value or document root | 1330 // If background color is transparent, traverse parent nodes until we hit a
different value or document root |
| 1330 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, | 1331 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, |
| 1331 // and find the background color of the common ancestor. | 1332 // and find the background color of the common ancestor. |
| 1332 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { | 1333 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { |
| 1333 RefPtrWillBeRawPtr<Range> range(selection.toNormalizedRange()); | 1334 RefPtrWillBeRawPtr<Range> range(selection.toNormalizedRange()); |
| 1334 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(ran
ge->commonAncestorContainer())) | 1335 if (NullableCSSValue value = backgroundColorInEffect(range->commonAncest
orContainer())) |
| 1335 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); | 1336 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
| 1336 } | 1337 } |
| 1337 | 1338 |
| 1338 return style; | 1339 return style; |
| 1339 } | 1340 } |
| 1340 | 1341 |
| 1341 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) | 1342 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) |
| 1342 { | 1343 { |
| 1343 hasNestedOrMultipleEmbeddings = true; | 1344 hasNestedOrMultipleEmbeddings = true; |
| 1344 | 1345 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1355 if (selection.isRange()) { | 1356 if (selection.isRange()) { |
| 1356 end = selection.end().upstream(); | 1357 end = selection.end().upstream(); |
| 1357 | 1358 |
| 1358 ASSERT(end.document()); | 1359 ASSERT(end.document()); |
| 1359 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(); |
| 1360 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { | 1361 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { |
| 1361 if (!n->isStyledElement()) | 1362 if (!n->isStyledElement()) |
| 1362 continue; | 1363 continue; |
| 1363 | 1364 |
| 1364 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS
tyleDeclaration::create(n); | 1365 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS
tyleDeclaration::create(n); |
| 1365 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValu
e(CSSPropertyUnicodeBidi); | 1366 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropert
yUnicodeBidi); |
| 1366 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1367 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 1367 continue; | 1368 continue; |
| 1368 | 1369 |
| 1369 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())
->getValueID(); | 1370 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getV
alueID(); |
| 1370 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu
eBidiOverride) | 1371 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu
eBidiOverride) |
| 1371 return NaturalWritingDirection; | 1372 return NaturalWritingDirection; |
| 1372 } | 1373 } |
| 1373 } | 1374 } |
| 1374 | 1375 |
| 1375 if (selection.isCaret()) { | 1376 if (selection.isCaret()) { |
| 1376 WritingDirection direction; | 1377 WritingDirection direction; |
| 1377 if (typingStyle && typingStyle->textDirection(direction)) { | 1378 if (typingStyle && typingStyle->textDirection(direction)) { |
| 1378 hasNestedOrMultipleEmbeddings = false; | 1379 hasNestedOrMultipleEmbeddings = false; |
| 1379 return direction; | 1380 return direction; |
| 1380 } | 1381 } |
| 1381 node = selection.visibleStart().deepEquivalent().deprecatedNode(); | 1382 node = selection.visibleStart().deepEquivalent().deprecatedNode(); |
| 1382 } | 1383 } |
| 1383 | 1384 |
| 1384 // 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 |
| 1385 // to decide. | 1386 // to decide. |
| 1386 Node* block = enclosingBlock(node); | 1387 Node* block = enclosingBlock(node); |
| 1387 WritingDirection foundDirection = NaturalWritingDirection; | 1388 WritingDirection foundDirection = NaturalWritingDirection; |
| 1388 | 1389 |
| 1389 for (; node != block; node = node->parentNode()) { | 1390 for (; node != block; node = node->parentNode()) { |
| 1390 if (!node->isStyledElement()) | 1391 if (!node->isStyledElement()) |
| 1391 continue; | 1392 continue; |
| 1392 | 1393 |
| 1393 Element* element = toElement(node); | 1394 Element* element = toElement(node); |
| 1394 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle
Declaration::create(element); | 1395 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle
Declaration::create(element); |
| 1395 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CS
SPropertyUnicodeBidi); | 1396 NullableCSSValue unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni
codeBidi); |
| 1396 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1397 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
| 1397 continue; | 1398 continue; |
| 1398 | 1399 |
| 1399 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge
tValueID(); | 1400 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue
ID(); |
| 1400 if (unicodeBidiValue == CSSValueNormal) | 1401 if (unicodeBidiValue == CSSValueNormal) |
| 1401 continue; | 1402 continue; |
| 1402 | 1403 |
| 1403 if (unicodeBidiValue == CSSValueBidiOverride) | 1404 if (unicodeBidiValue == CSSValueBidiOverride) |
| 1404 return NaturalWritingDirection; | 1405 return NaturalWritingDirection; |
| 1405 | 1406 |
| 1406 ASSERT(unicodeBidiValue == CSSValueEmbed); | 1407 ASSERT(unicodeBidiValue == CSSValueEmbed); |
| 1407 RefPtrWillBeRawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSP
ropertyDirection); | 1408 NullableCSSValue direction = style->getPropertyCSSValue(CSSPropertyDirec
tion); |
| 1408 if (!direction || !direction->isPrimitiveValue()) | 1409 if (!direction || !direction->isPrimitiveValue()) |
| 1409 continue; | 1410 continue; |
| 1410 | 1411 |
| 1411 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); | 1412 int directionValue = toCSSPrimitiveValue(direction)->getValueID(); |
| 1412 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) | 1413 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) |
| 1413 continue; | 1414 continue; |
| 1414 | 1415 |
| 1415 if (foundDirection != NaturalWritingDirection) | 1416 if (foundDirection != NaturalWritingDirection) |
| 1416 return NaturalWritingDirection; | 1417 return NaturalWritingDirection; |
| 1417 | 1418 |
| 1418 // 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. |
| 1419 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(element
)) | 1420 if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(element
)) |
| 1420 return NaturalWritingDirection; | 1421 return NaturalWritingDirection; |
| 1421 | 1422 |
| 1422 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; | 1423 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; |
| 1423 } | 1424 } |
| 1424 hasNestedOrMultipleEmbeddings = false; | 1425 hasNestedOrMultipleEmbeddings = false; |
| 1425 return foundDirection; | 1426 return foundDirection; |
| 1426 } | 1427 } |
| 1427 | 1428 |
| 1428 DEFINE_TRACE(EditingStyle) | 1429 DEFINE_TRACE(EditingStyle) |
| 1429 { | 1430 { |
| 1430 visitor->trace(m_mutableStyle); | 1431 visitor->trace(m_mutableStyle); |
| 1431 } | 1432 } |
| 1432 | 1433 |
| 1433 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) | 1434 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) |
| 1434 { | 1435 { |
| 1435 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSS
Value(CSSPropertyWebkitTextDecorationsInEffect); | 1436 NullableCSSValue textDecorationsInEffect = style->getPropertyCSSValue(CSSPro
pertyWebkitTextDecorationsInEffect); |
| 1436 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex
tDecorationPropertyForEditing()); | 1437 NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); |
| 1437 // 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. |
| 1438 ASSERT(!textDecorationsInEffect || !textDecoration); | 1439 ASSERT(!textDecorationsInEffect || !textDecoration); |
| 1439 if (textDecorationsInEffect) { | 1440 if (textDecorationsInEffect) { |
| 1440 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn
Effect->cssText()); | 1441 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn
Effect->cssText()); |
| 1441 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 1442 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 1442 textDecoration = textDecorationsInEffect; | 1443 textDecoration = textDecorationsInEffect; |
| 1443 } | 1444 } |
| 1444 | 1445 |
| 1445 // 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". |
| 1446 if (textDecoration && !textDecoration->isValueList()) | 1447 if (textDecoration && !textDecoration->isValueList()) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 } | 1502 } |
| 1502 | 1503 |
| 1503 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1504 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
| 1504 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1505 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
| 1505 style->removeProperty(CSSPropertyFontStyle); | 1506 style->removeProperty(CSSPropertyFontStyle); |
| 1506 m_applyItalic = true; | 1507 m_applyItalic = true; |
| 1507 } | 1508 } |
| 1508 | 1509 |
| 1509 // 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 |
| 1510 // 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. |
| 1511 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex
tDecorationPropertyForEditing()); | 1512 NullableCSSValue textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); |
| 1512 if (textDecoration && textDecoration->isValueList()) { | 1513 if (textDecoration && textDecoration->isValueList()) { |
| 1513 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP
rimitiveValue::createIdentifier(CSSValueUnderline))); | 1514 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP
rimitiveValue::createIdentifier(CSSValueUnderline))); |
| 1514 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS
SPrimitiveValue::createIdentifier(CSSValueLineThrough))); | 1515 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS
SPrimitiveValue::createIdentifier(CSSValueLineThrough))); |
| 1515 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text
Decoration.get())->copy(); | 1516 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text
Decoration)->copy(); |
| 1516 if (newTextDecoration->removeAll(underline)) | 1517 if (newTextDecoration->removeAll(CSSValue(*underline))) |
| 1517 m_applyUnderline = true; | 1518 m_applyUnderline = true; |
| 1518 if (newTextDecoration->removeAll(lineThrough)) | 1519 if (newTextDecoration->removeAll(CSSValue(*lineThrough))) |
| 1519 m_applyLineThrough = true; | 1520 m_applyLineThrough = true; |
| 1520 | 1521 |
| 1521 // If trimTextDecorations, delete underline and line-through | 1522 // If trimTextDecorations, delete underline and line-through |
| 1522 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration
PropertyForEditing()); | 1523 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration
PropertyForEditing()); |
| 1523 } | 1524 } |
| 1524 | 1525 |
| 1525 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); | 1526 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); |
| 1526 switch (verticalAlign) { | 1527 switch (verticalAlign) { |
| 1527 case CSSValueSub: | 1528 case CSSValueSub: |
| 1528 style->removeProperty(CSSPropertyVerticalAlign); | 1529 style->removeProperty(CSSPropertyVerticalAlign); |
| 1529 m_applySubscript = true; | 1530 m_applySubscript = true; |
| 1530 break; | 1531 break; |
| 1531 case CSSValueSuper: | 1532 case CSSValueSuper: |
| 1532 style->removeProperty(CSSPropertyVerticalAlign); | 1533 style->removeProperty(CSSPropertyVerticalAlign); |
| 1533 m_applySuperscript = true; | 1534 m_applySuperscript = true; |
| 1534 break; | 1535 break; |
| 1535 } | 1536 } |
| 1536 | 1537 |
| 1537 if (style->getPropertyCSSValue(CSSPropertyColor)) { | 1538 if (style->getPropertyCSSValue(CSSPropertyColor)) { |
| 1538 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); | 1539 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); |
| 1539 style->removeProperty(CSSPropertyColor); | 1540 style->removeProperty(CSSPropertyColor); |
| 1540 } | 1541 } |
| 1541 | 1542 |
| 1542 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); | 1543 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); |
| 1543 // 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 |
| 1544 m_applyFontFace.replaceWithLiteral('\'', ""); | 1545 m_applyFontFace.replaceWithLiteral('\'', ""); |
| 1545 style->removeProperty(CSSPropertyFontFamily); | 1546 style->removeProperty(CSSPropertyFontFamily); |
| 1546 | 1547 |
| 1547 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr
opertyFontSize)) { | 1548 if (NullableCSSValue fontSize = style->getPropertyCSSValue(CSSPropertyFontSi
ze)) { |
| 1548 if (!fontSize->isPrimitiveValue()) { | 1549 if (!fontSize->isPrimitiveValue()) { |
| 1549 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. |
| 1550 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize.get()), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelV
aluesMatch)) { | 1551 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesM
atch)) { |
| 1551 m_applyFontSize = String::number(legacyFontSize); | 1552 m_applyFontSize = String::number(legacyFontSize); |
| 1552 style->removeProperty(CSSPropertyFontSize); | 1553 style->removeProperty(CSSPropertyFontSize); |
| 1553 } | 1554 } |
| 1554 } | 1555 } |
| 1555 } | 1556 } |
| 1556 | 1557 |
| 1557 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertID, CSSValue* refTextDecoration) | 1558 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertyID, NullableCSSValue refTextDecoration) |
| 1558 { | 1559 { |
| 1559 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(pro
pertID); | 1560 NullableCSSValue textDecoration = style->getPropertyCSSValue(propertyID); |
| 1560 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) | 1561 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) |
| 1561 return; | 1562 return; |
| 1562 | 1563 |
| 1563 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco
ration.get())->copy(); | 1564 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco
ration)->copy(); |
| 1564 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); | 1565 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); |
| 1565 | 1566 |
| 1566 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) | 1567 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) |
| 1567 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); | 1568 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); |
| 1568 | 1569 |
| 1569 setTextDecorationProperty(style, newTextDecoration.get(), propertID); | 1570 setTextDecorationProperty(style, newTextDecoration.get(), propertyID); |
| 1570 } | 1571 } |
| 1571 | 1572 |
| 1572 static bool fontWeightIsBold(CSSValue* fontWeight) | 1573 static bool fontWeightIsBold(CSSValue fontWeight) |
| 1573 { | 1574 { |
| 1574 if (!fontWeight->isPrimitiveValue()) | 1575 if (!fontWeight.isPrimitiveValue()) |
| 1575 return false; | 1576 return false; |
| 1576 | 1577 |
| 1577 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. | 1578 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. |
| 1578 // Collapse all other values to either one of these two states for editing p
urposes. | 1579 // Collapse all other values to either one of these two states for editing p
urposes. |
| 1579 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { | 1580 switch (toCSSPrimitiveValue(fontWeight).getValueID()) { |
| 1580 case CSSValue100: | 1581 case CSSValue100: |
| 1581 case CSSValue200: | 1582 case CSSValue200: |
| 1582 case CSSValue300: | 1583 case CSSValue300: |
| 1583 case CSSValue400: | 1584 case CSSValue400: |
| 1584 case CSSValue500: | 1585 case CSSValue500: |
| 1585 case CSSValueNormal: | 1586 case CSSValueNormal: |
| 1586 return false; | 1587 return false; |
| 1587 case CSSValueBold: | 1588 case CSSValueBold: |
| 1588 case CSSValue600: | 1589 case CSSValue600: |
| 1589 case CSSValue700: | 1590 case CSSValue700: |
| 1590 case CSSValue800: | 1591 case CSSValue800: |
| 1591 case CSSValue900: | 1592 case CSSValue900: |
| 1592 return true; | 1593 return true; |
| 1593 default: | 1594 default: |
| 1594 break; | 1595 break; |
| 1595 } | 1596 } |
| 1596 | 1597 |
| 1597 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter | 1598 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter |
| 1598 return false; | 1599 return false; |
| 1599 } | 1600 } |
| 1600 | 1601 |
| 1601 static bool fontWeightNeedsResolving(CSSValue* fontWeight) | 1602 static bool fontWeightNeedsResolving(CSSValue fontWeight) |
| 1602 { | 1603 { |
| 1603 if (!fontWeight->isPrimitiveValue()) | 1604 if (!fontWeight.isPrimitiveValue()) |
| 1604 return true; | 1605 return true; |
| 1605 | 1606 |
| 1606 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); | 1607 CSSValueID value = toCSSPrimitiveValue(fontWeight).getValueID(); |
| 1607 return value == CSSValueLighter || value == CSSValueBolder; | 1608 return value == CSSValueLighter || value == CSSValueBolder; |
| 1608 } | 1609 } |
| 1609 | 1610 |
| 1610 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) | 1611 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) |
| 1611 { | 1612 { |
| 1612 ASSERT(styleWithRedundantProperties); | 1613 ASSERT(styleWithRedundantProperties); |
| 1613 ASSERT(baseStyle); | 1614 ASSERT(baseStyle); |
| 1614 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope
rties->mutableCopy(); | 1615 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope
rties->mutableCopy(); |
| 1615 | 1616 |
| 1616 result->removeEquivalentProperties(baseStyle); | 1617 result->removeEquivalentProperties(baseStyle); |
| 1617 | 1618 |
| 1618 RefPtrWillBeRawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPro
pertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect); | 1619 NullableCSSValue baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu
eInternal(CSSPropertyWebkitTextDecorationsInEffect); |
| 1619 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe
xtDecorationsInEffect.get()); | 1620 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe
xtDecorationsInEffect); |
| 1620 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); | 1621 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect); |
| 1621 | 1622 |
| 1622 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV
alueInternal(CSSPropertyFontWeight)) { | 1623 if (NullableCSSValue baseFontWeight = baseStyle->getPropertyCSSValueInternal
(CSSPropertyFontWeight)) { |
| 1623 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu
e(CSSPropertyFontWeight)) { | 1624 if (NullableCSSValue fontWeight = result->getPropertyCSSValue(CSSPropert
yFontWeight)) { |
| 1624 if (!fontWeightNeedsResolving(fontWeight.get()) && (fontWeightIsBold
(fontWeight.get()) == fontWeightIsBold(baseFontWeight.get()))) | 1625 if (!fontWeightNeedsResolving(*fontWeight) && (fontWeightIsBold(*fon
tWeight) == fontWeightIsBold(*baseFontWeight))) |
| 1625 result->removeProperty(CSSPropertyFontWeight); | 1626 result->removeProperty(CSSPropertyFontWeight); |
| 1626 } | 1627 } |
| 1627 } | 1628 } |
| 1628 | 1629 |
| 1629 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) | 1630 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) |
| 1630 result->removeProperty(CSSPropertyColor); | 1631 result->removeProperty(CSSPropertyColor); |
| 1631 | 1632 |
| 1632 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1633 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
| 1633 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) | 1634 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) |
| 1634 result->removeProperty(CSSPropertyTextAlign); | 1635 result->removeProperty(CSSPropertyTextAlign); |
| 1635 | 1636 |
| 1636 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) | 1637 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) |
| 1637 result->removeProperty(CSSPropertyBackgroundColor); | 1638 result->removeProperty(CSSPropertyBackgroundColor); |
| 1638 | 1639 |
| 1639 return result.release(); | 1640 return result.release(); |
| 1640 } | 1641 } |
| 1641 | 1642 |
| 1642 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) | 1643 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
| 1643 { | 1644 { |
| 1644 if (!style) | 1645 if (!style) |
| 1645 return CSSValueInvalid; | 1646 return CSSValueInvalid; |
| 1646 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); | 1647 NullableCSSValue value = style->getPropertyCSSValue(propertyID); |
| 1647 if (!value || !value->isPrimitiveValue()) | 1648 if (!value || !value->isPrimitiveValue()) |
| 1648 return CSSValueInvalid; | 1649 return CSSValueInvalid; |
| 1649 return toCSSPrimitiveValue(value.get())->getValueID(); | 1650 return toCSSPrimitiveValue(value)->getValueID(); |
| 1650 } | 1651 } |
| 1651 | 1652 |
| 1652 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) | 1653 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) |
| 1653 { | 1654 { |
| 1654 if (!style) | 1655 if (!style) |
| 1655 return CSSValueInvalid; | 1656 return CSSValueInvalid; |
| 1656 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValueInternal(prop
ertyID); | 1657 NullableCSSValue value = style->getPropertyCSSValueInternal(propertyID); |
| 1657 if (!value || !value->isPrimitiveValue()) | 1658 if (!value || !value->isPrimitiveValue()) |
| 1658 return CSSValueInvalid; | 1659 return CSSValueInvalid; |
| 1659 return toCSSPrimitiveValue(value.get())->getValueID(); | 1660 return toCSSPrimitiveValue(value)->getValueID(); |
| 1660 } | 1661 } |
| 1661 | 1662 |
| 1662 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
l isMonospaceFont, LegacyFontSizeMode mode) | 1663 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
l isMonospaceFont, LegacyFontSizeMode mode) |
| 1663 { | 1664 { |
| 1664 CSSPrimitiveValue::LengthUnitType lengthType; | 1665 CSSPrimitiveValue::LengthUnitType lengthType; |
| 1665 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->primitiveType(), leng
thType) | 1666 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->primitiveType(), leng
thType) |
| 1666 && lengthType == CSSPrimitiveValue::UnitTypePixels) { | 1667 && lengthType == CSSPrimitiveValue::UnitTypePixels) { |
| 1667 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa
ctor(value->primitiveType()); | 1668 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa
ctor(value->primitiveType()); |
| 1668 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion); | 1669 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion); |
| 1669 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i
sMonospaceFont); | 1670 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i
sMonospaceFont); |
| 1670 // 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. |
| 1671 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu
ment, legacyFontSize, isMonospaceFont) == pixelFontSize) | 1672 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu
ment, legacyFontSize, isMonospaceFont) == pixelFontSize) |
| 1672 return legacyFontSize; | 1673 return legacyFontSize; |
| 1673 | 1674 |
| 1674 return 0; | 1675 return 0; |
| 1675 } | 1676 } |
| 1676 | 1677 |
| 1677 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) | 1678 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) |
| 1678 return value->getValueID() - CSSValueXSmall + 1; | 1679 return value->getValueID() - CSSValueXSmall + 1; |
| 1679 | 1680 |
| 1680 return 0; | 1681 return 0; |
| 1681 } | 1682 } |
| 1682 | 1683 |
| 1683 bool isTransparentColorValue(CSSValue* cssValue) | 1684 bool isTransparentColorValue(NullableCSSValue cssValue) |
| 1684 { | 1685 { |
| 1685 if (!cssValue) | 1686 if (!cssValue) |
| 1686 return true; | 1687 return true; |
| 1687 if (!cssValue->isPrimitiveValue()) | 1688 if (!cssValue->isPrimitiveValue()) |
| 1688 return false; | 1689 return false; |
| 1689 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); | 1690 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); |
| 1690 if (value->isRGBColor()) | 1691 if (value->isRGBColor()) |
| 1691 return !alphaChannel(value->getRGBA32Value()); | 1692 return !alphaChannel(value->getRGBA32Value()); |
| 1692 return value->getValueID() == CSSValueTransparent; | 1693 return value->getValueID() == CSSValueTransparent; |
| 1693 } | 1694 } |
| 1694 | 1695 |
| 1695 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) | 1696 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) |
| 1696 { | 1697 { |
| 1697 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(C
SSPropertyBackgroundColor); | 1698 NullableCSSValue cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa
ckgroundColor); |
| 1698 return isTransparentColorValue(cssValue.get()); | 1699 return isTransparentColorValue(cssValue); |
| 1699 } | 1700 } |
| 1700 | 1701 |
| 1701 bool hasTransparentBackgroundColor(StylePropertySet* style) | 1702 bool hasTransparentBackgroundColor(StylePropertySet* style) |
| 1702 { | 1703 { |
| 1703 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSProper
tyBackgroundColor); | 1704 NullableCSSValue cssValue = style->getPropertyCSSValue(CSSPropertyBackground
Color); |
| 1704 return isTransparentColorValue(cssValue.get()); | 1705 return isTransparentColorValue(cssValue); |
| 1705 } | 1706 } |
| 1706 | 1707 |
| 1707 PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node* node) | 1708 NullableCSSValue backgroundColorInEffect(Node* node) |
| 1708 { | 1709 { |
| 1709 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1710 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1710 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1711 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
| 1711 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1712 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1712 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1713 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1713 } | 1714 } |
| 1714 return nullptr; | 1715 return nullptr; |
| 1715 } | 1716 } |
| 1716 | 1717 |
| 1717 } | 1718 } |
| OLD | NEW |