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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent> >& HTML
ElementEquivalents = htmlElementEquivalents(); | 902 const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent> >& HTML
ElementEquivalents = htmlElementEquivalents(); |
903 size_t i; | 903 size_t i; |
904 for (i = 0; i < HTMLElementEquivalents.size(); ++i) { | 904 for (i = 0; i < HTMLElementEquivalents.size(); ++i) { |
905 if (HTMLElementEquivalents[i]->matches(element)) { | 905 if (HTMLElementEquivalents[i]->matches(element)) { |
906 elementIsSpanOrElementEquivalent = true; | 906 elementIsSpanOrElementEquivalent = true; |
907 break; | 907 break; |
908 } | 908 } |
909 } | 909 } |
910 } | 910 } |
911 | 911 |
912 if (!element->hasAttributes()) | 912 AttributeCollection attributes = element->attributes(); |
| 913 if (attributes.isEmpty()) |
913 return elementIsSpanOrElementEquivalent; // span, b, etc... without any
attributes | 914 return elementIsSpanOrElementEquivalent; // span, b, etc... without any
attributes |
914 | 915 |
915 unsigned matchedAttributes = 0; | 916 unsigned matchedAttributes = 0; |
916 const WillBeHeapVector<OwnPtrWillBeMember<HTMLAttributeEquivalent> >& HTMLAt
tributeEquivalents = htmlAttributeEquivalents(); | 917 const WillBeHeapVector<OwnPtrWillBeMember<HTMLAttributeEquivalent> >& HTMLAt
tributeEquivalents = htmlAttributeEquivalents(); |
917 for (size_t i = 0; i < HTMLAttributeEquivalents.size(); ++i) { | 918 for (size_t i = 0; i < HTMLAttributeEquivalents.size(); ++i) { |
918 if (HTMLAttributeEquivalents[i]->matches(element) && HTMLAttributeEquiva
lents[i]->attributeName() != HTMLNames::dirAttr) | 919 if (HTMLAttributeEquivalents[i]->matches(element) && HTMLAttributeEquiva
lents[i]->attributeName() != HTMLNames::dirAttr) |
919 matchedAttributes++; | 920 matchedAttributes++; |
920 } | 921 } |
921 | 922 |
922 if (!elementIsSpanOrElementEquivalent && !matchedAttributes) | 923 if (!elementIsSpanOrElementEquivalent && !matchedAttributes) |
923 return false; // element is not a span, a html element equivalent, or fo
nt element. | 924 return false; // element is not a span, a html element equivalent, or fo
nt element. |
924 | 925 |
925 if (element->getAttribute(HTMLNames::classAttr) == AppleStyleSpanClass) | 926 if (element->getAttribute(HTMLNames::classAttr) == AppleStyleSpanClass) |
926 matchedAttributes++; | 927 matchedAttributes++; |
927 | 928 |
928 if (element->hasAttribute(HTMLNames::styleAttr)) { | 929 if (element->hasAttribute(HTMLNames::styleAttr)) { |
929 if (const StylePropertySet* style = element->inlineStyle()) { | 930 if (const StylePropertySet* style = element->inlineStyle()) { |
930 unsigned propertyCount = style->propertyCount(); | 931 unsigned propertyCount = style->propertyCount(); |
931 for (unsigned i = 0; i < propertyCount; ++i) { | 932 for (unsigned i = 0; i < propertyCount; ++i) { |
932 if (!isEditingProperty(style->propertyAt(i).id())) | 933 if (!isEditingProperty(style->propertyAt(i).id())) |
933 return false; | 934 return false; |
934 } | 935 } |
935 } | 936 } |
936 matchedAttributes++; | 937 matchedAttributes++; |
937 } | 938 } |
938 | 939 |
939 // font with color attribute, span with style attribute, etc... | 940 // font with color attribute, span with style attribute, etc... |
940 ASSERT(matchedAttributes <= element->attributes().size()); | 941 ASSERT(matchedAttributes <= attributes.size()); |
941 return matchedAttributes >= element->attributes().size(); | 942 return matchedAttributes >= attributes.size(); |
942 } | 943 } |
943 | 944 |
944 void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit
ingDirection shouldPreserveWritingDirection) | 945 void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit
ingDirection shouldPreserveWritingDirection) |
945 { | 946 { |
946 if (!m_mutableStyle) | 947 if (!m_mutableStyle) |
947 return; | 948 return; |
948 | 949 |
949 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. | 950 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o
nly removes the editing style. |
950 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate | 951 // If this function was modified in the future to delete all redundant prope
rties, then add a boolean value to indicate |
951 // which one of editingStyleAtPosition or computedStyle is called. | 952 // which one of editingStyleAtPosition or computedStyle is called. |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 { | 1678 { |
1678 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1679 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1679 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1680 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
1680 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1681 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1681 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1682 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
1682 } | 1683 } |
1683 return nullptr; | 1684 return nullptr; |
1684 } | 1685 } |
1685 | 1686 |
1686 } | 1687 } |
OLD | NEW |