Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The deprecated, non-standard and internal only
method of the Canvas 2D API renders a region of a window into the
The contents of the window's viewport are rendered, ignoring viewport clipping and
This API cannot be used by Web content. It is synchronous, and as such can't capture
cross-origin (out of process) iframes with Fission. If you're using it from an
extension, you should switch to
tabs.captureTab to capture the
tab's image as a data: URL and then render the captured image onto canvas using
CanvasRenderingContext2D.drawImage. If you're writing chrome code,
you probably want WindowGlobalParent.drawSnapshot
from the parent process.
drawWindow(window, x, y, w, h, bgColor) drawWindow(window, x, y, w, h, bgColor, flags)
The x-axis coordinate of the window.
The y-axis coordinate of the window.
The width of the window.
The height of the window.
A string that specifies the color the canvas is filled with before the window is rendered into it. This color may be transparent/translucent. It is given as a CSS color string (for example,
rgba(0,0,0,0)" is used for the background color, the drawing will be transparent wherever the window is transparent.
- Top-level browsed documents are usually not transparent because the user's background-color preference is applied, but iframes are transparent if the page doesn't set a background.
- If an opaque color is used for the background color, rendering will be faster because we won't have to compute the window's transparency.
- If "
Used to better control the
drawWindowcall. Several flags can be set at the same time, by grouping them with an or (
Show the caret if appropriate when drawing.
Do not flush pending layout notifications that could otherwise be batched up.
Draw scrollbars and scroll the viewport if they are present.
Use the widget layer manager if available. This means hardware acceleration may be used, but it might actually be slower or lower quality than normal. It will, however, more accurately reflect the pixels rendered to the screen.
Do not synchronously decode images: draw what we have.
This method draws a snapshot of the contents of a DOM
window into the
canvas. For example,
ctx.drawWindow(window, 0, 0, 100, 200, 'rgb(255,255,255)');
... would draw the contents of the current window, in the rectangle (0,0,100,200) in
pixels relative to the top-left of the viewport, on a white background, into the canvas.
By specifying "
rgba(255,255,255,0)" as the color, the contents would be
drawn with a transparent background (which would be slower).
It is usually a bad idea to use any background other than pure white
rgb(255,255,255)" or transparent, as this is what all browsers do, and
many websites expect that transparent parts of their interface will be drawn on white
With this method, it is possible to fill a hidden IFRAME with arbitrary content (e.g., CSS-styled HTML text, or SVG) and draw it into a canvas. It will be scaled, rotated and so on according to the current transformation.
Ted Mielczarek's tab preview extension uses this technique in chrome to provide thumbnails of web pages, and the source is available for reference.
Not part of any current specification or draft. This is a non-standard and internal only API.
BCD tables only load in the browser