Changeset 155454 in webkit


Ignore:
Timestamp:
Sep 10, 2013 10:37:27 AM (11 years ago)
Author:
Brent Fulgham
Message:

Source/WebCore: [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject template.
https://bugs.webkit.org/show_bug.cgi?id=120778

Reviewed by Anders Carlsson.

Change code to use a GDI-specific smart pointer, rather than OwnPtr. This
is a first step to simplifying OwnPtr. It also gets rid of some Windows-
specific code in WTF.

  • WebCore.vcxproj/WebCore.vcxproj: Add the new header file.
  • WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
  • page/win/FrameCGWin.cpp:

(WebCore::imageFromRect): Switch to GDIObject.

  • page/win/FrameCairoWin.cpp:

(WebCore::imageFromRect): Switch to GDIObject.

  • page/win/FrameWin.cpp:

(WebCore::imageFromSelection): Switch to GDIObject.
(WebCore::Frame::dragImageForSelection): Ditto.
(WebCore::Frame::nodeImage): Ditto.

  • page/win/FrameWin.h:
  • platform/graphics/ca/win/CACFLayerTreeHost.cpp:

(WebCore::getDirtyRects): Switch from OwnPtr to GDIObject.

  • platform/graphics/win/FontCacheWin.cpp:

(WebCore::createGDIFont): Switch to GDIObject.
(WebCore::FontCache::createFontPlatformData): Ditto.

  • platform/graphics/win/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData): Switch to GDIObject.

  • platform/graphics/win/FontCustomPlatformDataCairo.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData): Switch to GDIObject.

  • platform/graphics/win/GraphicsContextCGWin.cpp:

(WebCore::GraphicsContext::releaseWindowsContext): Switch to GDIObject.

  • platform/graphics/win/GraphicsContextCairoWin.cpp:

(WebCore::GraphicsContext::releaseWindowsContext): Switch to GDIObject.

  • platform/graphics/win/GraphicsContextWin.cpp:

(WebCore::GraphicsContext::getWindowsContext): Switch to GDIObject.

  • platform/graphics/win/SimpleFontDataWin.cpp:

(WebCore::SimpleFontData::platformCreateScaledFontData): Switch to GDIObject.

  • platform/win/CursorWin.cpp:

(WebCore::createSharedCursor): Switch to GDIObject.

  • platform/win/DragImageCGWin.cpp:

(WebCore::scaleDragImage): Switch to GDIObject.
(WebCore::createDragImageFromImage):

  • platform/win/DragImageCairoWin.cpp:

(WebCore::scaleDragImage): Switch to GDIObject.
(WebCore::createDragImageFromImage): Ditto.

  • platform/win/DragImageWin.cpp:

(WebCore::createDragImageForLink): Switch to GDIObject.

  • platform/win/PasteboardWin.cpp:

(WebCore::Pasteboard::writeImage): Switch to GDIObject.

  • platform/win/ScrollbarThemeWin.cpp:

(WebCore::ScrollbarThemeWin::paintTrackPiece): Switch to GDIObject.

  • plugins/win/PluginViewWin.cpp:

(WebCore::PluginView::updatePluginWidget): Switch to GDIObject.
(WebCore::PluginView::snapshot): Ditto.

  • rendering/RenderThemeWin.cpp:

(WebCore::drawControl): Switch to GDIObject.

