Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 } | 91 } |
| 92 | 92 |
| 93 const std::vector<BreakList<bool>>& styles() const { | 93 const std::vector<BreakList<bool>>& styles() const { |
| 94 return render_text_->styles(); | 94 return render_text_->styles(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 const std::vector<internal::Line>& lines() const { | 97 const std::vector<internal::Line>& lines() const { |
| 98 return render_text_->lines(); | 98 return render_text_->lines(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void set_lines(std::vector<internal::Line>* lines) { | |
| 102 render_text_->set_lines(lines); | |
| 103 } | |
| 104 | |
| 101 SelectionModel EdgeSelectionModel(VisualCursorDirection direction) { | 105 SelectionModel EdgeSelectionModel(VisualCursorDirection direction) { |
| 102 return render_text_->EdgeSelectionModel(direction); | 106 return render_text_->EdgeSelectionModel(direction); |
| 103 } | 107 } |
| 104 | 108 |
| 105 size_t TextIndexToDisplayIndex(size_t index) { | 109 size_t TextIndexToDisplayIndex(size_t index) { |
| 106 return render_text_->TextIndexToDisplayIndex(index); | 110 return render_text_->TextIndexToDisplayIndex(index); |
| 107 } | 111 } |
| 108 | 112 |
| 109 size_t DisplayIndexToTextIndex(size_t index) { | 113 size_t DisplayIndexToTextIndex(size_t index) { |
| 110 return render_text_->DisplayIndexToTextIndex(index); | 114 return render_text_->DisplayIndexToTextIndex(index); |
| (...skipping 4291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4402 #endif | 4406 #endif |
| 4403 const std::string font_name = "invalid_font"; | 4407 const std::string font_name = "invalid_font"; |
| 4404 const int kFontSize = 13; | 4408 const int kFontSize = 13; |
| 4405 RenderText* render_text = GetRenderText(); | 4409 RenderText* render_text = GetRenderText(); |
| 4406 render_text->SetFontList(FontList(Font(font_name, kFontSize))); | 4410 render_text->SetFontList(FontList(Font(font_name, kFontSize))); |
| 4407 render_text->SetText(ASCIIToUTF16("abc")); | 4411 render_text->SetText(ASCIIToUTF16("abc")); |
| 4408 | 4412 |
| 4409 DrawVisualText(); | 4413 DrawVisualText(); |
| 4410 } | 4414 } |
| 4411 | 4415 |
| 4416 TEST_P(RenderTextTest, LinesInvalidationOnElideBehaviorChange) { | |
| 4417 RenderText* render_text = GetRenderText(); | |
| 4418 EXPECT_EQ(render_text->elide_behavior(), gfx::NO_ELIDE); | |
| 4419 | |
| 4420 std::vector<internal::Line> lines(1); | |
| 4421 test_api()->set_lines(&lines); | |
|
msw
2017/04/17 23:51:44
nit: avoid adding RenderTextTestApi::set_lines and
simonhong
2017/04/18 13:33:33
Done.
| |
| 4422 | |
| 4423 render_text->SetElideBehavior(gfx::NO_ELIDE); | |
| 4424 EXPECT_FALSE(test_api()->lines().empty()); | |
| 4425 | |
| 4426 // lines are cleared when elide behavior changes. | |
|
msw
2017/04/17 23:51:44
nit: "Lines"
simonhong
2017/04/18 13:33:33
Done.
| |
| 4427 render_text->SetElideBehavior(gfx::ELIDE_TAIL); | |
| 4428 EXPECT_TRUE(test_api()->lines().empty()); | |
| 4429 } | |
| 4430 | |
| 4412 // Ensures that text is centered vertically and consistently when either the | 4431 // Ensures that text is centered vertically and consistently when either the |
| 4413 // display rectangle height changes, or when the minimum line height changes. | 4432 // display rectangle height changes, or when the minimum line height changes. |
| 4414 // The difference between the two is the selection rectangle, which should match | 4433 // The difference between the two is the selection rectangle, which should match |
| 4415 // the line height. | 4434 // the line height. |
| 4416 TEST_P(RenderTextHarfBuzzTest, BaselineWithLineHeight) { | 4435 TEST_P(RenderTextHarfBuzzTest, BaselineWithLineHeight) { |
| 4417 RenderText* render_text = GetRenderText(); | 4436 RenderText* render_text = GetRenderText(); |
| 4418 const int font_height = render_text->font_list().GetHeight(); | 4437 const int font_height = render_text->font_list().GetHeight(); |
| 4419 render_text->SetDisplayRect(Rect(500, font_height)); | 4438 render_text->SetDisplayRect(Rect(500, font_height)); |
| 4420 render_text->SetText(ASCIIToUTF16("abc")); | 4439 render_text->SetText(ASCIIToUTF16("abc")); |
| 4421 | 4440 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4521 ::testing::Values(RENDER_TEXT_HARFBUZZ), | 4540 ::testing::Values(RENDER_TEXT_HARFBUZZ), |
| 4522 PrintRenderTextBackend()); | 4541 PrintRenderTextBackend()); |
| 4523 #endif | 4542 #endif |
| 4524 | 4543 |
| 4525 INSTANTIATE_TEST_CASE_P(, | 4544 INSTANTIATE_TEST_CASE_P(, |
| 4526 RenderTextHarfBuzzTest, | 4545 RenderTextHarfBuzzTest, |
| 4527 ::testing::Values(RENDER_TEXT_HARFBUZZ), | 4546 ::testing::Values(RENDER_TEXT_HARFBUZZ), |
| 4528 PrintRenderTextBackend()); | 4547 PrintRenderTextBackend()); |
| 4529 | 4548 |
| 4530 } // namespace gfx | 4549 } // namespace gfx |
| OLD | NEW |