1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *           (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) Research In Motion Limited 2011. All rights reserved.
11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2012 Google Inc. All rights reserved.
12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * This library is free software; you can redistribute it and/or
14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modify it under the terms of the GNU Library General Public
15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * License as published by the Free Software Foundation; either
16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * version 2 of the License, or (at your option) any later version.
17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * This library is distributed in the hope that it will be useful,
19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of
20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Library General Public License for more details.
22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * You should have received a copy of the GNU Library General Public License
24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * along with this library; see the file COPYING.LIB.  If not, write to
25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Boston, MA 02110-1301, USA.
27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */
28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
29926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#ifndef VisitedLinkState_h
30926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#define VisitedLinkState_h
31926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/Element.h"
3353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/rendering/style/RenderStyleConstants.h"
341e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/LinkHash.h"
3593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "wtf/HashSet.h"
36926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
37c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
38926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
39926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class Document;
40926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
41c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)class VisitedLinkState : public NoBaseWillBeGarbageCollectedFinalized<VisitedLinkState> {
42c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
43926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public:
44c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    static PassOwnPtrWillBeRawPtr<VisitedLinkState> create(const Document& document)
451e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    {
46c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)        return adoptPtrWillBeNoop(new VisitedLinkState(document));
471e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    }
48926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void invalidateStyleForAllLinks();
50926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    void invalidateStyleForLink(LinkHash);
511e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
521e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    EInsideLink determineLinkState(const Element& element)
531e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    {
541e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)        if (element.isLink())
551e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)            return determineLinkStateSlowCase(element);
561e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)        return NotInsideLink;
571e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    }
58926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
59c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    void trace(Visitor*);
60c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)
61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)private:
621e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    explicit VisitedLinkState(const Document&);
63c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    const Document& document() const { return *m_document; }
64926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
651e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    EInsideLink determineLinkStateSlowCase(const Element&);
66926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
67c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    RawPtrWillBeMember<const Document> m_document;
68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    HashSet<LinkHash, LinkHashHash> m_linksCheckedForVisitedState;
69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
70926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
71926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
72926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
73926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif
74926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
75