OLD | NEW |
1 #ifndef _PLUGIN_DOM_TRAVERSER_BASE_H_ | 1 #ifndef _PLUGIN_DOM_TRAVERSER_BASE_H_ |
2 #define _PLUGIN_DOM_TRAVERSER_BASE_H_ | 2 #define _PLUGIN_DOM_TRAVERSER_BASE_H_ |
3 | 3 |
4 | |
5 #include "PluginTypedef.h" | 4 #include "PluginTypedef.h" |
6 #include "PluginTab.h" | 5 #include "PluginTab.h" |
7 | 6 #include "COM_Client.h" |
| 7 #include "Wrapper.h" |
8 | 8 |
9 class CPluginDomTraverserCacheBase | 9 class CPluginDomTraverserCacheBase |
10 { | 10 { |
11 public: | 11 public: |
12 | 12 |
13 long m_elements; | 13 long m_elements; |
14 | 14 |
15 CPluginDomTraverserCacheBase() : m_elements(0) {}; | 15 CPluginDomTraverserCacheBase() : m_elements(0) {}; |
16 void Init() { m_elements=0; } | 16 void Init() { m_elements=0; } |
17 }; | 17 }; |
18 | 18 |
19 template <class T> | 19 template <class T> |
20 class CPluginDomTraverserBase | 20 class CPluginDomTraverserBase |
21 { | 21 { |
22 | 22 |
23 public: | 23 public: |
24 | 24 |
25 CPluginDomTraverserBase(CPluginTab* tab); | 25 CPluginDomTraverserBase(CPluginTab* tab); |
26 ~CPluginDomTraverserBase(); | 26 ~CPluginDomTraverserBase(); |
27 | 27 |
28 void TraverseHeader(bool isHeaderTraversed); | 28 void TraverseHeader(bool isHeaderTraversed); |
29 | 29 |
30 void TraverseDocument(IWebBrowser2* pBrowser, const CString& domain, const CSt
ring& documentName); | 30 void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring & domain, con
st std::wstring & documentName); |
31 void TraverseSubdocument(IWebBrowser2* pBrowser, const CString& domain, const
CString& documentName); | 31 void TraverseSubdocument(IWebBrowser2* pBrowser, const std::wstring & domain,
const std::wstring & documentName); |
32 | 32 |
33 virtual void ClearCache(); | 33 virtual void ClearCache(); |
34 | 34 |
35 void ShowNotification(CPluginTab* tab); | 35 void ShowNotification(CPluginTab* tab); |
36 | 36 |
37 protected: | 37 protected: |
38 | 38 |
39 virtual bool OnIFrame(IHTMLElement* pEl, const CString& url, CString& indent)
{ return true; } | 39 virtual bool OnIFrame(IHTMLElement* pEl, const std::wstring & url, std::wstrin
g & indent) { return true; } |
40 virtual bool OnElement(IHTMLElement* pEl, const CString& tag, T* cache, bool i
sDebug, CString& indent) { return true; } | 40 virtual bool OnElement(IHTMLElement* pEl, const std::wstring & tag, T* cache,
bool isDebug, std::wstring & indent) { return true; } |
41 | 41 |
42 virtual bool IsEnabled(); | 42 virtual bool IsEnabled(); |
43 | 43 |
44 protected: | 44 protected: |
45 | 45 |
46 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, CString indent); | 46 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, std::wstring ind
ent); |
47 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, CString& indent,
bool isCached=true); | 47 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, std::wstring & i
ndent, bool isCached=true); |
48 | 48 |
49 CComAutoCriticalSection m_criticalSection; | 49 CComAutoCriticalSection m_criticalSection; |
50 | 50 |
51 CString m_domain; | 51 std::wstring m_domain; |
52 CString m_documentName; | 52 std::wstring m_documentName; |
53 | 53 |
54 bool m_isHeaderTraversed; | 54 bool m_isHeaderTraversed; |
55 | 55 |
56 // Caching | 56 // Caching |
57 long m_cacheDomElementCount; | 57 long m_cacheDomElementCount; |
58 | 58 |
59 int m_cacheIndexLast; | 59 int m_cacheIndexLast; |
60 int m_cacheElementsMax; | 60 int m_cacheElementsMax; |
61 std::set<CString> m_cacheDocumentHasFrames; | 61 std::set< std::wstring > m_cacheDocumentHasFrames; |
62 std::set<CString> m_cacheDocumentHasIframes; | 62 std::set< std::wstring > m_cacheDocumentHasIframes; |
63 | 63 |
64 T* m_cacheElements; | 64 T* m_cacheElements; |
65 | 65 |
66 CPluginTab* m_tab; | 66 CPluginTab* m_tab; |
67 CComPtr<IWebBrowser2> m_pBrowser; | 67 CComPtr<IWebBrowser2> m_pBrowser; |
68 }; | 68 }; |
69 | 69 |
70 template <class T> | 70 template <class T> |
71 CPluginDomTraverserBase<T>::CPluginDomTraverserBase(CPluginTab* tab) : | 71 CPluginDomTraverserBase<T>::CPluginDomTraverserBase(CPluginTab* tab) : |
72 m_tab(tab), m_isHeaderTraversed(false), m_cacheDomElementCount(0), m_cacheInde
xLast(0), m_cacheElementsMax(5000) | 72 m_tab(tab), m_isHeaderTraversed(false), m_cacheDomElementCount(0), m_cacheInde
xLast(0), m_cacheElementsMax(5000) |
73 { | 73 { |
74 m_cacheElements = new T[m_cacheElementsMax]; | 74 m_cacheElements = new T[m_cacheElementsMax]; |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 template <class T> | 78 template <class T> |
79 CPluginDomTraverserBase<T>::~CPluginDomTraverserBase() | 79 CPluginDomTraverserBase<T>::~CPluginDomTraverserBase() |
80 { | 80 { |
81 delete [] m_cacheElements; | 81 delete [] m_cacheElements; |
82 } | 82 } |
83 | 83 |
84 template <class T> | 84 template <class T> |
85 void CPluginDomTraverserBase<T>::TraverseHeader(bool isHeaderTraversed) | 85 void CPluginDomTraverserBase<T>::TraverseHeader(bool isHeaderTraversed) |
86 { | 86 { |
87 m_isHeaderTraversed = isHeaderTraversed; | 87 m_isHeaderTraversed = isHeaderTraversed; |
88 } | 88 } |
89 | 89 |
90 template <class T> | 90 template <class T> |
91 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const
CString& domain, const CString& documentName) | 91 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, const
std::wstring & domain, const std::wstring & documentName) |
92 { | 92 { |
93 m_domain = domain; | 93 m_domain = domain; |
94 | 94 |
95 TraverseDocument(pBrowser, true, ""); | 95 TraverseDocument(pBrowser, true, L""); |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 template <class T> | 99 template <class T> |
100 void CPluginDomTraverserBase<T>::TraverseSubdocument(IWebBrowser2* pBrowser, con
st CString& domain, const CString& documentName) | 100 void CPluginDomTraverserBase<T>::TraverseSubdocument(IWebBrowser2* pBrowser, con
st std::wstring & domain, const std::wstring & documentName) |
101 { | 101 { |
102 m_domain = domain; | 102 m_domain = domain; |
103 | 103 |
104 TraverseDocument(pBrowser, false, ""); | 104 TraverseDocument(pBrowser, false, L""); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 template <class T> | 108 template <class T> |
109 bool CPluginDomTraverserBase<T>::IsEnabled() | 109 bool CPluginDomTraverserBase<T>::IsEnabled() |
110 { | 110 { |
111 return CPluginSettings::GetInstance()->IsPluginEnabled(); | 111 return CPluginSettings::GetInstance()->IsPluginEnabled(); |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 template <class T> | 115 template <class T> |
116 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, bool i
sMainDoc, CString indent) | 116 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, bool i
sMainDoc, std::wstring indent) |
117 { | 117 { |
118 DWORD res = WaitForSingleObject(m_tab->m_filter->hideFiltersLoadedEvent, ENGIN
E_STARTUP_TIMEOUT); | 118 DWORD res = WaitForSingleObject(m_tab->m_filter->hideFiltersLoadedEvent, ENGIN
E_STARTUP_TIMEOUT); |
119 if (!IsEnabled()) return; | 119 if (!IsEnabled()) return; |
120 | 120 |
121 VARIANT_BOOL isBusy; | 121 VARIANT_BOOL isBusy; |
122 if (SUCCEEDED(pBrowser->get_Busy(&isBusy))) | 122 if (SUCCEEDED(pBrowser->get_Busy(&isBusy))) |
123 { | 123 { |
124 if (isBusy) | 124 if (isBusy) |
125 { | 125 { |
126 return; | 126 return; |
(...skipping 26 matching lines...) Expand all Loading... |
153 { | 153 { |
154 pBodyEl = pBody; | 154 pBodyEl = pBody; |
155 } | 155 } |
156 else | 156 else |
157 { | 157 { |
158 CComPtr<IHTMLElementCollection> pBodyCollection; | 158 CComPtr<IHTMLElementCollection> pBodyCollection; |
159 if (FAILED(pDoc->getElementsByTagName(L"body", &pBodyCollection)) || !pBodyC
ollection) | 159 if (FAILED(pDoc->getElementsByTagName(L"body", &pBodyCollection)) || !pBodyC
ollection) |
160 { | 160 { |
161 return; | 161 return; |
162 } | 162 } |
163 | 163 Wrapper::HTML_Element_Collection body_elements( pBodyCollection ); |
164 CComVariant vIndex(0); | 164 CComPtr<IDispatch> pBodyDispatch = body_elements.at( 0 ); |
165 CComPtr<IDispatch> pBodyDispatch; | 165 if ( !pBodyDispatch ) |
166 if (FAILED(pBodyCollection->item(vIndex, vIndex, &pBodyDispatch)) || !pBodyD
ispatch) | |
167 { | 166 { |
168 return; | 167 return; |
169 } | 168 } |
170 | 169 |
171 if (FAILED(pBodyDispatch->QueryInterface(IID_IHTMLElement, (LPVOID*)&pBodyEl
)) || !pBodyEl) | 170 if (FAILED(pBodyDispatch->QueryInterface(IID_IHTMLElement, (LPVOID*)&pBodyEl
)) || !pBodyEl) |
172 { | 171 { |
173 return; | 172 return; |
174 } | 173 } |
175 } | 174 } |
176 | 175 |
177 // Clear cache (if eg. refreshing) ??? | 176 // Clear cache (if eg. refreshing) ??? |
178 if (isMainDoc) | 177 if (isMainDoc) |
179 { | 178 { |
180 CComVariant vCacheIndex; | 179 Wrapper::HTML_Element body_element( pBodyEl ); |
181 | 180 std::wstring cache_attr; |
182 if (FAILED(pBodyEl->getAttribute(L"abp", 0, &vCacheIndex)) || vCacheIndex.vt
== VT_NULL) | 181 if ( !body_element.attribute( L"abp", cache_attr ) || cache_attr.empty() ) |
183 { | 182 { |
184 ClearCache(); | 183 ClearCache(); |
185 } | 184 } |
186 } | 185 } |
187 | 186 |
188 // Hide elements in body part | 187 // Hide elements in body part |
189 TraverseChild(pBodyEl, pBrowser, indent); | 188 TraverseChild(pBodyEl, pBrowser, indent); |
190 | 189 |
191 // Check frames and iframes | 190 // Check frames and iframes |
192 bool hasFrames = false; | 191 bool hasFrames = false; |
193 bool hasIframes = false; | 192 bool hasIframes = false; |
194 | 193 |
195 m_criticalSection.Lock(); | 194 m_criticalSection.Lock(); |
196 { | 195 { |
197 hasFrames = m_cacheDocumentHasFrames.find(m_documentName) != m_cacheDocument
HasFrames.end(); | 196 hasFrames = m_cacheDocumentHasFrames.find(m_documentName) != m_cacheDocument
HasFrames.end(); |
198 hasIframes = m_cacheDocumentHasIframes.find(m_documentName) != m_cacheDocume
ntHasIframes.end(); | 197 hasIframes = m_cacheDocumentHasIframes.find(m_documentName) != m_cacheDocume
ntHasIframes.end(); |
199 } | 198 } |
200 m_criticalSection.Unlock(); | 199 m_criticalSection.Unlock(); |
201 | 200 |
202 // Frames | 201 // Frames |
203 if (hasFrames) | 202 if (hasFrames) |
204 { | 203 { |
205 // eg. http://gamecopyworld.com/ | 204 // eg. http://gamecopyworld.com/ |
206 long frameCount = 0; | 205 long frameCount = 0; |
207 CComPtr<IHTMLElementCollection> pFrameCollection; | 206 CComPtr<IHTMLElementCollection> pFrameCollection; |
208 if (SUCCEEDED(pDoc->getElementsByTagName(L"frame", &pFrameCollection)) && pF
rameCollection) | 207 if (SUCCEEDED(pDoc->getElementsByTagName(L"frame", &pFrameCollection)) && pF
rameCollection) |
209 { | 208 { |
210 pFrameCollection->get_length(&frameCount); | 209 pFrameCollection->get_length(&frameCount); |
211 } | 210 } |
| 211 Wrapper::HTML_Element_Collection frames( pFrameCollection ); |
212 | 212 |
213 // Iterate through all frames | 213 // Iterate through all frames |
214 for (long i = 0; i < frameCount; i++) | 214 for (long i = 0; i < frameCount; i++) |
215 { | 215 { |
216 CComVariant vIndex(i); | 216 CComPtr<IDispatch> pFrameDispatch = frames.at( i ); |
217 CComVariant vRetIndex; | 217 if ( pFrameDispatch ) |
218 CComPtr<IDispatch> pFrameDispatch; | |
219 | |
220 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch))
&& pFrameDispatch) | |
221 { | 218 { |
222 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; | 219 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; |
223 if (pFrameBrowser) | 220 if (pFrameBrowser) |
224 { | 221 { |
225 CComBSTR bstrSrc; | 222 Wrapper::Browser frame_browser( pFrameBrowser ); |
226 CString src; | 223 std::wstring src; |
227 | 224 if ( frame_browser.Location_URL( src ) ) |
228 if (SUCCEEDED(pFrameBrowser->get_LocationURL(&bstrSrc))) | |
229 { | 225 { |
230 src = bstrSrc; | 226 Wrapper::Unescape_URL( src ); |
231 CPluginClient::UnescapeUrl(src); | |
232 } | 227 } |
233 | 228 |
234 if (!src.IsEmpty()) | 229 if (!src.empty()) |
235 { | 230 { |
236 TraverseDocument(pFrameBrowser, false, indent); | 231 TraverseDocument(pFrameBrowser, false, indent); |
237 } | 232 } |
238 } | 233 } |
239 } | 234 } |
240 } | 235 } |
241 } | 236 } |
242 | 237 |
243 // Iframes | 238 // Iframes |
244 if (hasIframes) | 239 if (hasIframes) |
245 { | 240 { |
246 long frameCount = 0; | 241 long frameCount = 0; |
247 CComPtr<IHTMLElementCollection> pFrameCollection; | 242 CComPtr<IHTMLElementCollection> pFrameCollection; |
248 if (SUCCEEDED(pDoc->getElementsByTagName(L"iframe", &pFrameCollection)) && p
FrameCollection) | 243 if (SUCCEEDED(pDoc->getElementsByTagName(L"iframe", &pFrameCollection)) && p
FrameCollection) |
249 { | 244 { |
250 pFrameCollection->get_length(&frameCount); | 245 pFrameCollection->get_length(&frameCount); |
251 } | 246 } |
252 | 247 |
253 // Iterate through all iframes | 248 // Iterate through all iframes |
| 249 Wrapper::HTML_Element_Collection frames( pFrameCollection ); |
254 for (long i = 0; i < frameCount; i++) | 250 for (long i = 0; i < frameCount; i++) |
255 { | 251 { |
256 CComVariant vIndex(i); | 252 CComPtr<IDispatch> pFrameDispatch = frames.at( i ); |
257 CComVariant vRetIndex; | 253 if ( pFrameDispatch ) |
258 CComPtr<IDispatch> pFrameDispatch; | |
259 | |
260 if (SUCCEEDED(pFrameCollection->item(vIndex, vRetIndex, &pFrameDispatch))
&& pFrameDispatch) | |
261 { | 254 { |
262 CComQIPtr<IHTMLElement> pFrameEl = pFrameDispatch; | 255 CComQIPtr<IHTMLElement> pFrameEl = pFrameDispatch; |
263 if (pFrameEl) | 256 if (pFrameEl) |
264 { | 257 { |
265 CComVariant vAttr; | 258 Wrapper::HTML_Element element( pFrameEl ); |
| 259 std::wstring src; |
| 260 if ( element.attribute( L"src", src ) && !src.empty() ) |
| 261 { |
| 262 // Some times, domain is missing. Should this be added on image src'
s as well?'' |
| 263 // eg. gadgetzone.com.au |
266 | 264 |
267 if (SUCCEEDED(pFrameEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt =
= VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0) | 265 if ( ABP::util::begins_with( src, L"//" ) ) |
268 { | |
269 CString src = vAttr.bstrVal; | |
270 | |
271 // Some times, domain is missing. Should this be added on image src'
s as well?'' | |
272 | |
273 // eg. gadgetzone.com.au | |
274 if (src.Left(2) == L"//") | |
275 { | 266 { |
276 src = L"http:" + src; | 267 src = L"http:" + src; |
277 } | 268 } |
278 // eg. http://w3schools.com/html/html_examples.asp | 269 // eg. http://w3schools.com/html/html_examples.asp |
279 else if (src.Left(4) != L"http" && src.Left(6) != L"res://") | 270 else if ( !ABP::util::begins_with( src, L"http" ) && !ABP::util::beg
ins_with( src, L"res://" ) ) |
280 { | 271 { |
281 src = L"http://" + m_domain + src; | 272 src = L"http://" + m_domain + src; |
282 } | 273 } |
283 | 274 Wrapper::Unescape_URL( src ); |
284 CPluginClient::UnescapeUrl(src); | |
285 | 275 |
286 // Check if Iframe should be traversed | 276 // Check if Iframe should be traversed |
287 if (OnIFrame(pFrameEl, src, indent)) | 277 if (OnIFrame(pFrameEl, src, indent)) |
288 { | 278 { |
289 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; | 279 CComQIPtr<IWebBrowser2> pFrameBrowser = pFrameDispatch; |
290 if (pFrameBrowser) | 280 if (pFrameBrowser) |
291 { | 281 { |
292 TraverseDocument(pFrameBrowser, false, indent); | 282 TraverseDocument(pFrameBrowser, false, indent); |
293 } | 283 } |
294 } | 284 } |
295 } | 285 } |
296 } | 286 } |
297 } | 287 } |
298 } | 288 } |
299 } | 289 } |
300 } | 290 } |
301 | 291 |
302 | 292 |
303 template <class T> | 293 template <class T> |
304 void CPluginDomTraverserBase<T>::TraverseChild(IHTMLElement* pEl, IWebBrowser2*
pBrowser, CString& indent, bool isCached) | 294 void CPluginDomTraverserBase<T>::TraverseChild(IHTMLElement* pEl, IWebBrowser2*
pBrowser, std::wstring & indent, bool isCached) |
305 { | 295 { |
306 int cacheIndex = -1; | 296 int cacheIndex = -1; |
307 long cacheAllElementsCount = -1; | 297 long cacheAllElementsCount = -1; |
| 298 Wrapper::HTML_Element element( pEl ); |
308 | 299 |
309 m_criticalSection.Lock(); | 300 m_criticalSection.Lock(); |
310 { | 301 { |
311 CComVariant vCacheIndex; | 302 if ( isCached && element.attribute( L"abp", cacheIndex ) ) |
312 if (isCached && SUCCEEDED(pEl->getAttribute(L"abp", 0, &vCacheIndex)) && vCa
cheIndex.vt == VT_I4) | |
313 { | 303 { |
314 cacheIndex = vCacheIndex.intVal; | |
315 | |
316 cacheAllElementsCount = m_cacheElements[cacheIndex].m_elements; | 304 cacheAllElementsCount = m_cacheElements[cacheIndex].m_elements; |
317 } | 305 } |
318 else | 306 else |
319 { | 307 { |
320 isCached = false; | 308 isCached = false; |
321 | 309 |
322 cacheIndex = m_cacheIndexLast++; | 310 cacheIndex = m_cacheIndexLast++; |
323 | 311 |
324 // Resize cache??? | 312 // Resize cache??? |
325 if (cacheIndex >= m_cacheElementsMax) | 313 if (cacheIndex >= m_cacheElementsMax) |
326 { | 314 { |
327 T* oldCacheElements = m_cacheElements; | 315 T* oldCacheElements = m_cacheElements; |
328 | 316 |
329 m_cacheElements = new T[2*m_cacheElementsMax]; | 317 m_cacheElements = new T[2*m_cacheElementsMax]; |
330 | 318 |
331 memcpy(m_cacheElements, oldCacheElements, m_cacheElementsMax*sizeof(T)); | 319 memcpy(m_cacheElements, oldCacheElements, m_cacheElementsMax*sizeof(T)); |
332 | 320 |
333 m_cacheElementsMax *= 2; | 321 m_cacheElementsMax *= 2; |
334 | 322 |
335 delete [] oldCacheElements; | 323 delete [] oldCacheElements; |
336 } | 324 } |
337 | 325 |
338 m_cacheElements[cacheIndex].Init(); | 326 m_cacheElements[cacheIndex].Init(); |
339 | 327 |
| 328 VARIANT vCacheIndex; |
340 vCacheIndex.vt = VT_I4; | 329 vCacheIndex.vt = VT_I4; |
341 vCacheIndex.intVal = cacheIndex; | 330 vCacheIndex.intVal = cacheIndex; |
342 | 331 |
343 pEl->setAttribute(L"abp", vCacheIndex); | 332 pEl->setAttribute(L"abp", vCacheIndex); |
344 } | 333 } |
345 } | 334 } |
346 m_criticalSection.Unlock(); | 335 m_criticalSection.Unlock(); |
347 | 336 |
348 // Get number of elements in the scope of pEl | 337 // Get number of elements in the scope of pEl |
349 long allElementsCount = 0; | 338 long allElementsCount = 0; |
(...skipping 15 matching lines...) Expand all Loading... |
365 } | 354 } |
366 | 355 |
367 // Update cache | 356 // Update cache |
368 m_criticalSection.Lock(); | 357 m_criticalSection.Lock(); |
369 { | 358 { |
370 m_cacheElements[cacheIndex].m_elements = allElementsCount; | 359 m_cacheElements[cacheIndex].m_elements = allElementsCount; |
371 } | 360 } |
372 m_criticalSection.Unlock(); | 361 m_criticalSection.Unlock(); |
373 | 362 |
374 // Get tag | 363 // Get tag |
375 CComBSTR bstrTag; | 364 std::wstring tag; |
376 if (FAILED(pEl->get_tagName(&bstrTag)) || !bstrTag) | 365 if ( ! element.tag_name( tag ) || tag.empty() ) |
377 { | 366 { |
378 return; | 367 return; |
379 } | 368 } |
380 | 369 ABP::util::to_lower( tag ); |
381 CString tag = bstrTag; | |
382 tag.MakeLower(); | |
383 | 370 |
384 // Custom OnElement | 371 // Custom OnElement |
385 if (!OnElement(pEl, tag, &m_cacheElements[cacheIndex], false, indent)) | 372 if (!OnElement(pEl, tag, &m_cacheElements[cacheIndex], false, indent)) |
386 { | 373 { |
387 return; | 374 return; |
388 } | 375 } |
389 | 376 |
390 // Update frame/iframe cache | 377 // Update frame/iframe cache |
391 if (tag == "iframe") | 378 if (tag == L"iframe") |
392 { | 379 { |
393 m_criticalSection.Lock(); | 380 m_criticalSection.Lock(); |
394 { | 381 { |
395 m_cacheDocumentHasIframes.insert(m_documentName); | 382 m_cacheDocumentHasIframes.insert(m_documentName); |
396 } | 383 } |
397 m_criticalSection.Unlock(); | 384 m_criticalSection.Unlock(); |
398 } | 385 } |
399 else if (tag == "frame") | 386 else if (tag == L"frame") |
400 { | 387 { |
401 m_criticalSection.Lock(); | 388 m_criticalSection.Lock(); |
402 { | 389 { |
403 m_cacheDocumentHasFrames.insert(m_documentName); | 390 m_cacheDocumentHasFrames.insert(m_documentName); |
404 } | 391 } |
405 m_criticalSection.Unlock(); | 392 m_criticalSection.Unlock(); |
406 } | 393 } |
407 | 394 |
408 // Iterate through children of this element | 395 // Iterate through children of this element |
409 if (allElementsCount > 0) | 396 if (allElementsCount > 0) |
410 { | 397 { |
411 long childElementsCount = 0; | 398 long childElementsCount = 0; |
412 | 399 |
413 CComPtr<IDispatch> pChildCollectionDisp; | 400 CComPtr<IDispatch> pChildCollectionDisp; |
414 if (SUCCEEDED(pEl->get_children(&pChildCollectionDisp)) && pChildCollectionD
isp) | 401 if (SUCCEEDED(pEl->get_children(&pChildCollectionDisp)) && pChildCollectionD
isp) |
415 { | 402 { |
416 CComPtr<IHTMLElementCollection> pChildCollection; | 403 CComPtr<IHTMLElementCollection> pChildCollection; |
417 if (SUCCEEDED(pChildCollectionDisp->QueryInterface(IID_IHTMLElementCollect
ion, (LPVOID*)&pChildCollection)) && pChildCollection) | 404 if (SUCCEEDED(pChildCollectionDisp->QueryInterface(IID_IHTMLElementCollect
ion, (LPVOID*)&pChildCollection)) && pChildCollection) |
418 { | 405 { |
| 406 Wrapper::HTML_Element_Collection child_elements( pChildCollection ); |
419 pChildCollection->get_length(&childElementsCount); | 407 pChildCollection->get_length(&childElementsCount); |
420 | 408 |
421 CComVariant vIndex(0); | |
422 | |
423 // Iterate through all children | 409 // Iterate through all children |
424 for (long i = 0; i < childElementsCount; i++) | 410 for (long i = 0; i < childElementsCount; i++) |
425 { | 411 { |
426 CComPtr<IDispatch> pChildElDispatch; | 412 CComPtr<IDispatch> pChildElDispatch; |
427 CComVariant vRetIndex; | 413 pChildElDispatch = child_elements.at( i ); |
428 | 414 if ( pChildElDispatch ) |
429 vIndex.intVal = i; | |
430 | |
431 if (SUCCEEDED(pChildCollection->item(vIndex, vRetIndex, &pChildElDispa
tch)) && pChildElDispatch) | |
432 { | 415 { |
433 CComPtr<IHTMLElement> pChildEl; | 416 CComPtr<IHTMLElement> pChildEl; |
434 if (SUCCEEDED(pChildElDispatch->QueryInterface(IID_IHTMLElement, (LP
VOID*)&pChildEl)) && pChildEl) | 417 if (SUCCEEDED(pChildElDispatch->QueryInterface(IID_IHTMLElement, (LP
VOID*)&pChildEl)) && pChildEl) |
435 { | 418 { |
436 TraverseChild(pChildEl, pBrowser, indent + " ", isCached); | 419 TraverseChild(pChildEl, pBrowser, indent + L" ", isCached); |
437 } | 420 } |
438 } | 421 } |
439 } | 422 } |
440 } | 423 } |
441 } | 424 } |
442 } | 425 } |
443 } | 426 } |
444 | 427 |
445 | 428 |
446 template <class T> | 429 template <class T> |
(...skipping 13 matching lines...) Expand all Loading... |
460 if (tab->m_plugin->GetTabHWND() == NULL) | 443 if (tab->m_plugin->GetTabHWND() == NULL) |
461 { | 444 { |
462 return; | 445 return; |
463 } | 446 } |
464 | 447 |
465 | 448 |
466 } | 449 } |
467 | 450 |
468 | 451 |
469 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ | 452 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ |
OLD | NEW |