Closed
Bug 460073
Opened 17 years ago
Closed 15 years ago
Add a simple wrapper for rendering HTML content to an image
Categories
(Core Graveyard :: Embedding: APIs, defect)
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 596743
People
(Reporter: mfinkle, Assigned: mfinkle)
Details
Attachments
(1 file)
|
3.91 KB,
patch
|
roc
:
review-
|
Details | Diff | Splinter Review |
Since the embedding wrappers use standalone linking, we can't just clone the canvas::drawWindow code into the wrapper layer. The thebes code require dependent linking.
So, I'm going to try to add a method to nsIDOMWindowUtils. The method should return a safe interface, not raw bits. The embedding wrapper layer can pull out the raw bits.
| Assignee | ||
Updated•17 years ago
|
Assignee: nobody → mark.finkle
| Assignee | ||
Comment 1•17 years ago
|
||
This patch adds drawWindow to nsIDOMWindowUtils. The method works in a similar way to the canvas version, without any security checks since you must be chrome to access nsIDOMWindowUtils anyway.
The method also requires the caller pass in an image encoder. After the call completes the caller can do what they want with the encoded data.
I'll attach a simple example of a caller next.
Attachment #343997 -
Flags: review?(roc)
| Assignee | ||
Comment 2•17 years ago
|
||
... assume domWindow is an instance of nsIDOMWindow
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(domWindow);
if (utils) {
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance("@mozilla.org/image/encoder;2?type=image/png");
rv = utils->DrawWindow(0, 0, 1000, 1000, NS_RGB(255, 255, 255), encoder);
nsAutoString fileName(NS_LITERAL_STRING("e:\\dummy-new.png"));
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
rv = file->InitWithPath(fileName);
PRUint32 length;
encoder->Available(&length);
nsCOMPtr<nsIOutputStream> outputStream;
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), file);
nsCOMPtr<nsIOutputStream> bufferedOutputStream;
rv = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream), outputStream, length);
PRUint32 numWritten;
rv = bufferedOutputStream->WriteFrom(encoder, length, &numWritten);
}
Wouldn't it make more sense to render the window contents into a platform-specific graphics surface, or possibly a raw RGBA pixel buffer? It seems to me that will be wanted far more often than a PNG or other compressed format.
| Assignee | ||
Comment 4•17 years ago
|
||
> Wouldn't it make more sense to render the window contents into a
> platform-specific graphics surface, or possibly a raw RGBA pixel buffer? It
> seems to me that will be wanted far more often than a PNG or other compressed
> format.
More detail from IRC: roc suggests passing a platform specific structure, like HDC on Windows, would make more sense from an embedding standpoint. We could also request PDF and SVG easier this way. The IDL would change to a: voidPtr and an enum to specify the type of structure.
This means the method is no longer scriptable (yes, attachment 343997 [details] [diff] [review] can be called from JS too). This shouldn't be a big concern.
roc also mentioned the idea of moving this from nsIDOMWindowUtils and creating a component explicitly for embedding.
Comment 5•17 years ago
|
||
it makes more sense to me to use thebes here, than try to reinvent platform surfaces.
We can't expose Thebes to embedders, or glue code in the embedding layer, since they can't link to the Thebes symbols. (See comment #0.)
Anyway, the simplest possible API for embedders is not Thebes but just to pass in an HDC or whatever. Once we get that HDC across to libxul, sure, the first thing we do is wrap it in a gfxWindowsSurface.
Comment on attachment 343997 [details] [diff] [review]
adds drawWindow to nsIDOMWindowUtils
I presume this is no longer needed
Attachment #343997 -
Flags: review?(roc) → review-
Comment 8•15 years ago
|
||
(In reply to comment #7)
> Comment on attachment 343997 [details] [diff] [review]
> adds drawWindow to nsIDOMWindowUtils
>
> I presume this is no longer needed
Needed
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
Updated•6 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•