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" |
caio.oliveira@openbossa.org | 26b85d3 | 2012-03-08 17:42:28 +0000 | [diff] [blame] | 27 | #include "NamedNodeMap.h" |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 28 | #include "NodeRareData.h" |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 29 | #include "PseudoElement.h" |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 30 | #include "RenderElement.h" |
antti@apple.com | 64d6939 | 2013-08-15 16:52:40 +0000 | [diff] [blame] | 31 | #include "ShadowRoot.h" |
commit-queue@webkit.org | d0c076d | 2012-08-22 22:25:59 +0000 | [diff] [blame] | 32 | #include "StyleInheritedData.h" |
commit-queue@webkit.org | 1e0ed9d | 2014-02-25 20:42:44 +0000 | [diff] [blame] | 33 | #include <wtf/OwnPtr.h> |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 34 | |
| 35 | namespace WebCore { |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 36 | |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 37 | class ElementRareData : public NodeRareData { |
| 38 | public: |
commit-queue@webkit.org | 1e0ed9d | 2014-02-25 20:42:44 +0000 | [diff] [blame] | 39 | static PassOwnPtr<ElementRareData> create(RenderElement* renderer) { return adoptPtr(new ElementRareData(renderer)); } |
| 40 | |
rniwa@webkit.org | c311c02 | 2013-01-16 05:23:04 +0000 | [diff] [blame] | 41 | ~ElementRareData(); |
darin@apple.com | 929b907 | 2008-12-13 22:53:55 +0000 | [diff] [blame] | 42 | |
antti@apple.com | 9426a74 | 2013-08-24 11:09:26 +0000 | [diff] [blame] | 43 | void setBeforePseudoElement(PassRefPtr<PseudoElement>); |
| 44 | void setAfterPseudoElement(PassRefPtr<PseudoElement>); |
| 45 | |
| 46 | PseudoElement* beforePseudoElement() const { return m_beforePseudoElement.get(); } |
| 47 | PseudoElement* afterPseudoElement() const { return m_afterPseudoElement.get(); } |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 48 | |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 49 | void resetComputedStyle(); |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 50 | void resetDynamicRestyleObservations(); |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 51 | |
| 52 | short tabIndex() const { return m_tabIndex; } |
| 53 | void setTabIndexExplicitly(short index) { m_tabIndex = index; m_tabIndexWasSetExplicitly = true; } |
| 54 | bool tabIndexSetExplicitly() const { return m_tabIndexWasSetExplicitly; } |
| 55 | void clearTabIndexExplicitly() { m_tabIndex = 0; m_tabIndexWasSetExplicitly = false; } |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 56 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 57 | bool needsFocusAppearanceUpdateSoonAfterAttach() const { return m_needsFocusAppearanceUpdateSoonAfterAttach; } |
| 58 | void setNeedsFocusAppearanceUpdateSoonAfterAttach(bool needs) { m_needsFocusAppearanceUpdateSoonAfterAttach = needs; } |
| 59 | |
| 60 | bool styleAffectedByEmpty() const { return m_styleAffectedByEmpty; } |
| 61 | void setStyleAffectedByEmpty(bool value) { m_styleAffectedByEmpty = value; } |
| 62 | |
| 63 | bool isInCanvasSubtree() const { return m_isInCanvasSubtree; } |
| 64 | void setIsInCanvasSubtree(bool value) { m_isInCanvasSubtree = value; } |
| 65 | |
commit-queue@webkit.org | 75d76c4 | 2013-06-20 16:13:11 +0000 | [diff] [blame] | 66 | RegionOversetState regionOversetState() const { return m_regionOversetState; } |
| 67 | void setRegionOversetState(RegionOversetState state) { m_regionOversetState = state; } |
| 68 | |
kling@webkit.org | c7b06df | 2012-10-03 12:55:24 +0000 | [diff] [blame] | 69 | #if ENABLE(FULLSCREEN_API) |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 70 | bool containsFullScreenElement() { return m_containsFullScreenElement; } |
| 71 | void setContainsFullScreenElement(bool value) { m_containsFullScreenElement = value; } |
kling@webkit.org | c7b06df | 2012-10-03 12:55:24 +0000 | [diff] [blame] | 72 | #endif |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 73 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 74 | bool childrenAffectedByActive() const { return m_childrenAffectedByActive; } |
| 75 | void setChildrenAffectedByActive(bool value) { m_childrenAffectedByActive = value; } |
| 76 | bool childrenAffectedByDrag() const { return m_childrenAffectedByDrag; } |
| 77 | void setChildrenAffectedByDrag(bool value) { m_childrenAffectedByDrag = value; } |
| 78 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 79 | bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByLastChildRules; } |
| 80 | void setChildrenAffectedByLastChildRules(bool value) { m_childrenAffectedByLastChildRules = value; } |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 81 | bool childrenAffectedByForwardPositionalRules() const { return m_childrenAffectedByForwardPositionalRules; } |
| 82 | void setChildrenAffectedByForwardPositionalRules(bool value) { m_childrenAffectedByForwardPositionalRules = value; } |
| 83 | bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; } |
| 84 | void setChildrenAffectedByBackwardPositionalRules(bool value) { m_childrenAffectedByBackwardPositionalRules = value; } |
benjamin@webkit.org | 9c6a1c6 | 2014-04-14 08:42:53 +0000 | [diff] [blame] | 85 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 86 | unsigned childIndex() const { return m_childIndex; } |
| 87 | void setChildIndex(unsigned index) { m_childIndex = index; } |
benjamin@webkit.org | 9c6a1c6 | 2014-04-14 08:42:53 +0000 | [diff] [blame] | 88 | static ptrdiff_t childIndexMemoryOffset() { return OBJECT_OFFSETOF(ElementRareData, m_childIndex); } |
darin@apple.com | 929b907 | 2008-12-13 22:53:55 +0000 | [diff] [blame] | 89 | |
antti@apple.com | 64d6939 | 2013-08-15 16:52:40 +0000 | [diff] [blame] | 90 | void clearShadowRoot() { m_shadowRoot = nullptr; } |
| 91 | ShadowRoot* shadowRoot() const { return m_shadowRoot.get(); } |
| 92 | void setShadowRoot(PassRefPtr<ShadowRoot> shadowRoot) { m_shadowRoot = shadowRoot; } |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 93 | |
| 94 | NamedNodeMap* attributeMap() const { return m_attributeMap.get(); } |
commit-queue@webkit.org | 1e0ed9d | 2014-02-25 20:42:44 +0000 | [diff] [blame] | 95 | void setAttributeMap(PassOwnPtr<NamedNodeMap> attributeMap) { m_attributeMap = attributeMap; } |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 96 | |
| 97 | RenderStyle* computedStyle() const { return m_computedStyle.get(); } |
akling@apple.com | 5bbaebd | 2013-10-23 10:42:20 +0000 | [diff] [blame] | 98 | void setComputedStyle(PassRef<RenderStyle> computedStyle) { m_computedStyle = std::move(computedStyle); } |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 99 | |
| 100 | ClassList* classList() const { return m_classList.get(); } |
commit-queue@webkit.org | eabb648 | 2013-10-30 05:15:27 +0000 | [diff] [blame] | 101 | void setClassList(std::unique_ptr<ClassList> classList) { m_classList = std::move(classList); } |
esprehn@chromium.org | fbc22e5 | 2013-01-03 02:59:32 +0000 | [diff] [blame] | 102 | void clearClassListValueForQuirksMode() |
| 103 | { |
| 104 | if (!m_classList) |
| 105 | return; |
| 106 | m_classList->clearValueForQuirksMode(); |
| 107 | } |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 108 | |
| 109 | DatasetDOMStringMap* dataset() const { return m_dataset.get(); } |
commit-queue@webkit.org | eabb648 | 2013-10-30 05:15:27 +0000 | [diff] [blame] | 110 | void setDataset(std::unique_ptr<DatasetDOMStringMap> dataset) { m_dataset = std::move(dataset); } |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 111 | |
| 112 | LayoutSize minimumSizeForResizing() const { return m_minimumSizeForResizing; } |
| 113 | void setMinimumSizeForResizing(LayoutSize size) { m_minimumSizeForResizing = size; } |
| 114 | |
| 115 | IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } |
| 116 | void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = size; } |
| 117 | |
senorblanco@chromium.org | 7b6792b | 2013-01-04 19:48:10 +0000 | [diff] [blame] | 118 | bool hasPendingResources() const { return m_hasPendingResources; } |
| 119 | void setHasPendingResources(bool has) { m_hasPendingResources = has; } |
senorblanco@chromium.org | 7b6792b | 2013-01-04 19:48:10 +0000 | [diff] [blame] | 120 | |
commit-queue@webkit.org | 63be935 | 2012-12-05 20:43:40 +0000 | [diff] [blame] | 121 | private: |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 122 | short m_tabIndex; |
| 123 | unsigned short m_childIndex; |
| 124 | unsigned m_tabIndexWasSetExplicitly : 1; |
| 125 | unsigned m_needsFocusAppearanceUpdateSoonAfterAttach : 1; |
| 126 | unsigned m_styleAffectedByEmpty : 1; |
| 127 | unsigned m_isInCanvasSubtree : 1; |
| 128 | #if ENABLE(FULLSCREEN_API) |
| 129 | unsigned m_containsFullScreenElement : 1; |
| 130 | #endif |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 131 | unsigned m_hasPendingResources : 1; |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 132 | unsigned m_childrenAffectedByHover : 1; |
| 133 | unsigned m_childrenAffectedByActive : 1; |
| 134 | unsigned m_childrenAffectedByDrag : 1; |
| 135 | // Bits for dynamic child matching. |
| 136 | // We optimize for :first-child and :last-child. The other positional child selectors like nth-child or |
| 137 | // *-child-of-type, we will just give up and re-evaluate whenever children change at all. |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 138 | unsigned m_childrenAffectedByLastChildRules : 1; |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 139 | unsigned m_childrenAffectedByForwardPositionalRules : 1; |
| 140 | unsigned m_childrenAffectedByBackwardPositionalRules : 1; |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 141 | |
commit-queue@webkit.org | 75d76c4 | 2013-06-20 16:13:11 +0000 | [diff] [blame] | 142 | RegionOversetState m_regionOversetState; |
| 143 | |
eae@chromium.org | 5b93f41 | 2011-08-15 23:51:21 +0000 | [diff] [blame] | 144 | LayoutSize m_minimumSizeForResizing; |
rniwa@webkit.org | c311c02 | 2013-01-16 05:23:04 +0000 | [diff] [blame] | 145 | IntSize m_savedLayerScrollOffset; |
hyatt@apple.com | dec0cbf2 | 2008-10-17 00:25:33 +0000 | [diff] [blame] | 146 | RefPtr<RenderStyle> m_computedStyle; |
weinig@apple.com | 96a2cf9 | 2010-06-30 23:15:15 +0000 | [diff] [blame] | 147 | |
commit-queue@webkit.org | eabb648 | 2013-10-30 05:15:27 +0000 | [diff] [blame] | 148 | std::unique_ptr<DatasetDOMStringMap> m_dataset; |
| 149 | std::unique_ptr<ClassList> m_classList; |
antti@apple.com | 64d6939 | 2013-08-15 16:52:40 +0000 | [diff] [blame] | 150 | RefPtr<ShadowRoot> m_shadowRoot; |
commit-queue@webkit.org | 1e0ed9d | 2014-02-25 20:42:44 +0000 | [diff] [blame] | 151 | OwnPtr<NamedNodeMap> m_attributeMap; |
jer.noble@apple.com | 366ebb0 | 2011-05-30 02:05:30 +0000 | [diff] [blame] | 152 | |
antti@apple.com | 9426a74 | 2013-08-24 11:09:26 +0000 | [diff] [blame] | 153 | RefPtr<PseudoElement> m_beforePseudoElement; |
| 154 | RefPtr<PseudoElement> m_afterPseudoElement; |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 155 | |
commit-queue@webkit.org | 1e0ed9d | 2014-02-25 20:42:44 +0000 | [diff] [blame] | 156 | explicit ElementRareData(RenderElement*); |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 157 | void releasePseudoElement(PseudoElement*); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | inline IntSize defaultMinimumSizeForResizing() |
| 161 | { |
eae@chromium.org | 9717cd8 | 2012-11-07 18:33:44 +0000 | [diff] [blame] | 162 | return IntSize(LayoutUnit::max(), LayoutUnit::max()); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 163 | } |
| 164 | |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 165 | inline ElementRareData::ElementRareData(RenderElement* renderer) |
rniwa@webkit.org | fdb7fa2 | 2013-01-16 07:36:55 +0000 | [diff] [blame] | 166 | : NodeRareData(renderer) |
| 167 | , m_tabIndex(0) |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 168 | , m_childIndex(0) |
| 169 | , m_tabIndexWasSetExplicitly(false) |
| 170 | , m_needsFocusAppearanceUpdateSoonAfterAttach(false) |
| 171 | , m_styleAffectedByEmpty(false) |
| 172 | , m_isInCanvasSubtree(false) |
| 173 | #if ENABLE(FULLSCREEN_API) |
| 174 | , m_containsFullScreenElement(false) |
| 175 | #endif |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 176 | , m_hasPendingResources(false) |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 177 | , m_childrenAffectedByHover(false) |
| 178 | , m_childrenAffectedByActive(false) |
| 179 | , m_childrenAffectedByDrag(false) |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 180 | , m_childrenAffectedByLastChildRules(false) |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 181 | , m_childrenAffectedByForwardPositionalRules(false) |
| 182 | , m_childrenAffectedByBackwardPositionalRules(false) |
commit-queue@webkit.org | 75d76c4 | 2013-06-20 16:13:11 +0000 | [diff] [blame] | 183 | , m_regionOversetState(RegionUndefined) |
rniwa@webkit.org | 2015feb | 2013-01-14 23:57:39 +0000 | [diff] [blame] | 184 | , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 185 | { |
| 186 | } |
| 187 | |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 188 | inline ElementRareData::~ElementRareData() |
| 189 | { |
antti@apple.com | 64d6939 | 2013-08-15 16:52:40 +0000 | [diff] [blame] | 190 | ASSERT(!m_shadowRoot); |
antti@apple.com | 9426a74 | 2013-08-24 11:09:26 +0000 | [diff] [blame] | 191 | ASSERT(!m_beforePseudoElement); |
| 192 | ASSERT(!m_afterPseudoElement); |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 193 | } |
| 194 | |
antti@apple.com | 9426a74 | 2013-08-24 11:09:26 +0000 | [diff] [blame] | 195 | inline void ElementRareData::setBeforePseudoElement(PassRefPtr<PseudoElement> pseudoElement) |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 196 | { |
antti@apple.com | 9426a74 | 2013-08-24 11:09:26 +0000 | [diff] [blame] | 197 | ASSERT(!m_beforePseudoElement || !pseudoElement); |
| 198 | m_beforePseudoElement = pseudoElement; |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 199 | } |
| 200 | |
antti@apple.com | 9426a74 | 2013-08-24 11:09:26 +0000 | [diff] [blame] | 201 | inline void ElementRareData::setAfterPseudoElement(PassRefPtr<PseudoElement> pseudoElement) |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 202 | { |
antti@apple.com | 9426a74 | 2013-08-24 11:09:26 +0000 | [diff] [blame] | 203 | ASSERT(!m_afterPseudoElement || !pseudoElement); |
| 204 | m_afterPseudoElement = pseudoElement; |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 205 | } |
| 206 | |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 207 | inline void ElementRareData::resetComputedStyle() |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 208 | { |
akling@apple.com | 5bbaebd | 2013-10-23 10:42:20 +0000 | [diff] [blame] | 209 | m_computedStyle = nullptr; |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 210 | setStyleAffectedByEmpty(false); |
| 211 | setChildIndex(0); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 212 | } |
| 213 | |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 214 | inline void ElementRareData::resetDynamicRestyleObservations() |
| 215 | { |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 216 | setChildrenAffectedByActive(false); |
| 217 | setChildrenAffectedByDrag(false); |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 218 | setChildrenAffectedByLastChildRules(false); |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 219 | setChildrenAffectedByForwardPositionalRules(false); |
| 220 | setChildrenAffectedByBackwardPositionalRules(false); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 221 | } |
allan.jensen@digia.com | 44ec64e | 2012-11-28 13:09:40 +0000 | [diff] [blame] | 222 | |
| 223 | } // namespace |
| 224 | |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 225 | #endif // ElementRareData_h |