darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | f5247d1 | 2010-06-13 17:29:10 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008 David Smith <catfish.man@gmail.com> |
| 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 ElementRareData_h |
| 23 | #define ElementRareData_h |
| 24 | |
commit-queue@webkit.org | 691d04f | 2010-10-29 09:32:14 +0000 | [diff] [blame] | 25 | #include "ClassList.h" |
weinig@apple.com | 96a2cf9 | 2010-06-30 23:15:15 +0000 | [diff] [blame] | 26 | #include "DatasetDOMStringMap.h" |
morrita@google.com | 948bd53 | 2012-05-07 06:05:42 +0000 | [diff] [blame] | 27 | #include "ElementShadow.h" |
caio.oliveira@openbossa.org | 26b85d3 | 2012-03-08 17:42:28 +0000 | [diff] [blame] | 28 | #include "NamedNodeMap.h" |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 29 | #include "NodeRareData.h" |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame^] | 30 | #include "PseudoElement.h" |
commit-queue@webkit.org | d0c076d | 2012-08-22 22:25:59 +0000 | [diff] [blame] | 31 | #include "StyleInheritedData.h" |
weinig@apple.com | 96a2cf9 | 2010-06-30 23:15:15 +0000 | [diff] [blame] | 32 | #include <wtf/OwnPtr.h> |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 33 | |
| 34 | namespace WebCore { |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 35 | |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 36 | class ElementRareData : public NodeRareData { |
| 37 | public: |
commit-queue@webkit.org | f0dfc63 | 2012-12-02 11:16:33 +0000 | [diff] [blame] | 38 | ElementRareData(Document*); |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 39 | virtual ~ElementRareData(); |
darin@apple.com | 929b907 | 2008-12-13 22:53:55 +0000 | [diff] [blame] | 40 | |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame^] | 41 | void setPseudoElement(PseudoId, PassRefPtr<PseudoElement>); |
| 42 | PseudoElement* pseudoElement(PseudoId) const; |
| 43 | |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 44 | void resetComputedStyle(); |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 45 | void resetDynamicRestyleObservations(); |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 46 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 47 | bool needsFocusAppearanceUpdateSoonAfterAttach() const { return m_needsFocusAppearanceUpdateSoonAfterAttach; } |
| 48 | void setNeedsFocusAppearanceUpdateSoonAfterAttach(bool needs) { m_needsFocusAppearanceUpdateSoonAfterAttach = needs; } |
| 49 | |
| 50 | bool styleAffectedByEmpty() const { return m_styleAffectedByEmpty; } |
| 51 | void setStyleAffectedByEmpty(bool value) { m_styleAffectedByEmpty = value; } |
| 52 | |
| 53 | bool isInCanvasSubtree() const { return m_isInCanvasSubtree; } |
| 54 | void setIsInCanvasSubtree(bool value) { m_isInCanvasSubtree = value; } |
| 55 | |
kling@webkit.org | c7b06df | 2012-10-03 12:55:24 +0000 | [diff] [blame] | 56 | #if ENABLE(FULLSCREEN_API) |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 57 | bool containsFullScreenElement() { return m_containsFullScreenElement; } |
| 58 | void setContainsFullScreenElement(bool value) { m_containsFullScreenElement = value; } |
kling@webkit.org | c7b06df | 2012-10-03 12:55:24 +0000 | [diff] [blame] | 59 | #endif |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 60 | |
commit-queue@webkit.org | 86b2dc1 | 2012-11-20 04:45:02 +0000 | [diff] [blame] | 61 | #if ENABLE(DIALOG_ELEMENT) |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 62 | bool isInTopLayer() const { return m_isInTopLayer; } |
| 63 | void setIsInTopLayer(bool value) { m_isInTopLayer = value; } |
commit-queue@webkit.org | 86b2dc1 | 2012-11-20 04:45:02 +0000 | [diff] [blame] | 64 | #endif |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 65 | |
| 66 | bool childrenAffectedByHover() const { return m_childrenAffectedByHover; } |
| 67 | void setChildrenAffectedByHover(bool value) { m_childrenAffectedByHover = value; } |
| 68 | bool childrenAffectedByActive() const { return m_childrenAffectedByActive; } |
| 69 | void setChildrenAffectedByActive(bool value) { m_childrenAffectedByActive = value; } |
| 70 | bool childrenAffectedByDrag() const { return m_childrenAffectedByDrag; } |
| 71 | void setChildrenAffectedByDrag(bool value) { m_childrenAffectedByDrag = value; } |
| 72 | |
| 73 | bool childrenAffectedByFirstChildRules() const { return m_childrenAffectedByFirstChildRules; } |
| 74 | void setChildrenAffectedByFirstChildRules(bool value) { m_childrenAffectedByFirstChildRules = value; } |
| 75 | bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByLastChildRules; } |
| 76 | void setChildrenAffectedByLastChildRules(bool value) { m_childrenAffectedByLastChildRules = value; } |
| 77 | bool childrenAffectedByDirectAdjacentRules() const { return m_childrenAffectedByDirectAdjacentRules; } |
| 78 | void setChildrenAffectedByDirectAdjacentRules(bool value) { m_childrenAffectedByDirectAdjacentRules = value; } |
| 79 | bool childrenAffectedByForwardPositionalRules() const { return m_childrenAffectedByForwardPositionalRules; } |
| 80 | void setChildrenAffectedByForwardPositionalRules(bool value) { m_childrenAffectedByForwardPositionalRules = value; } |
| 81 | bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; } |
| 82 | void setChildrenAffectedByBackwardPositionalRules(bool value) { m_childrenAffectedByBackwardPositionalRules = value; } |
| 83 | unsigned childIndex() const { return m_childIndex; } |
| 84 | void setChildIndex(unsigned index) { m_childIndex = index; } |
darin@apple.com | 929b907 | 2008-12-13 22:53:55 +0000 | [diff] [blame] | 85 | |
loislo@chromium.org | edc2201 | 2012-11-02 09:11:19 +0000 | [diff] [blame] | 86 | virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; |
| 87 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 88 | ElementShadow* shadow() const { return m_shadow.get(); } |
| 89 | void setShadow(PassOwnPtr<ElementShadow> shadow) { m_shadow = shadow; } |
| 90 | |
| 91 | NamedNodeMap* attributeMap() const { return m_attributeMap.get(); } |
| 92 | void setAttributeMap(PassOwnPtr<NamedNodeMap> attributeMap) { m_attributeMap = attributeMap; } |
| 93 | |
| 94 | RenderStyle* computedStyle() const { return m_computedStyle.get(); } |
| 95 | void setComputedStyle(PassRefPtr<RenderStyle> computedStyle) { m_computedStyle = computedStyle; } |
| 96 | |
| 97 | ClassList* classList() const { return m_classList.get(); } |
| 98 | void setClassList(PassOwnPtr<ClassList> classList) { m_classList = classList; } |
| 99 | |
| 100 | DatasetDOMStringMap* dataset() const { return m_dataset.get(); } |
| 101 | void setDataset(PassOwnPtr<DatasetDOMStringMap> dataset) { m_dataset = dataset; } |
| 102 | |
| 103 | LayoutSize minimumSizeForResizing() const { return m_minimumSizeForResizing; } |
| 104 | void setMinimumSizeForResizing(LayoutSize size) { m_minimumSizeForResizing = size; } |
| 105 | |
| 106 | IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } |
| 107 | void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = size; } |
| 108 | |
| 109 | private: |
| 110 | // Many fields are in NodeRareData for better packing. |
eae@chromium.org | 5b93f41 | 2011-08-15 23:51:21 +0000 | [diff] [blame] | 111 | LayoutSize m_minimumSizeForResizing; |
hyatt@apple.com | dec0cbf2 | 2008-10-17 00:25:33 +0000 | [diff] [blame] | 112 | RefPtr<RenderStyle> m_computedStyle; |
weinig@apple.com | 96a2cf9 | 2010-06-30 23:15:15 +0000 | [diff] [blame] | 113 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 114 | OwnPtr<DatasetDOMStringMap> m_dataset; |
commit-queue@webkit.org | 691d04f | 2010-10-29 09:32:14 +0000 | [diff] [blame] | 115 | OwnPtr<ClassList> m_classList; |
morrita@google.com | 948bd53 | 2012-05-07 06:05:42 +0000 | [diff] [blame] | 116 | OwnPtr<ElementShadow> m_shadow; |
caio.oliveira@openbossa.org | 26b85d3 | 2012-03-08 17:42:28 +0000 | [diff] [blame] | 117 | OwnPtr<NamedNodeMap> m_attributeMap; |
jer.noble@apple.com | 366ebb0 | 2011-05-30 02:05:30 +0000 | [diff] [blame] | 118 | |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame^] | 119 | RefPtr<PseudoElement> m_generatedBefore; |
| 120 | RefPtr<PseudoElement> m_generatedAfter; |
| 121 | |
commit-queue@webkit.org | ba181c4 | 2012-04-02 19:37:59 +0000 | [diff] [blame] | 122 | IntSize m_savedLayerScrollOffset; |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame^] | 123 | |
| 124 | private: |
| 125 | void releasePseudoElement(PseudoElement*); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | inline IntSize defaultMinimumSizeForResizing() |
| 129 | { |
eae@chromium.org | 9717cd8 | 2012-11-07 18:33:44 +0000 | [diff] [blame] | 130 | return IntSize(LayoutUnit::max(), LayoutUnit::max()); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 131 | } |
| 132 | |
commit-queue@webkit.org | f0dfc63 | 2012-12-02 11:16:33 +0000 | [diff] [blame] | 133 | inline ElementRareData::ElementRareData(Document* document) |
| 134 | : NodeRareData(document) |
| 135 | , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame^] | 136 | , m_generatedBefore(0) |
| 137 | , m_generatedAfter(0) |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 138 | { |
| 139 | } |
| 140 | |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 141 | inline ElementRareData::~ElementRareData() |
| 142 | { |
morrita@google.com | 948bd53 | 2012-05-07 06:05:42 +0000 | [diff] [blame] | 143 | ASSERT(!m_shadow); |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame^] | 144 | ASSERT(!m_generatedBefore); |
| 145 | ASSERT(!m_generatedAfter); |
| 146 | } |
| 147 | |
| 148 | inline void ElementRareData::setPseudoElement(PseudoId pseudoId, PassRefPtr<PseudoElement> element) |
| 149 | { |
| 150 | switch (pseudoId) { |
| 151 | case BEFORE: |
| 152 | releasePseudoElement(m_generatedBefore.get()); |
| 153 | m_generatedBefore = element; |
| 154 | break; |
| 155 | case AFTER: |
| 156 | releasePseudoElement(m_generatedAfter.get()); |
| 157 | m_generatedAfter = element; |
| 158 | break; |
| 159 | default: |
| 160 | ASSERT_NOT_REACHED(); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | inline PseudoElement* ElementRareData::pseudoElement(PseudoId pseudoId) const |
| 165 | { |
| 166 | switch (pseudoId) { |
| 167 | case BEFORE: |
| 168 | return m_generatedBefore.get(); |
| 169 | case AFTER: |
| 170 | return m_generatedAfter.get(); |
| 171 | default: |
| 172 | ASSERT_NOT_REACHED(); |
| 173 | return 0; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | inline void ElementRareData::releasePseudoElement(PseudoElement* element) |
| 178 | { |
| 179 | if (!element) |
| 180 | return; |
| 181 | |
| 182 | if (element->attached()) |
| 183 | element->detach(); |
| 184 | |
| 185 | ASSERT(!element->nextSibling()); |
| 186 | ASSERT(!element->previousSibling()); |
| 187 | |
| 188 | element->setParentOrHostNode(0); |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 189 | } |
| 190 | |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 191 | inline void ElementRareData::resetComputedStyle() |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 192 | { |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 193 | setComputedStyle(0); |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 194 | setStyleAffectedByEmpty(false); |
| 195 | setChildIndex(0); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 196 | } |
| 197 | |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 198 | inline void ElementRareData::resetDynamicRestyleObservations() |
| 199 | { |
| 200 | setChildrenAffectedByHover(false); |
| 201 | setChildrenAffectedByActive(false); |
| 202 | setChildrenAffectedByDrag(false); |
| 203 | setChildrenAffectedByFirstChildRules(false); |
| 204 | setChildrenAffectedByLastChildRules(false); |
| 205 | setChildrenAffectedByDirectAdjacentRules(false); |
| 206 | setChildrenAffectedByForwardPositionalRules(false); |
| 207 | setChildrenAffectedByBackwardPositionalRules(false); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 208 | } |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 209 | |
| 210 | } // namespace |
| 211 | |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 212 | #endif // ElementRareData_h |