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

Unified Diff: src/plugin/AdblockPlusDomTraverser.cpp

Issue 29333350: Issue #3562 - Use 'ToWstring()' to convert BSTR values (Closed)
Patch Set: fix up error log message Created Jan. 11, 2016, 3:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/plugin/PluginClass.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/AdblockPlusDomTraverser.cpp
===================================================================
--- a/src/plugin/AdblockPlusDomTraverser.cpp
+++ b/src/plugin/AdblockPlusDomTraverser.cpp
@@ -65,18 +65,19 @@
if (tag == L"img")
{
CComVariant vAttr;
-
- if (SUCCEEDED(pEl->getAttribute(ATL::CComBSTR(L"src"), 0, &vAttr)) && vAttr.vt == VT_BSTR && ::SysStringLen(vAttr.bstrVal) > 0)
+ if (SUCCEEDED(pEl->getAttribute(ATL::CComBSTR(L"src"), 0, &vAttr)) && vAttr.vt == VT_BSTR)
{
- std::wstring src(vAttr.bstrVal, SysStringLen(vAttr.bstrVal));
-
- // If src should be blocked, set style display:none on image
- cache->m_isHidden = client->ShouldBlock(src,
- AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_IMAGE, m_documentUrl);
- if (cache->m_isHidden)
+ std::wstring src = ToWstring(vAttr.bstrVal);
+ if (!src.empty())
{
- HideElement(pEl, L"image", src, true, indent);
- return false;
+ // If src should be blocked, set style display:none on image
+ cache->m_isHidden = client->ShouldBlock(src,
+ AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_IMAGE, m_documentUrl);
+ if (cache->m_isHidden)
+ {
+ HideElement(pEl, L"image", src, true, indent);
+ return false;
+ }
}
}
}
@@ -138,17 +139,14 @@
if (SUCCEEDED(pEl->get_style(&pStyle)) && pStyle)
{
CComBSTR bstrDisplay;
- if (SUCCEEDED(pStyle->get_display(&bstrDisplay)) && bstrDisplay && ToWstring(bstrDisplay) == L"none")
+ if (SUCCEEDED(pStyle->get_display(&bstrDisplay)) && ToWstring(bstrDisplay) == L"none")
{
return;
}
-
static const CComBSTR sbstrNone(L"none");
-
if (SUCCEEDED(pStyle->put_display(sbstrNone)))
{
DEBUG_HIDE_EL(ToWstring(indent) + L"HideEl::Hiding " + ToWstring(type) + L" url:" + url)
-
#ifdef ENABLE_DEBUG_RESULT
if (isDebug)
{
« no previous file with comments | « no previous file | src/plugin/PluginClass.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld