~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/gfx/src/xlib/nsDeviceContextXlib.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Netscape Public License
 
6
 * Version 1.1 (the "License"); you may not use this file except in
 
7
 * compliance with the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/NPL/
 
9
 *
 
10
 * Software distributed under the License is distributed on an "AS IS" basis,
 
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
12
 * for the specific language governing rights and limitations under the
 
13
 * License.
 
14
 *
 
15
 * The Original Code is mozilla.org code.
 
16
 *
 
17
 * The Initial Developer of the Original Code is 
 
18
 * Netscape Communications Corporation.
 
19
 * Portions created by the Initial Developer are Copyright (C) 1998
 
20
 * the Initial Developer. All Rights Reserved.
 
21
 *
 
22
 * Contributor(s):
 
23
 *   Pierre Phaneuf <pp@ludusdesign.com>
 
24
 *   Peter Hartshorn <peter@igelaus.com.au>
 
25
 *   Ken Faulkner <faulkner@igelaus.com.au>
 
26
 *   Tony Tsui <tony@igelaus.com.au>
 
27
 *   Tim Copperfield <timecop@network.email.ne.jp>
 
28
 *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> 
 
29
 *
 
30
 *
 
31
 * Alternatively, the contents of this file may be used under the terms of
 
32
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
33
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
34
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
35
 * of those above. If you wish to allow use of your version of this file only
 
36
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
37
 * use your version of this file under the terms of the NPL, indicate your
 
38
 * decision by deleting the provisions above and replace them with the notice
 
39
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
40
 * the provisions above, a recipient may use your version of this file under
 
41
 * the terms of any one of the NPL, the GPL or the LGPL.
 
42
 *
 
43
 * ***** END LICENSE BLOCK ***** */
 
44
 
 
45
#include "nsRenderingContextXlib.h"
 
46
#include "nsDrawingSurfaceXlib.h"
 
47
#include "nsDeviceContextXlib.h"
 
48
#include "nsIPref.h"
 
49
#include "nsIServiceManager.h"
 
50
#include "nsGfxCIID.h"
 
51
#include "nspr.h"
 
52
 
 
53
#include "nsFontMetricsXlib.h"
 
54
 
 
55
#include "xlibrgb.h"
 
56
#include <X11/Xatom.h>
 
57
 
 
58
#include "nsDeviceContextSpecXlib.h"
 
59
 
 
60
#ifdef USE_POSTSCRIPT
 
61
#include "nsGfxPSCID.h"
 
62
#include "nsIDeviceContextPS.h"
 
63
#endif /* USE_POSTSCRIPT */
 
64
#ifdef USE_XPRINT
 
65
#include "nsGfxXPrintCID.h"
 
66
#include "nsIDeviceContextXPrint.h"
 
67
#endif /* USE_XPRINT */
 
68
 
 
69
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
 
70
 
 
71
#define XLIB_DEFAULT_FONT1 "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"
 
72
#define XLIB_DEFAULT_FONT2 "-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*"
 
73
 
 
74
#ifdef PR_LOGGING 
 
75
static PRLogModuleInfo *DeviceContextXlibLM = PR_NewLogModule("DeviceContextXlib");
 
76
#endif /* PR_LOGGING */ 
 
77
 
 
78
/* global default font handle */
 
79
static XFontStruct *mDefaultFont = nsnull;
 
80
 
 
81
nsDeviceContextXlib::nsDeviceContextXlib()
 
82
  : nsDeviceContextX()
 
83
{
 
84
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::nsDeviceContextXlib()\n"));
 
85
  mTwipsToPixels = 1.0;
 
86
  mPixelsToTwips = 1.0;
 
87
  mNumCells = 0;
 
88
  mSurface = nsnull;
 
89
  mDisplay = nsnull;
 
90
  mScreen = nsnull;
 
91
  mVisual = nsnull;
 
92
  mDepth = 0;
 
93
 
 
94
  mWidthFloat = 0.0f;
 
95
  mHeightFloat = 0.0f;
 
96
  mWidth = -1;
 
97
  mHeight = -1;
 
98
  mXlibRgbHandle = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE);
 
99
  if (!mXlibRgbHandle)
 
100
    abort();
 
101
    
 
102
  mContextCounter++;
 
103
}
 
104
 
 
105
nsDeviceContextXlib::~nsDeviceContextXlib()
 
106
{
 
107
  nsIDrawingSurfaceXlib *surf = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, mSurface);
 
108
  NS_IF_RELEASE(surf);
 
109
  mSurface = nsnull;
 
110
  
 
111
  mContextCounter--;
 
112
  
 
113
  if (mContextCounter == 0)
 
114
  {
 
115
    DeleteRenderingContextXlibContext(mRCContext);
 
116
    DeleteFontMetricsXlibContext(mFontMetricsContext);
 
117
    mRCContext          = nsnull;
 
118
    mFontMetricsContext = nsnull;
 
119
  }
 
120
}
 
121
 
 
122
nsFontMetricsXlibContext      *nsDeviceContextXlib::mFontMetricsContext = nsnull;
 
123
nsRenderingContextXlibContext *nsDeviceContextXlib::mRCContext          = nsnull;
 
124
int                            nsDeviceContextXlib::mContextCounter     = 0;
 
125
 
 
126
NS_IMETHODIMP nsDeviceContextXlib::Init(nsNativeWidget aNativeWidget)
 
127
{
 
128
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::Init()\n"));
 
129
 
 
130
  mWidget = aNativeWidget;
 
131
 
 
132
  mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
 
133
  mScreen  = xxlib_rgb_get_screen(mXlibRgbHandle);
 
134
  mVisual  = xxlib_rgb_get_visual(mXlibRgbHandle);
 
135
  mDepth   = xxlib_rgb_get_depth(mXlibRgbHandle);
 
136
 
 
137
  if (!mDefaultFont)
 
138
    mDefaultFont = XLoadQueryFont(mDisplay, XLIB_DEFAULT_FONT1);
 
139
 
 
140
  if (!mDefaultFont)
 
141
    mDefaultFont = XLoadQueryFont(mDisplay, XLIB_DEFAULT_FONT2);
 
142
 
 
143
#ifdef DEBUG
 
144
  static PRBool once = PR_TRUE;
 
145
 
 
146
  if (once)
 
147
  {
 
148
    once = PR_FALSE;
 
149
 
 
150
    printf("nsDeviceContextXlib::Init(dpy=%p  screen=%p  visual=%p  depth=%d)\n",
 
151
           mDisplay,
 
152
           mScreen,
 
153
           mVisual,
 
154
           mDepth);
 
155
  }
 
156
#endif /* DEBUG */
 
157
 
 
158
  return CommonInit();
 
159
}
 
160
 
 
161
nsresult
 
162
nsDeviceContextXlib::CommonInit(void)
 
163
{
 
164
  nsresult rv = NS_OK;;
 
165
 
 
166
  // FIXME: PeterH
 
167
  // This was set to 100 dpi, then later on in the function is was changed
 
168
  // to a default of 96dpi IF we had a preference component. We need to 
 
169
  // find a way to get the actual server dpi for a comparison ala GTK.
 
170
  static nscoord dpi = 96;
 
171
  static int initialized = 0;
 
172
 
 
173
  if (!initialized) {
 
174
    initialized = 1;
 
175
    nsresult res;
 
176
    nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &res));
 
177
    if (NS_SUCCEEDED(res) && prefs) {
 
178
      PRInt32 intVal = 96;
 
179
      res = prefs->GetIntPref("browser.display.screen_resolution", &intVal);
 
180
      if (NS_SUCCEEDED(res)) {
 
181
        if (intVal) {
 
182
          dpi = intVal;
 
183
        }
 
184
        else {
 
185
          // Compute dpi of display
 
186
          float screenWidth = float(XWidthOfScreen(mScreen));
 
187
          float screenWidthIn = float(XWidthMMOfScreen(mScreen)) / 25.4f;
 
188
          dpi = nscoord(screenWidth / screenWidthIn);
 
189
        }
 
190
      }
 
191
    }
 
192
  }
 
193
 
 
194
  // Do extra rounding (based on GTK). KenF
 
195
  mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(72)) / float(dpi)));
 
196
  mTwipsToPixels = 1.0f / mPixelsToTwips;
 
197
 
 
198
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("GFX: dpi=%d t2p=%g p2t=%g\n", dpi, mTwipsToPixels, mPixelsToTwips));
 
199
 
 
200
  mWidthFloat  = (float) XWidthOfScreen(mScreen);
 
201
  mHeightFloat = (float) XHeightOfScreen(mScreen);
 
202
 
 
203
  DeviceContextImpl::CommonInit();
 
204
  
 
205
  if (!mFontMetricsContext)
 
206
  {
 
207
    rv = CreateFontMetricsXlibContext(this, PR_FALSE, &mFontMetricsContext);
 
208
    if (NS_FAILED(rv))
 
209
      return rv;
 
210
  }
 
211
 
 
212
  if (!mRCContext)
 
213
  {
 
214
    rv = CreateRenderingContextXlibContext(this, &mRCContext);
 
215
    if (NS_FAILED(rv))
 
216
      return rv;
 
217
  }
 
218
   
 
219
  return rv;
 
220
}
 
221
 
 
222
NS_IMETHODIMP nsDeviceContextXlib::CreateRenderingContext(nsIRenderingContext *&aContext)
 
223
{
 
224
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::CreateRenderingContext()\n"));
 
225
 
 
226
#ifdef NS_PRINT_PREVIEW
 
227
  /* Defer to Alt when there is one */
 
228
  if (mAltDC && ((mUseAltDC & kUseAltDCFor_CREATERC_PAINT) || (mUseAltDC & kUseAltDCFor_CREATERC_REFLOW))) {
 
229
    return mAltDC->CreateRenderingContext(aContext);
 
230
  }
 
231
#endif /* NS_PRINT_PREVIEW */
 
232
 
 
233
  nsIRenderingContext      *context;
 
234
  nsDrawingSurfaceXlibImpl *surface = nsnull;
 
235
  nsresult                  rv;
 
236
 
 
237
  context = new nsRenderingContextXlib();
 
238
 
 
239
  if (nsnull != context) {
 
240
    NS_ADDREF(context);
 
241
    surface = new nsDrawingSurfaceXlibImpl();
 
242
    if (nsnull != surface) {
 
243
      xGC *gc = new xGC(mDisplay, (Drawable)mWidget, 0, nsnull);
 
244
      rv = surface->Init(mXlibRgbHandle,
 
245
                         (Drawable)mWidget, 
 
246
                         gc);
 
247
 
 
248
      if (NS_SUCCEEDED(rv)) {
 
249
        rv = context->Init(this, surface);
 
250
      }
 
251
    }
 
252
    else {
 
253
      rv = NS_ERROR_OUT_OF_MEMORY;
 
254
    }
 
255
  }
 
256
  else {
 
257
    rv = NS_ERROR_OUT_OF_MEMORY;
 
258
  }
 
259
  
 
260
  if (NS_FAILED(rv)) {
 
261
    NS_IF_RELEASE(context);
 
262
  }
 
263
  aContext = context;
 
264
  
 
265
  return rv;
 
266
}
 
267
 
 
268
NS_IMETHODIMP nsDeviceContextXlib::CreateRenderingContextInstance(nsIRenderingContext *&aContext)
 
269
{
 
270
  nsCOMPtr<nsIRenderingContext> renderingContext = new nsRenderingContextXlib();
 
271
  if (!renderingContext)
 
272
    return NS_ERROR_OUT_OF_MEMORY;
 
273
         
 
274
  aContext = renderingContext;
 
275
  NS_ADDREF(aContext);
 
276
  
 
277
  return NS_OK;
 
278
}
 
279
 
 
280
NS_IMETHODIMP nsDeviceContextXlib::SupportsNativeWidgets(PRBool &aSupportsWidgets)
 
281
{
 
282
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::SupportsNativeWidgets()\n"));
 
283
  aSupportsWidgets = PR_TRUE;
 
284
  return NS_OK;
 
285
}
 
286
 
 
287
NS_IMETHODIMP nsDeviceContextXlib::GetScrollBarDimensions(float &aWidth, float &aHeight) const
 
288
{
 
289
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::GetScrollBarDimensions()\n"));
 
290
  float scale;
 
291
  GetCanonicalPixelScale(scale);
 
292
  // XXX Oh, yeah.  These are hard coded.
 
293
  aWidth = 15 * mPixelsToTwips * scale;
 
294
  aHeight = 15 * mPixelsToTwips * scale;
 
295
 
 
296
  return NS_OK;
 
297
}
 
298
 
 
299
NS_IMETHODIMP nsDeviceContextXlib::GetSystemFont(nsSystemFontID anID, nsFont *aFont) const
 
300
{
 
301
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::GetSystemFont()\n"));
 
302
 
 
303
  switch (anID) {
 
304
    case eSystemFont_Caption:              // css2
 
305
    case eSystemFont_Icon:
 
306
    case eSystemFont_Menu:
 
307
    case eSystemFont_MessageBox:
 
308
    case eSystemFont_SmallCaption:
 
309
    case eSystemFont_StatusBar:
 
310
    case eSystemFont_Window:                       // css3
 
311
    case eSystemFont_Document:
 
312
    case eSystemFont_Workspace:
 
313
    case eSystemFont_Desktop:
 
314
    case eSystemFont_Info:
 
315
    case eSystemFont_Dialog:
 
316
    case eSystemFont_Button:
 
317
    case eSystemFont_PullDownMenu:
 
318
    case eSystemFont_List:
 
319
    case eSystemFont_Field:
 
320
    case eSystemFont_Tooltips:             // moz
 
321
    case eSystemFont_Widget:
 
322
      aFont->style       = NS_FONT_STYLE_NORMAL;
 
323
      aFont->weight      = NS_FONT_WEIGHT_NORMAL;
 
324
      aFont->decorations = NS_FONT_DECORATION_NONE;
 
325
 
 
326
      if (!mDefaultFont)
 
327
        return NS_ERROR_FAILURE;
 
328
      else
 
329
      {
 
330
        char *fontName = nsnull;
 
331
        unsigned long pr = 0;
 
332
 
 
333
        ::XGetFontProperty(mDefaultFont, XA_FULL_NAME, &pr);
 
334
        if(pr)
 
335
          {
 
336
            fontName = XGetAtomName(mDisplay, pr);
 
337
            aFont->name.AssignWithConversion(fontName);
 
338
            ::XFree(fontName);
 
339
          }
 
340
  
 
341
        pr = 0;
 
342
        ::XGetFontProperty(mDefaultFont, XA_WEIGHT, &pr);
 
343
        if ( pr > 10 )
 
344
          aFont->weight = NS_FONT_WEIGHT_BOLD;
 
345
    
 
346
        pr = 0;
 
347
        Atom pixelSizeAtom = ::XInternAtom(mDisplay, "PIXEL_SIZE", 0);
 
348
        ::XGetFontProperty(mDefaultFont, pixelSizeAtom, &pr);
 
349
        if( pr )
 
350
          aFont->size = NSIntPixelsToTwips(pr, mPixelsToTwips);
 
351
 
 
352
        pr = 0;
 
353
        ::XGetFontProperty(mDefaultFont, XA_ITALIC_ANGLE, &pr );
 
354
        if( pr )
 
355
          aFont->style = NS_FONT_STYLE_ITALIC;
 
356
    
 
357
        pr = 0;
 
358
        ::XGetFontProperty(mDefaultFont, XA_UNDERLINE_THICKNESS, &pr);
 
359
        if( pr )
 
360
          aFont->decorations = NS_FONT_DECORATION_UNDERLINE;
 
361
      }
 
362
      break;
 
363
  }
 
364
 
 
365
  aFont->systemFont = PR_TRUE;
 
366
 
 
367
  return NS_OK;
 
368
}
 
369
 
 
370
NS_IMETHODIMP nsDeviceContextXlib::CheckFontExistence(const nsString& aFontName)
 
371
{
 
372
  return nsFontMetricsXlib::FamilyExists(mFontMetricsContext, aFontName);
 
373
}
 
374
 
 
375
NS_IMETHODIMP nsDeviceContextXlib::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
 
376
{
 
377
#ifdef NS_PRINT_PREVIEW                                                         
 
378
  /* Defer to Alt when there is one */
 
379
  if (mAltDC && (mUseAltDC & kUseAltDCFor_SURFACE_DIM)) {
 
380
    return mAltDC->GetDeviceSurfaceDimensions(aWidth, aHeight);
 
381
  }
 
382
#endif /* NS_PRINT_PREVIEW */
 
383
 
 
384
  if (mWidth == -1)
 
385
    mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
 
386
 
 
387
  if (mHeight == -1)
 
388
    mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
 
389
 
 
390
  aWidth = mWidth;
 
391
  aHeight = mHeight;
 
392
 
 
393
  return NS_OK;
 
394
}
 
395
 
 
396
NS_IMETHODIMP nsDeviceContextXlib::GetRect(nsRect &aRect)
 
397
{
 
398
  PRInt32 width, height;
 
399
  nsresult rv;
 
400
  rv = GetDeviceSurfaceDimensions(width, height);
 
401
  aRect.x = 0;
 
402
  aRect.y = 0;
 
403
  aRect.width = width;
 
404
  aRect.height = height;
 
405
  return rv;
 
406
}
 
407
 
 
408
NS_IMETHODIMP nsDeviceContextXlib::GetClientRect(nsRect &aRect)
 
409
{
 
410
  PRInt32 width, height;
 
411
  nsresult rv;
 
412
  rv = GetDeviceSurfaceDimensions(width, height);
 
413
  aRect.x = 0;
 
414
  aRect.y = 0;
 
415
  aRect.width = width;
 
416
  aRect.height = height;
 
417
  return rv;
 
418
}
 
419
 
 
420
NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
 
421
                                                       nsIDeviceContext *&aContext)
 
