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.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include <memory> | 40 #include <memory> |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 class FontDescription; | 44 class FontDescription; |
45 | 45 |
46 class CORE_EXPORT StyleResolverState { | 46 class CORE_EXPORT StyleResolverState { |
47 STACK_ALLOCATED(); | 47 STACK_ALLOCATED(); |
48 WTF_MAKE_NONCOPYABLE(StyleResolverState); | 48 WTF_MAKE_NONCOPYABLE(StyleResolverState); |
49 public: | 49 public: |
| 50 StyleResolverState(const ComputedStyle* parentStyle); |
50 StyleResolverState(Document&, const ElementResolveContext&, const ComputedSt
yle* parentStyle); | 51 StyleResolverState(Document&, const ElementResolveContext&, const ComputedSt
yle* parentStyle); |
51 StyleResolverState(Document&, Element*, const ComputedStyle* parentStyle = 0
); | 52 StyleResolverState(Document&, Element*, const ComputedStyle* parentStyle = 0
); |
52 ~StyleResolverState(); | 53 ~StyleResolverState(); |
53 | 54 |
54 // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to
grab the document from. | 55 // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to
grab the document from. |
55 // This is why we have to store the document separately. | 56 // This is why we have to store the document separately. |
| 57 bool hasDocument() const { return m_document; } |
56 Document& document() const { return *m_document; } | 58 Document& document() const { return *m_document; } |
57 // These are all just pass-through methods to ElementResolveContext. | 59 // These are all just pass-through methods to ElementResolveContext. |
58 Element* element() const { return m_elementContext.element(); } | 60 Element* element() const { return m_elementContext.element(); } |
59 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } | 61 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } |
60 const ComputedStyle* rootElementStyle() const { return m_elementContext.root
ElementStyle(); } | 62 const ComputedStyle* rootElementStyle() const { return m_elementContext.root
ElementStyle(); } |
61 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } | 63 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } |
62 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } | 64 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } |
63 | 65 |
64 const ElementResolveContext& elementContext() const { return m_elementContex
t; } | 66 const ElementResolveContext& elementContext() const { return m_elementContex
t; } |
65 | 67 |
66 void setStyle(PassRefPtr<ComputedStyle> style) | 68 void setStyle(PassRefPtr<ComputedStyle> style) |
67 { | 69 { |
68 // FIXME: Improve RAII of StyleResolverState to remove this function. | 70 // FIXME: Improve RAII of StyleResolverState to remove this function. |
69 m_style = style; | 71 m_style = style; |
70 m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), r
ootElementStyle(), document().layoutViewItem(), m_style->effectiveZoom()); | 72 if (m_document) { |
| 73 m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(
), rootElementStyle(), document().layoutViewItem(), m_style->effectiveZoom()); |
| 74 } else { |
| 75 m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(
), m_style->effectiveZoom()); |
| 76 } |
71 } | 77 } |
72 const ComputedStyle* style() const { return m_style.get(); } | 78 const ComputedStyle* style() const { return m_style.get(); } |
73 ComputedStyle* style() { return m_style.get(); } | 79 ComputedStyle* style() { return m_style.get(); } |
74 PassRefPtr<ComputedStyle> takeStyle() { return m_style.release(); } | 80 PassRefPtr<ComputedStyle> takeStyle() { return m_style.release(); } |
75 | 81 |
76 ComputedStyle& mutableStyleRef() const { return *m_style; } | 82 ComputedStyle& mutableStyleRef() const { return *m_style; } |
77 const ComputedStyle& styleRef() const { return mutableStyleRef(); } | 83 const ComputedStyle& styleRef() const { return mutableStyleRef(); } |
78 | 84 |
79 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } | 85 const CSSToLengthConversionData& cssToLengthConversionData() const { return
m_cssToLengthConversionData; } |
80 CSSToLengthConversionData fontSizeConversionData() const; | 86 CSSToLengthConversionData fontSizeConversionData() const; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 196 |
191 HeapHashMap<String, Member<StylePropertySet>> m_customPropertySetsForApplyAt
Rule; | 197 HeapHashMap<String, Member<StylePropertySet>> m_customPropertySetsForApplyAt
Rule; |
192 | 198 |
193 HeapHashMap<Member<const CSSPendingSubstitutionValue>, Member<HeapHashMap<CS
SPropertyID, Member<const CSSValue>>>> m_parsedPropertiesForPendingSubstitution; | 199 HeapHashMap<Member<const CSSPendingSubstitutionValue>, Member<HeapHashMap<CS
SPropertyID, Member<const CSSValue>>>> m_parsedPropertiesForPendingSubstitution; |
194 | 200 |
195 }; | 201 }; |
196 | 202 |
197 } // namespace blink | 203 } // namespace blink |
198 | 204 |
199 #endif // StyleResolverState_h | 205 #endif // StyleResolverState_h |
OLD | NEW |