| 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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 929 |
| 930 bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const | 930 bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const |
| 931 { | 931 { |
| 932 return !m_mutableStyle || getPropertiesNotIn(m_mutableStyle.get(), CSSComput
edStyleDeclaration::create(node).get())->isEmpty(); | 932 return !m_mutableStyle || getPropertiesNotIn(m_mutableStyle.get(), CSSComput
edStyleDeclaration::create(node).get())->isEmpty(); |
| 933 } | 933 } |
| 934 | 934 |
| 935 bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* elemen
t) | 935 bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* elemen
t) |
| 936 { | 936 { |
| 937 ASSERT(element); | 937 ASSERT(element); |
| 938 bool elementIsSpanOrElementEquivalent = false; | 938 bool elementIsSpanOrElementEquivalent = false; |
| 939 if (isHTMLSpanElement(*element)) | 939 if (isHTMLSpanElement(*element)) { |
| 940 elementIsSpanOrElementEquivalent = true; | 940 elementIsSpanOrElementEquivalent = true; |
| 941 else { | 941 } else { |
| 942 const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent>>& HTMLE
lementEquivalents = htmlElementEquivalents(); | 942 const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent>>& HTMLE
lementEquivalents = htmlElementEquivalents(); |
| 943 size_t i; | 943 size_t i; |
| 944 for (i = 0; i < HTMLElementEquivalents.size(); ++i) { | 944 for (i = 0; i < HTMLElementEquivalents.size(); ++i) { |
| 945 if (HTMLElementEquivalents[i]->matches(element)) { | 945 if (HTMLElementEquivalents[i]->matches(element)) { |
| 946 elementIsSpanOrElementEquivalent = true; | 946 elementIsSpanOrElementEquivalent = true; |
| 947 break; | 947 break; |
| 948 } | 948 } |
| 949 } | 949 } |
| 950 } | 950 } |
| 951 | 951 |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 // FIXME: Shouldn't this be done in getPropertiesNotIn? | 1484 // FIXME: Shouldn't this be done in getPropertiesNotIn? |
| 1485 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) | 1485 if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->sty
le()->getPropertyCSSValue(CSSPropertyDirection)) |
| 1486 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); | 1486 mutableStyle->setProperty(CSSPropertyDirection, style->style()->getPrope
rtyValue(CSSPropertyDirection)); |
| 1487 | 1487 |
| 1488 // Save the result for later | 1488 // Save the result for later |
| 1489 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); | 1489 m_cssStyle = mutableStyle->asText().stripWhiteSpace(); |
| 1490 } | 1490 } |
| 1491 | 1491 |
| 1492 static void setTextDecorationProperty(MutableStylePropertySet* style, const CSSV
alueList* newTextDecoration, CSSPropertyID propertyID) | 1492 static void setTextDecorationProperty(MutableStylePropertySet* style, const CSSV
alueList* newTextDecoration, CSSPropertyID propertyID) |
| 1493 { | 1493 { |
| 1494 if (newTextDecoration->length()) | 1494 if (newTextDecoration->length()) { |
| 1495 style->setProperty(propertyID, newTextDecoration->cssText(), style->prop
ertyIsImportant(propertyID)); | 1495 style->setProperty(propertyID, newTextDecoration->cssText(), style->prop
ertyIsImportant(propertyID)); |
| 1496 else { | 1496 } else { |
| 1497 // text-decoration: none is redundant since it does not remove any text
decorations. | 1497 // text-decoration: none is redundant since it does not remove any text |
| 1498 // decorations. |
| 1498 style->removeProperty(propertyID); | 1499 style->removeProperty(propertyID); |
| 1499 } | 1500 } |
| 1500 } | 1501 } |
| 1501 | 1502 |
| 1502 void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
style, bool isMonospaceFont) | 1503 void StyleChange::extractTextStyles(Document* document, MutableStylePropertySet*
style, bool isMonospaceFont) |
| 1503 { | 1504 { |
| 1504 ASSERT(style); | 1505 ASSERT(style); |
| 1505 | 1506 |
| 1506 if (getIdentifierValue(style, CSSPropertyFontWeight) == CSSValueBold) { | 1507 if (getIdentifierValue(style, CSSPropertyFontWeight) == CSSValueBold) { |
| 1507 style->removeProperty(CSSPropertyFontWeight); | 1508 style->removeProperty(CSSPropertyFontWeight); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 } | 1579 } |
| 1579 | 1580 |
| 1580 static bool fontWeightIsBold(CSSValue* fontWeight) | 1581 static bool fontWeightIsBold(CSSValue* fontWeight) |
| 1581 { | 1582 { |
| 1582 if (!fontWeight->isPrimitiveValue()) | 1583 if (!fontWeight->isPrimitiveValue()) |
| 1583 return false; | 1584 return false; |
| 1584 | 1585 |
| 1585 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. | 1586 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. |
| 1586 // Collapse all other values to either one of these two states for editing p
urposes. | 1587 // Collapse all other values to either one of these two states for editing p
urposes. |
| 1587 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { | 1588 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { |
| 1588 case CSSValue100: | 1589 case CSSValue100: |
| 1589 case CSSValue200: | 1590 case CSSValue200: |
| 1590 case CSSValue300: | 1591 case CSSValue300: |
| 1591 case CSSValue400: | 1592 case CSSValue400: |
| 1592 case CSSValue500: | 1593 case CSSValue500: |
| 1593 case CSSValueNormal: | 1594 case CSSValueNormal: |
| 1594 return false; | 1595 return false; |
| 1595 case CSSValueBold: | 1596 case CSSValueBold: |
| 1596 case CSSValue600: | 1597 case CSSValue600: |
| 1597 case CSSValue700: | 1598 case CSSValue700: |
| 1598 case CSSValue800: | 1599 case CSSValue800: |
| 1599 case CSSValue900: | 1600 case CSSValue900: |
| 1600 return true; | 1601 return true; |
| 1601 default: | 1602 default: |
| 1602 break; | 1603 break; |
| 1603 } | 1604 } |
| 1604 | 1605 |
| 1605 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter | 1606 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter |
| 1606 return false; | 1607 return false; |
| 1607 } | 1608 } |
| 1608 | 1609 |
| 1609 static bool fontWeightNeedsResolving(CSSValue* fontWeight) | 1610 static bool fontWeightNeedsResolving(CSSValue* fontWeight) |
| 1610 { | 1611 { |
| 1611 if (!fontWeight->isPrimitiveValue()) | 1612 if (!fontWeight->isPrimitiveValue()) |
| 1612 return true; | 1613 return true; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 { | 1717 { |
| 1717 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1718 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1718 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1719 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
| 1719 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1720 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1720 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1721 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1721 } | 1722 } |
| 1722 return nullptr; | 1723 return nullptr; |
| 1723 } | 1724 } |
| 1724 | 1725 |
| 1725 } | 1726 } |
| OLD | NEW |