Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: third_party/WebKit/Source/core/dom/VisitedLinkState.cpp

Issue 1910433002: Invalidate LinkHash state for links in shadow roots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing include. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/VisitedLinkState.cpp
diff --git a/third_party/WebKit/Source/core/dom/VisitedLinkState.cpp b/third_party/WebKit/Source/core/dom/VisitedLinkState.cpp
index 4d7876030bcff6497ae96219ea37906a14d862b9..e7abe0e6f494080d63ff0ea0f6a4c8489003683c 100644
--- a/third_party/WebKit/Source/core/dom/VisitedLinkState.cpp
+++ b/third_party/WebKit/Source/core/dom/VisitedLinkState.cpp
@@ -30,6 +30,8 @@
#include "core/HTMLNames.h"
#include "core/dom/ElementTraversal.h"
+#include "core/dom/shadow/ElementShadow.h"
+#include "core/dom/shadow/ShadowRoot.h"
#include "core/html/HTMLAnchorElement.h"
#include "core/svg/SVGURIReference.h"
#include "public/platform/Platform.h"
@@ -58,11 +60,9 @@ VisitedLinkState::VisitedLinkState(const Document& document)
{
}
-void VisitedLinkState::invalidateStyleForAllLinks(bool invalidateVisitedLinkHashes)
+static void invalidateStyleForAllLinksRecursively(Node& rootNode, bool invalidateVisitedLinkHashes)
{
- if (m_linksCheckedForVisitedState.isEmpty())
- return;
- for (Node& node : NodeTraversal::startsAt(document().firstChild())) {
+ for (Node& node : NodeTraversal::startsAt(&rootNode)) {
if (node.isLink()) {
if (invalidateVisitedLinkHashes && isHTMLAnchorElement(node))
toHTMLAnchorElement(node).invalidateCachedVisitedLinkHash();
@@ -70,22 +70,41 @@ void VisitedLinkState::invalidateStyleForAllLinks(bool invalidateVisitedLinkHash
toElement(node).pseudoStateChanged(CSSSelector::PseudoVisited);
toElement(node).pseudoStateChanged(CSSSelector::PseudoAnyLink);
}
+ if (isShadowHost(&node)) {
+ for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root->olderShadowRoot())
+ invalidateStyleForAllLinksRecursively(*root, invalidateVisitedLinkHashes);
+ }
}
}
-void VisitedLinkState::invalidateStyleForLink(LinkHash linkHash)
+void VisitedLinkState::invalidateStyleForAllLinks(bool invalidateVisitedLinkHashes)
{
- if (!m_linksCheckedForVisitedState.contains(linkHash))
+ if (m_linksCheckedForVisitedState.isEmpty())
tkent 2016/04/21 03:55:23 nit: if (!m_linksCheckedForVisitedState.isEmpty(
kochi 2016/04/21 04:13:53 Done.
return;
- for (Node& node : NodeTraversal::startsAt(document().firstChild())) {
+ invalidateStyleForAllLinksRecursively(*document().firstChild(), invalidateVisitedLinkHashes);
+}
+
+static void invalidateStyleForLinkRecursively(Node& rootNode, LinkHash linkHash)
+{
+ for (Node& node : NodeTraversal::startsAt(&rootNode)) {
if (node.isLink() && linkHashForElement(toElement(node)) == linkHash) {
toElement(node).pseudoStateChanged(CSSSelector::PseudoLink);
toElement(node).pseudoStateChanged(CSSSelector::PseudoVisited);
toElement(node).pseudoStateChanged(CSSSelector::PseudoAnyLink);
}
+ if (isShadowHost(&node))
+ for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root->olderShadowRoot())
+ invalidateStyleForLinkRecursively(*root, linkHash);
}
}
+void VisitedLinkState::invalidateStyleForLink(LinkHash linkHash)
+{
+ if (!m_linksCheckedForVisitedState.contains(linkHash))
tkent 2016/04/21 03:55:23 nit: if (m_linksCheckedForVisitedState.contain
kochi 2016/04/21 04:13:53 Done.
+ return;
+ invalidateStyleForLinkRecursively(*document().firstChild(), linkHash);
+}
+
EInsideLink VisitedLinkState::determineLinkStateSlowCase(const Element& element)
{
DCHECK(element.isLink());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698