diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-06-22 16:06:39 +0100 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-06-22 16:06:39 +0100 |
commit | 0f0555776f0d7b4f2d54730d236ae4ad621d0689 (patch) | |
tree | 75158c0e13aa7937f4b3216f3ee000acc9ddce9f /meta/packages/mozilla-headless | |
parent | 18b5cd7ba2fc0c4d155accd709201f3fe26b38f7 (diff) | |
download | poky-0f0555776f0d7b4f2d54730d236ae4ad621d0689.tar.gz |
mozilla-headless: Add patches for revision a3e7c6626661
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/packages/mozilla-headless')
5 files changed, 2334 insertions, 0 deletions
diff --git a/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/0001-Adds-initial-Gtk-clipboard-support-to-moz-headless.patch b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/0001-Adds-initial-Gtk-clipboard-support-to-moz-headless.patch new file mode 100644 index 0000000000..b3972e78f7 --- /dev/null +++ b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/0001-Adds-initial-Gtk-clipboard-support-to-moz-headless.patch | |||
@@ -0,0 +1,1486 @@ | |||
1 | From fb41f028badb4dfddfc47fb2a1a68c1aa90dcef5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Robert Bragg <robert@linux.intel.com> | ||
3 | Date: Fri, 8 May 2009 13:57:22 +0100 | ||
4 | Subject: [PATCH] Adds initial Gtk clipboard support to moz-headless | ||
5 | |||
6 | If build with MOZ_X11 enabled then this now builds the clipboard code taken | ||
7 | from the gtk2 backend. This doesn't provide any embedding API yet to expose | ||
8 | the clipboard. | ||
9 | --- | ||
10 | widget/src/headless/Makefile.in | 6 + | ||
11 | widget/src/headless/nsClipboard.cpp | 948 +++++++++++++++++++++++++++++++ | ||
12 | widget/src/headless/nsClipboard.h | 93 +++ | ||
13 | widget/src/headless/nsIImageToPixbuf.h | 62 ++ | ||
14 | widget/src/headless/nsImageToPixbuf.cpp | 196 +++++++ | ||
15 | widget/src/headless/nsImageToPixbuf.h | 71 +++ | ||
16 | widget/src/headless/nsWidgetFactory.cpp | 18 + | ||
17 | 7 files changed, 1394 insertions(+), 0 deletions(-) | ||
18 | create mode 100644 widget/src/headless/nsClipboard.cpp | ||
19 | create mode 100644 widget/src/headless/nsClipboard.h | ||
20 | create mode 100644 widget/src/headless/nsIImageToPixbuf.h | ||
21 | create mode 100644 widget/src/headless/nsImageToPixbuf.cpp | ||
22 | create mode 100644 widget/src/headless/nsImageToPixbuf.h | ||
23 | |||
24 | diff --git a/widget/src/headless/Makefile.in b/widget/src/headless/Makefile.in | ||
25 | index c8727d9..cbdf900 100644 | ||
26 | --- a/widget/src/headless/Makefile.in | ||
27 | +++ b/widget/src/headless/Makefile.in | ||
28 | @@ -95,6 +95,12 @@ CPPSRCS = \ | ||
29 | nsScreenManagerHeadless.cpp \ | ||
30 | $(NULL) | ||
31 | |||
32 | +ifdef MOZ_X11 | ||
33 | +CPPSRCS += nsClipboard.cpp \ | ||
34 | + nsImageToPixbuf.cpp \ | ||
35 | + $(NULL) | ||
36 | +endif | ||
37 | + | ||
38 | # build our subdirs, too | ||
39 | SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a | ||
40 | |||
41 | diff --git a/widget/src/headless/nsClipboard.cpp b/widget/src/headless/nsClipboard.cpp | ||
42 | new file mode 100644 | ||
43 | index 0000000..72a37fc | ||
44 | --- /dev/null | ||
45 | +++ b/widget/src/headless/nsClipboard.cpp | ||
46 | @@ -0,0 +1,948 @@ | ||
47 | +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
48 | +/* vim:expandtab:shiftwidth=4:tabstop=4: | ||
49 | + */ | ||
50 | +/* ***** BEGIN LICENSE BLOCK ***** | ||
51 | + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
52 | + * | ||
53 | + * The contents of this file are subject to the Mozilla Public License Version | ||
54 | + * 1.1 (the "License"); you may not use this file except in compliance with | ||
55 | + * the License. You may obtain a copy of the License at | ||
56 | + * http://www.mozilla.org/MPL/ | ||
57 | + * | ||
58 | + * Software distributed under the License is distributed on an "AS IS" basis, | ||
59 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
60 | + * for the specific language governing rights and limitations under the | ||
61 | + * License. | ||
62 | + * | ||
63 | + * The Original Code is mozilla.org code. | ||
64 | + * | ||
65 | + * The Initial Developer of the Original Code is Christopher Blizzard | ||
66 | + * <blizzard@mozilla.org>. Portions created by the Initial Developer | ||
67 | + * are Copyright (C) 2001 the Initial Developer. All Rights Reserved. | ||
68 | + * | ||
69 | + * Contributor(s): | ||
70 | + * | ||
71 | + * Alternatively, the contents of this file may be used under the terms of | ||
72 | + * either the GNU General Public License Version 2 or later (the "GPL"), or | ||
73 | + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
74 | + * in which case the provisions of the GPL or the LGPL are applicable instead | ||
75 | + * of those above. If you wish to allow use of your version of this file only | ||
76 | + * under the terms of either the GPL or the LGPL, and not to allow others to | ||
77 | + * use your version of this file under the terms of the MPL, indicate your | ||
78 | + * decision by deleting the provisions above and replace them with the notice | ||
79 | + * and other provisions required by the GPL or the LGPL. If you do not delete | ||
80 | + * the provisions above, a recipient may use your version of this file under | ||
81 | + * the terms of any one of the MPL, the GPL or the LGPL. | ||
82 | + * | ||
83 | + * ***** END LICENSE BLOCK ***** */ | ||
84 | + | ||
85 | +#include "nsClipboard.h" | ||
86 | +#include "nsSupportsPrimitives.h" | ||
87 | +#include "nsString.h" | ||
88 | +#include "nsReadableUtils.h" | ||
89 | +#include "nsXPIDLString.h" | ||
90 | +#include "nsPrimitiveHelpers.h" | ||
91 | +#include "nsICharsetConverterManager.h" | ||
92 | +#include "nsIServiceManager.h" | ||
93 | +#include "nsIImage.h" | ||
94 | +#include "nsImageToPixbuf.h" | ||
95 | +#include "nsStringStream.h" | ||
96 | + | ||
97 | +#include <gtk/gtk.h> | ||
98 | + | ||
99 | +// For manipulation of the X event queue | ||
100 | +#include <X11/Xlib.h> | ||
101 | +#include <gdk/gdkx.h> | ||
102 | +#include <sys/time.h> | ||
103 | +#include <sys/types.h> | ||
104 | +#include <unistd.h> | ||
105 | + | ||
106 | +#ifdef POLL_WITH_XCONNECTIONNUMBER | ||
107 | +#include <poll.h> | ||
108 | +#endif | ||
109 | + | ||
110 | +// Callback when someone asks us for the selection | ||
111 | +void | ||
112 | +invisible_selection_get_cb (GtkWidget *aWidget, | ||
113 | + GtkSelectionData *aSelectionData, | ||
114 | + guint aTime, | ||
115 | + guint aInfo, | ||
116 | + nsClipboard *aClipboard); | ||
117 | + | ||
118 | +gboolean | ||
119 | +selection_clear_event_cb (GtkWidget *aWidget, | ||
120 | + GdkEventSelection *aEvent, | ||
121 | + nsClipboard *aClipboard); | ||
122 | + | ||
123 | +static void | ||
124 | +ConvertHTMLtoUCS2 (guchar *data, | ||
125 | + PRInt32 dataLength, | ||
126 | + PRUnichar **unicodeData, | ||
127 | + PRInt32 &outUnicodeLen); | ||
128 | + | ||
129 | +static void | ||
130 | +GetHTMLCharset (guchar * data, PRInt32 dataLength, nsCString& str); | ||
131 | + | ||
132 | + | ||
133 | +// Our own versions of gtk_clipboard_wait_for_contents and | ||
134 | +// gtk_clipboard_wait_for_text, which don't run the event loop while | ||
135 | +// waiting for the data. This prevents a lot of problems related to | ||
136 | +// dispatching events at unexpected times. | ||
137 | + | ||
138 | +static GtkSelectionData * | ||
139 | +wait_for_contents (GtkClipboard *clipboard, GdkAtom target); | ||
140 | + | ||
141 | +static gchar * | ||
142 | +wait_for_text (GtkClipboard *clipboard); | ||
143 | + | ||
144 | +static Bool | ||
145 | +checkEventProc(Display *display, XEvent *event, XPointer arg); | ||
146 | + | ||
147 | +struct retrieval_context | ||
148 | +{ | ||
149 | + PRBool completed; | ||
150 | + void *data; | ||
151 | + | ||
152 | + retrieval_context() : completed(PR_FALSE), data(nsnull) { } | ||
153 | +}; | ||
154 | + | ||
155 | +static void | ||
156 | +wait_for_retrieval(GtkClipboard *clipboard, retrieval_context *transferData); | ||
157 | + | ||
158 | +static void | ||
159 | +clipboard_contents_received(GtkClipboard *clipboard, | ||
160 | + GtkSelectionData *selection_data, | ||
161 | + gpointer data); | ||
162 | + | ||
163 | +static void | ||
164 | +clipboard_text_received(GtkClipboard *clipboard, | ||
165 | + const gchar *text, | ||
166 | + gpointer data); | ||
167 | + | ||
168 | +nsClipboard::nsClipboard() | ||
169 | +{ | ||
170 | + mWidget = nsnull; | ||
171 | +} | ||
172 | + | ||
173 | +nsClipboard::~nsClipboard() | ||
174 | +{ | ||
175 | + if (mWidget) | ||
176 | + gtk_widget_destroy(mWidget); | ||
177 | +} | ||
178 | + | ||
179 | +NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard) | ||
180 | + | ||
181 | +nsresult | ||
182 | +nsClipboard::Init(void) | ||
183 | +{ | ||
184 | + mWidget = gtk_invisible_new(); | ||
185 | + if (!mWidget) | ||
186 | + return NS_ERROR_FAILURE; | ||
187 | + | ||
188 | + g_signal_connect(G_OBJECT(mWidget), "selection_get", | ||
189 | + G_CALLBACK(invisible_selection_get_cb), this); | ||
190 | + | ||
191 | + g_signal_connect(G_OBJECT(mWidget), "selection_clear_event", | ||
192 | + G_CALLBACK(selection_clear_event_cb), this); | ||
193 | + | ||
194 | + // XXX make sure to set up the selection_clear event | ||
195 | + | ||
196 | + return NS_OK; | ||
197 | +} | ||
198 | + | ||
199 | +NS_IMETHODIMP | ||
200 | +nsClipboard::SetData(nsITransferable *aTransferable, | ||
201 | + nsIClipboardOwner *aOwner, PRInt32 aWhichClipboard) | ||
202 | +{ | ||
203 | + // See if we can short cut | ||
204 | + if ((aWhichClipboard == kGlobalClipboard && | ||
205 | + aTransferable == mGlobalTransferable.get() && | ||
206 | + aOwner == mGlobalOwner.get()) || | ||
207 | + (aWhichClipboard == kSelectionClipboard && | ||
208 | + aTransferable == mSelectionTransferable.get() && | ||
209 | + aOwner == mSelectionOwner.get())) { | ||
210 | + return NS_OK; | ||
211 | + } | ||
212 | + | ||
213 | + nsresult rv; | ||
214 | + if (!mPrivacyHandler) { | ||
215 | + rv = NS_NewClipboardPrivacyHandler(getter_AddRefs(mPrivacyHandler)); | ||
216 | + NS_ENSURE_SUCCESS(rv, rv); | ||
217 | + } | ||
218 | + rv = mPrivacyHandler->PrepareDataForClipboard(aTransferable); | ||
219 | + NS_ENSURE_SUCCESS(rv, rv); | ||
220 | + | ||
221 | + // Clear out the clipboard in order to set the new data | ||
222 | + EmptyClipboard(aWhichClipboard); | ||
223 | + | ||
224 | + if (aWhichClipboard == kSelectionClipboard) { | ||
225 | + mSelectionOwner = aOwner; | ||
226 | + mSelectionTransferable = aTransferable; | ||
227 | + } | ||
228 | + else { | ||
229 | + mGlobalOwner = aOwner; | ||
230 | + mGlobalTransferable = aTransferable; | ||
231 | + } | ||
232 | + | ||
233 | + // Which selection are we about to claim, CLIPBOARD or PRIMARY? | ||
234 | + GdkAtom selectionAtom = GetSelectionAtom(aWhichClipboard); | ||
235 | + | ||
236 | + // Make ourselves the owner. If we fail to, return. | ||
237 | + if (!gtk_selection_owner_set(mWidget, selectionAtom, GDK_CURRENT_TIME)) | ||
238 | + return NS_ERROR_FAILURE; | ||
239 | + | ||
240 | + // Clear the old selection target list. | ||
241 | + gtk_selection_clear_targets(mWidget, selectionAtom); | ||
242 | + | ||
243 | + // Get the types of supported flavors | ||
244 | + nsCOMPtr<nsISupportsArray> flavors; | ||
245 | + | ||
246 | + rv = aTransferable->FlavorsTransferableCanExport(getter_AddRefs(flavors)); | ||
247 | + if (!flavors || NS_FAILED(rv)) | ||
248 | + return NS_ERROR_FAILURE; | ||
249 | + | ||
250 | + // Add all the flavors to this widget's supported type. | ||
251 | + PRUint32 count; | ||
252 | + flavors->Count(&count); | ||
253 | + for (PRUint32 i=0; i < count; i++) { | ||
254 | + nsCOMPtr<nsISupports> tastesLike; | ||
255 | + flavors->GetElementAt(i, getter_AddRefs(tastesLike)); | ||
256 | + nsCOMPtr<nsISupportsCString> flavor = do_QueryInterface(tastesLike); | ||
257 | + | ||
258 | + if (flavor) { | ||
259 | + nsXPIDLCString flavorStr; | ||
260 | + flavor->ToString(getter_Copies(flavorStr)); | ||
261 | + | ||
262 | + // special case text/unicode since we can handle all of | ||
263 | + // the string types | ||
264 | + if (!strcmp(flavorStr, kUnicodeMime)) { | ||
265 | + AddTarget(gdk_atom_intern("UTF8_STRING", FALSE), | ||
266 | + selectionAtom); | ||
267 | + AddTarget(gdk_atom_intern("COMPOUND_TEXT", FALSE), | ||
268 | + selectionAtom); | ||
269 | + AddTarget(gdk_atom_intern("TEXT", FALSE), selectionAtom); | ||
270 | + AddTarget(GDK_SELECTION_TYPE_STRING, selectionAtom); | ||
271 | + // next loop iteration | ||
272 | + continue; | ||
273 | + } | ||
274 | + | ||
275 | + // very special case for this one. since our selection mechanism doesn't work for images, | ||
276 | + // we must use GTK's clipboard utility functions | ||
277 | + if (!strcmp(flavorStr, kNativeImageMime) || !strcmp(flavorStr, kPNGImageMime) || | ||
278 | + !strcmp(flavorStr, kJPEGImageMime) || !strcmp(flavorStr, kGIFImageMime)) { | ||
279 | + nsCOMPtr<nsISupports> item; | ||
280 | + PRUint32 len; | ||
281 | + rv = aTransferable->GetTransferData(flavorStr, getter_AddRefs(item), &len); | ||
282 | + nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive(do_QueryInterface(item)); | ||
283 | + if (!ptrPrimitive) | ||
284 | + continue; | ||
285 | + | ||
286 | + nsCOMPtr<nsISupports> primitiveData; | ||
287 | + ptrPrimitive->GetData(getter_AddRefs(primitiveData)); | ||
288 | + nsCOMPtr<nsIImage> image(do_QueryInterface(primitiveData)); | ||
289 | + if (!image) // Not getting an image for an image mime type!? | ||
290 | + continue; | ||
291 | + | ||
292 | + if (NS_FAILED(image->LockImagePixels(PR_FALSE))) | ||
293 | + continue; | ||
294 | + GdkPixbuf* pixbuf = nsImageToPixbuf::ImageToPixbuf(image); | ||
295 | + if (!pixbuf) { | ||
296 | + image->UnlockImagePixels(PR_FALSE); | ||
297 | + continue; | ||
298 | + } | ||
299 | + | ||
300 | + GtkClipboard *aClipboard = gtk_clipboard_get(GetSelectionAtom(aWhichClipboard)); | ||
301 | + gtk_clipboard_set_image(aClipboard, pixbuf); | ||
302 | + g_object_unref(pixbuf); | ||
303 | + image->UnlockImagePixels(PR_FALSE); | ||
304 | + continue; | ||
305 | + } | ||
306 | + | ||
307 | + // Add this to our list of valid targets | ||
308 | + GdkAtom atom = gdk_atom_intern(flavorStr, FALSE); | ||
309 | + AddTarget(atom, selectionAtom); | ||
310 | + } | ||
311 | + } | ||
312 | + | ||
313 | + return NS_OK; | ||
314 | +} | ||
315 | + | ||
316 | +NS_IMETHODIMP | ||
317 | +nsClipboard::GetData(nsITransferable *aTransferable, PRInt32 aWhichClipboard) | ||
318 | +{ | ||
319 | + if (!aTransferable) | ||
320 | + return NS_ERROR_FAILURE; | ||
321 | + | ||
322 | + GtkClipboard *clipboard; | ||
323 | + clipboard = gtk_clipboard_get(GetSelectionAtom(aWhichClipboard)); | ||
324 | + | ||
325 | + guchar *data = NULL; | ||
326 | + gint length = 0; | ||
327 | + PRBool foundData = PR_FALSE; | ||
328 | + nsCAutoString foundFlavor; | ||
329 | + | ||
330 | + // Get a list of flavors this transferable can import | ||
331 | + nsCOMPtr<nsISupportsArray> flavors; | ||
332 | + nsresult rv; | ||
333 | + rv = aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavors)); | ||
334 | + if (!flavors || NS_FAILED(rv)) | ||
335 | + return NS_ERROR_FAILURE; | ||
336 | + | ||
337 | + PRUint32 count; | ||
338 | + flavors->Count(&count); | ||
339 | + for (PRUint32 i=0; i < count; i++) { | ||
340 | + nsCOMPtr<nsISupports> genericFlavor; | ||
341 | + flavors->GetElementAt(i, getter_AddRefs(genericFlavor)); | ||
342 | + | ||
343 | + nsCOMPtr<nsISupportsCString> currentFlavor; | ||
344 | + currentFlavor = do_QueryInterface(genericFlavor); | ||
345 | + | ||
346 | + if (currentFlavor) { | ||
347 | + nsXPIDLCString flavorStr; | ||
348 | + currentFlavor->ToString(getter_Copies(flavorStr)); | ||
349 | + | ||
350 | + // Special case text/unicode since we can convert any | ||
351 | + // string into text/unicode | ||
352 | + if (!strcmp(flavorStr, kUnicodeMime)) { | ||
353 | + gchar* new_text = wait_for_text(clipboard); | ||
354 | + if (new_text) { | ||
355 | + // Convert utf-8 into our unicode format. | ||
356 | + NS_ConvertUTF8toUTF16 ucs2string(new_text); | ||
357 | + data = (guchar *)ToNewUnicode(ucs2string); | ||
358 | + length = ucs2string.Length() * 2; | ||
359 | + g_free(new_text); | ||
360 | + foundData = PR_TRUE; | ||
361 | + foundFlavor = kUnicodeMime; | ||
362 | + break; | ||
363 | + } | ||
364 | + // If the type was text/unicode and we couldn't get | ||
365 | + // text off the clipboard, run the next loop | ||
366 | + // iteration. | ||
367 | + continue; | ||
368 | + } | ||
369 | + | ||
370 | + // For images, we must wrap the data in an nsIInputStream then return instead of break, | ||
371 | + // because that code below won't help us. | ||
372 | + if (!strcmp(flavorStr, kJPEGImageMime) || !strcmp(flavorStr, kPNGImageMime) || !strcmp(flavorStr, kGIFImageMime)) { | ||
373 | + GdkAtom atom; | ||
374 | + if (!strcmp(flavorStr, kJPEGImageMime)) // This is image/jpg, but X only understands image/jpeg | ||
375 | + atom = gdk_atom_intern("image/jpeg", FALSE); | ||
376 | + else | ||
377 | + atom = gdk_atom_intern(flavorStr, FALSE); | ||
378 | + | ||
379 | + GtkSelectionData *selectionData = wait_for_contents(clipboard, atom); | ||
380 | + if (!selectionData) | ||
381 | + continue; | ||
382 | + | ||
383 | + nsCOMPtr<nsIInputStream> byteStream; | ||
384 | + NS_NewByteInputStream(getter_AddRefs(byteStream), (const char*)selectionData->data, | ||
385 | + selectionData->length, NS_ASSIGNMENT_COPY); | ||
386 | + aTransferable->SetTransferData(flavorStr, byteStream, sizeof(nsIInputStream*)); | ||
387 | + gtk_selection_data_free(selectionData); | ||
388 | + return NS_OK; | ||
389 | + } | ||
390 | + | ||
391 | + // Get the atom for this type and try to request it off | ||
392 | + // the clipboard. | ||
393 | + GdkAtom atom = gdk_atom_intern(flavorStr, FALSE); | ||
394 | + GtkSelectionData *selectionData; | ||
395 | + selectionData = wait_for_contents(clipboard, atom); | ||
396 | + if (selectionData) { | ||
397 | + length = selectionData->length; | ||
398 | + // Special case text/html since we can convert into UCS2 | ||
399 | + if (!strcmp(flavorStr, kHTMLMime)) { | ||
400 | + PRUnichar* htmlBody= nsnull; | ||
401 | + PRInt32 htmlBodyLen = 0; | ||
402 | + // Convert text/html into our unicode format | ||
403 | + ConvertHTMLtoUCS2((guchar *)selectionData->data, length, | ||
404 | + &htmlBody, htmlBodyLen); | ||
405 | + if (!htmlBodyLen) | ||
406 | + break; | ||
407 | + data = (guchar *)htmlBody; | ||
408 | + length = htmlBodyLen * 2; | ||
409 | + } else { | ||
410 | + data = (guchar *)nsMemory::Alloc(length); | ||
411 | + if (!data) | ||
412 | + break; | ||
413 | + memcpy(data, selectionData->data, length); | ||
414 | + } | ||
415 | + foundData = PR_TRUE; | ||
416 | + foundFlavor = flavorStr; | ||
417 | + break; | ||
418 | + } | ||
419 | + } | ||
420 | + } | ||
421 | + | ||
422 | + if (foundData) { | ||
423 | + nsCOMPtr<nsISupports> wrapper; | ||
424 | + nsPrimitiveHelpers::CreatePrimitiveForData(foundFlavor.get(), | ||
425 | + data, length, | ||
426 | + getter_AddRefs(wrapper)); | ||
427 | + aTransferable->SetTransferData(foundFlavor.get(), | ||
428 | + wrapper, length); | ||
429 | + } | ||
430 | + | ||
431 | + if (data) | ||
432 | + nsMemory::Free(data); | ||
433 | + | ||
434 | + return NS_OK; | ||
435 | +} | ||
436 | + | ||
437 | +NS_IMETHODIMP | ||
438 | +nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard) | ||
439 | +{ | ||
440 | + if (aWhichClipboard == kSelectionClipboard) { | ||
441 | + if (mSelectionOwner) { | ||
442 | + mSelectionOwner->LosingOwnership(mSelectionTransferable); | ||
443 | + mSelectionOwner = nsnull; | ||
444 | + } | ||
445 | + mSelectionTransferable = nsnull; | ||
446 | + } | ||
447 | + else { | ||
448 | + if (mGlobalOwner) { | ||
449 | + mGlobalOwner->LosingOwnership(mGlobalTransferable); | ||
450 | + mGlobalOwner = nsnull; | ||
451 | + } | ||
452 | + mGlobalTransferable = nsnull; | ||
453 | + } | ||
454 | + | ||
455 | + return NS_OK; | ||
456 | +} | ||
457 | + | ||
458 | +NS_IMETHODIMP | ||
459 | +nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength, | ||
460 | + PRInt32 aWhichClipboard, PRBool *_retval) | ||
461 | +{ | ||
462 | + if (!aFlavorList || !_retval) | ||
463 | + return NS_ERROR_NULL_POINTER; | ||
464 | + | ||
465 | + *_retval = PR_FALSE; | ||
466 | + | ||
467 | + GtkSelectionData *selection_data = | ||
468 | + GetTargets(GetSelectionAtom(aWhichClipboard)); | ||
469 | + if (!selection_data) | ||
470 | + return NS_OK; | ||
471 | + | ||
472 | + gint n_targets = 0; | ||
473 | + GdkAtom *targets = NULL; | ||
474 | + | ||
475 | + if (!gtk_selection_data_get_targets(selection_data, | ||
476 | + &targets, &n_targets) || | ||
477 | + !n_targets) | ||
478 | + return NS_OK; | ||
479 | + | ||
480 | + // Walk through the provided types and try to match it to a | ||
481 | + // provided type. | ||
482 | + for (PRUint32 i = 0; i < aLength && !*_retval; i++) { | ||
483 | + // We special case text/unicode here. | ||
484 | + if (!strcmp(aFlavorList[i], kUnicodeMime) && | ||
485 | + gtk_selection_data_targets_include_text(selection_data)) { | ||
486 | + *_retval = PR_TRUE; | ||
487 | + break; | ||
488 | + } | ||
489 | + | ||
490 | + for (PRInt32 j = 0; j < n_targets; j++) { | ||
491 | + gchar *atom_name = gdk_atom_name(targets[j]); | ||
492 | + if (!strcmp(atom_name, aFlavorList[i])) | ||
493 | + *_retval = PR_TRUE; | ||
494 | + | ||
495 | + // X clipboard wants image/jpeg, not image/jpg | ||
496 | + if (!strcmp(aFlavorList[i], kJPEGImageMime) && !strcmp(atom_name, "image/jpeg")) | ||
497 | + *_retval = PR_TRUE; | ||
498 | + | ||
499 | + g_free(atom_name); | ||
500 | + | ||
501 | + if (*_retval) | ||
502 | + break; | ||
503 | + } | ||
504 | + } | ||
505 | + gtk_selection_data_free(selection_data); | ||
506 | + g_free(targets); | ||
507 | + | ||
508 | + return NS_OK; | ||
509 | +} | ||
510 | + | ||
511 | +NS_IMETHODIMP | ||
512 | +nsClipboard::SupportsSelectionClipboard(PRBool *_retval) | ||
513 | +{ | ||
514 | + *_retval = PR_TRUE; // yeah, unix supports the selection clipboard | ||
515 | + return NS_OK; | ||
516 | +} | ||
517 | + | ||
518 | +/* static */ | ||
519 | +GdkAtom | ||
520 | +nsClipboard::GetSelectionAtom(PRInt32 aWhichClipboard) | ||
521 | +{ | ||
522 | + if (aWhichClipboard == kGlobalClipboard) | ||
523 | + return GDK_SELECTION_CLIPBOARD; | ||
524 | + | ||
525 | + return GDK_SELECTION_PRIMARY; | ||
526 | +} | ||
527 | + | ||
528 | +/* static */ | ||
529 | +GtkSelectionData * | ||
530 | +nsClipboard::GetTargets(GdkAtom aWhichClipboard) | ||
531 | +{ | ||
532 | + GtkClipboard *clipboard = gtk_clipboard_get(aWhichClipboard); | ||
533 | + return wait_for_contents(clipboard, gdk_atom_intern("TARGETS", FALSE)); | ||
534 | +} | ||
535 | + | ||
536 | +nsITransferable * | ||
537 | +nsClipboard::GetTransferable(PRInt32 aWhichClipboard) | ||
538 | +{ | ||
539 | + nsITransferable *retval; | ||
540 | + | ||
541 | + if (aWhichClipboard == kSelectionClipboard) | ||
542 | + retval = mSelectionTransferable.get(); | ||
543 | + else | ||
544 | + retval = mGlobalTransferable.get(); | ||
545 | + | ||
546 | + return retval; | ||
547 | +} | ||
548 | + | ||
549 | +void | ||
550 | +nsClipboard::AddTarget(GdkAtom aName, GdkAtom aClipboard) | ||
551 | +{ | ||
552 | + gtk_selection_add_target(mWidget, aClipboard, aName, 0); | ||
553 | +} | ||
554 | + | ||
555 | +void | ||
556 | +nsClipboard::SelectionGetEvent (GtkWidget *aWidget, | ||
557 | + GtkSelectionData *aSelectionData, | ||
558 | + guint aTime) | ||
559 | +{ | ||
560 | + // Someone has asked us to hand them something. The first thing | ||
561 | + // that we want to do is see if that something includes text. If | ||
562 | + // it does, try to give it text/unicode after converting it to | ||
563 | + // utf-8. | ||
564 | + | ||
565 | + PRInt32 whichClipboard; | ||
566 | + | ||
567 | + // which clipboard? | ||
568 | + if (aSelectionData->selection == GDK_SELECTION_PRIMARY) | ||
569 | + whichClipboard = kSelectionClipboard; | ||
570 | + else if (aSelectionData->selection == GDK_SELECTION_CLIPBOARD) | ||
571 | + whichClipboard = kGlobalClipboard; | ||
572 | + else | ||
573 | + return; // THAT AIN'T NO CLIPBOARD I EVER HEARD OF | ||
574 | + | ||
575 | + nsCOMPtr<nsITransferable> trans = GetTransferable(whichClipboard); | ||
576 | + | ||
577 | + nsresult rv; | ||
578 | + nsCOMPtr<nsISupports> item; | ||
579 | + PRUint32 len; | ||
580 | + | ||
581 | + // Check to see if the selection data includes any of the string | ||
582 | + // types that we support. | ||
583 | + if (aSelectionData->target == gdk_atom_intern ("STRING", FALSE) || | ||
584 | + aSelectionData->target == gdk_atom_intern ("TEXT", FALSE) || | ||
585 | + aSelectionData->target == gdk_atom_intern ("COMPOUND_TEXT", FALSE) || | ||
586 | + aSelectionData->target == gdk_atom_intern ("UTF8_STRING", FALSE)) { | ||
587 | + // Try to convert our internal type into a text string. Get | ||
588 | + // the transferable for this clipboard and try to get the | ||
589 | + // text/unicode type for it. | ||
590 | + rv = trans->GetTransferData("text/unicode", getter_AddRefs(item), | ||
591 | + &len); | ||
592 | + if (!item || NS_FAILED(rv)) | ||
593 | + return; | ||
594 | + | ||
595 | + nsCOMPtr<nsISupportsString> wideString; | ||
596 | + wideString = do_QueryInterface(item); | ||
597 | + if (!wideString) | ||
598 | + return; | ||
599 | + | ||
600 | + nsAutoString ucs2string; | ||
601 | + wideString->GetData(ucs2string); | ||
602 | + char *utf8string = ToNewUTF8String(ucs2string); | ||
603 | + if (!utf8string) | ||
604 | + return; | ||
605 | + | ||
606 | + gtk_selection_data_set_text (aSelectionData, utf8string, | ||
607 | + strlen(utf8string)); | ||
608 | + | ||
609 | + nsMemory::Free(utf8string); | ||
610 | + return; | ||
611 | + } | ||
612 | + | ||
613 | + // Try to match up the selection data target to something our | ||
614 | + // transferable provides. | ||
615 | + gchar *target_name = gdk_atom_name(aSelectionData->target); | ||
616 | + if (!target_name) | ||
617 | + return; | ||
618 | + | ||
619 | + rv = trans->GetTransferData(target_name, getter_AddRefs(item), &len); | ||
620 | + // nothing found? | ||
621 | + if (!item || NS_FAILED(rv)) { | ||
622 | + g_free(target_name); | ||
623 | + return; | ||
624 | + } | ||
625 | + | ||
626 | + void *primitive_data = nsnull; | ||
627 | + nsPrimitiveHelpers::CreateDataFromPrimitive(target_name, item, | ||
628 | + &primitive_data, len); | ||
629 | + | ||
630 | + if (primitive_data) { | ||
631 | + // Check to see if the selection data is text/html | ||
632 | + if (aSelectionData->target == gdk_atom_intern (kHTMLMime, FALSE)) { | ||
633 | + /* | ||
634 | + * "text/html" can be encoded UCS2. It is recommended that | ||
635 | + * documents transmitted as UCS2 always begin with a ZERO-WIDTH | ||
636 | + * NON-BREAKING SPACE character (hexadecimal FEFF, also called | ||
637 | + * Byte Order Mark (BOM)). Adding BOM can help other app to | ||
638 | + * detect mozilla use UCS2 encoding when copy-paste. | ||
639 | + */ | ||
640 | + guchar *buffer = (guchar *) | ||
641 | + nsMemory::Alloc((len * sizeof(guchar)) + sizeof(PRUnichar)); | ||
642 | + if (!buffer) | ||
643 | + return; | ||
644 | + PRUnichar prefix = 0xFEFF; | ||
645 | + memcpy(buffer, &prefix, sizeof(prefix)); | ||
646 | + memcpy(buffer + sizeof(prefix), primitive_data, len); | ||
647 | + nsMemory::Free((guchar *)primitive_data); | ||
648 | + primitive_data = (guchar *)buffer; | ||
649 | + len += sizeof(prefix); | ||
650 | + } | ||
651 | + | ||
652 | + gtk_selection_data_set(aSelectionData, aSelectionData->target, | ||
653 | + 8, /* 8 bits in a unit */ | ||
654 | + (const guchar *)primitive_data, len); | ||
655 | + nsMemory::Free(primitive_data); | ||
656 | + } | ||
657 | + | ||
658 | + g_free(target_name); | ||
659 | + | ||
660 | +} | ||
661 | + | ||
662 | +void | ||
663 | +nsClipboard::SelectionClearEvent (GtkWidget *aWidget, | ||
664 | + GdkEventSelection *aEvent) | ||
665 | +{ | ||
666 | + PRInt32 whichClipboard; | ||
667 | + | ||
668 | + // which clipboard? | ||
669 | + if (aEvent->selection == GDK_SELECTION_PRIMARY) | ||
670 | + whichClipboard = kSelectionClipboard; | ||
671 | + else if (aEvent->selection == GDK_SELECTION_CLIPBOARD) | ||
672 | + whichClipboard = kGlobalClipboard; | ||
673 | + else | ||
674 | + return; // THAT AIN'T NO CLIPBOARD I EVER HEARD OF | ||
675 | + | ||
676 | + EmptyClipboard(whichClipboard); | ||
677 | +} | ||
678 | + | ||
679 | +void | ||
680 | +invisible_selection_get_cb (GtkWidget *aWidget, | ||
681 | + GtkSelectionData *aSelectionData, | ||
682 | + guint aTime, | ||
683 | + guint aInfo, | ||
684 | + nsClipboard *aClipboard) | ||
685 | +{ | ||
686 | + aClipboard->SelectionGetEvent(aWidget, aSelectionData, aTime); | ||
687 | +} | ||
688 | + | ||
689 | +gboolean | ||
690 | +selection_clear_event_cb (GtkWidget *aWidget, | ||
691 | + GdkEventSelection *aEvent, | ||
692 | + nsClipboard *aClipboard) | ||
693 | +{ | ||
694 | + aClipboard->SelectionClearEvent(aWidget, aEvent); | ||
695 | + return TRUE; | ||
696 | +} | ||
697 | + | ||
698 | +/* | ||
699 | + * when copy-paste, mozilla wants data encoded using UCS2, | ||
700 | + * other app such as StarOffice use "text/html"(RFC2854). | ||
701 | + * This function convert data(got from GTK clipboard) | ||
702 | + * to data mozilla wanted. | ||
703 | + * | ||
704 | + * data from GTK clipboard can be 3 forms: | ||
705 | + * 1. From current mozilla | ||
706 | + * "text/html", charset = utf-16 | ||
707 | + * 2. From old version mozilla or mozilla-based app | ||
708 | + * content("body" only), charset = utf-16 | ||
709 | + * 3. From other app who use "text/html" when copy-paste | ||
710 | + * "text/html", has "charset" info | ||
711 | + * | ||
712 | + * data : got from GTK clipboard | ||
713 | + * dataLength: got from GTK clipboard | ||
714 | + * body : pass to Mozilla | ||
715 | + * bodyLength: pass to Mozilla | ||
716 | + */ | ||
717 | +void ConvertHTMLtoUCS2(guchar * data, PRInt32 dataLength, | ||
718 | + PRUnichar** unicodeData, PRInt32& outUnicodeLen) | ||
719 | +{ | ||
720 | + nsCAutoString charset; | ||
721 | + GetHTMLCharset(data, dataLength, charset);// get charset of HTML | ||
722 | + if (charset.EqualsLiteral("UTF-16")) {//current mozilla | ||
723 | + outUnicodeLen = (dataLength / 2) - 1; | ||
724 | + *unicodeData = reinterpret_cast<PRUnichar*> | ||
725 | + (nsMemory::Alloc((outUnicodeLen + sizeof('\0')) * | ||
726 | + sizeof(PRUnichar))); | ||
727 | + if (*unicodeData) { | ||
728 | + memcpy(*unicodeData, data + sizeof(PRUnichar), | ||
729 | + outUnicodeLen * sizeof(PRUnichar)); | ||
730 | + (*unicodeData)[outUnicodeLen] = '\0'; | ||
731 | + } | ||
732 | + } else if (charset.EqualsLiteral("UNKNOWN")) { | ||
733 | + outUnicodeLen = 0; | ||
734 | + return; | ||
735 | + } else { | ||
736 | + // app which use "text/html" to copy&paste | ||
737 | + nsCOMPtr<nsIUnicodeDecoder> decoder; | ||
738 | + nsresult rv; | ||
739 | + // get the decoder | ||
740 | + nsCOMPtr<nsICharsetConverterManager> ccm = | ||
741 | + do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); | ||
742 | + if (NS_FAILED(rv)) { | ||
743 | +#ifdef DEBUG_CLIPBOARD | ||
744 | + g_print(" can't get CHARSET CONVERTER MANAGER service\n"); | ||
745 | +#endif | ||
746 | + outUnicodeLen = 0; | ||
747 | + return; | ||
748 | + } | ||
749 | + rv = ccm->GetUnicodeDecoder(charset.get(), getter_AddRefs(decoder)); | ||
750 | + if (NS_FAILED(rv)) { | ||
751 | +#ifdef DEBUG_CLIPBOARD | ||
752 | + g_print(" get unicode decoder error\n"); | ||
753 | +#endif | ||
754 | + outUnicodeLen = 0; | ||
755 | + return; | ||
756 | + } | ||
757 | + // converting | ||
758 | + decoder->GetMaxLength((const char *)data, dataLength, &outUnicodeLen); | ||
759 | + // |outUnicodeLen| is number of chars | ||
760 | + if (outUnicodeLen) { | ||
761 | + *unicodeData = reinterpret_cast<PRUnichar*> | ||
762 | + (nsMemory::Alloc((outUnicodeLen + sizeof('\0')) * | ||
763 | + sizeof(PRUnichar))); | ||
764 | + if (*unicodeData) { | ||
765 | + PRInt32 numberTmp = dataLength; | ||
766 | + decoder->Convert((const char *)data, &numberTmp, | ||
767 | + *unicodeData, &outUnicodeLen); | ||
768 | +#ifdef DEBUG_CLIPBOARD | ||
769 | + if (numberTmp != dataLength) | ||
770 | + printf("didn't consume all the bytes\n"); | ||
771 | +#endif | ||
772 | + // null terminate. Convert() doesn't do it for us | ||
773 | + (*unicodeData)[outUnicodeLen] = '\0'; | ||
774 | + } | ||
775 | + } // if valid length | ||
776 | + } | ||
777 | +} | ||
778 | + | ||
779 | +/* | ||
780 | + * get "charset" information from clipboard data | ||
781 | + * return value can be: | ||
782 | + * 1. "UTF-16": mozilla or "text/html" with "charset=utf-16" | ||
783 | + * 2. "UNKNOWN": mozilla can't detect what encode it use | ||
784 | + * 3. other: "text/html" with other charset than utf-16 | ||
785 | + */ | ||
786 | +void GetHTMLCharset(guchar * data, PRInt32 dataLength, nsCString& str) | ||
787 | +{ | ||
788 | + // if detect "FFFE" or "FEFF", assume UTF-16 | ||
789 | + PRUnichar* beginChar = (PRUnichar*)data; | ||
790 | + if ((beginChar[0] == 0xFFFE) || (beginChar[0] == 0xFEFF)) { | ||
791 | + str.AssignLiteral("UTF-16"); | ||
792 | + return; | ||
793 | + } | ||
794 | + // no "FFFE" and "FEFF", assume ASCII first to find "charset" info | ||
795 | + const nsDependentCString htmlStr((const char *)data, dataLength); | ||
796 | + nsACString::const_iterator start, end; | ||
797 | + htmlStr.BeginReading(start); | ||
798 | + htmlStr.EndReading(end); | ||
799 | + nsACString::const_iterator valueStart(start), valueEnd(start); | ||
800 | + | ||
801 | + if (CaseInsensitiveFindInReadable( | ||
802 | + NS_LITERAL_CSTRING("CONTENT=\"text/html;"), | ||
803 | + start, end)) { | ||
804 | + start = end; | ||
805 | + htmlStr.EndReading(end); | ||
806 | + | ||
807 | + if (CaseInsensitiveFindInReadable( | ||
808 | + NS_LITERAL_CSTRING("charset="), | ||
809 | + start, end)) { | ||
810 | + valueStart = end; | ||
811 | + start = end; | ||
812 | + htmlStr.EndReading(end); | ||
813 | + | ||
814 | + if (FindCharInReadable('"', start, end)) | ||
815 | + valueEnd = start; | ||
816 | + } | ||
817 | + } | ||
818 | + // find "charset" in HTML | ||
819 | + if (valueStart != valueEnd) { | ||
820 | + str = Substring(valueStart, valueEnd); | ||
821 | + ToUpperCase(str); | ||
822 | +#ifdef DEBUG_CLIPBOARD | ||
823 | + printf("Charset of HTML = %s\n", charsetUpperStr.get()); | ||
824 | +#endif | ||
825 | + return; | ||
826 | + } | ||
827 | + str.AssignLiteral("UNKNOWN"); | ||
828 | +} | ||
829 | + | ||
830 | +static void | ||
831 | +DispatchSelectionNotifyEvent(GtkWidget *widget, XEvent *xevent) | ||
832 | +{ | ||
833 | + GdkEvent event; | ||
834 | + event.selection.type = GDK_SELECTION_NOTIFY; | ||
835 | + event.selection.window = widget->window; | ||
836 | + event.selection.selection = gdk_x11_xatom_to_atom(xevent->xselection.selection); | ||
837 | + event.selection.target = gdk_x11_xatom_to_atom(xevent->xselection.target); | ||
838 | + event.selection.property = gdk_x11_xatom_to_atom(xevent->xselection.property); | ||
839 | + event.selection.time = xevent->xselection.time; | ||
840 | + | ||
841 | + gtk_widget_event(widget, &event); | ||
842 | +} | ||
843 | + | ||
844 | +static void | ||
845 | +DispatchPropertyNotifyEvent(GtkWidget *widget, XEvent *xevent) | ||
846 | +{ | ||
847 | + if (((GdkWindowObject *) widget->window)->event_mask & GDK_PROPERTY_CHANGE_MASK) { | ||
848 | + GdkEvent event; | ||
849 | + event.property.type = GDK_PROPERTY_NOTIFY; | ||
850 | + event.property.window = widget->window; | ||
851 | + event.property.atom = gdk_x11_xatom_to_atom(xevent->xproperty.atom); | ||
852 | + event.property.time = xevent->xproperty.time; | ||
853 | + event.property.state = xevent->xproperty.state; | ||
854 | + | ||
855 | + gtk_widget_event(widget, &event); | ||
856 | + } | ||
857 | +} | ||
858 | + | ||
859 | +struct checkEventContext | ||
860 | +{ | ||
861 | + GtkWidget *cbWidget; | ||
862 | + Atom selAtom; | ||
863 | +}; | ||
864 | + | ||
865 | +static Bool | ||
866 | +checkEventProc(Display *display, XEvent *event, XPointer arg) | ||
867 | +{ | ||
868 | + checkEventContext *context = (checkEventContext *) arg; | ||
869 | + | ||
870 | + if (event->xany.type == SelectionNotify || | ||
871 | + (event->xany.type == PropertyNotify && | ||
872 | + event->xproperty.atom == context->selAtom)) { | ||
873 | + | ||
874 | + GdkWindow *cbWindow = gdk_window_lookup(event->xany.window); | ||
875 | + if (cbWindow) { | ||
876 | + GtkWidget *cbWidget = NULL; | ||
877 | + gdk_window_get_user_data(cbWindow, (gpointer *)&cbWidget); | ||
878 | + if (cbWidget && GTK_IS_WIDGET(cbWidget)) { | ||
879 | + context->cbWidget = cbWidget; | ||
880 | + return True; | ||
881 | + } | ||
882 | + } | ||
883 | + } | ||
884 | + | ||
885 | + return False; | ||
886 | +} | ||
887 | + | ||
888 | +// Idle timeout for receiving selection and property notify events (microsec) | ||
889 | +static const int kClipboardTimeout = 500000; | ||
890 | + | ||
891 | +static void | ||
892 | +wait_for_retrieval(GtkClipboard *clipboard, retrieval_context *r_context) | ||
893 | +{ | ||
894 | + if (r_context->completed) // the request completed synchronously | ||
895 | + return; | ||
896 | + | ||
897 | + Display *xDisplay = GDK_DISPLAY(); | ||
898 | + checkEventContext context; | ||
899 | + context.cbWidget = NULL; | ||
900 | + context.selAtom = gdk_x11_atom_to_xatom(gdk_atom_intern("GDK_SELECTION", | ||
901 | + FALSE)); | ||
902 | + | ||
903 | + // Send X events which are relevant to the ongoing selection retrieval | ||
904 | + // to the clipboard widget. Wait until either the operation completes, or | ||
905 | + // we hit our timeout. All other X events remain queued. | ||
906 | + | ||
907 | + int select_result; | ||
908 | + | ||
909 | +#ifdef POLL_WITH_XCONNECTIONNUMBER | ||
910 | + struct pollfd fds[1]; | ||
911 | + fds[0].fd = XConnectionNumber(xDisplay); | ||
912 | + fds[0].events = POLLIN; | ||
913 | +#else | ||
914 | + int cnumber = ConnectionNumber(xDisplay); | ||
915 | + fd_set select_set; | ||
916 | + FD_ZERO(&select_set); | ||
917 | + FD_SET(cnumber, &select_set); | ||
918 | + ++cnumber; | ||
919 | + struct timeval tv; | ||
920 | +#endif | ||
921 | + | ||
922 | + do { | ||
923 | + XEvent xevent; | ||
924 | + | ||
925 | + while (XCheckIfEvent(xDisplay, &xevent, checkEventProc, | ||
926 | + (XPointer) &context)) { | ||
927 | + | ||
928 | + if (xevent.xany.type == SelectionNotify) | ||
929 | + DispatchSelectionNotifyEvent(context.cbWidget, &xevent); | ||
930 | + else | ||
931 | + DispatchPropertyNotifyEvent(context.cbWidget, &xevent); | ||
932 | + | ||
933 | + if (r_context->completed) | ||
934 | + return; | ||
935 | + } | ||
936 | + | ||
937 | +#ifdef POLL_WITH_XCONNECTIONNUMBER | ||
938 | + select_result = poll(fds, 1, kClipboardTimeout / 1000); | ||
939 | +#else | ||
940 | + tv.tv_sec = 0; | ||
941 | + tv.tv_usec = kClipboardTimeout; | ||
942 | + select_result = select(cnumber, &select_set, NULL, NULL, &tv); | ||
943 | +#endif | ||
944 | + } while (select_result == 1); | ||
945 | + | ||
946 | +#ifdef DEBUG_CLIPBOARD | ||
947 | + printf("exceeded clipboard timeout\n"); | ||
948 | +#endif | ||
949 | +} | ||
950 | + | ||
951 | +static void | ||
952 | +clipboard_contents_received(GtkClipboard *clipboard, | ||
953 | + GtkSelectionData *selection_data, | ||
954 | + gpointer data) | ||
955 | +{ | ||
956 | + retrieval_context *context = static_cast<retrieval_context *>(data); | ||
957 | + context->completed = PR_TRUE; | ||
958 | + | ||
959 | + if (selection_data->length >= 0) | ||
960 | + context->data = gtk_selection_data_copy(selection_data); | ||
961 | +} | ||
962 | + | ||
963 | + | ||
964 | +static GtkSelectionData * | ||
965 | +wait_for_contents(GtkClipboard *clipboard, GdkAtom target) | ||
966 | +{ | ||
967 | + retrieval_context context; | ||
968 | + gtk_clipboard_request_contents(clipboard, target, | ||
969 | + clipboard_contents_received, | ||
970 | + &context); | ||
971 | + | ||
972 | + wait_for_retrieval(clipboard, &context); | ||
973 | + return static_cast<GtkSelectionData *>(context.data); | ||
974 | +} | ||
975 | + | ||
976 | +static void | ||
977 | +clipboard_text_received(GtkClipboard *clipboard, | ||
978 | + const gchar *text, | ||
979 | + gpointer data) | ||
980 | +{ | ||
981 | + retrieval_context *context = static_cast<retrieval_context *>(data); | ||
982 | + context->completed = PR_TRUE; | ||
983 | + context->data = g_strdup(text); | ||
984 | +} | ||
985 | + | ||
986 | +static gchar * | ||
987 | +wait_for_text(GtkClipboard *clipboard) | ||
988 | +{ | ||
989 | + retrieval_context context; | ||
990 | + gtk_clipboard_request_text(clipboard, clipboard_text_received, &context); | ||
991 | + | ||
992 | + wait_for_retrieval(clipboard, &context); | ||
993 | + return static_cast<gchar *>(context.data); | ||
994 | +} | ||
995 | diff --git a/widget/src/headless/nsClipboard.h b/widget/src/headless/nsClipboard.h | ||
996 | new file mode 100644 | ||
997 | index 0000000..dc690c0 | ||
998 | --- /dev/null | ||
999 | +++ b/widget/src/headless/nsClipboard.h | ||
1000 | @@ -0,0 +1,93 @@ | ||
1001 | +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
1002 | +/* vim:expandtab:shiftwidth=4:tabstop=4: | ||
1003 | + */ | ||
1004 | +/* ***** BEGIN LICENSE BLOCK ***** | ||
1005 | + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
1006 | + * | ||
1007 | + * The contents of this file are subject to the Mozilla Public License Version | ||
1008 | + * 1.1 (the "License"); you may not use this file except in compliance with | ||
1009 | + * the License. You may obtain a copy of the License at | ||
1010 | + * http://www.mozilla.org/MPL/ | ||
1011 | + * | ||
1012 | + * Software distributed under the License is distributed on an "AS IS" basis, | ||
1013 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
1014 | + * for the specific language governing rights and limitations under the | ||
1015 | + * License. | ||
1016 | + * | ||
1017 | + * The Original Code is mozilla.org code. | ||
1018 | + * | ||
1019 | + * The Initial Developer of the Original Code is Christopher Blizzard | ||
1020 | + * <blizzard@mozilla.org>. Portions created by the Initial Developer | ||
1021 | + * are Copyright (C) 2001 the Initial Developer. All Rights Reserved. | ||
1022 | + * | ||
1023 | + * Contributor(s): | ||
1024 | + * | ||
1025 | + * Alternatively, the contents of this file may be used under the terms of | ||
1026 | + * either the GNU General Public License Version 2 or later (the "GPL"), or | ||
1027 | + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
1028 | + * in which case the provisions of the GPL or the LGPL are applicable instead | ||
1029 | + * of those above. If you wish to allow use of your version of this file only | ||
1030 | + * under the terms of either the GPL or the LGPL, and not to allow others to | ||
1031 | + * use your version of this file under the terms of the MPL, indicate your | ||
1032 | + * decision by deleting the provisions above and replace them with the notice | ||
1033 | + * and other provisions required by the GPL or the LGPL. If you do not delete | ||
1034 | + * the provisions above, a recipient may use your version of this file under | ||
1035 | + * the terms of any one of the MPL, the GPL or the LGPL. | ||
1036 | + * | ||
1037 | + * ***** END LICENSE BLOCK ***** */ | ||
1038 | + | ||
1039 | +#ifndef __nsClipboard_h_ | ||
1040 | +#define __nsClipboard_h_ | ||
1041 | + | ||
1042 | +#include "nsIClipboard.h" | ||
1043 | +#include "nsClipboardPrivacyHandler.h" | ||
1044 | +#include "nsAutoPtr.h" | ||
1045 | +#include <gtk/gtk.h> | ||
1046 | + | ||
1047 | +class nsClipboard : public nsIClipboard | ||
1048 | +{ | ||
1049 | +public: | ||
1050 | + nsClipboard(); | ||
1051 | + virtual ~nsClipboard(); | ||
1052 | + | ||
1053 | + NS_DECL_ISUPPORTS | ||
1054 | + | ||
1055 | + NS_DECL_NSICLIPBOARD | ||
1056 | + | ||
1057 | + // Make sure we are initialized, called from the factory | ||
1058 | + // constructor | ||
1059 | + nsresult Init (void); | ||
1060 | + // Someone requested the selection from the hidden widget | ||
1061 | + void SelectionGetEvent (GtkWidget *aWidget, | ||
1062 | + GtkSelectionData *aSelectionData, | ||
1063 | + guint aTime); | ||
1064 | + void SelectionClearEvent (GtkWidget *aWidget, | ||
1065 | + GdkEventSelection *aEvent); | ||
1066 | + | ||
1067 | + | ||
1068 | +private: | ||
1069 | + // Utility methods | ||
1070 | + static GdkAtom GetSelectionAtom (PRInt32 aWhichClipboard); | ||
1071 | + static GtkSelectionData *GetTargets (GdkAtom aWhichClipboard); | ||
1072 | + | ||
1073 | + // Get our hands on the correct transferable, given a specific | ||
1074 | + // clipboard | ||
1075 | + nsITransferable *GetTransferable (PRInt32 aWhichClipboard); | ||
1076 | + | ||
1077 | + // Add a target type to the hidden widget | ||
1078 | + void AddTarget (GdkAtom aName, | ||
1079 | + GdkAtom aClipboard); | ||
1080 | + | ||
1081 | + // The hidden widget where we do all of our operations | ||
1082 | + GtkWidget *mWidget; | ||
1083 | + // Hang on to our owners and transferables so we can transfer data | ||
1084 | + // when asked. | ||
1085 | + nsCOMPtr<nsIClipboardOwner> mSelectionOwner; | ||
1086 | + nsCOMPtr<nsIClipboardOwner> mGlobalOwner; | ||
1087 | + nsCOMPtr<nsITransferable> mSelectionTransferable; | ||
1088 | + nsCOMPtr<nsITransferable> mGlobalTransferable; | ||
1089 | + nsRefPtr<nsClipboardPrivacyHandler> mPrivacyHandler; | ||
1090 | + | ||
1091 | +}; | ||
1092 | + | ||
1093 | +#endif /* __nsClipboard_h_ */ | ||
1094 | diff --git a/widget/src/headless/nsIImageToPixbuf.h b/widget/src/headless/nsIImageToPixbuf.h | ||
1095 | new file mode 100644 | ||
1096 | index 0000000..1c46015 | ||
1097 | --- /dev/null | ||
1098 | +++ b/widget/src/headless/nsIImageToPixbuf.h | ||
1099 | @@ -0,0 +1,62 @@ | ||
1100 | +/* ***** BEGIN LICENSE BLOCK ***** | ||
1101 | + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
1102 | + * | ||
1103 | + * The contents of this file are subject to the Mozilla Public License Version | ||
1104 | + * 1.1 (the "License"); you may not use this file except in compliance with | ||
1105 | + * the License. You may obtain a copy of the License at | ||
1106 | + * http://www.mozilla.org/MPL/ | ||
1107 | + * | ||
1108 | + * Software distributed under the License is distributed on an "AS IS" basis, | ||
1109 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
1110 | + * for the specific language governing rights and limitations under the | ||
1111 | + * License. | ||
1112 | + * | ||
1113 | + * The Original Code is mozilla.org widget code. | ||
1114 | + * | ||
1115 | + * The Initial Developer of the Original Code is | ||
1116 | + * Christian Biesinger <cbiesinger@web.de>. | ||
1117 | + * Portions created by the Initial Developer are Copyright (C) 2006 | ||
1118 | + * the Initial Developer. All Rights Reserved. | ||
1119 | + * | ||
1120 | + * Contributor(s): | ||
1121 | + * | ||
1122 | + * Alternatively, the contents of this file may be used under the terms of | ||
1123 | + * either the GNU General Public License Version 2 or later (the "GPL"), or | ||
1124 | + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
1125 | + * in which case the provisions of the GPL or the LGPL are applicable instead | ||
1126 | + * of those above. If you wish to allow use of your version of this file only | ||
1127 | + * under the terms of either the GPL or the LGPL, and not to allow others to | ||
1128 | + * use your version of this file under the terms of the MPL, indicate your | ||
1129 | + * decision by deleting the provisions above and replace them with the notice | ||
1130 | + * and other provisions required by the GPL or the LGPL. If you do not delete | ||
1131 | + * the provisions above, a recipient may use your version of this file under | ||
1132 | + * the terms of any one of the MPL, the GPL or the LGPL. | ||
1133 | + * | ||
1134 | + * ***** END LICENSE BLOCK ***** */ | ||
1135 | + | ||
1136 | +#ifndef NSIIMAGETOPIXBUF_H_ | ||
1137 | +#define NSIIMAGETOPIXBUF_H_ | ||
1138 | + | ||
1139 | +#include "nsISupports.h" | ||
1140 | + | ||
1141 | +// dfa4ac93-83f2-4ab8-9b2a-0ff7022aebe2 | ||
1142 | +#define NSIIMAGETOPIXBUF_IID \ | ||
1143 | +{ 0xdfa4ac93, 0x83f2, 0x4ab8, \ | ||
1144 | + { 0x9b, 0x2a, 0x0f, 0xf7, 0x02, 0x2a, 0xeb, 0xe2 } } | ||
1145 | + | ||
1146 | +class nsIImage; | ||
1147 | +typedef struct _GdkPixbuf GdkPixbuf; | ||
1148 | + | ||
1149 | +/** | ||
1150 | + * An interface that allows converting an nsIImage to a GdkPixbuf*. | ||
1151 | + */ | ||
1152 | +class nsIImageToPixbuf : public nsISupports { | ||
1153 | + public: | ||
1154 | + NS_DECLARE_STATIC_IID_ACCESSOR(NSIIMAGETOPIXBUF_IID) | ||
1155 | + | ||
1156 | + NS_IMETHOD_(GdkPixbuf*) ConvertImageToPixbuf(nsIImage* aImage) = 0; | ||
1157 | +}; | ||
1158 | + | ||
1159 | +NS_DEFINE_STATIC_IID_ACCESSOR(nsIImageToPixbuf, NSIIMAGETOPIXBUF_IID) | ||
1160 | + | ||
1161 | +#endif | ||
1162 | diff --git a/widget/src/headless/nsImageToPixbuf.cpp b/widget/src/headless/nsImageToPixbuf.cpp | ||
1163 | new file mode 100644 | ||
1164 | index 0000000..496815c | ||
1165 | --- /dev/null | ||
1166 | +++ b/widget/src/headless/nsImageToPixbuf.cpp | ||
1167 | @@ -0,0 +1,196 @@ | ||
1168 | +/* vim:set sw=4 sts=4 et cin: */ | ||
1169 | +/* ***** BEGIN LICENSE BLOCK ***** | ||
1170 | + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
1171 | + * | ||
1172 | + * The contents of this file are subject to the Mozilla Public License Version | ||
1173 | + * 1.1 (the "License"); you may not use this file except in compliance with | ||
1174 | + * the License. You may obtain a copy of the License at | ||
1175 | + * http://www.mozilla.org/MPL/ | ||
1176 | + * | ||
1177 | + * Software distributed under the License is distributed on an "AS IS" basis, | ||
1178 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
1179 | + * for the specific language governing rights and limitations under the | ||
1180 | + * License. | ||
1181 | + * | ||
1182 | + * The Original Code is mozilla.org widget code. | ||
1183 | + * | ||
1184 | + * The Initial Developer of the Original Code is | ||
1185 | + * Christian Biesinger <cbiesinger@web.de>. | ||
1186 | + * Portions created by the Initial Developer are Copyright (C) 2006 | ||
1187 | + * the Initial Developer. All Rights Reserved. | ||
1188 | + * | ||
1189 | + * Contributor(s): | ||
1190 | + * | ||
1191 | + * Alternatively, the contents of this file may be used under the terms of | ||
1192 | + * either the GNU General Public License Version 2 or later (the "GPL"), or | ||
1193 | + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
1194 | + * in which case the provisions of the GPL or the LGPL are applicable instead | ||
1195 | + * of those above. If you wish to allow use of your version of this file only | ||
1196 | + * under the terms of either the GPL or the LGPL, and not to allow others to | ||
1197 | + * use your version of this file under the terms of the MPL, indicate your | ||
1198 | + * decision by deleting the provisions above and replace them with the notice | ||
1199 | + * and other provisions required by the GPL or the LGPL. If you do not delete | ||
1200 | + * the provisions above, a recipient may use your version of this file under | ||
1201 | + * the terms of any one of the MPL, the GPL or the LGPL. | ||
1202 | + * | ||
1203 | + * ***** END LICENSE BLOCK ***** */ | ||
1204 | + | ||
1205 | +#include <gdk-pixbuf/gdk-pixbuf.h> | ||
1206 | + | ||
1207 | +#include "gfxASurface.h" | ||
1208 | +#include "gfxImageSurface.h" | ||
1209 | +#include "gfxContext.h" | ||
1210 | + | ||
1211 | +#include "nsIImage.h" | ||
1212 | + | ||
1213 | +#include "nsAutoPtr.h" | ||
1214 | + | ||
1215 | +#include "nsImageToPixbuf.h" | ||
1216 | + | ||
1217 | +NS_IMPL_ISUPPORTS1(nsImageToPixbuf, nsIImageToPixbuf) | ||
1218 | + | ||
1219 | +inline unsigned char | ||
1220 | +unpremultiply (unsigned char color, | ||
1221 | + unsigned char alpha) | ||
1222 | +{ | ||
1223 | + if (alpha == 0) | ||
1224 | + return 0; | ||
1225 | + // plus alpha/2 to round instead of truncate | ||
1226 | + return (color * 255 + alpha / 2) / alpha; | ||
1227 | +} | ||
1228 | + | ||
1229 | +NS_IMETHODIMP_(GdkPixbuf*) | ||
1230 | +nsImageToPixbuf::ConvertImageToPixbuf(nsIImage* aImage) | ||
1231 | +{ | ||
1232 | + return ImageToPixbuf(aImage); | ||
1233 | +} | ||
1234 | + | ||
1235 | +GdkPixbuf* | ||
1236 | +nsImageToPixbuf::ImageToPixbuf(nsIImage* aImage) | ||
1237 | +{ | ||
1238 | + PRInt32 width = aImage->GetWidth(), | ||
1239 | + height = aImage->GetHeight(); | ||
1240 | + | ||
1241 | + nsRefPtr<gfxPattern> pattern; | ||
1242 | + aImage->GetPattern(getter_AddRefs(pattern)); | ||
1243 | + | ||
1244 | + return PatternToPixbuf(pattern, width, height); | ||
1245 | +} | ||
1246 | + | ||
1247 | +GdkPixbuf* | ||
1248 | +nsImageToPixbuf::ImgSurfaceToPixbuf(gfxImageSurface* aImgSurface, PRInt32 aWidth, PRInt32 aHeight) | ||
1249 | +{ | ||
1250 | + GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, PR_TRUE, 8, | ||
1251 | + aWidth, aHeight); | ||
1252 | + if (!pixbuf) | ||
1253 | + return nsnull; | ||
1254 | + | ||
1255 | + PRUint32 rowstride = gdk_pixbuf_get_rowstride (pixbuf); | ||
1256 | + guchar* pixels = gdk_pixbuf_get_pixels (pixbuf); | ||
1257 | + | ||
1258 | + long cairoStride = aImgSurface->Stride(); | ||
1259 | + unsigned char* cairoData = aImgSurface->Data(); | ||
1260 | + | ||
1261 | + gfxASurface::gfxImageFormat format = aImgSurface->Format(); | ||
1262 | + | ||
1263 | + for (PRInt32 row = 0; row < aHeight; ++row) { | ||
1264 | + for (PRInt32 col = 0; col < aWidth; ++col) { | ||
1265 | + guchar* pixel = pixels + row * rowstride + 4 * col; | ||
1266 | + | ||
1267 | + PRUint32* cairoPixel = reinterpret_cast<PRUint32*> | ||
1268 | + ((cairoData + row * cairoStride + 4 * col)); | ||
1269 | + | ||
1270 | + if (format == gfxASurface::ImageFormatARGB32) { | ||
1271 | + const PRUint8 a = (*cairoPixel >> 24) & 0xFF; | ||
1272 | + const PRUint8 r = unpremultiply((*cairoPixel >> 16) & 0xFF, a); | ||
1273 | + const PRUint8 g = unpremultiply((*cairoPixel >> 8) & 0xFF, a); | ||
1274 | + const PRUint8 b = unpremultiply((*cairoPixel >> 0) & 0xFF, a); | ||
1275 | + | ||
1276 | + *pixel++ = r; | ||
1277 | + *pixel++ = g; | ||
1278 | + *pixel++ = b; | ||
1279 | + *pixel++ = a; | ||
1280 | + } else { | ||
1281 | + NS_ASSERTION(format == gfxASurface::ImageFormatRGB24, | ||
1282 | + "unexpected format"); | ||
1283 | + const PRUint8 r = (*cairoPixel >> 16) & 0xFF; | ||
1284 | + const PRUint8 g = (*cairoPixel >> 8) & 0xFF; | ||
1285 | + const PRUint8 b = (*cairoPixel >> 0) & 0xFF; | ||
1286 | + | ||
1287 | + *pixel++ = r; | ||
1288 | + *pixel++ = g; | ||
1289 | + *pixel++ = b; | ||
1290 | + *pixel++ = 0xFF; // A | ||
1291 | + } | ||
1292 | + } | ||
1293 | + } | ||
1294 | + | ||
1295 | + return pixbuf; | ||
1296 | +} | ||
1297 | + | ||
1298 | +GdkPixbuf* | ||
1299 | +nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, PRInt32 aWidth, PRInt32 aHeight) | ||
1300 | +{ | ||
1301 | + if (aSurface->CairoStatus()) { | ||
1302 | + NS_ERROR("invalid surface"); | ||
1303 | + return nsnull; | ||
1304 | + } | ||
1305 | + | ||
1306 | + nsRefPtr<gfxImageSurface> imgSurface; | ||
1307 | + if (aSurface->GetType() == gfxASurface::SurfaceTypeImage) { | ||
1308 | + imgSurface = static_cast<gfxImageSurface*> | ||
1309 | + (static_cast<gfxASurface*>(aSurface)); | ||
1310 | + } else { | ||
1311 | + imgSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight), | ||
1312 | + gfxImageSurface::ImageFormatARGB32); | ||
1313 | + | ||
1314 | + if (!imgSurface) | ||
1315 | + return nsnull; | ||
1316 | + | ||
1317 | + nsRefPtr<gfxContext> context = new gfxContext(imgSurface); | ||
1318 | + if (!context) | ||
1319 | + return nsnull; | ||
1320 | + | ||
1321 | + context->SetOperator(gfxContext::OPERATOR_SOURCE); | ||
1322 | + context->SetSource(aSurface); | ||
1323 | + context->Paint(); | ||
1324 | + } | ||
1325 | + | ||
1326 | + return ImgSurfaceToPixbuf(imgSurface, aWidth, aHeight); | ||
1327 | +} | ||
1328 | + | ||
1329 | +GdkPixbuf* | ||
1330 | +nsImageToPixbuf::PatternToPixbuf(gfxPattern* aPattern, PRInt32 aWidth, PRInt32 aHeight) | ||
1331 | +{ | ||
1332 | + if (aPattern->CairoStatus()) { | ||
1333 | + NS_ERROR("invalid pattern"); | ||
1334 | + return nsnull; | ||
1335 | + } | ||
1336 | + | ||
1337 | + nsRefPtr<gfxImageSurface> imgSurface; | ||
1338 | + if (aPattern->GetType() == gfxPattern::PATTERN_SURFACE) { | ||
1339 | + nsRefPtr<gfxASurface> surface = aPattern->GetSurface(); | ||
1340 | + if (surface->GetType() == gfxASurface::SurfaceTypeImage) { | ||
1341 | + imgSurface = static_cast<gfxImageSurface*> | ||
1342 | + (static_cast<gfxASurface*>(surface.get())); | ||
1343 | + } | ||
1344 | + } | ||
1345 | + | ||
1346 | + if (!imgSurface) { | ||
1347 | + imgSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight), | ||
1348 | + gfxImageSurface::ImageFormatARGB32); | ||
1349 | + | ||
1350 | + if (!imgSurface) | ||
1351 | + return nsnull; | ||
1352 | + | ||
1353 | + nsRefPtr<gfxContext> context = new gfxContext(imgSurface); | ||
1354 | + if (!context) | ||
1355 | + return nsnull; | ||
1356 | + | ||
1357 | + context->SetOperator(gfxContext::OPERATOR_SOURCE); | ||
1358 | + context->SetPattern(aPattern); | ||
1359 | + context->Paint(); | ||
1360 | + } | ||
1361 | + | ||
1362 | + return ImgSurfaceToPixbuf(imgSurface, aWidth, aHeight); | ||
1363 | +} | ||
1364 | diff --git a/widget/src/headless/nsImageToPixbuf.h b/widget/src/headless/nsImageToPixbuf.h | ||
1365 | new file mode 100644 | ||
1366 | index 0000000..0e3f516 | ||
1367 | --- /dev/null | ||
1368 | +++ b/widget/src/headless/nsImageToPixbuf.h | ||
1369 | @@ -0,0 +1,71 @@ | ||
1370 | +/* vim:set sw=4 sts=4 et cin: */ | ||
1371 | +/* ***** BEGIN LICENSE BLOCK ***** | ||
1372 | + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
1373 | + * | ||
1374 | + * The contents of this file are subject to the Mozilla Public License Version | ||
1375 | + * 1.1 (the "License"); you may not use this file except in compliance with | ||
1376 | + * the License. You may obtain a copy of the License at | ||
1377 | + * http://www.mozilla.org/MPL/ | ||
1378 | + * | ||
1379 | + * Software distributed under the License is distributed on an "AS IS" basis, | ||
1380 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
1381 | + * for the specific language governing rights and limitations under the | ||
1382 | + * License. | ||
1383 | + * | ||
1384 | + * The Original Code is mozilla.org widget code. | ||
1385 | + * | ||
1386 | + * The Initial Developer of the Original Code is | ||
1387 | + * Christian Biesinger <cbiesinger@web.de>. | ||
1388 | + * Portions created by the Initial Developer are Copyright (C) 2006 | ||
1389 | + * the Initial Developer. All Rights Reserved. | ||
1390 | + * | ||
1391 | + * Contributor(s): | ||
1392 | + * | ||
1393 | + * Alternatively, the contents of this file may be used under the terms of | ||
1394 | + * either the GNU General Public License Version 2 or later (the "GPL"), or | ||
1395 | + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
1396 | + * in which case the provisions of the GPL or the LGPL are applicable instead | ||
1397 | + * of those above. If you wish to allow use of your version of this file only | ||
1398 | + * under the terms of either the GPL or the LGPL, and not to allow others to | ||
1399 | + * use your version of this file under the terms of the MPL, indicate your | ||
1400 | + * decision by deleting the provisions above and replace them with the notice | ||
1401 | + * and other provisions required by the GPL or the LGPL. If you do not delete | ||
1402 | + * the provisions above, a recipient may use your version of this file under | ||
1403 | + * the terms of any one of the MPL, the GPL or the LGPL. | ||
1404 | + * | ||
1405 | + * ***** END LICENSE BLOCK ***** */ | ||
1406 | + | ||
1407 | +#ifndef NSIMAGETOPIXBUF_H_ | ||
1408 | +#define NSIMAGETOPIXBUF_H_ | ||
1409 | + | ||
1410 | +#include "nsIImageToPixbuf.h" | ||
1411 | + | ||
1412 | +class gfxASurface; | ||
1413 | +class gfxPattern; | ||
1414 | +class gfxImageSurface; | ||
1415 | + | ||
1416 | +class nsImageToPixbuf : public nsIImageToPixbuf { | ||
1417 | + public: | ||
1418 | + NS_DECL_ISUPPORTS | ||
1419 | + NS_IMETHOD_(GdkPixbuf*) ConvertImageToPixbuf(nsIImage* aImage); | ||
1420 | + | ||
1421 | + // Friendlier version of ConvertImageToPixbuf for callers inside of | ||
1422 | + // widget | ||
1423 | + static GdkPixbuf* ImageToPixbuf(nsIImage* aImage); | ||
1424 | + static GdkPixbuf* SurfaceToPixbuf(gfxASurface* aSurface, | ||
1425 | + PRInt32 aWidth, PRInt32 aHeight); | ||
1426 | + static GdkPixbuf* PatternToPixbuf(gfxPattern* aPattern, | ||
1427 | + PRInt32 aWidth, PRInt32 aHeight); | ||
1428 | + private: | ||
1429 | + static GdkPixbuf* ImgSurfaceToPixbuf(gfxImageSurface* aImgSurface, | ||
1430 | + PRInt32 aWidth, PRInt32 aHeight); | ||
1431 | + ~nsImageToPixbuf() {} | ||
1432 | +}; | ||
1433 | + | ||
1434 | + | ||
1435 | +// fc2389b8-c650-4093-9e42-b05e5f0685b7 | ||
1436 | +#define NS_IMAGE_TO_PIXBUF_CID \ | ||
1437 | +{ 0xfc2389b8, 0xc650, 0x4093, \ | ||
1438 | + { 0x9e, 0x42, 0xb0, 0x5e, 0x5f, 0x06, 0x85, 0xb7 } } | ||
1439 | + | ||
1440 | +#endif | ||
1441 | diff --git a/widget/src/headless/nsWidgetFactory.cpp b/widget/src/headless/nsWidgetFactory.cpp | ||
1442 | index eb94333..a215988 100644 | ||
1443 | --- a/widget/src/headless/nsWidgetFactory.cpp | ||
1444 | +++ b/widget/src/headless/nsWidgetFactory.cpp | ||
1445 | @@ -46,6 +46,10 @@ | ||
1446 | #include "nsWindow.h" | ||
1447 | #include "nsTransferable.h" | ||
1448 | #include "nsHTMLFormatConverter.h" | ||
1449 | +#ifdef MOZ_X11 | ||
1450 | +#include "nsClipboardHelper.h" | ||
1451 | +#include "nsClipboard.h" | ||
1452 | +#endif | ||
1453 | //#include "nsFilePicker.h" | ||
1454 | #include "nsSound.h" | ||
1455 | #include "nsBidiKeyboard.h" | ||
1456 | @@ -74,6 +78,10 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) | ||
1457 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) | ||
1458 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) | ||
1459 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) | ||
1460 | +#ifdef MOZ_X11 | ||
1461 | +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) | ||
1462 | +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsClipboard, Init) | ||
1463 | +#endif | ||
1464 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) | ||
1465 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerHeadless) | ||
1466 | //NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageToPixbuf) | ||
1467 | @@ -189,6 +197,16 @@ static const nsModuleComponentInfo components[] = | ||
1468 | NS_TRANSFERABLE_CID, | ||
1469 | "@mozilla.org/widget/transferable;1", | ||
1470 | nsTransferableConstructor }, | ||
1471 | +#ifdef MOZ_X11 | ||
1472 | + { "Gtk Clipboard", | ||
1473 | + NS_CLIPBOARD_CID, | ||
1474 | + "@mozilla.org/widget/clipboard;1", | ||
1475 | + nsClipboardConstructor }, | ||
1476 | + { "Clipboard Helper", | ||
1477 | + NS_CLIPBOARDHELPER_CID, | ||
1478 | + "@mozilla.org/widget/clipboardhelper;1", | ||
1479 | + nsClipboardHelperConstructor }, | ||
1480 | +#endif | ||
1481 | { "HTML Format Converter", | ||
1482 | NS_HTMLFORMATCONVERTER_CID, | ||
1483 | "@mozilla.org/widget/htmlformatconverter;1", | ||
1484 | -- | ||
1485 | 1.6.0.4 | ||
1486 | |||
diff --git a/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/configurefix.patch b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/configurefix.patch new file mode 100644 index 0000000000..e02e4af2b6 --- /dev/null +++ b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/configurefix.patch | |||
@@ -0,0 +1,775 @@ | |||
1 | Index: offscreen/configure.in | ||
2 | =================================================================== | ||
3 | --- offscreen.orig/configure.in 2009-04-16 22:51:48.000000000 +0100 | ||
4 | +++ offscreen/configure.in 2009-04-16 23:07:48.000000000 +0100 | ||
5 | @@ -62,7 +62,6 @@ | ||
6 | |||
7 | AC_PREREQ(2.13) | ||
8 | AC_INIT(config/config.mk) | ||
9 | -AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf) | ||
10 | AC_CANONICAL_SYSTEM | ||
11 | TARGET_CPU="${target_cpu}" | ||
12 | TARGET_VENDOR="${target_vendor}" | ||
13 | @@ -103,7 +102,6 @@ | ||
14 | _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS" | ||
15 | _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS" | ||
16 | _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS" | ||
17 | -_SUBDIR_CONFIG_ARGS="$ac_configure_args" | ||
18 | |||
19 | dnl Set the version number of the libs included with mozilla | ||
20 | dnl ======================================================== | ||
21 | @@ -136,6 +134,9 @@ | ||
22 | |||
23 | MSMANIFEST_TOOL= | ||
24 | |||
25 | +ac_cv_have_usable_wchar_v2=no | ||
26 | +ac_cv_have_usable_wchar_option_v2=no | ||
27 | + | ||
28 | dnl Set various checks | ||
29 | dnl ======================================================== | ||
30 | MISSING_X= | ||
31 | @@ -281,7 +282,7 @@ | ||
32 | ;; | ||
33 | esac | ||
34 | |||
35 | -if test -n "$CROSS_COMPILE" && test "$target" != "$host"; then | ||
36 | + | ||
37 | echo "cross compiling from $host to $target" | ||
38 | cross_compiling=yes | ||
39 | |||
40 | @@ -319,7 +320,7 @@ | ||
41 | |||
42 | AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works]) | ||
43 | AC_TRY_COMPILE([], [return(0);], | ||
44 | - [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])], | ||
45 | + [ac_cv_prog_hostcc_works=1; AC_MSG_RESULT([yes])], | ||
46 | AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) ) | ||
47 | |||
48 | CC="$HOST_CXX" | ||
49 | @@ -327,7 +328,7 @@ | ||
50 | |||
51 | AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works]) | ||
52 | AC_TRY_COMPILE([], [return(0);], | ||
53 | - [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])], | ||
54 | + [ac_cv_prog_hostcxx_works=1; AC_MSG_RESULT([yes])], | ||
55 | AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) ) | ||
56 | |||
57 | CC=$_SAVE_CC | ||
58 | @@ -348,7 +349,7 @@ | ||
59 | ;; | ||
60 | esac | ||
61 | |||
62 | - AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :) | ||
63 | + CC="${target_alias}-gcc" | ||
64 | unset ac_cv_prog_CC | ||
65 | AC_PROG_CC | ||
66 | AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :) | ||
67 | @@ -372,37 +373,6 @@ | ||
68 | AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :) | ||
69 | AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :) | ||
70 | AC_DEFINE(CROSS_COMPILE) | ||
71 | -else | ||
72 | - AC_PROG_CC | ||
73 | - AC_PROG_CXX | ||
74 | - AC_PROG_RANLIB | ||
75 | - MOZ_PATH_PROGS(AS, $AS as, $CC) | ||
76 | - AC_CHECK_PROGS(AR, ar, :) | ||
77 | - AC_CHECK_PROGS(LD, ld, :) | ||
78 | - AC_CHECK_PROGS(STRIP, strip, :) | ||
79 | - AC_CHECK_PROGS(WINDRES, windres, :) | ||
80 | - if test -z "$HOST_CC"; then | ||
81 | - HOST_CC="$CC" | ||
82 | - fi | ||
83 | - if test -z "$HOST_CFLAGS"; then | ||
84 | - HOST_CFLAGS="$CFLAGS" | ||
85 | - fi | ||
86 | - if test -z "$HOST_CXX"; then | ||
87 | - HOST_CXX="$CXX" | ||
88 | - fi | ||
89 | - if test -z "$HOST_CXXFLAGS"; then | ||
90 | - HOST_CXXFLAGS="$CXXFLAGS" | ||
91 | - fi | ||
92 | - if test -z "$HOST_LDFLAGS"; then | ||
93 | - HOST_LDFLAGS="$LDFLAGS" | ||
94 | - fi | ||
95 | - if test -z "$HOST_RANLIB"; then | ||
96 | - HOST_RANLIB="$RANLIB" | ||
97 | - fi | ||
98 | - if test -z "$HOST_AR"; then | ||
99 | - HOST_AR="$AR" | ||
100 | - fi | ||
101 | -fi | ||
102 | |||
103 | GNU_AS= | ||
104 | GNU_LD= | ||
105 | @@ -1569,6 +1539,7 @@ | ||
106 | ' | ||
107 | |||
108 | dnl test that the macros actually work: | ||
109 | +ac_cv_static_assertion_macros_work="yes" | ||
110 | AC_MSG_CHECKING(that static assertion macros used in autoconf tests work) | ||
111 | AC_CACHE_VAL(ac_cv_static_assertion_macros_work, | ||
112 | [AC_LANG_SAVE | ||
113 | @@ -2730,9 +2701,13 @@ | ||
114 | AC_LANG_C | ||
115 | AC_HEADER_STDC | ||
116 | AC_C_CONST | ||
117 | +ac_cv_type_mode_t=yes | ||
118 | AC_TYPE_MODE_T | ||
119 | +ac_cv_type_off_t=yes | ||
120 | AC_TYPE_OFF_T | ||
121 | +ac_cv_type_pid_t=yes | ||
122 | AC_TYPE_PID_T | ||
123 | +ac_cv_type_size_t=yes | ||
124 | AC_TYPE_SIZE_T | ||
125 | AC_STRUCT_ST_BLKSIZE | ||
126 | AC_MSG_CHECKING(for siginfo_t) | ||
127 | @@ -3115,19 +3090,9 @@ | ||
128 | dnl We don't want to link against libm or libpthread on Darwin since | ||
129 | dnl they both are just symlinks to libSystem and explicitly linking | ||
130 | dnl against libSystem causes issues when debugging (see bug 299601). | ||
131 | -case $target in | ||
132 | -*-darwin*) | ||
133 | - ;; | ||
134 | -*-beos*) | ||
135 | - ;; | ||
136 | -*) | ||
137 | AC_CHECK_LIB(m, atan) | ||
138 | AC_CHECK_LIB(dl, dlopen, | ||
139 | - AC_CHECK_HEADER(dlfcn.h, | ||
140 | - LIBS="-ldl $LIBS" | ||
141 | - AC_DEFINE(HAVE_LIBDL))) | ||
142 | - ;; | ||
143 | -esac | ||
144 | + AC_DEFINE(HAVE_LIBDL)) | ||
145 | |||
146 | _SAVE_CFLAGS="$CFLAGS" | ||
147 | CFLAGS="$CFLAGS -D_GNU_SOURCE" | ||
148 | @@ -6931,18 +6896,13 @@ | ||
149 | |||
150 | # Demangle only for debug or trace-malloc builds | ||
151 | MOZ_DEMANGLE_SYMBOLS= | ||
152 | -if test "$HAVE_DEMANGLE" -a "$HAVE_GCC3_ABI" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then | ||
153 | - MOZ_DEMANGLE_SYMBOLS=1 | ||
154 | - AC_DEFINE(MOZ_DEMANGLE_SYMBOLS) | ||
155 | -fi | ||
156 | + | ||
157 | AC_SUBST(MOZ_DEMANGLE_SYMBOLS) | ||
158 | |||
159 | dnl ======================================================== | ||
160 | dnl = Support for gcc stack unwinding (from gcc 3.3) | ||
161 | dnl ======================================================== | ||
162 | -if test "$HAVE_GCC3_ABI" && test -z "$SKIP_LIBRARY_CHECKS"; then | ||
163 | - AC_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace)) | ||
164 | -fi | ||
165 | + | ||
166 | |||
167 | dnl ======================================================== | ||
168 | dnl = | ||
169 | @@ -7454,10 +7414,7 @@ | ||
170 | dnl if no gtk/libIDL1 or gtk2/libIDL2 combination was found, fall back | ||
171 | dnl to either libIDL1 or libIDL2. | ||
172 | if test -z "$_LIBIDL_FOUND"; then | ||
173 | - AM_PATH_LIBIDL($LIBIDL_VERSION,_LIBIDL_FOUND=1) | ||
174 | - if test -z "$_LIBIDL_FOUND"; then | ||
175 | PKG_CHECK_MODULES(LIBIDL, libIDL-2.0 >= 0.8.0,_LIBIDL_FOUND=1) | ||
176 | - fi | ||
177 | fi | ||
178 | dnl | ||
179 | dnl If we don't have a libIDL config program & not cross-compiling, | ||
180 | @@ -7529,13 +7486,7 @@ | ||
181 | fi | ||
182 | |||
183 | if test -z "$SKIP_PATH_CHECKS"; then | ||
184 | -if test -z "${GLIB_CFLAGS}" || test -z "${GLIB_LIBS}" ; then | ||
185 | - if test "$MOZ_ENABLE_GTK2" || test "$USE_ELF_DYNSTR_GC" || test "$MOZ_ENABLE_HEADLESS"; then | ||
186 | PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0) | ||
187 | - else | ||
188 | - AM_PATH_GLIB(${GLIB_VERSION}) | ||
189 | - fi | ||
190 | -fi | ||
191 | fi | ||
192 | |||
193 | if test -z "${GLIB_GMODULE_LIBS}" -a -n "${GLIB_CONFIG}"; then | ||
194 | @@ -8346,10 +8297,7 @@ | ||
195 | HAVE_WCRTOMB | ||
196 | " | ||
197 | |||
198 | -AC_CONFIG_HEADER( | ||
199 | -netwerk/necko-config.h | ||
200 | -xpcom/xpcom-config.h | ||
201 | -xpcom/xpcom-private.h | ||
202 | +AC_CONFIG_HEADER(netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h | ||
203 | ) | ||
204 | |||
205 | # Save the defines header file before autoconf removes it. | ||
206 | @@ -8408,31 +8356,11 @@ | ||
207 | dnl To add new Makefiles, edit allmakefiles.sh. | ||
208 | dnl allmakefiles.sh sets the variable, MAKEFILES. | ||
209 | . ${srcdir}/allmakefiles.sh | ||
210 | -dnl | ||
211 | -dnl Run a perl script to quickly create the makefiles. | ||
212 | -dnl If it succeeds, it outputs a shell command to set CONFIG_FILES | ||
213 | -dnl for the files it cannot handle correctly. This way, config.status | ||
214 | -dnl will handle these files. | ||
215 | -dnl If it fails, nothing is set and config.status will run as usual. | ||
216 | -dnl | ||
217 | -dnl This does not change the $MAKEFILES variable. | ||
218 | -dnl | ||
219 | -dnl OpenVMS gets a line overflow on the long eval command, so use a temp file. | ||
220 | -dnl | ||
221 | -if test -z "${AS_PERL}"; then | ||
222 | -echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl > conftest.sh | ||
223 | -else | ||
224 | -echo $MAKEFILES | ${PERL} $srcdir/build/autoconf/acoutput-fast.pl -nowrap --cygwin-srcdir=$srcdir > conftest.sh | ||
225 | -fi | ||
226 | -. ./conftest.sh | ||
227 | -rm conftest.sh | ||
228 | |||
229 | echo $MAKEFILES > unallmakefiles | ||
230 | |||
231 | mv -f config/autoconf.mk config/autoconf.mk.orig 2> /dev/null | ||
232 | |||
233 | -AC_OUTPUT($MAKEFILES) | ||
234 | - | ||
235 | dnl Prevent the regeneration of cairo-features.h forcing rebuilds of gfx stuff | ||
236 | if test "$CAIRO_FEATURES_H"; then | ||
237 | if cmp -s $CAIRO_FEATURES_H "$CAIRO_FEATURES_H".orig; then | ||
238 | @@ -8458,14 +8386,14 @@ | ||
239 | HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS" | ||
240 | RC= | ||
241 | |||
242 | -unset MAKEFILES | ||
243 | -unset CONFIG_FILES | ||
244 | +#unset MAKEFILES | ||
245 | +#unset CONFIG_FILES | ||
246 | |||
247 | # No need to run subconfigures when building with LIBXUL_SDK_DIR | ||
248 | if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then | ||
249 | |||
250 | if test -z "$MOZ_NATIVE_NSPR"; then | ||
251 | - ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla" | ||
252 | + ac_configure_args="$ac_configure_args --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla" | ||
253 | if test -z "$MOZ_DEBUG"; then | ||
254 | ac_configure_args="$ac_configure_args --disable-debug" | ||
255 | fi | ||
256 | @@ -8481,8 +8409,7 @@ | ||
257 | if test -n "$USE_ARM_KUSER"; then | ||
258 | ac_configure_args="$ac_configure_args --with-arm-kuser" | ||
259 | fi | ||
260 | - AC_OUTPUT_SUBDIRS(nsprpub) | ||
261 | - ac_configure_args="$_SUBDIR_CONFIG_ARGS" | ||
262 | + AC_CONFIG_SUBDIRS(nsprpub) | ||
263 | fi | ||
264 | |||
265 | if test -z "$MOZ_NATIVE_NSPR"; then | ||
266 | @@ -8499,7 +8426,6 @@ | ||
267 | |||
268 | # Run the SpiderMonkey 'configure' script. | ||
269 | dist=$MOZ_BUILD_ROOT/dist | ||
270 | -ac_configure_args="$_SUBDIR_CONFIG_ARGS" | ||
271 | ac_configure_args="$ac_configure_args --enable-threadsafe" | ||
272 | if test -z "$MOZ_NATIVE_NSPR"; then | ||
273 | ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'" | ||
274 | @@ -8513,11 +8439,14 @@ | ||
275 | if test "$MOZ_MEMORY"; then | ||
276 | ac_configure_args="$ac_configure_args --enable-jemalloc" | ||
277 | fi | ||
278 | -AC_OUTPUT_SUBDIRS(js/src) | ||
279 | -ac_configure_args="$_SUBDIR_CONFIG_ARGS" | ||
280 | +AC_CONFIG_SUBDIRS(js/src) | ||
281 | |||
282 | fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR | ||
283 | |||
284 | +m4_pattern_allow(AS_BIN) | ||
285 | + | ||
286 | +AC_OUTPUT($MAKEFILES) | ||
287 | + | ||
288 | dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world | ||
289 | dnl Needs to be at the end to respect possible changes from NSPR configure | ||
290 | if cmp -s config/autoconf.mk config/autoconf.mk.orig; then | ||
291 | Index: offscreen/js/src/configure.in | ||
292 | =================================================================== | ||
293 | --- offscreen.orig/js/src/configure.in 2009-04-16 22:51:49.000000000 +0100 | ||
294 | +++ offscreen/js/src/configure.in 2009-04-16 23:06:42.000000000 +0100 | ||
295 | @@ -62,7 +62,6 @@ | ||
296 | |||
297 | AC_PREREQ(2.13) | ||
298 | AC_INIT(jsapi.h) | ||
299 | -AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf) | ||
300 | AC_CONFIG_HEADER(js-config.h) | ||
301 | AC_CANONICAL_SYSTEM | ||
302 | TARGET_CPU="${target_cpu}" | ||
303 | @@ -101,6 +100,9 @@ | ||
304 | _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS" | ||
305 | _SUBDIR_CONFIG_ARGS="$ac_configure_args" | ||
306 | |||
307 | +ac_cv_have_usable_wchar_v2=no | ||
308 | +ac_cv_have_usable_wchar_option_v2=no | ||
309 | + | ||
310 | dnl Set the version number of the libs included with mozilla | ||
311 | dnl ======================================================== | ||
312 | NSPR_VERSION=4 | ||
313 | @@ -114,6 +116,8 @@ | ||
314 | |||
315 | MSMANIFEST_TOOL= | ||
316 | |||
317 | +m4_pattern_allow(AS_BIN) | ||
318 | + | ||
319 | dnl Set various checks | ||
320 | dnl ======================================================== | ||
321 | MISSING_X= | ||
322 | @@ -200,7 +204,7 @@ | ||
323 | |||
324 | if test "$COMPILE_ENVIRONMENT"; then | ||
325 | |||
326 | -if test "$target" != "$host"; then | ||
327 | + | ||
328 | echo "cross compiling from $host to $target" | ||
329 | |||
330 | _SAVE_CC="$CC" | ||
331 | @@ -237,7 +241,7 @@ | ||
332 | |||
333 | AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works]) | ||
334 | AC_TRY_COMPILE([], [return(0);], | ||
335 | - [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])], | ||
336 | + [ac_cv_prog_hostcc_works=1; AC_MSG_RESULT([yes])], | ||
337 | AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) ) | ||
338 | |||
339 | CC="$HOST_CXX" | ||
340 | @@ -245,7 +249,7 @@ | ||
341 | |||
342 | AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works]) | ||
343 | AC_TRY_COMPILE([], [return(0);], | ||
344 | - [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])], | ||
345 | + [ac_cv_prog_hostcxx_works=1; AC_MSG_RESULT([yes])], | ||
346 | AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) ) | ||
347 | |||
348 | CC=$_SAVE_CC | ||
349 | @@ -266,7 +270,7 @@ | ||
350 | ;; | ||
351 | esac | ||
352 | |||
353 | - AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :) | ||
354 | + CC="${target_alias}-gcc" | ||
355 | unset ac_cv_prog_CC | ||
356 | AC_PROG_CC | ||
357 | AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :) | ||
358 | @@ -296,37 +300,6 @@ | ||
359 | dnl able to run ppc code in a translated environment, making a cross | ||
360 | dnl compiler appear native. So we override that here. | ||
361 | cross_compiling=yes | ||
362 | -else | ||
363 | - AC_PROG_CC | ||
364 | - AC_PROG_CXX | ||
365 | - AC_PROG_RANLIB | ||
366 | - MOZ_PATH_PROGS(AS, $AS as, $CC) | ||
367 | - AC_CHECK_PROGS(AR, ar, :) | ||
368 | - AC_CHECK_PROGS(LD, ld, :) | ||
369 | - AC_CHECK_PROGS(STRIP, strip, :) | ||
370 | - AC_CHECK_PROGS(WINDRES, windres, :) | ||
371 | - if test -z "$HOST_CC"; then | ||
372 | - HOST_CC="$CC" | ||
373 | - fi | ||
374 | - if test -z "$HOST_CFLAGS"; then | ||
375 | - HOST_CFLAGS="$CFLAGS" | ||
376 | - fi | ||
377 | - if test -z "$HOST_CXX"; then | ||
378 | - HOST_CXX="$CXX" | ||
379 | - fi | ||
380 | - if test -z "$HOST_CXXFLAGS"; then | ||
381 | - HOST_CXXFLAGS="$CXXFLAGS" | ||
382 | - fi | ||
383 | - if test -z "$HOST_LDFLAGS"; then | ||
384 | - HOST_LDFLAGS="$LDFLAGS" | ||
385 | - fi | ||
386 | - if test -z "$HOST_RANLIB"; then | ||
387 | - HOST_RANLIB="$RANLIB" | ||
388 | - fi | ||
389 | - if test -z "$HOST_AR"; then | ||
390 | - HOST_AR="$AR" | ||
391 | - fi | ||
392 | -fi | ||
393 | |||
394 | GNU_AS= | ||
395 | GNU_LD= | ||
396 | @@ -1435,6 +1408,8 @@ | ||
397 | fi # GNU_CC | ||
398 | fi # COMPILE_ENVIRONMENT | ||
399 | |||
400 | +ac_cv_static_assertion_macros_work=yes | ||
401 | + | ||
402 | dnl ================================================================= | ||
403 | dnl Set up and test static assertion macros used to avoid AC_TRY_RUN, | ||
404 | dnl which is bad when cross compiling. | ||
405 | @@ -2565,9 +2540,13 @@ | ||
406 | AC_LANG_C | ||
407 | AC_HEADER_STDC | ||
408 | AC_C_CONST | ||
409 | +ac_cv_type_mode_t=yes | ||
410 | AC_TYPE_MODE_T | ||
411 | +ac_cv_type_off_t=yes | ||
412 | AC_TYPE_OFF_T | ||
413 | +ac_cv_type_pid_t=yes | ||
414 | AC_TYPE_PID_T | ||
415 | +ac_cv_type_size_t=yes | ||
416 | AC_TYPE_SIZE_T | ||
417 | AC_STRUCT_ST_BLKSIZE | ||
418 | AC_MSG_CHECKING(for siginfo_t) | ||
419 | @@ -2592,7 +2571,8 @@ | ||
420 | |||
421 | AC_CHECK_HEADER(stdint.h) | ||
422 | if test "$ac_cv_header_stdint_h" = yes; then | ||
423 | - AC_DEFINE(JS_HAVE_STDINT_H) | ||
424 | + AC_DEFINE(JS_HAVE_STDINT_H, 1, [have stdint.h]) | ||
425 | + AC_DEFINE(HAVE_STDINT_H) | ||
426 | else | ||
427 | dnl We'll figure them out for ourselves. List more likely types | ||
428 | dnl earlier. If we ever really encounter a size for which none of | ||
429 | @@ -2990,10 +2970,7 @@ | ||
430 | ;; | ||
431 | *) | ||
432 | AC_CHECK_LIB(m, atan) | ||
433 | - AC_CHECK_LIB(dl, dlopen, | ||
434 | - AC_CHECK_HEADER(dlfcn.h, | ||
435 | - LIBS="-ldl $LIBS" | ||
436 | - AC_DEFINE(HAVE_LIBDL))) | ||
437 | + AC_CHECK_LIB(dl, dlopen, AC_DEFINE(HAVE_LIBDL)) | ||
438 | ;; | ||
439 | esac | ||
440 | |||
441 | @@ -3908,6 +3885,7 @@ | ||
442 | [ --with-nspr-libs=LIBS Pass LIBS to LD when linking code that uses NSPR. | ||
443 | See --with-nspr-cflags for more details.], | ||
444 | NSPR_LIBS=$withval) | ||
445 | +$NSPR_LIBS="$NSPR_LIBS -L$(LIBXUL_DIST)/sdk/lib" | ||
446 | AC_SUBST(NSPR_CFLAGS) | ||
447 | AC_SUBST(NSPR_LIBS) | ||
448 | |||
449 | @@ -4542,18 +4520,11 @@ | ||
450 | |||
451 | # Demangle only for debug or trace-malloc builds | ||
452 | MOZ_DEMANGLE_SYMBOLS= | ||
453 | -if test "$HAVE_DEMANGLE" -a "$HAVE_GCC3_ABI" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then | ||
454 | - MOZ_DEMANGLE_SYMBOLS=1 | ||
455 | - AC_DEFINE(MOZ_DEMANGLE_SYMBOLS) | ||
456 | -fi | ||
457 | AC_SUBST(MOZ_DEMANGLE_SYMBOLS) | ||
458 | |||
459 | dnl ======================================================== | ||
460 | dnl = Support for gcc stack unwinding (from gcc 3.3) | ||
461 | dnl ======================================================== | ||
462 | -if test "$HAVE_GCC3_ABI" && test -z "$SKIP_LIBRARY_CHECKS"; then | ||
463 | - AC_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace)) | ||
464 | -fi | ||
465 | |||
466 | dnl ======================================================== | ||
467 | dnl = | ||
468 | @@ -5256,6 +5227,8 @@ | ||
469 | done | ||
470 | AC_SUBST(LIBS_PATH) | ||
471 | |||
472 | + | ||
473 | + | ||
474 | dnl ======================================================== | ||
475 | dnl JavaScript shell | ||
476 | dnl ======================================================== | ||
477 | @@ -5396,3 +5369,4 @@ | ||
478 | # 'js-config' in Makefile.in. | ||
479 | AC_MSG_RESULT(invoking make to create js-config script) | ||
480 | $MAKE js-config | ||
481 | + | ||
482 | Index: offscreen/nsprpub/configure.in | ||
483 | =================================================================== | ||
484 | --- offscreen.orig/nsprpub/configure.in 2009-04-16 18:09:00.000000000 +0100 | ||
485 | +++ offscreen/nsprpub/configure.in 2009-04-16 23:06:42.000000000 +0100 | ||
486 | @@ -42,7 +42,6 @@ | ||
487 | AC_PREREQ(2.12) | ||
488 | AC_INIT(config/libc_r.h) | ||
489 | |||
490 | -AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf) | ||
491 | AC_CANONICAL_SYSTEM | ||
492 | |||
493 | dnl ======================================================== | ||
494 | @@ -400,7 +399,7 @@ | ||
495 | dnl ======================================================== | ||
496 | dnl Checks for compilers. | ||
497 | dnl ======================================================== | ||
498 | -if test "$target" != "$host"; then | ||
499 | + | ||
500 | echo "cross compiling from $host to $target" | ||
501 | cross_compiling=yes | ||
502 | |||
503 | @@ -427,7 +426,7 @@ | ||
504 | |||
505 | AC_MSG_CHECKING([whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works]) | ||
506 | AC_TRY_COMPILE([], [return(0);], | ||
507 | - [ac_cv_prog_host_cc_works=1 AC_MSG_RESULT([yes])], | ||
508 | + [ac_cv_prog_host_cc_works=1; AC_MSG_RESULT([yes])], | ||
509 | AC_MSG_ERROR([installation or configuration problem: $host compiler $HOST_CC cannot create executables.]) ) | ||
510 | |||
511 | CC=$_SAVE_CC | ||
512 | @@ -448,7 +447,7 @@ | ||
513 | ;; | ||
514 | esac | ||
515 | |||
516 | - AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo) | ||
517 | + CC="${target_alias}-gcc" | ||
518 | unset ac_cv_prog_CC | ||
519 | AC_PROG_CC | ||
520 | if test -n "$USE_CPLUS"; then | ||
521 | @@ -474,30 +473,6 @@ | ||
522 | AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", echo) | ||
523 | AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", echo) | ||
524 | |||
525 | -else | ||
526 | - AC_PROG_CC | ||
527 | - if test -n "$USE_CPLUS"; then | ||
528 | - if test "$CC" = "cl" -a -z "$CXX"; then | ||
529 | - CXX=$CC | ||
530 | - else | ||
531 | - AC_PROG_CXX | ||
532 | - fi | ||
533 | - fi | ||
534 | - AC_PROG_CPP | ||
535 | - AC_PROG_RANLIB | ||
536 | - AC_PATH_PROGS(AS, as, $CC) | ||
537 | - AC_PATH_PROGS(AR, ar, echo not_ar) | ||
538 | - AC_PATH_PROGS(LD, ld link, echo not_ld) | ||
539 | - AC_PATH_PROGS(STRIP, strip, echo not_strip) | ||
540 | - AC_PATH_PROGS(WINDRES, windres, echo not_windres) | ||
541 | - if test -z "$HOST_CC"; then | ||
542 | - HOST_CC="$CC" | ||
543 | - fi | ||
544 | - if test -z "$HOST_CFLAGS"; then | ||
545 | - HOST_CFLAGS="$CFLAGS" | ||
546 | - fi | ||
547 | -fi | ||
548 | - | ||
549 | if test "$GCC" = "yes"; then | ||
550 | GNU_CC=1 | ||
551 | fi | ||
552 | @@ -518,11 +493,8 @@ | ||
553 | ;; | ||
554 | esac | ||
555 | |||
556 | -if test "$cross_compiling" = "yes"; then | ||
557 | + | ||
558 | CROSS_COMPILE=1 | ||
559 | -else | ||
560 | - CROSS_COMPILE= | ||
561 | -fi | ||
562 | |||
563 | dnl ======================================================== | ||
564 | dnl Check for gcc -pipe support | ||
565 | @@ -2249,10 +2221,7 @@ | ||
566 | *-darwin*|*-beos*) | ||
567 | ;; | ||
568 | *) | ||
569 | - AC_CHECK_LIB(dl, dlopen, | ||
570 | - AC_CHECK_HEADER(dlfcn.h, | ||
571 | - OS_LIBS="-ldl $OS_LIBS")) | ||
572 | - ;; | ||
573 | + AC_CHECK_LIB(dl, dlopen) | ||
574 | esac | ||
575 | |||
576 | |||
577 | @@ -2869,6 +2838,8 @@ | ||
578 | dnl pr/tests/w16gui/Makefile | ||
579 | dnl tools/Makefile | ||
580 | |||
581 | +m4_pattern_allow(AS_BIN) | ||
582 | + | ||
583 | if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then | ||
584 | MAKEFILES="$MAKEFILES pr/src/threads/combined/Makefile" | ||
585 | elif test -n "$USE_PTHREADS"; then | ||
586 | @@ -2884,3 +2855,5 @@ | ||
587 | echo $MAKEFILES > unallmakefiles | ||
588 | |||
589 | AC_OUTPUT([$MAKEFILES], [chmod +x config/nspr-config]) | ||
590 | + | ||
591 | + | ||
592 | Index: offscreen/toolkit/toolkit-makefiles.sh | ||
593 | =================================================================== | ||
594 | --- offscreen.orig/toolkit/toolkit-makefiles.sh 2009-04-16 22:51:50.000000000 +0100 | ||
595 | +++ offscreen/toolkit/toolkit-makefiles.sh 2009-04-16 23:06:42.000000000 +0100 | ||
596 | @@ -628,7 +628,6 @@ | ||
597 | toolkit/crashreporter/client/Makefile | ||
598 | toolkit/crashreporter/google-breakpad/src/client/Makefile | ||
599 | toolkit/crashreporter/google-breakpad/src/client/mac/handler/Makefile | ||
600 | - toolkit/crashreporter/google-breakpad/src/client/windows/Makefile | ||
601 | toolkit/crashreporter/google-breakpad/src/client/windows/handler/Makefile | ||
602 | toolkit/crashreporter/google-breakpad/src/client/windows/sender/Makefile | ||
603 | toolkit/crashreporter/google-breakpad/src/common/Makefile | ||
604 | Index: offscreen/js/src/Makefile.in | ||
605 | =================================================================== | ||
606 | --- offscreen.orig/js/src/Makefile.in 2009-04-16 18:07:56.000000000 +0100 | ||
607 | +++ offscreen/js/src/Makefile.in 2009-04-16 23:06:42.000000000 +0100 | ||
608 | @@ -507,20 +507,8 @@ | ||
609 | |||
610 | export:: jsautocfg.h | ||
611 | |||
612 | -ifeq (,$(CROSS_COMPILE)$(GNU_CC)$(filter-out WINNT,$(OS_ARCH))) | ||
613 | jsautocfg.h: | ||
614 | touch $@ | ||
615 | -else | ||
616 | -ifeq ($(OS_ARCH),WINCE) | ||
617 | -jsautocfg.h: | ||
618 | - touch $@ | ||
619 | -else | ||
620 | -jsautocfg.h: jscpucfg$(HOST_BIN_SUFFIX) | ||
621 | - @rm -f $@ jsautocfg.tmp | ||
622 | - ./jscpucfg > jsautocfg.tmp | ||
623 | - mv jsautocfg.tmp $@ | ||
624 | -endif | ||
625 | -endif | ||
626 | |||
627 | # jscpucfg is a strange target | ||
628 | # Needs to be built with the host compiler but needs to include | ||
629 | @@ -550,7 +538,7 @@ | ||
630 | echo no need to build jscpucfg $< | ||
631 | else | ||
632 | jscpucfg$(HOST_BIN_SUFFIX): jscpucfg.cpp Makefile.in | ||
633 | - $(HOST_CXX) $(HOST_CXXFLAGS) $(JSCPUCFG_DEFINES) $(DEFINES) $(NSPR_CFLAGS) $(HOST_OUTOPTION)$@ $< | ||
634 | + $(HOST_CXX) $(HOST_CXXFLAGS) $(JSCPUCFG_DEFINES) $(DEFINES) -I$(DIST)/sdk/include $(NSPR_CFLAGS) $(HOST_OUTOPTION)$@ $< | ||
635 | endif | ||
636 | endif | ||
637 | |||
638 | Index: offscreen/js/src/xpconnect/loader/mozJSComponentLoader.cpp | ||
639 | =================================================================== | ||
640 | --- offscreen.orig/js/src/xpconnect/loader/mozJSComponentLoader.cpp 2009-04-16 18:08:00.000000000 +0100 | ||
641 | +++ offscreen/js/src/xpconnect/loader/mozJSComponentLoader.cpp 2009-04-16 23:06:42.000000000 +0100 | ||
642 | @@ -47,6 +47,8 @@ | ||
643 | |||
644 | #include <stdarg.h> | ||
645 | |||
646 | +#include "mozilla-config.h" | ||
647 | + | ||
648 | #include "prlog.h" | ||
649 | |||
650 | #include "nsCOMPtr.h" | ||
651 | Index: offscreen/js/src/xpconnect/loader/mozJSSubScriptLoader.cpp | ||
652 | =================================================================== | ||
653 | --- offscreen.orig/js/src/xpconnect/loader/mozJSSubScriptLoader.cpp 2009-04-16 18:08:00.000000000 +0100 | ||
654 | +++ offscreen/js/src/xpconnect/loader/mozJSSubScriptLoader.cpp 2009-04-16 23:06:42.000000000 +0100 | ||
655 | @@ -39,6 +39,8 @@ | ||
656 | * | ||
657 | * ***** END LICENSE BLOCK ***** */ | ||
658 | |||
659 | +#include "mozilla-config.h" | ||
660 | + | ||
661 | #if !defined(XPCONNECT_STANDALONE) && !defined(NO_SUBSCRIPT_LOADER) | ||
662 | |||
663 | #include "mozJSSubScriptLoader.h" | ||
664 | Index: offscreen/modules/lcms/include/icc34.h | ||
665 | =================================================================== | ||
666 | --- offscreen.orig/modules/lcms/include/icc34.h 2009-04-16 18:08:47.000000000 +0100 | ||
667 | +++ offscreen/modules/lcms/include/icc34.h 2009-04-16 23:06:42.000000000 +0100 | ||
668 | @@ -144,7 +144,7 @@ | ||
669 | */ | ||
670 | |||
671 | |||
672 | -#ifdef PACKAGE_NAME | ||
673 | +#if 0 | ||
674 | /* | ||
675 | June 9, 2003, Adapted for use with configure by Bob Friesenhahn | ||
676 | Added the stupid check for autoconf by Marti Maria. | ||
677 | Index: offscreen/toolkit/mozapps/update/src/updater/Makefile.in | ||
678 | =================================================================== | ||
679 | --- offscreen.orig/toolkit/mozapps/update/src/updater/Makefile.in 2009-04-16 18:09:35.000000000 +0100 | ||
680 | +++ offscreen/toolkit/mozapps/update/src/updater/Makefile.in 2009-04-16 23:06:42.000000000 +0100 | ||
681 | @@ -59,7 +59,7 @@ | ||
682 | |||
683 | LIBS += \ | ||
684 | $(DEPTH)/modules/libmar/src/$(LIB_PREFIX)mar.$(LIB_SUFFIX) \ | ||
685 | - $(BZ2_LIBS) \ | ||
686 | + $(BZ2_LIBS) -lpthread \ | ||
687 | $(NULL) | ||
688 | |||
689 | ifeq ($(OS_ARCH),WINNT) | ||
690 | Index: offscreen/xpcom/sample/program/Makefile.in | ||
691 | =================================================================== | ||
692 | --- offscreen.orig/xpcom/sample/program/Makefile.in 2009-04-16 18:09:47.000000000 +0100 | ||
693 | +++ offscreen/xpcom/sample/program/Makefile.in 2009-04-16 23:06:42.000000000 +0100 | ||
694 | @@ -57,7 +57,7 @@ | ||
695 | # that the application be linked against the XPCOM dynamic library or the NSPR | ||
696 | # dynamic libraries. | ||
697 | LIBS = \ | ||
698 | - $(XPCOM_STANDALONE_GLUE_LDOPTS) \ | ||
699 | + $(XPCOM_STANDALONE_GLUE_LDOPTS) -ldl \ | ||
700 | $(NULL) | ||
701 | |||
702 | # Need to link with CoreFoundation on Mac | ||
703 | Index: offscreen/xpcom/tools/registry/Makefile.in | ||
704 | =================================================================== | ||
705 | --- offscreen.orig/xpcom/tools/registry/Makefile.in 2009-04-16 18:09:48.000000000 +0100 | ||
706 | +++ offscreen/xpcom/tools/registry/Makefile.in 2009-04-16 23:06:42.000000000 +0100 | ||
707 | @@ -54,7 +54,7 @@ | ||
708 | SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX)) | ||
709 | |||
710 | LIBS = \ | ||
711 | - $(XPCOM_STANDALONE_GLUE_LDOPTS) \ | ||
712 | + $(XPCOM_STANDALONE_GLUE_LDOPTS) -ldl \ | ||
713 | $(NULL) | ||
714 | |||
715 | # Need to link with CoreFoundation on Mac | ||
716 | Index: offscreen/xulrunner/app/Makefile.in | ||
717 | =================================================================== | ||
718 | --- offscreen.orig/xulrunner/app/Makefile.in 2009-04-16 18:09:50.000000000 +0100 | ||
719 | +++ offscreen/xulrunner/app/Makefile.in 2009-04-16 23:06:42.000000000 +0100 | ||
720 | @@ -180,7 +180,7 @@ | ||
721 | RCFLAGS += -DXULRUNNER_ICO=\"$(DIST)/branding/xulrunner.ico\" -DDOCUMENT_ICO=\"$(DIST)/branding/document.ico\" | ||
722 | endif | ||
723 | |||
724 | -LIBS += $(JEMALLOC_LIBS) | ||
725 | +LIBS += $(JEMALLOC_LIBS) -lpthread -ldl | ||
726 | |||
727 | include $(topsrcdir)/config/rules.mk | ||
728 | |||
729 | Index: offscreen/xulrunner/stub/Makefile.in | ||
730 | =================================================================== | ||
731 | --- offscreen.orig/xulrunner/stub/Makefile.in 2009-04-16 18:09:50.000000000 +0100 | ||
732 | +++ offscreen/xulrunner/stub/Makefile.in 2009-04-16 23:06:42.000000000 +0100 | ||
733 | @@ -101,7 +101,7 @@ | ||
734 | endif | ||
735 | endif | ||
736 | |||
737 | -LIBS += $(JEMALLOC_LIBS) | ||
738 | +LIBS += $(JEMALLOC_LIBS) -lpthread -ldl | ||
739 | |||
740 | include $(topsrcdir)/config/rules.mk | ||
741 | |||
742 | Index: offscreen/modules/plugin/test/testplugin/Makefile.in | ||
743 | =================================================================== | ||
744 | --- offscreen.orig/modules/plugin/test/testplugin/Makefile.in 2009-04-16 18:08:56.000000000 +0100 | ||
745 | +++ offscreen/modules/plugin/test/testplugin/Makefile.in 2009-04-16 23:06:42.000000000 +0100 | ||
746 | @@ -63,9 +63,7 @@ | ||
747 | CMMSRCS = nptest_macosx.mm | ||
748 | endif | ||
749 | |||
750 | -ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2) | ||
751 | CPPSRCS += nptest_gtk2.cpp | ||
752 | -endif | ||
753 | |||
754 | ifeq ($(MOZ_WIDGET_TOOLKIT),qt) | ||
755 | CPPSRCS += nptest_qt.cpp | ||
756 | Index: offscreen/xulrunner/installer/libxul-unstable.pc.in | ||
757 | =================================================================== | ||
758 | --- offscreen.orig/xulrunner/installer/libxul-unstable.pc.in 2009-04-16 18:09:50.000000000 +0100 | ||
759 | +++ offscreen/xulrunner/installer/libxul-unstable.pc.in 2009-04-16 23:06:42.000000000 +0100 | ||
760 | @@ -8,5 +8,5 @@ | ||
761 | Description: The Mozilla Runtime and Embedding Engine (unstable API) | ||
762 | Version: %MOZILLA_VERSION% | ||
763 | Requires: %NSPR_NAME% >= %NSPR_VERSION% | ||
764 | -Libs: -L${sdkdir}/lib -lxpcomglue_s -lxul -lxpcom | ||
765 | +Libs: -L${sdkdir}/lib -lxpcomglue_s -lxul -lxpcom -lsmime3 -lnss3 -lssl3 -lnssutil3 -L${sdkdir}/../xulrunner-1.9.2a1pre | ||
766 | Cflags: -I${includedir}/${includetype} %WCHAR_CFLAGS% | ||
767 | Index: offscreen/js/src/aclocal.m4 | ||
768 | =================================================================== | ||
769 | --- offscreen.orig/js/src/aclocal.m4 2009-04-16 18:07:56.000000000 +0100 | ||
770 | +++ offscreen/js/src/aclocal.m4 2009-04-16 23:06:42.000000000 +0100 | ||
771 | @@ -9,4 +9,3 @@ | ||
772 | builtin(include, build/autoconf/moznbytetype.m4)dnl | ||
773 | builtin(include, build/autoconf/mozprog.m4)dnl | ||
774 | |||
775 | -MOZ_PROG_CHECKMSYS() | ||
diff --git a/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/mozconfig b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/mozconfig new file mode 100644 index 0000000000..6123d11d27 --- /dev/null +++ b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/mozconfig | |||
@@ -0,0 +1,23 @@ | |||
1 | # this line sets the directory for all build output | ||
2 | mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obj-headless-release | ||
3 | |||
4 | # comment out the previous line and uncomment these two for a debug build | ||
5 | #mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obj-headless-debug | ||
6 | #ac_add_options --disable-optimize --enable-debug | ||
7 | |||
8 | # this is the line that enables the headless implementation | ||
9 | ac_add_options --enable-default-toolkit=cairo-headless | ||
10 | |||
11 | # comment out the previous line and uncomment these two for a GTK build | ||
12 | #ac_add_options --enable-system-cairo | ||
13 | #ac_add_options --enable-default-toolkit=cairo-gtk2 | ||
14 | |||
15 | ac_add_options --disable-tests | ||
16 | ac_add_options --disable-javaxpcom | ||
17 | ac_add_options --enable-application=xulrunner | ||
18 | ac_add_options --enable-pango | ||
19 | ac_add_options --disable-printing | ||
20 | ac_add_options --disable-crashreporter | ||
21 | ac_add_options --enable-plugins | ||
22 | ac_add_options --disable-accessibility | ||
23 | mk_add_options MOZ_CO_PROJECT=xulrunner | ||
diff --git a/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/mozilla-jemalloc.patch b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/mozilla-jemalloc.patch new file mode 100644 index 0000000000..aabd6906e8 --- /dev/null +++ b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/mozilla-jemalloc.patch | |||
@@ -0,0 +1,24 @@ | |||
1 | diff -r f1af606531f5 memory/jemalloc/jemalloc.h | ||
2 | --- a/memory/jemalloc/jemalloc.h Sat Nov 22 20:22:22 2008 +0100 | ||
3 | +++ b/memory/jemalloc/jemalloc.h Mon Dec 01 16:53:06 2008 -0500 | ||
4 | @@ -45,14 +45,14 @@ | ||
5 | } jemalloc_stats_t; | ||
6 | |||
7 | #ifndef MOZ_MEMORY_DARWIN | ||
8 | -void *malloc(size_t size); | ||
9 | -void *valloc(size_t size); | ||
10 | -void *calloc(size_t num, size_t size); | ||
11 | -void *realloc(void *ptr, size_t size); | ||
12 | -void free(void *ptr); | ||
13 | +void *malloc(size_t size) __THROW __attribute_malloc__ __wur; | ||
14 | +void *valloc(size_t size) __THROW __attribute_malloc__ __wur; | ||
15 | +void *calloc(size_t num, size_t size) __THROW __attribute_malloc__ __wur; | ||
16 | +void *realloc(void *ptr, size_t size) __THROW __attribute_malloc__ __wur; | ||
17 | +void free(void *ptr) __THROW __attribute_malloc__ __wur; | ||
18 | #endif | ||
19 | |||
20 | -int posix_memalign(void **memptr, size_t alignment, size_t size); | ||
21 | +int posix_memalign(void **memptr, size_t alignment, size_t size) __THROW __attribute_malloc__ __wur; | ||
22 | void *memalign(size_t alignment, size_t size); | ||
23 | size_t malloc_usable_size(const void *ptr); | ||
24 | void jemalloc_stats(jemalloc_stats_t *stats); | ||
diff --git a/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/removebadrpath.patch b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/removebadrpath.patch new file mode 100644 index 0000000000..9409105780 --- /dev/null +++ b/meta/packages/mozilla-headless/mozilla-headless-0.0+hg-1.0+a3e7c6626661/removebadrpath.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | Index: offscreen/js/src/configure.in | ||
2 | =================================================================== | ||
3 | --- offscreen.orig/js/src/configure.in 2009-06-17 14:31:40.000000000 +0100 | ||
4 | +++ offscreen/js/src/configure.in 2009-06-17 14:31:40.000000000 +0100 | ||
5 | @@ -880,7 +880,7 @@ | ||
6 | HOST_AR_FLAGS='$(AR_FLAGS)' | ||
7 | |||
8 | MOZ_JS_LIBS='-L$(libdir) -lmozjs' | ||
9 | -MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(PREFIX)/lib' | ||
10 | +MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin' | ||
11 | |||
12 | MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)' | ||
13 | MOZ_XPCOM_OBSOLETE_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom_compat' | ||
14 | Index: offscreen/configure.in | ||
15 | =================================================================== | ||
16 | --- offscreen.orig/configure.in 2009-06-17 15:09:44.000000000 +0100 | ||
17 | +++ offscreen/configure.in 2009-06-17 15:10:00.000000000 +0100 | ||
18 | @@ -1060,7 +1060,7 @@ | ||
19 | |||
20 | MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs' | ||
21 | DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core' | ||
22 | -MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib' | ||
23 | +MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin' | ||
24 | XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom' | ||
25 | LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul' | ||
26 | XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)' | ||