OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
4 * All rights reserved. | 4 * 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 * |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "core/dom/Node.h" | 27 #include "core/dom/Node.h" |
28 #include "core/dom/NodeComputedStyle.h" | 28 #include "core/dom/NodeComputedStyle.h" |
29 #include "core/frame/FrameHost.h" | 29 #include "core/frame/FrameHost.h" |
30 #include "core/layout/api/LayoutViewItem.h" | 30 #include "core/layout/api/LayoutViewItem.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 StyleResolverState::StyleResolverState( | 34 StyleResolverState::StyleResolverState( |
35 Document& document, | 35 Document& document, |
36 const ElementResolveContext& elementContext, | 36 const ElementResolveContext& elementContext, |
37 const ComputedStyle* parentStyle) | 37 const ComputedStyle* parentStyle, |
| 38 const ComputedStyle* layoutParentStyle) |
38 : m_elementContext(elementContext), | 39 : m_elementContext(elementContext), |
39 m_document(document), | 40 m_document(document), |
40 m_style(nullptr), | 41 m_style(nullptr), |
41 // TODO(jchaffraix): We should make m_parentStyle const | 42 // TODO(jchaffraix): We should make m_parentStyle const |
42 // (https://crbug.com/468152) | 43 // (https://crbug.com/468152) |
43 m_parentStyle(const_cast<ComputedStyle*>(parentStyle)), | 44 m_parentStyle(const_cast<ComputedStyle*>(parentStyle)), |
| 45 m_layoutParentStyle(layoutParentStyle), |
44 m_applyPropertyToRegularStyle(true), | 46 m_applyPropertyToRegularStyle(true), |
45 m_applyPropertyToVisitedLinkStyle(false), | 47 m_applyPropertyToVisitedLinkStyle(false), |
46 m_hasDirAutoAttribute(false), | 48 m_hasDirAutoAttribute(false), |
47 m_fontBuilder(document), | 49 m_fontBuilder(document), |
48 m_elementStyleResources(document, document.devicePixelRatio()) { | 50 m_elementStyleResources(document, document.devicePixelRatio()) { |
| 51 DCHECK(!!m_parentStyle == !!m_layoutParentStyle); |
| 52 |
49 if (!m_parentStyle) { | 53 if (!m_parentStyle) { |
50 // TODO(jchaffraix): We should make m_parentStyle const | 54 // TODO(jchaffraix): We should make m_parentStyle const |
51 // (https://crbug.com/468152) | 55 // (https://crbug.com/468152) |
52 m_parentStyle = const_cast<ComputedStyle*>(m_elementContext.parentStyle()); | 56 m_parentStyle = const_cast<ComputedStyle*>(m_elementContext.parentStyle()); |
53 } | 57 } |
54 | 58 |
| 59 if (!m_layoutParentStyle) |
| 60 m_layoutParentStyle = m_elementContext.layoutParentStyle(); |
| 61 |
| 62 if (!m_layoutParentStyle) |
| 63 m_layoutParentStyle = m_parentStyle; |
| 64 |
55 DCHECK(document.isActive()); | 65 DCHECK(document.isActive()); |
56 } | 66 } |
57 | 67 |
58 StyleResolverState::StyleResolverState(Document& document, | 68 StyleResolverState::StyleResolverState(Document& document, |
59 Element* element, | 69 Element* element, |
60 const ComputedStyle* parentStyle) | 70 const ComputedStyle* parentStyle, |
| 71 const ComputedStyle* layoutParentStyle) |
61 : StyleResolverState(document, | 72 : StyleResolverState(document, |
62 element ? ElementResolveContext(*element) | 73 element ? ElementResolveContext(*element) |
63 : ElementResolveContext(document), | 74 : ElementResolveContext(document), |
64 parentStyle) {} | 75 parentStyle, |
| 76 layoutParentStyle) {} |
65 | 77 |
66 StyleResolverState::~StyleResolverState() { | 78 StyleResolverState::~StyleResolverState() { |
67 // For performance reasons, explicitly clear HeapVectors and | 79 // For performance reasons, explicitly clear HeapVectors and |
68 // HeapHashMaps to avoid giving a pressure on Oilpan's GC. | 80 // HeapHashMaps to avoid giving a pressure on Oilpan's GC. |
69 m_animationUpdate.clear(); | 81 m_animationUpdate.clear(); |
70 } | 82 } |
71 | 83 |
72 void StyleResolverState::setStyle(PassRefPtr<ComputedStyle> style) { | 84 void StyleResolverState::setStyle(PassRefPtr<ComputedStyle> style) { |
73 // FIXME: Improve RAII of StyleResolverState to remove this function. | 85 // FIXME: Improve RAII of StyleResolverState to remove this function. |
74 m_style = style; | 86 m_style = style; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 HeapHashMap<CSSPropertyID, Member<const CSSValue>>* map = | 121 HeapHashMap<CSSPropertyID, Member<const CSSValue>>* map = |
110 m_parsedPropertiesForPendingSubstitutionCache.get(&value); | 122 m_parsedPropertiesForPendingSubstitutionCache.get(&value); |
111 if (!map) { | 123 if (!map) { |
112 map = new HeapHashMap<CSSPropertyID, Member<const CSSValue>>; | 124 map = new HeapHashMap<CSSPropertyID, Member<const CSSValue>>; |
113 m_parsedPropertiesForPendingSubstitutionCache.set(&value, map); | 125 m_parsedPropertiesForPendingSubstitutionCache.set(&value, map); |
114 } | 126 } |
115 return *map; | 127 return *map; |
116 } | 128 } |
117 | 129 |
118 } // namespace blink | 130 } // namespace blink |
OLD | NEW |