OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
3 * Copyright (C) 2007 Apple Inc. | 3 * Copyright (C) 2007 Apple Inc. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return; | 229 return; |
230 const AtomicString& href = toElement(node)->getAttribute(HTMLNames::hrefAttr
); | 230 const AtomicString& href = toElement(node)->getAttribute(HTMLNames::hrefAttr
); |
231 if (href.isNull()) | 231 if (href.isNull()) |
232 return; | 232 return; |
233 KURL url = node->document().completeURL(href); | 233 KURL url = node->document().completeURL(href); |
234 if (!url.isValid()) | 234 if (!url.isValid()) |
235 return; | 235 return; |
236 | 236 |
237 bool linkIsValid = true; | 237 bool linkIsValid = true; |
238 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, node
->document().baseURL())) { | 238 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, node
->document().baseURL())) { |
239 String name = url.fragmentIdentifier(); | 239 // Only output anchors and links to anchors in the top-level frame becau
se our PrintContext |
240 Element* element = node->document().findAnchor(name); | 240 // supports only one namespace for the anchors. |
241 if (element) | 241 if (node->document().frame() == m_frame.get()) { |
242 m_linkedDestinations.set(name, element); | 242 String name = url.fragmentIdentifier(); |
243 else | 243 if (Element* element = node->document().findAnchor(name)) |
| 244 m_linkedDestinations.set(name, element); |
| 245 else |
| 246 linkIsValid = false; |
| 247 } else { |
244 linkIsValid = false; | 248 linkIsValid = false; |
| 249 } |
245 } | 250 } |
246 | 251 |
247 if (linkIsValid) | 252 if (linkIsValid) |
248 m_linkDestinations.set(toElement(node), url); | 253 m_linkDestinations.set(toElement(node), url); |
249 } | 254 } |
250 | 255 |
251 void PrintContext::outputLinkAndLinkedDestinations(GraphicsContext& graphicsCont
ext, Node* node, const IntRect& pageRect) | 256 void PrintContext::outputLinkAndLinkedDestinations(GraphicsContext& graphicsCont
ext, const IntRect& pageRect) |
252 { | 257 { |
253 if (!m_linkAndLinkedDestinationsValid) { | 258 if (!m_linkAndLinkedDestinationsValid) { |
254 collectLinkAndLinkedDestinations(node); | 259 for (Frame* currentFrame = frame(); currentFrame; currentFrame = current
Frame->tree().traverseNext(frame())) { |
| 260 if (currentFrame->isLocalFrame()) |
| 261 collectLinkAndLinkedDestinations(toLocalFrame(currentFrame)->doc
ument()); |
| 262 } |
255 m_linkAndLinkedDestinationsValid = true; | 263 m_linkAndLinkedDestinationsValid = true; |
256 } | 264 } |
257 | 265 |
258 for (const auto& entry : m_linkDestinations) { | 266 for (const auto& entry : m_linkDestinations) { |
259 LayoutObject* renderer = entry.key->renderer(); | 267 LayoutObject* renderer = entry.key->renderer(); |
260 if (!renderer) | 268 if (!renderer) |
261 continue; | 269 continue; |
262 KURL url = entry.value; | 270 KURL url = entry.value; |
263 IntRect boundingBox = renderer->absoluteBoundingBoxRect(); | 271 IntRect boundingBox = renderer->absoluteBoundingBoxRect(); |
264 if (!pageRect.intersects(boundingBox)) | 272 if (!pageRect.intersects(boundingBox)) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 void PrintContext::trace(Visitor* visitor) | 350 void PrintContext::trace(Visitor* visitor) |
343 { | 351 { |
344 #if ENABLE(OILPAN) | 352 #if ENABLE(OILPAN) |
345 visitor->trace(m_frame); | 353 visitor->trace(m_frame); |
346 visitor->trace(m_linkDestinations); | 354 visitor->trace(m_linkDestinations); |
347 visitor->trace(m_linkedDestinations); | 355 visitor->trace(m_linkedDestinations); |
348 #endif | 356 #endif |
349 } | 357 } |
350 | 358 |
351 } | 359 } |
OLD | NEW |