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 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1485 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); | 1485 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); |
1486 | 1486 |
1487 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) | 1487 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) |
1488 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); | 1488 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); |
1489 | 1489 |
1490 setTextDecorationProperty(style, newTextDecoration.get(), propertID); | 1490 setTextDecorationProperty(style, newTextDecoration.get(), propertID); |
1491 } | 1491 } |
1492 | 1492 |
1493 static bool fontWeightIsBold(CSSValue* fontWeight) | 1493 static bool fontWeightIsBold(CSSValue* fontWeight) |
1494 { | 1494 { |
1495 if (!fontWeight) | |
1496 return false; | |
1497 if (!fontWeight->isPrimitiveValue()) | 1495 if (!fontWeight->isPrimitiveValue()) |
1498 return false; | 1496 return false; |
1499 | 1497 |
1500 // Because b tag can only bold text, there are only two states in plain html : bold and not bold. | 1498 // Because b tag can only bold text, there are only two states in plain html : bold and not bold. |
1501 // Collapse all other values to either one of these two states for editing p urposes. | 1499 // Collapse all other values to either one of these two states for editing p urposes. |
1502 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { | 1500 switch (toCSSPrimitiveValue(fontWeight)->getValueID()) { |
1503 case CSSValue100: | 1501 case CSSValue100: |
1504 case CSSValue200: | 1502 case CSSValue200: |
1505 case CSSValue300: | 1503 case CSSValue300: |
1506 case CSSValue400: | 1504 case CSSValue400: |
1507 case CSSValue500: | 1505 case CSSValue500: |
1508 case CSSValueNormal: | 1506 case CSSValueNormal: |
1509 return false; | 1507 return false; |
1510 case CSSValueBold: | 1508 case CSSValueBold: |
1511 case CSSValue600: | 1509 case CSSValue600: |
1512 case CSSValue700: | 1510 case CSSValue700: |
1513 case CSSValue800: | 1511 case CSSValue800: |
1514 case CSSValue900: | 1512 case CSSValue900: |
1515 return true; | 1513 return true; |
1516 default: | 1514 default: |
1517 break; | 1515 break; |
1518 } | 1516 } |
1519 | 1517 |
1520 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter | 1518 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter |
1521 return false; | 1519 return false; |
1522 } | 1520 } |
1523 | 1521 |
1524 static bool fontWeightIsBold(CSSStyleDeclaration* style) | 1522 static bool fontWeightNeedsResolving(CSSValue* fontWeight) |
1525 { | 1523 { |
1526 ASSERT(style); | 1524 if (!fontWeight->isPrimitiveValue()) |
1527 RefPtr<CSSValue> fontWeight = style->getPropertyCSSValueInternal(CSSProperty FontWeight); | 1525 return true; |
1528 return fontWeightIsBold(fontWeight.get()); | |
1529 } | |
1530 | 1526 |
1531 static bool fontWeightIsBold(StylePropertySet* style) | 1527 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); |
1532 { | 1528 return value == CSSValueLighter || value == CSSValueBolder; |
1533 ASSERT(style); | |
1534 RefPtr<CSSValue> fontWeight = style->getPropertyCSSValue(CSSPropertyFontWeig ht); | |
1535 return fontWeightIsBold(fontWeight.get()); | |
1536 } | 1529 } |
1537 | 1530 |
1538 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle) | 1531 PassRefPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWi thRedundantProperties, CSSStyleDeclaration* baseStyle) |
1539 { | 1532 { |
1540 ASSERT(styleWithRedundantProperties); | 1533 ASSERT(styleWithRedundantProperties); |
1541 ASSERT(baseStyle); | 1534 ASSERT(baseStyle); |
1542 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy(); | 1535 RefPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy(); |
1543 | 1536 |
1544 result->removeEquivalentProperties(baseStyle); | 1537 result->removeEquivalentProperties(baseStyle); |
1545 | 1538 |
1546 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); | 1539 RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect); |
1547 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat ionsInEffect.get()); | 1540 diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorat ionsInEffect.get()); |
1548 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); | 1541 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); |
1549 | 1542 |
1550 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyFontWeight) && fontWei ghtIsBold(result.get()) == fontWeightIsBold(baseStyle)) | 1543 if (RefPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSValueInternal (CSSPropertyFontWeight)) { |
1551 result->removeProperty(CSSPropertyFontWeight); | 1544 if (RefPtr<CSSValue> fontWeight = result->getPropertyCSSValue(CSSPropert yFontWeight)) { |
1545 if (!fontWeightNeedsResolving(fontWeight.get()) && (fontWeightIsBold (fontWeight.get()) == fontWeightIsBold(baseFontWeight.get()))) | |
rniwa-cr
2013/08/16 05:56:53
This is still incorrect. This function MUST remove
| |
1546 result->removeProperty(CSSPropertyFontWeight); | |
1547 } | |
1548 } | |
1552 | 1549 |
1553 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) | 1550 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getRGBAFontC olor(result.get()) == getRGBAFontColor(baseStyle)) |
1554 result->removeProperty(CSSPropertyColor); | 1551 result->removeProperty(CSSPropertyColor); |
1555 | 1552 |
1556 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) | 1553 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) |
1557 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) | 1554 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) |
1558 result->removeProperty(CSSPropertyTextAlign); | 1555 result->removeProperty(CSSPropertyTextAlign); |
1559 | 1556 |
1560 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) | 1557 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tRGBABackgroundColor(result.get()) == getRGBABackgroundColor(baseStyle)) |
1561 result->removeProperty(CSSPropertyBackgroundColor); | 1558 result->removeProperty(CSSPropertyBackgroundColor); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1635 { | 1632 { |
1636 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1633 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1637 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); | 1634 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor); |
1638 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1635 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1639 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); | 1636 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); |
1640 } | 1637 } |
1641 return 0; | 1638 return 0; |
1642 } | 1639 } |
1643 | 1640 |
1644 } | 1641 } |
OLD | NEW |