1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * This library is free software; you can redistribute it and/or
6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modify it under the terms of the GNU Library General Public
7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * License as published by the Free Software Foundation; either
8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * version 2 of the License, or (at your option) any later version.
9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * This library is distributed in the hope that it will be useful,
11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of
12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Library General Public License for more details.
14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * You should have received a copy of the GNU Library General Public License
16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * along with this library; see the file COPYING.LIB.  If not, write to
17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Boston, MA 02110-1301, USA.
19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */
21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#ifndef PageRuleCollector_h
23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#define PageRuleCollector_h
24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
25e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "core/css/resolver/MatchResult.h"
26591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "wtf/Vector.h"
27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)namespace WebCore {
29926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
30e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochclass ElementResolveContext;
31926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class StyleRulePage;
32926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
33926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class PageRuleCollector {
34926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public:
35e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    PageRuleCollector(const ElementResolveContext&, int pageIndex);
36926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    void matchPageRules(RuleSet* rules);
38e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    MatchResult& matchedResult() { return m_result; }
39926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
40926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)private:
41926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    bool isLeftPage(int pageIndex) const;
42926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); }
43926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    bool isFirstPage(int pageIndex) const;
44926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    String pageName(int pageIndex) const;
45926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
46926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vector<StyleRulePage*>& rules, bool isLeftPage, bool isFirstPage, const String& pageName);
47926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
48e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    const ElementResolveContext& m_context;
4953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const bool m_isLeftPage;
5053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const bool m_isFirstPage;
5153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    const String m_pageName;
52926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
53e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    MatchResult m_result;
54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
55926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
56926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} // namespace WebCore
57926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
58926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif // PageRuleCollector_h
59