summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-12 02:19:33 +0000
committerxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-12 02:19:33 +0000
commit5f4fd30eb1a03f9853e732a8b97c1b2ce8cf3aaf (patch)
treecad152f58ed4cf17c3b71b57edb9e913356a081a /ui/gfx
parentb0e13f27c9116a3b92b699c934cec24d96785655 (diff)
downloadchromium_src-5f4fd30eb1a03f9853e732a8b97c1b2ce8cf3aaf.zip
chromium_src-5f4fd30eb1a03f9853e732a8b97c1b2ce8cf3aaf.tar.gz
chromium_src-5f4fd30eb1a03f9853e732a8b97c1b2ce8cf3aaf.tar.bz2
Fix input text is not visible in Find bar textfield and Add Bookmark name field.
The display area's height in find-in-page and bookmark bubble textfields are smaller than font.GetHeight(). The size_t/int conversion in GetOriginForSkiaDrawing() made origin.y (drawing y coordindate) a very large negative number. BUG=109327 TEST=manual find-in-page and bookmark bubble. RenderTextTest.OriginForSkiaDrawing Review URL: http://codereview.chromium.org/9181001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117365 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/render_text.cc2
-rw-r--r--ui/gfx/render_text.h1
-rw-r--r--ui/gfx/render_text_unittest.cc31
3 files changed, 33 insertions, 1 deletions
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 4695245..47ee948 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -649,7 +649,7 @@ Point RenderText::GetOriginForSkiaDrawing() {
Point origin(ToViewPoint(Point()));
// TODO(msw): Establish a vertical baseline for strings of mixed font heights.
const Font& font = GetFont();
- size_t height = font.GetHeight();
+ int height = font.GetHeight();
// Center the text vertically in the display area.
origin.Offset(0, (display_rect().height() - height) / 2);
// Offset by the font size to account for Skia expecting y to be the bottom.
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index 217f846..5b9c15a 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -298,6 +298,7 @@ class UI_EXPORT RenderText {
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StyleRangesAdjust);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SelectionModels);
+ FRIEND_TEST_ALL_PREFIXES(RenderTextTest, OriginForSkiaDrawing);
// Return an index belonging to the |next| or previous logical grapheme.
// If |next| is false and |IsCursorablePosition(index)| is true, the result
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 40f872b..bc35d6a 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -883,4 +883,35 @@ TEST_F(RenderTextTest, StringWidthTest) {
#endif
+TEST_F(RenderTextTest, OriginForSkiaDrawing) {
+ scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
+ render_text->SetText(ASCIIToUTF16("abcdefg"));
+ render_text->SetFontList(FontList("Arial, 13px"));
+
+ // Set display area's height equals to font height.
+ int font_height = render_text->GetFont().GetHeight();
+ Rect display_rect(0, 0, 100, font_height);
+ render_text->SetDisplayRect(display_rect);
+
+ Point origin = render_text->GetOriginForSkiaDrawing();
+ EXPECT_EQ(origin.x(), 0);
+ EXPECT_EQ(origin.y(), 13);
+
+ // Set display area's height greater than font height.
+ display_rect = Rect(0, 0, 100, font_height + 2);
+ render_text->SetDisplayRect(display_rect);
+
+ origin = render_text->GetOriginForSkiaDrawing();
+ EXPECT_EQ(origin.x(), 0);
+ EXPECT_EQ(origin.y(), 14);
+
+ // Set display area's height less than font height.
+ display_rect = Rect(0, 0, 100, font_height - 2);
+ render_text->SetDisplayRect(display_rect);
+
+ origin = render_text->GetOriginForSkiaDrawing();
+ EXPECT_EQ(origin.x(), 0);
+ EXPECT_EQ(origin.y(), 12);
+}
+
} // namespace gfx