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

Side by Side Diff: sky/engine/core/css/resolver/SharedStyleFinder.h

Issue 837883002: Store features in the ScopedStyleResoolver. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Simpler even. Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google, Inc. 2 * Copyright (C) 2013 Google, Inc.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #ifndef SKY_ENGINE_CORE_CSS_RESOLVER_SHAREDSTYLEFINDER_H_ 22 #ifndef SKY_ENGINE_CORE_CSS_RESOLVER_SHAREDSTYLEFINDER_H_
23 #define SKY_ENGINE_CORE_CSS_RESOLVER_SHAREDSTYLEFINDER_H_ 23 #define SKY_ENGINE_CORE_CSS_RESOLVER_SHAREDSTYLEFINDER_H_
24 24
25 #include "sky/engine/core/css/resolver/ElementResolveContext.h" 25 #include "sky/engine/core/css/resolver/ElementResolveContext.h"
26 #include "sky/engine/core/dom/Element.h" 26 #include "sky/engine/core/dom/Element.h"
27 27
28 namespace blink { 28 namespace blink {
29 29
30 class ContainerNode;
30 class Element; 31 class Element;
31 class Node;
32 class RenderStyle; 32 class RenderStyle;
33 class RuleFeatureSet;
34 class RuleSet;
35 class SpaceSplitString;
36 class StyleResolver; 33 class StyleResolver;
37 34
38 class SharedStyleFinder { 35 class SharedStyleFinder {
39 STACK_ALLOCATED(); 36 STACK_ALLOCATED();
40 public: 37 public:
41 // RuleSets are passed non-const as the act of matching against them can cau se them 38 // RuleSets are passed non-const as the act of matching against them can cau se them
42 // to be compacted. :( 39 // to be compacted. :(
43 SharedStyleFinder(const ElementResolveContext& context, 40 SharedStyleFinder(const ElementResolveContext& context, StyleResolver& style Resolver)
44 const RuleFeatureSet& features, StyleResolver& styleResolver)
45 : m_elementAffectedByClassRules(false) 41 : m_elementAffectedByClassRules(false)
46 , m_features(features)
47 , m_styleResolver(styleResolver) 42 , m_styleResolver(styleResolver)
48 , m_context(context) 43 , m_context(context)
49 , m_renderingParent(nullptr) 44 , m_renderingParent(nullptr)
50 { } 45 { }
51 46
52 RenderStyle* findSharedStyle(); 47 RenderStyle* findSharedStyle();
53 48
54 private: 49 private:
55 Element* findElementForStyleSharing() const; 50 Element* findElementForStyleSharing() const;
56 51
57 // Only used when we're collecting stats on styles. 52 // Only used when we're collecting stats on styles.
58 bool documentContainsValidCandidate() const; 53 bool documentContainsValidCandidate() const;
59 54
60 bool classNamesAffectedByRules(const Element&) const; 55 bool classNamesAffectedByRules(const Element&) const;
61 bool attributesAffectedByRules(const Element&) const; 56 bool attributesAffectedByRules(const Element&) const;
62 57
63 bool canShareStyleWithElement(Element& candidate) const; 58 bool canShareStyleWithElement(Element& candidate) const;
64 bool sharingCandidateHasIdenticalStyleAffectingAttributes(Element& candidate ) const; 59 bool sharingCandidateHasIdenticalStyleAffectingAttributes(Element& candidate ) const;
65 bool sharingCandidateCanShareHostStyles(Element& candidate) const; 60 bool sharingCandidateCanShareHostStyles(Element& candidate) const;
66 bool sharingCandidateDistributedToSameInsertionPoint(Element& candidate) con st; 61 bool sharingCandidateDistributedToSameInsertionPoint(Element& candidate) con st;
67 62
68 Element& element() const { return *m_context.element(); } 63 Element& element() const { return *m_context.element(); }
69 Document& document() const { return element().document(); } 64 Document& document() const { return element().document(); }
70 65
71 bool m_elementAffectedByClassRules; 66 bool m_elementAffectedByClassRules;
72 const RuleFeatureSet& m_features;
73 StyleResolver& m_styleResolver; 67 StyleResolver& m_styleResolver;
74 const ElementResolveContext& m_context; 68 const ElementResolveContext& m_context;
75 ContainerNode* m_renderingParent; 69 ContainerNode* m_renderingParent;
76 }; 70 };
77 71
78 } // namespace blink 72 } // namespace blink
79 73
80 #endif // SKY_ENGINE_CORE_CSS_RESOLVER_SHAREDSTYLEFINDER_H_ 74 #endif // SKY_ENGINE_CORE_CSS_RESOLVER_SHAREDSTYLEFINDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698