| OLD | NEW |
| (Empty) | |
| 1 /* |
| 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. |
| 4 * |
| 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. |
| 9 * |
| 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. |
| 14 * |
| 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. |
| 19 * |
| 20 */ |
| 21 |
| 22 #ifndef StyleResolverState_h |
| 23 #define StyleResolverState_h |
| 24 |
| 25 #include "CSSPropertyNames.h" |
| 26 |
| 27 #include "core/css/CSSValueList.h" |
| 28 #if ENABLE(SVG) |
| 29 #include "core/css/WebKitCSSSVGDocumentValue.h" |
| 30 #endif |
| 31 #include "core/dom/Element.h" |
| 32 #include "core/platform/graphics/Color.h" |
| 33 #include "core/platform/graphics/filters/FilterOperations.h" |
| 34 #include "core/rendering/style/BorderData.h" |
| 35 #include "core/rendering/style/FillLayer.h" |
| 36 #include "core/rendering/style/RenderStyle.h" |
| 37 #include "core/rendering/style/StyleInheritedData.h" |
| 38 #include "wtf/HashMap.h" |
| 39 |
| 40 namespace WebCore { |
| 41 |
| 42 class FillLayer; |
| 43 class FontDescription; |
| 44 class RenderRegion; |
| 45 class StyledElement; |
| 46 |
| 47 typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; |
| 48 #if ENABLE(SVG) |
| 49 typedef HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > PendingSVG
DocumentMap; |
| 50 #endif |
| 51 |
| 52 class StyleResolverState { |
| 53 WTF_MAKE_NONCOPYABLE(StyleResolverState); |
| 54 public: |
| 55 StyleResolverState() |
| 56 : m_element(0) |
| 57 , m_styledElement(0) |
| 58 , m_parentNode(0) |
| 59 , m_parentStyle(0) |
| 60 , m_rootElementStyle(0) |
| 61 , m_regionForStyling(0) |
| 62 , m_elementLinkState(NotInsideLink) |
| 63 , m_distributedToInsertionPoint(false) |
| 64 , m_elementAffectedByClassRules(false) |
| 65 , m_applyPropertyToRegularStyle(true) |
| 66 , m_applyPropertyToVisitedLinkStyle(false) |
| 67 , m_hasPendingShaders(false) |
| 68 , m_lineHeightValue(0) |
| 69 , m_fontDirty(false) |
| 70 , m_hasUAAppearance(false) |
| 71 , m_backgroundData(BackgroundFillLayer) { } |
| 72 |
| 73 public: |
| 74 void initElement(Element*); |
| 75 void initForStyleResolve(Document*, Element*, RenderStyle* parentStyle = 0,
RenderRegion* regionForStyling = 0); |
| 76 void clear(); |
| 77 |
| 78 Color colorFromPrimitiveValue(CSSPrimitiveValue*, bool forVisitedLink = fals
e) const; |
| 79 |
| 80 Document* document() const { return m_element->document(); } |
| 81 Element* element() const { return m_element; } |
| 82 StyledElement* styledElement() const { return m_styledElement; } |
| 83 void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; } |
| 84 RenderStyle* style() const { return m_style.get(); } |
| 85 PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); } |
| 86 |
| 87 const ContainerNode* parentNode() const { return m_parentNode; } |
| 88 void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_parentStyle = p
arentStyle; } |
| 89 RenderStyle* parentStyle() const { return m_parentStyle.get(); } |
| 90 RenderStyle* rootElementStyle() const { return m_rootElementStyle; } |
| 91 |
| 92 const RenderRegion* regionForStyling() const { return m_regionForStyling; } |
| 93 EInsideLink elementLinkState() const { return m_elementLinkState; } |
| 94 bool distributedToInsertionPoint() const { return m_distributedToInsertionPo
int; } |
| 95 void setElementAffectedByClassRules(bool isAffected) { m_elementAffectedByCl
assRules = isAffected; } |
| 96 bool elementAffectedByClassRules() const { return m_elementAffectedByClassRu
les; } |
| 97 |
| 98 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular
Style = isApply; } |
| 99 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis
itedLinkStyle = isApply; } |
| 100 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt
yle; } |
| 101 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit
edLinkStyle; } |
| 102 PendingImagePropertyMap& pendingImageProperties() { return m_pendingImagePro
perties; } |
| 103 #if ENABLE(SVG) |
| 104 PendingSVGDocumentMap& pendingSVGDocuments() { return m_pendingSVGDocuments;
} |
| 105 #endif |
| 106 void setHasPendingShaders(bool hasPendingShaders) { m_hasPendingShaders = ha
sPendingShaders; } |
| 107 bool hasPendingShaders() const { return m_hasPendingShaders; } |
| 108 |
| 109 void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; } |
| 110 CSSValue* lineHeightValue() { return m_lineHeightValue; } |
| 111 void setFontDirty(bool isDirty) { m_fontDirty = isDirty; } |
| 112 bool fontDirty() const { return m_fontDirty; } |
| 113 |
| 114 void cacheBorderAndBackground(); |
| 115 bool hasUAAppearance() const { return m_hasUAAppearance; } |
| 116 BorderData borderData() const { return m_borderData; } |
| 117 FillLayer backgroundData() const { return m_backgroundData; } |
| 118 Color backgroundColor() const { return m_backgroundColor; } |
| 119 |
| 120 const FontDescription& fontDescription() { return m_style->fontDescription()
; } |
| 121 const FontDescription& parentFontDescription() { return m_parentStyle->fontD
escription(); } |
| 122 void setFontDescription(const FontDescription& fontDescription) { m_fontDirt
y |= m_style->setFontDescription(fontDescription); } |
| 123 void setZoom(float f) { m_fontDirty |= m_style->setZoom(f); } |
| 124 void setEffectiveZoom(float f) { m_fontDirty |= m_style->setEffectiveZoom(f)
; } |
| 125 void setWritingMode(WritingMode writingMode) { m_fontDirty |= m_style->setWr
itingMode(writingMode); } |
| 126 void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= m_
style->setTextOrientation(textOrientation); } |
| 127 |
| 128 bool useSVGZoomRules() const { return m_element && m_element->isSVGElement()
; } |
| 129 |
| 130 private: |
| 131 // FIXME(bug 108563): to make it easier to review, these member |
| 132 // variables are public. However we should add methods to access |
| 133 // these variables. |
| 134 Element* m_element; |
| 135 RefPtr<RenderStyle> m_style; |
| 136 StyledElement* m_styledElement; |
| 137 ContainerNode* m_parentNode; |
| 138 RefPtr<RenderStyle> m_parentStyle; |
| 139 RenderStyle* m_rootElementStyle; |
| 140 |
| 141 // Required to ASSERT in applyProperties. |
| 142 RenderRegion* m_regionForStyling; |
| 143 |
| 144 EInsideLink m_elementLinkState; |
| 145 |
| 146 bool m_distributedToInsertionPoint; |
| 147 |
| 148 bool m_elementAffectedByClassRules; |
| 149 |
| 150 bool m_applyPropertyToRegularStyle; |
| 151 bool m_applyPropertyToVisitedLinkStyle; |
| 152 |
| 153 PendingImagePropertyMap m_pendingImageProperties; |
| 154 bool m_hasPendingShaders; |
| 155 #if ENABLE(SVG) |
| 156 PendingSVGDocumentMap m_pendingSVGDocuments; |
| 157 #endif |
| 158 CSSValue* m_lineHeightValue; |
| 159 bool m_fontDirty; |
| 160 |
| 161 bool m_hasUAAppearance; |
| 162 BorderData m_borderData; |
| 163 FillLayer m_backgroundData; |
| 164 Color m_backgroundColor; |
| 165 }; |
| 166 |
| 167 } // namespace WebCore |
| 168 |
| 169 #endif // StyleResolverState_h |
| OLD | NEW |