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

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

Issue 5747779603267584: Issue #1234 - Rework strings in debug facility (Closed)
Patch Set: typo fix Created March 5, 2015, 12:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginDebugMacros.h ('k') | src/plugin/PluginStdAfx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 if (!id.IsEmpty()) 563 if (!id.IsEmpty())
564 { 564 {
565 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT agsNamed::const_iterator> idItEnum = 565 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT agsNamed::const_iterator> idItEnum =
566 m_elementHideTagsId.equal_range(std::make_pair(tagCString, id)); 566 m_elementHideTagsId.equal_range(std::make_pair(tagCString, id));
567 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++) 567 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++)
568 { 568 {
569 if (idIt->second.IsMatchFilterElementHide(pEl)) 569 if (idIt->second.IsMatchFilterElementHide(pEl))
570 { 570 {
571 #ifdef ENABLE_DEBUG_RESULT 571 #ifdef ENABLE_DEBUG_RESULT
572 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/id) filter:" + idIt->second .m_filterText) 572 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/id) filter:" + idIt->second .m_filterText)
573 CPluginDebug::DebugResultHiding(tagCString, L"id:" + id, idIt->secon d.m_filterText); 573 CPluginDebug::DebugResultHiding(tag, L"id:" + ToWstring(id), ToWstri ng(idIt->second.m_filterText));
574 #endif 574 #endif
575 return true; 575 return true;
576 } 576 }
577 } 577 }
578 578
579 // Search general id 579 // Search general id
580 idItEnum = m_elementHideTagsId.equal_range(std::make_pair("", id)); 580 idItEnum = m_elementHideTagsId.equal_range(std::make_pair("", id));
581 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++) 581 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id It != idItEnum.second; idIt ++)
582 { 582 {
583 if (idIt->second.IsMatchFilterElementHide(pEl)) 583 if (idIt->second.IsMatchFilterElementHide(pEl))
584 { 584 {
585 #ifdef ENABLE_DEBUG_RESULT 585 #ifdef ENABLE_DEBUG_RESULT
586 DEBUG_HIDE_EL(indent + "HideEl::Found (?/id) filter:" + idIt->second.m _filterText) 586 DEBUG_HIDE_EL(indent + "HideEl::Found (?/id) filter:" + idIt->second.m _filterText)
587 CPluginDebug::DebugResultHiding(tagCString, L"id:" + id, idIt->secon d.m_filterText); 587 CPluginDebug::DebugResultHiding(tag, L"id:" + ToWstring(id), ToWstri ng(idIt->second.m_filterText));
588 #endif 588 #endif
589 return true; 589 return true;
590 } 590 }
591 } 591 }
592 } 592 }
593 593
594 // Search tag/className filters 594 // Search tag/className filters
595 if (!classNames.IsEmpty()) 595 if (!classNames.IsEmpty())
596 { 596 {
597 int pos = 0; 597 int pos = 0;
598 CString className = classNames.Tokenize(L" \t\n\r", pos); 598 CString className = classNames.Tokenize(L" \t\n\r", pos);
599 while (pos >= 0) 599 while (pos >= 0)
600 { 600 {
601 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHid eTagsNamed::const_iterator> classItEnum = 601 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHid eTagsNamed::const_iterator> classItEnum =
602 m_elementHideTagsClass.equal_range(std::make_pair(tagCString, classNam e)); 602 m_elementHideTagsClass.equal_range(std::make_pair(tagCString, classNam e));
603 603
604 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++classIt) 604 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++classIt)
605 { 605 {
606 if (classIt->second.IsMatchFilterElementHide(pEl)) 606 if (classIt->second.IsMatchFilterElementHide(pEl))
607 { 607 {
608 #ifdef ENABLE_DEBUG_RESULT 608 #ifdef ENABLE_DEBUG_RESULT
609 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/class) filter:" + classIt ->second.m_filterText) 609 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/class) filter:" + classIt ->second.m_filterText)
610 CPluginDebug::DebugResultHiding(tagCString, L"class:" + className, classIt->second.m_filterText); 610 CPluginDebug::DebugResultHiding(tag, L"class:" + ToWstring(classNa me), ToWstring(classIt->second.m_filterText));
611 #endif 611 #endif
612 return true; 612 return true;
613 } 613 }
614 } 614 }
615 615
616 // Search general class name 616 // Search general class name
617 classItEnum = m_elementHideTagsClass.equal_range(std::make_pair("", clas sName)); 617 classItEnum = m_elementHideTagsClass.equal_range(std::make_pair("", clas sName));
618 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++ classIt) 618 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f irst; classIt != classItEnum.second; ++ classIt)
619 { 619 {
620 if (classIt->second.IsMatchFilterElementHide(pEl)) 620 if (classIt->second.IsMatchFilterElementHide(pEl))
621 { 621 {
622 #ifdef ENABLE_DEBUG_RESULT 622 #ifdef ENABLE_DEBUG_RESULT
623 DEBUG_HIDE_EL(indent + "HideEl::Found (?/class) filter:" + classIt-> second.m_filterText) 623 DEBUG_HIDE_EL(indent + L"HideEl::Found (?/class) filter:" + ToWStrin g(classIt->second.m_filterText));
624 CPluginDebug::DebugResultHiding(tagCString, "class:" + className, classIt->second.m_filterText); 624 CPluginDebug::DebugResultHiding(tag, L"class:" + ToWstring(className ), ToWstring(classIt->second.m_filterText));
625 #endif 625 #endif
626 return true; 626 return true;
627 } 627 }
628 } 628 }
629 629
630 // Next class name 630 // Next class name
631 className = classNames.Tokenize(L" \t\n\r", pos); 631 className = classNames.Tokenize(L" \t\n\r", pos);
632 } 632 }
633 } 633 }
634 634
635 // Search tag filters 635 // Search tag filters
636 std::pair<TFilterElementHideTags::const_iterator, TFilterElementHideTags::co nst_iterator> tagItEnum 636 std::pair<TFilterElementHideTags::const_iterator, TFilterElementHideTags::co nst_iterator> tagItEnum
637 = m_elementHideTags.equal_range(tagCString); 637 = m_elementHideTags.equal_range(tagCString);
638 for (TFilterElementHideTags::const_iterator tagIt = tagItEnum.first; tagIt ! = tagItEnum.second; ++ tagIt) 638 for (TFilterElementHideTags::const_iterator tagIt = tagItEnum.first; tagIt ! = tagItEnum.second; ++ tagIt)
639 { 639 {
640 if (tagIt->second.IsMatchFilterElementHide(pEl)) 640 if (tagIt->second.IsMatchFilterElementHide(pEl))
641 { 641 {
642 #ifdef ENABLE_DEBUG_RESULT 642 #ifdef ENABLE_DEBUG_RESULT
643 DEBUG_HIDE_EL(indent + "HideEl::Found (tag) filter:" + tagIt->second.m_f ilterText) 643 DEBUG_HIDE_EL(indent + "HideEl::Found (tag) filter:" + tagIt->second.m_f ilterText)
644 CPluginDebug::DebugResultHiding(tagCString, "-", tagIt->second.m_filte rText); 644 CPluginDebug::DebugResultHiding(tag, L"-", ToWstring(tagIt->second.m_f ilterText));
645 #endif 645 #endif
646 return true; 646 return true;
647 } 647 }
648 } 648 }
649 } 649 }
650 650
651 return false; 651 return false;
652 } 652 }
653 653
654 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters) 654 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters)
(...skipping 16 matching lines...) Expand all
671 671
672 // See http://adblockplus.org/en/filters for further documentation 672 // See http://adblockplus.org/en/filters for further documentation
673 673
674 try 674 try
675 { 675 {
676 AddFilterElementHide(filter); 676 AddFilterElementHide(filter);
677 } 677 }
678 catch(...) 678 catch(...)
679 { 679 {
680 #ifdef ENABLE_DEBUG_RESULT 680 #ifdef ENABLE_DEBUG_RESULT
681 CPluginDebug::DebugResult(L"Error loading hide filter: " + filter); 681 CPluginDebug::DebugResult(L"Error loading hide filter: " + ToWstring(f ilter));
682 #endif 682 #endif
683 } 683 }
684 } 684 }
685 } 685 }
686 } 686 }
687 687
688 return isRead; 688 return isRead;
689 } 689 }
690 690
691 void CPluginFilter::ClearFilters() 691 void CPluginFilter::ClearFilters()
(...skipping 20 matching lines...) Expand all
712 712
713 CPluginClient* client = CPluginClient::GetInstance(); 713 CPluginClient* client = CPluginClient::GetInstance();
714 bool result = client->Matches(srcTrimmed, contentType, domain); 714 bool result = client->Matches(srcTrimmed, contentType, domain);
715 715
716 #ifdef ENABLE_DEBUG_RESULT 716 #ifdef ENABLE_DEBUG_RESULT
717 if (addDebug) 717 if (addDebug)
718 { 718 {
719 std::wstring type = ToUtf16String(AdblockPlus::FilterEngine::ContentTypeToSt ring(contentType)); 719 std::wstring type = ToUtf16String(AdblockPlus::FilterEngine::ContentTypeToSt ring(contentType));
720 if (result) 720 if (result)
721 { 721 {
722 CPluginDebug::DebugResultBlocking(ToCString(type), srcTrimmed, domain); 722 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain);
723 } 723 }
724 else 724 else
725 { 725 {
726 CPluginDebug::DebugResultIgnoring(ToCString(type), srcTrimmed, domain); 726 CPluginDebug::DebugResultIgnoring(type, srcTrimmed, domain);
727 } 727 }
728 } 728 }
729 #endif 729 #endif
730 return result; 730 return result;
731 } 731 }
OLDNEW
« no previous file with comments | « src/plugin/PluginDebugMacros.h ('k') | src/plugin/PluginStdAfx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld