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

Side by Side Diff: src/plugin/AdblockPlusDomTraverser.cpp

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: fix accoring to comments Created Jan. 13, 2015, 12:59 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginClient.h" 3 #include "PluginClient.h"
4 #include "PluginFilter.h" 4 #include "PluginFilter.h"
5 #include "PluginSettings.h" 5 #include "PluginSettings.h"
6 6
7 #include "AdblockPlusDomTraverser.h" 7 #include "AdblockPlusDomTraverser.h"
8 8
9 9
10 CPluginDomTraverser::CPluginDomTraverser(CPluginTab* tab) : CPluginDomTraverserB ase(tab) 10 CPluginDomTraverser::CPluginDomTraverser(CPluginTab* tab) : CPluginDomTraverserB ase(tab)
11 { 11 {
12 } 12 }
13 13
14 14
15 bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const CString& url, CStrin g& indent) 15 bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const CString& url, CStrin g& indent)
16 { 16 {
17 CPluginClient* client = CPluginClient::GetInstance(); 17 CPluginClient* client = CPluginClient::GetInstance();
18 18
19 // If src should be blocked, set style display:none on iframe 19 // If src should be blocked, set style display:none on iframe
20 bool isBlocked = client->ShouldBlock(to_wstring(url), CFilter::contentTypeSubd ocument, m_domain); 20 bool isBlocked = client->ShouldBlock(ToWstring(url),
21 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_SUBDOCUMENT, m_domain);
21 if (isBlocked) 22 if (isBlocked)
22 { 23 {
23 HideElement(pEl, "iframe", url, true, indent); 24 HideElement(pEl, "iframe", url, true, indent);
24 } 25 }
25 26
26 return !isBlocked; 27 return !isBlocked;
27 } 28 }
28 29
29 30
30 bool CPluginDomTraverser::OnElement(IHTMLElement* pEl, const CString& tag, CPlug inDomTraverserCache* cache, bool isDebug, CString& indent) 31 bool CPluginDomTraverser::OnElement(IHTMLElement* pEl, const CString& tag, CPlug inDomTraverserCache* cache, bool isDebug, CString& indent)
31 { 32 {
32 if (cache->m_isHidden) 33 if (cache->m_isHidden)
33 { 34 {
34 return false; 35 return false;
35 } 36 }
36 37
37 // Check if element is hidden 38 // Check if element is hidden
38 CPluginClient* client = CPluginClient::GetInstance(); 39 CPluginClient* client = CPluginClient::GetInstance();
39 40
40 cache->m_isHidden = client->IsElementHidden(to_wstring(tag), pEl, m_domain, to _wstring(indent), m_tab->m_filter.get()); 41 cache->m_isHidden = client->IsElementHidden(ToWstring(tag), pEl, m_domain, ToW string(indent), m_tab->m_filter.get());
41 if (cache->m_isHidden) 42 if (cache->m_isHidden)
42 { 43 {
43 HideElement(pEl, tag, "", false, indent); 44 HideElement(pEl, tag, "", false, indent);
44 return false; 45 return false;
45 } 46 }
46 47
47 // Images 48 // Images
48 if (tag == "img") 49 if (tag == "img")
49 { 50 {
50 CComVariant vAttr; 51 CComVariant vAttr;
51 52
52 if (SUCCEEDED(pEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt == VT_BSTR & & ::SysStringLen(vAttr.bstrVal) > 0) 53 if (SUCCEEDED(pEl->getAttribute(L"src", 0, &vAttr)) && vAttr.vt == VT_BSTR & & ::SysStringLen(vAttr.bstrVal) > 0)
53 { 54 {
54 CString src = vAttr.bstrVal; 55 CString src = vAttr.bstrVal;
55 CPluginClient::UnescapeUrl(src); 56 CPluginClient::UnescapeUrl(src);
56 57
57 // If src should be blocked, set style display:none on image 58 // If src should be blocked, set style display:none on image
58 cache->m_isHidden = client->ShouldBlock(to_wstring(src), CFilter::contentT ypeImage, m_domain); 59 cache->m_isHidden = client->ShouldBlock(ToWstring(src),
60 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_IMAGE, m_domain);
59 if (cache->m_isHidden) 61 if (cache->m_isHidden)
60 { 62 {
61 HideElement(pEl, "image", src, true, indent); 63 HideElement(pEl, "image", src, true, indent);
62 return false; 64 return false;
63 } 65 }
64 } 66 }
65 } 67 }
66 // Objects 68 // Objects
67 else if (tag == "object") 69 else if (tag == "object")
68 { 70 {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 137
136 #ifdef ENABLE_DEBUG_RESULT 138 #ifdef ENABLE_DEBUG_RESULT
137 if (isDebug) 139 if (isDebug)
138 { 140 {
139 CPluginDebug::DebugResultHiding(type, url, "-"); 141 CPluginDebug::DebugResultHiding(type, url, "-");
140 } 142 }
141 #endif // ENABLE_DEBUG_RESULT 143 #endif // ENABLE_DEBUG_RESULT
142 } 144 }
143 } 145 }
144 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld