OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 CComVariant vIndex(0); | 177 CComVariant vIndex(0); |
178 CComPtr<IDispatch> pBodyDispatch; | 178 CComPtr<IDispatch> pBodyDispatch; |
179 if (FAILED(pBodyCollection->item(vIndex, vIndex, &pBodyDispatch)) || !pBodyD
ispatch) | 179 if (FAILED(pBodyCollection->item(vIndex, vIndex, &pBodyDispatch)) || !pBodyD
ispatch) |
180 { | 180 { |
181 return; | 181 return; |
182 } | 182 } |
183 | 183 |
184 if (FAILED(pBodyDispatch->QueryInterface(IID_IHTMLElement, (LPVOID*)&pBodyEl
)) || !pBodyEl) | 184 if (FAILED(pBodyDispatch->QueryInterface(&pBodyEl)) || !pBodyEl) |
185 { | 185 { |
186 return; | 186 return; |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 // Clear cache (if eg. refreshing) ??? | 190 // Clear cache (if eg. refreshing) ??? |
191 if (isMainDoc) | 191 if (isMainDoc) |
192 { | 192 { |
193 CComVariant vCacheIndex; | 193 CComVariant vCacheIndex; |
194 | 194 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 // Get number of elements in the scope of pEl | 355 // Get number of elements in the scope of pEl |
356 long allElementsCount = 0; | 356 long allElementsCount = 0; |
357 | 357 |
358 CComPtr<IDispatch> pAllCollectionDisp; | 358 CComPtr<IDispatch> pAllCollectionDisp; |
359 | 359 |
360 if (SUCCEEDED(pEl->get_all(&pAllCollectionDisp)) && pAllCollectionDisp) | 360 if (SUCCEEDED(pEl->get_all(&pAllCollectionDisp)) && pAllCollectionDisp) |
361 { | 361 { |
362 CComPtr<IHTMLElementCollection> pAllCollection; | 362 CComPtr<IHTMLElementCollection> pAllCollection; |
363 | 363 |
364 if (SUCCEEDED(pAllCollectionDisp->QueryInterface(IID_IHTMLElementCollection,
(LPVOID*)&pAllCollection)) && pAllCollection) | 364 if (SUCCEEDED(pAllCollectionDisp->QueryInterface(&pAllCollection)) && pAllCo
llection) |
365 { | 365 { |
366 // If number of elements = cached number, return | 366 // If number of elements = cached number, return |
367 if (SUCCEEDED(pAllCollection->get_length(&allElementsCount)) && allElement
sCount == cacheAllElementsCount) | 367 if (SUCCEEDED(pAllCollection->get_length(&allElementsCount)) && allElement
sCount == cacheAllElementsCount) |
368 { | 368 { |
369 return; | 369 return; |
370 } | 370 } |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 // Update cache | 374 // Update cache |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 414 |
415 // Iterate through children of this element | 415 // Iterate through children of this element |
416 if (allElementsCount > 0) | 416 if (allElementsCount > 0) |
417 { | 417 { |
418 long childElementsCount = 0; | 418 long childElementsCount = 0; |
419 | 419 |
420 CComPtr<IDispatch> pChildCollectionDisp; | 420 CComPtr<IDispatch> pChildCollectionDisp; |
421 if (SUCCEEDED(pEl->get_children(&pChildCollectionDisp)) && pChildCollectionD
isp) | 421 if (SUCCEEDED(pEl->get_children(&pChildCollectionDisp)) && pChildCollectionD
isp) |
422 { | 422 { |
423 CComPtr<IHTMLElementCollection> pChildCollection; | 423 CComPtr<IHTMLElementCollection> pChildCollection; |
424 if (SUCCEEDED(pChildCollectionDisp->QueryInterface(IID_IHTMLElementCollect
ion, (LPVOID*)&pChildCollection)) && pChildCollection) | 424 if (SUCCEEDED(pChildCollectionDisp->QueryInterface(&pChildCollection)) &&
pChildCollection) |
425 { | 425 { |
426 pChildCollection->get_length(&childElementsCount); | 426 pChildCollection->get_length(&childElementsCount); |
427 | 427 |
428 CComVariant vIndex(0); | 428 CComVariant vIndex(0); |
429 | 429 |
430 // Iterate through all children | 430 // Iterate through all children |
431 for (long i = 0; i < childElementsCount; i++) | 431 for (long i = 0; i < childElementsCount; i++) |
432 { | 432 { |
433 CComPtr<IDispatch> pChildElDispatch; | 433 CComPtr<IDispatch> pChildElDispatch; |
434 CComVariant vRetIndex; | 434 CComVariant vRetIndex; |
435 | 435 |
436 vIndex.intVal = i; | 436 vIndex.intVal = i; |
437 | 437 |
438 if (SUCCEEDED(pChildCollection->item(vIndex, vRetIndex, &pChildElDispa
tch)) && pChildElDispatch) | 438 if (SUCCEEDED(pChildCollection->item(vIndex, vRetIndex, &pChildElDispa
tch)) && pChildElDispatch) |
439 { | 439 { |
440 CComPtr<IHTMLElement> pChildEl; | 440 CComPtr<IHTMLElement> pChildEl; |
441 if (SUCCEEDED(pChildElDispatch->QueryInterface(IID_IHTMLElement, (LP
VOID*)&pChildEl)) && pChildEl) | 441 if (SUCCEEDED(pChildElDispatch->QueryInterface(&pChildEl)) && pChild
El) |
442 { | 442 { |
443 TraverseChild(pChildEl, pBrowser, indent + " ", isCached); | 443 TraverseChild(pChildEl, pBrowser, indent + " ", isCached); |
444 } | 444 } |
445 } | 445 } |
446 } | 446 } |
447 } | 447 } |
448 } | 448 } |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 template <class T> | 453 template <class T> |
454 void CPluginDomTraverserBase<T>::ClearCache() | 454 void CPluginDomTraverserBase<T>::ClearCache() |
455 { | 455 { |
456 m_criticalSection.Lock(); | 456 m_criticalSection.Lock(); |
457 { | 457 { |
458 m_cacheIndexLast = 0; | 458 m_cacheIndexLast = 0; |
459 m_cacheDocumentHasFrames.clear(); | 459 m_cacheDocumentHasFrames.clear(); |
460 m_cacheDocumentHasIframes.clear(); | 460 m_cacheDocumentHasIframes.clear(); |
461 } | 461 } |
462 m_criticalSection.Unlock(); | 462 m_criticalSection.Unlock(); |
463 } | 463 } |
464 | 464 |
465 | 465 |
466 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ | 466 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ |
OLD | NEW |