summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink')
-rw-r--r--chromium/third_party/blink/renderer/core/inspector/inspector_media_context_impl.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/page/print_context_test.cc61
-rw-r--r--chromium/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc14
-rw-r--r--chromium/third_party/blink/renderer/platform/widget/widget_base.cc6
4 files changed, 83 insertions, 6 deletions
diff --git a/chromium/third_party/blink/renderer/core/inspector/inspector_media_context_impl.cc b/chromium/third_party/blink/renderer/core/inspector/inspector_media_context_impl.cc
index 8260587fcc9..91318882e2d 100644
--- a/chromium/third_party/blink/renderer/core/inspector/inspector_media_context_impl.cc
+++ b/chromium/third_party/blink/renderer/core/inspector/inspector_media_context_impl.cc
@@ -109,9 +109,13 @@ void MediaInspectorContextImpl::TrimPlayer(const WebString& playerId) {
void MediaInspectorContextImpl::CullPlayers(const WebString& prefer_keep) {
// Erase all the dead players, but only erase the required number of others.
- for (const auto& playerId : dead_players_)
+ while (!dead_players_.empty()) {
+ auto playerId = dead_players_.back();
+ // remove it first, since |RemovePlayer| can cause a GC event which can
+ // potentially caues more players to get added to |dead_players_|.
+ dead_players_.pop_back();
RemovePlayer(playerId);
- dead_players_.clear();
+ }
while (!expendable_players_.empty()) {
if (total_event_count_ <= kMaxCachedPlayerEvents)
diff --git a/chromium/third_party/blink/renderer/core/page/print_context_test.cc b/chromium/third_party/blink/renderer/core/page/print_context_test.cc
index 36df50f346e..c72c5187260 100644
--- a/chromium/third_party/blink/renderer/core/page/print_context_test.cc
+++ b/chromium/third_party/blink/renderer/core/page/print_context_test.cc
@@ -130,14 +130,17 @@ class PrintContextTest : public PaintTestConfigurations, public RenderingTest {
GetDocument().body()->setInnerHTML(body_content);
}
- void PrintSinglePage(SkCanvas& canvas) {
- gfx::Rect page_rect(0, 0, kPageWidth, kPageHeight);
+ gfx::Rect PrintSinglePage(SkCanvas& canvas, int page_number = 0) {
GetDocument().SetPrinting(Document::kBeforePrinting);
Event* event = MakeGarbageCollected<BeforePrintEvent>();
GetPrintContext().GetFrame()->DomWindow()->DispatchEvent(*event);
- GetPrintContext().BeginPrintMode(page_rect.width(), page_rect.height());
+ GetPrintContext().BeginPrintMode(kPageWidth, kPageHeight);
GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(
DocumentUpdateReason::kTest);
+
+ GetPrintContext().ComputePageRects(gfx::SizeF(kPageWidth, kPageHeight));
+ gfx::Rect page_rect = GetPrintContext().PageRect(page_number);
+
auto* builder = MakeGarbageCollected<PaintRecordBuilder>();
GraphicsContext& context = builder->Context();
context.SetPrinting(true);
@@ -151,6 +154,7 @@ class PrintContextTest : public PaintTestConfigurations, public RenderingTest {
}
builder->EndRecording()->Playback(&canvas);
GetPrintContext().EndPrintMode();
+ return page_rect;
}
static String AbsoluteBlockHtmlForLink(int x,
@@ -466,6 +470,57 @@ TEST_P(PrintContextTest, LinkTargetBoundingBox) {
EXPECT_SKRECT_EQ(50, 60, 200, 100, operations[0].rect);
}
+TEST_P(PrintContextTest, LinkInFragmentedContainer) {
+ SetBodyInnerHTML(R"HTML(
+ <style>
+ body {
+ margin: 0;
+ line-height: 50px;
+ orphans: 1;
+ widows: 1;
+ }
+ </style>
+ <div style="height:calc(100vh - 90px);"></div>
+ <div>
+ <a href="http://www.google.com">link 1</a><br>
+ <!-- Page break here. -->
+ <a href="http://www.google.com">link 2</a><br>
+ <a href="http://www.google.com">link 3</a><br>
+ </div>
+ )HTML");
+
+ MockPageContextCanvas first_page_canvas;
+ gfx::Rect page_rect = PrintSinglePage(first_page_canvas, 0);
+ Vector<MockPageContextCanvas::Operation> operations =
+ first_page_canvas.RecordedOperations();
+
+ // TODO(crbug.com/1392701): Should be 1.
+ ASSERT_EQ(operations.size(), 3u);
+
+ const auto& page1_link1 = operations[0];
+ EXPECT_EQ(page1_link1.type, MockPageContextCanvas::kDrawRect);
+ EXPECT_GE(page1_link1.rect.y(), page_rect.height() - 90);
+ EXPECT_LE(page1_link1.rect.bottom(), page_rect.height() - 40);
+
+ MockPageContextCanvas second_page_canvas;
+ page_rect = PrintSinglePage(second_page_canvas, 1);
+ operations = second_page_canvas.RecordedOperations();
+
+ // TODO(crbug.com/1392701): Should be 2.
+ ASSERT_EQ(operations.size(), 3u);
+ // TODO(crbug.com/1392701): Should be operations[0]
+ const auto& page2_link1 = operations[1];
+ // TODO(crbug.com/1392701): Should be operations[1]
+ const auto& page2_link2 = operations[2];
+
+ EXPECT_EQ(page2_link1.type, MockPageContextCanvas::kDrawRect);
+ EXPECT_GE(page2_link1.rect.y(), page_rect.y());
+ EXPECT_LE(page2_link1.rect.bottom(), page_rect.y() + 50);
+ EXPECT_EQ(page2_link2.type, MockPageContextCanvas::kDrawRect);
+ EXPECT_GE(page2_link2.rect.y(), page_rect.y() + 50);
+ EXPECT_LE(page2_link2.rect.bottom(), page_rect.y() + 100);
+}
+
// Here are a few tests to check that shrink to fit doesn't mess up page count.
TEST_P(PrintContextTest, ScaledVerticalRL1) {
diff --git a/chromium/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc b/chromium/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
index 5b7cb08913f..c22267b1c6a 100644
--- a/chromium/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
+++ b/chromium/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
@@ -821,8 +821,20 @@ void NGBoxFragmentPainter::PaintLineBoxes(const PaintInfo& paint_info,
if (child_paint_info.phase == PaintPhase::kForeground &&
child_paint_info.ShouldAddUrlMetadata()) {
+ // TODO(crbug.com/1392701): Avoid walking the LayoutObject tree (which is
+ // what AddURLRectsForInlineChildrenRecursively() does). We should walk the
+ // fragment tree instead (if we can figure out how to deal with culled
+ // inlines - or get rid of them). Walking the LayoutObject tree means that
+ // we'll visit every link in the container for each fragment generated,
+ // leading to duplicate entries. This is only fine as long as the absolute
+ // offsets is the same every time a given link is visited. Otherwise links
+ // might end up as unclickable in the resulting PDF. So make sure that the
+ // paint offset relative to the first fragment generated by this
+ // container. This matches legacy engine behavior.
+ PhysicalOffset paint_offset_for_first_fragment =
+ paint_offset - OffsetInStitchedFragments(box_fragment_);
AddURLRectsForInlineChildrenRecursively(*layout_object, child_paint_info,
- paint_offset);
+ paint_offset_for_first_fragment);
}
// If we have no lines then we have no work to do.
diff --git a/chromium/third_party/blink/renderer/platform/widget/widget_base.cc b/chromium/third_party/blink/renderer/platform/widget/widget_base.cc
index 2e57c4fe3ca..f779d8d0910 100644
--- a/chromium/third_party/blink/renderer/platform/widget/widget_base.cc
+++ b/chromium/third_party/blink/renderer/platform/widget/widget_base.cc
@@ -898,8 +898,14 @@ void WidgetBase::BeginMainFrame(base::TimeTicks frame_time) {
if (ShouldRecordBeginMainFrameMetrics()) {
raf_aligned_input_start_time = base::TimeTicks::Now();
}
+
+ auto weak_this = weak_ptr_factory_.GetWeakPtr();
widget_input_handler_manager_->input_event_queue()->DispatchRafAlignedInput(
frame_time);
+ // DispatchRafAlignedInput could have detached the frame.
+ if (!weak_this)
+ return;
+
if (ShouldRecordBeginMainFrameMetrics()) {
client_->RecordDispatchRafAlignedInputTime(raf_aligned_input_start_time);
}