94
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Matches CSS patterns
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CCSSPatternMatcher_H
|
|
20 |
#define CCSSPatternMatcher_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include "CSSParser.h"
|
|
24 |
#include "CSSSelector.h"
|
|
25 |
#include <nw_dom_element.h>
|
|
26 |
#include <nw_wbxml_dictionary.h>
|
|
27 |
#include "nw_evt_event.h"
|
|
28 |
#include "nw_hed_documentnode.h"
|
|
29 |
#include "nw_hed_domhelper.h"
|
|
30 |
|
|
31 |
#include <e32base.h>
|
|
32 |
|
|
33 |
// CONSTANTS
|
|
34 |
|
|
35 |
// MACROS
|
|
36 |
|
|
37 |
// DATA TYPES
|
|
38 |
|
|
39 |
// FORWARD DECLARATIONS
|
|
40 |
|
|
41 |
// CLASS DECLARATION
|
|
42 |
|
|
43 |
/**
|
|
44 |
* This class contains information about the node
|
|
45 |
* @lib css.lib
|
|
46 |
* @since 2.1
|
|
47 |
*/
|
|
48 |
class CCSSNodeData : public CBase
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
// class Value of node
|
|
52 |
NW_Ucs2* classVal;
|
|
53 |
// idValue of node
|
|
54 |
NW_Ucs2* idVal;
|
|
55 |
// if node is link
|
|
56 |
TBool isLink;
|
|
57 |
// if associated url os visited
|
|
58 |
TBool isVisited;
|
|
59 |
// if url is cached
|
|
60 |
TBool isCached;
|
|
61 |
// associated url;
|
|
62 |
NW_Text_t* elementUrl;
|
|
63 |
|
|
64 |
// constructor
|
|
65 |
CCSSNodeData()
|
|
66 |
{
|
|
67 |
classVal = NULL;
|
|
68 |
idVal = NULL;
|
|
69 |
elementUrl = NULL;
|
|
70 |
isCached = EFalse;
|
|
71 |
isLink = EFalse;
|
|
72 |
isVisited = EFalse;
|
|
73 |
}
|
|
74 |
// destructor
|
|
75 |
virtual ~CCSSNodeData()
|
|
76 |
{
|
|
77 |
if (classVal)
|
|
78 |
{
|
|
79 |
NW_Mem_Free(classVal);
|
|
80 |
}
|
|
81 |
if (idVal)
|
|
82 |
{
|
|
83 |
NW_Mem_Free(idVal);
|
|
84 |
}
|
|
85 |
if (elementUrl)
|
|
86 |
{
|
|
87 |
NW_Object_Delete(elementUrl);
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
};
|
|
92 |
|
|
93 |
// CLASS DECLARATION
|
|
94 |
|
|
95 |
/**
|
|
96 |
* This class matches patterns
|
|
97 |
*
|
|
98 |
* @lib css.lib
|
|
99 |
* @since 2.1
|
|
100 |
*/
|
|
101 |
class CCSSPatternMatcher : public CBase
|
|
102 |
{
|
|
103 |
public: // Constructors and destructor
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Destructor.
|
|
107 |
*/
|
|
108 |
virtual ~CCSSPatternMatcher(){};
|
|
109 |
|
|
110 |
CCSSPatternMatcher(NW_WBXML_Dictionary_t* aDictionary,
|
|
111 |
NW_HED_DocumentNode_t* aOwner,
|
|
112 |
NW_HED_DomHelper_t* aDomHelper)
|
|
113 |
{
|
|
114 |
iDictionary = aDictionary;
|
|
115 |
iOwner = aOwner;
|
|
116 |
iDomHelper = aDomHelper;
|
|
117 |
}
|
|
118 |
|
|
119 |
|
|
120 |
public: // New functions
|
|
121 |
|
|
122 |
/**
|
|
123 |
* This function matches selector pattern to element node using lazy parsing
|
|
124 |
* @since 2.1
|
|
125 |
* @param aElementNode: element node for which pattern needs to be matched
|
|
126 |
* @param aParser: parser initialized to beginning of selector
|
|
127 |
* @param aSelector: selector to be matched
|
|
128 |
* @param aEvent: event
|
|
129 |
* @param aNodeData: node specific data containing class, id information
|
|
130 |
* @return NW_FALSE if pattern not matched or NW_TRUE if pattern matches
|
|
131 |
*/
|
|
132 |
TBool MatchPatternLazyL(NW_DOM_ElementNode_t* aElementNode,
|
|
133 |
TCSSParser* aParser,
|
|
134 |
NW_Byte* aSelector,
|
|
135 |
const NW_Evt_Event_t* aEvent,
|
|
136 |
CCSSNodeData* aNodeData);
|
|
137 |
/**
|
|
138 |
* This function matches selector pattern to element node
|
|
139 |
* @since 2.1
|
|
140 |
* @param aElementNode: element node for which pattern needs to be matched
|
|
141 |
* @param aParser: parser initialized to beginning of selector
|
|
142 |
* @param aSelector: selector to be matched
|
|
143 |
* @param aEvent: event
|
|
144 |
* @param aNodeData: node specific data containing class, id information
|
|
145 |
* @return NW_FALSE if pattern not matched or NW_TRUE if pattern matches
|
|
146 |
*/
|
|
147 |
TBool MatchPatternL(NW_DOM_ElementNode_t* aElementNode,
|
|
148 |
CCSSSelector* aSelector,
|
|
149 |
const NW_Evt_Event_t* aEvent,
|
|
150 |
CCSSNodeData* aNodeData);
|
|
151 |
|
|
152 |
private: // New functions
|
|
153 |
|
|
154 |
// data associated with a simple selector
|
|
155 |
struct TSimpleSelectorData
|
|
156 |
{
|
|
157 |
TCSSReaderUnit nameSpace;
|
|
158 |
TUint16 elementToken;
|
|
159 |
TText8* conditionListHandle;
|
|
160 |
TUint16 simpleSelectorNum;
|
|
161 |
};
|
|
162 |
|
|
163 |
/**
|
|
164 |
* This function matches selector pattern to element node
|
|
165 |
* using lazy parsing
|
|
166 |
* @since 2.1
|
|
167 |
* @param aElementNode: element node for which pattern needs to be matched
|
|
168 |
* @param aParser: parser initialized to beginning of selector
|
|
169 |
* @param aEvent: event
|
|
170 |
* @param aNodeData: node specific data containing class, id information
|
|
171 |
* @param aConditionListHandle pointer to beginning of conditions
|
|
172 |
* @return NW_FALSE if conditions not matched or NW_TRUE if conditions matches
|
|
173 |
*/
|
|
174 |
TBool MatchConditionLazyL(NW_DOM_ElementNode_t* aElementNode,
|
|
175 |
NW_Byte* aConditionListHandle,
|
|
176 |
TCSSParser* aParser,
|
|
177 |
const NW_Evt_Event_t* aEvent,
|
|
178 |
CCSSNodeData* aNodeData);
|
|
179 |
|
|
180 |
/**
|
|
181 |
* This function matches selector pattern to element node
|
|
182 |
* @since 2.1
|
|
183 |
* @param aElementNode: element node for which pattern needs to be matched
|
|
184 |
* @param aParser: parser initialized to beginning of selector
|
|
185 |
* @param aEvent: event
|
|
186 |
* @param aNodeData: node specific data containing class, id information
|
|
187 |
* @param aConditionList: list of conditions
|
|
188 |
* @return NW_FALSE if conditions not matched or NW_TRUE if conditions matches
|
|
189 |
*/
|
|
190 |
TBool MatchConditionL(NW_DOM_ElementNode_t* aElementNode,
|
|
191 |
CCSSConditionList* aConditionList,
|
|
192 |
const NW_Evt_Event_t* aEvent,
|
|
193 |
CCSSNodeData* aNodeData);
|
|
194 |
|
|
195 |
/**
|
|
196 |
* This function gets the data associated with a simple selector (iterator method)
|
|
197 |
* @since 2.1
|
|
198 |
* @param aParser: parser to parse selector
|
|
199 |
* @param aSelector: selector to be matched
|
|
200 |
* @param aEvent: event
|
|
201 |
* @param aNodeData(OUT): node specific data containing class, id information
|
|
202 |
* @return KBrsrIterateDone (if all simple selectors are parsed)
|
|
203 |
* KBrsrIterateMore (if more simple selectors need to be parsed)
|
|
204 |
*/
|
|
205 |
TBrowserStatusCode GetNextSimpleSelectorL(TCSSParser* aParser,
|
|
206 |
NW_Byte* aSelector,
|
|
207 |
TSimpleSelectorData& aData);
|
|
208 |
|
|
209 |
|
|
210 |
/**
|
|
211 |
* This function matches selector pattern to element node
|
|
212 |
* @since 2.1
|
|
213 |
* @param aElementNode: element node whose url is to be matched
|
|
214 |
* @return url associated with href
|
|
215 |
*/
|
|
216 |
NW_Text_t* GetElementURLL(NW_DOM_ElementNode_t* aElementNode);
|
|
217 |
|
|
218 |
/**
|
|
219 |
* This function returns true if url is in history stack
|
|
220 |
* @since 2.1
|
|
221 |
* @param aElementNode: element node whose url is to be searched
|
|
222 |
* @return true (if url is in history stack), otherwise false
|
|
223 |
*/
|
|
224 |
TBool UrlInHistory(NW_DOM_ElementNode_t* aElementNode);
|
|
225 |
|
|
226 |
/**
|
|
227 |
* This function returns true if url is in cache
|
|
228 |
* @since 2.1
|
|
229 |
* @param aElementNode: element node whose url is to be searched
|
|
230 |
* @return true (if url is in cache), otherwise false
|
|
231 |
*/
|
|
232 |
TBool UrlInCache(NW_DOM_ElementNode_t* aElementNode);
|
|
233 |
|
|
234 |
/**
|
|
235 |
* This function returns true if url is in cache
|
|
236 |
* @since 2.1
|
|
237 |
* @param aParser: parser to parse selector
|
|
238 |
* @param aSelector: selector to be matched
|
|
239 |
* @param aData: simpleselector data
|
|
240 |
* @return KBrsrSuccess or KBrsrFailure
|
|
241 |
*/
|
|
242 |
TBrowserStatusCode InitSimpleSelectorData(TCSSParser* aParser, NW_Byte* aSelector, TSimpleSelectorData& aData);
|
|
243 |
|
|
244 |
private: // Data
|
|
245 |
|
|
246 |
// dictionary for document
|
|
247 |
NW_WBXML_Dictionary_t* iDictionary;
|
|
248 |
|
|
249 |
// document
|
|
250 |
NW_HED_DocumentNode_t* iOwner;
|
|
251 |
|
|
252 |
// domHelper for resolving entities
|
|
253 |
NW_HED_DomHelper_t* iDomHelper;
|
|
254 |
};
|
|
255 |
|
|
256 |
#endif /* CCSSPatternMatcher_H */
|