Source/WebKit/win: [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject template.
https://bugs.webkit.org/show_bug.cgi?id=120778

Reviewed by Anders Carlsson.

  • FullscreenVideoController.cpp:

(FullscreenVideoController::createHUDWindow): Switch to GDIObject.
(FullscreenVideoController::draw): Ditto.

  • FullscreenVideoController.h:
  • WebCoreSupport/EmbeddedWidget.cpp:

(EmbeddedWidget::frameRectsChanged): Switch to GDIObject.

  • WebNodeHighlight.cpp:

(WebNodeHighlight::update): Switch to GDIObject.

  • WebView.cpp:

(WebView::scrollBackingStore): Switch to GDIObject.
(WebView::updateBackingStore): Ditto.
(WebView::performLayeredWindowUpdate): Ditto.
(WebView::paint): Ditto.
(WebView::paintIntoBackingStore): Ditto.
(WebView::paintIntoWindow): Ditto.
(WebView::generateSelectionImage): Ditto.

Source/WTF: [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject template.
https://bugs.webkit.org/show_bug.cgi?id=120778

Reviewed by Anders Carlsson.

  • WTF.vcxproj/WTF.vcxproj: Add new GDIObject header file.
  • WTF.vcxproj/WTF.vcxproj.filters: Ditto.
  • WTF.vcxproj/copy-files.cmd: Copy new header file.
  • wtf/OwnPtrCommon.h: Remove some GDI specializations.
  • wtf/win/GDIObject.h: Added.

(WTF::GDIObject::GDIObject):
(WTF::GDIObject::~GDIObject):
(WTF::GDIObject::get):
(WTF::GDIObject::operator!):
(WTF::GDIObject::operator UnspecifiedBoolType):
(WTF::GDIObject::operator=):
(WTF::GDIObject::swap):
(WTF::::clear):
(WTF::::leak):
(WTF::::GDIObject):
(WTF::=):
(WTF::adoptGDIObject):
(WTF::swap):
(WTF::T):
(WTF::HDC):

  • wtf/win/OwnPtrWin.cpp:

(WTF::deleteOwnedPtr): Remove some GDI specializations.

Tools: [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject.
https://bugs.webkit.org/show_bug.cgi?id=120778

Reviewed by Anders Carlsson.

  • DumpRenderTree/win/PixelDumpSupportWin.cpp:

(createBitmapContextFromWebView): Use GDIObject.

  • Scripts/webkitpy/style/checkers/cpp.py:

(check_for_leaky_patterns): Update for GDIObject instead of adoptPtr and OwnPtr.

  • Scripts/webkitpy/style/checkers/cpp_unittest.py:

(LeakyPatternTest.test_create_dc): Update for GDIObject instead of adoptPtr/OwnPtr.
(LeakyPatternTest.test_create_compatible_dc): Ditto.

Location:
trunk
Files:
1 added
39 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r155407 r155454  
     12013-09-09  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject template.
     4        https://bugs.webkit.org/show_bug.cgi?id=120778
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WTF.vcxproj/WTF.vcxproj: Add new GDIObject header file.
     9        * WTF.vcxproj/WTF.vcxproj.filters: Ditto.
     10        * WTF.vcxproj/copy-files.cmd: Copy new header file.
     11        * wtf/OwnPtrCommon.h: Remove some GDI specializations.
     12        * wtf/win/GDIObject.h: Added.
     13        (WTF::GDIObject::GDIObject):
     14        (WTF::GDIObject::~GDIObject):
     15        (WTF::GDIObject::get):
     16        (WTF::GDIObject::operator!):
     17        (WTF::GDIObject::operator UnspecifiedBoolType):
     18        (WTF::GDIObject::operator=):
     19        (WTF::GDIObject::swap):
     20        (WTF::::clear):
     21        (WTF::::leak):
     22        (WTF::::GDIObject):
     23        (WTF::=):
     24        (WTF::adoptGDIObject):
     25        (WTF::swap):
     26        (WTF::T):
     27        (WTF::HDC):
     28        * wtf/win/OwnPtrWin.cpp:
     29        (WTF::deleteOwnedPtr): Remove some GDI specializations.
     30
    1312013-09-09  Anders Carlsson  <andersca@apple.com>
    232
  • trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj

    r155402 r155454  
    270270    <ClInclude Include="..\wtf\Vector.h" />
    271271    <ClInclude Include="..\wtf\VMTags.h" />
     272    <ClInclude Include="..\wtf\win\GDIObject.h" />
    272273    <ClInclude Include="..\wtf\WTFThreadData.h" />
    273274  </ItemGroup>
  • trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters

    r155402 r155454  
    492492      <Filter>wtf</Filter>
    493493    </ClInclude>
    494     <ClInclude Include="..\wtf\Ref.h">
    495       <Filter>wtf</Filter>
    496     </ClInclude>
    497494    <ClInclude Include="..\wtf\Noncopyable.h">
    498495      <Filter>wtf</Filter>
     
    681678    <ClInclude Include="..\wtf\DeferrableRefCounted.h">
    682679      <Filter>wtf</Filter>
     680    </ClInclude>
     681    <ClInclude Include="..\wtf\win\GDIObject.h">
     682      <Filter>win</Filter>
    683683    </ClInclude>
    684684  </ItemGroup>
  • trunk/Source/WTF/WTF.vcxproj/copy-files.cmd

    r152381 r155454  
    1616    wtf\unicode
    1717    wtf\unicode\icu
     18    wtf\win
    1819) do (
    1920    mkdir "%PrivateHeadersDirectory%\%%d" 2>NUL
  • trunk/Source/WTF/wtf/OwnPtrCommon.h

    r142454 r155454  
    3131#if OS(WINDOWS)
    3232typedef struct HBITMAP__* HBITMAP;
    33 typedef struct HBRUSH__* HBRUSH;
    3433typedef struct HDC__* HDC;
    35 typedef struct HFONT__* HFONT;
    36 typedef struct HPALETTE__* HPALETTE;
    37 typedef struct HPEN__* HPEN;
    3834typedef struct HRGN__* HRGN;
    3935#endif
     
    6662#if OS(WINDOWS)
    6763    WTF_EXPORT_PRIVATE void deleteOwnedPtr(HBITMAP);
    68     WTF_EXPORT_PRIVATE void deleteOwnedPtr(HBRUSH);
    6964    WTF_EXPORT_PRIVATE void deleteOwnedPtr(HDC);
    70     WTF_EXPORT_PRIVATE void deleteOwnedPtr(HFONT);
    71     WTF_EXPORT_PRIVATE void deleteOwnedPtr(HPALETTE);
    72     WTF_EXPORT_PRIVATE void deleteOwnedPtr(HPEN);
    7365    WTF_EXPORT_PRIVATE void deleteOwnedPtr(HRGN);
    7466#endif
  • trunk/Source/WTF/wtf/win/OwnPtrWin.cpp

    r139974 r155454  
    4040}
    4141
    42 void deleteOwnedPtr(HBRUSH ptr)
    43 {
    44     if (ptr)
    45         DeleteObject(ptr);
    46 }
    47 
    4842void deleteOwnedPtr(HDC ptr)
    4943{
    5044    if (ptr)
    5145        DeleteDC(ptr);
    52 }
    53 
    54 void deleteOwnedPtr(HFONT ptr)
    55 {
    56     if (ptr)
    57         DeleteObject(ptr);
    58 }
    59 
    60 void deleteOwnedPtr(HPALETTE ptr)
    61 {
    62     if (ptr)
    63         DeleteObject(ptr);
    64 }
    65 
    66 void deleteOwnedPtr(HPEN ptr)
    67 {
    68     if (ptr)
    69         DeleteObject(ptr);
    7046}
    7147
  • trunk/Source/WebCore/ChangeLog

    r155447 r155454  
     12013-09-09  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject template.
     4        https://bugs.webkit.org/show_bug.cgi?id=120778
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Change code to use a GDI-specific smart pointer, rather than OwnPtr. This
     9        is a first step to simplifying OwnPtr. It also gets rid of some Windows-
     10        specific code in WTF.
     11
     12        * WebCore.vcxproj/WebCore.vcxproj: Add the new header file.
     13        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
     14        * page/win/FrameCGWin.cpp:
     15        (WebCore::imageFromRect): Switch to GDIObject.
     16        * page/win/FrameCairoWin.cpp:
     17        (WebCore::imageFromRect): Switch to GDIObject.
     18        * page/win/FrameWin.cpp:
     19        (WebCore::imageFromSelection): Switch to GDIObject.
     20        (WebCore::Frame::dragImageForSelection): Ditto.
     21        (WebCore::Frame::nodeImage): Ditto.
     22        * page/win/FrameWin.h:
     23        * platform/graphics/ca/win/CACFLayerTreeHost.cpp:
     24        (WebCore::getDirtyRects): Switch from OwnPtr to GDIObject.
     25        * platform/graphics/win/FontCacheWin.cpp:
     26        (WebCore::createGDIFont): Switch to GDIObject.
     27        (WebCore::FontCache::createFontPlatformData): Ditto.
     28        * platform/graphics/win/FontCustomPlatformData.cpp:
     29        (WebCore::FontCustomPlatformData::fontPlatformData): Switch to GDIObject.
     30        * platform/graphics/win/FontCustomPlatformDataCairo.cpp:
     31        (WebCore::FontCustomPlatformData::fontPlatformData): Switch to GDIObject.
     32        * platform/graphics/win/GraphicsContextCGWin.cpp:
     33        (WebCore::GraphicsContext::releaseWindowsContext): Switch to GDIObject.
     34        * platform/graphics/win/GraphicsContextCairoWin.cpp:
     35        (WebCore::GraphicsContext::releaseWindowsContext): Switch to GDIObject.
     36        * platform/graphics/win/GraphicsContextWin.cpp:
     37        (WebCore::GraphicsContext::getWindowsContext): Switch to GDIObject.
     38        * platform/graphics/win/SimpleFontDataWin.cpp:
     39        (WebCore::SimpleFontData::platformCreateScaledFontData): Switch to GDIObject.
     40        * platform/win/CursorWin.cpp:
     41        (WebCore::createSharedCursor): Switch to GDIObject.
     42        * platform/win/DragImageCGWin.cpp:
     43        (WebCore::scaleDragImage): Switch to GDIObject.
     44        (WebCore::createDragImageFromImage):
     45        * platform/win/DragImageCairoWin.cpp:
     46        (WebCore::scaleDragImage): Switch to GDIObject.
     47        (WebCore::createDragImageFromImage): Ditto.
     48        * platform/win/DragImageWin.cpp:
     49        (WebCore::createDragImageForLink): Switch to GDIObject.
     50        * platform/win/PasteboardWin.cpp:
     51        (WebCore::Pasteboard::writeImage): Switch to GDIObject.
     52        * platform/win/ScrollbarThemeWin.cpp:
     53        (WebCore::ScrollbarThemeWin::paintTrackPiece): Switch to GDIObject.
     54        * plugins/win/PluginViewWin.cpp:
     55        (WebCore::PluginView::updatePluginWidget): Switch to GDIObject.
     56        (WebCore::PluginView::snapshot): Ditto.
     57        * rendering/RenderThemeWin.cpp:
     58        (WebCore::drawControl): Switch to GDIObject.
     59
    1602013-09-10  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    261
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r155315 r155454  
    31783178      <Filter>dom</Filter>
    31793179    </ClCompile>
    3180     <ClCompile Include="..\dom\ComposedShadowTreeWalker.cpp">
    3181       <Filter>dom</Filter>
    3182     </ClCompile>
    31833180    <ClCompile Include="..\dom\CompositionEvent.cpp">
    31843181      <Filter>dom</Filter>
     
    1024210239    </ClInclude>
    1024310240    <ClInclude Include="..\dom\Comment.h">
    10244       <Filter>dom</Filter>
    10245     </ClInclude>
    10246     <ClInclude Include="..\dom\ComposedShadowTreeWalker.h">
    1024710241      <Filter>dom</Filter>
    1024810242    </ClInclude>
  • trunk/Source/WebCore/page/win/FrameCGWin.cpp

    r153586 r155454  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636#include <CoreGraphics/CoreGraphics.h>
    3737#include <windows.h>
     38#include <wtf/win/GDIObject.h>
    3839
    3940namespace WebCore {
     
    5051}
    5152
    52 PassOwnPtr<HBITMAP> imageFromRect(const Frame* frame, IntRect& ir)
     53GDIObject<HBITMAP> imageFromRect(const Frame* frame, IntRect& ir)
    5354{
    5455    PaintBehavior oldPaintBehavior = frame->view()->paintBehavior();
     
    5657
    5758    void* bits;
    58     HDC hdc = CreateCompatibleDC(0);
     59    auto hdc = adoptGDIObject(::CreateCompatibleDC(0));
    5960    int w = ir.width();
    6061    int h = ir.height();
    6162    BitmapInfo bmp = BitmapInfo::create(IntSize(w, h));
    6263
    63     OwnPtr<HBITMAP> hbmp = adoptPtr(CreateDIBSection(0, &bmp, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0));
    64     HGDIOBJ hbmpOld = SelectObject(hdc, hbmp.get());
     64    GDIObject<HBITMAP> hbmp = adoptGDIObject(::CreateDIBSection(0, &bmp, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0));
     65    HGDIOBJ hbmpOld = SelectObject(hdc.get(), hbmp.get());
    6566    CGContextRef context = CGBitmapContextCreate(static_cast<void*>(bits), w, h,
    6667        8, w * sizeof(RGBQUAD), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
     
    7273
    7374    CGContextRelease(context);
    74     SelectObject(hdc, hbmpOld);
    75     DeleteDC(hdc);
     75    SelectObject(hdc.get(), hbmpOld);
    7676
    7777    frame->view()->setPaintBehavior(oldPaintBehavior);
    7878
    79     return hbmp.release();
     79    return hbmp;
    8080}
    8181
  • trunk/Source/WebCore/page/win/FrameCairoWin.cpp

    r153586 r155454  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929
    3030#include "NotImplemented.h"
     31#include <wtf/win/GDIObject.h>
    3132
    3233namespace WebCore {
    3334
    34 PassOwnPtr<HBITMAP> imageFromRect(const Frame*, IntRect&)
     35GDIObject<HBITMAP> imageFromRect(const Frame*, IntRect&)
    3536{
    3637    notImplemented();
  • trunk/Source/WebCore/page/win/FrameWin.cpp

    r154286 r155454  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4646}
    4747
    48 PassOwnPtr<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText)
     48GDIObject<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText)
    4949{
    5050    frame->document()->updateLayout();
     
    5353    FloatRect fr = frame->selection().bounds();
    5454    IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()), static_cast<int>(fr.width()), static_cast<int>(fr.height()));
    55     OwnPtr<HBITMAP> image = imageFromRect(frame, ir);
     55    GDIObject<HBITMAP> image = imageFromRect(frame, ir);
    5656    frame->view()->setPaintBehavior(PaintBehaviorNormal);
    57     return image.release();
     57    return image;
    5858}
    5959
     
    6161{
    6262    if (selection().isRange())
    63         return imageFromSelection(this, false).leakPtr();
     63        return imageFromSelection(this, false).leak();
    6464
    6565    return 0;
     
    7878
    7979    m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode
    80     OwnPtr<HBITMAP> result = imageFromRect(this, paintingRect);
     80    GDIObject<HBITMAP> result = imageFromRect(this, paintingRect);
    8181    m_view->setNodeToDraw(0);
    8282
    83     return result.leakPtr();
     83    return result.leak();
    8484}
    8585
  • trunk/Source/WebCore/page/win/FrameWin.h

    r153586 r155454  
    2727#define FrameWin_h
    2828
    29 #include <wtf/PassOwnPtr.h>
    3029#include <wtf/Vector.h>
    31 
    32 // Forward declared so we don't need wingdi.h.
    33 typedef struct HBITMAP__* HBITMAP;
     30#include <wtf/win/GDIObject.h>
    3431
    3532namespace WebCore {
     
    3835class IntRect;
    3936
    40 PassOwnPtr<HBITMAP> imageFromRect(const Frame*, IntRect&);
    41 PassOwnPtr<HBITMAP> imageFromSelection(Frame*, bool forceWhiteText);
     37GDIObject<HBITMAP> imageFromRect(const Frame*, IntRect&);
     38GDIObject<HBITMAP> imageFromSelection(Frame*, bool forceWhiteText);
    4239void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight);
    4340
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r155358 r155454  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc.
     2 * Copyright (C) 2006, 2007, 2008, 2010, 2013 Apple Inc.
    33 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
    44 * Copyright (C) 2007 Holger Hans Peter Freyther
     
    6363
    6464#if PLATFORM(WIN)
     65#include <wtf/win/GDIObject.h>
    6566typedef struct HFONT__* HFONT;
    6667#endif
  • trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp

    r154706 r155454  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4040#include <wtf/CurrentTime.h>
    4141#include <wtf/OwnArrayPtr.h>
     42#include <wtf/win/GDIObject.h>
    4243
    4344#ifdef DEBUG_ALL
     
    240241        return;
    241242
    242     OwnPtr<HRGN> region = adoptPtr(CreateRectRgn(0, 0, 0, 0));
     243    auto region = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
    243244    int regionType = GetUpdateRgn(window, region.get(), false);
    244245    if (regionType != COMPLEXREGION) {
     
    249250    }
    250251
    251     DWORD dataSize = GetRegionData(region.get(), 0, 0);
     252    DWORD dataSize = ::GetRegionData(region.get(), 0, 0);
    252253    OwnArrayPtr<unsigned char> regionDataBuffer = adoptArrayPtr(new unsigned char[dataSize]);
    253254    RGNDATA* regionData = reinterpret_cast<RGNDATA*>(regionDataBuffer.get());
    254     if (!GetRegionData(region.get(), dataSize, regionData))
     255    if (!::GetRegionData(region.get(), dataSize, regionData))
    255256        return;
    256257
  • trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp

    r152142 r155454  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3838#include <wtf/StdLibExtras.h>
    3939#include <wtf/text/StringHash.h>
     40#include <wtf/win/GDIObject.h>
    4041#if USE(CG)
    4142#include <ApplicationServices/ApplicationServices.h>
     
    476477       matchData.m_chosen.lfItalic = 1;
    477478
    478     HFONT result = CreateFontIndirect(&matchData.m_chosen);
    479     if (!result)
     479    auto chosenFont = adoptGDIObject(::CreateFontIndirect(&matchData.m_chosen));
     480    if (!chosenFont)
    480481        return 0;
    481482
    482483    HWndDC dc(0);
    483484    SaveDC(dc);
    484     SelectObject(dc, result);
     485    SelectObject(dc, chosenFont.get());
    485486    WCHAR actualName[LF_FACESIZE];
    486487    GetTextFace(dc, LF_FACESIZE, actualName);
    487488    RestoreDC(dc, -1);
    488489
    489     if (wcsicmp(matchData.m_chosen.lfFaceName, actualName)) {
    490         DeleteObject(result);
    491         result = 0;
    492     }
    493 
    494     return result;
     490    if (wcsicmp(matchData.m_chosen.lfFaceName, actualName))
     491        return 0;
     492
     493    return chosenFont.leak();
    495494}
    496495
     
    555554    // look as nice. That may be solvable though.
    556555    LONG weight = adjustedGDIFontWeight(toGDIFontWeight(fontDescription.weight()), family);
    557     HFONT hfont = createGDIFont(family, weight, fontDescription.italic(),
    558                                 fontDescription.computedPixelSize() * (useGDI ? 1 : 32), useGDI);
     556    auto hfont = adoptGDIObject(createGDIFont(family, weight, fontDescription.italic(),
     557        fontDescription.computedPixelSize() * (useGDI ? 1 : 32), useGDI));
    559558
    560559    if (!hfont)
     
    565564
    566565    LOGFONT logFont;
    567     GetObject(hfont, sizeof(LOGFONT), &logFont);
     566    GetObject(hfont.get(), sizeof(LOGFONT), &logFont);
    568567
    569568    bool synthesizeBold = isGDIFontWeightBold(weight) && !isGDIFontWeightBold(logFont.lfWeight);
    570569    bool synthesizeItalic = fontDescription.italic() && !logFont.lfItalic;
    571570
    572     FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);
     571    FontPlatformData* result = new FontPlatformData(hfont.get(), fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);
    573572
    574573#if USE(CG)
     
    583582        // font.
    584583        delete result;
    585         DeleteObject(hfont);
    586584        return nullptr;
    587585    }       
    588586
     587    hfont.leak(); // result now owns the HFONT.
     588
    589589    return adoptPtr(result);
    590590}
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp

    r152142 r155454  
    11/*
    2  * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    3030#include <wtf/RetainPtr.h>
    3131#include <wtf/text/Base64.h>
     32#include <wtf/win/GDIObject.h>
    3233
    3334namespace WebCore {
     
    6364    logFont.lfWeight = bold ? 700 : 400;
    6465
    65     HFONT hfont = CreateFontIndirect(&logFont);
     66    auto hfont = adoptGDIObject(::CreateFontIndirect(&logFont));
    6667
    6768    RetainPtr<CGFontRef> cgFont = adoptCF(CGFontCreateWithPlatformFont(&logFont));
    68     return FontPlatformData(hfont, cgFont.get(), size, bold, italic, renderingMode == AlternateRenderingMode);
     69    return FontPlatformData(hfont.leak(), cgFont.get(), size, bold, italic, renderingMode == AlternateRenderingMode);
    6970}
    7071
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp

    r152142 r155454  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Computer, Inc.
     2 * Copyright (C) 2007, 2008, 2013 Apple Computer, Inc.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2929#include <wtf/RetainPtr.h>
    3030#include <wtf/text/Base64.h>
     31#include <wtf/win/GDIObject.h>
    3132
    3233namespace WebCore {
     
    5960    logFont.lfWeight = bold ? 700 : 400;
    6061
    61     HFONT hfont = CreateFontIndirect(&logFont);
     62    auto hfont = adoptGDIObject(::CreateFontIndirect(&logFont));
    6263
    6364    cairo_font_face_t* fontFace = cairo_win32_font_face_create_for_hfont(hfont);
    6465
    65     FontPlatformData fontPlatformData(hfont, fontFace, size, bold, italic);
     66    FontPlatformData fontPlatformData(hfont.leak(), fontFace, size, bold, italic);
    6667
    6768    cairo_font_face_destroy(fontFace);
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp

    r149716 r155454  
    11/*
    2  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#include "AffineTransform.h"
     30#include "GraphicsContextPlatformPrivateCG.h"
    3031#include "Path.h"
    3132
    3233#include <CoreGraphics/CGBitmapContext.h>
    3334#include <WebKitSystemInterface/WebKitSystemInterface.h>
    34 #include "GraphicsContextPlatformPrivateCG.h"
     35#include <wtf/win/GDIObject.h>
    3536
    3637using namespace std;
     
    100101        return;
    101102
    102     OwnPtr<HBITMAP> bitmap = adoptPtr(static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP)));
     103    auto bitmap = adoptGDIObject(static_cast<HBITMAP>(::GetCurrentObject(hdc, OBJ_BITMAP)));
    103104
    104105    DIBPixelData pixelData(bitmap.get());
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp

    r134629 r155454  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    138138        return;
    139139
    140     OwnPtr<HBITMAP> bitmap = adoptPtr(static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP)));
     140    auto bitmap = adoptGDIObject(static_cast<HBITMAP>(::GetCurrentObject(hdc, OBJ_BITMAP)));
    141141
    142142    DIBPixelData pixelData(bitmap.get());
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp

    r120956 r155454  
    11/*
    2  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939#include "Path.h"
    4040#include <wtf/MathExtras.h>
     41#include <wtf/win/GDIObject.h>
    4142
    4243using namespace std;
     
    113114            return 0;
    114115
    115         HDC bitmapDC = ::CreateCompatibleDC(m_data->m_hdc);
    116         ::SelectObject(bitmapDC, bitmap);
     116        auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(m_data->m_hdc));
     117        ::SelectObject(bitmapDC.get(), bitmap);
    117118
    118119        // Fill our buffer with clear if we're going to alpha blend.
     
    121122
    122123        // Make sure we can do world transforms.
    123         SetGraphicsMode(bitmapDC, GM_ADVANCED);
     124        ::SetGraphicsMode(bitmapDC.get(), GM_ADVANCED);
    124125
    125126        // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
    126127        XFORM xform = TransformationMatrix().translate(-dstRect.x(), -dstRect.y());
    127128
    128         ::SetWorldTransform(bitmapDC, &xform);
    129 
    130         return bitmapDC;
     129        ::SetWorldTransform(bitmapDC.get(), &xform);
     130
     131        return bitmapDC.leak();
    131132    }
    132133
  • trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp

    r146129 r155454  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737#include <mlang.h>
    3838#include <wtf/MathExtras.h>
     39#include <wtf/win/GDIObject.h>
    3940
    4041namespace WebCore {
     
    139140    GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winfont);
    140141    winfont.lfHeight = -lroundf(scaledSize * (m_platformData.useGDI() ? 1 : 32));
    141     HFONT hfont = CreateFontIndirect(&winfont);
    142     return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false);
     142    auto hfont = adoptGDIObject(::CreateFontIndirect(&winfont));
     143    return SimpleFontData::create(FontPlatformData(hfont.leak(), scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false);
    143144}
    144145
  • trunk/Source/WebCore/platform/win/CursorWin.cpp

    r105661 r155454  
    11/*
    22 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
    3  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     3 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    3636#include <wtf/OwnPtr.h>
    3737#include <wtf/PassOwnPtr.h>
     38#include <wtf/win/GDIObject.h>
    3839
    3940#include <windows.h>
     
    5253
    5354    HWndDC dc(0);
    54     HDC workingDC = CreateCompatibleDC(dc);
     55    auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc));
    5556    if (doAlpha) {
    56         OwnPtr<HBITMAP> hCursor = adoptPtr(CreateDIBSection(dc, (BITMAPINFO *)&cursorImage, DIB_RGB_COLORS, 0, 0, 0));
     57        auto hCursor = adoptGDIObject(::CreateDIBSection(dc, (BITMAPINFO *)&cursorImage, DIB_RGB_COLORS, 0, 0, 0));
    5758        ASSERT(hCursor);
    5859
    5960        img->getHBITMAP(hCursor.get());
    60         HBITMAP hOldBitmap = (HBITMAP)SelectObject(workingDC, hCursor.get());
    61         SetBkMode(workingDC, TRANSPARENT);
    62         SelectObject(workingDC, hOldBitmap);
     61        HBITMAP hOldBitmap = (HBITMAP)SelectObject(workingDC.get(), hCursor.get());
     62        SetBkMode(workingDC.get(), TRANSPARENT);
     63        SelectObject(workingDC.get(), hOldBitmap);
    6364
    6465        Vector<unsigned char, 128> maskBits;
    6566        maskBits.fill(0xff, (img->width() + 7) / 8 * img->height());
    66         OwnPtr<HBITMAP> hMask = adoptPtr(CreateBitmap(img->width(), img->height(), 1, 1, maskBits.data()));
     67        auto hMask = adoptGDIObject(::CreateBitmap(img->width(), img->height(), 1, 1, maskBits.data()));
    6768
    6869        ICONINFO ii;
     
    7374        ii.hbmColor = hCursor.get();
    7475
    75         impl = SharedCursor::create(CreateIconIndirect(&ii));
     76        impl = SharedCursor::create(::CreateIconIndirect(&ii));
    7677    } else {
    7778        // Platform doesn't support alpha blended cursors, so we need
    7879        // to create the mask manually
    79         HDC andMaskDC = CreateCompatibleDC(dc);
    80         HDC xorMaskDC = CreateCompatibleDC(dc);
    81         OwnPtr<HBITMAP> hCursor = adoptPtr(CreateDIBSection(dc, &cursorImage, DIB_RGB_COLORS, 0, 0, 0));
     80        auto andMaskDC = adoptGDIObject(::CreateCompatibleDC(dc));
     81        auto xorMaskDC = adoptGDIObject(::CreateCompatibleDC(dc));
     82        auto hCursor = adoptGDIObject(::CreateDIBSection(dc, &cursorImage, DIB_RGB_COLORS, 0, 0, 0));
    8283        ASSERT(hCursor);
    8384        img->getHBITMAP(hCursor.get());
    8485        BITMAP cursor;
    8586        GetObject(hCursor.get(), sizeof(BITMAP), &cursor);
    86         OwnPtr<HBITMAP> andMask = adoptPtr(CreateBitmap(cursor.bmWidth, cursor.bmHeight, 1, 1, NULL));
    87         OwnPtr<HBITMAP> xorMask = adoptPtr(CreateCompatibleBitmap(dc, cursor.bmWidth, cursor.bmHeight));
    88         HBITMAP oldCursor = (HBITMAP)SelectObject(workingDC, hCursor.get());
    89         HBITMAP oldAndMask = (HBITMAP)SelectObject(andMaskDC, andMask.get());
    90         HBITMAP oldXorMask = (HBITMAP)SelectObject(xorMaskDC, xorMask.get());
    91 
    92         SetBkColor(workingDC, RGB(0,0,0)); 
    93         BitBlt(andMaskDC, 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC, 0, 0, SRCCOPY);
     87        auto andMask = adoptGDIObject(::CreateBitmap(cursor.bmWidth, cursor.bmHeight, 1, 1, 0));
     88        auto xorMask = adoptGDIObject(::CreateCompatibleBitmap(dc, cursor.bmWidth, cursor.bmHeight));
     89        HBITMAP oldCursor = (HBITMAP)SelectObject(workingDC.get(), hCursor.get());
     90        HBITMAP oldAndMask = (HBITMAP)SelectObject(andMaskDC.get(), andMask.get());
     91        HBITMAP oldXorMask = (HBITMAP)SelectObject(xorMaskDC.get(), xorMask.get());
     92
     93        SetBkColor(workingDC.get(), RGB(0, 0, 0)); 
     94        BitBlt(andMaskDC.get(), 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC.get(), 0, 0, SRCCOPY);
    9495   
    95         SetBkColor(xorMaskDC, RGB(255, 255, 255));
    96         SetTextColor(xorMaskDC, RGB(255, 255, 255));
    97         BitBlt(xorMaskDC, 0, 0, cursor.bmWidth, cursor.bmHeight, andMaskDC, 0, 0, SRCCOPY);
    98         BitBlt(xorMaskDC, 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC, 0,0, SRCAND);
    99 
    100         SelectObject(workingDC, oldCursor);
    101         SelectObject(andMaskDC, oldAndMask);
    102         SelectObject(xorMaskDC, oldXorMask);
     96        SetBkColor(xorMaskDC.get(), RGB(255, 255, 255));
     97        SetTextColor(xorMaskDC.get(), RGB(255, 255, 255));
     98        BitBlt(xorMaskDC.get(), 0, 0, cursor.bmWidth, cursor.bmHeight, andMaskDC.get(), 0, 0, SRCCOPY);
     99        BitBlt(xorMaskDC.get(), 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC.get(), 0, 0, SRCAND);
     100
     101        SelectObject(workingDC.get(), oldCursor);
     102        SelectObject(andMaskDC.get(), oldAndMask);
     103        SelectObject(xorMaskDC.get(), oldXorMask);
    103104
    104105        ICONINFO icon = {0};
     
    109110        icon.hbmColor = xorMask.get();
    110111        impl = SharedCursor::create(CreateIconIndirect(&icon));
    111 
    112         DeleteDC(xorMaskDC);
    113         DeleteDC(andMaskDC);
    114112    }
    115     DeleteDC(workingDC);
    116113
    117114    return impl.release();
  • trunk/Source/WebCore/platform/win/DragImageCGWin.cpp

    r154088 r155454  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007, 2008, 2013 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535#include <CoreGraphics/CoreGraphics.h>
    3636#include <wtf/RetainPtr.h>
     37#include <wtf/win/GDIObject.h>
    3738
    3839#include <windows.h>
     
    9293    HBITMAP hbmp = 0;
    9394    HWndDC dc(0);
    94     HDC dstDC = CreateCompatibleDC(dc);
     95    auto dstDC = adoptGDIObject(::CreateCompatibleDC(dc));
    9596    if (!dstDC)
    9697        goto exit;
    9798
    98     hbmp = allocImage(dstDC, dstSize, &targetContext);
     99    hbmp = allocImage(dstDC.get(), dstSize, &targetContext);
    99100    if (!hbmp)
    100101        goto exit;
     
    116117    if (!hbmp)
    117118        hbmp = image;
    118     if (dstDC)
    119         DeleteDC(dstDC);
    120119    return hbmp;
    121120}
     
    125124    HBITMAP hbmp = 0;
    126125    HWndDC dc(0);
    127     HDC workingDC = CreateCompatibleDC(dc);
     126    auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc));
    128127    CGContextRef drawContext = 0;
    129128    if (!workingDC)
    130         goto exit;
     129        return 0;
    131130
    132     hbmp = allocImage(workingDC, img->size(), &drawContext);
     131    hbmp = allocImage(workingDC.get(), img->size(), &drawContext);
    133132
    134133    if (!hbmp)
    135         goto exit;
     134        return 0;
    136135
    137136    if (!drawContext) {
     
    155154    CGContextRelease(drawContext);
    156155
    157 exit:
    158     if (workingDC)
    159         DeleteDC(workingDC);
    160156    return hbmp;
    161157}
  • trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp

    r154088 r155454  
    11/*
    2  * Copyright (C) 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2008, 2013 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232#include "GraphicsContextPlatformPrivateCairo.h"
    3333#include "Image.h"
    34 #include <wtf/RetainPtr.h>
    3534#include <cairo-win32.h>
    3635#include <windows.h>
     36#include <wtf/RetainPtr.h>
     37#include <wtf/win/GDIObject.h>
    3738
    3839namespace WebCore {
     
    114115    HBITMAP hbmp = 0;
    115116    HDC dc = GetDC(0);
    116     HDC dstDC = CreateCompatibleDC(dc);
     117    auto dstDC = adoptGDIObject(::CreateCompatibleDC(dc));
    117118
    118119    if (!dstDC)
     
    120121
    121122    PlatformContextCairo* targetContext;
    122     hbmp = allocImage(dstDC, dstSize, &targetContext);
     123    hbmp = allocImage(dstDC.get(), dstSize, &targetContext);
    123124    if (!hbmp)
    124125        goto exit;
     
    145146    if (!hbmp)
    146147        hbmp = image;
    147     if (dstDC)
    148         DeleteDC(dstDC);
    149148    ReleaseDC(0, dc);
    150149    return hbmp;
     
    155154    HBITMAP hbmp = 0;
    156155    HDC dc = GetDC(0);
    157     HDC workingDC = CreateCompatibleDC(dc);
     156    auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc));
    158157    if (!workingDC)
    159158        goto exit;
    160159
    161160    PlatformContextCairo* drawContext = 0;
    162     hbmp = allocImage(workingDC, img->size(), &drawContext);
     161    hbmp = allocImage(workingDC.get(), img->size(), &drawContext);
    163162    if (!hbmp)
    164163        goto exit;
     
    185184
    186185exit:
    187     if (workingDC)
    188         DeleteDC(workingDC);
    189186    ReleaseDC(0, dc);
    190187    return hbmp;
  • trunk/Source/WebCore/platform/win/DragImageWin.cpp

    r152142 r155454  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007, 2008, 2013 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939#include "WebCoreTextRenderer.h"
    4040#include <wtf/RetainPtr.h>
     41#include <wtf/win/GDIObject.h>
    4142
    4243#include <windows.h>
     
    180181    HBITMAP image = 0;
    181182    HWndDC dc(0);
    182     HDC workingDC = CreateCompatibleDC(dc);
     183    auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc));
    183184    if (!workingDC)
    184185        return 0;
    185186
    186187    PlatformGraphicsContext* contextRef;
    187     image = allocImage(workingDC, imageSize, &contextRef);
    188     if (!image) {
    189         DeleteDC(workingDC);
    190         return 0;
    191     }
     188    image = allocImage(workingDC.get(), imageSize, &contextRef);
     189    if (!image)
     190        return 0;
    192191       
    193     SelectObject(workingDC, image);
     192    ::SelectObject(workingDC.get(), image);
    194193    GraphicsContext context(contextRef);
    195194    // On Mac alpha is {0.7, 0.7, 0.7, 0.8}, however we can't control alpha
     
    217216
    218217    deallocContext(contextRef);
    219     DeleteDC(workingDC);
    220218    return image;
    221219}
  • trunk/Source/WebCore/platform/win/PasteboardWin.cpp

    r154877 r155454  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007, 2013 Apple Inc.  All rights reserved.
    33 * Copyright (C) 2013 Xueqing Huang <huangxueqing@baidu.com>
    44 *
     
    5252#include <wtf/WindowsExtras.h>
    5353#include <wtf/text/CString.h>
     54#include <wtf/win/GDIObject.h>
    5455
    5556namespace WebCore {
     
    742743
    743744    HWndDC dc(0);
    744     HDC compatibleDC = CreateCompatibleDC(0);
    745     HDC sourceDC = CreateCompatibleDC(0);
    746     OwnPtr<HBITMAP> resultBitmap = adoptPtr(CreateCompatibleBitmap(dc, image->width(), image->height()));
    747     HGDIOBJ oldBitmap = SelectObject(compatibleDC, resultBitmap.get());
     745    auto compatibleDC = adoptGDIObject(::CreateCompatibleDC(0));
     746    auto sourceDC = adoptGDIObject(::CreateCompatibleDC(0));
     747    auto resultBitmap = adoptGDIObject(::CreateCompatibleBitmap(dc, image->width(), image->height()));
     748    HGDIOBJ oldBitmap = ::SelectObject(compatibleDC.get(), resultBitmap.get());
    748749
    749750    BitmapInfo bmInfo = BitmapInfo::create(image->size());
    750751
    751     HBITMAP coreBitmap = CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0);
    752     HGDIOBJ oldSource = SelectObject(sourceDC, coreBitmap);
    753     image->getHBITMAP(coreBitmap);
    754 
    755     BitBlt(compatibleDC, 0, 0, image->width(), image->height(), sourceDC, 0, 0, SRCCOPY);
    756 
    757     SelectObject(sourceDC, oldSource);
    758     DeleteObject(coreBitmap);
    759 
    760     SelectObject(compatibleDC, oldBitmap);
    761     DeleteDC(sourceDC);
    762     DeleteDC(compatibleDC);
     752    auto coreBitmap = adoptGDIObject(::CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0));
     753    HGDIOBJ oldSource = ::SelectObject(sourceDC.get(), coreBitmap.get());
     754    image->getHBITMAP(coreBitmap.get());
     755
     756    ::BitBlt(compatibleDC.get(), 0, 0, image->width(), image->height(), sourceDC.get(), 0, 0, SRCCOPY);
     757
     758    ::SelectObject(sourceDC.get(), oldSource);
     759    ::SelectObject(compatibleDC.get(), oldBitmap);
    763760
    764761    if (::OpenClipboard(m_owner)) {
    765         ::SetClipboardData(CF_BITMAP, resultBitmap.leakPtr());
     762        ::SetClipboardData(CF_BITMAP, resultBitmap.leak());
    766763        ::CloseClipboard();
    767764    }
  • trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp

    r153478 r155454  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008, 2013 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333#include "SoftLinking.h"
    3434#include "SystemInfo.h"
     35#include <wtf/win/GDIObject.h>
    3536
    3637// Generic state constants
     
    257258        else {
    258259            static WORD patternBits[8] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
    259             OwnPtr<HBITMAP> patternBitmap = adoptPtr(::CreateBitmap(8, 8, 1, 1, patternBits));
    260             OwnPtr<HBRUSH> brush = adoptPtr(::CreatePatternBrush(patternBitmap.get()));
     260            auto patternBitmap = adoptGDIObject(::CreateBitmap(8, 8, 1, 1, patternBits));
     261            auto brush = adoptGDIObject(::CreatePatternBrush(patternBitmap.get()));
    261262            SaveDC(hdc);
    262263            ::SetTextColor(hdc, ::GetSysColor(COLOR_3DHILIGHT));
  • trunk/Source/WebCore/plugins/win/PluginViewWin.cpp

    r154272 r155454  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Collabora Ltd. All rights reserved.
    44 * Copyright (C) 2008-2009 Torch Mobile, Inc. All rights reserved.
     
    7272#include <wtf/ASCIICType.h>
    7373#include <wtf/text/WTFString.h>
     74#include <wtf/win/GDIObject.h>
    7475
    7576#if OS(WINCE)
     
    458459
    459460    if (platformPluginWidget() && (!m_haveUpdatedPluginWidget || m_windowRect != oldWindowRect || m_clipRect != oldClipRect)) {
    460         HRGN rgn;
    461461
    462462        setCallingPlugin(true);
     
    468468
    469469        if (clipToZeroRect) {
    470             rgn = ::CreateRectRgn(0, 0, 0, 0);
    471             ::SetWindowRgn(platformPluginWidget(), rgn, FALSE);
     470            auto rgn = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
     471            ::SetWindowRgn(platformPluginWidget(), rgn.leak(), FALSE);
    472472        } else {
    473             rgn = ::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY());
    474             ::SetWindowRgn(platformPluginWidget(), rgn, TRUE);
     473            auto rgn = adoptGDIObject(::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()));
     474            ::SetWindowRgn(platformPluginWidget(), rgn.leak(), TRUE);
    475475        }
    476476
     
    479479
    480480        if (clipToZeroRect) {
    481             rgn = ::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY());
    482             ::SetWindowRgn(platformPluginWidget(), rgn, TRUE);
     481            auto rgn = adoptGDIObject(::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()));
     482            ::SetWindowRgn(platformPluginWidget(), rgn.leak(), TRUE);
    483483        }
    484484
     
    10691069{
    10701070#if !PLATFORM(GTK) && !USE(WINGDI)
    1071     OwnPtr<HDC> hdc = adoptPtr(CreateCompatibleDC(0));
     1071    auto hdc = adoptGDIObject(::CreateCompatibleDC(0));
    10721072
    10731073    if (!m_isWindowed) {
     
    10891089    void* bits;
    10901090    BitmapInfo bmp = BitmapInfo::createBottomUp(frameRect().size());
    1091     OwnPtr<HBITMAP> hbmp = adoptPtr(CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0));
     1091    auto hbmp = adoptGDIObject(::CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0));
    10921092
    10931093    HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc.get(), hbmp.get()));
  • trunk/Source/WebCore/rendering/RenderThemeWin.cpp

    r154877 r155454  
    3838#include "SystemInfo.h"
    3939#include "UserAgentStyleSheets.h"
     40#include <wtf/win/GDIObject.h>
    4041
    4142#if ENABLE(VIDEO)
     
    691692            if (themeData.m_state == TUS_DISABLED) {
    692693                static WORD patternBits[8] = {0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55};
    693                 OwnPtr<HBITMAP> patternBmp = adoptPtr(::CreateBitmap(8, 8, 1, 1, patternBits));
     694                auto patternBmp = adoptGDIObject(::CreateBitmap(8, 8, 1, 1, patternBits));
    694695                if (patternBmp) {
    695                     OwnPtr<HBRUSH> brush = adoptPtr(::CreatePatternBrush(patternBmp.get()));
     696                    auto brush = adoptGDIObject(::CreatePatternBrush(patternBmp.get()));
    696697                    COLORREF oldForeColor = ::SetTextColor(hdc, ::GetSysColor(COLOR_3DFACE));
    697698                    COLORREF oldBackColor = ::SetBkColor(hdc, ::GetSysColor(COLOR_3DHILIGHT));
  • trunk/Source/WebKit/win/ChangeLog

    r155212 r155454  
     12013-09-09  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject template.
     4        https://bugs.webkit.org/show_bug.cgi?id=120778
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * FullscreenVideoController.cpp:
     9        (FullscreenVideoController::createHUDWindow): Switch to GDIObject.
     10        (FullscreenVideoController::draw): Ditto.
     11        * FullscreenVideoController.h:
     12        * WebCoreSupport/EmbeddedWidget.cpp:
     13        (EmbeddedWidget::frameRectsChanged): Switch to GDIObject.
     14        * WebNodeHighlight.cpp:
     15        (WebNodeHighlight::update): Switch to GDIObject.
     16        * WebView.cpp:
     17        (WebView::scrollBackingStore): Switch to GDIObject.
     18        (WebView::updateBackingStore): Ditto.
     19        (WebView::performLayeredWindowUpdate): Ditto.
     20        (WebView::paint): Ditto.
     21        (WebView::paintIntoBackingStore): Ditto.
     22        (WebView::paintIntoWindow): Ditto.
     23        (WebView::generateSelectionImage): Ditto.
     24
    1252013-09-05  Roger Fong  <roger_fong@apple.com>
    226
  • trunk/Source/WebKit/win/FullscreenVideoController.cpp

    r154877 r155454  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    444444    void* pixels;
    445445    BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(IntSize(windowWidth, windowHeight));
    446     m_bitmap = adoptPtr(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));
     446    m_bitmap = adoptGDIObject(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));
    447447
    448448    // Dirty the window so the HUD draws
     
    488488void FullscreenVideoController::draw()
    489489{
    490     OwnPtr<HDC> bitmapDC = adoptPtr(CreateCompatibleDC(HWndDC(m_hudWindow)));
     490    auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(HWndDC(m_hudWindow)));
    491491    HGDIOBJ oldBitmap = SelectObject(bitmapDC.get(), m_bitmap.get());
    492492
  • trunk/Source/WebKit/win/FullscreenVideoController.h

    r82120 r155454  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636#include <WebCore/IntSize.h>
    3737#include <wtf/RefPtr.h>
     38#include <wtf/win/GDIObject.h>
    3839
    3940namespace WebCore {
     
    154155
    155156    HWND m_hudWindow;
    156     OwnPtr<HBITMAP> m_bitmap;
     157    GDIObject<HBITMAP> m_bitmap;
    157158    WebCore::IntSize m_fullscreenSize;
    158159    WebCore::IntPoint m_hudPosition;
  • trunk/Source/WebKit/win/WebCoreSupport/EmbeddedWidget.cpp

    r154877 r155454  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008, 2013 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include <WebCore/HTMLPlugInElement.h>
    3232#include <WebCore/RenderObject.h>
     33#include <wtf/win/GDIObject.h>
    3334
    3435#include "MemoryStream.h"
     
    110111        return;
    111112
    112     HRGN rgn;
    113 
    114113    // To prevent flashes while scrolling, we disable drawing during the window
    115114    // update process by clipping the window to the zero rect.
     
    118117
    119118    if (clipToZeroRect) {
    120         rgn = ::CreateRectRgn(0, 0, 0, 0);
    121         ::SetWindowRgn(m_window, rgn, FALSE);
     119        auto rgn = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
     120        ::SetWindowRgn(m_window, rgn.leak(), FALSE);
    122121    } else {
    123         rgn = ::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY());
    124         ::SetWindowRgn(m_window, rgn, TRUE);
     122        auto rgn = adoptGDIObject(::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()));
     123        ::SetWindowRgn(m_window, rgn.leak(), TRUE);
    125124     }
    126125
     
    129128
    130129     if (clipToZeroRect) {
    131         rgn = ::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY());
    132         ::SetWindowRgn(m_window, rgn, TRUE);
     130        auto rgn = adoptGDIObject(::CreateRectRgn(m_clipRect.x(), m_clipRect.y(), m_clipRect.maxX(), m_clipRect.maxY()));
     131        ::SetWindowRgn(m_window, rgn.leak(), TRUE);
    133132    }
    134133}
  • trunk/Source/WebKit/win/WebNodeHighlight.cpp

    r114499 r155454  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007, 2013 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4040#include <wtf/HashSet.h>
    4141#include <wtf/OwnPtr.h>
     42#include <wtf/win/GDIObject.h>
    4243
    4344using namespace WebCore;
     
    141142    ASSERT(m_overlay);
    142143
    143     HDC hdc = ::CreateCompatibleDC(HWndDC(m_overlay));
     144    auto hdc = adoptGDIObject(::CreateCompatibleDC(HWndDC(m_overlay)));
    144145    if (!hdc)
    145146        return;
     
    158159
    159160    void* pixels = 0;
    160     OwnPtr<HBITMAP> hbmp = adoptPtr(::CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));
     161    auto hbmp = adoptGDIObject(::CreateDIBSection(hdc.get(), &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));
    161162    ASSERT_WITH_MESSAGE(hbmp, "::CreateDIBSection failed with error %lu", ::GetLastError());
    162163
    163     ::SelectObject(hdc, hbmp.get());
    164 
    165     GraphicsContext context(hdc);
     164    ::SelectObject(hdc.get(), hbmp.get());
     165
     166    GraphicsContext context(hdc.get());
    166167#if ENABLE(INSPECTOR)
    167168    m_inspectedWebView->page()->inspectorController()->drawHighlight(context);
     
    182183    dstPoint.y = webViewRect.top;
    183184
    184     ::UpdateLayeredWindow(m_overlay, HWndDC(0), &dstPoint, &size, hdc, &srcPoint, 0, &bf, ULW_ALPHA);
    185     ::DeleteDC(hdc);
     185    ::UpdateLayeredWindow(m_overlay, HWndDC(0), &dstPoint, &size, hdc.get(), &srcPoint, 0, &bf, ULW_ALPHA);
    186186}
    187187
  • trunk/Source/WebKit/win/WebView.cpp

    r155194 r155454  
    181181#include <wtf/text/CString.h>
    182182#include <wtf/text/StringConcatenate.h>
     183#include <wtf/win/GDIObject.h>
    183184
    184185// Soft link functions for gestures and panning feedback
     
    894895    // Collect our device context info and select the bitmap to scroll.
    895896    HWndDC windowDC(m_viewWindow);
    896     HDC bitmapDC = ::CreateCompatibleDC(windowDC);
    897     HGDIOBJ oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle());
     897    auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(windowDC));
     898    HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), m_backingStoreBitmap->handle());
    898899   
    899900    // Scroll the bitmap.
    900901    RECT scrollRectWin(scrollViewRect);
    901902    RECT clipRectWin(clipRect);
    902     ::ScrollDC(bitmapDC, dx, dy, &scrollRectWin, &clipRectWin, updateRegion, 0);
     903    ::ScrollDC(bitmapDC.get(), dx, dy, &scrollRectWin, &clipRectWin, updateRegion, 0);
    903904    RECT regionBox;
    904905    ::GetRgnBox(updateRegion, &regionBox);
     
    914915
    915916    // Update the backing store.
    916     updateBackingStore(frameView, bitmapDC, false);
     917    updateBackingStore(frameView, bitmapDC.get(), false);
    917918
    918919    // Clean up.
    919     ::SelectObject(bitmapDC, oldBitmap);
    920     ::DeleteDC(bitmapDC);
     920    ::SelectObject(bitmapDC.get(), oldBitmap);
    921921}
    922922
     
    988988    LOCAL_GDI_COUNTER(0, __FUNCTION__);
    989989
     990    GDIObject<HDC> bitmapDCObject;
     991
    990992    HDC bitmapDC = dc;
    991993    HGDIOBJ oldBitmap = 0;
    992994    if (!dc) {
    993995        HWndDC windowDC(m_viewWindow);
    994         bitmapDC = ::CreateCompatibleDC(windowDC);
     996        bitmapDCObject = adoptGDIObject(::CreateCompatibleDC(windowDC));
     997        bitmapDC = bitmapDCObject.get();
    995998        oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle());
    996999    }
     
    10221025    }
    10231026
    1024     if (!dc) {
     1027    if (!dc)
    10251028        ::SelectObject(bitmapDC, oldBitmap);
    1026         ::DeleteDC(bitmapDC);
    1027     }
    10281029
    10291030    GdiFlush();
     
    10371038
    10381039    HWndDC hdcScreen(m_viewWindow);
    1039     OwnPtr<HDC> hdcMem = adoptPtr(::CreateCompatibleDC(hdcScreen));
     1040    auto hdcMem = adoptGDIObject(::CreateCompatibleDC(hdcScreen));
    10401041    HBITMAP hbmOld = static_cast<HBITMAP>(::SelectObject(hdcMem.get(), m_backingStoreBitmap->handle()));
    10411042
     
    11111112    m_paintCount++;
    11121113
    1113     HDC bitmapDC = ::CreateCompatibleDC(hdc);
    1114     HGDIOBJ oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle());
     1114    auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(hdc));
     1115    HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), m_backingStoreBitmap->handle());
    11151116
    11161117    // Update our backing store if needed.
    1117     updateBackingStore(frameView, bitmapDC, backingStoreCompletelyDirty, windowsToPaint);
     1118    updateBackingStore(frameView, bitmapDC.get(), backingStoreCompletelyDirty, windowsToPaint);
    11181119
    11191120    // Now we blit the updated backing store
     
    11281129
    11291130    for (unsigned i = 0; i < blitRects.size(); ++i)
    1130         paintIntoWindow(bitmapDC, hdc, blitRects[i]);
    1131 
    1132     ::SelectObject(bitmapDC, oldBitmap);
    1133     ::DeleteDC(bitmapDC);
     1131        paintIntoWindow(bitmapDC.get(), hdc, blitRects[i]);
     1132
     1133    ::SelectObject(bitmapDC.get(), oldBitmap);
    11341134
    11351135    if (!dc)
     
    11611161    {
    11621162        HWndDC dc(m_viewWindow);
    1163         OwnPtr<HBRUSH> yellowBrush(CreateSolidBrush(RGB(255, 255, 0)));
     1163        auto yellowBrush = adoptGDIObject(::CreateSolidBrush(RGB(255, 255, 0)));
    11641164        FillRect(dc, &rect, yellowBrush.get());
    11651165        GdiFlush();
     
    11981198    LOCAL_GDI_COUNTER(0, __FUNCTION__);
    11991199#if FLASH_WINDOW_REDRAW
    1200     OwnPtr<HBRUSH> greenBrush = CreateSolidBrush(RGB(0, 255, 0));
     1200    auto greenBrush = adoptGDIObject(::CreateSolidBrush(RGB(0, 255, 0)));
    12011201    RECT rect = dirtyRect;
    12021202    FillRect(windowDC, &rect, greenBrush.get());
     
    35783578    WebCore::Frame& frame = m_page->focusController().focusedOrMainFrame();
    35793579
    3580     OwnPtr<HBITMAP> bitmap = imageFromSelection(&frame, forceWhiteText ? TRUE : FALSE);
    3581     *hBitmap = static_cast<OLE_HANDLE>(reinterpret_cast<ULONG64>(bitmap.leakPtr()));
     3580    auto bitmap = imageFromSelection(&frame, forceWhiteText ? TRUE : FALSE);
     3581    *hBitmap = static_cast<OLE_HANDLE>(reinterpret_cast<ULONG64>(bitmap.leak()));
    35823582
    35833583    return S_OK;
  • trunk/Tools/ChangeLog

    r155453 r155454  
     12013-09-09  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Windows] Change from using OwnPtr<GDI Stuff> to new GDIObject.
     4        https://bugs.webkit.org/show_bug.cgi?id=120778
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * DumpRenderTree/win/PixelDumpSupportWin.cpp:
     9        (createBitmapContextFromWebView): Use GDIObject.
     10        * Scripts/webkitpy/style/checkers/cpp.py:
     11        (check_for_leaky_patterns): Update for GDIObject instead of adoptPtr and OwnPtr.
     12        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
     13        (LeakyPatternTest.test_create_dc): Update for GDIObject instead of adoptPtr/OwnPtr.
     14        (LeakyPatternTest.test_create_compatible_dc): Ditto.
     15
    1162013-09-10  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
    217
  • trunk/Tools/DumpRenderTree/win/PixelDumpSupportWin.cpp

    r149716 r155454  
    11/*
    2  * Copyright (C) 2007 Apple, Inc. All rights reserved.
     2 * Copyright (C) 2007, 2013 Apple, Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444#include <wtf/Assertions.h>
    4545#include <wtf/RetainPtr.h>
     46#include <wtf/win/GDIObject.h>
    4647
    4748static void makeAlphaChannelOpaque(void* argbBits, LONG width, LONG height)
     
    7172    HBITMAP bitmap = CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0);
    7273
    73     HDC memoryDC = CreateCompatibleDC(0);
    74     SelectObject(memoryDC, bitmap);
    75     SendMessage(webViewWindow, WM_PRINT, reinterpret_cast<WPARAM>(memoryDC), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED);
    76     DeleteDC(memoryDC);
     74    auto memoryDC = adoptGDIObject(::CreateCompatibleDC(0));
     75    ::SelectObject(memoryDC.get(), bitmap);
     76    SendMessage(webViewWindow, WM_PRINT, reinterpret_cast<WPARAM>(memoryDC.get()), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED);
    7777
    7878    BITMAP info = {0};
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r152748 r155454  
    17311731
    17321732    matched_create_dc = search(r'\b(?P<function_name>Create(Compatible)?DC)\s*\(', line)
    1733     matched_own_dc = search(r'\badoptPtr\b', line)
     1733    matched_own_dc = search(r'\badoptGDIObject\b', line)
    17341734    if matched_create_dc and not matched_own_dc:
    17351735        error(line_number, 'runtime/leaky_pattern', 5,
    1736               'Use adoptPtr and OwnPtr<HDC> when calling %s to avoid potential '
     1736              'Use adoptGDIObject and GDIObject<HDC> when calling %s to avoid potential '
    17371737              'memory leaks.' % matched_create_dc.group('function_name'))
    17381738
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r152748 r155454  
    35273527        self.assert_leaky_pattern_check(
    35283528            'HDC dc2 = ::CreateDC();',
    3529             'Use adoptPtr and OwnPtr<HDC> when calling CreateDC to avoid potential '
     3529            'Use adoptGDIObject and GDIObject<HDC> when calling CreateDC to avoid potential '
    35303530            'memory leaks.  [runtime/leaky_pattern] [5]')
    35313531
    35323532        self.assert_leaky_pattern_check(
    3533             'adoptPtr(CreateDC());',
     3533            'adoptGDIObject(CreateDC());',
    35343534            '')
    35353535
     
    35373537        self.assert_leaky_pattern_check(
    35383538            'HDC dc2 = CreateCompatibleDC(dc);',
    3539             'Use adoptPtr and OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential '
     3539            'Use adoptGDIObject and GDIObject<HDC> when calling CreateCompatibleDC to avoid potential '
    35403540            'memory leaks.  [runtime/leaky_pattern] [5]')
    35413541        self.assert_leaky_pattern_check(
    3542             'adoptPtr(CreateCompatibleDC(dc));',
     3542            'adoptGDIObject(CreateCompatibleDC(dc));',
    35433543            '')
    35443544
Note: See TracChangeset for help on using the changeset viewer.