Changeset 84154 in webkit


Ignore:
Timestamp:
Apr 18, 2011 10:08:45 AM (13 years ago)
Author:
Patrick Gansterer
Message:

2011-04-18 Patrick Gansterer <Patrick Gansterer>

Reviewed by Adam Roben.

[WIN] Use WCHAR instead of TCHAR
https://bugs.webkit.org/show_bug.cgi?id=58755

We always use the UNICODE versions of windows functions, so
the usage of TCHAR makes no sense and mixing them is bad style.

  • WinLauncher/PrintWebUIDelegate.cpp: Also fix various style issues (including indentation and removal of ugly C-casts).
  • WinLauncher/WinLauncher.cpp:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r84139 r84154  
     12011-04-18  Patrick Gansterer  <paroga@webkit.org>
     2
     3        Reviewed by Adam Roben.
     4
     5        [WIN] Use WCHAR instead of TCHAR
     6        https://bugs.webkit.org/show_bug.cgi?id=58755
     7
     8        We always use the UNICODE versions of windows functions, so
     9        the usage of TCHAR makes no sense and mixing them is bad style.
     10
     11        * WinLauncher/PrintWebUIDelegate.cpp:
     12          Also fix various style issues (including indentation and removal of ugly C-casts).
     13        * WinLauncher/WinLauncher.cpp:
     14
    1152011-04-18  Dominic Cooney  <dominicc@chromium.org>
    216
  • trunk/Tools/WinLauncher/PrintWebUIDelegate.cpp

    r53154 r84154  
    2828#include "PrintWebUIDelegate.h"
    2929
     30#include <WebKit/WebKitCOMAPI.h>
    3031#include <commctrl.h>
    3132#include <commdlg.h>
     
    3334#include <shlwapi.h>
    3435#include <wininet.h>
    35 
    36 #include <WebKit/WebKitCOMAPI.h>
    3736
    3837static const int MARGIN = 20;
     
    9897HRESULT PrintWebUIDelegate::webViewHeaderHeight(IWebView* webView, float* height)
    9998{
    100    if (!webView || !height)
    101       return E_POINTER;
    102    
    103    HDC dc = ::GetDC(0);
     99    if (!webView || !height)
     100        return E_POINTER;
    104101
    105    TEXTMETRIC textMetric;
    106    ::GetTextMetrics(dc, &textMetric);
    107    ::ReleaseDC(0, dc);
     102    HDC dc = ::GetDC(0);
    108103
    109    *height = 1.1 * textMetric.tmHeight;
     104    TEXTMETRIC textMetric;
     105    ::GetTextMetrics(dc, &textMetric);
     106    ::ReleaseDC(0, dc);
    110107
    111    return S_OK;
     108    *height = 1.1 * textMetric.tmHeight;
     109
     110    return S_OK;
    112111}
    113112
    114113HRESULT PrintWebUIDelegate::webViewFooterHeight(IWebView* webView, float* height)
    115114{
    116    if (!webView || !height)
    117       return E_POINTER;
     115    if (!webView || !height)
     116        return E_POINTER;
    118117
    119    HDC dc = ::GetDC(0);
     118    HDC dc = ::GetDC(0);
    120119
    121    TEXTMETRIC textMetric;
    122    ::GetTextMetrics(dc, &textMetric);
    123    ::ReleaseDC(0, dc);
     120    TEXTMETRIC textMetric;
     121    ::GetTextMetrics(dc, &textMetric);
     122    ::ReleaseDC(0, dc);
    124123
    125    *height = 1.1 * textMetric.tmHeight;
     124    *height = 1.1 * textMetric.tmHeight;
    126125
    127    return S_OK;
     126    return S_OK;
    128127}
    129128
    130 HRESULT PrintWebUIDelegate::drawHeaderInRect( 
    131             /* [in] */ IWebView *webView,
    132             /* [in] */ RECT *rect,
     129HRESULT PrintWebUIDelegate::drawHeaderInRect(
     130            /* [in] */ IWebView* webView,
     131            /* [in] */ RECT* rect,
    133132            /* [in] */ OLE_HANDLE drawingContext)
    134133{
    135    if (!webView || !rect)
    136       return E_POINTER;
     134    if (!webView || !rect)
     135        return E_POINTER;
    137136
    138    // Turn off header for now.
    139    HDC dc = reinterpret_cast<HDC>(drawingContext);
     137    // Turn off header for now.
     138    HDC dc = reinterpret_cast<HDC>(drawingContext);
    140139
    141    HFONT hFont = (HFONT)::GetStockObject(ANSI_VAR_FONT);
    142    HFONT hOldFont = (HFONT)::SelectObject(dc, hFont);
     140    HGDIOBJ hFont = ::GetStockObject(ANSI_VAR_FONT);
     141    HGDIOBJ hOldFont = ::SelectObject(dc, hFont);
    143142
    144    LPCTSTR header(_T("[Sample Header]"));
    145    int length = _tcslen(header);
     143    LPCWSTR header = L"[Sample Header]";
     144    size_t length = wcslen(header);
    146145
    147    int rc = ::DrawText(dc, header, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER | DT_SINGLELINE);
    148    ::SelectObject(dc, hOldFont);
     146    int rc = ::DrawTextW(dc, header, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER | DT_SINGLELINE);
     147    ::SelectObject(dc, hOldFont);
    149148
    150    if (!rc)
    151       return E_FAIL;
     149    if (!rc)
     150        return E_FAIL;
    152151
    153    ::MoveToEx(dc, rect->left, rect->bottom, 0);
    154    HPEN hPen = (HPEN)::GetStockObject(BLACK_PEN);
    155    HPEN hOldPen = (HPEN)::SelectObject(dc, hPen);
    156    ::LineTo(dc, rect->right, rect->bottom);
    157    ::SelectObject(dc, hOldPen);
     152    ::MoveToEx(dc, rect->left, rect->bottom, 0);
     153    HGDIOBJ hPen = ::GetStockObject(BLACK_PEN);
     154    HGDIOBJ hOldPen = ::SelectObject(dc, hPen);
     155    ::LineTo(dc, rect->right, rect->bottom);
     156    ::SelectObject(dc, hOldPen);
    158157
    159    return S_OK;
     158    return S_OK;
    160159}
    161160
    162 HRESULT PrintWebUIDelegate::drawFooterInRect( 
    163             /* [in] */ IWebView *webView,
    164             /* [in] */ RECT *rect,
     161HRESULT PrintWebUIDelegate::drawFooterInRect(
     162            /* [in] */ IWebView* webView,
     163            /* [in] */ RECT* rect,
    165164            /* [in] */ OLE_HANDLE drawingContext,
    166165            /* [in] */ UINT pageIndex,
    167166            /* [in] */ UINT pageCount)
    168167{
    169    if (!webView || !rect)
    170       return E_POINTER;
     168    if (!webView || !rect)
     169        return E_POINTER;
    171170
    172    HDC dc = reinterpret_cast<HDC>(drawingContext);
     171    HDC dc = reinterpret_cast<HDC>(drawingContext);
    173172
    174    HFONT hFont = (HFONT)::GetStockObject(ANSI_VAR_FONT);
    175    HFONT hOldFont = (HFONT)::SelectObject(dc, hFont);
     173    HGDIOBJ hFont = ::GetStockObject(ANSI_VAR_FONT);
     174    HGDIOBJ hOldFont = ::SelectObject(dc, hFont);
    176175
    177    LPCTSTR footer(_T("[Sample Footer]"));
    178    int length = _tcslen(footer);
     176    LPCWSTR footer = L"[Sample Footer]";
     177    size_t length = wcslen(footer);
    179178
    180    // Add a line, 1/10th inch above the footer text from left margin to right margin.
    181    ::MoveToEx(dc, rect->left, rect->top, 0);
    182    HPEN hPen = (HPEN)::GetStockObject(BLACK_PEN);
    183    HPEN hOldPen = (HPEN)::SelectObject(dc, hPen);
    184    ::LineTo(dc, rect->right, rect->top);
    185    ::SelectObject(dc, hOldPen);
     179    // Add a line, 1/10th inch above the footer text from left margin to right margin.
     180    ::MoveToEx(dc, rect->left, rect->top, 0);
     181    HGDIOBJ hPen = ::GetStockObject(BLACK_PEN);
     182    HGDIOBJ hOldPen = ::SelectObject(dc, hPen);
     183    ::LineTo(dc, rect->right, rect->top);
     184    ::SelectObject(dc, hOldPen);
    186185
    187    int rc = ::DrawText(dc, footer, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER | DT_SINGLELINE);
    188    ::SelectObject(dc, hOldFont);
     186    int rc = ::DrawTextW(dc, footer, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER | DT_SINGLELINE);
     187    ::SelectObject(dc, hOldFont);
    189188
    190    if (!rc)
    191       return E_FAIL;
     189    if (!rc)
     190        return E_FAIL;
    192191
    193    return S_OK;
     192    return S_OK;
    194193}
  • trunk/Tools/WinLauncher/WinLauncher.cpp

    r72258 r84154  
    328328    HDC printDC = getPrinterDC();
    329329    if (!printDC) {
    330         ::MessageBox(0, _T("Error creating printing DC"), _T("Error"), MB_APPLMODAL | MB_OK);
     330        ::MessageBoxW(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK);
    331331        return;
    332332    }
    333333
    334334    if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) {
    335         ::MessageBox(0, _T("Error setting up AbortProc"), _T("Error"), MB_APPLMODAL | MB_OK);
     335        ::MessageBoxW(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK);
    336336        return;
    337337    }
     
    351351
    352352    DOCINFO di;
    353     initDocStruct(&di, _T("WebKit Doc"));
     353    initDocStruct(&di, L"WebKit Doc");
    354354    ::StartDoc(printDC, &di);
    355355
Note: See TracChangeset for help on using the changeset viewer.