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

Delta Between Two Patch Sets: src/plugin/AdblockPlusDomTraverser.cpp

Issue 6567422169448448: Issue 119 - Switch to injecting CSS for element hiding (Closed)
Left Patch Set: rebase Created Dec. 1, 2015, 11:29 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/AdblockPlusDomTraverser.h ('k') | src/plugin/PluginClass.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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include "PluginStdAfx.h" 18 #include "PluginStdAfx.h"
19 #include "AdblockPlusDomTraverser.h" 19 #include "AdblockPlusDomTraverser.h"
20 #include "AdblockPlusClient.h" 20 #include "AdblockPlusClient.h"
21 #include "PluginFilter.h" 21 #include "PluginFilter.h"
22 #include "PluginSettings.h" 22 #include "PluginSettings.h"
23 #include "..\shared\Utils.h" 23 #include "..\shared\Utils.h"
24 24
25 25
26 CPluginDomTraverser::CPluginDomTraverser(CPluginTab* tab) : CPluginDomTraverserB ase(tab) 26 CPluginDomTraverser::CPluginDomTraverser(const PluginFilterPtr& pluginFilter) : CPluginDomTraverserBase(pluginFilter)
27 { 27 {
28 } 28 }
29 29
30 30
31 bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const std::wstring& url, c onst std::wstring& indent) 31 bool CPluginDomTraverser::OnIFrame(IHTMLElement* pEl, const std::wstring& url, c onst std::wstring& indent)
32 { 32 {
33 CPluginClient* client = CPluginClient::GetInstance(); 33 CPluginClient* client = CPluginClient::GetInstance();
34 34
35 // If src should be blocked, set style display:none on iframe 35 // If src should be blocked, set style display:none on iframe
36 bool isBlocked = client->ShouldBlock(url, 36 bool isBlocked = client->ShouldBlock(url,
37 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_SUBDOCUMENT, m_document Url); 37 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_SUBDOCUMENT, m_document Url);
38 if (isBlocked) 38 if (isBlocked)
39 { 39 {
40 HideElement(pEl, L"iframe", url, true, indent); 40 HideElement(pEl, L"iframe", url, true, indent);
41 } 41 }
42 42
43 return !isBlocked; 43 return !isBlocked;
44 } 44 }
45 45
46 46
47 bool CPluginDomTraverser::OnElement(IHTMLElement* pEl, const std::wstring& tag, CPluginDomTraverserCache* cache, bool isDebug, const std::wstring& indent) 47 bool CPluginDomTraverser::OnElement(IHTMLElement* pEl, const std::wstring& tag, CPluginDomTraverserCache* cache, bool isDebug, const std::wstring& indent)
48 { 48 {
49 if (cache->m_isHidden) 49 if (cache->m_isHidden)
50 { 50 {
51 return false; 51 return false;
52 } 52 }
53 53
54 // Check if element is hidden 54 cache->m_isHidden = m_pluginFilter->IsElementHidden(tag, pEl, m_domain, indent );
55 CPluginClient* client = CPluginClient::GetInstance();
56
57 cache->m_isHidden = client->IsElementHidden(tag, pEl, m_domain, indent, &(m_ta b->m_filter));
58 if (cache->m_isHidden) 55 if (cache->m_isHidden)
59 { 56 {
60 HideElement(pEl, tag, L"", false, indent); 57 HideElement(pEl, tag, L"", false, indent);
61 return false; 58 return false;
62 } 59 }
63 60
64 // Images 61 // Images
65 if (tag == L"img") 62 if (tag == L"img")
66 { 63 {
67 CComVariant vAttr; 64 CComVariant vAttr;
68 if (SUCCEEDED(pEl->getAttribute(ATL::CComBSTR(L"src"), 0, &vAttr)) && vAttr. vt == VT_BSTR) 65 if (SUCCEEDED(pEl->getAttribute(ATL::CComBSTR(L"src"), 0, &vAttr)) && vAttr. vt == VT_BSTR)
69 { 66 {
70 std::wstring src = ToWstring(vAttr.bstrVal); 67 std::wstring src = ToWstring(vAttr.bstrVal);
71 if (!src.empty()) 68 if (!src.empty())
72 { 69 {
73 // If src should be blocked, set style display:none on image 70 // If src should be blocked, set style display:none on image
74 cache->m_isHidden = client->ShouldBlock(src, 71 cache->m_isHidden = CPluginClient::GetInstance()->ShouldBlock(src,
75 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_IMAGE, m_document Url); 72 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_IMAGE, m_document Url);
76 if (cache->m_isHidden) 73 if (cache->m_isHidden)
77 { 74 {
78 HideElement(pEl, L"image", src, true, indent); 75 HideElement(pEl, L"image", src, true, indent);
79 return false; 76 return false;
80 } 77 }
81 } 78 }
82 } 79 }
83 } 80 }
84 // Objects 81 // Objects
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 DEBUG_HIDE_EL(ToWstring(indent) + L"HideEl::Hiding " + ToWstring(type) + L " url:" + url) 146 DEBUG_HIDE_EL(ToWstring(indent) + L"HideEl::Hiding " + ToWstring(type) + L " url:" + url)
150 #ifdef ENABLE_DEBUG_RESULT 147 #ifdef ENABLE_DEBUG_RESULT
151 if (isDebug) 148 if (isDebug)
152 { 149 {
153 CPluginDebug::DebugResultHiding(type, url, L"-"); 150 CPluginDebug::DebugResultHiding(type, url, L"-");
154 } 151 }
155 #endif // ENABLE_DEBUG_RESULT 152 #endif // ENABLE_DEBUG_RESULT
156 } 153 }
157 } 154 }
158 } 155 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld