Commit e6a1f1a3 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove some testing of RenderTextMac.

Per the linked bug, RenderTextMac is effectively dead.  While I was touching
render_text_unittest.cc anyway, I thought I'd help a little with the cleanup.

Bug: 131618
Change-Id: I679ce91e4eebc9984ff44b0a8e899f0c36910ee7
Reviewed-on: https://chromium-review.googlesource.com/c/1343106
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609946}
parent 8cc2d519
...@@ -104,7 +104,7 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont { ...@@ -104,7 +104,7 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont {
private: private:
friend class internal::SystemFonts; friend class internal::SystemFonts;
FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, HarfBuzz_UniscribeFallback); FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI); FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution); FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, AdjustFontSize); FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, AdjustFontSize);
...@@ -164,8 +164,7 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont { ...@@ -164,8 +164,7 @@ class GFX_EXPORT PlatformFontWin : public PlatformFont {
private: private:
friend class base::RefCounted<HFontRef>; friend class base::RefCounted<HFontRef>;
FRIEND_TEST_ALL_PREFIXES(RenderTextHarfBuzzTest, FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback);
HarfBuzz_UniscribeFallback);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI); FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, Metrics_SkiaVersusGDI);
FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution); FRIEND_TEST_ALL_PREFIXES(PlatformFontWinTest, DirectWriteFontSubstitution);
......
...@@ -1306,6 +1306,53 @@ std::vector<RenderText::FontSpan> RenderTextHarfBuzz::GetFontSpansForTesting() { ...@@ -1306,6 +1306,53 @@ std::vector<RenderText::FontSpan> RenderTextHarfBuzz::GetFontSpansForTesting() {
return spans; return spans;
} }
std::vector<Rect> RenderTextHarfBuzz::GetSubstringBounds(const Range& range) {
EnsureLayout();
DCHECK(!update_display_run_list_);
DCHECK(Range(0, text().length()).Contains(range));
const size_t start =
IsValidCursorIndex(range.GetMin())
? range.GetMin()
: IndexOfAdjacentGrapheme(range.GetMin(), CURSOR_BACKWARD);
const size_t end =
IsValidCursorIndex(range.GetMax())
? range.GetMax()
: IndexOfAdjacentGrapheme(range.GetMax(), CURSOR_FORWARD);
const Range display_range(TextIndexToDisplayIndex(start),
TextIndexToDisplayIndex(end));
DCHECK(Range(0, GetDisplayText().length()).Contains(display_range));
std::vector<Rect> rects;
if (display_range.is_empty())
return rects;
internal::TextRunList* run_list = GetRunList();
for (size_t line_index = 0; line_index < lines().size(); ++line_index) {
const internal::Line& line = lines()[line_index];
// Only the last line can be empty.
DCHECK(!line.segments.empty() || (line_index == lines().size() - 1));
const float line_start_x =
line.segments.empty()
? 0
: run_list->runs()[line.segments[0].run]->preceding_run_widths;
for (const internal::LineSegment& segment : line.segments) {
const Range intersection = segment.char_range.Intersect(display_range);
DCHECK(!intersection.is_reversed());
if (!intersection.is_empty()) {
const internal::TextRunHarfBuzz& run = *run_list->runs()[segment.run];
RangeF selected_span =
run.GetGraphemeSpanForCharRange(this, intersection);
int start_x = std::ceil(selected_span.start() - line_start_x);
int end_x = std::ceil(selected_span.end() - line_start_x);
Rect rect(start_x, 0, end_x - start_x, std::ceil(line.size.height()));
rects.push_back(rect + GetLineOffset(line_index));
}
}
}
return rects;
}
Range RenderTextHarfBuzz::GetCursorSpan(const Range& text_range) { Range RenderTextHarfBuzz::GetCursorSpan(const Range& text_range) {
DCHECK(!text_range.is_reversed()); DCHECK(!text_range.is_reversed());
EnsureLayout(); EnsureLayout();
...@@ -1437,53 +1484,6 @@ SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel( ...@@ -1437,53 +1484,6 @@ SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel(
return current; return current;
} }
std::vector<Rect> RenderTextHarfBuzz::GetSubstringBounds(const Range& range) {
EnsureLayout();
DCHECK(!update_display_run_list_);
DCHECK(Range(0, text().length()).Contains(range));
const size_t start =
IsValidCursorIndex(range.GetMin())
? range.GetMin()
: IndexOfAdjacentGrapheme(range.GetMin(), CURSOR_BACKWARD);
const size_t end =
IsValidCursorIndex(range.GetMax())
? range.GetMax()
: IndexOfAdjacentGrapheme(range.GetMax(), CURSOR_FORWARD);
const Range display_range(TextIndexToDisplayIndex(start),
TextIndexToDisplayIndex(end));
DCHECK(Range(0, GetDisplayText().length()).Contains(display_range));
std::vector<Rect> rects;
if (display_range.is_empty())
return rects;
internal::TextRunList* run_list = GetRunList();
for (size_t line_index = 0; line_index < lines().size(); ++line_index) {
const internal::Line& line = lines()[line_index];
// Only the last line can be empty.
DCHECK(!line.segments.empty() || (line_index == lines().size() - 1));
const float line_start_x =
line.segments.empty()
? 0
: run_list->runs()[line.segments[0].run]->preceding_run_widths;
for (const internal::LineSegment& segment : line.segments) {
const Range intersection = segment.char_range.Intersect(display_range);
DCHECK(!intersection.is_reversed());
if (!intersection.is_empty()) {
const internal::TextRunHarfBuzz& run = *run_list->runs()[segment.run];
RangeF selected_span =
run.GetGraphemeSpanForCharRange(this, intersection);
int start_x = std::ceil(selected_span.start() - line_start_x);
int end_x = std::ceil(selected_span.end() - line_start_x);
Rect rect(start_x, 0, end_x - start_x, std::ceil(line.size.height()));
rects.push_back(rect + GetLineOffset(line_index));
}
}
}
return rects;
}
size_t RenderTextHarfBuzz::TextIndexToDisplayIndex(size_t index) { size_t RenderTextHarfBuzz::TextIndexToDisplayIndex(size_t index) {
return TextIndexToGivenTextIndex(GetDisplayText(), index); return TextIndexToGivenTextIndex(GetDisplayText(), index);
} }
......
...@@ -214,6 +214,7 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText { ...@@ -214,6 +214,7 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText {
SelectionModel FindCursorPosition(const Point& point) override; SelectionModel FindCursorPosition(const Point& point) override;
bool IsSelectionSupported() const override; bool IsSelectionSupported() const override;
std::vector<FontSpan> GetFontSpansForTesting() override; std::vector<FontSpan> GetFontSpansForTesting() override;
std::vector<Rect> GetSubstringBounds(const Range& range) override;
Range GetCursorSpan(const Range& text_range) override; Range GetCursorSpan(const Range& text_range) override;
// ICU grapheme iterator for the layout text. Can be null in case of an error. // ICU grapheme iterator for the layout text. Can be null in case of an error.
...@@ -228,7 +229,6 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText { ...@@ -228,7 +229,6 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText {
SelectionModel AdjacentWordSelectionModel( SelectionModel AdjacentWordSelectionModel(
const SelectionModel& selection, const SelectionModel& selection,
VisualCursorDirection direction) override; VisualCursorDirection direction) override;
std::vector<Rect> GetSubstringBounds(const Range& range) override;
size_t TextIndexToDisplayIndex(size_t index) override; size_t TextIndexToDisplayIndex(size_t index) override;
size_t DisplayIndexToTextIndex(size_t index) override; size_t DisplayIndexToTextIndex(size_t index) override;
bool IsValidCursorIndex(size_t index) override; bool IsValidCursorIndex(size_t index) override;
...@@ -239,7 +239,7 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText { ...@@ -239,7 +239,7 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText {
private: private:
friend class test::RenderTextTestApi; friend class test::RenderTextTestApi;
friend class RenderTextHarfBuzzTest; friend class RenderTextTest;
// Return the run index that contains the argument; or the length of the // Return the run index that contains the argument; or the length of the
// |runs_| vector if argument exceeds the text length or width. // |runs_| vector if argument exceeds the text length or width.
......
This diff is collapsed.
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