Commit 11b92d75 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[PE] Correct anchor position in printed subframe

When a subframe initiates printing, all coordinates should be in the
subframe's space, so we should not map anchors to the root frame.

Bug: 808057

Change-Id: I8714cfaddc1bd5471da2561f69ef92994d57c559
Reviewed-on: https://chromium-review.googlesource.com/894464
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533723}
parent bc75a035
<p>This text in the subframe should be printed.</p>
<script> <p style="height: 2000px">
window.onload = function() { frames[0].print(); } This text in the main frame should not be printed
</script> when the sub frame (scroll down to see it) initiates printing.
<p>This text in the main frame should not be printed.</p> </p>
<iframe src="resources/print-subframe.html"> <iframe srcdoc="
<p>This <a href='#target'>link</a> in the subframe should be printed.</p>
<button onclick='print()'>Print</button>
<p>In the saved pdf, clicking the above link should navigate to the page containing 'TARGET'</p>
<div style='height: 2000px'></div>
<a name='target'>TARGET</a>
<div style='height: 2000px'></div>
<script>
setTimeout(function() { window.print(); }, 500);
</script>">
</iframe>
...@@ -226,16 +226,9 @@ void PrintContext::OutputLinkedDestinations(GraphicsContext& context, ...@@ -226,16 +226,9 @@ void PrintContext::OutputLinkedDestinations(GraphicsContext& context,
LayoutObject* layout_object = entry.value->GetLayoutObject(); LayoutObject* layout_object = entry.value->GetLayoutObject();
if (!layout_object || !layout_object->GetFrameView()) if (!layout_object || !layout_object->GetFrameView())
continue; continue;
IntRect bounding_box = layout_object->AbsoluteBoundingBoxRect(); IntPoint anchor_point = layout_object->AbsoluteBoundingBoxRect().Location();
// TODO(bokan): |bounding_box| looks to be in content coordinates but if (page_rect.Contains(anchor_point))
// ConvertToRootFrame() doesn't apply scroll offsets when converting up to context.SetURLDestinationLocation(entry.key, anchor_point);
// the root frame.
IntPoint point = layout_object->GetFrameView()->ConvertToRootFrame(
bounding_box.Location());
if (!page_rect.Contains(point))
continue;
point.ClampNegativeToZero();
context.SetURLDestinationLocation(entry.key, point);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment