blob: cd2384d88b09c4a853ef5df875837d702fd3dbd2 [file] [log] [blame]
darin@apple.comfaced262009-01-12 07:44:27 +00001/*
darin@apple.comf5247d12010-06-13 17:29:10 +00002 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +00003 * 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.org691d04f2010-10-29 09:32:14 +000025#include "ClassList.h"
weinig@apple.com96a2cf92010-06-30 23:15:15 +000026#include "DatasetDOMStringMap.h"
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +000027#include "Element.h"
kling@webkit.orga3a65e32012-01-01 21:05:42 +000028#include "HTMLCollection.h"
caio.oliveira@openbossa.org26b85d32012-03-08 17:42:28 +000029#include "NamedNodeMap.h"
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +000030#include "NodeRareData.h"
shinyak@chromium.orgfea48242012-02-27 06:50:19 +000031#include "ShadowTree.h"
weinig@apple.com96a2cf92010-06-30 23:15:15 +000032#include <wtf/OwnPtr.h>
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +000033
34namespace WebCore {
alp@webkit.org2122a042008-10-03 12:38:12 +000035
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +000036class ElementRareData : public NodeRareData {
37public:
darin@apple.comfaced262009-01-12 07:44:27 +000038 ElementRareData();
morrita@google.comd75075c2011-01-20 01:24:40 +000039 virtual ~ElementRareData();
darin@apple.com929b9072008-12-13 22:53:55 +000040
darin@apple.comfaced262009-01-12 07:44:27 +000041 void resetComputedStyle();
alp@webkit.org2122a042008-10-03 12:38:12 +000042
darin@apple.com929b9072008-12-13 22:53:55 +000043 using NodeRareData::needsFocusAppearanceUpdateSoonAfterAttach;
44 using NodeRareData::setNeedsFocusAppearanceUpdateSoonAfterAttach;
45
kling@webkit.orgfe420042012-01-07 09:35:21 +000046 typedef FixedArray<OwnPtr<HTMLCollection>, NumNodeCollectionTypes> CachedHTMLCollectionArray;
kling@webkit.orga3a65e32012-01-01 21:05:42 +000047
48 bool hasCachedHTMLCollections() const
49 {
50 return m_cachedCollections;
51 }
52
kling@webkit.orga3a65e32012-01-01 21:05:42 +000053 HTMLCollection* ensureCachedHTMLCollection(Element* element, CollectionType type)
54 {
55 if (!m_cachedCollections)
56 m_cachedCollections = adoptPtr(new CachedHTMLCollectionArray);
57
kling@webkit.orgfe420042012-01-07 09:35:21 +000058 OwnPtr<HTMLCollection>& collection = (*m_cachedCollections)[type - FirstNodeCollectionType];
kling@webkit.orga3a65e32012-01-01 21:05:42 +000059 if (!collection)
60 collection = HTMLCollection::create(element, type);
61 return collection.get();
62 }
63
64 OwnPtr<CachedHTMLCollectionArray> m_cachedCollections;
65
eae@chromium.org5b93f412011-08-15 23:51:21 +000066 LayoutSize m_minimumSizeForResizing;
hyatt@apple.comdec0cbf22008-10-17 00:25:33 +000067 RefPtr<RenderStyle> m_computedStyle;
dglazkov@chromium.orgd505a102011-06-29 06:05:16 +000068 AtomicString m_shadowPseudoId;
weinig@apple.com96a2cf92010-06-30 23:15:15 +000069
70 OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap;
commit-queue@webkit.org691d04f2010-10-29 09:32:14 +000071 OwnPtr<ClassList> m_classList;
shinyak@chromium.org1fae3082012-02-28 08:05:51 +000072 OwnPtr<ShadowTree> m_shadowTree;
caio.oliveira@openbossa.org26b85d32012-03-08 17:42:28 +000073 OwnPtr<NamedNodeMap> m_attributeMap;
jer.noble@apple.com366ebb02011-05-30 02:05:30 +000074
mitz@apple.com29333122011-07-10 15:37:30 +000075 bool m_styleAffectedByEmpty;
76
jer.noble@apple.com366ebb02011-05-30 02:05:30 +000077#if ENABLE(FULLSCREEN_API)
78 bool m_containsFullScreenElement;
79#endif
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +000080};
81
82inline IntSize defaultMinimumSizeForResizing()
83{
84 return IntSize(INT_MAX, INT_MAX);
85}
86
darin@apple.comfaced262009-01-12 07:44:27 +000087inline ElementRareData::ElementRareData()
rolandsteiner@chromium.org2ce77d72012-02-15 09:17:20 +000088 : NodeRareData()
89 , m_minimumSizeForResizing(defaultMinimumSizeForResizing())
mitz@apple.com29333122011-07-10 15:37:30 +000090 , m_styleAffectedByEmpty(false)
jer.noble@apple.com366ebb02011-05-30 02:05:30 +000091#if ENABLE(FULLSCREEN_API)
92 , m_containsFullScreenElement(false)
93#endif
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +000094{
95}
96
morrita@google.comd75075c2011-01-20 01:24:40 +000097inline ElementRareData::~ElementRareData()
98{
shinyak@chromium.org1fae3082012-02-28 08:05:51 +000099 ASSERT(!m_shadowTree);
morrita@google.comd75075c2011-01-20 01:24:40 +0000100}
101
darin@apple.comfaced262009-01-12 07:44:27 +0000102inline void ElementRareData::resetComputedStyle()
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +0000103{
hyatt@apple.comdec0cbf22008-10-17 00:25:33 +0000104 m_computedStyle.clear();
dsmith@webkit.orgbee65b52008-09-26 02:36:38 +0000105}
106
107}
alp@webkit.org2122a042008-10-03 12:38:12 +0000108#endif // ElementRareData_h