1 /*
2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
4  * All rights reserved.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
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
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_ELEMENT_RESOLVE_CONTEXT_H_
24 #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_ELEMENT_RESOLVE_CONTEXT_H_
25 
26 #include "third_party/blink/renderer/core/dom/element.h"
27 #include "third_party/blink/renderer/core/style/computed_style_constants.h"
28 
29 namespace blink {
30 
31 class ContainerNode;
32 class Element;
33 class ComputedStyle;
34 
35 // Wraps an Element for use by ElementRuleCollector. Computes various values
36 // from the element for quick access during style calculation. It is immutable.
37 class CORE_EXPORT ElementResolveContext {
38   STACK_ALLOCATED();
39 
40  public:
41   explicit ElementResolveContext(Element&);
42 
GetElement()43   Element& GetElement() const { return *element_; }
ParentNode()44   const ContainerNode* ParentNode() const { return parent_node_; }
LayoutParent()45   const ContainerNode* LayoutParent() const { return layout_parent_; }
RootElementStyle()46   const ComputedStyle* RootElementStyle() const {
47     return root_element_style_.get();
48   }
ParentStyle()49   const ComputedStyle* ParentStyle() const {
50     return ParentNode() && ParentNode()->IsElementNode()
51                ? ParentNode()->GetComputedStyle()
52                : nullptr;
53   }
LayoutParentStyle()54   const ComputedStyle* LayoutParentStyle() const {
55     return LayoutParent() ? LayoutParent()->GetComputedStyle() : nullptr;
56   }
ElementLinkState()57   EInsideLink ElementLinkState() const { return element_link_state_; }
DistributedToV0InsertionPoint()58   bool DistributedToV0InsertionPoint() const {
59     return distributed_to_insertion_point_;
60   }
61 
62  private:
63   Element* element_;
64   ContainerNode* parent_node_;
65   ContainerNode* layout_parent_;
66   scoped_refptr<const ComputedStyle> root_element_style_;
67   EInsideLink element_link_state_;
68   bool distributed_to_insertion_point_;
69 };
70 
71 }  // namespace blink
72 
73 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_ELEMENT_RESOLVE_CONTEXT_H_
74