Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: Source/core/css/analyzer/DescendantInvalidationSet.h

Issue 129633003: Add a first pass of a class descendant invalidator, and a containing RuleSetAnalyzer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed extra line. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 ened to have style
esprehn 2014/01/14 21:32:56 s/ened/need/
chrishtr 2014/01/14 23:33:00 Done.
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 // Marks the appropriate subtree of this elemennt (including the element its elf if appropriate) for style recalc
52 bool operator!=(const StyleVariableData& other) const { return !(*this == ot her); } 54 // based on the information available.
55 void invalidateElementSubtree(Element*);
53 56
54 void setVariable(const AtomicString& name, const String& value) { m_data.set (name, value); } 57 void combine(const DescendantInvalidationSet& other);
55 58
56 HashMap<AtomicString, String> m_data; 59 void addClass(const AtomicString& className);
60 void addId(const AtomicString& id);
61 void addTagName(const AtomicString& tagName);
62
63 void setWholeSubtreeInvalid() { allDescendantsMightBeInvalid = true; };
64
57 private: 65 private:
58 explicit StyleVariableData() : RefCounted<StyleVariableData>() { } 66 DescendantInvalidationSet();
59 StyleVariableData(const StyleVariableData& other) : RefCounted<StyleVariable Data>(), m_data(HashMap<AtomicString, String>(other.m_data)) { } 67
68 bool invalidateElementSubtreeInternal(Element*);
69 // If true, all descendants might be invalidated, so a full subtree recalc i s required.
70 bool allDescendantsMightBeInvalid;
esprehn 2014/01/14 21:32:56 m_ missing
71
72 HashSet<AtomicString> m_classes;
73 HashSet<AtomicString> m_ids;
74 HashSet<AtomicString> m_tagNames;
esprehn 2014/01/14 21:32:56 HashSets are pretty big in terms of memory usage,
chrishtr 2014/01/14 23:33:00 Done.
60 }; 75 };
61 76
62 } // namespace WebCore 77 } // namespace WebCore
63 78
64 #endif /* StyleVariableData_h */ 79 #endif // DescendantInvalidationSet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698