summaryrefslogtreecommitdiffstats
path: root/chrome/views/tree_view.cc
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 00:34:06 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 00:34:06 +0000
commit55cc33475ae6c10cd0c29b77ff9f322f70e5b507 (patch)
treef9704e89f5fbd3395deafb0d9b60a6677be366d8 /chrome/views/tree_view.cc
parentd2a7d0aabc8cc354b72a2f699cd736a950a80d71 (diff)
downloadchromium_src-55cc33475ae6c10cd0c29b77ff9f322f70e5b507.zip
chromium_src-55cc33475ae6c10cd0c29b77ff9f322f70e5b507.tar.gz
chromium_src-55cc33475ae6c10cd0c29b77ff9f322f70e5b507.tar.bz2
Fixes trees on Hebrew locales. The current code was problematic
because SetWorldTransform and a graphics mode of COMPATIBLE don't work together. Instead we must use SetViewportOrgEx. BUG=4515 TEST=see bug Review URL: http://codereview.chromium.org/11253 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/tree_view.cc')
-rw-r--r--chrome/views/tree_view.cc28
1 files changed, 26 insertions, 2 deletions
diff --git a/chrome/views/tree_view.cc b/chrome/views/tree_view.cc
index 2a11c85..0410ecc 100644
--- a/chrome/views/tree_view.cc
+++ b/chrome/views/tree_view.cc
@@ -642,16 +642,40 @@ LRESULT CALLBACK TreeView::TreeWndProc(HWND window,
if (canvas.isEmpty())
return 0;
- HDC dc = canvas.beginPlatformPaint();
+ HDC dc = canvas.beginPlatformPaint();
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
// ChromeCanvas ends up configuring the DC with a mode of GM_ADVANCED.
// For some reason a graphics mode of ADVANCED triggers all the text
// to be mirrored when RTL. Set the mode back to COMPATIBLE and
- // explicitly set the layout.
+ // explicitly set the layout. Additionally SetWorldTransform and
+ // COMPATIBLE don't play nicely together. We need to use
+ // SetViewportOrgEx when using a mode of COMPATIBLE.
+ //
+ // Reset the transform to the identify transform. Even though
+ // SetWorldTransform and COMPATIBLE don't play nicely, bits of the
+ // transform still carry over when we set the mode.
+ XFORM xform = {0};
+ xform.eM11 = xform.eM22 = 1;
+ SetWorldTransform(dc, &xform);
+
+ // Set the mode and layout.
SetGraphicsMode(dc, GM_COMPATIBLE);
SetLayout(dc, LAYOUT_RTL);
+
+ // Transform the viewport such that the origin of the dc is that of
+ // the dirty region. This way when we invoke WM_PRINTCLIENT tree-view
+ // draws the dirty region at the origin of the DC so that when we
+ // copy the bits everything lines up nicely. Without this we end up
+ // copying the upper-left corner to the redraw region.
+ SetViewportOrgEx(dc, -canvas.paintStruct().rcPaint.left,
+ -canvas.paintStruct().rcPaint.top, NULL);
}
SendMessage(window, WM_PRINTCLIENT, reinterpret_cast<WPARAM>(dc), 0);
+ if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
+ // Reset the origin of the dc back to 0. This way when we copy the bits
+ // over we copy the right bits.
+ SetViewportOrgEx(dc, 0, 0, NULL);
+ }
canvas.endPlatformPaint();
return 0;
}