Commit 3cf1176f authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Utilize NGInlineCursor in InspectorCSSAgent::CollectPlatformFontsForLayoutObject()

This patch changes |InspectorCSSAgent::CollectPlatformFontsForLayoutObject()| to
utilize |NGInlineCursor| for preparation of migration to |NGFragmentItem|.

Bug: 982194
Change-Id: Id8550ce0d70def5b1eb1f7d442e0e97152cc7fba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880360
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710677}
parent 3364e996
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
#include "third_party/blink/renderer/core/layout/layout_text.h" #include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/line/inline_text_box.h" #include "third_party/blink/renderer/core/layout/line/inline_text_box.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h"
#include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" #include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
...@@ -1185,12 +1185,11 @@ void InspectorCSSAgent::CollectPlatformFontsForLayoutObject( ...@@ -1185,12 +1185,11 @@ void InspectorCSSAgent::CollectPlatformFontsForLayoutObject(
LayoutText* layout_text = ToLayoutText(layout_object); LayoutText* layout_text = ToLayoutText(layout_object);
if (RuntimeEnabledFeatures::LayoutNGEnabled()) { if (RuntimeEnabledFeatures::LayoutNGEnabled()) {
auto fragments = NGPaintFragment::InlineFragmentsFor(layout_object); if (layout_object->IsInLayoutNGInlineFormattingContext()) {
if (fragments.IsInLayoutNGInlineFormattingContext()) { NGInlineCursor cursor;
for (const NGPaintFragment* fragment : fragments) { cursor.MoveTo(*layout_object);
const auto& text_fragment = for (; cursor; cursor.MoveToNextForSameLayoutObject()) {
To<NGPhysicalTextFragment>(fragment->PhysicalFragment()); const ShapeResultView* shape_result = cursor.CurrentTextShapeResult();
const ShapeResultView* shape_result = text_fragment.TextShapeResult();
if (!shape_result) if (!shape_result)
continue; continue;
Vector<ShapeResult::RunFontData> run_font_data_list; Vector<ShapeResult::RunFontData> run_font_data_list;
......
...@@ -412,6 +412,19 @@ unsigned NGInlineCursor::CurrentTextEndOffset() const { ...@@ -412,6 +412,19 @@ unsigned NGInlineCursor::CurrentTextEndOffset() const {
return 0u; return 0u;
} }
const ShapeResultView* NGInlineCursor::CurrentTextShapeResult() const {
DCHECK(IsText());
if (current_paint_fragment_) {
return To<NGPhysicalTextFragment>(
current_paint_fragment_->PhysicalFragment())
.TextShapeResult();
}
if (current_item_)
return current_item_->TextShapeResult();
NOTREACHED();
return nullptr;
}
PhysicalRect NGInlineCursor::CurrentLocalRect(unsigned start_offset, PhysicalRect NGInlineCursor::CurrentLocalRect(unsigned start_offset,
unsigned end_offset) const { unsigned end_offset) const {
DCHECK(IsText()); DCHECK(IsText());
......
...@@ -26,6 +26,7 @@ class Node; ...@@ -26,6 +26,7 @@ class Node;
struct PhysicalOffset; struct PhysicalOffset;
struct PhysicalRect; struct PhysicalRect;
struct PhysicalSize; struct PhysicalSize;
class ShapeResultView;
// This class traverses fragments in an inline formatting context. // This class traverses fragments in an inline formatting context.
// //
...@@ -150,6 +151,10 @@ class CORE_EXPORT NGInlineCursor { ...@@ -150,6 +151,10 @@ class CORE_EXPORT NGInlineCursor {
unsigned CurrentTextStartOffset() const; unsigned CurrentTextStartOffset() const;
unsigned CurrentTextEndOffset() const; unsigned CurrentTextEndOffset() const;
// Returns |ShapeResultView| of the current position. It is error to call
// other than text.
const ShapeResultView* CurrentTextShapeResult() const;
// The layout box of text in (start, end) range in local coordinate. // The layout box of text in (start, end) range in local coordinate.
// Start and end offsets must be between |CurrentTextStartOffset()| and // Start and end offsets must be between |CurrentTextStartOffset()| and
// |CurrentTextEndOffset()|. It is error to call other than text. // |CurrentTextEndOffset()|. It is error to call other than text.
......
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