OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 if (isShadowHost(&node)) { | 73 if (isShadowHost(&node)) { |
74 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root
->olderShadowRoot()) | 74 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root
->olderShadowRoot()) |
75 invalidateStyleForAllLinksRecursively(*root, invalidateVisitedLi
nkHashes); | 75 invalidateStyleForAllLinksRecursively(*root, invalidateVisitedLi
nkHashes); |
76 } | 76 } |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void VisitedLinkState::invalidateStyleForAllLinks(bool invalidateVisitedLinkHash
es) | 80 void VisitedLinkState::invalidateStyleForAllLinks(bool invalidateVisitedLinkHash
es) |
81 { | 81 { |
82 if (!m_linksCheckedForVisitedState.isEmpty()) | 82 if (!m_linksCheckedForVisitedState.isEmpty() && document().firstChild()) |
83 invalidateStyleForAllLinksRecursively(*document().firstChild(), invalida
teVisitedLinkHashes); | 83 invalidateStyleForAllLinksRecursively(*document().firstChild(), invalida
teVisitedLinkHashes); |
84 } | 84 } |
85 | 85 |
86 static void invalidateStyleForLinkRecursively(Node& rootNode, LinkHash linkHash) | 86 static void invalidateStyleForLinkRecursively(Node& rootNode, LinkHash linkHash) |
87 { | 87 { |
88 for (Node& node : NodeTraversal::startsAt(&rootNode)) { | 88 for (Node& node : NodeTraversal::startsAt(&rootNode)) { |
89 if (node.isLink() && linkHashForElement(toElement(node)) == linkHash) { | 89 if (node.isLink() && linkHashForElement(toElement(node)) == linkHash) { |
90 toElement(node).pseudoStateChanged(CSSSelector::PseudoLink); | 90 toElement(node).pseudoStateChanged(CSSSelector::PseudoLink); |
91 toElement(node).pseudoStateChanged(CSSSelector::PseudoVisited); | 91 toElement(node).pseudoStateChanged(CSSSelector::PseudoVisited); |
92 toElement(node).pseudoStateChanged(CSSSelector::PseudoAnyLink); | 92 toElement(node).pseudoStateChanged(CSSSelector::PseudoAnyLink); |
93 } | 93 } |
94 if (isShadowHost(&node)) | 94 if (isShadowHost(&node)) |
95 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root
->olderShadowRoot()) | 95 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root
->olderShadowRoot()) |
96 invalidateStyleForLinkRecursively(*root, linkHash); | 96 invalidateStyleForLinkRecursively(*root, linkHash); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 void VisitedLinkState::invalidateStyleForLink(LinkHash linkHash) | 100 void VisitedLinkState::invalidateStyleForLink(LinkHash linkHash) |
101 { | 101 { |
102 if (m_linksCheckedForVisitedState.contains(linkHash)) | 102 if (m_linksCheckedForVisitedState.contains(linkHash) && document().firstChil
d()) |
103 invalidateStyleForLinkRecursively(*document().firstChild(), linkHash); | 103 invalidateStyleForLinkRecursively(*document().firstChild(), linkHash); |
104 } | 104 } |
105 | 105 |
106 EInsideLink VisitedLinkState::determineLinkStateSlowCase(const Element& element) | 106 EInsideLink VisitedLinkState::determineLinkStateSlowCase(const Element& element) |
107 { | 107 { |
108 DCHECK(element.isLink()); | 108 DCHECK(element.isLink()); |
109 DCHECK(document().isActive()); | 109 DCHECK(document().isActive()); |
110 DCHECK(document() == element.document()); | 110 DCHECK(document() == element.document()); |
111 | 111 |
112 const AtomicString& attribute = linkAttribute(element); | 112 const AtomicString& attribute = linkAttribute(element); |
(...skipping 16 matching lines...) Expand all Loading... |
129 | 129 |
130 return InsideUnvisitedLink; | 130 return InsideUnvisitedLink; |
131 } | 131 } |
132 | 132 |
133 DEFINE_TRACE(VisitedLinkState) | 133 DEFINE_TRACE(VisitedLinkState) |
134 { | 134 { |
135 visitor->trace(m_document); | 135 visitor->trace(m_document); |
136 } | 136 } |
137 | 137 |
138 } // namespace blink | 138 } // namespace blink |
OLD | NEW |