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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return nullptr; | 153 return nullptr; |
154 return CSSComputedStyleDeclaration::create(elem); | 154 return CSSComputedStyleDeclaration::create(elem); |
155 } | 155 } |
156 | 156 |
157 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); | 157 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); |
158 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; | 158 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; |
159 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac
yFontSizeMode); | 159 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac
yFontSizeMode); |
160 static bool isTransparentColorValue(CSSValue*); | 160 static bool isTransparentColorValue(CSSValue*); |
161 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); | 161 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); |
162 static bool hasTransparentBackgroundColor(StylePropertySet*); | 162 static bool hasTransparentBackgroundColor(StylePropertySet*); |
163 static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node*); | 163 static PassRefPtr<CSSValue> backgroundColorInEffect(Node*); |
164 | 164 |
165 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu
ivalent> { | 165 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollectedFinalized<HTMLE
lementEquivalent> { |
166 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent); | 166 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent); |
167 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); | 167 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); |
168 public: | 168 public: |
169 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) | 169 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) |
170 { | 170 { |
171 return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiv
eValue, tagName)); | 171 return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiv
eValue, tagName)); |
172 } | 172 } |
173 | 173 |
174 virtual bool matches(const Element* element) const { return !m_tagName || el
ement->hasTagName(*m_tagName); } | 174 virtual bool matches(const Element* element) const { return !m_tagName || el
ement->hasTagName(*m_tagName); } |
175 virtual bool hasAttribute() const { return false; } | 175 virtual bool hasAttribute() const { return false; } |
176 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re
turn style->getPropertyCSSValue(m_propertyID); } | 176 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re
turn style->getPropertyCSSValue(m_propertyID); } |
177 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const; | 177 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const; |
178 virtual void addToStyle(Element*, EditingStyle*) const; | 178 virtual void addToStyle(Element*, EditingStyle*) const; |
179 | 179 |
180 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_primitiveValue); } | 180 DEFINE_INLINE_VIRTUAL_TRACE() { } |
181 | 181 |
182 protected: | 182 protected: |
183 HTMLElementEquivalent(CSSPropertyID); | 183 HTMLElementEquivalent(CSSPropertyID); |
184 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName); | 184 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName); |
185 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu
alifiedName& tagName); | 185 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu
alifiedName& tagName); |
186 const CSSPropertyID m_propertyID; | 186 const CSSPropertyID m_propertyID; |
187 const RefPtrWillBeMember<CSSPrimitiveValue> m_primitiveValue; | 187 const RefPtr<CSSPrimitiveValue> m_primitiveValue; |
188 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t
ag names are const global. | 188 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t
ag names are const global. |
189 }; | 189 }; |
190 | 190 |
191 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); | 191 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); |
192 | 192 |
193 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id) | 193 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id) |
194 : m_propertyID(id) | 194 : m_propertyID(id) |
195 , m_tagName(0) | 195 , m_tagName(0) |
196 { | 196 { |
197 } | 197 } |
198 | 198 |
199 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi
edName& tagName) | 199 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi
edName& tagName) |
200 : m_propertyID(id) | 200 : m_propertyID(id) |
201 , m_tagName(&tagName) | 201 , m_tagName(&tagName) |
202 { | 202 { |
203 } | 203 } |
204 | 204 |
205 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
iveValue, const HTMLQualifiedName& tagName) | 205 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
iveValue, const HTMLQualifiedName& tagName) |
206 : m_propertyID(id) | 206 : m_propertyID(id) |
207 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) | 207 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) |
208 , m_tagName(&tagName) | 208 , m_tagName(&tagName) |
209 { | 209 { |
210 ASSERT(primitiveValue != CSSValueInvalid); | 210 ASSERT(primitiveValue != CSSValueInvalid); |
211 } | 211 } |
212 | 212 |
213 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro
pertySet* style) const | 213 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro
pertySet* style) const |
214 { | 214 { |
215 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID
); | 215 RefPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID); |
216 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit
iveValue(value.get())->getValueID() == m_primitiveValue->getValueID(); | 216 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit
iveValue(value.get())->getValueID() == m_primitiveValue->getValueID(); |
217 } | 217 } |
218 | 218 |
219 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const | 219 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const |
220 { | 220 { |
221 style->setProperty(m_propertyID, m_primitiveValue->cssText()); | 221 style->setProperty(m_propertyID, m_primitiveValue->cssText()); |
222 } | 222 } |
223 | 223 |
224 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { | 224 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { |
225 public: | 225 public: |
(...skipping 17 matching lines...) Expand all Loading... |
243 } | 243 } |
244 | 244 |
245 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
style) const | 245 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet*
style) const |
246 { | 246 { |
247 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) | 247 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) |
248 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); | 248 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); |
249 } | 249 } |
250 | 250 |
251 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S
tylePropertySet* style) const | 251 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S
tylePropertySet* style) const |
252 { | 252 { |
253 RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSProp
ertyWebkitTextDecorationsInEffect); | 253 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe
xtDecorationsInEffect); |
254 if (!styleValue) | 254 if (!styleValue) |
255 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing
()); | 255 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing
()); |
256 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue.get())->hasValue(m_primitiveValue.get()); | 256 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue.get())->hasValue(m_primitiveValue.get()); |
257 } | 257 } |
258 | 258 |
259 class HTMLAttributeEquivalent : public HTMLElementEquivalent { | 259 class HTMLAttributeEquivalent : public HTMLElementEquivalent { |
260 public: | 260 public: |
261 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID
propertyID, const HTMLQualifiedName& tagName, const QualifiedName& attrName) | 261 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID
propertyID, const HTMLQualifiedName& tagName, const QualifiedName& attrName) |
262 { | 262 { |
263 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, tagNam
e, attrName)); | 263 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, tagNam
e, attrName)); |
264 } | 264 } |
265 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID
propertyID, const QualifiedName& attrName) | 265 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID
propertyID, const QualifiedName& attrName) |
266 { | 266 { |
267 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, attrNa
me)); | 267 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, attrNa
me)); |
268 } | 268 } |
269 | 269 |
270 bool matches(const Element* element) const override { return HTMLElementEqui
valent::matches(element) && element->hasAttribute(m_attrName); } | 270 bool matches(const Element* element) const override { return HTMLElementEqui
valent::matches(element) && element->hasAttribute(m_attrName); } |
271 bool hasAttribute() const override { return true; } | 271 bool hasAttribute() const override { return true; } |
272 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override; | 272 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override; |
273 void addToStyle(Element*, EditingStyle*) const override; | 273 void addToStyle(Element*, EditingStyle*) const override; |
274 virtual PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*)
const; | 274 virtual PassRefPtr<CSSValue> attributeValueAsCSSValue(Element*) const; |
275 inline const QualifiedName& attributeName() const { return m_attrName; } | 275 inline const QualifiedName& attributeName() const { return m_attrName; } |
276 | 276 |
277 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); } | 277 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); } |
278 | 278 |
279 protected: | 279 protected: |
280 HTMLAttributeEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName, con
st QualifiedName& attrName); | 280 HTMLAttributeEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName, con
st QualifiedName& attrName); |
281 HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& attrName); | 281 HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& attrName); |
282 const QualifiedName& m_attrName; // We can store a reference because HTML at
tribute names are const global. | 282 const QualifiedName& m_attrName; // We can store a reference because HTML at
tribute names are const global. |
283 }; | 283 }; |
284 | 284 |
285 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const HTMLQua
lifiedName& tagName, const QualifiedName& attrName) | 285 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const HTMLQua
lifiedName& tagName, const QualifiedName& attrName) |
286 : HTMLElementEquivalent(id, tagName) | 286 : HTMLElementEquivalent(id, tagName) |
287 , m_attrName(attrName) | 287 , m_attrName(attrName) |
288 { | 288 { |
289 } | 289 } |
290 | 290 |
291 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
edName& attrName) | 291 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
edName& attrName) |
292 : HTMLElementEquivalent(id) | 292 : HTMLElementEquivalent(id) |
293 , m_attrName(attrName) | 293 , m_attrName(attrName) |
294 { | 294 { |
295 } | 295 } |
296 | 296 |
297 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP
ropertySet* style) const | 297 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP
ropertySet* style) const |
298 { | 298 { |
299 RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element); | 299 RefPtr<CSSValue> value = attributeValueAsCSSValue(element); |
300 RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_prope
rtyID); | 300 RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_propertyID); |
301 | 301 |
302 return compareCSSValuePtr(value, styleValue); | 302 return compareCSSValuePtr(value, styleValue); |
303 } | 303 } |
304 | 304 |
305 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
const | 305 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
const |
306 { | 306 { |
307 if (RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element)) | 307 if (RefPtr<CSSValue> value = attributeValueAsCSSValue(element)) |
308 style->setProperty(m_propertyID, value->cssText()); | 308 style->setProperty(m_propertyID, value->cssText()); |
309 } | 309 } |
310 | 310 |
311 PassRefPtrWillBeRawPtr<CSSValue> HTMLAttributeEquivalent::attributeValueAsCSSVal
ue(Element* element) const | 311 PassRefPtr<CSSValue> HTMLAttributeEquivalent::attributeValueAsCSSValue(Element*
element) const |
312 { | 312 { |
313 ASSERT(element); | 313 ASSERT(element); |
314 const AtomicString& value = element->getAttribute(m_attrName); | 314 const AtomicString& value = element->getAttribute(m_attrName); |
315 if (value.isNull()) | 315 if (value.isNull()) |
316 return nullptr; | 316 return nullptr; |
317 | 317 |
318 RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = nullptr; | 318 RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = nullptr; |
319 dummyStyle = MutableStylePropertySet::create(); | 319 dummyStyle = MutableStylePropertySet::create(); |
320 dummyStyle->setProperty(m_propertyID, value); | 320 dummyStyle->setProperty(m_propertyID, value); |
321 return dummyStyle->getPropertyCSSValue(m_propertyID); | 321 return dummyStyle->getPropertyCSSValue(m_propertyID); |
322 } | 322 } |
323 | 323 |
324 class HTMLFontSizeEquivalent final : public HTMLAttributeEquivalent { | 324 class HTMLFontSizeEquivalent final : public HTMLAttributeEquivalent { |
325 public: | 325 public: |
326 static PassOwnPtrWillBeRawPtr<HTMLFontSizeEquivalent> create() | 326 static PassOwnPtrWillBeRawPtr<HTMLFontSizeEquivalent> create() |
327 { | 327 { |
328 return adoptPtrWillBeNoop(new HTMLFontSizeEquivalent()); | 328 return adoptPtrWillBeNoop(new HTMLFontSizeEquivalent()); |
329 } | 329 } |
330 PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const ov
erride; | 330 PassRefPtr<CSSValue> attributeValueAsCSSValue(Element*) const override; |
331 | 331 |
332 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); } | 332 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); } |
333 | 333 |
334 private: | 334 private: |
335 HTMLFontSizeEquivalent(); | 335 HTMLFontSizeEquivalent(); |
336 }; | 336 }; |
337 | 337 |
338 HTMLFontSizeEquivalent::HTMLFontSizeEquivalent() | 338 HTMLFontSizeEquivalent::HTMLFontSizeEquivalent() |
339 : HTMLAttributeEquivalent(CSSPropertyFontSize, HTMLNames::fontTag, HTMLNames
::sizeAttr) | 339 : HTMLAttributeEquivalent(CSSPropertyFontSize, HTMLNames::fontTag, HTMLNames
::sizeAttr) |
340 { | 340 { |
341 } | 341 } |
342 | 342 |
343 PassRefPtrWillBeRawPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValu
e(Element* element) const | 343 PassRefPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* e
lement) const |
344 { | 344 { |
345 ASSERT(element); | 345 ASSERT(element); |
346 const AtomicString& value = element->getAttribute(m_attrName); | 346 const AtomicString& value = element->getAttribute(m_attrName); |
347 if (value.isNull()) | 347 if (value.isNull()) |
348 return nullptr; | 348 return nullptr; |
349 CSSValueID size; | 349 CSSValueID size; |
350 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) | 350 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) |
351 return nullptr; | 351 return nullptr; |
352 return CSSPrimitiveValue::createIdentifier(size); | 352 return CSSPrimitiveValue::createIdentifier(size); |
353 } | 353 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 { | 466 { |
467 if (isTabHTMLSpanElementTextNode(node)) | 467 if (isTabHTMLSpanElementTextNode(node)) |
468 node = tabSpanElement(node)->parentNode(); | 468 node = tabSpanElement(node)->parentNode(); |
469 else if (isTabHTMLSpanElement(node)) | 469 else if (isTabHTMLSpanElement(node)) |
470 node = node->parentNode(); | 470 node = node->parentNode(); |
471 | 471 |
472 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS
SComputedStyleDeclaration::create(node); | 472 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS
SComputedStyleDeclaration::create(node); |
473 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); | 473 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi
tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle
(computedStyleAtPosition); |
474 | 474 |
475 if (propertiesToInclude == EditingPropertiesInEffect) { | 475 if (propertiesToInclude == EditingPropertiesInEffect) { |
476 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(node)) | 476 if (RefPtr<CSSValue> value = backgroundColorInEffect(node)) |
477 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); | 477 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe
xt()); |
478 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro
pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) | 478 if (RefPtr<CSSValue> value = computedStyleAtPosition->getPropertyCSSValu
e(CSSPropertyWebkitTextDecorationsInEffect)) |
479 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); | 479 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex
t()); |
480 } | 480 } |
481 | 481 |
482 if (node && node->ensureComputedStyle()) { | 482 if (node && node->ensureComputedStyle()) { |
483 const ComputedStyle* computedStyle = node->ensureComputedStyle(); | 483 const ComputedStyle* computedStyle = node->ensureComputedStyle(); |
484 removeTextFillAndStrokeColorsIfNeeded(computedStyle); | 484 removeTextFillAndStrokeColorsIfNeeded(computedStyle); |
485 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio
n.get()); | 485 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio
n.get()); |
486 } | 486 } |
487 | 487 |
488 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); | 488 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 if (!m_mutableStyle) | 520 if (!m_mutableStyle) |
521 return; | 521 return; |
522 | 522 |
523 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) { | 523 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) { |
524 // Explicit font size overrides any delta. | 524 // Explicit font size overrides any delta. |
525 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); | 525 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); |
526 return; | 526 return; |
527 } | 527 } |
528 | 528 |
529 // Get the adjustment amount out of the style. | 529 // Get the adjustment amount out of the style. |
530 RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSS
PropertyWebkitFontSizeDelta); | 530 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebk
itFontSizeDelta); |
531 if (!value || !value->isPrimitiveValue()) | 531 if (!value || !value->isPrimitiveValue()) |
532 return; | 532 return; |
533 | 533 |
534 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); | 534 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); |
535 | 535 |
536 // Only PX handled now. If we handle more types in the future, perhaps | 536 // Only PX handled now. If we handle more types in the future, perhaps |
537 // a switch statement here would be more appropriate. | 537 // a switch statement here would be more appropriate. |
538 if (!primitiveValue->isPx()) | 538 if (!primitiveValue->isPx()) |
539 return; | 539 return; |
540 | 540 |
541 m_fontSizeDelta = primitiveValue->getFloatValue(); | 541 m_fontSizeDelta = primitiveValue->getFloatValue(); |
542 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); | 542 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); |
543 } | 543 } |
544 | 544 |
545 bool EditingStyle::isEmpty() const | 545 bool EditingStyle::isEmpty() const |
546 { | 546 { |
547 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta ==
NoFontDelta; | 547 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta ==
NoFontDelta; |
548 } | 548 } |
549 | 549 |
550 bool EditingStyle::textDirection(WritingDirection& writingDirection) const | 550 bool EditingStyle::textDirection(WritingDirection& writingDirection) const |
551 { | 551 { |
552 if (!m_mutableStyle) | 552 if (!m_mutableStyle) |
553 return false; | 553 return false; |
554 | 554 |
555 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSVal
ue(CSSPropertyUnicodeBidi); | 555 RefPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSProper
tyUnicodeBidi); |
556 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 556 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
557 return false; | 557 return false; |
558 | 558 |
559 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal
ueID(); | 559 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal
ueID(); |
560 if (unicodeBidiValue == CSSValueEmbed) { | 560 if (unicodeBidiValue == CSSValueEmbed) { |
561 RefPtrWillBeRawPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSV
alue(CSSPropertyDirection); | 561 RefPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSValue(CSSProp
ertyDirection); |
562 if (!direction || !direction->isPrimitiveValue()) | 562 if (!direction || !direction->isPrimitiveValue()) |
563 return false; | 563 return false; |
564 | 564 |
565 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() ==
CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; | 565 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() ==
CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; |
566 | 566 |
567 return true; | 567 return true; |
568 } | 568 } |
569 | 569 |
570 if (unicodeBidiValue == CSSValueNormal) { | 570 if (unicodeBidiValue == CSSValueNormal) { |
571 writingDirection = NaturalWritingDirection; | 571 writingDirection = NaturalWritingDirection; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 unsigned propertyCount = nodeStyle->propertyCount(); | 689 unsigned propertyCount = nodeStyle->propertyCount(); |
690 for (unsigned i = 0; i < propertyCount; ++i) | 690 for (unsigned i = 0; i < propertyCount; ++i) |
691 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); | 691 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); |
692 } | 692 } |
693 | 693 |
694 void EditingStyle::collapseTextDecorationProperties() | 694 void EditingStyle::collapseTextDecorationProperties() |
695 { | 695 { |
696 if (!m_mutableStyle) | 696 if (!m_mutableStyle) |
697 return; | 697 return; |
698 | 698 |
699 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPr
opertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); | 699 RefPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal
ue(CSSPropertyWebkitTextDecorationsInEffect); |
700 if (!textDecorationsInEffect) | 700 if (!textDecorationsInEffect) |
701 return; | 701 return; |
702 | 702 |
703 if (textDecorationsInEffect->isValueList()) | 703 if (textDecorationsInEffect->isValueList()) |
704 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco
rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr
opertyForEditing())); | 704 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco
rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr
opertyForEditing())); |
705 else | 705 else |
706 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); | 706 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); |
707 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 707 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
708 } | 708 } |
709 | 709 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 { | 986 { |
987 if (!m_mutableStyle) | 987 if (!m_mutableStyle) |
988 return; | 988 return; |
989 | 989 |
990 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. | 990 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. |
991 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate | 991 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate |
992 // which one of editingStyleAtPosition or computedStyle is called. | 992 // which one of editingStyleAtPosition or computedStyle is called. |
993 RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::crea
te(position, EditingPropertiesInEffect); | 993 RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::crea
te(position, EditingPropertiesInEffect); |
994 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); | 994 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); |
995 | 995 |
996 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = nullptr; | 996 RefPtr<CSSValue> unicodeBidi = nullptr; |
997 RefPtrWillBeRawPtr<CSSValue> direction = nullptr; | 997 RefPtr<CSSValue> direction = nullptr; |
998 if (shouldPreserveWritingDirection == PreserveWritingDirection) { | 998 if (shouldPreserveWritingDirection == PreserveWritingDirection) { |
999 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); | 999 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); |
1000 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); | 1000 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); |
1001 } | 1001 } |
1002 | 1002 |
1003 m_mutableStyle->removeEquivalentProperties(styleAtPosition); | 1003 m_mutableStyle->removeEquivalentProperties(styleAtPosition); |
1004 | 1004 |
1005 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) | 1005 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) |
1006 m_mutableStyle->removeProperty(CSSPropertyTextAlign); | 1006 m_mutableStyle->removeProperty(CSSPropertyTextAlign); |
1007 | 1007 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node),
EditingStyle::DoNotOverrideValues, | 1125 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node),
EditingStyle::DoNotOverrideValues, |
1126 EditingStyle::EditingPropertiesInEffect); | 1126 EditingStyle::EditingPropertiesInEffect); |
1127 } | 1127 } |
1128 } | 1128 } |
1129 | 1129 |
1130 return wrappingStyle.release(); | 1130 return wrappingStyle.release(); |
1131 } | 1131 } |
1132 | 1132 |
1133 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL
ist* valueToMerge) | 1133 static void mergeTextDecorationValues(CSSValueList* mergedValue, const CSSValueL
ist* valueToMerge) |
1134 { | 1134 { |
1135 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSPrimi
tiveValue::createIdentifier(CSSValueUnderline))); | 1135 DEFINE_STATIC_REF(CSSPrimitiveValue, underline, (CSSPrimitiveValue::createId
entifier(CSSValueUnderline))); |
1136 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CSSPri
mitiveValue::createIdentifier(CSSValueLineThrough))); | 1136 DEFINE_STATIC_REF(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::create
Identifier(CSSValueLineThrough))); |
1137 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) | 1137 if (valueToMerge->hasValue(underline) && !mergedValue->hasValue(underline)) |
1138 mergedValue->append(underline); | 1138 mergedValue->append(underline); |
1139 | 1139 |
1140 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug
h)) | 1140 if (valueToMerge->hasValue(lineThrough) && !mergedValue->hasValue(lineThroug
h)) |
1141 mergedValue->append(lineThrough); | 1141 mergedValue->append(lineThrough); |
1142 } | 1142 } |
1143 | 1143 |
1144 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) | 1144 void EditingStyle::mergeStyle(const StylePropertySet* style, CSSPropertyOverride
Mode mode) |
1145 { | 1145 { |
1146 if (!style) | 1146 if (!style) |
1147 return; | 1147 return; |
1148 | 1148 |
1149 if (!m_mutableStyle) { | 1149 if (!m_mutableStyle) { |
1150 m_mutableStyle = style->mutableCopy(); | 1150 m_mutableStyle = style->mutableCopy(); |
1151 return; | 1151 return; |
1152 } | 1152 } |
1153 | 1153 |
1154 unsigned propertyCount = style->propertyCount(); | 1154 unsigned propertyCount = style->propertyCount(); |
1155 for (unsigned i = 0; i < propertyCount; ++i) { | 1155 for (unsigned i = 0; i < propertyCount; ++i) { |
1156 StylePropertySet::PropertyReference property = style->propertyAt(i); | 1156 StylePropertySet::PropertyReference property = style->propertyAt(i); |
1157 RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue
(property.id()); | 1157 RefPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id
()); |
1158 | 1158 |
1159 // text decorations never override values | 1159 // text decorations never override values |
1160 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList(
) && value) { | 1160 if ((property.id() == textDecorationPropertyForEditing() || property.id(
) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList(
) && value) { |
1161 if (value->isValueList()) { | 1161 if (value->isValueList()) { |
1162 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu
eList(property.value())); | 1162 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu
eList(property.value())); |
1163 continue; | 1163 continue; |
1164 } | 1164 } |
1165 value = nullptr; // text-decoration: none is equivalent to not havin
g the property | 1165 value = nullptr; // text-decoration: none is equivalent to not havin
g the property |
1166 } | 1166 } |
1167 | 1167 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS
SComputedStyleDeclaration::create(element); | 1204 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS
SComputedStyleDeclaration::create(element); |
1205 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle
PropertySet::create(); | 1205 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle
PropertySet::create(); |
1206 { | 1206 { |
1207 unsigned propertyCount = m_mutableStyle->propertyCount(); | 1207 unsigned propertyCount = m_mutableStyle->propertyCount(); |
1208 for (unsigned i = 0; i < propertyCount; ++i) { | 1208 for (unsigned i = 0; i < propertyCount; ++i) { |
1209 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); | 1209 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); |
1210 CSSValue* value = property.value(); | 1210 CSSValue* value = property.value(); |
1211 if (!value->isPrimitiveValue()) | 1211 if (!value->isPrimitiveValue()) |
1212 continue; | 1212 continue; |
1213 if (toCSSPrimitiveValue(value)->isPercentage()) { | 1213 if (toCSSPrimitiveValue(value)->isPercentage()) { |
1214 if (RefPtrWillBeRawPtr<CSSValue> computedPropertyValue = compute
dStyleForElement->getPropertyCSSValue(property.id())) | 1214 if (RefPtr<CSSValue> computedPropertyValue = computedStyleForEle
ment->getPropertyCSSValue(property.id())) |
1215 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), computedPropertyValue)); | 1215 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), computedPropertyValue)); |
1216 } | 1216 } |
1217 } | 1217 } |
1218 } | 1218 } |
1219 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); | 1219 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); |
1220 } | 1220 } |
1221 | 1221 |
1222 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) | 1222 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper
tiesFrom, StylePropertySet* style) |
1223 { | 1223 { |
1224 unsigned propertyCount = style->propertyCount(); | 1224 unsigned propertyCount = style->propertyCount(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 void EditingStyle::forceInline() | 1298 void EditingStyle::forceInline() |
1299 { | 1299 { |
1300 if (!m_mutableStyle) | 1300 if (!m_mutableStyle) |
1301 m_mutableStyle = MutableStylePropertySet::create(); | 1301 m_mutableStyle = MutableStylePropertySet::create(); |
1302 const bool propertyIsImportant = true; | 1302 const bool propertyIsImportant = true; |
1303 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); | 1303 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); |
1304 } | 1304 } |
1305 | 1305 |
1306 int EditingStyle::legacyFontSize(Document* document) const | 1306 int EditingStyle::legacyFontSize(Document* document) const |
1307 { | 1307 { |
1308 RefPtrWillBeRawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(
CSSPropertyFontSize); | 1308 RefPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyF
ontSize); |
1309 if (!cssValue || !cssValue->isPrimitiveValue()) | 1309 if (!cssValue || !cssValue->isPrimitiveValue()) |
1310 return 0; | 1310 return 0; |
1311 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get
()), | 1311 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get
()), |
1312 m_isMonospaceFont, AlwaysUseLegacyFontSize); | 1312 m_isMonospaceFont, AlwaysUseLegacyFontSize); |
1313 } | 1313 } |
1314 | 1314 |
1315 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V
isibleSelection& selection, bool shouldUseBackgroundColorInEffect) | 1315 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V
isibleSelection& selection, bool shouldUseBackgroundColorInEffect) |
1316 { | 1316 { |
1317 if (selection.isNone()) | 1317 if (selection.isNone()) |
1318 return nullptr; | 1318 return nullptr; |
(...skipping 13 matching lines...) Expand all Loading... |
1332 return nullptr; | 1332 return nullptr; |
1333 | 1333 |
1334 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi
ngStyle::AllProperties); | 1334 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi
ngStyle::AllProperties); |
1335 style->mergeTypingStyle(&element->document()); | 1335 style->mergeTypingStyle(&element->document()); |
1336 | 1336 |
1337 // If background color is transparent, traverse parent nodes until we hit a
different value or document root | 1337 // If background color is transparent, traverse parent nodes until we hit a
different value or document root |
1338 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, | 1338 // Also, if the selection is a range, ignore the background color at the sta
rt of selection, |
1339 // and find the background color of the common ancestor. | 1339 // and find the background color of the common ancestor. |
1340 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { | 1340 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare
ntBackgroundColor(style->m_mutableStyle.get()))) { |
1341 const EphemeralRange range(selection.toNormalizedEphemeralRange()); | 1341 const EphemeralRange range(selection.toNormalizedEphemeralRange()); |
1342 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorInEffect(Ran
ge::commonAncestorContainer(range.startPosition().computeContainerNode(), range.
endPosition().computeContainerNode()))) | 1342 if (PassRefPtr<CSSValue> value = backgroundColorInEffect(Range::commonAn
cestorContainer(range.startPosition().computeContainerNode(), range.endPosition(
).computeContainerNode()))) |
1343 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); | 1343 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
1344 } | 1344 } |
1345 | 1345 |
1346 return style; | 1346 return style; |
1347 } | 1347 } |
1348 | 1348 |
1349 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) | 1349 WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
selection, EditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings) |
1350 { | 1350 { |
1351 hasNestedOrMultipleEmbeddings = true; | 1351 hasNestedOrMultipleEmbeddings = true; |
1352 | 1352 |
(...skipping 10 matching lines...) Expand all Loading... |
1363 if (selection.isRange()) { | 1363 if (selection.isRange()) { |
1364 end = mostBackwardCaretPosition(selection.end()); | 1364 end = mostBackwardCaretPosition(selection.end()); |
1365 | 1365 |
1366 ASSERT(end.document()); | 1366 ASSERT(end.document()); |
1367 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE
quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); | 1367 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE
quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); |
1368 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { | 1368 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { |
1369 if (!n->isStyledElement()) | 1369 if (!n->isStyledElement()) |
1370 continue; | 1370 continue; |
1371 | 1371 |
1372 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS
tyleDeclaration::create(n); | 1372 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS
tyleDeclaration::create(n); |
1373 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValu
e(CSSPropertyUnicodeBidi); | 1373 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropert
yUnicodeBidi); |
1374 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1374 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
1375 continue; | 1375 continue; |
1376 | 1376 |
1377 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())
->getValueID(); | 1377 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())
->getValueID(); |
1378 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu
eBidiOverride) | 1378 if (unicodeBidiValue == CSSValueEmbed || unicodeBidiValue == CSSValu
eBidiOverride) |
1379 return NaturalWritingDirection; | 1379 return NaturalWritingDirection; |
1380 } | 1380 } |
1381 } | 1381 } |
1382 | 1382 |
1383 if (selection.isCaret()) { | 1383 if (selection.isCaret()) { |
1384 WritingDirection direction; | 1384 WritingDirection direction; |
1385 if (typingStyle && typingStyle->textDirection(direction)) { | 1385 if (typingStyle && typingStyle->textDirection(direction)) { |
1386 hasNestedOrMultipleEmbeddings = false; | 1386 hasNestedOrMultipleEmbeddings = false; |
1387 return direction; | 1387 return direction; |
1388 } | 1388 } |
1389 node = selection.visibleStart().deepEquivalent().anchorNode(); | 1389 node = selection.visibleStart().deepEquivalent().anchorNode(); |
1390 } | 1390 } |
1391 | 1391 |
1392 // 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 | 1392 // 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 |
1393 // to decide. | 1393 // to decide. |
1394 Node* block = enclosingBlock(node); | 1394 Node* block = enclosingBlock(node); |
1395 WritingDirection foundDirection = NaturalWritingDirection; | 1395 WritingDirection foundDirection = NaturalWritingDirection; |
1396 | 1396 |
1397 for (; node != block; node = node->parentNode()) { | 1397 for (; node != block; node = node->parentNode()) { |
1398 if (!node->isStyledElement()) | 1398 if (!node->isStyledElement()) |
1399 continue; | 1399 continue; |
1400 | 1400 |
1401 Element* element = toElement(node); | 1401 Element* element = toElement(node); |
1402 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle
Declaration::create(element); | 1402 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle
Declaration::create(element); |
1403 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CS
SPropertyUnicodeBidi); | 1403 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni
codeBidi); |
1404 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1404 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) |
1405 continue; | 1405 continue; |
1406 | 1406 |
1407 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge
tValueID(); | 1407 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge
tValueID(); |
1408 if (unicodeBidiValue == CSSValueNormal) | 1408 if (unicodeBidiValue == CSSValueNormal) |
1409 continue; | 1409 continue; |
1410 | 1410 |
1411 if (unicodeBidiValue == CSSValueBidiOverride) | 1411 if (unicodeBidiValue == CSSValueBidiOverride) |
1412 return NaturalWritingDirection; | 1412 return NaturalWritingDirection; |
1413 | 1413 |
1414 ASSERT(unicodeBidiValue == CSSValueEmbed); | 1414 ASSERT(unicodeBidiValue == CSSValueEmbed); |
1415 RefPtrWillBeRawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSP
ropertyDirection); | 1415 RefPtr<CSSValue> direction = style->getPropertyCSSValue(CSSPropertyDirec
tion); |
1416 if (!direction || !direction->isPrimitiveValue()) | 1416 if (!direction || !direction->isPrimitiveValue()) |
1417 continue; | 1417 continue; |
1418 | 1418 |
1419 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); | 1419 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); |
1420 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) | 1420 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) |
1421 continue; | 1421 continue; |
1422 | 1422 |
1423 if (foundDirection != NaturalWritingDirection) | 1423 if (foundDirection != NaturalWritingDirection) |
1424 return NaturalWritingDirection; | 1424 return NaturalWritingDirection; |
1425 | 1425 |
1426 // In the range case, make sure that the embedding element persists unti
l the end of the range. | 1426 // In the range case, make sure that the embedding element persists unti
l the end of the range. |
1427 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element)) | 1427 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element)) |
1428 return NaturalWritingDirection; | 1428 return NaturalWritingDirection; |
1429 | 1429 |
1430 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; | 1430 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec
tion : RightToLeftWritingDirection; |
1431 } | 1431 } |
1432 hasNestedOrMultipleEmbeddings = false; | 1432 hasNestedOrMultipleEmbeddings = false; |
1433 return foundDirection; | 1433 return foundDirection; |
1434 } | 1434 } |
1435 | 1435 |
1436 DEFINE_TRACE(EditingStyle) | 1436 DEFINE_TRACE(EditingStyle) |
1437 { | 1437 { |
1438 visitor->trace(m_mutableStyle); | 1438 visitor->trace(m_mutableStyle); |
1439 } | 1439 } |
1440 | 1440 |
1441 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) | 1441 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) |
1442 { | 1442 { |
1443 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSS
Value(CSSPropertyWebkitTextDecorationsInEffect); | 1443 RefPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro
pertyWebkitTextDecorationsInEffect); |
1444 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex
tDecorationPropertyForEditing()); | 1444 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); |
1445 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. | 1445 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef
fect because that wouldn't make sense. |
1446 ASSERT(!textDecorationsInEffect || !textDecoration); | 1446 ASSERT(!textDecorationsInEffect || !textDecoration); |
1447 if (textDecorationsInEffect) { | 1447 if (textDecorationsInEffect) { |
1448 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn
Effect->cssText()); | 1448 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn
Effect->cssText()); |
1449 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); | 1449 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
1450 textDecoration = textDecorationsInEffect; | 1450 textDecoration = textDecorationsInEffect; |
1451 } | 1451 } |
1452 | 1452 |
1453 // If text-decoration is set to "none", remove the property because we don't
want to add redundant "text-decoration: none". | 1453 // If text-decoration is set to "none", remove the property because we don't
want to add redundant "text-decoration: none". |
1454 if (textDecoration && !textDecoration->isValueList()) | 1454 if (textDecoration && !textDecoration->isValueList()) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 } | 1510 } |
1511 | 1511 |
1512 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1512 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
1513 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1513 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
1514 style->removeProperty(CSSPropertyFontStyle); | 1514 style->removeProperty(CSSPropertyFontStyle); |
1515 m_applyItalic = true; | 1515 m_applyItalic = true; |
1516 } | 1516 } |
1517 | 1517 |
1518 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect | 1518 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect |
1519 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. | 1519 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. |
1520 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex
tDecorationPropertyForEditing()); | 1520 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP
ropertyForEditing()); |
1521 if (textDecoration && textDecoration->isValueList()) { | 1521 if (textDecoration && textDecoration->isValueList()) { |
1522 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP
rimitiveValue::createIdentifier(CSSValueUnderline))); | 1522 DEFINE_STATIC_REF(CSSPrimitiveValue, underline, (CSSPrimitiveValue::crea
teIdentifier(CSSValueUnderline))); |
1523 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS
SPrimitiveValue::createIdentifier(CSSValueLineThrough))); | 1523 DEFINE_STATIC_REF(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::cr
eateIdentifier(CSSValueLineThrough))); |
1524 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text
Decoration.get())->copy(); | 1524 RefPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.g
et())->copy(); |
1525 if (newTextDecoration->removeAll(underline)) | 1525 if (newTextDecoration->removeAll(underline)) |
1526 m_applyUnderline = true; | 1526 m_applyUnderline = true; |
1527 if (newTextDecoration->removeAll(lineThrough)) | 1527 if (newTextDecoration->removeAll(lineThrough)) |
1528 m_applyLineThrough = true; | 1528 m_applyLineThrough = true; |
1529 | 1529 |
1530 // If trimTextDecorations, delete underline and line-through | 1530 // If trimTextDecorations, delete underline and line-through |
1531 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration
PropertyForEditing()); | 1531 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration
PropertyForEditing()); |
1532 } | 1532 } |
1533 | 1533 |
1534 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); | 1534 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); |
(...skipping 11 matching lines...) Expand all Loading... |
1546 if (style->getPropertyCSSValue(CSSPropertyColor)) { | 1546 if (style->getPropertyCSSValue(CSSPropertyColor)) { |
1547 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); | 1547 m_applyFontColor = Color(getRGBAFontColor(style)).serialized(); |
1548 style->removeProperty(CSSPropertyColor); | 1548 style->removeProperty(CSSPropertyColor); |
1549 } | 1549 } |
1550 | 1550 |
1551 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); | 1551 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); |
1552 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 | 1552 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 |
1553 m_applyFontFace.replaceWithLiteral('\'', ""); | 1553 m_applyFontFace.replaceWithLiteral('\'', ""); |
1554 style->removeProperty(CSSPropertyFontFamily); | 1554 style->removeProperty(CSSPropertyFontFamily); |
1555 | 1555 |
1556 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr
opertyFontSize)) { | 1556 if (RefPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPropertyFontSi
ze)) { |
1557 if (!fontSize->isPrimitiveValue()) { | 1557 if (!fontSize->isPrimitiveValue()) { |
1558 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. | 1558 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. |
1559 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize.get()), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelV
aluesMatch)) { | 1559 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize.get()), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelV
aluesMatch)) { |
1560 m_applyFontSize = String::number(legacyFontSize); | 1560 m_applyFontSize = String::number(legacyFontSize); |
1561 style->removeProperty(CSSPropertyFontSize); | 1561 style->removeProperty(CSSPropertyFontSize); |
1562 } | 1562 } |
1563 } | 1563 } |
1564 } | 1564 } |
1565 | 1565 |
1566 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertID, CSSValue* refTextDecoration) | 1566 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertID, CSSValue* refTextDecoration) |
1567 { | 1567 { |
1568 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(pro
pertID); | 1568 RefPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID); |
1569 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) | 1569 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) |
1570 return; | 1570 return; |
1571 | 1571 |
1572 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco
ration.get())->copy(); | 1572 RefPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.get()
)->copy(); |
1573 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); | 1573 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); |
1574 | 1574 |
1575 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) | 1575 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) |
1576 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); | 1576 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); |
1577 | 1577 |
1578 setTextDecorationProperty(style, newTextDecoration.get(), propertID); | 1578 setTextDecorationProperty(style, newTextDecoration.get(), propertID); |
1579 } | 1579 } |
1580 | 1580 |
1581 static bool fontWeightIsBold(CSSValue* fontWeight) | 1581 static bool fontWeightIsBold(CSSValue* fontWeight) |
1582 { | 1582 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 } | 1617 } |
1618 | 1618 |
1619 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) | 1619 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) |
1620 { | 1620 { |
1621 ASSERT(styleWithRedundantProperties); | 1621 ASSERT(styleWithRedundantProperties); |
1622 ASSERT(baseStyle); | 1622 ASSERT(baseStyle); |
1623 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope
rties->mutableCopy(); | 1623 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope
rties->mutableCopy(); |
1624 | 1624 |
1625 result->removeEquivalentProperties(baseStyle); | 1625 result->removeEquivalentProperties(baseStyle); |
1626 | 1626 |
1627 RefPtrWillBeRawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPro
pertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect); | 1627 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu
eInternal(CSSPropertyWebkitTextDecorationsInEffect); |
1628 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe
xtDecorationsInEffect.get()); | 1628 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe
xtDecorationsInEffect.get()); |
1629 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); | 1629 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect,
baseTextDecorationsInEffect.get()); |
1630 | 1630 |
1631 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV
alueInternal(CSSPropertyFontWeight)) { | 1631 if (RefPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSValueInternal
(CSSPropertyFontWeight)) { |
1632 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu
e(CSSPropertyFontWeight)) { | 1632 if (RefPtr<CSSValue> fontWeight = result->getPropertyCSSValue(CSSPropert
yFontWeight)) { |
1633 if (!fontWeightNeedsResolving(fontWeight.get()) && !fontWeightNeedsR
esolving(baseFontWeight.get()) | 1633 if (!fontWeightNeedsResolving(fontWeight.get()) && !fontWeightNeedsR
esolving(baseFontWeight.get()) |
1634 && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseF
ontWeight.get()))) | 1634 && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseF
ontWeight.get()))) |
1635 result->removeProperty(CSSPropertyFontWeight); | 1635 result->removeProperty(CSSPropertyFontWeight); |
1636 } | 1636 } |
1637 } | 1637 } |
1638 | 1638 |
1639 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) | 1639 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC
olor(result.get()) == getRGBAFontColor(baseStyle)) |
1640 result->removeProperty(CSSPropertyColor); | 1640 result->removeProperty(CSSPropertyColor); |
1641 | 1641 |
1642 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1642 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
1643 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) | 1643 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar
tAndEnd(baseStyle)) |
1644 result->removeProperty(CSSPropertyTextAlign); | 1644 result->removeProperty(CSSPropertyTextAlign); |
1645 | 1645 |
1646 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) | 1646 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge
tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) |
1647 result->removeProperty(CSSPropertyBackgroundColor); | 1647 result->removeProperty(CSSPropertyBackgroundColor); |
1648 | 1648 |
1649 return result.release(); | 1649 return result.release(); |
1650 } | 1650 } |
1651 | 1651 |
1652 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) | 1652 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
1653 { | 1653 { |
1654 if (!style) | 1654 if (!style) |
1655 return CSSValueInvalid; | 1655 return CSSValueInvalid; |
1656 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); | 1656 RefPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); |
1657 if (!value || !value->isPrimitiveValue()) | 1657 if (!value || !value->isPrimitiveValue()) |
1658 return CSSValueInvalid; | 1658 return CSSValueInvalid; |
1659 return toCSSPrimitiveValue(value.get())->getValueID(); | 1659 return toCSSPrimitiveValue(value.get())->getValueID(); |
1660 } | 1660 } |
1661 | 1661 |
1662 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) | 1662 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) |
1663 { | 1663 { |
1664 if (!style) | 1664 if (!style) |
1665 return CSSValueInvalid; | 1665 return CSSValueInvalid; |
1666 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValueInternal(prop
ertyID); | 1666 RefPtr<CSSValue> value = style->getPropertyCSSValueInternal(propertyID); |
1667 if (!value || !value->isPrimitiveValue()) | 1667 if (!value || !value->isPrimitiveValue()) |
1668 return CSSValueInvalid; | 1668 return CSSValueInvalid; |
1669 return toCSSPrimitiveValue(value.get())->getValueID(); | 1669 return toCSSPrimitiveValue(value.get())->getValueID(); |
1670 } | 1670 } |
1671 | 1671 |
1672 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
l isMonospaceFont, LegacyFontSizeMode mode) | 1672 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo
l isMonospaceFont, LegacyFontSizeMode mode) |
1673 { | 1673 { |
1674 CSSPrimitiveValue::LengthUnitType lengthType; | 1674 CSSPrimitiveValue::LengthUnitType lengthType; |
1675 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(
), lengthType) | 1675 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(
), lengthType) |
1676 && lengthType == CSSPrimitiveValue::UnitTypePixels) { | 1676 && lengthType == CSSPrimitiveValue::UnitTypePixels) { |
(...skipping 20 matching lines...) Expand all Loading... |
1697 if (!cssValue->isPrimitiveValue()) | 1697 if (!cssValue->isPrimitiveValue()) |
1698 return false; | 1698 return false; |
1699 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); | 1699 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); |
1700 if (value->isRGBColor()) | 1700 if (value->isRGBColor()) |
1701 return !alphaChannel(value->getRGBA32Value()); | 1701 return !alphaChannel(value->getRGBA32Value()); |
1702 return value->getValueID() == CSSValueTransparent; | 1702 return value->getValueID() == CSSValueTransparent; |
1703 } | 1703 } |
1704 | 1704 |
1705 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) | 1705 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) |
1706 { | 1706 { |
1707 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(C
SSPropertyBackgroundColor); | 1707 RefPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa
ckgroundColor); |
1708 return isTransparentColorValue(cssValue.get()); | 1708 return isTransparentColorValue(cssValue.get()); |
1709 } | 1709 } |
1710 | 1710 |
1711 bool hasTransparentBackgroundColor(StylePropertySet* style) | 1711 bool hasTransparentBackgroundColor(StylePropertySet* style) |
1712 { | 1712 { |
1713 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSProper
tyBackgroundColor); | 1713 RefPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackground
Color); |
1714 return isTransparentColorValue(cssValue.get()); | 1714 return isTransparentColorValue(cssValue.get()); |
1715 } | 1715 } |
1716 | 1716 |
1717 PassRefPtrWillBeRawPtr<CSSValue> backgroundColorInEffect(Node* node) | 1717 PassRefPtr<CSSValue> backgroundColorInEffect(Node* node) |
1718 { | 1718 { |
1719 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1719 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1720 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1720 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
1721 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1721 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1722 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1722 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
1723 } | 1723 } |
1724 return nullptr; | 1724 return nullptr; |
1725 } | 1725 } |
1726 | 1726 |
1727 } | 1727 } |
OLD | NEW |