| 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 | |
| 39 #include <wtf/HashMap.h> | |
| 40 | |
| 41 namespace WebCore { | |
| 42 | |
| 43 class FillLayer; | |
| 44 class FontDescription; | |
| 45 class RenderRegion; | |
| 46 class StyledElement; | |
| 47 | |
| 48 typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; | |
| 49 #if ENABLE(SVG) | |
| 50 typedef HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue> > Pendin
gSVGDocumentMap; | |
| 51 #endif | |
| 52 | |
| 53 class StyleResolverState { | |
| 54 WTF_MAKE_NONCOPYABLE(StyleResolverState); | |
| 55 public: | |
| 56 StyleResolverState() | |
| 57 : m_element(0) | |
| 58 , m_styledElement(0) | |
| 59 , m_parentNode(0) | |
| 60 , m_parentStyle(0) | |
| 61 , m_rootElementStyle(0) | |
| 62 , m_regionForStyling(0) | |
| 63 , m_elementLinkState(NotInsideLink) | |
| 64 , m_distributedToInsertionPoint(false) | |
| 65 , m_elementAffectedByClassRules(false) | |
| 66 , m_applyPropertyToRegularStyle(true) | |
| 67 , m_applyPropertyToVisitedLinkStyle(false) | |
| 68 , m_hasPendingShaders(false) | |
| 69 , m_lineHeightValue(0) | |
| 70 , m_fontDirty(false) | |
| 71 , m_hasUAAppearance(false) | |
| 72 , m_backgroundData(BackgroundFillLayer) { } | |
| 73 | |
| 74 public: | |
| 75 void initElement(Element*); | |
| 76 void initForStyleResolve(Document*, Element*, RenderStyle* parentStyle =
0, RenderRegion* regionForStyling = 0); | |
| 77 void clear(); | |
| 78 | |
| 79 Color colorFromPrimitiveValue(CSSPrimitiveValue*, bool forVisitedLink =
false) const; | |
| 80 | |
| 81 Document* document() const { return m_element->document(); } | |
| 82 Element* element() const { return m_element; } | |
| 83 StyledElement* styledElement() const { return m_styledElement; } | |
| 84 void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; } | |
| 85 RenderStyle* style() const { return m_style.get(); } | |
| 86 PassRefPtr<RenderStyle> takeStyle() { return m_style.release(); } | |
| 87 | |
| 88 const ContainerNode* parentNode() const { return m_parentNode; } | |
| 89 void setParentStyle(PassRefPtr<RenderStyle> parentStyle) { m_parentStyle
= parentStyle; } | |
| 90 RenderStyle* parentStyle() const { return m_parentStyle.get(); } | |
| 91 RenderStyle* rootElementStyle() const { return m_rootElementStyle; } | |
| 92 | |
| 93 const RenderRegion* regionForStyling() const { return m_regionForStyling
; } | |
| 94 EInsideLink elementLinkState() const { return m_elementLinkState; } | |
| 95 bool distributedToInsertionPoint() const { return m_distributedToInserti
onPoint; } | |
| 96 void setElementAffectedByClassRules(bool isAffected) { m_elementAffected
ByClassRules = isAffected; } | |
| 97 bool elementAffectedByClassRules() const { return m_elementAffectedByCla
ssRules; } | |
| 98 | |
| 99 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToReg
ularStyle = isApply; } | |
| 100 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyT
oVisitedLinkStyle = isApply; } | |
| 101 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegul
arStyle; } | |
| 102 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToV
isitedLinkStyle; } | |
| 103 PendingImagePropertyMap& pendingImageProperties() { return m_pendingImag
eProperties; } | |
| 104 #if ENABLE(SVG) | |
| 105 PendingSVGDocumentMap& pendingSVGDocuments() { return m_pendingSVGDocume
nts; } | |
| 106 #endif | |
| 107 void setHasPendingShaders(bool hasPendingShaders) { m_hasPendingShaders
= hasPendingShaders; } | |
| 108 bool hasPendingShaders() const { return m_hasPendingShaders; } | |
| 109 | |
| 110 void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; } | |
| 111 CSSValue* lineHeightValue() { return m_lineHeightValue; } | |
| 112 void setFontDirty(bool isDirty) { m_fontDirty = isDirty; } | |
| 113 bool fontDirty() const { return m_fontDirty; } | |
| 114 | |
| 115 void cacheBorderAndBackground(); | |
| 116 bool hasUAAppearance() const { return m_hasUAAppearance; } | |
| 117 BorderData borderData() const { return m_borderData; } | |
| 118 FillLayer backgroundData() const { return m_backgroundData; } | |
| 119 Color backgroundColor() const { return m_backgroundColor; } | |
| 120 | |
| 121 const FontDescription& fontDescription() { return m_style->fontDescripti
on(); } | |
| 122 const FontDescription& parentFontDescription() { return m_parentStyle->f
ontDescription(); } | |
| 123 void setFontDescription(const FontDescription& fontDescription) { m_font
Dirty |= m_style->setFontDescription(fontDescription); } | |
| 124 void setZoom(float f) { m_fontDirty |= m_style->setZoom(f); } | |
| 125 void setEffectiveZoom(float f) { m_fontDirty |= m_style->setEffectiveZoo
m(f); } | |
| 126 void setWritingMode(WritingMode writingMode) { m_fontDirty |= m_style->s
etWritingMode(writingMode); } | |
| 127 void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |
= m_style->setTextOrientation(textOrientation); } | |
| 128 | |
| 129 bool useSVGZoomRules() const { return m_element && m_element->isSVGEleme
nt(); } | |
| 130 | |
| 131 private: | |
| 132 // FIXME(bug 108563): to make it easier to review, these member | |
| 133 // variables are public. However we should add methods to access | |
| 134 // these variables. | |
| 135 Element* m_element; | |
| 136 RefPtr<RenderStyle> m_style; | |
| 137 StyledElement* m_styledElement; | |
| 138 ContainerNode* m_parentNode; | |
| 139 RefPtr<RenderStyle> m_parentStyle; | |
| 140 RenderStyle* m_rootElementStyle; | |
| 141 | |
| 142 // Required to ASSERT in applyProperties. | |
| 143 RenderRegion* m_regionForStyling; | |
| 144 | |
| 145 EInsideLink m_elementLinkState; | |
| 146 | |
| 147 bool m_distributedToInsertionPoint; | |
| 148 | |
| 149 bool m_elementAffectedByClassRules; | |
| 150 | |
| 151 bool m_applyPropertyToRegularStyle; | |
| 152 bool m_applyPropertyToVisitedLinkStyle; | |
| 153 | |
| 154 PendingImagePropertyMap m_pendingImageProperties; | |
| 155 bool m_hasPendingShaders; | |
| 156 #if ENABLE(SVG) | |
| 157 PendingSVGDocumentMap m_pendingSVGDocuments; | |
| 158 #endif | |
| 159 CSSValue* m_lineHeightValue; | |
| 160 bool m_fontDirty; | |
| 161 | |
| 162 bool m_hasUAAppearance; | |
| 163 BorderData m_borderData; | |
| 164 FillLayer m_backgroundData; | |
| 165 Color m_backgroundColor; | |
| 166 }; | |
| 167 | |
| 168 } // namespace WebCore | |
| 169 | |
| 170 #endif // StyleResolverState_h | |
| OLD | NEW |