| 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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 | 847 |
| 848 // We don't override whitespace property of a tab span because that would | 848 // We don't override whitespace property of a tab span because that would |
| 849 // collapse the tab into a space. | 849 // collapse the tab into a space. |
| 850 if (propertyID == CSSPropertyWhiteSpace && isTabHTMLSpanElement(element)) | 850 if (propertyID == CSSPropertyWhiteSpace && isTabHTMLSpanElement(element)) |
| 851 continue; | 851 continue; |
| 852 | 852 |
| 853 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && | 853 if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && |
| 854 inlineStyle->getPropertyCSSValue(textDecorationPropertyForEditing())) { | 854 inlineStyle->getPropertyCSSValue(textDecorationPropertyForEditing())) { |
| 855 if (!conflictingProperties) | 855 if (!conflictingProperties) |
| 856 return true; | 856 return true; |
| 857 conflictingProperties->append(CSSPropertyTextDecoration); | 857 conflictingProperties->push_back(CSSPropertyTextDecoration); |
| 858 // Because text-decoration expands to text-decoration-line when CSS3 | 858 // Because text-decoration expands to text-decoration-line when CSS3 |
| 859 // Text Decoration is enabled, we also state it as conflicting. | 859 // Text Decoration is enabled, we also state it as conflicting. |
| 860 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | 860 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
| 861 conflictingProperties->append(CSSPropertyTextDecorationLine); | 861 conflictingProperties->push_back(CSSPropertyTextDecorationLine); |
| 862 if (extractedStyle) | 862 if (extractedStyle) |
| 863 extractedStyle->setProperty( | 863 extractedStyle->setProperty( |
| 864 textDecorationPropertyForEditing(), | 864 textDecorationPropertyForEditing(), |
| 865 inlineStyle->getPropertyValue(textDecorationPropertyForEditing()), | 865 inlineStyle->getPropertyValue(textDecorationPropertyForEditing()), |
| 866 inlineStyle->propertyIsImportant( | 866 inlineStyle->propertyIsImportant( |
| 867 textDecorationPropertyForEditing())); | 867 textDecorationPropertyForEditing())); |
| 868 continue; | 868 continue; |
| 869 } | 869 } |
| 870 | 870 |
| 871 if (!inlineStyle->getPropertyCSSValue(propertyID)) | 871 if (!inlineStyle->getPropertyCSSValue(propertyID)) |
| 872 continue; | 872 continue; |
| 873 | 873 |
| 874 if (propertyID == CSSPropertyUnicodeBidi && | 874 if (propertyID == CSSPropertyUnicodeBidi && |
| 875 inlineStyle->getPropertyCSSValue(CSSPropertyDirection)) { | 875 inlineStyle->getPropertyCSSValue(CSSPropertyDirection)) { |
| 876 if (!conflictingProperties) | 876 if (!conflictingProperties) |
| 877 return true; | 877 return true; |
| 878 conflictingProperties->append(CSSPropertyDirection); | 878 conflictingProperties->push_back(CSSPropertyDirection); |
| 879 if (extractedStyle) | 879 if (extractedStyle) |
| 880 extractedStyle->setProperty( | 880 extractedStyle->setProperty( |
| 881 propertyID, inlineStyle->getPropertyValue(propertyID), | 881 propertyID, inlineStyle->getPropertyValue(propertyID), |
| 882 inlineStyle->propertyIsImportant(propertyID)); | 882 inlineStyle->propertyIsImportant(propertyID)); |
| 883 } | 883 } |
| 884 | 884 |
| 885 if (!conflictingProperties) | 885 if (!conflictingProperties) |
| 886 return true; | 886 return true; |
| 887 | 887 |
| 888 conflictingProperties->append(propertyID); | 888 conflictingProperties->push_back(propertyID); |
| 889 | 889 |
| 890 if (extractedStyle) | 890 if (extractedStyle) |
| 891 extractedStyle->setProperty(propertyID, | 891 extractedStyle->setProperty(propertyID, |
| 892 inlineStyle->getPropertyValue(propertyID), | 892 inlineStyle->getPropertyValue(propertyID), |
| 893 inlineStyle->propertyIsImportant(propertyID)); | 893 inlineStyle->propertyIsImportant(propertyID)); |
| 894 } | 894 } |
| 895 | 895 |
| 896 return conflictingProperties && !conflictingProperties->isEmpty(); | 896 return conflictingProperties && !conflictingProperties->isEmpty(); |
| 897 } | 897 } |
| 898 | 898 |
| 899 static const HeapVector<Member<HTMLElementEquivalent>>& | 899 static const HeapVector<Member<HTMLElementEquivalent>>& |
| 900 htmlElementEquivalents() { | 900 htmlElementEquivalents() { |
| 901 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLElementEquivalent>>, | 901 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLElementEquivalent>>, |
| 902 HTMLElementEquivalents, | 902 HTMLElementEquivalents, |
| 903 (new HeapVector<Member<HTMLElementEquivalent>>)); | 903 (new HeapVector<Member<HTMLElementEquivalent>>)); |
| 904 if (!HTMLElementEquivalents.size()) { | 904 if (!HTMLElementEquivalents.size()) { |
| 905 HTMLElementEquivalents.append(HTMLElementEquivalent::create( | 905 HTMLElementEquivalents.push_back(HTMLElementEquivalent::create( |
| 906 CSSPropertyFontWeight, CSSValueBold, HTMLNames::bTag)); | 906 CSSPropertyFontWeight, CSSValueBold, HTMLNames::bTag)); |
| 907 HTMLElementEquivalents.append(HTMLElementEquivalent::create( | 907 HTMLElementEquivalents.push_back(HTMLElementEquivalent::create( |
| 908 CSSPropertyFontWeight, CSSValueBold, HTMLNames::strongTag)); | 908 CSSPropertyFontWeight, CSSValueBold, HTMLNames::strongTag)); |
| 909 HTMLElementEquivalents.append(HTMLElementEquivalent::create( | 909 HTMLElementEquivalents.push_back(HTMLElementEquivalent::create( |
| 910 CSSPropertyVerticalAlign, CSSValueSub, HTMLNames::subTag)); | 910 CSSPropertyVerticalAlign, CSSValueSub, HTMLNames::subTag)); |
| 911 HTMLElementEquivalents.append(HTMLElementEquivalent::create( | 911 HTMLElementEquivalents.push_back(HTMLElementEquivalent::create( |
| 912 CSSPropertyVerticalAlign, CSSValueSuper, HTMLNames::supTag)); | 912 CSSPropertyVerticalAlign, CSSValueSuper, HTMLNames::supTag)); |
| 913 HTMLElementEquivalents.append(HTMLElementEquivalent::create( | 913 HTMLElementEquivalents.push_back(HTMLElementEquivalent::create( |
| 914 CSSPropertyFontStyle, CSSValueItalic, HTMLNames::iTag)); | 914 CSSPropertyFontStyle, CSSValueItalic, HTMLNames::iTag)); |
| 915 HTMLElementEquivalents.append(HTMLElementEquivalent::create( | 915 HTMLElementEquivalents.push_back(HTMLElementEquivalent::create( |
| 916 CSSPropertyFontStyle, CSSValueItalic, HTMLNames::emTag)); | 916 CSSPropertyFontStyle, CSSValueItalic, HTMLNames::emTag)); |
| 917 | 917 |
| 918 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create( | 918 HTMLElementEquivalents.push_back(HTMLTextDecorationEquivalent::create( |
| 919 CSSValueUnderline, HTMLNames::uTag)); | 919 CSSValueUnderline, HTMLNames::uTag)); |
| 920 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create( | 920 HTMLElementEquivalents.push_back(HTMLTextDecorationEquivalent::create( |
| 921 CSSValueLineThrough, HTMLNames::sTag)); | 921 CSSValueLineThrough, HTMLNames::sTag)); |
| 922 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create( | 922 HTMLElementEquivalents.push_back(HTMLTextDecorationEquivalent::create( |
| 923 CSSValueLineThrough, HTMLNames::strikeTag)); | 923 CSSValueLineThrough, HTMLNames::strikeTag)); |
| 924 } | 924 } |
| 925 | 925 |
| 926 return HTMLElementEquivalents; | 926 return HTMLElementEquivalents; |
| 927 } | 927 } |
| 928 | 928 |
| 929 bool EditingStyle::conflictsWithImplicitStyleOfElement( | 929 bool EditingStyle::conflictsWithImplicitStyleOfElement( |
| 930 HTMLElement* element, | 930 HTMLElement* element, |
| 931 EditingStyle* extractedStyle, | 931 EditingStyle* extractedStyle, |
| 932 ShouldExtractMatchingStyle shouldExtractMatchingStyle) const { | 932 ShouldExtractMatchingStyle shouldExtractMatchingStyle) const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 951 | 951 |
| 952 static const HeapVector<Member<HTMLAttributeEquivalent>>& | 952 static const HeapVector<Member<HTMLAttributeEquivalent>>& |
| 953 htmlAttributeEquivalents() { | 953 htmlAttributeEquivalents() { |
| 954 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLAttributeEquivalent>>, | 954 DEFINE_STATIC_LOCAL(HeapVector<Member<HTMLAttributeEquivalent>>, |
| 955 HTMLAttributeEquivalents, | 955 HTMLAttributeEquivalents, |
| 956 (new HeapVector<Member<HTMLAttributeEquivalent>>)); | 956 (new HeapVector<Member<HTMLAttributeEquivalent>>)); |
| 957 if (!HTMLAttributeEquivalents.size()) { | 957 if (!HTMLAttributeEquivalents.size()) { |
| 958 // elementIsStyledSpanOrHTMLEquivalent depends on the fact each | 958 // elementIsStyledSpanOrHTMLEquivalent depends on the fact each |
| 959 // HTMLAttriuteEquivalent matches exactly one attribute of exactly one | 959 // HTMLAttriuteEquivalent matches exactly one attribute of exactly one |
| 960 // element except dirAttr. | 960 // element except dirAttr. |
| 961 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create( | 961 HTMLAttributeEquivalents.push_back(HTMLAttributeEquivalent::create( |
| 962 CSSPropertyColor, HTMLNames::fontTag, HTMLNames::colorAttr)); | 962 CSSPropertyColor, HTMLNames::fontTag, HTMLNames::colorAttr)); |
| 963 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create( | 963 HTMLAttributeEquivalents.push_back(HTMLAttributeEquivalent::create( |
| 964 CSSPropertyFontFamily, HTMLNames::fontTag, HTMLNames::faceAttr)); | 964 CSSPropertyFontFamily, HTMLNames::fontTag, HTMLNames::faceAttr)); |
| 965 HTMLAttributeEquivalents.append(HTMLFontSizeEquivalent::create()); | 965 HTMLAttributeEquivalents.push_back(HTMLFontSizeEquivalent::create()); |
| 966 | 966 |
| 967 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create( | 967 HTMLAttributeEquivalents.push_back(HTMLAttributeEquivalent::create( |
| 968 CSSPropertyDirection, HTMLNames::dirAttr)); | 968 CSSPropertyDirection, HTMLNames::dirAttr)); |
| 969 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create( | 969 HTMLAttributeEquivalents.push_back(HTMLAttributeEquivalent::create( |
| 970 CSSPropertyUnicodeBidi, HTMLNames::dirAttr)); | 970 CSSPropertyUnicodeBidi, HTMLNames::dirAttr)); |
| 971 } | 971 } |
| 972 | 972 |
| 973 return HTMLAttributeEquivalents; | 973 return HTMLAttributeEquivalents; |
| 974 } | 974 } |
| 975 | 975 |
| 976 bool EditingStyle::conflictsWithImplicitStyleOfAttributes( | 976 bool EditingStyle::conflictsWithImplicitStyleOfAttributes( |
| 977 HTMLElement* element) const { | 977 HTMLElement* element) const { |
| 978 DCHECK(element); | 978 DCHECK(element); |
| 979 if (!m_mutableStyle) | 979 if (!m_mutableStyle) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 continue; | 1018 continue; |
| 1019 | 1019 |
| 1020 if (!equivalent->matches(element) || | 1020 if (!equivalent->matches(element) || |
| 1021 !equivalent->propertyExistsInStyle(m_mutableStyle.get()) || | 1021 !equivalent->propertyExistsInStyle(m_mutableStyle.get()) || |
| 1022 (shouldExtractMatchingStyle == DoNotExtractMatchingStyle && | 1022 (shouldExtractMatchingStyle == DoNotExtractMatchingStyle && |
| 1023 equivalent->valueIsPresentInStyle(element, m_mutableStyle.get()))) | 1023 equivalent->valueIsPresentInStyle(element, m_mutableStyle.get()))) |
| 1024 continue; | 1024 continue; |
| 1025 | 1025 |
| 1026 if (extractedStyle) | 1026 if (extractedStyle) |
| 1027 equivalent->addToStyle(element, extractedStyle); | 1027 equivalent->addToStyle(element, extractedStyle); |
| 1028 conflictingAttributes.append(equivalent->attributeName()); | 1028 conflictingAttributes.push_back(equivalent->attributeName()); |
| 1029 removed = true; | 1029 removed = true; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 return removed; | 1032 return removed; |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const { | 1035 bool EditingStyle::styleIsPresentInComputedStyleOfNode(Node* node) const { |
| 1036 return !m_mutableStyle || | 1036 return !m_mutableStyle || |
| 1037 getPropertiesNotIn(m_mutableStyle.get(), | 1037 getPropertiesNotIn(m_mutableStyle.get(), |
| 1038 CSSComputedStyleDeclaration::create(node)) | 1038 CSSComputedStyleDeclaration::create(node)) |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 2036 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 2037 CSSComputedStyleDeclaration* ancestorStyle = | 2037 CSSComputedStyleDeclaration* ancestorStyle = |
| 2038 CSSComputedStyleDeclaration::create(ancestor); | 2038 CSSComputedStyleDeclaration::create(ancestor); |
| 2039 if (!hasTransparentBackgroundColor(ancestorStyle)) | 2039 if (!hasTransparentBackgroundColor(ancestorStyle)) |
| 2040 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); | 2040 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); |
| 2041 } | 2041 } |
| 2042 return nullptr; | 2042 return nullptr; |
| 2043 } | 2043 } |
| 2044 | 2044 |
| 2045 } // namespace blink | 2045 } // namespace blink |
| OLD | NEW |