Changeset 155454 in webkit
- Timestamp:
- Sep 10, 2013 10:37:27 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r155407 r155454 1 2013-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 1 31 2013-09-09 Anders Carlsson <andersca@apple.com> 2 32 -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj
r155402 r155454 270 270 <ClInclude Include="..\wtf\Vector.h" /> 271 271 <ClInclude Include="..\wtf\VMTags.h" /> 272 <ClInclude Include="..\wtf\win\GDIObject.h" /> 272 273 <ClInclude Include="..\wtf\WTFThreadData.h" /> 273 274 </ItemGroup> -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
r155402 r155454 492 492 <Filter>wtf</Filter> 493 493 </ClInclude> 494 <ClInclude Include="..\wtf\Ref.h">495 <Filter>wtf</Filter>496 </ClInclude>497 494 <ClInclude Include="..\wtf\Noncopyable.h"> 498 495 <Filter>wtf</Filter> … … 681 678 <ClInclude Include="..\wtf\DeferrableRefCounted.h"> 682 679 <Filter>wtf</Filter> 680 </ClInclude> 681 <ClInclude Include="..\wtf\win\GDIObject.h"> 682 <Filter>win</Filter> 683 683 </ClInclude> 684 684 </ItemGroup> -
trunk/Source/WTF/WTF.vcxproj/copy-files.cmd
r152381 r155454 16 16 wtf\unicode 17 17 wtf\unicode\icu 18 wtf\win 18 19 ) do ( 19 20 mkdir "%PrivateHeadersDirectory%\%%d" 2>NUL -
trunk/Source/WTF/wtf/OwnPtrCommon.h
r142454 r155454 31 31 #if OS(WINDOWS) 32 32 typedef struct HBITMAP__* HBITMAP; 33 typedef struct HBRUSH__* HBRUSH;34 33 typedef struct HDC__* HDC; 35 typedef struct HFONT__* HFONT;36 typedef struct HPALETTE__* HPALETTE;37 typedef struct HPEN__* HPEN;38 34 typedef struct HRGN__* HRGN; 39 35 #endif … … 66 62 #if OS(WINDOWS) 67 63 WTF_EXPORT_PRIVATE void deleteOwnedPtr(HBITMAP); 68 WTF_EXPORT_PRIVATE void deleteOwnedPtr(HBRUSH);69 64 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);73 65 WTF_EXPORT_PRIVATE void deleteOwnedPtr(HRGN); 74 66 #endif -
trunk/Source/WTF/wtf/win/OwnPtrWin.cpp
r139974 r155454 40 40 } 41 41 42 void deleteOwnedPtr(HBRUSH ptr)43 {44 if (ptr)45 DeleteObject(ptr);46 }47 48 42 void deleteOwnedPtr(HDC ptr) 49 43 { 50 44 if (ptr) 51 45 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);70 46 } 71 47 -
trunk/Source/WebCore/ChangeLog
r155447 r155454 1 2013-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 1 60 2013-09-10 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 61 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r155315 r155454 3178 3178 <Filter>dom</Filter> 3179 3179 </ClCompile> 3180 <ClCompile Include="..\dom\ComposedShadowTreeWalker.cpp">3181 <Filter>dom</Filter>3182 </ClCompile>3183 3180 <ClCompile Include="..\dom\CompositionEvent.cpp"> 3184 3181 <Filter>dom</Filter> … … 10242 10239 </ClInclude> 10243 10240 <ClInclude Include="..\dom\Comment.h"> 10244 <Filter>dom</Filter>10245 </ClInclude>10246 <ClInclude Include="..\dom\ComposedShadowTreeWalker.h">10247 10241 <Filter>dom</Filter> 10248 10242 </ClInclude> -
trunk/Source/WebCore/page/win/FrameCGWin.cpp
r153586 r155454 1 1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 #include <CoreGraphics/CoreGraphics.h> 37 37 #include <windows.h> 38 #include <wtf/win/GDIObject.h> 38 39 39 40 namespace WebCore { … … 50 51 } 51 52 52 PassOwnPtr<HBITMAP> imageFromRect(const Frame* frame, IntRect& ir)53 GDIObject<HBITMAP> imageFromRect(const Frame* frame, IntRect& ir) 53 54 { 54 55 PaintBehavior oldPaintBehavior = frame->view()->paintBehavior(); … … 56 57 57 58 void* bits; 58 HDC hdc = CreateCompatibleDC(0);59 auto hdc = adoptGDIObject(::CreateCompatibleDC(0)); 59 60 int w = ir.width(); 60 61 int h = ir.height(); 61 62 BitmapInfo bmp = BitmapInfo::create(IntSize(w, h)); 62 63 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()); 65 66 CGContextRef context = CGBitmapContextCreate(static_cast<void*>(bits), w, h, 66 67 8, w * sizeof(RGBQUAD), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst); … … 72 73 73 74 CGContextRelease(context); 74 SelectObject(hdc, hbmpOld); 75 DeleteDC(hdc); 75 SelectObject(hdc.get(), hbmpOld); 76 76 77 77 frame->view()->setPaintBehavior(oldPaintBehavior); 78 78 79 return hbmp .release();79 return hbmp; 80 80 } 81 81 -
trunk/Source/WebCore/page/win/FrameCairoWin.cpp
r153586 r155454 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 30 30 #include "NotImplemented.h" 31 #include <wtf/win/GDIObject.h> 31 32 32 33 namespace WebCore { 33 34 34 PassOwnPtr<HBITMAP> imageFromRect(const Frame*, IntRect&)35 GDIObject<HBITMAP> imageFromRect(const Frame*, IntRect&) 35 36 { 36 37 notImplemented(); -
trunk/Source/WebCore/page/win/FrameWin.cpp
r154286 r155454 1 1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 46 46 } 47 47 48 PassOwnPtr<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText)48 GDIObject<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText) 49 49 { 50 50 frame->document()->updateLayout(); … … 53 53 FloatRect fr = frame->selection().bounds(); 54 54 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); 56 56 frame->view()->setPaintBehavior(PaintBehaviorNormal); 57 return image .release();57 return image; 58 58 } 59 59 … … 61 61 { 62 62 if (selection().isRange()) 63 return imageFromSelection(this, false).leak Ptr();63 return imageFromSelection(this, false).leak(); 64 64 65 65 return 0; … … 78 78 79 79 m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode 80 OwnPtr<HBITMAP> result = imageFromRect(this, paintingRect);80 GDIObject<HBITMAP> result = imageFromRect(this, paintingRect); 81 81 m_view->setNodeToDraw(0); 82 82 83 return result.leak Ptr();83 return result.leak(); 84 84 } 85 85 -
trunk/Source/WebCore/page/win/FrameWin.h
r153586 r155454 27 27 #define FrameWin_h 28 28 29 #include <wtf/PassOwnPtr.h>30 29 #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> 34 31 35 32 namespace WebCore { … … 38 35 class IntRect; 39 36 40 PassOwnPtr<HBITMAP> imageFromRect(const Frame*, IntRect&);41 PassOwnPtr<HBITMAP> imageFromSelection(Frame*, bool forceWhiteText);37 GDIObject<HBITMAP> imageFromRect(const Frame*, IntRect&); 38 GDIObject<HBITMAP> imageFromSelection(Frame*, bool forceWhiteText); 42 39 void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight); 43 40 -
trunk/Source/WebCore/platform/graphics/FontPlatformData.h
r155358 r155454 1 1 /* 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc.2 * Copyright (C) 2006, 2007, 2008, 2010, 2013 Apple Inc. 3 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com 4 4 * Copyright (C) 2007 Holger Hans Peter Freyther … … 63 63 64 64 #if PLATFORM(WIN) 65 #include <wtf/win/GDIObject.h> 65 66 typedef struct HFONT__* HFONT; 66 67 #endif -
trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp
r154706 r155454 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 #include <wtf/CurrentTime.h> 41 41 #include <wtf/OwnArrayPtr.h> 42 #include <wtf/win/GDIObject.h> 42 43 43 44 #ifdef DEBUG_ALL … … 240 241 return; 241 242 242 OwnPtr<HRGN> region = adoptPtr(CreateRectRgn(0, 0, 0, 0));243 auto region = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0)); 243 244 int regionType = GetUpdateRgn(window, region.get(), false); 244 245 if (regionType != COMPLEXREGION) { … … 249 250 } 250 251 251 DWORD dataSize = GetRegionData(region.get(), 0, 0);252 DWORD dataSize = ::GetRegionData(region.get(), 0, 0); 252 253 OwnArrayPtr<unsigned char> regionDataBuffer = adoptArrayPtr(new unsigned char[dataSize]); 253 254 RGNDATA* regionData = reinterpret_cast<RGNDATA*>(regionDataBuffer.get()); 254 if (! GetRegionData(region.get(), dataSize, regionData))255 if (!::GetRegionData(region.get(), dataSize, regionData)) 255 256 return; 256 257 -
trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r152142 r155454 1 1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 38 38 #include <wtf/StdLibExtras.h> 39 39 #include <wtf/text/StringHash.h> 40 #include <wtf/win/GDIObject.h> 40 41 #if USE(CG) 41 42 #include <ApplicationServices/ApplicationServices.h> … … 476 477 matchData.m_chosen.lfItalic = 1; 477 478 478 HFONT result = CreateFontIndirect(&matchData.m_chosen);479 if (! result)479 auto chosenFont = adoptGDIObject(::CreateFontIndirect(&matchData.m_chosen)); 480 if (!chosenFont) 480 481 return 0; 481 482 482 483 HWndDC dc(0); 483 484 SaveDC(dc); 484 SelectObject(dc, result);485 SelectObject(dc, chosenFont.get()); 485 486 WCHAR actualName[LF_FACESIZE]; 486 487 GetTextFace(dc, LF_FACESIZE, actualName); 487 488 RestoreDC(dc, -1); 488 489 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(); 495 494 } 496 495 … … 555 554 // look as nice. That may be solvable though. 556 555 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)); 559 558 560 559 if (!hfont) … … 565 564 566 565 LOGFONT logFont; 567 GetObject(hfont , sizeof(LOGFONT), &logFont);566 GetObject(hfont.get(), sizeof(LOGFONT), &logFont); 568 567 569 568 bool synthesizeBold = isGDIFontWeightBold(weight) && !isGDIFontWeightBold(logFont.lfWeight); 570 569 bool synthesizeItalic = fontDescription.italic() && !logFont.lfItalic; 571 570 572 FontPlatformData* result = new FontPlatformData(hfont , fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);571 FontPlatformData* result = new FontPlatformData(hfont.get(), fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI); 573 572 574 573 #if USE(CG) … … 583 582 // font. 584 583 delete result; 585 DeleteObject(hfont);586 584 return nullptr; 587 585 } 588 586 587 hfont.leak(); // result now owns the HFONT. 588 589 589 return adoptPtr(result); 590 590 } -
trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
r152142 r155454 1 1 /* 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. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 30 30 #include <wtf/RetainPtr.h> 31 31 #include <wtf/text/Base64.h> 32 #include <wtf/win/GDIObject.h> 32 33 33 34 namespace WebCore { … … 63 64 logFont.lfWeight = bold ? 700 : 400; 64 65 65 HFONT hfont = CreateFontIndirect(&logFont);66 auto hfont = adoptGDIObject(::CreateFontIndirect(&logFont)); 66 67 67 68 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); 69 70 } 70 71 -
trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
r152142 r155454 1 1 /* 2 * Copyright (C) 2007, 2008 Apple Computer, Inc.2 * Copyright (C) 2007, 2008, 2013 Apple Computer, Inc. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 29 29 #include <wtf/RetainPtr.h> 30 30 #include <wtf/text/Base64.h> 31 #include <wtf/win/GDIObject.h> 31 32 32 33 namespace WebCore { … … 59 60 logFont.lfWeight = bold ? 700 : 400; 60 61 61 HFONT hfont = CreateFontIndirect(&logFont);62 auto hfont = adoptGDIObject(::CreateFontIndirect(&logFont)); 62 63 63 64 cairo_font_face_t* fontFace = cairo_win32_font_face_create_for_hfont(hfont); 64 65 65 FontPlatformData fontPlatformData(hfont , fontFace, size, bold, italic);66 FontPlatformData fontPlatformData(hfont.leak(), fontFace, size, bold, italic); 66 67 67 68 cairo_font_face_destroy(fontFace); -
trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
r149716 r155454 1 1 /* 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. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #include "AffineTransform.h" 30 #include "GraphicsContextPlatformPrivateCG.h" 30 31 #include "Path.h" 31 32 32 33 #include <CoreGraphics/CGBitmapContext.h> 33 34 #include <WebKitSystemInterface/WebKitSystemInterface.h> 34 #include "GraphicsContextPlatformPrivateCG.h"35 #include <wtf/win/GDIObject.h> 35 36 36 37 using namespace std; … … 100 101 return; 101 102 102 OwnPtr<HBITMAP> bitmap = adoptPtr(static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP)));103 auto bitmap = adoptGDIObject(static_cast<HBITMAP>(::GetCurrentObject(hdc, OBJ_BITMAP))); 103 104 104 105 DIBPixelData pixelData(bitmap.get()); -
trunk/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
r134629 r155454 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 138 138 return; 139 139 140 OwnPtr<HBITMAP> bitmap = adoptPtr(static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP)));140 auto bitmap = adoptGDIObject(static_cast<HBITMAP>(::GetCurrentObject(hdc, OBJ_BITMAP))); 141 141 142 142 DIBPixelData pixelData(bitmap.get()); -
trunk/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
r120956 r155454 1 1 /* 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. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 #include "Path.h" 40 40 #include <wtf/MathExtras.h> 41 #include <wtf/win/GDIObject.h> 41 42 42 43 using namespace std; … … 113 114 return 0; 114 115 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); 117 118 118 119 // Fill our buffer with clear if we're going to alpha blend. … … 121 122 122 123 // Make sure we can do world transforms. 123 SetGraphicsMode(bitmapDC, GM_ADVANCED);124 ::SetGraphicsMode(bitmapDC.get(), GM_ADVANCED); 124 125 125 126 // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap. 126 127 XFORM xform = TransformationMatrix().translate(-dstRect.x(), -dstRect.y()); 127 128 128 ::SetWorldTransform(bitmapDC , &xform);129 130 return bitmapDC ;129 ::SetWorldTransform(bitmapDC.get(), &xform); 130 131 return bitmapDC.leak(); 131 132 } 132 133 -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
r146129 r155454 1 1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 #include <mlang.h> 38 38 #include <wtf/MathExtras.h> 39 #include <wtf/win/GDIObject.h> 39 40 40 41 namespace WebCore { … … 139 140 GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winfont); 140 141 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); 143 144 } 144 145 -
trunk/Source/WebCore/platform/win/CursorWin.cpp
r105661 r155454 1 1 /* 2 2 * 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. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 36 36 #include <wtf/OwnPtr.h> 37 37 #include <wtf/PassOwnPtr.h> 38 #include <wtf/win/GDIObject.h> 38 39 39 40 #include <windows.h> … … 52 53 53 54 HWndDC dc(0); 54 HDC workingDC = CreateCompatibleDC(dc);55 auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc)); 55 56 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)); 57 58 ASSERT(hCursor); 58 59 59 60 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); 63 64 64 65 Vector<unsigned char, 128> maskBits; 65 66 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())); 67 68 68 69 ICONINFO ii; … … 73 74 ii.hbmColor = hCursor.get(); 74 75 75 impl = SharedCursor::create( CreateIconIndirect(&ii));76 impl = SharedCursor::create(::CreateIconIndirect(&ii)); 76 77 } else { 77 78 // Platform doesn't support alpha blended cursors, so we need 78 79 // 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)); 82 83 ASSERT(hCursor); 83 84 img->getHBITMAP(hCursor.get()); 84 85 BITMAP cursor; 85 86 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); 94 95 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); 103 104 104 105 ICONINFO icon = {0}; … … 109 110 icon.hbmColor = xorMask.get(); 110 111 impl = SharedCursor::create(CreateIconIndirect(&icon)); 111 112 DeleteDC(xorMaskDC);113 DeleteDC(andMaskDC);114 112 } 115 DeleteDC(workingDC);116 113 117 114 return impl.release(); -
trunk/Source/WebCore/platform/win/DragImageCGWin.cpp
r154088 r155454 1 1 /* 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 #include <CoreGraphics/CoreGraphics.h> 36 36 #include <wtf/RetainPtr.h> 37 #include <wtf/win/GDIObject.h> 37 38 38 39 #include <windows.h> … … 92 93 HBITMAP hbmp = 0; 93 94 HWndDC dc(0); 94 HDC dstDC = CreateCompatibleDC(dc);95 auto dstDC = adoptGDIObject(::CreateCompatibleDC(dc)); 95 96 if (!dstDC) 96 97 goto exit; 97 98 98 hbmp = allocImage(dstDC , dstSize, &targetContext);99 hbmp = allocImage(dstDC.get(), dstSize, &targetContext); 99 100 if (!hbmp) 100 101 goto exit; … … 116 117 if (!hbmp) 117 118 hbmp = image; 118 if (dstDC)119 DeleteDC(dstDC);120 119 return hbmp; 121 120 } … … 125 124 HBITMAP hbmp = 0; 126 125 HWndDC dc(0); 127 HDC workingDC = CreateCompatibleDC(dc);126 auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc)); 128 127 CGContextRef drawContext = 0; 129 128 if (!workingDC) 130 goto exit;129 return 0; 131 130 132 hbmp = allocImage(workingDC , img->size(), &drawContext);131 hbmp = allocImage(workingDC.get(), img->size(), &drawContext); 133 132 134 133 if (!hbmp) 135 goto exit;134 return 0; 136 135 137 136 if (!drawContext) { … … 155 154 CGContextRelease(drawContext); 156 155 157 exit:158 if (workingDC)159 DeleteDC(workingDC);160 156 return hbmp; 161 157 } -
trunk/Source/WebCore/platform/win/DragImageCairoWin.cpp
r154088 r155454 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #include "GraphicsContextPlatformPrivateCairo.h" 33 33 #include "Image.h" 34 #include <wtf/RetainPtr.h>35 34 #include <cairo-win32.h> 36 35 #include <windows.h> 36 #include <wtf/RetainPtr.h> 37 #include <wtf/win/GDIObject.h> 37 38 38 39 namespace WebCore { … … 114 115 HBITMAP hbmp = 0; 115 116 HDC dc = GetDC(0); 116 HDC dstDC = CreateCompatibleDC(dc);117 auto dstDC = adoptGDIObject(::CreateCompatibleDC(dc)); 117 118 118 119 if (!dstDC) … … 120 121 121 122 PlatformContextCairo* targetContext; 122 hbmp = allocImage(dstDC , dstSize, &targetContext);123 hbmp = allocImage(dstDC.get(), dstSize, &targetContext); 123 124 if (!hbmp) 124 125 goto exit; … … 145 146 if (!hbmp) 146 147 hbmp = image; 147 if (dstDC)148 DeleteDC(dstDC);149 148 ReleaseDC(0, dc); 150 149 return hbmp; … … 155 154 HBITMAP hbmp = 0; 156 155 HDC dc = GetDC(0); 157 HDC workingDC = CreateCompatibleDC(dc);156 auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc)); 158 157 if (!workingDC) 159 158 goto exit; 160 159 161 160 PlatformContextCairo* drawContext = 0; 162 hbmp = allocImage(workingDC , img->size(), &drawContext);161 hbmp = allocImage(workingDC.get(), img->size(), &drawContext); 163 162 if (!hbmp) 164 163 goto exit; … … 185 184 186 185 exit: 187 if (workingDC)188 DeleteDC(workingDC);189 186 ReleaseDC(0, dc); 190 187 return hbmp; -
trunk/Source/WebCore/platform/win/DragImageWin.cpp
r152142 r155454 1 1 /* 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 #include "WebCoreTextRenderer.h" 40 40 #include <wtf/RetainPtr.h> 41 #include <wtf/win/GDIObject.h> 41 42 42 43 #include <windows.h> … … 180 181 HBITMAP image = 0; 181 182 HWndDC dc(0); 182 HDC workingDC = CreateCompatibleDC(dc);183 auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc)); 183 184 if (!workingDC) 184 185 return 0; 185 186 186 187 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; 192 191 193 SelectObject(workingDC, image);192 ::SelectObject(workingDC.get(), image); 194 193 GraphicsContext context(contextRef); 195 194 // On Mac alpha is {0.7, 0.7, 0.7, 0.8}, however we can't control alpha … … 217 216 218 217 deallocContext(contextRef); 219 DeleteDC(workingDC);220 218 return image; 221 219 } -
trunk/Source/WebCore/platform/win/PasteboardWin.cpp
r154877 r155454 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2013 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2013 Xueqing Huang <huangxueqing@baidu.com> 4 4 * … … 52 52 #include <wtf/WindowsExtras.h> 53 53 #include <wtf/text/CString.h> 54 #include <wtf/win/GDIObject.h> 54 55 55 56 namespace WebCore { … … 742 743 743 744 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()); 748 749 749 750 BitmapInfo bmInfo = BitmapInfo::create(image->size()); 750 751 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); 763 760 764 761 if (::OpenClipboard(m_owner)) { 765 ::SetClipboardData(CF_BITMAP, resultBitmap.leak Ptr());762 ::SetClipboardData(CF_BITMAP, resultBitmap.leak()); 766 763 ::CloseClipboard(); 767 764 } -
trunk/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
r153478 r155454 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.2 * Copyright (C) 2008, 2013 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "SoftLinking.h" 34 34 #include "SystemInfo.h" 35 #include <wtf/win/GDIObject.h> 35 36 36 37 // Generic state constants … … 257 258 else { 258 259 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())); 261 262 SaveDC(hdc); 262 263 ::SetTextColor(hdc, ::GetSysColor(COLOR_3DHILIGHT)); -
trunk/Source/WebCore/plugins/win/PluginViewWin.cpp
r154272 r155454 1 1 /* 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Collabora Ltd. All rights reserved. 4 4 * Copyright (C) 2008-2009 Torch Mobile, Inc. All rights reserved. … … 72 72 #include <wtf/ASCIICType.h> 73 73 #include <wtf/text/WTFString.h> 74 #include <wtf/win/GDIObject.h> 74 75 75 76 #if OS(WINCE) … … 458 459 459 460 if (platformPluginWidget() && (!m_haveUpdatedPluginWidget || m_windowRect != oldWindowRect || m_clipRect != oldClipRect)) { 460 HRGN rgn;461 461 462 462 setCallingPlugin(true); … … 468 468 469 469 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); 472 472 } 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); 475 475 } 476 476 … … 479 479 480 480 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); 483 483 } 484 484 … … 1069 1069 { 1070 1070 #if !PLATFORM(GTK) && !USE(WINGDI) 1071 OwnPtr<HDC> hdc = adoptPtr(CreateCompatibleDC(0));1071 auto hdc = adoptGDIObject(::CreateCompatibleDC(0)); 1072 1072 1073 1073 if (!m_isWindowed) { … … 1089 1089 void* bits; 1090 1090 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)); 1092 1092 1093 1093 HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc.get(), hbmp.get())); -
trunk/Source/WebCore/rendering/RenderThemeWin.cpp
r154877 r155454 38 38 #include "SystemInfo.h" 39 39 #include "UserAgentStyleSheets.h" 40 #include <wtf/win/GDIObject.h> 40 41 41 42 #if ENABLE(VIDEO) … … 691 692 if (themeData.m_state == TUS_DISABLED) { 692 693 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)); 694 695 if (patternBmp) { 695 OwnPtr<HBRUSH> brush = adoptPtr(::CreatePatternBrush(patternBmp.get()));696 auto brush = adoptGDIObject(::CreatePatternBrush(patternBmp.get())); 696 697 COLORREF oldForeColor = ::SetTextColor(hdc, ::GetSysColor(COLOR_3DFACE)); 697 698 COLORREF oldBackColor = ::SetBkColor(hdc, ::GetSysColor(COLOR_3DHILIGHT)); -
trunk/Source/WebKit/win/ChangeLog
r155212 r155454 1 2013-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 1 25 2013-09-05 Roger Fong <roger_fong@apple.com> 2 26 -
trunk/Source/WebKit/win/FullscreenVideoController.cpp
r154877 r155454 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 444 444 void* pixels; 445 445 BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(IntSize(windowWidth, windowHeight)); 446 m_bitmap = adopt Ptr(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));446 m_bitmap = adoptGDIObject(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0)); 447 447 448 448 // Dirty the window so the HUD draws … … 488 488 void FullscreenVideoController::draw() 489 489 { 490 OwnPtr<HDC> bitmapDC = adoptPtr(CreateCompatibleDC(HWndDC(m_hudWindow)));490 auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(HWndDC(m_hudWindow))); 491 491 HGDIOBJ oldBitmap = SelectObject(bitmapDC.get(), m_bitmap.get()); 492 492 -
trunk/Source/WebKit/win/FullscreenVideoController.h
r82120 r155454 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 #include <WebCore/IntSize.h> 37 37 #include <wtf/RefPtr.h> 38 #include <wtf/win/GDIObject.h> 38 39 39 40 namespace WebCore { … … 154 155 155 156 HWND m_hudWindow; 156 OwnPtr<HBITMAP> m_bitmap;157 GDIObject<HBITMAP> m_bitmap; 157 158 WebCore::IntSize m_fullscreenSize; 158 159 WebCore::IntPoint m_hudPosition; -
trunk/Source/WebKit/win/WebCoreSupport/EmbeddedWidget.cpp
r154877 r155454 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.2 * Copyright (C) 2008, 2013 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include <WebCore/HTMLPlugInElement.h> 32 32 #include <WebCore/RenderObject.h> 33 #include <wtf/win/GDIObject.h> 33 34 34 35 #include "MemoryStream.h" … … 110 111 return; 111 112 112 HRGN rgn;113 114 113 // To prevent flashes while scrolling, we disable drawing during the window 115 114 // update process by clipping the window to the zero rect. … … 118 117 119 118 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); 122 121 } 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); 125 124 } 126 125 … … 129 128 130 129 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); 133 132 } 134 133 } -
trunk/Source/WebKit/win/WebNodeHighlight.cpp
r114499 r155454 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 #include <wtf/HashSet.h> 41 41 #include <wtf/OwnPtr.h> 42 #include <wtf/win/GDIObject.h> 42 43 43 44 using namespace WebCore; … … 141 142 ASSERT(m_overlay); 142 143 143 HDC hdc = ::CreateCompatibleDC(HWndDC(m_overlay));144 auto hdc = adoptGDIObject(::CreateCompatibleDC(HWndDC(m_overlay))); 144 145 if (!hdc) 145 146 return; … … 158 159 159 160 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)); 161 162 ASSERT_WITH_MESSAGE(hbmp, "::CreateDIBSection failed with error %lu", ::GetLastError()); 162 163 163 ::SelectObject(hdc , hbmp.get());164 165 GraphicsContext context(hdc );164 ::SelectObject(hdc.get(), hbmp.get()); 165 166 GraphicsContext context(hdc.get()); 166 167 #if ENABLE(INSPECTOR) 167 168 m_inspectedWebView->page()->inspectorController()->drawHighlight(context); … … 182 183 dstPoint.y = webViewRect.top; 183 184 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); 186 186 } 187 187 -
trunk/Source/WebKit/win/WebView.cpp
r155194 r155454 181 181 #include <wtf/text/CString.h> 182 182 #include <wtf/text/StringConcatenate.h> 183 #include <wtf/win/GDIObject.h> 183 184 184 185 // Soft link functions for gestures and panning feedback … … 894 895 // Collect our device context info and select the bitmap to scroll. 895 896 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()); 898 899 899 900 // Scroll the bitmap. 900 901 RECT scrollRectWin(scrollViewRect); 901 902 RECT clipRectWin(clipRect); 902 ::ScrollDC(bitmapDC , dx, dy, &scrollRectWin, &clipRectWin, updateRegion, 0);903 ::ScrollDC(bitmapDC.get(), dx, dy, &scrollRectWin, &clipRectWin, updateRegion, 0); 903 904 RECT regionBox; 904 905 ::GetRgnBox(updateRegion, ®ionBox); … … 914 915 915 916 // Update the backing store. 916 updateBackingStore(frameView, bitmapDC , false);917 updateBackingStore(frameView, bitmapDC.get(), false); 917 918 918 919 // Clean up. 919 ::SelectObject(bitmapDC, oldBitmap); 920 ::DeleteDC(bitmapDC); 920 ::SelectObject(bitmapDC.get(), oldBitmap); 921 921 } 922 922 … … 988 988 LOCAL_GDI_COUNTER(0, __FUNCTION__); 989 989 990 GDIObject<HDC> bitmapDCObject; 991 990 992 HDC bitmapDC = dc; 991 993 HGDIOBJ oldBitmap = 0; 992 994 if (!dc) { 993 995 HWndDC windowDC(m_viewWindow); 994 bitmapDC = ::CreateCompatibleDC(windowDC); 996 bitmapDCObject = adoptGDIObject(::CreateCompatibleDC(windowDC)); 997 bitmapDC = bitmapDCObject.get(); 995 998 oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle()); 996 999 } … … 1022 1025 } 1023 1026 1024 if (!dc) {1027 if (!dc) 1025 1028 ::SelectObject(bitmapDC, oldBitmap); 1026 ::DeleteDC(bitmapDC);1027 }1028 1029 1029 1030 GdiFlush(); … … 1037 1038 1038 1039 HWndDC hdcScreen(m_viewWindow); 1039 OwnPtr<HDC> hdcMem = adoptPtr(::CreateCompatibleDC(hdcScreen));1040 auto hdcMem = adoptGDIObject(::CreateCompatibleDC(hdcScreen)); 1040 1041 HBITMAP hbmOld = static_cast<HBITMAP>(::SelectObject(hdcMem.get(), m_backingStoreBitmap->handle())); 1041 1042 … … 1111 1112 m_paintCount++; 1112 1113 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()); 1115 1116 1116 1117 // Update our backing store if needed. 1117 updateBackingStore(frameView, bitmapDC , backingStoreCompletelyDirty, windowsToPaint);1118 updateBackingStore(frameView, bitmapDC.get(), backingStoreCompletelyDirty, windowsToPaint); 1118 1119 1119 1120 // Now we blit the updated backing store … … 1128 1129 1129 1130 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); 1134 1134 1135 1135 if (!dc) … … 1161 1161 { 1162 1162 HWndDC dc(m_viewWindow); 1163 OwnPtr<HBRUSH> yellowBrush(CreateSolidBrush(RGB(255, 255, 0)));1163 auto yellowBrush = adoptGDIObject(::CreateSolidBrush(RGB(255, 255, 0))); 1164 1164 FillRect(dc, &rect, yellowBrush.get()); 1165 1165 GdiFlush(); … … 1198 1198 LOCAL_GDI_COUNTER(0, __FUNCTION__); 1199 1199 #if FLASH_WINDOW_REDRAW 1200 OwnPtr<HBRUSH> greenBrush = CreateSolidBrush(RGB(0, 255, 0));1200 auto greenBrush = adoptGDIObject(::CreateSolidBrush(RGB(0, 255, 0))); 1201 1201 RECT rect = dirtyRect; 1202 1202 FillRect(windowDC, &rect, greenBrush.get()); … … 3578 3578 WebCore::Frame& frame = m_page->focusController().focusedOrMainFrame(); 3579 3579 3580 OwnPtr<HBITMAP>bitmap = imageFromSelection(&frame, forceWhiteText ? TRUE : FALSE);3581 *hBitmap = static_cast<OLE_HANDLE>(reinterpret_cast<ULONG64>(bitmap.leak Ptr()));3580 auto bitmap = imageFromSelection(&frame, forceWhiteText ? TRUE : FALSE); 3581 *hBitmap = static_cast<OLE_HANDLE>(reinterpret_cast<ULONG64>(bitmap.leak())); 3582 3582 3583 3583 return S_OK; -
trunk/Tools/ChangeLog
r155453 r155454 1 2013-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 1 16 2013-09-10 Víctor Manuel Jáquez Leal <vjaquez@igalia.com> 2 17 -
trunk/Tools/DumpRenderTree/win/PixelDumpSupportWin.cpp
r149716 r155454 1 1 /* 2 * Copyright (C) 2007 Apple, Inc. All rights reserved.2 * Copyright (C) 2007, 2013 Apple, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 44 44 #include <wtf/Assertions.h> 45 45 #include <wtf/RetainPtr.h> 46 #include <wtf/win/GDIObject.h> 46 47 47 48 static void makeAlphaChannelOpaque(void* argbBits, LONG width, LONG height) … … 71 72 HBITMAP bitmap = CreateDIBSection(0, &bmp, DIB_RGB_COLORS, &bits, 0, 0); 72 73 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); 77 77 78 78 BITMAP info = {0}; -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r152748 r155454 1731 1731 1732 1732 matched_create_dc = search(r'\b(?P<function_name>Create(Compatible)?DC)\s*\(', line) 1733 matched_own_dc = search(r'\badopt Ptr\b', line)1733 matched_own_dc = search(r'\badoptGDIObject\b', line) 1734 1734 if matched_create_dc and not matched_own_dc: 1735 1735 error(line_number, 'runtime/leaky_pattern', 5, 1736 'Use adopt Ptr and OwnPtr<HDC> when calling %s to avoid potential '1736 'Use adoptGDIObject and GDIObject<HDC> when calling %s to avoid potential ' 1737 1737 'memory leaks.' % matched_create_dc.group('function_name')) 1738 1738 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r152748 r155454 3527 3527 self.assert_leaky_pattern_check( 3528 3528 'HDC dc2 = ::CreateDC();', 3529 'Use adopt Ptr and OwnPtr<HDC> when calling CreateDC to avoid potential '3529 'Use adoptGDIObject and GDIObject<HDC> when calling CreateDC to avoid potential ' 3530 3530 'memory leaks. [runtime/leaky_pattern] [5]') 3531 3531 3532 3532 self.assert_leaky_pattern_check( 3533 'adopt Ptr(CreateDC());',3533 'adoptGDIObject(CreateDC());', 3534 3534 '') 3535 3535 … … 3537 3537 self.assert_leaky_pattern_check( 3538 3538 'HDC dc2 = CreateCompatibleDC(dc);', 3539 'Use adopt Ptr and OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential '3539 'Use adoptGDIObject and GDIObject<HDC> when calling CreateCompatibleDC to avoid potential ' 3540 3540 'memory leaks. [runtime/leaky_pattern] [5]') 3541 3541 self.assert_leaky_pattern_check( 3542 'adopt Ptr(CreateCompatibleDC(dc));',3542 'adoptGDIObject(CreateCompatibleDC(dc));', 3543 3543 '') 3544 3544
Note: See TracChangeset
for help on using the changeset viewer.