| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return true; | 49 return true; |
| 50 | 50 |
| 51 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) | 51 if (m_tagNames && m_tagNames->contains(element.tagQName().localName())) |
| 52 return true; | 52 return true; |
| 53 | 53 |
| 54 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution
())) | 54 if (element.hasID() && m_ids && m_ids->contains(element.idForStyleResolution
())) |
| 55 return true; | 55 return true; |
| 56 | 56 |
| 57 if (element.hasClass() && m_classes) { | 57 if (element.hasClass() && m_classes) { |
| 58 const SpaceSplitString& classNames = element.classNames(); | 58 const SpaceSplitString& classNames = element.classNames(); |
| 59 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg
in(); it != m_classes->end(); ++it) { | 59 for (const auto& className : *m_classes) { |
| 60 if (classNames.contains(*it)) | 60 if (classNames.contains(className)) |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (element.hasAttributes() && m_attributes) { | 65 if (element.hasAttributes() && m_attributes) { |
| 66 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes->
begin(); it != m_attributes->end(); ++it) { | 66 for (const auto& attribute : *m_attributes) { |
| 67 if (element.hasAttribute(*it)) | 67 if (element.hasAttribute(attribute)) |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) | 75 void DescendantInvalidationSet::combine(const DescendantInvalidationSet& other) |
| 76 { | 76 { |
| 77 // No longer bother combining data structures, since the whole subtree is de
emed invalid. | 77 // No longer bother combining data structures, since the whole subtree is de
emed invalid. |
| 78 if (wholeSubtreeInvalid()) | 78 if (wholeSubtreeInvalid()) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 if (other.wholeSubtreeInvalid()) { | 81 if (other.wholeSubtreeInvalid()) { |
| 82 setWholeSubtreeInvalid(); | 82 setWholeSubtreeInvalid(); |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 | 85 |
| 86 if (other.customPseudoInvalid()) | 86 if (other.customPseudoInvalid()) |
| 87 setCustomPseudoInvalid(); | 87 setCustomPseudoInvalid(); |
| 88 | 88 |
| 89 if (other.treeBoundaryCrossing()) | 89 if (other.treeBoundaryCrossing()) |
| 90 setTreeBoundaryCrossing(); | 90 setTreeBoundaryCrossing(); |
| 91 | 91 |
| 92 if (other.m_classes) { | 92 if (other.m_classes) { |
| 93 WillBeHeapHashSet<AtomicString>::const_iterator end = other.m_classes->e
nd(); | 93 for (const auto& className : *other.m_classes) |
| 94 for (WillBeHeapHashSet<AtomicString>::const_iterator it = other.m_classe
s->begin(); it != end; ++it) | 94 addClass(className); |
| 95 addClass(*it); | |
| 96 } | 95 } |
| 97 | 96 |
| 98 if (other.m_ids) { | 97 if (other.m_ids) { |
| 99 WillBeHeapHashSet<AtomicString>::const_iterator end = other.m_ids->end()
; | 98 for (const auto& id : *other.m_ids) |
| 100 for (WillBeHeapHashSet<AtomicString>::const_iterator it = other.m_ids->b
egin(); it != end; ++it) | 99 addId(id); |
| 101 addId(*it); | |
| 102 } | 100 } |
| 103 | 101 |
| 104 if (other.m_tagNames) { | 102 if (other.m_tagNames) { |
| 105 WillBeHeapHashSet<AtomicString>::const_iterator end = other.m_tagNames->
end(); | 103 for (const auto& tagName : *other.m_tagNames) |
| 106 for (WillBeHeapHashSet<AtomicString>::const_iterator it = other.m_tagNam
es->begin(); it != end; ++it) | 104 addTagName(tagName); |
| 107 addTagName(*it); | |
| 108 } | 105 } |
| 109 | 106 |
| 110 if (other.m_attributes) { | 107 if (other.m_attributes) { |
| 111 WillBeHeapHashSet<AtomicString>::const_iterator end = other.m_attributes
->end(); | 108 for (const auto& attribute : *other.m_attributes) |
| 112 for (WillBeHeapHashSet<AtomicString>::const_iterator it = other.m_attrib
utes->begin(); it != end; ++it) | 109 addAttribute(attribute); |
| 113 addAttribute(*it); | |
| 114 } | 110 } |
| 115 } | 111 } |
| 116 | 112 |
| 117 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureClassSet() | 113 WillBeHeapHashSet<AtomicString>& DescendantInvalidationSet::ensureClassSet() |
| 118 { | 114 { |
| 119 if (!m_classes) | 115 if (!m_classes) |
| 120 m_classes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); | 116 m_classes = adoptPtrWillBeNoop(new WillBeHeapHashSet<AtomicString>); |
| 121 return *m_classes; | 117 return *m_classes; |
| 122 } | 118 } |
| 123 | 119 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void DescendantInvalidationSet::show() const | 193 void DescendantInvalidationSet::show() const |
| 198 { | 194 { |
| 199 fprintf(stderr, "DescendantInvalidationSet { "); | 195 fprintf(stderr, "DescendantInvalidationSet { "); |
| 200 if (m_allDescendantsMightBeInvalid) | 196 if (m_allDescendantsMightBeInvalid) |
| 201 fprintf(stderr, "* "); | 197 fprintf(stderr, "* "); |
| 202 if (m_customPseudoInvalid) | 198 if (m_customPseudoInvalid) |
| 203 fprintf(stderr, "::custom "); | 199 fprintf(stderr, "::custom "); |
| 204 if (m_treeBoundaryCrossing) | 200 if (m_treeBoundaryCrossing) |
| 205 fprintf(stderr, "::shadow/deep/ "); | 201 fprintf(stderr, "::shadow/deep/ "); |
| 206 if (m_ids) { | 202 if (m_ids) { |
| 207 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_ids->begin()
; it != m_ids->end(); ++it) | 203 for (const auto& id : *m_ids) |
| 208 fprintf(stderr, "#%s ", (*it).ascii().data()); | 204 fprintf(stderr, "#%s ", id.ascii().data()); |
| 209 } | 205 } |
| 210 if (m_classes) { | 206 if (m_classes) { |
| 211 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_classes->beg
in(); it != m_classes->end(); ++it) | 207 for (const auto& className : *m_classes) |
| 212 fprintf(stderr, ".%s ", (*it).ascii().data()); | 208 fprintf(stderr, ".%s ", className.ascii().data()); |
| 213 } | 209 } |
| 214 if (m_tagNames) { | 210 if (m_tagNames) { |
| 215 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_tagNames->be
gin(); it != m_tagNames->end(); ++it) | 211 for (const auto& tagName : *m_tagNames) |
| 216 fprintf(stderr, "<%s> ", (*it).ascii().data()); | 212 fprintf(stderr, "<%s> ", tagName.ascii().data()); |
| 217 } | 213 } |
| 218 if (m_attributes) { | 214 if (m_attributes) { |
| 219 for (WillBeHeapHashSet<AtomicString>::const_iterator it = m_attributes->
begin(); it != m_attributes->end(); ++it) | 215 for (const auto& attribute : *m_attributes) |
| 220 fprintf(stderr, "[%s] ", (*it).ascii().data()); | 216 fprintf(stderr, "[%s] ", attribute.ascii().data()); |
| 221 } | 217 } |
| 222 fprintf(stderr, "}\n"); | 218 fprintf(stderr, "}\n"); |
| 223 } | 219 } |
| 224 #endif // NDEBUG | 220 #endif // NDEBUG |
| 225 | 221 |
| 226 } // namespace blink | 222 } // namespace blink |
| OLD | NEW |