422
{
 
423
  nsresult                 rv;
 
424
  PrintMethod              method;
 
425
  nsDeviceContextSpecXlib *spec = NS_STATIC_CAST(nsDeviceContextSpecXlib *, aDevice);
 
426
  
 
427
  rv = spec->GetPrintMethod(method);
 
428
  if (NS_FAILED(rv)) 
 
429
    return rv;
 
430
 
 
431
#ifdef USE_XPRINT
 
432
  if (method == pmXprint) { // XPRINT
 
433
    static NS_DEFINE_CID(kCDeviceContextXp, NS_DEVICECONTEXTXP_CID);
 
434
    nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
 
435
    NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context.");    
 
436
    if (NS_FAILED(rv)) 
 
437
      return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
 
438
    
 
439
    rv = dcxp->SetSpec(aDevice);
 
440
    if (NS_FAILED(rv)) 
 
441
      return rv;
 
442
    
 
443
    rv = dcxp->InitDeviceContextXP((nsIDeviceContext*)aContext,
 
444
                                   (nsIDeviceContext*)this);
 
445
    if (NS_FAILED(rv)) 
 
446
      return rv;
 
447
      
 
448
    rv = dcxp->QueryInterface(NS_GET_IID(nsIDeviceContext),
 
449
                              (void **)&aContext);
 
450
    return rv;
 
451
  }
 
452
  else
 
453
#endif /* USE_XPRINT */
 
454
#ifdef USE_POSTSCRIPT
 
455
  if (method == pmPostScript) { // PostScript
 
456
    // default/PS
 
457
    static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
 
458
  
 
459
    // Create a Postscript device context 
 
460
    nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv));
 
461
    NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context.");
 
462
    if (NS_FAILED(rv)) 
 
463
      return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
 
464
  
 
465
    rv = dcps->SetSpec(aDevice);
 
466
    if (NS_FAILED(rv)) 
 
467
      return rv;
 
468
      
 
469
    rv = dcps->InitDeviceContextPS((nsIDeviceContext*)aContext,
 
470
                                   (nsIDeviceContext*)this);
 
471
    if (NS_FAILED(rv)) 
 
472
      return rv;
 
473
 
 
474
    rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext),
 
475
                              (void **)&aContext);
 
476
    return rv;
 
477
  }
 
478
#endif /* USE_POSTSCRIPT */  
 
479
  
 
480
  NS_WARNING("no print module created.");
 
481
  return NS_ERROR_UNEXPECTED;
 
482
}
 
483
 
 
484
NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
 
485
{
 
486
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::BeginDocument()\n"));
 
487
  return NS_OK;
 
488
}
 
489
 
 
490
NS_IMETHODIMP nsDeviceContextXlib::EndDocument(void)
 
491
{
 
492
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::EndDocument()\n"));
 
493
  return NS_OK;
 
494
}
 
495
 
 
496
NS_IMETHODIMP nsDeviceContextXlib::AbortDocument(void)
 
497
{
 
498
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::EndDocument()\n"));
 
499
  return NS_OK;
 
500
}
 
501
 
 
502
NS_IMETHODIMP nsDeviceContextXlib::BeginPage(void)
 
503
{
 
504
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::BeginPage()\n"));
 
505
  return NS_OK;
 
506
}
 
507
 
 
508
NS_IMETHODIMP nsDeviceContextXlib::EndPage(void)
 
509
{
 
510
  PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::EndPage()\n"));
 
511
  return NS_OK;
 
512
}
 
513
 
 
514
class nsFontCacheXlib : public nsFontCache
 
515
{
 
516
public:
 
517
  /* override DeviceContextImpl::CreateFontCache() */
 
518
  virtual nsresult CreateFontMetricsInstance(nsIFontMetrics** aResult);
 
519
};
 
520
 
 
521
 
 
522
nsresult nsFontCacheXlib::CreateFontMetricsInstance(nsIFontMetrics** aResult)
 
523
{
 
524
  NS_PRECONDITION(aResult, "null out param");
 
525
  nsIFontMetrics *fm = new nsFontMetricsXlib();
 
526
  if (!fm)
 
527
    return NS_ERROR_OUT_OF_MEMORY;
 
528
  NS_ADDREF(fm);
 
529
  *aResult = fm;
 
530
  return NS_OK;
 
531
}
 
532
 
 
533
/* override DeviceContextImpl::CreateFontCache() */
 
534
NS_IMETHODIMP nsDeviceContextXlib::CreateFontCache()
 
535
{
 
536
  mFontCache = new nsFontCacheXlib();
 
537
  if (nsnull == mFontCache) {
 
538
    return NS_ERROR_OUT_OF_MEMORY;
 
539
  }
 
540
  return mFontCache->Init(this);
 
541
}
 
542
 
 
543