Avoid unnecessary work in |RenderTextWin::UpdateLayout()| if there are no runs.

Avoids calling unnecessary Uniscribe functions until there's text to process.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/8515012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109723 0039d316-1c4b-4281-b951-d872f2087c98
parent 87cee897
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/win/scoped_hdc.h"
#include "third_party/skia/include/core/SkTypeface.h" #include "third_party/skia/include/core/SkTypeface.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_skia.h" #include "ui/gfx/canvas_skia.h"
...@@ -316,9 +317,8 @@ bool RenderTextWin::IsCursorablePosition(size_t position) { ...@@ -316,9 +317,8 @@ bool RenderTextWin::IsCursorablePosition(size_t position) {
void RenderTextWin::UpdateLayout() { void RenderTextWin::UpdateLayout() {
// TODO(msw): Skip complex processing if ScriptIsComplex returns false. // TODO(msw): Skip complex processing if ScriptIsComplex returns false.
ItemizeLogicalText(); ItemizeLogicalText();
HDC hdc = CreateCompatibleDC(NULL); if (!runs_.empty())
LayoutVisualText(hdc); LayoutVisualText();
DeleteDC(hdc);
} }
size_t RenderTextWin::IndexOfAdjacentGrapheme(size_t index, bool next) { size_t RenderTextWin::IndexOfAdjacentGrapheme(size_t index, bool next) {
...@@ -398,8 +398,9 @@ void RenderTextWin::ItemizeLogicalText() { ...@@ -398,8 +398,9 @@ void RenderTextWin::ItemizeLogicalText() {
} }
} }
void RenderTextWin::LayoutVisualText(HDC hdc) { void RenderTextWin::LayoutVisualText() {
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
base::win::ScopedCreateDC hdc(CreateCompatibleDC(NULL));
std::vector<internal::TextRun*>::const_iterator run_iter; std::vector<internal::TextRun*>::const_iterator run_iter;
for (run_iter = runs_.begin(); run_iter < runs_.end(); ++run_iter) { for (run_iter = runs_.begin(); run_iter < runs_.end(); ++run_iter) {
internal::TextRun* run = *run_iter; internal::TextRun* run = *run_iter;
......
...@@ -79,7 +79,7 @@ class RenderTextWin : public RenderText { ...@@ -79,7 +79,7 @@ class RenderTextWin : public RenderText {
virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE; virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE;
void ItemizeLogicalText(); void ItemizeLogicalText();
void LayoutVisualText(HDC hdc); void LayoutVisualText();
// 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.
......
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