summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-12 04:14:36 +0000
committerckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-12 04:14:36 +0000
commit816d8e51ddf1958992b85a58da838ad9de03bc59 (patch)
tree2c701d60bda6af2adedcfe4ff306a0b4391afea0 /ui/gfx
parent70c8735c9b743e54274ac7557320e6d9a5948960 (diff)
downloadchromium_src-816d8e51ddf1958992b85a58da838ad9de03bc59.zip
chromium_src-816d8e51ddf1958992b85a58da838ad9de03bc59.tar.gz
chromium_src-816d8e51ddf1958992b85a58da838ad9de03bc59.tar.bz2
Temporarily revert r221850 to get a tighter range on XP perf bots
BUG=287816 Review URL: https://codereview.chromium.org/26663003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/render_text_unittest.cc22
-rw-r--r--ui/gfx/render_text_win.cc39
-rw-r--r--ui/gfx/render_text_win.h1
3 files changed, 7 insertions, 55 deletions
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index d482407..1cc81de 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -1734,26 +1734,4 @@ TEST_F(RenderTextTest, Multiline_SufficientWidth) {
}
#endif // defined(OS_WIN)
-#if defined(OS_WIN)
-TEST_F(RenderTextTest, Win_BreakRunsByUnicodeBlocks) {
- scoped_ptr<RenderTextWin> render_text(
- static_cast<RenderTextWin*>(RenderText::CreateInstance()));
-
- render_text->SetText(WideToUTF16(L"x\x25B6y"));
- render_text->EnsureLayout();
- ASSERT_EQ(3U, render_text->runs_.size());
- EXPECT_EQ(Range(0, 1), render_text->runs_[0]->range);
- EXPECT_EQ(Range(1, 2), render_text->runs_[1]->range);
- EXPECT_EQ(Range(2, 3), render_text->runs_[2]->range);
-
- render_text->SetText(WideToUTF16(L"x \x25B6 y"));
- render_text->EnsureLayout();
- ASSERT_EQ(3U, render_text->runs_.size());
- EXPECT_EQ(Range(0, 2), render_text->runs_[0]->range);
- EXPECT_EQ(Range(2, 3), render_text->runs_[1]->range);
- EXPECT_EQ(Range(3, 5), render_text->runs_[2]->range);
-
-}
-#endif // !defined(OS_WIN)
-
} // namespace gfx
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc
index e283de3..dfcff0e 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -7,7 +7,6 @@
#include <algorithm>
#include "base/i18n/break_iterator.h"
-#include "base/i18n/char_iterator.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
@@ -860,14 +859,13 @@ void RenderTextWin::ItemizeLogicalText() {
script_state_.uBidiLevel =
(GetTextDirection() == base::i18n::RIGHT_TO_LEFT) ? 1 : 0;
- const base::string16& layout_text = GetLayoutText();
- if (layout_text.empty())
+ if (text().empty())
return;
HRESULT hr = E_OUTOFMEMORY;
int script_items_count = 0;
std::vector<SCRIPT_ITEM> script_items;
- const size_t layout_text_length = layout_text.length();
+ const size_t layout_text_length = GetLayoutText().length();
// Ensure that |kMaxRuns| is attempted and the loop terminates afterward.
for (size_t runs = kGuessRuns; hr == E_OUTOFMEMORY && runs <= kMaxRuns;
runs = std::max(runs + 1, std::min(runs * 2, kMaxRuns))) {
@@ -875,9 +873,9 @@ void RenderTextWin::ItemizeLogicalText() {
// ScriptItemize always adds a terminal array item so that the length of
// the last item can be derived from the terminal SCRIPT_ITEM::iCharPos.
script_items.resize(runs);
- hr = ScriptItemize(layout_text.c_str(), layout_text_length, runs - 1,
- &script_control_, &script_state_, &script_items[0],
- &script_items_count);
+ hr = ScriptItemize(GetLayoutText().c_str(), layout_text_length,
+ runs - 1, &script_control_, &script_state_,
+ &script_items[0], &script_items_count);
}
DCHECK(SUCCEEDED(hr));
if (!SUCCEEDED(hr) || script_items_count <= 0)
@@ -889,7 +887,7 @@ void RenderTextWin::ItemizeLogicalText() {
// Build the list of runs from the script items and ranged styles. Use an
// empty color BreakList to avoid breaking runs at color boundaries.
BreakList<SkColor> empty_colors;
- empty_colors.SetMax(layout_text_length);
+ empty_colors.SetMax(text().length());
internal::StyleIterator style(empty_colors, styles());
SCRIPT_ITEM* script_item = &script_items[0];
const size_t max_run_length = kMaxGlyphs / 2;
@@ -910,32 +908,9 @@ void RenderTextWin::ItemizeLogicalText() {
const size_t script_item_break = (script_item + 1)->iCharPos;
run_break = std::min(script_item_break,
TextIndexToLayoutIndex(style.GetRange().end()));
-
// Clamp run lengths to avoid exceeding the maximum supported glyph count.
- if ((run_break - run->range.start()) > max_run_length) {
+ if ((run_break - run->range.start()) > max_run_length)
run_break = run->range.start() + max_run_length;
- if (!gfx::IsValidCodePointIndex(layout_text, run_break))
- --run_break;
- }
-
- // Break runs between characters in different code blocks. This avoids using
- // fallback fonts for more characters than needed. http://crbug.com/278913
- if (run_break > run->range.start()) {
- const size_t run_start = run->range.start();
- const int32 run_length = static_cast<int32>(run_break - run_start);
- base::i18n::UTF16CharIterator iter(layout_text.c_str() + run_start,
- run_length);
- const UBlockCode first_block_code = ublock_getCode(iter.get());
- while (iter.Advance() && iter.array_pos() < run_length) {
- if (ublock_getCode(iter.get()) != first_block_code) {
- run_break = run_start + iter.array_pos();
- break;
- }
- }
- }
-
- DCHECK(gfx::IsValidCodePointIndex(layout_text, run_break));
-
style.UpdatePosition(LayoutIndexToTextIndex(run_break));
if (script_item_break == run_break)
script_item++;
diff --git a/ui/gfx/render_text_win.h b/ui/gfx/render_text_win.h
index 423e31f..6aca235 100644
--- a/ui/gfx/render_text_win.h
+++ b/ui/gfx/render_text_win.h
@@ -86,7 +86,6 @@ class RenderTextWin : public RenderText {
virtual void DrawVisualText(Canvas* canvas) OVERRIDE;
private:
- FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_BreakRunsByUnicodeBlocks);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_MinWidth);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_NormalWidth);