Skip to content

Commit

Permalink
Support for webkit-transform (thanks Nate Weaver)
Browse files Browse the repository at this point in the history
As noted in #13, the method
we used to capture the contents of the window didn't work with
webkit-transform. Nate Weaver (@Wevar) provided some nifty code that should
fix this when run on Mac OS X 10.5 or later whilst still letting the script
run on older versions.

Only problem is that I've only been able to test this on 10.7, 10.6 and 10.5.
I don't think many people are running webkit2png on older OS versions so this
should be OK.
  • Loading branch information
paulhammond committed Nov 30, 2011
1 parent dc311ce commit 2bf1cc9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions webkit2png
Expand Up @@ -158,12 +158,16 @@ class WebkitLoad (Foundation.NSObject, WebKit.protocols.WebFrameLoadDelegate):
view.setFrame_(view.bounds()) view.setFrame_(view.bounds())


def captureView(self,view): def captureView(self,view):
view.lockFocus() if hasattr(view, "bitmapImageRepForCachingDisplayInRect_"):
bitmapdata = AppKit.NSBitmapImageRep.alloc() bitmapdata = view.bitmapImageRepForCachingDisplayInRect_(view.bounds())
bitmapdata.initWithFocusedViewRect_(view.bounds()) view.cacheDisplayInRect_toBitmapImageRep_(view.bounds(), bitmapdata)
view.unlockFocus() else:
view.lockFocus()
bitmapdata = AppKit.NSBitmapImageRep.alloc()
bitmapdata.initWithFocusedViewRect_(view.bounds())
view.unlockFocus()
return bitmapdata return bitmapdata

# what happens when the page has finished loading # what happens when the page has finished loading
def webView_didFinishLoadForFrame_(self,webview,frame): def webView_didFinishLoadForFrame_(self,webview,frame):
# don't care about subframes # don't care about subframes
Expand Down

0 comments on commit 2bf1cc9

Please sign in to comment.