| 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 12 matching lines...) Expand all Loading... |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/editing/EditingStyle.h" | 27 #include "core/editing/EditingStyle.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
| 31 #include "core/css/CSSColorValue.h" | 31 #include "core/css/CSSColorValue.h" |
| 32 #include "core/css/CSSComputedStyleDeclaration.h" | 32 #include "core/css/CSSComputedStyleDeclaration.h" |
| 33 #include "core/css/CSSIdentifierValue.h" |
| 33 #include "core/css/CSSPrimitiveValue.h" | 34 #include "core/css/CSSPrimitiveValue.h" |
| 34 #include "core/css/CSSPrimitiveValueMappings.h" | 35 #include "core/css/CSSPrimitiveValueMappings.h" |
| 35 #include "core/css/CSSPropertyMetadata.h" | 36 #include "core/css/CSSPropertyMetadata.h" |
| 36 #include "core/css/CSSRuleList.h" | 37 #include "core/css/CSSRuleList.h" |
| 37 #include "core/css/CSSStyleRule.h" | 38 #include "core/css/CSSStyleRule.h" |
| 38 #include "core/css/CSSValueList.h" | 39 #include "core/css/CSSValueList.h" |
| 39 #include "core/css/FontSize.h" | 40 #include "core/css/FontSize.h" |
| 40 #include "core/css/StylePropertySet.h" | 41 #include "core/css/StylePropertySet.h" |
| 41 #include "core/css/StyleRule.h" | 42 #include "core/css/StyleRule.h" |
| 42 #include "core/css/parser/CSSParser.h" | 43 #include "core/css/parser/CSSParser.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 static CSSComputedStyleDeclaration* ensureComputedStyle(const Position& position
) | 153 static CSSComputedStyleDeclaration* ensureComputedStyle(const Position& position
) |
| 153 { | 154 { |
| 154 Element* elem = associatedElementOf(position); | 155 Element* elem = associatedElementOf(position); |
| 155 if (!elem) | 156 if (!elem) |
| 156 return nullptr; | 157 return nullptr; |
| 157 return CSSComputedStyleDeclaration::create(elem); | 158 return CSSComputedStyleDeclaration::create(elem); |
| 158 } | 159 } |
| 159 | 160 |
| 160 static MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRe
dundantProperties, CSSStyleDeclaration* baseStyle); | 161 static MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRe
dundantProperties, CSSStyleDeclaration* baseStyle); |
| 161 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; | 162 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; |
| 162 static int legacyFontSizeFromCSSValue(Document*, const CSSPrimitiveValue*, bool,
LegacyFontSizeMode); | 163 static int legacyFontSizeFromCSSValue(Document*, const CSSValue*, bool, LegacyFo
ntSizeMode); |
| 163 static bool isTransparentColorValue(const CSSValue*); | 164 static bool isTransparentColorValue(const CSSValue*); |
| 164 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); | 165 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); |
| 165 static bool hasTransparentBackgroundColor(StylePropertySet*); | 166 static bool hasTransparentBackgroundColor(StylePropertySet*); |
| 166 static const CSSValue* backgroundColorValueInEffect(Node*); | 167 static const CSSValue* backgroundColorValueInEffect(Node*); |
| 167 static bool hasAncestorVerticalAlignStyle(Node&, CSSValueID); | 168 static bool hasAncestorVerticalAlignStyle(Node&, CSSValueID); |
| 168 | 169 |
| 169 class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> { | 170 class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> { |
| 170 public: | 171 public: |
| 171 static HTMLElementEquivalent* create(CSSPropertyID propertyID, CSSValueID pr
imitiveValue, const HTMLQualifiedName& tagName) | 172 static HTMLElementEquivalent* create(CSSPropertyID propertyID, CSSValueID pr
imitiveValue, const HTMLQualifiedName& tagName) |
| 172 { | 173 { |
| 173 return new HTMLElementEquivalent(propertyID, primitiveValue, tagName); | 174 return new HTMLElementEquivalent(propertyID, primitiveValue, tagName); |
| 174 } | 175 } |
| 175 | 176 |
| 176 virtual bool matches(const Element* element) const { return !m_tagName || el
ement->hasTagName(*m_tagName); } | 177 virtual bool matches(const Element* element) const { return !m_tagName || el
ement->hasTagName(*m_tagName); } |
| 177 virtual bool hasAttribute() const { return false; } | 178 virtual bool hasAttribute() const { return false; } |
| 178 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re
turn style->getPropertyCSSValue(m_propertyID); } | 179 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re
turn style->getPropertyCSSValue(m_propertyID); } |
| 179 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const; | 180 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const; |
| 180 virtual void addToStyle(Element*, EditingStyle*) const; | 181 virtual void addToStyle(Element*, EditingStyle*) const; |
| 181 | 182 |
| 182 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_primitiveValue); } | 183 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_identifierValue); } |
| 183 | 184 |
| 184 protected: | 185 protected: |
| 185 HTMLElementEquivalent(CSSPropertyID); | 186 HTMLElementEquivalent(CSSPropertyID); |
| 186 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName); | 187 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName); |
| 187 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu
alifiedName& tagName); | 188 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu
alifiedName& tagName); |
| 188 const CSSPropertyID m_propertyID; | 189 const CSSPropertyID m_propertyID; |
| 189 const Member<CSSPrimitiveValue> m_primitiveValue; | 190 const Member<CSSIdentifierValue> m_identifierValue; |
| 190 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t
ag names are const global. | 191 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t
ag names are const global. |
| 191 }; | 192 }; |
| 192 | 193 |
| 193 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id) | 194 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id) |
| 194 : m_propertyID(id) | 195 : m_propertyID(id) |
| 195 , m_tagName(0) | 196 , m_tagName(0) |
| 196 { | 197 { |
| 197 } | 198 } |
| 198 | 199 |
| 199 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi
edName& tagName) | 200 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi
edName& tagName) |
| 200 : m_propertyID(id) | 201 : m_propertyID(id) |
| 201 , m_tagName(&tagName) | 202 , m_tagName(&tagName) |
| 202 { | 203 { |
| 203 } | 204 } |
| 204 | 205 |
| 205 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit
iveValue, const HTMLQualifiedName& tagName) | 206 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID valueI
D, const HTMLQualifiedName& tagName) |
| 206 : m_propertyID(id) | 207 : m_propertyID(id) |
| 207 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) | 208 , m_identifierValue(CSSIdentifierValue::create(valueID)) |
| 208 , m_tagName(&tagName) | 209 , m_tagName(&tagName) |
| 209 { | 210 { |
| 210 DCHECK_NE(primitiveValue, CSSValueInvalid); | 211 DCHECK_NE(valueID, CSSValueInvalid); |
| 211 } | 212 } |
| 212 | 213 |
| 213 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro
pertySet* style) const | 214 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro
pertySet* style) const |
| 214 { | 215 { |
| 215 const CSSValue* value = style->getPropertyCSSValue(m_propertyID); | 216 const CSSValue* value = style->getPropertyCSSValue(m_propertyID); |
| 216 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit
iveValue(value)->getValueID() == m_primitiveValue->getValueID(); | 217 return matches(element) && value && value->isIdentifierValue() && toCSSIdent
ifierValue(value)->getValueID() == m_identifierValue->getValueID(); |
| 217 } | 218 } |
| 218 | 219 |
| 219 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const | 220 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const |
| 220 { | 221 { |
| 221 style->setProperty(m_propertyID, m_primitiveValue->cssText()); | 222 style->setProperty(m_propertyID, m_identifierValue->cssText()); |
| 222 } | 223 } |
| 223 | 224 |
| 224 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { | 225 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { |
| 225 public: | 226 public: |
| 226 static HTMLElementEquivalent* create(CSSValueID primitiveValue, const HTMLQu
alifiedName& tagName) | 227 static HTMLElementEquivalent* create(CSSValueID primitiveValue, const HTMLQu
alifiedName& tagName) |
| 227 { | 228 { |
| 228 return new HTMLTextDecorationEquivalent(primitiveValue, tagName); | 229 return new HTMLTextDecorationEquivalent(primitiveValue, tagName); |
| 229 } | 230 } |
| 230 bool propertyExistsInStyle(const StylePropertySet*) const override; | 231 bool propertyExistsInStyle(const StylePropertySet*) const override; |
| 231 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override; | 232 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 246 { | 247 { |
| 247 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) | 248 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) |
| 248 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); | 249 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); |
| 249 } | 250 } |
| 250 | 251 |
| 251 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S
tylePropertySet* style) const | 252 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S
tylePropertySet* style) const |
| 252 { | 253 { |
| 253 const CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTex
tDecorationsInEffect); | 254 const CSSValue* styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTex
tDecorationsInEffect); |
| 254 if (!styleValue) | 255 if (!styleValue) |
| 255 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing
()); | 256 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing
()); |
| 256 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue)->hasValue(*m_primitiveValue); | 257 return matches(element) && styleValue && styleValue->isValueList() && toCSSV
alueList(styleValue)->hasValue(*m_identifierValue); |
| 257 } | 258 } |
| 258 | 259 |
| 259 class HTMLAttributeEquivalent : public HTMLElementEquivalent { | 260 class HTMLAttributeEquivalent : public HTMLElementEquivalent { |
| 260 public: | 261 public: |
| 261 static HTMLAttributeEquivalent* create(CSSPropertyID propertyID, const HTMLQ
ualifiedName& tagName, const QualifiedName& attrName) | 262 static HTMLAttributeEquivalent* create(CSSPropertyID propertyID, const HTMLQ
ualifiedName& tagName, const QualifiedName& attrName) |
| 262 { | 263 { |
| 263 return new HTMLAttributeEquivalent(propertyID, tagName, attrName); | 264 return new HTMLAttributeEquivalent(propertyID, tagName, attrName); |
| 264 } | 265 } |
| 265 static HTMLAttributeEquivalent* create(CSSPropertyID propertyID, const Quali
fiedName& attrName) | 266 static HTMLAttributeEquivalent* create(CSSPropertyID propertyID, const Quali
fiedName& attrName) |
| 266 { | 267 { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 343 |
| 343 const CSSValue* HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* elemen
t) const | 344 const CSSValue* HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* elemen
t) const |
| 344 { | 345 { |
| 345 DCHECK(element); | 346 DCHECK(element); |
| 346 const AtomicString& value = element->getAttribute(m_attrName); | 347 const AtomicString& value = element->getAttribute(m_attrName); |
| 347 if (value.isNull()) | 348 if (value.isNull()) |
| 348 return nullptr; | 349 return nullptr; |
| 349 CSSValueID size; | 350 CSSValueID size; |
| 350 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) | 351 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) |
| 351 return nullptr; | 352 return nullptr; |
| 352 return CSSPrimitiveValue::createIdentifier(size); | 353 return CSSIdentifierValue::create(size); |
| 353 } | 354 } |
| 354 | 355 |
| 355 float EditingStyle::NoFontDelta = 0.0f; | 356 float EditingStyle::NoFontDelta = 0.0f; |
| 356 | 357 |
| 357 EditingStyle::EditingStyle(ContainerNode* node, PropertiesToInclude propertiesTo
Include) | 358 EditingStyle::EditingStyle(ContainerNode* node, PropertiesToInclude propertiesTo
Include) |
| 358 { | 359 { |
| 359 init(node, propertiesToInclude); | 360 init(node, propertiesToInclude); |
| 360 } | 361 } |
| 361 | 362 |
| 362 EditingStyle::EditingStyle(const Position& position, PropertiesToInclude propert
iesToInclude) | 363 EditingStyle::EditingStyle(const Position& position, PropertiesToInclude propert
iesToInclude) |
| 363 { | 364 { |
| 364 init(position.anchorNode(), propertiesToInclude); | 365 init(position.anchorNode(), propertiesToInclude); |
| 365 } | 366 } |
| 366 | 367 |
| 367 EditingStyle::EditingStyle(const StylePropertySet* style) | 368 EditingStyle::EditingStyle(const StylePropertySet* style) |
| 368 : m_mutableStyle(style ? style->mutableCopy() : nullptr) | 369 : m_mutableStyle(style ? style->mutableCopy() : nullptr) |
| 369 { | 370 { |
| 370 extractFontSizeDelta(); | 371 extractFontSizeDelta(); |
| 371 } | 372 } |
| 372 | 373 |
| 373 EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value) | 374 EditingStyle::EditingStyle(CSSPropertyID propertyID, const String& value) |
| 374 : m_mutableStyle(nullptr) | 375 : m_mutableStyle(nullptr) |
| 375 { | 376 { |
| 376 setProperty(propertyID, value); | 377 setProperty(propertyID, value); |
| 377 m_isVerticalAlign = propertyID == CSSPropertyVerticalAlign && (value == "sub
" || value == "super"); | 378 m_isVerticalAlign = propertyID == CSSPropertyVerticalAlign && (value == "sub
" || value == "super"); |
| 378 } | 379 } |
| 379 | 380 |
| 380 static Color cssValueToColor(const CSSValue* colorValue) | 381 static Color cssValueToColor(const CSSValue* colorValue) |
| 381 { | 382 { |
| 382 if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveV
alue())) | 383 if (!colorValue || (!colorValue->isColorValue() && !colorValue->isPrimitiveV
alue() && !colorValue->isIdentifierValue())) |
| 383 return Color::transparent; | 384 return Color::transparent; |
| 384 | 385 |
| 385 if (colorValue->isColorValue()) | 386 if (colorValue->isColorValue()) |
| 386 return toCSSColorValue(colorValue)->value(); | 387 return toCSSColorValue(colorValue)->value(); |
| 387 | 388 |
| 388 Color color = 0; | 389 Color color = 0; |
| 389 // FIXME: Why ignore the return value? | 390 // FIXME: Why ignore the return value? |
| 390 CSSParser::parseColor(color, colorValue->cssText()); | 391 CSSParser::parseColor(color, colorValue->cssText()); |
| 391 return color; | 392 return color; |
| 392 } | 393 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 { | 529 { |
| 529 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta ==
NoFontDelta; | 530 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta ==
NoFontDelta; |
| 530 } | 531 } |
| 531 | 532 |
| 532 bool EditingStyle::textDirection(WritingDirection& writingDirection) const | 533 bool EditingStyle::textDirection(WritingDirection& writingDirection) const |
| 533 { | 534 { |
| 534 if (!m_mutableStyle) | 535 if (!m_mutableStyle) |
| 535 return false; | 536 return false; |
| 536 | 537 |
| 537 const CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropert
yUnicodeBidi); | 538 const CSSValue* unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropert
yUnicodeBidi); |
| 538 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 539 if (!unicodeBidi || !unicodeBidi->isIdentifierValue()) |
| 539 return false; | 540 return false; |
| 540 | 541 |
| 541 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValueID()
; | 542 CSSValueID unicodeBidiValue = toCSSIdentifierValue(unicodeBidi)->getValueID(
); |
| 542 if (isEmbedOrIsolate(unicodeBidiValue)) { | 543 if (isEmbedOrIsolate(unicodeBidiValue)) { |
| 543 const CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPrope
rtyDirection); | 544 const CSSValue* direction = m_mutableStyle->getPropertyCSSValue(CSSPrope
rtyDirection); |
| 544 if (!direction || !direction->isPrimitiveValue()) | 545 if (!direction || !direction->isIdentifierValue()) |
| 545 return false; | 546 return false; |
| 546 | 547 |
| 547 writingDirection = toCSSPrimitiveValue(direction)->getValueID() == CSSVa
lueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; | 548 writingDirection = toCSSIdentifierValue(direction)->getValueID() == CSSV
alueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; |
| 548 | 549 |
| 549 return true; | 550 return true; |
| 550 } | 551 } |
| 551 | 552 |
| 552 if (unicodeBidiValue == CSSValueNormal) { | 553 if (unicodeBidiValue == CSSValueNormal) { |
| 553 writingDirection = NaturalWritingDirection; | 554 writingDirection = NaturalWritingDirection; |
| 554 return true; | 555 return true; |
| 555 } | 556 } |
| 556 | 557 |
| 557 return false; | 558 return false; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 TriState state = FalseTriState; | 748 TriState state = FalseTriState; |
| 748 bool nodeIsStart = true; | 749 bool nodeIsStart = true; |
| 749 for (Node& node : NodeTraversal::startsAt(*selection.start().anchorNode()))
{ | 750 for (Node& node : NodeTraversal::startsAt(*selection.start().anchorNode()))
{ |
| 750 if (node.layoutObject() && hasEditableStyle(node)) { | 751 if (node.layoutObject() && hasEditableStyle(node)) { |
| 751 CSSComputedStyleDeclaration* nodeStyle = CSSComputedStyleDeclaration
::create(&node); | 752 CSSComputedStyleDeclaration* nodeStyle = CSSComputedStyleDeclaration
::create(&node); |
| 752 if (nodeStyle) { | 753 if (nodeStyle) { |
| 753 // If the selected element has <sub> or <sup> ancestor element,
apply the corresponding | 754 // If the selected element has <sub> or <sup> ancestor element,
apply the corresponding |
| 754 // style(vertical-align) to it so that document.queryCommandStat
e() works with the style. | 755 // style(vertical-align) to it so that document.queryCommandStat
e() works with the style. |
| 755 // See bug http://crbug.com/582225. | 756 // See bug http://crbug.com/582225. |
| 756 if (m_isVerticalAlign && getIdentifierValue(nodeStyle, CSSProper
tyVerticalAlign) == CSSValueBaseline) { | 757 if (m_isVerticalAlign && getIdentifierValue(nodeStyle, CSSProper
tyVerticalAlign) == CSSValueBaseline) { |
| 757 const CSSPrimitiveValue* verticalAlign = toCSSPrimitiveValue
(m_mutableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign)); | 758 const CSSIdentifierValue* verticalAlign = toCSSIdentifierVal
ue(m_mutableStyle->getPropertyCSSValue(CSSPropertyVerticalAlign)); |
| 758 if (hasAncestorVerticalAlignStyle(node, verticalAlign->getVa
lueID())) | 759 if (hasAncestorVerticalAlignStyle(node, verticalAlign->getVa
lueID())) |
| 759 node.mutableComputedStyle()->setVerticalAlign(verticalAl
ign->convertTo<EVerticalAlign>()); | 760 node.mutableComputedStyle()->setVerticalAlign(verticalAl
ign->convertTo<EVerticalAlign>()); |
| 760 } | 761 } |
| 761 | 762 |
| 762 // Pass EditingStyle::DoNotIgnoreTextOnlyProperties without chec
king if node.isTextNode() | 763 // Pass EditingStyle::DoNotIgnoreTextOnlyProperties without chec
king if node.isTextNode() |
| 763 // because the node can be an element node. See bug http://crbug
.com/584939. | 764 // because the node can be an element node. See bug http://crbug
.com/584939. |
| 764 TriState nodeState = triStateOfStyle(nodeStyle, EditingStyle::Do
NotIgnoreTextOnlyProperties); | 765 TriState nodeState = triStateOfStyle(nodeStyle, EditingStyle::Do
NotIgnoreTextOnlyProperties); |
| 765 if (nodeIsStart) { | 766 if (nodeIsStart) { |
| 766 state = nodeState; | 767 state = nodeState; |
| 767 nodeIsStart = false; | 768 nodeIsStart = false; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) | 1013 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) |
| 1013 m_mutableStyle->removeProperty(CSSPropertyTextAlign); | 1014 m_mutableStyle->removeProperty(CSSPropertyTextAlign); |
| 1014 | 1015 |
| 1015 if (getFontColor(m_mutableStyle.get()) == getFontColor(styleAtPosition)) | 1016 if (getFontColor(m_mutableStyle.get()) == getFontColor(styleAtPosition)) |
| 1016 m_mutableStyle->removeProperty(CSSPropertyColor); | 1017 m_mutableStyle->removeProperty(CSSPropertyColor); |
| 1017 | 1018 |
| 1018 if (hasTransparentBackgroundColor(m_mutableStyle.get()) | 1019 if (hasTransparentBackgroundColor(m_mutableStyle.get()) |
| 1019 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgr
oundColor)) == backgroundColorInEffect(position.computeContainerNode())) | 1020 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgr
oundColor)) == backgroundColorInEffect(position.computeContainerNode())) |
| 1020 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); | 1021 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); |
| 1021 | 1022 |
| 1022 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { | 1023 if (unicodeBidi && unicodeBidi->isIdentifierValue()) { |
| 1023 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(
unicodeBidi)->getValueID()); | 1024 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSIdentifierValue
(unicodeBidi)->getValueID()); |
| 1024 if (direction && direction->isPrimitiveValue()) | 1025 if (direction && direction->isIdentifierValue()) |
| 1025 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu
e(direction)->getValueID()); | 1026 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSIdentifierVal
ue(direction)->getValueID()); |
| 1026 } | 1027 } |
| 1027 } | 1028 } |
| 1028 | 1029 |
| 1029 void EditingStyle::mergeTypingStyle(Document* document) | 1030 void EditingStyle::mergeTypingStyle(Document* document) |
| 1030 { | 1031 { |
| 1031 DCHECK(document); | 1032 DCHECK(document); |
| 1032 | 1033 |
| 1033 EditingStyle* typingStyle = document->frame()->selection().typingStyle(); | 1034 EditingStyle* typingStyle = document->frame()->selection().typingStyle(); |
| 1034 if (!typingStyle || typingStyle == this) | 1035 if (!typingStyle || typingStyle == this) |
| 1035 return; | 1036 return; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node)
, EditingStyle::DoNotOverrideValues, | 1136 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(&node)
, EditingStyle::DoNotOverrideValues, |
| 1136 EditingStyle::EditingPropertiesInEffect); | 1137 EditingStyle::EditingPropertiesInEffect); |
| 1137 } | 1138 } |
| 1138 } | 1139 } |
| 1139 | 1140 |
| 1140 return wrappingStyle; | 1141 return wrappingStyle; |
| 1141 } | 1142 } |
| 1142 | 1143 |
| 1143 static const CSSValueList& mergeTextDecorationValues(const CSSValueList& mergedV
alue, const CSSValueList& valueToMerge) | 1144 static const CSSValueList& mergeTextDecorationValues(const CSSValueList& mergedV
alue, const CSSValueList& valueToMerge) |
| 1144 { | 1145 { |
| 1145 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::create
Identifier(CSSValueUnderline))); | 1146 DEFINE_STATIC_LOCAL(CSSIdentifierValue, underline, (CSSIdentifierValue::crea
te(CSSValueUnderline))); |
| 1146 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::crea
teIdentifier(CSSValueLineThrough))); | 1147 DEFINE_STATIC_LOCAL(CSSIdentifierValue, lineThrough, (CSSIdentifierValue::cr
eate(CSSValueLineThrough))); |
| 1147 CSSValueList& result = *mergedValue.copy(); | 1148 CSSValueList& result = *mergedValue.copy(); |
| 1148 if (valueToMerge.hasValue(underline) && !mergedValue.hasValue(underline)) | 1149 if (valueToMerge.hasValue(underline) && !mergedValue.hasValue(underline)) |
| 1149 result.append(underline); | 1150 result.append(underline); |
| 1150 | 1151 |
| 1151 if (valueToMerge.hasValue(lineThrough) && !mergedValue.hasValue(lineThrough)
) | 1152 if (valueToMerge.hasValue(lineThrough) && !mergedValue.hasValue(lineThrough)
) |
| 1152 result.append(lineThrough); | 1153 result.append(lineThrough); |
| 1153 | 1154 |
| 1154 return result; | 1155 return result; |
| 1155 } | 1156 } |
| 1156 | 1157 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 { | 1318 { |
| 1318 if (!m_mutableStyle) | 1319 if (!m_mutableStyle) |
| 1319 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode); | 1320 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode); |
| 1320 const bool propertyIsImportant = true; | 1321 const bool propertyIsImportant = true; |
| 1321 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); | 1322 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); |
| 1322 } | 1323 } |
| 1323 | 1324 |
| 1324 int EditingStyle::legacyFontSize(Document* document) const | 1325 int EditingStyle::legacyFontSize(Document* document) const |
| 1325 { | 1326 { |
| 1326 const CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFo
ntSize); | 1327 const CSSValue* cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyFo
ntSize); |
| 1327 if (!cssValue || !cssValue->isPrimitiveValue()) | 1328 if (!cssValue || !(cssValue->isPrimitiveValue() || cssValue->isIdentifierVal
ue())) |
| 1328 return 0; | 1329 return 0; |
| 1329 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue), | 1330 return legacyFontSizeFromCSSValue(document, cssValue, m_isMonospaceFont, Alw
aysUseLegacyFontSize); |
| 1330 m_isMonospaceFont, AlwaysUseLegacyFontSize); | |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 EditingStyle* EditingStyle::styleAtSelectionStart(const VisibleSelection& select
ion, bool shouldUseBackgroundColorInEffect, MutableStylePropertySet* styleToChec
k) | 1333 EditingStyle* EditingStyle::styleAtSelectionStart(const VisibleSelection& select
ion, bool shouldUseBackgroundColorInEffect, MutableStylePropertySet* styleToChec
k) |
| 1334 { | 1334 { |
| 1335 if (selection.isNone()) | 1335 if (selection.isNone()) |
| 1336 return nullptr; | 1336 return nullptr; |
| 1337 | 1337 |
| 1338 Document& document = *selection.start().document(); | 1338 Document& document = *selection.start().document(); |
| 1339 | 1339 |
| 1340 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 1340 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 end = mostBackwardCaretPosition(selection.end()); | 1408 end = mostBackwardCaretPosition(selection.end()); |
| 1409 | 1409 |
| 1410 DCHECK(end.document()); | 1410 DCHECK(end.document()); |
| 1411 const EphemeralRange caretRange(position.parentAnchoredEquivalent(), end
.parentAnchoredEquivalent()); | 1411 const EphemeralRange caretRange(position.parentAnchoredEquivalent(), end
.parentAnchoredEquivalent()); |
| 1412 for (Node& n : caretRange.nodes()) { | 1412 for (Node& n : caretRange.nodes()) { |
| 1413 if (!n.isStyledElement()) | 1413 if (!n.isStyledElement()) |
| 1414 continue; | 1414 continue; |
| 1415 | 1415 |
| 1416 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::cr
eate(&n); | 1416 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::cr
eate(&n); |
| 1417 const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSProperty
UnicodeBidi); | 1417 const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSProperty
UnicodeBidi); |
| 1418 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1418 if (!unicodeBidi || !unicodeBidi->isIdentifierValue()) |
| 1419 continue; | 1419 continue; |
| 1420 | 1420 |
| 1421 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getV
alueID(); | 1421 CSSValueID unicodeBidiValue = toCSSIdentifierValue(unicodeBidi)->get
ValueID(); |
| 1422 if (isUnicodeBidiNestedOrMultipleEmbeddings(unicodeBidiValue)) | 1422 if (isUnicodeBidiNestedOrMultipleEmbeddings(unicodeBidiValue)) |
| 1423 return NaturalWritingDirection; | 1423 return NaturalWritingDirection; |
| 1424 } | 1424 } |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 if (selection.isCaret()) { | 1427 if (selection.isCaret()) { |
| 1428 WritingDirection direction; | 1428 WritingDirection direction; |
| 1429 if (typingStyle && typingStyle->textDirection(direction)) { | 1429 if (typingStyle && typingStyle->textDirection(direction)) { |
| 1430 hasNestedOrMultipleEmbeddings = false; | 1430 hasNestedOrMultipleEmbeddings = false; |
| 1431 return direction; | 1431 return direction; |
| 1432 } | 1432 } |
| 1433 node = selection.visibleStart().deepEquivalent().anchorNode(); | 1433 node = selection.visibleStart().deepEquivalent().anchorNode(); |
| 1434 } | 1434 } |
| 1435 DCHECK(node); | 1435 DCHECK(node); |
| 1436 | 1436 |
| 1437 // 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 | 1437 // 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 |
| 1438 // to decide. | 1438 // to decide. |
| 1439 Node* block = enclosingBlock(node); | 1439 Node* block = enclosingBlock(node); |
| 1440 WritingDirection foundDirection = NaturalWritingDirection; | 1440 WritingDirection foundDirection = NaturalWritingDirection; |
| 1441 | 1441 |
| 1442 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { | 1442 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { |
| 1443 if (runner == block) | 1443 if (runner == block) |
| 1444 break; | 1444 break; |
| 1445 if (!runner.isStyledElement()) | 1445 if (!runner.isStyledElement()) |
| 1446 continue; | 1446 continue; |
| 1447 | 1447 |
| 1448 Element* element = &toElement(runner); | 1448 Element* element = &toElement(runner); |
| 1449 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create
(element); | 1449 CSSComputedStyleDeclaration* style = CSSComputedStyleDeclaration::create
(element); |
| 1450 const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnic
odeBidi); | 1450 const CSSValue* unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnic
odeBidi); |
| 1451 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) | 1451 if (!unicodeBidi || !unicodeBidi->isIdentifierValue()) |
| 1452 continue; | 1452 continue; |
| 1453 | 1453 |
| 1454 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi)->getValue
ID(); | 1454 CSSValueID unicodeBidiValue = toCSSIdentifierValue(unicodeBidi)->getValu
eID(); |
| 1455 if (unicodeBidiValue == CSSValueNormal) | 1455 if (unicodeBidiValue == CSSValueNormal) |
| 1456 continue; | 1456 continue; |
| 1457 | 1457 |
| 1458 if (unicodeBidiValue == CSSValueBidiOverride) | 1458 if (unicodeBidiValue == CSSValueBidiOverride) |
| 1459 return NaturalWritingDirection; | 1459 return NaturalWritingDirection; |
| 1460 | 1460 |
| 1461 DCHECK(isEmbedOrIsolate(unicodeBidiValue)) << unicodeBidiValue; | 1461 DCHECK(isEmbedOrIsolate(unicodeBidiValue)) << unicodeBidiValue; |
| 1462 const CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirect
ion); | 1462 const CSSValue* direction = style->getPropertyCSSValue(CSSPropertyDirect
ion); |
| 1463 if (!direction || !direction->isPrimitiveValue()) | 1463 if (!direction || !direction->isIdentifierValue()) |
| 1464 continue; | 1464 continue; |
| 1465 | 1465 |
| 1466 int directionValue = toCSSPrimitiveValue(direction)->getValueID(); | 1466 int directionValue = toCSSIdentifierValue(direction)->getValueID(); |
| 1467 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) | 1467 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) |
| 1468 continue; | 1468 continue; |
| 1469 | 1469 |
| 1470 if (foundDirection != NaturalWritingDirection) | 1470 if (foundDirection != NaturalWritingDirection) |
| 1471 return NaturalWritingDirection; | 1471 return NaturalWritingDirection; |
| 1472 | 1472 |
| 1473 // In the range case, make sure that the embedding element persists unti
l the end of the range. | 1473 // In the range case, make sure that the embedding element persists unti
l the end of the range. |
| 1474 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element)) | 1474 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element)) |
| 1475 return NaturalWritingDirection; | 1475 return NaturalWritingDirection; |
| 1476 | 1476 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); | 1559 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); |
| 1560 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { | 1560 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { |
| 1561 style->removeProperty(CSSPropertyFontStyle); | 1561 style->removeProperty(CSSPropertyFontStyle); |
| 1562 m_applyItalic = true; | 1562 m_applyItalic = true; |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect | 1565 // Assuming reconcileTextDecorationProperties has been called, there should
not be -webkit-text-decorations-in-effect |
| 1566 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. | 1566 // Furthermore, text-decoration: none has been trimmed so that text-decorati
on property is always a CSSValueList. |
| 1567 const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPr
opertyForEditing()); | 1567 const CSSValue* textDecoration = style->getPropertyCSSValue(textDecorationPr
opertyForEditing()); |
| 1568 if (textDecoration && textDecoration->isValueList()) { | 1568 if (textDecoration && textDecoration->isValueList()) { |
| 1569 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, underline, (CSSPrimitiveValue::cr
eateIdentifier(CSSValueUnderline))); | 1569 DEFINE_STATIC_LOCAL(CSSIdentifierValue, underline, (CSSIdentifierValue::
create(CSSValueUnderline))); |
| 1570 DEFINE_STATIC_LOCAL(CSSPrimitiveValue, lineThrough, (CSSPrimitiveValue::
createIdentifier(CSSValueLineThrough))); | 1570 DEFINE_STATIC_LOCAL(CSSIdentifierValue, lineThrough, (CSSIdentifierValue
::create(CSSValueLineThrough))); |
| 1571 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy()
; | 1571 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy()
; |
| 1572 if (newTextDecoration->removeAll(underline)) | 1572 if (newTextDecoration->removeAll(underline)) |
| 1573 m_applyUnderline = true; | 1573 m_applyUnderline = true; |
| 1574 if (newTextDecoration->removeAll(lineThrough)) | 1574 if (newTextDecoration->removeAll(lineThrough)) |
| 1575 m_applyLineThrough = true; | 1575 m_applyLineThrough = true; |
| 1576 | 1576 |
| 1577 // If trimTextDecorations, delete underline and line-through | 1577 // If trimTextDecorations, delete underline and line-through |
| 1578 setTextDecorationProperty(style, newTextDecoration, textDecorationProper
tyForEditing()); | 1578 setTextDecorationProperty(style, newTextDecoration, textDecorationProper
tyForEditing()); |
| 1579 } | 1579 } |
| 1580 | 1580 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1594 m_applyFontColor = getFontColor(style).serialized(); | 1594 m_applyFontColor = getFontColor(style).serialized(); |
| 1595 style->removeProperty(CSSPropertyColor); | 1595 style->removeProperty(CSSPropertyColor); |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); | 1598 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); |
| 1599 // Remove double quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 | 1599 // Remove double quotes for Outlook 2007 compatibility. See https://bugs.web
kit.org/show_bug.cgi?id=79448 |
| 1600 m_applyFontFace.replace('"', ""); | 1600 m_applyFontFace.replace('"', ""); |
| 1601 style->removeProperty(CSSPropertyFontFamily); | 1601 style->removeProperty(CSSPropertyFontFamily); |
| 1602 | 1602 |
| 1603 if (const CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSiz
e)) { | 1603 if (const CSSValue* fontSize = style->getPropertyCSSValue(CSSPropertyFontSiz
e)) { |
| 1604 if (!fontSize->isPrimitiveValue()) { | 1604 if (!fontSize->isPrimitiveValue() && !fontSize->isIdentifierValue()) { |
| 1605 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. | 1605 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t
he number. Put no font size. |
| 1606 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC
SSPrimitiveValue(fontSize), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesM
atch)) { | 1606 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, fon
tSize, isMonospaceFont, UseLegacyFontSizeOnlyIfPixelValuesMatch)) { |
| 1607 m_applyFontSize = String::number(legacyFontSize); | 1607 m_applyFontSize = String::number(legacyFontSize); |
| 1608 style->removeProperty(CSSPropertyFontSize); | 1608 style->removeProperty(CSSPropertyFontSize); |
| 1609 } | 1609 } |
| 1610 } | 1610 } |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertyID, const CSSValue* refTextDecoration) | 1613 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr
opertyID, const CSSValue* refTextDecoration) |
| 1614 { | 1614 { |
| 1615 const CSSValue* textDecoration = style->getPropertyCSSValue(propertyID); | 1615 const CSSValue* textDecoration = style->getPropertyCSSValue(propertyID); |
| 1616 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) | 1616 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration
|| !refTextDecoration->isValueList()) |
| 1617 return; | 1617 return; |
| 1618 | 1618 |
| 1619 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy(); | 1619 CSSValueList* newTextDecoration = toCSSValueList(textDecoration)->copy(); |
| 1620 const CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecora
tion); | 1620 const CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecora
tion); |
| 1621 | 1621 |
| 1622 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) | 1622 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) |
| 1623 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); | 1623 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); |
| 1624 | 1624 |
| 1625 setTextDecorationProperty(style, newTextDecoration, propertyID); | 1625 setTextDecorationProperty(style, newTextDecoration, propertyID); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 static bool fontWeightIsBold(const CSSValue* fontWeight) | 1628 static bool fontWeightIsBold(const CSSValue* fontWeight) |
| 1629 { | 1629 { |
| 1630 if (!fontWeight->isPrimitiveValue()) | 1630 if (!fontWeight->isIdentifierValue()) |
| 1631 return false; | 1631 return false; |
| 1632 | 1632 |
| 1633 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. | 1633 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. |
| 1634 // Collapse all other values to either one of these two states for editing p
urposes. | 1634 // Collapse all other values to either one of these two states for editing p
urposes. |
| 1635 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { | 1635 switch (toCSSIdentifierValue(fontWeight)->getValueID()) { |
| 1636 case CSSValue100: | 1636 case CSSValue100: |
| 1637 case CSSValue200: | 1637 case CSSValue200: |
| 1638 case CSSValue300: | 1638 case CSSValue300: |
| 1639 case CSSValue400: | 1639 case CSSValue400: |
| 1640 case CSSValue500: | 1640 case CSSValue500: |
| 1641 case CSSValueNormal: | 1641 case CSSValueNormal: |
| 1642 return false; | 1642 return false; |
| 1643 case CSSValueBold: | 1643 case CSSValueBold: |
| 1644 case CSSValue600: | 1644 case CSSValue600: |
| 1645 case CSSValue700: | 1645 case CSSValue700: |
| 1646 case CSSValue800: | 1646 case CSSValue800: |
| 1647 case CSSValue900: | 1647 case CSSValue900: |
| 1648 return true; | 1648 return true; |
| 1649 default: | 1649 default: |
| 1650 break; | 1650 break; |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 NOTREACHED(); // For CSSValueBolder and CSSValueLighter | 1653 NOTREACHED(); // For CSSValueBolder and CSSValueLighter |
| 1654 return false; | 1654 return false; |
| 1655 } | 1655 } |
| 1656 | 1656 |
| 1657 static bool fontWeightNeedsResolving(const CSSValue* fontWeight) | 1657 static bool fontWeightNeedsResolving(const CSSValue* fontWeight) |
| 1658 { | 1658 { |
| 1659 if (!fontWeight->isPrimitiveValue()) | 1659 if (!fontWeight->isIdentifierValue()) |
| 1660 return true; | 1660 return true; |
| 1661 | 1661 |
| 1662 const CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); | 1662 const CSSValueID value = toCSSIdentifierValue(fontWeight)->getValueID(); |
| 1663 return value == CSSValueLighter || value == CSSValueBolder; | 1663 return value == CSSValueLighter || value == CSSValueBolder; |
| 1664 } | 1664 } |
| 1665 | 1665 |
| 1666 MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundant
Properties, CSSStyleDeclaration* baseStyle) | 1666 MutableStylePropertySet* getPropertiesNotIn(StylePropertySet* styleWithRedundant
Properties, CSSStyleDeclaration* baseStyle) |
| 1667 { | 1667 { |
| 1668 DCHECK(styleWithRedundantProperties); | 1668 DCHECK(styleWithRedundantProperties); |
| 1669 DCHECK(baseStyle); | 1669 DCHECK(baseStyle); |
| 1670 MutableStylePropertySet* result = styleWithRedundantProperties->mutableCopy(
); | 1670 MutableStylePropertySet* result = styleWithRedundantProperties->mutableCopy(
); |
| 1671 | 1671 |
| 1672 result->removeEquivalentProperties(baseStyle); | 1672 result->removeEquivalentProperties(baseStyle); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1694 result->removeProperty(CSSPropertyBackgroundColor); | 1694 result->removeProperty(CSSPropertyBackgroundColor); |
| 1695 | 1695 |
| 1696 return result; | 1696 return result; |
| 1697 } | 1697 } |
| 1698 | 1698 |
| 1699 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) | 1699 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) |
| 1700 { | 1700 { |
| 1701 if (!style) | 1701 if (!style) |
| 1702 return CSSValueInvalid; | 1702 return CSSValueInvalid; |
| 1703 const CSSValue* value = style->getPropertyCSSValue(propertyID); | 1703 const CSSValue* value = style->getPropertyCSSValue(propertyID); |
| 1704 if (!value || !value->isPrimitiveValue()) | 1704 if (!value || !value->isIdentifierValue()) |
| 1705 return CSSValueInvalid; | 1705 return CSSValueInvalid; |
| 1706 return toCSSPrimitiveValue(value)->getValueID(); | 1706 return toCSSIdentifierValue(value)->getValueID(); |
| 1707 } | 1707 } |
| 1708 | 1708 |
| 1709 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) | 1709 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property
ID) |
| 1710 { | 1710 { |
| 1711 if (!style) | 1711 if (!style) |
| 1712 return CSSValueInvalid; | 1712 return CSSValueInvalid; |
| 1713 const CSSValue* value = style->getPropertyCSSValueInternal(propertyID); | 1713 const CSSValue* value = style->getPropertyCSSValueInternal(propertyID); |
| 1714 if (!value || !value->isPrimitiveValue()) | 1714 if (!value || !value->isIdentifierValue()) |
| 1715 return CSSValueInvalid; | 1715 return CSSValueInvalid; |
| 1716 return toCSSPrimitiveValue(value)->getValueID(); | 1716 return toCSSIdentifierValue(value)->getValueID(); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 int legacyFontSizeFromCSSValue(Document* document, const CSSPrimitiveValue* valu
e, bool isMonospaceFont, LegacyFontSizeMode mode) | 1719 int legacyFontSizeFromCSSValue(Document* document, const CSSValue* value, bool i
sMonospaceFont, LegacyFontSizeMode mode) |
| 1720 { | 1720 { |
| 1721 CSSPrimitiveValue::LengthUnitType lengthType; | 1721 if (value->isPrimitiveValue()) { |
| 1722 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved(
), lengthType) | 1722 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(*value); |
| 1723 && lengthType == CSSPrimitiveValue::UnitTypePixels) { | 1723 CSSPrimitiveValue::LengthUnitType lengthType; |
| 1724 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsScaleFa
ctor(value->typeWithCalcResolved()); | 1724 if (CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.typeWithC
alcResolved(), lengthType) |
| 1725 int pixelFontSize = clampTo<int>(value->getDoubleValue() * conversion); | 1725 && lengthType == CSSPrimitiveValue::UnitTypePixels) { |
| 1726 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSize, i
sMonospaceFont); | 1726 double conversion = CSSPrimitiveValue::conversionToCanonicalUnitsSca
leFactor(primitiveValue.typeWithCalcResolved()); |
| 1727 // Use legacy font size only if pixel value matches exactly to that of l
egacy font size. | 1727 int pixelFontSize = clampTo<int>(primitiveValue.getDoubleValue() * c
onversion); |
| 1728 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(docu
ment, legacyFontSize, isMonospaceFont) == pixelFontSize) | 1728 int legacyFontSize = FontSize::legacyFontSize(document, pixelFontSiz
e, isMonospaceFont); |
| 1729 return legacyFontSize; | 1729 // Use legacy font size only if pixel value matches exactly to that
of legacy font size. |
| 1730 if (mode == AlwaysUseLegacyFontSize || FontSize::fontSizeForKeyword(
document, legacyFontSize, isMonospaceFont) == pixelFontSize) |
| 1731 return legacyFontSize; |
| 1730 | 1732 |
| 1731 return 0; | 1733 return 0; |
| 1734 } |
| 1732 } | 1735 } |
| 1733 | 1736 |
| 1734 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) | 1737 if (value->isIdentifierValue()) { |
| 1735 return value->getValueID() - CSSValueXSmall + 1; | 1738 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(*value)
; |
| 1739 if (CSSValueXSmall <= identifierValue.getValueID() && identifierValue.ge
tValueID() <= CSSValueWebkitXxxLarge) |
| 1740 return identifierValue.getValueID() - CSSValueXSmall + 1; |
| 1741 } |
| 1736 | 1742 |
| 1737 return 0; | 1743 return 0; |
| 1738 } | 1744 } |
| 1739 | 1745 |
| 1740 bool isTransparentColorValue(const CSSValue* cssValue) | 1746 bool isTransparentColorValue(const CSSValue* cssValue) |
| 1741 { | 1747 { |
| 1742 if (!cssValue) | 1748 if (!cssValue) |
| 1743 return true; | 1749 return true; |
| 1744 if (cssValue->isColorValue()) | 1750 if (cssValue->isColorValue()) |
| 1745 return !toCSSColorValue(cssValue)->value().alpha(); | 1751 return !toCSSColorValue(cssValue)->value().alpha(); |
| 1746 if (!cssValue->isPrimitiveValue()) | 1752 if (!cssValue->isIdentifierValue()) |
| 1747 return false; | 1753 return false; |
| 1748 const CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); | 1754 return toCSSIdentifierValue(cssValue)->getValueID() == CSSValueTransparent; |
| 1749 return value->getValueID() == CSSValueTransparent; | |
| 1750 } | 1755 } |
| 1751 | 1756 |
| 1752 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) | 1757 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) |
| 1753 { | 1758 { |
| 1754 const CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBac
kgroundColor); | 1759 const CSSValue* cssValue = style->getPropertyCSSValueInternal(CSSPropertyBac
kgroundColor); |
| 1755 return isTransparentColorValue(cssValue); | 1760 return isTransparentColorValue(cssValue); |
| 1756 } | 1761 } |
| 1757 | 1762 |
| 1758 bool hasTransparentBackgroundColor(StylePropertySet* style) | 1763 bool hasTransparentBackgroundColor(StylePropertySet* style) |
| 1759 { | 1764 { |
| 1760 const CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundC
olor); | 1765 const CSSValue* cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundC
olor); |
| 1761 return isTransparentColorValue(cssValue); | 1766 return isTransparentColorValue(cssValue); |
| 1762 } | 1767 } |
| 1763 | 1768 |
| 1764 const CSSValue* backgroundColorValueInEffect(Node* node) | 1769 const CSSValue* backgroundColorValueInEffect(Node* node) |
| 1765 { | 1770 { |
| 1766 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1771 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1767 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration
::create(ancestor); | 1772 CSSComputedStyleDeclaration* ancestorStyle = CSSComputedStyleDeclaration
::create(ancestor); |
| 1768 if (!hasTransparentBackgroundColor(ancestorStyle)) | 1773 if (!hasTransparentBackgroundColor(ancestorStyle)) |
| 1769 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1774 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1770 } | 1775 } |
| 1771 return nullptr; | 1776 return nullptr; |
| 1772 } | 1777 } |
| 1773 | 1778 |
| 1774 } // namespace blink | 1779 } // namespace blink |
| OLD | NEW |