| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 if (type == AllEditingProperties) | 133 if (type == AllEditingProperties) |
| 134 return style->copyPropertiesInSet(allEditingProperties()); | 134 return style->copyPropertiesInSet(allEditingProperties()); |
| 135 return style->copyPropertiesInSet(inheritableEditingProperties()); | 135 return style->copyPropertiesInSet(inheritableEditingProperties()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 static inline bool isEditingProperty(int id) | 138 static inline bool isEditingProperty(int id) |
| 139 { | 139 { |
| 140 return allEditingProperties().contains(static_cast<CSSPropertyID>(id)); | 140 return allEditingProperties().contains(static_cast<CSSPropertyID>(id)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 static RawPtr<MutableStylePropertySet> editingStyleFromComputedStyle(RawPtr<CSSC
omputedStyleDeclaration> style, EditingPropertiesType type = OnlyInheritableEdit
ingProperties) | 143 static MutableStylePropertySet* editingStyleFromComputedStyle(RawPtr<CSSComputed
StyleDeclaration> style, EditingPropertiesType type = OnlyInheritableEditingProp
erties) |
| 144 { | 144 { |
| 145 if (!style) | 145 if (!style) |
| 146 return MutableStylePropertySet::create(HTMLQuirksMode); | 146 return MutableStylePropertySet::create(HTMLQuirksMode); |
| 147 return copyEditingProperties(style.get(), type); | 147 return copyEditingProperties(style.get(), type); |
| 148 } | 148 } |
| 149 | 149 |
| 150 static RawPtr<CSSComputedStyleDeclaration> ensureComputedStyle(const Position& p
osition) | 150 static RawPtr<CSSComputedStyleDeclaration> ensureComputedStyle(const Position& p
osition) |
| 151 { | 151 { |
| 152 Element* elem = associatedElementOf(position); | 152 Element* elem = associatedElementOf(position); |
| 153 if (!elem) | 153 if (!elem) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 286 } |
| 287 | 287 |
| 288 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
edName& attrName) | 288 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi
edName& attrName) |
| 289 : HTMLElementEquivalent(id) | 289 : HTMLElementEquivalent(id) |
| 290 , m_attrName(attrName) | 290 , m_attrName(attrName) |
| 291 { | 291 { |
| 292 } | 292 } |
| 293 | 293 |
| 294 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP
ropertySet* style) const | 294 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP
ropertySet* style) const |
| 295 { | 295 { |
| 296 RawPtr<CSSValue> value = attributeValueAsCSSValue(element); | 296 CSSValue* value = attributeValueAsCSSValue(element); |
| 297 RawPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_propertyID); | 297 CSSValue* styleValue = style->getPropertyCSSValue(m_propertyID); |
| 298 | 298 |
| 299 return compareCSSValuePtr(value, styleValue); | 299 return compareCSSValuePtr(value, styleValue); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
const | 302 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style)
const |
| 303 { | 303 { |
| 304 if (RawPtr<CSSValue> value = attributeValueAsCSSValue(element)) | 304 if (RawPtr<CSSValue> value = attributeValueAsCSSValue(element)) |
| 305 style->setProperty(m_propertyID, value->cssText()); | 305 style->setProperty(m_propertyID, value->cssText()); |
| 306 } | 306 } |
| 307 | 307 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 return toCSSColorValue(colorValue)->value(); | 400 return toCSSColorValue(colorValue)->value(); |
| 401 | 401 |
| 402 Color color = 0; | 402 Color color = 0; |
| 403 // FIXME: Why ignore the return value? | 403 // FIXME: Why ignore the return value? |
| 404 CSSParser::parseColor(color, colorValue->cssText()); | 404 CSSParser::parseColor(color, colorValue->cssText()); |
| 405 return color; | 405 return color; |
| 406 } | 406 } |
| 407 | 407 |
| 408 static inline Color getFontColor(CSSStyleDeclaration* style) | 408 static inline Color getFontColor(CSSStyleDeclaration* style) |
| 409 { | 409 { |
| 410 return cssValueToColor(style->getPropertyCSSValueInternal(CSSPropertyColor).
get()); | 410 return cssValueToColor(style->getPropertyCSSValueInternal(CSSPropertyColor))
; |
| 411 } | 411 } |
| 412 | 412 |
| 413 static inline Color getFontColor(StylePropertySet* style) | 413 static inline Color getFontColor(StylePropertySet* style) |
| 414 { | 414 { |
| 415 return cssValueToColor(style->getPropertyCSSValue(CSSPropertyColor).get()); | 415 return cssValueToColor(style->getPropertyCSSValue(CSSPropertyColor)); |
| 416 } | 416 } |
| 417 | 417 |
| 418 static inline Color getBackgroundColor(CSSStyleDeclaration* style) | 418 static inline Color getBackgroundColor(CSSStyleDeclaration* style) |
| 419 { | 419 { |
| 420 return cssValueToColor(style->getPropertyCSSValueInternal(CSSPropertyBackgro
undColor).get()); | 420 return cssValueToColor(style->getPropertyCSSValueInternal(CSSPropertyBackgro
undColor)); |
| 421 } | 421 } |
| 422 | 422 |
| 423 static inline Color getBackgroundColor(StylePropertySet* style) | 423 static inline Color getBackgroundColor(StylePropertySet* style) |
| 424 { | 424 { |
| 425 return cssValueToColor(style->getPropertyCSSValue(CSSPropertyBackgroundColor
).get()); | 425 return cssValueToColor(style->getPropertyCSSValue(CSSPropertyBackgroundColor
)); |
| 426 } | 426 } |
| 427 | 427 |
| 428 static inline Color backgroundColorInEffect(Node* node) | 428 static inline Color backgroundColorInEffect(Node* node) |
| 429 { | 429 { |
| 430 return cssValueToColor(backgroundColorValueInEffect(node).get()); | 430 return cssValueToColor(backgroundColorValueInEffect(node)); |
| 431 } | 431 } |
| 432 | 432 |
| 433 static int textAlignResolvingStartAndEnd(int textAlign, int direction) | 433 static int textAlignResolvingStartAndEnd(int textAlign, int direction) |
| 434 { | 434 { |
| 435 switch (textAlign) { | 435 switch (textAlign) { |
| 436 case CSSValueCenter: | 436 case CSSValueCenter: |
| 437 case CSSValueWebkitCenter: | 437 case CSSValueWebkitCenter: |
| 438 return CSSValueCenter; | 438 return CSSValueCenter; |
| 439 case CSSValueJustify: | 439 case CSSValueJustify: |
| 440 return CSSValueJustify; | 440 return CSSValueJustify; |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 equivalent->addToStyle(element, extractedStyle); | 921 equivalent->addToStyle(element, extractedStyle); |
| 922 conflictingAttributes.append(equivalent->attributeName()); | 922 conflictingAttributes.append(equivalent->attributeName()); |
| 923 removed = true; | 923 removed = true; |
| 924 } | 924 } |
| 925 | 925 |
| 926 return removed; | 926 return removed; |
| 927 } | 927 } |
| 928 | 928 |
| 929 bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const | 929 bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const |
| 930 { | 930 { |
| 931 return !m_mutableStyle || getPropertiesNotIn(m_mutableStyle.get(), CSSComput
edStyleDeclaration::create(node).get())->isEmpty(); | 931 return !m_mutableStyle || getPropertiesNotIn(m_mutableStyle.get(), CSSComput
edStyleDeclaration::create(node))->isEmpty(); |
| 932 } | 932 } |
| 933 | 933 |
| 934 bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* elemen
t) | 934 bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* elemen
t) |
| 935 { | 935 { |
| 936 ASSERT(element); | 936 ASSERT(element); |
| 937 bool elementIsSpanOrElementEquivalent = false; | 937 bool elementIsSpanOrElementEquivalent = false; |
| 938 if (isHTMLSpanElement(*element)) { | 938 if (isHTMLSpanElement(*element)) { |
| 939 elementIsSpanOrElementEquivalent = true; | 939 elementIsSpanOrElementEquivalent = true; |
| 940 } else { | 940 } else { |
| 941 const HeapVector<Member<HTMLElementEquivalent>>& HTMLElementEquivalents
= htmlElementEquivalents(); | 941 const HeapVector<Member<HTMLElementEquivalent>>& HTMLElementEquivalents
= htmlElementEquivalents(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 { | 985 { |
| 986 if (!m_mutableStyle) | 986 if (!m_mutableStyle) |
| 987 return; | 987 return; |
| 988 | 988 |
| 989 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. | 989 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. |
| 990 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate | 990 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate |
| 991 // which one of editingStyleAtPosition or computedStyle is called. | 991 // which one of editingStyleAtPosition or computedStyle is called. |
| 992 RawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::create(position,
EditingPropertiesInEffect); | 992 RawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::create(position,
EditingPropertiesInEffect); |
| 993 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); | 993 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g
et(); |
| 994 | 994 |
| 995 RawPtr<CSSValue> unicodeBidi = nullptr; | 995 CSSValue* unicodeBidi = nullptr; |
| 996 RawPtr<CSSValue> direction = nullptr; | 996 CSSValue* direction = nullptr; |
| 997 if (shouldPreserveWritingDirection == PreserveWritingDirection) { | 997 if (shouldPreserveWritingDirection == PreserveWritingDirection) { |
| 998 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); | 998 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi
); |
| 999 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); | 999 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 m_mutableStyle->removeEquivalentProperties(styleAtPosition); | 1002 m_mutableStyle->removeEquivalentProperties(styleAtPosition); |
| 1003 | 1003 |
| 1004 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) | 1004 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin
gStartAndEnd(styleAtPosition)) |
| 1005 m_mutableStyle->removeProperty(CSSPropertyTextAlign); | 1005 m_mutableStyle->removeProperty(CSSPropertyTextAlign); |
| 1006 | 1006 |
| 1007 if (getFontColor(m_mutableStyle.get()) == getFontColor(styleAtPosition)) | 1007 if (getFontColor(m_mutableStyle.get()) == getFontColor(styleAtPosition)) |
| 1008 m_mutableStyle->removeProperty(CSSPropertyColor); | 1008 m_mutableStyle->removeProperty(CSSPropertyColor); |
| 1009 | 1009 |
| 1010 if (hasTransparentBackgroundColor(m_mutableStyle.get()) | 1010 if (hasTransparentBackgroundColor(m_mutableStyle.get()) |
| 1011 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgr
oundColor).get()) == backgroundColorInEffect(position.computeContainerNode())) | 1011 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgr
oundColor)) == backgroundColorInEffect(position.computeContainerNode())) |
| 1012 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); | 1012 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); |
| 1013 | 1013 |
| 1014 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { | 1014 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { |
| 1015 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(
unicodeBidi.get())->getValueID()); | 1015 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue(
unicodeBidi)->getValueID()); |
| 1016 if (direction && direction->isPrimitiveValue()) | 1016 if (direction && direction->isPrimitiveValue()) |
| 1017 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu
e(direction.get())->getValueID()); | 1017 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu
e(direction)->getValueID()); |
| 1018 } | 1018 } |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 void EditingStyle::mergeTypingStyle(Document* document) | 1021 void EditingStyle::mergeTypingStyle(Document* document) |
| 1022 { | 1022 { |
| 1023 ASSERT(document); | 1023 ASSERT(document); |
| 1024 | 1024 |
| 1025 RawPtr<EditingStyle> typingStyle = document->frame()->selection().typingStyl
e(); | 1025 RawPtr<EditingStyle> typingStyle = document->frame()->selection().typingStyl
e(); |
| 1026 if (!typingStyle || typingStyle == this) | 1026 if (!typingStyle || typingStyle == this) |
| 1027 return; | 1027 return; |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 { | 1724 { |
| 1725 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1725 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1726 RawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); | 1726 RawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl
aration::create(ancestor); |
| 1727 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1727 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1728 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1728 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1729 } | 1729 } |
| 1730 return nullptr; | 1730 return nullptr; |
| 1731 } | 1731 } |
| 1732 | 1732 |
| 1733 } // namespace blink | 1733 } // namespace blink |
| OLD | NEW |