Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support for webkit-transform (thanks Nate Weaver)

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...
commit 2bf1cc93b5a4652bfd28a26c66ddc5f4eec2eda2 1 parent dc311ce
@paulhammond authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 webkit2png
View
14 webkit2png
@@ -158,12 +158,16 @@ class WebkitLoad (Foundation.NSObject, WebKit.protocols.WebFrameLoadDelegate):
view.setFrame_(view.bounds())
def captureView(self,view):
- view.lockFocus()
- bitmapdata = AppKit.NSBitmapImageRep.alloc()
- bitmapdata.initWithFocusedViewRect_(view.bounds())
- view.unlockFocus()
+ if hasattr(view, "bitmapImageRepForCachingDisplayInRect_"):
+ bitmapdata = view.bitmapImageRepForCachingDisplayInRect_(view.bounds())
+ view.cacheDisplayInRect_toBitmapImageRep_(view.bounds(), bitmapdata)
+ else:
+ view.lockFocus()
+ bitmapdata = AppKit.NSBitmapImageRep.alloc()
+ bitmapdata.initWithFocusedViewRect_(view.bounds())
+ view.unlockFocus()
return bitmapdata
-
+
# what happens when the page has finished loading
def webView_didFinishLoadForFrame_(self,webview,frame):
# don't care about subframes
Please sign in to comment.
Something went wrong with that request. Please try again.