Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/plugin/PluginDomTraverserBase.h

Issue 6567422169448448: Issue 119 - Switch to injecting CSS for element hiding (Closed)
Left Patch Set: fix injecting of CSS when plugin is enabled/disabled and rearrange variables in InjectABPCSS Created April 13, 2015, 8:52 a.m.
Right Patch Set: rename OnQuit Created Sept. 30, 2016, 3:25 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/PluginClass.cpp ('k') | src/plugin/PluginFilter.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 19 matching lines...) Expand all
30 CPluginDomTraverserCacheBase() : m_elements(0) {}; 30 CPluginDomTraverserCacheBase() : m_elements(0) {};
31 void Init() { m_elements=0; } 31 void Init() { m_elements=0; }
32 }; 32 };
33 33
34 template <class T> 34 template <class T>
35 class CPluginDomTraverserBase 35 class CPluginDomTraverserBase
36 { 36 {
37 37
38 public: 38 public:
39 39
40 CPluginDomTraverserBase(CPluginTab* tab); 40 explicit CPluginDomTraverserBase(const PluginFilterPtr& pluginFilter);
41 ~CPluginDomTraverserBase(); 41 ~CPluginDomTraverserBase();
42 42
43 void TraverseHeader(bool isHeaderTraversed); 43 void TraverseHeader(bool isHeaderTraversed);
44 44
45 void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, cons t std::wstring& documentUrl); 45 void TraverseDocument(IWebBrowser2* pBrowser, const std::wstring& domain, cons t std::wstring& documentUrl);
46 void TraverseSubdocument(IWebBrowser2* pBrowser, const std::wstring& domain, c onst std::wstring& documentUrl); 46 void TraverseSubdocument(IWebBrowser2* pBrowser, const std::wstring& domain, c onst std::wstring& documentUrl);
47 47
48 virtual void ClearCache(); 48 virtual void ClearCache();
49 49
50 protected: 50 protected:
51 51
52 virtual bool OnIFrame(IHTMLElement* pEl, const std::wstring& url, const std::w string& indent) { return true; } 52 virtual bool OnIFrame(IHTMLElement* pEl, const std::wstring& url, const std::w string& indent) { return true; }
53 virtual bool OnElement(IHTMLElement* pEl, const std::wstring& tag, T* cache, b ool isDebug, const std::wstring& indent) { return true; } 53 virtual bool OnElement(IHTMLElement* pEl, const std::wstring& tag, T* cache, b ool isDebug, const std::wstring& indent) { return true; }
54 54
55 virtual bool IsEnabled(); 55 virtual bool IsEnabled();
56 56
57 protected: 57 protected:
58 58
59 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, const std::wstri ng& indent); 59 void TraverseDocument(IWebBrowser2* pBrowser, bool isMainDoc, const std::wstri ng& indent);
60 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, const std::wstri ng& indent, bool isCached=true); 60 void TraverseChild(IHTMLElement* pEl, IWebBrowser2* pBrowser, const std::wstri ng& indent, bool isCached=true);
61 61
62 CComAutoCriticalSection m_criticalSection; 62 CComAutoCriticalSection m_criticalSection;
63 63
64 std::wstring m_domain; 64 std::wstring m_domain;
65 std::wstring m_documentUrl; 65 std::wstring m_documentUrl;
66 66
67 bool m_isHeaderTraversed; 67 bool m_isHeaderTraversed;
68
69 // Caching
70 long m_cacheDomElementCount;
71 68
72 int m_cacheIndexLast; 69 int m_cacheIndexLast;
73 int m_cacheElementsMax; 70 int m_cacheElementsMax;
74 std::set<std::wstring> m_cacheDocumentHasFrames; 71 std::set<std::wstring> m_cacheDocumentHasFrames;
75 std::set<std::wstring> m_cacheDocumentHasIframes; 72 std::set<std::wstring> m_cacheDocumentHasIframes;
76 73
77 T* m_cacheElements; 74 T* m_cacheElements;
78 75
79 CPluginTab* m_tab; 76 std::shared_ptr<const CPluginFilter> m_pluginFilter;
80 CComPtr<IWebBrowser2> m_pBrowser;
81 }; 77 };
82 78
83 template <class T> 79 template <class T>
84 CPluginDomTraverserBase<T>::CPluginDomTraverserBase(CPluginTab* tab) : 80 CPluginDomTraverserBase<T>::CPluginDomTraverserBase(const PluginFilterPtr& plugi nFilter)
85 m_tab(tab), m_isHeaderTraversed(false), m_cacheDomElementCount(0), m_cacheInde xLast(0), m_cacheElementsMax(5000) 81 : m_pluginFilter(pluginFilter), m_isHeaderTraversed(false), m_cacheIndexLast(0 ), m_cacheElementsMax(5000)
86 { 82 {
87 m_cacheElements = new T[m_cacheElementsMax]; 83 m_cacheElements = new T[m_cacheElementsMax];
88 } 84 }
89 85
90 86
91 template <class T> 87 template <class T>
92 CPluginDomTraverserBase<T>::~CPluginDomTraverserBase() 88 CPluginDomTraverserBase<T>::~CPluginDomTraverserBase()
93 { 89 {
94 delete [] m_cacheElements; 90 delete [] m_cacheElements;
95 } 91 }
(...skipping 25 matching lines...) Expand all
121 template <class T> 117 template <class T>
122 bool CPluginDomTraverserBase<T>::IsEnabled() 118 bool CPluginDomTraverserBase<T>::IsEnabled()
123 { 119 {
124 return CPluginSettings::GetInstance()->IsPluginEnabled(); 120 return CPluginSettings::GetInstance()->IsPluginEnabled();
125 } 121 }
126 122
127 123
128 template <class T> 124 template <class T>
129 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, bool i sMainDoc, const std::wstring& indent) 125 void CPluginDomTraverserBase<T>::TraverseDocument(IWebBrowser2* pBrowser, bool i sMainDoc, const std::wstring& indent)
130 { 126 {
131 DWORD res = WaitForSingleObject(m_tab->m_filter.hideFiltersLoadedEvent, ENGINE _STARTUP_TIMEOUT);
132 if (!IsEnabled()) return; 127 if (!IsEnabled()) return;
133 128
134 VARIANT_BOOL isBusy; 129 VARIANT_BOOL isBusy;
135 if (SUCCEEDED(pBrowser->get_Busy(&isBusy))) 130 if (SUCCEEDED(pBrowser->get_Busy(&isBusy)))
136 { 131 {
137 if (isBusy != VARIANT_FALSE) 132 if (isBusy != VARIANT_FALSE)
138 { 133 {
139 return; 134 return;
140 } 135 }
141 } 136 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 { 451 {
457 m_cacheIndexLast = 0; 452 m_cacheIndexLast = 0;
458 m_cacheDocumentHasFrames.clear(); 453 m_cacheDocumentHasFrames.clear();
459 m_cacheDocumentHasIframes.clear(); 454 m_cacheDocumentHasIframes.clear();
460 } 455 }
461 m_criticalSection.Unlock(); 456 m_criticalSection.Unlock();
462 } 457 }
463 458
464 459
465 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_ 460 #endif // _PLUGIN_DOM_TRAVERSER_BASE_H_
LEFTRIGHT

Powered by Google App Engine
This is Rietveld