2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com>
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.
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.
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.
22 #ifndef NodeRareData_h
23 #define NodeRareData_h
25 #include "DynamicNodeList.h"
26 #include "EventListener.h"
27 #include "RegisteredEventListener.h"
28 #include "StringHash.h"
29 #include "QualifiedName.h"
30 #include <wtf/HashSet.h>
31 #include <wtf/OwnPtr.h>
35 struct NodeListsNodeData
{
36 typedef HashSet
<DynamicNodeList
*> NodeListSet
;
37 NodeListSet m_listsWithCaches
;
39 DynamicNodeList::Caches m_childNodeListCaches
;
41 typedef HashMap
<String
, DynamicNodeList::Caches
*> CacheMap
;
42 CacheMap m_classNodeListCaches
;
43 CacheMap m_nameNodeListCaches
;
45 typedef HashMap
<QualifiedName
, DynamicNodeList::Caches
*> TagCacheMap
;
46 TagCacheMap m_tagNodeListCaches
;
50 deleteAllValues(m_classNodeListCaches
);
51 deleteAllValues(m_nameNodeListCaches
);
52 deleteAllValues(m_tagNodeListCaches
);
55 void invalidateCaches();
56 void invalidateCachesThatDependOnAttributes();
64 , m_tabIndexWasSetExplicitly(false)
66 , m_needsFocusAppearanceUpdateSoonAfterAttach(false)
70 typedef HashMap
<const Node
*, NodeRareData
*> NodeRareDataMap
;
72 static NodeRareDataMap
& rareDataMap()
74 static NodeRareDataMap
* dataMap
= new NodeRareDataMap
;
78 static NodeRareData
* rareDataFromMap(const Node
* node
)
80 return rareDataMap().get(node
);
83 void clearNodeLists() { m_nodeLists
.clear(); }
84 void setNodeLists(std::auto_ptr
<NodeListsNodeData
> lists
) { m_nodeLists
.set(lists
.release()); }
85 NodeListsNodeData
* nodeLists() const { return m_nodeLists
.get(); }
87 short tabIndex() const { return m_tabIndex
; }
88 void setTabIndexExplicitly(short index
) { m_tabIndex
= index
; m_tabIndexWasSetExplicitly
= true; }
89 bool tabIndexSetExplicitly() const { return m_tabIndexWasSetExplicitly
; }
91 RegisteredEventListenerVector
* listeners() { return m_eventListeners
.get(); }
92 RegisteredEventListenerVector
& ensureListeners()
94 if (!m_eventListeners
)
95 m_eventListeners
.set(new RegisteredEventListenerVector
);
96 return *m_eventListeners
;
99 bool isFocused() const { return m_isFocused
; }
100 void setFocused(bool focused
) { m_isFocused
= focused
; }
103 // for ElementRareData
104 bool needsFocusAppearanceUpdateSoonAfterAttach() const { return m_needsFocusAppearanceUpdateSoonAfterAttach
; }
105 void setNeedsFocusAppearanceUpdateSoonAfterAttach(bool needs
) { m_needsFocusAppearanceUpdateSoonAfterAttach
= needs
; }
108 OwnPtr
<NodeListsNodeData
> m_nodeLists
;
109 OwnPtr
<RegisteredEventListenerVector
> m_eventListeners
;
111 bool m_tabIndexWasSetExplicitly
: 1;
112 bool m_isFocused
: 1;
113 bool m_needsFocusAppearanceUpdateSoonAfterAttach
: 1;