|
Lines 57-62
a/Source/WebCore/editing/EditingStyle.cpp_sec1
|
| 57 |
#include "SimpleRange.h" |
57 |
#include "SimpleRange.h" |
| 58 |
#include "StyleFontSizeFunctions.h" |
58 |
#include "StyleFontSizeFunctions.h" |
| 59 |
#include "StyleProperties.h" |
59 |
#include "StyleProperties.h" |
|
|
60 |
#include "StylePropertyShorthand.h" |
| 60 |
#include "StyleResolver.h" |
61 |
#include "StyleResolver.h" |
| 61 |
#include "StyleRule.h" |
62 |
#include "StyleRule.h" |
| 62 |
#include "StyledElement.h" |
63 |
#include "StyledElement.h" |
|
Lines 96-105
static const CSSPropertyID editingProperties[] = {
a/Source/WebCore/editing/EditingStyle.cpp_sec2
|
| 96 |
// Non-inheritable properties |
97 |
// Non-inheritable properties |
| 97 |
CSSPropertyBackgroundColor, |
98 |
CSSPropertyBackgroundColor, |
| 98 |
CSSPropertyTextDecorationLine, |
99 |
CSSPropertyTextDecorationLine, |
|
|
100 |
CSSPropertyTextDecorationThickness, |
| 101 |
CSSPropertyTextDecorationStyle, |
| 102 |
CSSPropertyTextDecorationColor, |
| 99 |
}; |
103 |
}; |
| 100 |
|
104 |
|
| 101 |
const unsigned numAllEditingProperties = WTF_ARRAY_LENGTH(editingProperties); |
105 |
const unsigned numAllEditingProperties = WTF_ARRAY_LENGTH(editingProperties); |
| 102 |
const unsigned numInheritableEditingProperties = numAllEditingProperties - 2; |
106 |
const unsigned numInheritableEditingProperties = numAllEditingProperties - 5; |
| 103 |
|
107 |
|
| 104 |
enum EditingPropertiesToInclude { OnlyInheritableEditingProperties, AllEditingProperties }; |
108 |
enum EditingPropertiesToInclude { OnlyInheritableEditingProperties, AllEditingProperties }; |
| 105 |
template <class StyleDeclarationType> |
109 |
template <class StyleDeclarationType> |
|
Lines 221-227
void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const
a/Source/WebCore/editing/EditingStyle.cpp_sec3
|
| 221 |
class HTMLTextDecorationEquivalent : public HTMLElementEquivalent { |
225 |
class HTMLTextDecorationEquivalent : public HTMLElementEquivalent { |
| 222 |
public: |
226 |
public: |
| 223 |
HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName) |
227 |
HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const QualifiedName& tagName) |
| 224 |
: HTMLElementEquivalent(CSSPropertyTextDecorationLine, primitiveValue, tagName) |
228 |
: HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName) |
| 225 |
, m_isUnderline(primitiveValue == CSSValueUnderline) |
229 |
, m_isUnderline(primitiveValue == CSSValueUnderline) |
| 226 |
{ |
230 |
{ |
| 227 |
} |
231 |
} |
|
Lines 516-522
void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude)
a/Source/WebCore/editing/EditingStyle.cpp_sec4
|
| 516 |
if (RefPtr<CSSValue> value = backgroundColorInEffect(node)) |
520 |
if (RefPtr<CSSValue> value = backgroundColorInEffect(node)) |
| 517 |
m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
521 |
m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText()); |
| 518 |
if (RefPtr<CSSValue> value = computedStyleAtPosition.propertyValue(CSSPropertyWebkitTextDecorationsInEffect)) { |
522 |
if (RefPtr<CSSValue> value = computedStyleAtPosition.propertyValue(CSSPropertyWebkitTextDecorationsInEffect)) { |
| 519 |
m_mutableStyle->setProperty(CSSPropertyTextDecorationLine, value->cssText()); |
523 |
m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText()); |
| 520 |
m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
524 |
m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 521 |
} |
525 |
} |
| 522 |
} |
526 |
} |
|
Lines 601-609
Ref<MutableStyleProperties> EditingStyle::styleWithResolvedTextDecorations() con
a/Source/WebCore/editing/EditingStyle.cpp_sec5
|
| 601 |
valueList->append(CSSValuePool::singleton().createIdentifierValue(CSSValueLineThrough)); |
605 |
valueList->append(CSSValuePool::singleton().createIdentifierValue(CSSValueLineThrough)); |
| 602 |
|
606 |
|
| 603 |
if (valueList->length()) |
607 |
if (valueList->length()) |
| 604 |
style->setProperty(CSSPropertyTextDecorationLine, valueList.ptr()); |
608 |
style->setProperty(CSSPropertyTextDecoration, valueList->cssText()); |
| 605 |
else |
609 |
else |
| 606 |
style->setProperty(CSSPropertyTextDecorationLine, CSSValuePool::singleton().createIdentifierValue(CSSValueNone)); |
610 |
style->setProperty(CSSPropertyTextDecoration, CSSValuePool::singleton().createIdentifierValue(CSSValueNone)); |
| 607 |
|
611 |
|
| 608 |
return style; |
612 |
return style; |
| 609 |
} |
613 |
} |
|
Lines 785-793
void EditingStyle::collapseTextDecorationProperties()
a/Source/WebCore/editing/EditingStyle.cpp_sec6
|
| 785 |
return; |
789 |
return; |
| 786 |
|
790 |
|
| 787 |
if (textDecorationsInEffect->isValueList()) |
791 |
if (textDecorationsInEffect->isValueList()) |
| 788 |
m_mutableStyle->setProperty(CSSPropertyTextDecorationLine, textDecorationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDecorationLine)); |
792 |
m_mutableStyle->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(CSSPropertyTextDecorationLine)); |
| 789 |
else |
793 |
else |
| 790 |
m_mutableStyle->removeProperty(CSSPropertyTextDecorationLine); |
794 |
m_mutableStyle->removeProperty(CSSPropertyTextDecoration); |
| 791 |
m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
795 |
m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 792 |
} |
796 |
} |
| 793 |
|
797 |
|
|
Lines 902-914
bool EditingStyle::conflictsWithInlineStyleOfElement(StyledElement& element, Ref
a/Source/WebCore/editing/EditingStyle.cpp_sec7
|
| 902 |
if (extractedValueList->length()) { |
906 |
if (extractedValueList->length()) { |
| 903 |
conflicts = true; |
907 |
conflicts = true; |
| 904 |
if (newValueList->length()) |
908 |
if (newValueList->length()) |
| 905 |
newInlineStyle->setProperty(CSSPropertyTextDecorationLine, WTFMove(newValueList)); |
909 |
newInlineStyle->setProperty(CSSPropertyTextDecoration, WTFMove(newValueList)); |
| 906 |
else |
910 |
else |
| 907 |
newInlineStyle->removeProperty(CSSPropertyTextDecorationLine); |
911 |
newInlineStyle->removeProperty(CSSPropertyTextDecorationLine); |
| 908 |
|
912 |
|
| 909 |
if (extractedStyle) { |
913 |
if (extractedStyle) { |
| 910 |
bool isImportant = inlineStyle->propertyIsImportant(CSSPropertyTextDecorationLine); |
914 |
bool isImportant = inlineStyle->propertyIsImportant(CSSPropertyTextDecorationLine); |
| 911 |
extractedStyle->setProperty(CSSPropertyTextDecorationLine, extractedValueList->cssText(), isImportant); |
915 |
extractedStyle->setProperty(CSSPropertyTextDecoration, extractedValueList->cssText(), isImportant); |
| 912 |
} |
916 |
} |
| 913 |
} |
917 |
} |
| 914 |
} |
918 |
} |
|
Lines 926-934
bool EditingStyle::conflictsWithInlineStyleOfElement(StyledElement& element, Ref
a/Source/WebCore/editing/EditingStyle.cpp_sec8
|
| 926 |
if (!newInlineStyle) |
930 |
if (!newInlineStyle) |
| 927 |
return true; |
931 |
return true; |
| 928 |
conflicts = true; |
932 |
conflicts = true; |
| 929 |
newInlineStyle->removeProperty(CSSPropertyTextDecorationLine); |
933 |
newInlineStyle->removeProperty(CSSPropertyTextDecoration); |
| 930 |
if (extractedStyle) |
934 |
if (extractedStyle) |
| 931 |
extractedStyle->setProperty(CSSPropertyTextDecorationLine, inlineStyle->getPropertyValue(CSSPropertyTextDecorationLine), inlineStyle->propertyIsImportant(CSSPropertyTextDecorationLine)); |
935 |
extractedStyle->setProperty(CSSPropertyTextDecoration, inlineStyle->getPropertyValue(CSSPropertyTextDecorationLine), inlineStyle->propertyIsImportant(CSSPropertyTextDecorationLine)); |
| 932 |
} |
936 |
} |
| 933 |
|
937 |
|
| 934 |
if (!inlineStyle->getPropertyCSSValue(propertyID)) |
938 |
if (!inlineStyle->getPropertyCSSValue(propertyID)) |
|
Lines 1469-1477
template<typename T>
a/Source/WebCore/editing/EditingStyle.cpp_sec9
|
| 1469 |
void EditingStyle::removeEquivalentProperties(T& style) |
1473 |
void EditingStyle::removeEquivalentProperties(T& style) |
| 1470 |
{ |
1474 |
{ |
| 1471 |
Vector<CSSPropertyID> propertiesToRemove; |
1475 |
Vector<CSSPropertyID> propertiesToRemove; |
|
|
1476 |
HashSet<CSSPropertyID> alreadyHandled; |
| 1472 |
for (auto& property : m_mutableStyle->m_propertyVector) { |
1477 |
for (auto& property : m_mutableStyle->m_propertyVector) { |
| 1473 |
if (style.propertyMatches(property.id(), property.value())) |
1478 |
CSSPropertyID id = property.id(); |
|
|
1479 |
if (alreadyHandled.contains(id)) |
| 1480 |
continue; |
| 1481 |
if (!style.propertyMatches(id, property.value())) |
| 1482 |
continue; |
| 1483 |
if (!property.isSetFromShorthand()) { |
| 1474 |
propertiesToRemove.append(property.id()); |
1484 |
propertiesToRemove.append(property.id()); |
|
|
1485 |
continue; |
| 1486 |
} |
| 1487 |
// Do not remove equivalent properties when they share a shorthand with non-equivalent ones, and the removal would prevent them from being serialized with the shorthand. |
| 1488 |
CSSPropertyID shorthandID = property.shorthandID(); |
| 1489 |
if (m_mutableStyle->getPropertyValue(shorthandID).isEmpty()) { |
| 1490 |
propertiesToRemove.append(property.id()); |
| 1491 |
continue; |
| 1492 |
} |
| 1493 |
auto shorthand = shorthandForProperty(shorthandID); |
| 1494 |
bool canRemoveAllLonghands = true; |
| 1495 |
for (CSSPropertyID longhandID : shorthand) { |
| 1496 |
if (id != longhandID && !style.propertyMatches(longhandID, m_mutableStyle->getPropertyCSSValue(longhandID).get())) { |
| 1497 |
canRemoveAllLonghands = false; |
| 1498 |
break; |
| 1499 |
} |
| 1500 |
} |
| 1501 |
for (CSSPropertyID longhandID : shorthand) { |
| 1502 |
if (canRemoveAllLonghands) |
| 1503 |
propertiesToRemove.append(longhandID); |
| 1504 |
alreadyHandled.add(longhandID); |
| 1505 |
} |
| 1475 |
} |
1506 |
} |
| 1476 |
// FIXME: This should use mass removal. |
1507 |
// FIXME: This should use mass removal. |
| 1477 |
for (auto& property : propertiesToRemove) |
1508 |
for (auto& property : propertiesToRemove) |
|
Lines 1698-1711
static void reconcileTextDecorationProperties(MutableStyleProperties* style)
a/Source/WebCore/editing/EditingStyle.cpp_sec10
|
| 1698 |
// We shouldn't have both text-decoration and -webkit-text-decorations-in-effect because that wouldn't make sense. |
1729 |
// We shouldn't have both text-decoration and -webkit-text-decorations-in-effect because that wouldn't make sense. |
| 1699 |
ASSERT(!textDecorationsInEffect || !textDecoration); |
1730 |
ASSERT(!textDecorationsInEffect || !textDecoration); |
| 1700 |
if (textDecorationsInEffect) { |
1731 |
if (textDecorationsInEffect) { |
| 1701 |
style->setProperty(CSSPropertyTextDecorationLine, textDecorationsInEffect->cssText()); |
1732 |
style->setProperty(CSSPropertyTextDecoration, textDecorationsInEffect->cssText()); |
| 1702 |
style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
1733 |
style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); |
| 1703 |
textDecoration = textDecorationsInEffect; |
1734 |
textDecoration = textDecorationsInEffect; |
| 1704 |
} |
1735 |
} |
| 1705 |
|
1736 |
|
| 1706 |
// If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". |
1737 |
// If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". |
| 1707 |
if (textDecoration && !textDecoration->isValueList()) |
1738 |
if (textDecoration && !textDecoration->isValueList()) |
| 1708 |
style->removeProperty(CSSPropertyTextDecorationLine); |
1739 |
style->removeProperty(CSSPropertyTextDecoration); |
| 1709 |
} |
1740 |
} |
| 1710 |
|
1741 |
|
| 1711 |
StyleChange::StyleChange(EditingStyle* style, const Position& position) |
1742 |
StyleChange::StyleChange(EditingStyle* style, const Position& position) |
|
Lines 1759-1765
StyleChange::StyleChange(EditingStyle* style, const Position& position)
a/Source/WebCore/editing/EditingStyle.cpp_sec11
|
| 1759 |
valueList->append(WTFMove(underline)); |
1790 |
valueList->append(WTFMove(underline)); |
| 1760 |
if (shouldAddStrikeThrough && !hasLineThrough) |
1791 |
if (shouldAddStrikeThrough && !hasLineThrough) |
| 1761 |
valueList->append(WTFMove(lineThrough)); |
1792 |
valueList->append(WTFMove(lineThrough)); |
| 1762 |
mutableStyle->setProperty(CSSPropertyTextDecorationLine, valueList.get()); |
1793 |
mutableStyle->setProperty(CSSPropertyTextDecoration, valueList->cssText()); |
| 1763 |
} else { |
1794 |
} else { |
| 1764 |
m_applyUnderline = shouldAddUnderline && !hasUnderline; |
1795 |
m_applyUnderline = shouldAddUnderline && !hasUnderline; |
| 1765 |
m_applyLineThrough = shouldAddStrikeThrough && !hasLineThrough; |
1796 |
m_applyLineThrough = shouldAddStrikeThrough && !hasLineThrough; |
|
Lines 1798-1806
bool StyleChange::operator==(const StyleChange& other)
a/Source/WebCore/editing/EditingStyle.cpp_sec12
|
| 1798 |
|
1829 |
|
| 1799 |
static void setTextDecorationProperty(MutableStyleProperties& style, const CSSValueList* newTextDecoration, CSSPropertyID propertyID) |
1830 |
static void setTextDecorationProperty(MutableStyleProperties& style, const CSSValueList* newTextDecoration, CSSPropertyID propertyID) |
| 1800 |
{ |
1831 |
{ |
| 1801 |
if (newTextDecoration->length()) |
1832 |
if (newTextDecoration->length()) { |
| 1802 |
style.setProperty(propertyID, newTextDecoration->cssText(), style.propertyIsImportant(propertyID)); |
1833 |
bool isImportant = style.propertyIsImportant(propertyID == CSSPropertyTextDecoration ? CSSPropertyTextDecorationLine : propertyID); |
| 1803 |
else { |
1834 |
style.setProperty(propertyID, newTextDecoration->cssText(), isImportant); |
|
|
1835 |
} else { |
| 1804 |
// text-decoration: none is redundant since it does not remove any text decorations. |
1836 |
// text-decoration: none is redundant since it does not remove any text decorations. |
| 1805 |
style.removeProperty(propertyID); |
1837 |
style.removeProperty(propertyID); |
| 1806 |
} |
1838 |
} |
|
Lines 1834-1840
void StyleChange::extractTextStyles(Document& document, MutableStyleProperties&
a/Source/WebCore/editing/EditingStyle.cpp_sec13
|
| 1834 |
m_applyLineThrough = true; |
1866 |
m_applyLineThrough = true; |
| 1835 |
|
1867 |
|
| 1836 |
// If trimTextDecorations, delete underline and line-through |
1868 |
// If trimTextDecorations, delete underline and line-through |
| 1837 |
setTextDecorationProperty(style, newTextDecoration.get(), CSSPropertyTextDecorationLine); |
1869 |
setTextDecorationProperty(style, newTextDecoration.get(), CSSPropertyTextDecoration); |
| 1838 |
} |
1870 |
} |
| 1839 |
|
1871 |
|
| 1840 |
int verticalAlign = identifierForStyleProperty(style, CSSPropertyVerticalAlign); |
1872 |
int verticalAlign = identifierForStyleProperty(style, CSSPropertyVerticalAlign); |
|
Lines 1872-1880
void StyleChange::extractTextStyles(Document& document, MutableStyleProperties&
a/Source/WebCore/editing/EditingStyle.cpp_sec14
|
| 1872 |
} |
1904 |
} |
| 1873 |
} |
1905 |
} |
| 1874 |
|
1906 |
|
| 1875 |
static void diffTextDecorations(MutableStyleProperties& style, CSSPropertyID propertID, CSSValue* refTextDecoration) |
1907 |
static void diffTextDecorations(MutableStyleProperties& style, CSSPropertyID propertyID, CSSValue* refTextDecoration) |
| 1876 |
{ |
1908 |
{ |
| 1877 |
RefPtr<CSSValue> textDecoration = style.getPropertyCSSValue(propertID); |
1909 |
RefPtr<CSSValue> textDecoration = style.getPropertyCSSValue(propertyID == CSSPropertyTextDecoration ? CSSPropertyTextDecorationLine : propertyID); |
| 1878 |
if (!is<CSSValueList>(textDecoration) || !is<CSSValueList>(refTextDecoration)) |
1910 |
if (!is<CSSValueList>(textDecoration) || !is<CSSValueList>(refTextDecoration)) |
| 1879 |
return; |
1911 |
return; |
| 1880 |
|
1912 |
|
|
Lines 1883-1889
static void diffTextDecorations(MutableStyleProperties& style, CSSPropertyID pro
a/Source/WebCore/editing/EditingStyle.cpp_sec15
|
| 1883 |
for (auto& value : downcast<CSSValueList>(*refTextDecoration)) |
1915 |
for (auto& value : downcast<CSSValueList>(*refTextDecoration)) |
| 1884 |
newTextDecoration->removeAll(&value.get()); |
1916 |
newTextDecoration->removeAll(&value.get()); |
| 1885 |
|
1917 |
|
| 1886 |
setTextDecorationProperty(style, newTextDecoration.get(), propertID); |
1918 |
setTextDecorationProperty(style, newTextDecoration.get(), propertyID); |
| 1887 |
} |
1919 |
} |
| 1888 |
|
1920 |
|
| 1889 |
template<typename T> |
1921 |
template<typename T> |
|
Lines 1902-1908
static Ref<MutableStyleProperties> extractPropertiesNotIn(StyleProperties& style
a/Source/WebCore/editing/EditingStyle.cpp_sec16
|
| 1902 |
Ref<MutableStyleProperties> mutableStyle = *result->style(); |
1934 |
Ref<MutableStyleProperties> mutableStyle = *result->style(); |
| 1903 |
|
1935 |
|
| 1904 |
RefPtr<CSSValue> baseTextDecorationsInEffect = extractPropertyValue(baseStyle, CSSPropertyWebkitTextDecorationsInEffect); |
1936 |
RefPtr<CSSValue> baseTextDecorationsInEffect = extractPropertyValue(baseStyle, CSSPropertyWebkitTextDecorationsInEffect); |
| 1905 |
diffTextDecorations(mutableStyle, CSSPropertyTextDecorationLine, baseTextDecorationsInEffect.get()); |
1937 |
diffTextDecorations(mutableStyle, CSSPropertyTextDecoration, baseTextDecorationsInEffect.get()); |
| 1906 |
diffTextDecorations(mutableStyle, CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); |
1938 |
diffTextDecorations(mutableStyle, CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); |
| 1907 |
|
1939 |
|
| 1908 |
if (extractPropertyValue(baseStyle, CSSPropertyFontWeight) && fontWeightIsBold(mutableStyle) == fontWeightIsBold(baseStyle)) |
1940 |
if (extractPropertyValue(baseStyle, CSSPropertyFontWeight) && fontWeightIsBold(mutableStyle) == fontWeightIsBold(baseStyle)) |