| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 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 |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 | 31 #ifndef DescendantInvalidationSet_h |
| 32 #ifndef StyleVariableData_h | 32 #define DescendantInvalidationSet_h |
| 33 #define StyleVariableData_h | |
| 34 | 33 |
| 35 #include "wtf/Forward.h" | 34 #include "wtf/Forward.h" |
| 36 #include "wtf/HashMap.h" | 35 #include "wtf/HashSet.h" |
| 37 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
| 37 #include "wtf/RefPtr.h" |
| 38 #include "wtf/text/AtomicStringHash.h" | 38 #include "wtf/text/AtomicStringHash.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 class CursorList; | 42 class Element; |
| 43 class QuotesData; | |
| 44 class ShadowData; | |
| 45 | 43 |
| 46 class StyleVariableData : public RefCounted<StyleVariableData> { | 44 // Tracks data to determine which elements of a DOM subtree need to have style |
| 45 // recalculated. |
| 46 class DescendantInvalidationSet : public RefCounted<DescendantInvalidationSet> { |
| 47 public: | 47 public: |
| 48 static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVar
iableData()); } | 48 static PassRefPtr<DescendantInvalidationSet> create() |
| 49 PassRefPtr<StyleVariableData> copy() const { return adoptRef(new StyleVariab
leData(*this)); } | 49 { |
| 50 return adoptRef(new DescendantInvalidationSet); |
| 51 } |
| 50 | 52 |
| 51 bool operator==(const StyleVariableData& other) const { return other.m_data
== m_data; } | 53 void combine(const DescendantInvalidationSet& other); |
| 52 bool operator!=(const StyleVariableData& other) const { return !(*this == ot
her); } | |
| 53 | 54 |
| 54 void setVariable(const AtomicString& name, const String& value) { m_data.set
(name, value); } | 55 void addClass(const AtomicString& className); |
| 56 void addId(const AtomicString& id); |
| 57 void addTagName(const AtomicString& tagName); |
| 55 | 58 |
| 56 HashMap<AtomicString, String> m_data; | 59 void appendClasses(Vector<AtomicString>& classes); |
| 60 |
| 61 void setWholeSubtreeInvalid() { m_allDescendantsMightBeInvalid = true; }; |
| 62 bool wholeSubtreeInvalid() { return m_allDescendantsMightBeInvalid; } |
| 57 private: | 63 private: |
| 58 explicit StyleVariableData() : RefCounted<StyleVariableData>() { } | 64 DescendantInvalidationSet(); |
| 59 StyleVariableData(const StyleVariableData& other) : RefCounted<StyleVariable
Data>(), m_data(HashMap<AtomicString, String>(other.m_data)) { } | 65 |
| 66 bool invalidateElementSubtreeInternal(Element*); |
| 67 // If true, all descendants might be invalidated, so a full subtree recalc i
s required. |
| 68 bool m_allDescendantsMightBeInvalid; |
| 69 |
| 70 // FIXME: optimize this if it becomes a memory issue. |
| 71 HashSet<AtomicString> m_classes; |
| 72 HashSet<AtomicString> m_ids; |
| 73 HashSet<AtomicString> m_tagNames; |
| 60 }; | 74 }; |
| 61 | 75 |
| 62 } // namespace WebCore | 76 } // namespace WebCore |
| 63 | 77 |
| 64 #endif /* StyleVariableData_h */ | 78 #endif // DescendantInvalidationSet_h |
| OLD | NEW |