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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2694 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width()); | 2694 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width()); |
2695 | 2695 |
2696 render_text->Draw(canvas.get()); | 2696 render_text->Draw(canvas.get()); |
2697 ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width()); | 2697 ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width()); |
2698 const uint32* buffer = | 2698 const uint32* buffer = |
2699 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr)); | 2699 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr)); |
2700 ASSERT_NE(nullptr, buffer); | 2700 ASSERT_NE(nullptr, buffer); |
2701 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(), | 2701 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(), |
2702 kCanvasSize.height()); | 2702 kCanvasSize.height()); |
2703 { | 2703 { |
2704 #if !defined(OS_CHROMEOS) | |
2705 // TODO(mukai): On ChromeOS text draws above the GetStringSize rect. | |
Jun Mukai
2015/03/07 02:19:02
Please do not do like this. Excluding specific pla
| |
2704 SCOPED_TRACE("TextDoesntClip Top Side"); | 2706 SCOPED_TRACE("TextDoesntClip Top Side"); |
2705 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, 0, kCanvasSize.width(), | 2707 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, 0, kCanvasSize.width(), |
2706 kTestSize); | 2708 kTestSize); |
2709 #endif | |
2707 } | 2710 } |
2708 { | 2711 { |
2709 SCOPED_TRACE("TextDoesntClip Bottom Side"); | 2712 SCOPED_TRACE("TextDoesntClip Bottom Side"); |
2710 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, | 2713 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, |
2711 kTestSize + string_size.height(), | 2714 kTestSize + string_size.height(), |
2712 kCanvasSize.width(), kTestSize); | 2715 kCanvasSize.width(), kTestSize); |
2713 } | 2716 } |
2714 { | 2717 { |
2715 SCOPED_TRACE("TextDoesntClip Left Side"); | 2718 SCOPED_TRACE("TextDoesntClip Left Side"); |
2716 #if defined(OS_WIN) || defined(OS_MACOSX) | 2719 #if defined(OS_WIN) |
2717 // TODO(mukai): On Windows and Mac smoothing draws left of text. | 2720 // TODO(mukai): On Windows XP the Unicode test draws to the left edge as |
2721 // if it is ignoring the SetDisplayRect shift by kTestSize. | |
Jun Mukai
2015/03/07 02:19:02
Why not just #if defined(OS_MACOSX) ?
| |
2722 #elif defined(OS_MACOSX) | |
2723 // TODO(mukai): On Windows (non-XP) and Mac smoothing draws left of text. | |
2718 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize, kTestSize - 1, | 2724 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize, kTestSize - 1, |
2719 string_size.height()); | 2725 string_size.height()); |
2720 #else | 2726 #else |
2721 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize, kTestSize, | 2727 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize, kTestSize, |
2722 string_size.height()); | 2728 string_size.height()); |
2723 #endif | 2729 #endif |
2724 } | 2730 } |
2725 { | 2731 { |
2726 SCOPED_TRACE("TextDoesntClip Right Side"); | 2732 SCOPED_TRACE("TextDoesntClip Right Side"); |
2727 #if !defined(OS_MACOSX) | 2733 #if !defined(OS_MACOSX) |
2728 // TODO(mukai): On Mac text draws to right of GetStringSize | 2734 // TODO(mukai): On Mac text draws to right of GetStringSize. |
2729 rect_buffer.EnsureSolidRect(SK_ColorWHITE, | 2735 rect_buffer.EnsureSolidRect(SK_ColorWHITE, |
2730 kTestSize + string_size.width(), kTestSize, | 2736 kTestSize + string_size.width(), kTestSize, |
2731 kTestSize, string_size.height()); | 2737 kTestSize, string_size.height()); |
2732 #endif | 2738 #endif |
2733 } | 2739 } |
2734 } | 2740 } |
2735 } | 2741 } |
2736 | 2742 |
2737 // Ensure that the text will clip to the display rect. Draws to a canvas and | 2743 // Ensure that the text will clip to the display rect. Draws to a canvas and |
2738 // checks whether any pixel beyond the bounding rectangle is colored. | 2744 // checks whether any pixel beyond the bounding rectangle is colored. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2783 } | 2789 } |
2784 { | 2790 { |
2785 SCOPED_TRACE("TextDoesClip Right Side"); | 2791 SCOPED_TRACE("TextDoesClip Right Side"); |
2786 rect_buffer.EnsureSolidRect(SK_ColorWHITE, kTestSize + fake_width, | 2792 rect_buffer.EnsureSolidRect(SK_ColorWHITE, kTestSize + fake_width, |
2787 kTestSize, kTestSize, fake_height); | 2793 kTestSize, kTestSize, fake_height); |
2788 } | 2794 } |
2789 } | 2795 } |
2790 } | 2796 } |
2791 | 2797 |
2792 } // namespace gfx | 2798 } // namespace gfx |
OLD | NEW |