Extend URL filter's Term definition to support groups/subpatterns
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Mar 2015 20:09:26 +0000 (20:09 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Mar 2015 20:09:26 +0000 (20:09 +0000)
commit5a22c2b3f1ac7d268b351d4b59223814fd5d8d5e
treeac960f0bcc875bcee309dbaebbe95f6ae768e787
parent4aa97a6e1bae1610b0563ef8f1988187612126ca
Extend URL filter's Term definition to support groups/subpatterns
https://bugs.webkit.org/show_bug.cgi?id=142519

Patch by Benjamin Poulain <bpoulain@apple.com> on 2015-03-10
Reviewed by Alex Christensen.

Source/WebCore:

Pretty simple extension: Term is extended to support holding
a Vector of Term. The quantifier of the Term applies to its
Vector of term as a whole.

To avoid exposing too much internal in the API of Term, I moved
graph generation from GraphBuilder to Term.

Sinking a CharacterSet works as usual. Sinking a Group is done
by sinking each of its Terms one by one and then apply the quantifier
on the whole subgraph. This is done by recursively calling into
Term::generateGraph().

Since groups could be nested, the groups make a stack with the latest
open group on top.
When sinking a floating Term, it is sunk to the latest open group. If there is no open
group, we use the prefix tree and sink the whole subpattern to the graph.

* contentextensions/URLFilterParser.cpp:
(WebCore::ContentExtensions::Term::Term):
(WebCore::ContentExtensions::Term::extendGroupSubpattern):
(WebCore::ContentExtensions::Term::generateGraph):
(WebCore::ContentExtensions::Term::operator==):
(WebCore::ContentExtensions::Term::hash):
(WebCore::ContentExtensions::Term::isUniversalTransition):
(WebCore::ContentExtensions::Term::generateSubgraphForAtom):
(WebCore::ContentExtensions::Term::destroy):
(WebCore::ContentExtensions::Term::Group::operator==):
(WebCore::ContentExtensions::Term::Group::hash):
(WebCore::ContentExtensions::GraphBuilder::finalize):
(WebCore::ContentExtensions::GraphBuilder::atomParenthesesSubpatternBegin):
(WebCore::ContentExtensions::GraphBuilder::atomParenthesesEnd):
(WebCore::ContentExtensions::GraphBuilder::sinkFloatingTermIfNecessary):
(WebCore::ContentExtensions::Term::quantifier): Deleted.
(WebCore::ContentExtensions::Term::visitSimpleTransitions): Deleted.
(WebCore::ContentExtensions::GraphBuilder::addTransitions): Deleted.
(WebCore::ContentExtensions::GraphBuilder::sinkFloatingTerm): Deleted.

Tools:

* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::testURL):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181341 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/contentextensions/URLFilterParser.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp