Index: Source/core/page/PrintContext.cpp |
diff --git a/Source/core/page/PrintContext.cpp b/Source/core/page/PrintContext.cpp |
index 32ef68ec5f8c979719137a46b42f9c7de4680171..83edd2db4b98e698e474adfc823cf289a7fd582b 100644 |
--- a/Source/core/page/PrintContext.cpp |
+++ b/Source/core/page/PrintContext.cpp |
@@ -236,22 +236,30 @@ void PrintContext::collectLinkAndLinkedDestinations(Node* node) |
bool linkIsValid = true; |
if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, node->document().baseURL())) { |
- String name = url.fragmentIdentifier(); |
- Element* element = node->document().findAnchor(name); |
- if (element) |
- m_linkedDestinations.set(name, element); |
- else |
+ // Only output anchors and links to anchors in the top-level frame because our PrintContext |
+ // supports only one namespace for the anchors. |
+ if (node->document().frame() == m_frame.get()) { |
+ String name = url.fragmentIdentifier(); |
+ if (Element* element = node->document().findAnchor(name)) |
+ m_linkedDestinations.set(name, element); |
+ else |
+ linkIsValid = false; |
+ } else { |
linkIsValid = false; |
+ } |
} |
if (linkIsValid) |
m_linkDestinations.set(toElement(node), url); |
} |
-void PrintContext::outputLinkAndLinkedDestinations(GraphicsContext& graphicsContext, Node* node, const IntRect& pageRect) |
+void PrintContext::outputLinkAndLinkedDestinations(GraphicsContext& graphicsContext, const IntRect& pageRect) |
{ |
if (!m_linkAndLinkedDestinationsValid) { |
- collectLinkAndLinkedDestinations(node); |
+ for (Frame* currentFrame = frame(); currentFrame; currentFrame = currentFrame->tree().traverseNext(frame())) { |
+ if (currentFrame->isLocalFrame()) |
+ collectLinkAndLinkedDestinations(toLocalFrame(currentFrame)->document()); |
+ } |
m_linkAndLinkedDestinationsValid = true; |
} |