Bug 385891: Removal of non-Cairo code from nsFrame.cpp and nsObjectFrame.cpp, p=alfredkayser, r/sr/a=dbaron
authormozilla@weilbacher.org
Thu, 23 Aug 2007 17:13:43 -0700
changeset 5235 958cceee3e7b995a524fcd4ef11fc56e885d3fa1
parent 5233 f38b2abd857d64caaa6ad115ab0660993f4eed47
child 5236 d397bdce2c5477801df62e5b842eb09814d200a0
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs385891
milestone1.9a8pre
Bug 385891: Removal of non-Cairo code from nsFrame.cpp and nsObjectFrame.cpp, p=alfredkayser, r/sr/a=dbaron
layout/base/Makefile.in
layout/base/nsISelectionImageService.idl
layout/base/nsPresContext.cpp
layout/build/nsLayoutCID.h
layout/build/nsLayoutModule.cpp
layout/generic/nsFrame.cpp
layout/generic/nsObjectFrame.cpp
--- a/layout/base/Makefile.in
+++ b/layout/base/Makefile.in
@@ -74,32 +74,25 @@ REQUIRES	= xpcom \
 		  imglib2 \
 		  unicharutil \
 		  htmlparser \
 		  util \
 		  windowwatcher \
 		  accessibility \
 		  shistory \
 		  caps \
+		  thebes \
+		  cairo \
 		  $(NULL)
 
-ifdef MOZ_ENABLE_CAIRO_GFX
-REQUIRES += thebes cairo
-endif
 
 XPIDLSRCS	= \
 		nsIStyleSheetService.idl	\
 		$(NULL)
 
-ifndef MOZ_ENABLE_CAIRO_GFX
-XPIDLSRCS	+= \
-		nsISelectionImageService.idl	\
-		$(NULL)
-endif
-
 EXPORTS		= \
 		nsBidi.h \
 		nsBidiPresUtils.h \
 		nsCSSFrameConstructor.h \
 		nsChangeHint.h \
 		nsCompatibility.h \
 		nsDisplayList.h \
 		nsFrameManager.h \
@@ -178,13 +171,11 @@ LOCAL_INCLUDES += \
         -I$(srcdir)/../mathml/base/src
 endif
 
 ifdef MOZ_SVG
 LOCAL_INCLUDES += \
         -I$(srcdir)/../svg/base/src
 endif
 
-ifdef MOZ_ENABLE_CAIRO_GFX
 CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
-endif
 
 DEFINES += -D_IMPL_NS_LAYOUT
deleted file mode 100644
--- a/layout/base/nsISelectionImageService.idl
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Mozilla browser.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications, Inc.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-
-%{ C++
-class imgIContainer;
-%}
-
-[ptr] native imgIContainer(imgIContainer);
-
-
-[uuid(f6f68e3c-f078-4235-bf71-53d180c37d26)]
-interface nsISelectionImageService : nsISupports
-{
-	/**
-	* the current image is marked as invalid
-	*/
-	void reset();
-
-	/**
-	* retrieve the image for alpha blending
-	*/
-	void getImage(in short selectionValue, out imgIContainer container);
-
-};
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -87,19 +87,17 @@
 #include "nsContentUtils.h"
 
 // Needed for Start/Stop of Image Animation
 #include "imgIContainer.h"
 #include "nsIImageLoadingContent.h"
 
 //needed for resetting of image service color
 #include "nsLayoutCID.h"
-#ifndef MOZ_CAIRO_GFX
-#include "nsISelectionImageService.h"
-#endif
+
 static nscolor
 MakeColorPref(const char *colstr)
 {
   PRUint32 red, green, blue;
   nscolor colorref;
 
   // 4.x stored RGB color values as a string rather than as an int,
   // thus we need to do this conversion
@@ -150,17 +148,16 @@ PR_STATIC_CALLBACK(PLDHashOperator)
 destroy_loads(const void * aKey, nsCOMPtr<nsImageLoader>& aData, void* closure)
 {
   aData->Destroy();
   return PL_DHASH_NEXT;
 }
 
 static NS_DEFINE_CID(kLookAndFeelCID,  NS_LOOKANDFEEL_CID);
 #include "nsContentCID.h"
-static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
 
   // NOTE! nsPresContext::operator new() zeroes out all members, so don't
   // bother initializing members to 0.
 
 nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
   : mType(aType), mDocument(aDocument), mTextZoom(1.0), mFullZoom(1.0),
     mPageSize(-1, -1), mPPScale(1.0f),
     mViewportStyleOverflow(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO),
@@ -1385,28 +1382,16 @@ nsPresContext::SysColorChangedInternal()
     mLookAndFeel->LookAndFeelChanged();
     sLookAndFeelChanged = PR_FALSE;
   }
    
   // Reset default background and foreground colors for the document since
   // they may be using system colors
   GetDocumentColorPreferences();
 
-#ifndef MOZ_CAIRO_GFX
-  // Clear out all of the style data since it may contain RGB values
-  // which originated from system colors.
-  nsCOMPtr<nsISelectionImageService> imageService;
-  nsresult result;
-  imageService = do_GetService(kSelectionImageService, &result);
-  if (NS_SUCCEEDED(result) && imageService)
-  {
-    imageService->Reset();
-  }
-#endif
-
   // We need to do a full reflow (and view update) here. Clearing the style
   // data without reflowing/updating views will lead to incorrect change hints
   // later, because when generating change hints, any style structs which have
   // been cleared and not reread are assumed to not be used at all.
   ClearStyleDataAndReflow();
 }
 
 void
--- a/layout/build/nsLayoutCID.h
+++ b/layout/build/nsLayoutCID.h
@@ -193,20 +193,16 @@
 // {6030f7ef-32ed-46a7-9a63-6a5d3f90445f}
 #define NS_PLAINTEXTSERIALIZER_CID \
 { 0x6030f7ef, 0x32ed, 0x46a7, { 0x9a, 0x63, 0x6a, 0x5d, 0x3f, 0x90, 0x44, 0x5f } }
 
 // {5C5AF390-34BE-11d5-A03B-0010A4EF48C9}
 #define NS_LAYOUT_HISTORY_STATE_CID \
 { 0x5c5af390, 0x34be, 0x11d5, { 0xa0, 0x3b, 0x00, 0x10, 0xa4, 0xef, 0x48, 0xc9 } }
 
-// {9d1001b1-e59a-456b-99dc-cc3f1283236e}
-#define NS_SELECTIONIMAGESERVICE_CID \
-{ 0x9d1001b1, 0xe59a, 0x456b, { 0x99, 0xdc, 0xcc, 0x3f, 0x12, 0x83, 0x23, 0x6e } }
-
 // {E14B66F6-BFC5-11d2-B57E-00105AA83B2F}
 #define NS_CARET_CID \
 { 0xe14b66f6, 0xbfc5, 0x11d2, { 0xb5, 0x7e, 0x0, 0x10, 0x5a, 0xa8, 0x3b, 0x2f } }
 
 // {f96f5ec9-755b-447e-b1f3-717d1a84bb41}
 #define NS_PLUGINDOCUMENT_CID \
 { 0xf96f5ec9, 0x755b, 0x447e, { 0xb1, 0xf3, 0x71, 0x7d, 0x1a, 0x84, 0xbb, 0x41 } }
 
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -91,19 +91,16 @@
 #include "nsXMLContentSerializer.h"
 #include "nsRuleNode.h"
 #include "nsWyciwygProtocolHandler.h"
 #include "nsContentAreaDragDrop.h"
 #include "nsContentList.h"
 #include "nsSyncLoadService.h"
 #include "nsBox.h"
 #include "nsIFrameTraversal.h"
-#ifndef MOZ_CAIRO_GFX
-#include "nsISelectionImageService.h"
-#endif
 #include "nsLayoutCID.h"
 #include "nsILanguageAtomService.h"
 #include "nsStyleSheetService.h"
 
 // Transformiix stuff
 #include "nsXPathEvaluator.h"
 #include "txMozillaXSLTProcessor.h"
 #include "txNodeSetAdaptor.h"
@@ -393,20 +390,16 @@ nsresult NS_NewTreeBoxObject(nsIBoxObjec
 #endif
 
 #ifdef MOZ_ENABLE_CANVAS
 nsresult NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult);
 #endif
 
 nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
 
-#ifndef MOZ_CAIRO_GFX
-nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult);
-#endif
-
 nsresult NS_NewSelection(nsFrameSelection** aResult);
 nsresult NS_NewDomSelection(nsISelection** aResult);
 nsresult NS_NewDocumentViewer(nsIDocumentViewer** aResult);
 nsresult NS_NewRange(nsIDOMRange** aResult);
 nsresult NS_NewRangeUtils(nsIRangeUtils** aResult);
 nsresult NS_NewContentIterator(nsIContentIterator** aResult);
 nsresult NS_NewPreContentIterator(nsIContentIterator** aResult);
 nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult);
@@ -459,38 +452,34 @@ MAKE_CTOR(CreateNewContainerBoxObject,  
 NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMView)
 #endif
 NS_GENERIC_FACTORY_CONSTRUCTOR(inDeepTreeWalker)
 NS_GENERIC_FACTORY_CONSTRUCTOR(inFlasher)
 NS_GENERIC_FACTORY_CONSTRUCTOR(inCSSValueSearch)
 NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMUtils)
 #endif
 
-#ifndef MOZ_CAIRO_GFX
-MAKE_CTOR(CreateSelectionImageService,  nsISelectionImageService,NS_NewSelectionImageService)
-#endif
-MAKE_CTOR(CreateCaret,                  nsICaret,               NS_NewCaret)
-
+MAKE_CTOR(CreateCaret,                    nsICaret,                    NS_NewCaret)
 MAKE_CTOR(CreateNameSpaceManager,         nsINameSpaceManager,         NS_GetNameSpaceManager)
 MAKE_CTOR(CreateEventListenerManager,     nsIEventListenerManager,     NS_NewEventListenerManager)
 MAKE_CTOR(CreateDOMEventGroup,            nsIDOMEventGroup,            NS_NewDOMEventGroup)
 MAKE_CTOR(CreateDocumentViewer,           nsIDocumentViewer,           NS_NewDocumentViewer)
 MAKE_CTOR(CreateCSSStyleSheet,            nsICSSStyleSheet,            NS_NewCSSStyleSheet)
 MAKE_CTOR(CreateHTMLDocument,             nsIDocument,                 NS_NewHTMLDocument)
 MAKE_CTOR(CreateHTMLCSSStyleSheet,        nsIHTMLCSSStyleSheet,        NS_NewHTMLCSSStyleSheet)
 MAKE_CTOR(CreateDOMImplementation,        nsIDOMDOMImplementation,     NS_NewDOMImplementation)
 MAKE_CTOR(CreateXMLDocument,              nsIDocument,                 NS_NewXMLDocument)
 #ifdef MOZ_SVG
 MAKE_CTOR(CreateSVGDocument,              nsIDocument,                 NS_NewSVGDocument)
 #endif
 MAKE_CTOR(CreateImageDocument,            nsIDocument,                 NS_NewImageDocument)
 MAKE_CTOR(CreateCSSParser,                nsICSSParser,                NS_NewCSSParser)
 MAKE_CTOR(CreateCSSLoader,                nsICSSLoader,                NS_NewCSSLoader)
 MAKE_CTOR(CreateDOMSelection,             nsISelection,                NS_NewDomSelection)
-MAKE_CTOR(CreateSelection,                nsFrameSelection,                 NS_NewSelection)
+MAKE_CTOR(CreateSelection,                nsFrameSelection,            NS_NewSelection)
 MAKE_CTOR(CreateRange,                    nsIDOMRange,                 NS_NewRange)
 MAKE_CTOR(CreateRangeUtils,               nsIRangeUtils,               NS_NewRangeUtils)
 MAKE_CTOR(CreateContentIterator,          nsIContentIterator,          NS_NewContentIterator)
 MAKE_CTOR(CreatePreContentIterator,       nsIContentIterator,          NS_NewPreContentIterator)
 MAKE_CTOR(CreateSubtreeIterator,          nsIContentIterator,          NS_NewContentSubtreeIterator)
 // CreateHTMLImgElement, see below
 // CreateHTMLOptionElement, see below
 MAKE_CTOR(CreateTextEncoder,              nsIDocumentEncoder,          NS_NewTextEncoder)
@@ -799,23 +788,16 @@ static const nsModuleComponentInfo gComp
     CreateNewLayoutDebugger },
 #endif
 
   { "Frame Traversal",
     NS_FRAMETRAVERSAL_CID,
     nsnull,
     CreateNewFrameTraversal },
 
-#ifndef MOZ_CAIRO_GFX
-  { "selection image storage",
-    NS_SELECTIONIMAGESERVICE_CID,
-    nsnull,
-    CreateSelectionImageService },
-#endif
-
   { "caret",
     NS_CARET_CID,
     "@mozilla.org/layout/caret;1",
     CreateCaret },
 
   // XXX ick
   { "Presentation shell",
     NS_PRESSHELL_CID,
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -101,38 +101,32 @@
 #include "nsIPercentHeightObserver.h"
 
 #ifdef IBMBIDI
 #include "nsBidiPresUtils.h"
 #endif
 
 // For triple-click pref
 #include "nsIServiceManager.h"
-#ifndef MOZ_CAIRO_GFX
-#include "nsISelectionImageService.h"
-#endif
 #include "imgIContainer.h"
 #include "imgIRequest.h"
 #include "gfxIImageFrame.h"
 #include "nsILookAndFeel.h"
 #include "nsLayoutCID.h"
 #include "nsWidgetsCID.h"     // for NS_LOOKANDFEEL_CID
 #include "nsUnicharUtils.h"
 #include "nsLayoutErrors.h"
 #include "nsContentErrors.h"
 #include "nsHTMLContainerFrame.h"
 #include "nsBoxLayoutState.h"
 #include "nsBlockFrame.h"
 #include "nsDisplayList.h"
 
-#ifdef MOZ_CAIRO_GFX
 #include "gfxContext.h"
-#endif
-
-static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
+
 static NS_DEFINE_CID(kLookAndFeelCID,  NS_LOOKANDFEEL_CID);
 static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
 
 // Struct containing cached metrics for box-wrapped frames.
 struct nsBoxLayoutMetrics
 {
   nsSize mPrefSize;
   nsSize mMinSize;
@@ -280,163 +274,16 @@ nsIFrameDebug::RootFrameList(nsPresConte
       if(NS_SUCCEEDED(rv))
         debugFrame->List(out, aIndent);
     }
   }
 }
 #endif
 // end nsIFrameDebug
 
-#ifndef MOZ_CAIRO_GFX
-// frame image selection drawing service implementation
-class SelectionImageService : public nsISelectionImageService
-{
-public:
-  SelectionImageService();
-  virtual ~SelectionImageService();
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSISELECTIONIMAGESERVICE
-private:
-  nsresult CreateImage(nscolor aImageColor, imgIContainer *aContainer);
-  nsCOMPtr<imgIContainer> mContainer;
-  nsCOMPtr<imgIContainer> mDisabledContainer;
-};
-
-NS_IMPL_ISUPPORTS1(SelectionImageService, nsISelectionImageService)
-
-SelectionImageService::SelectionImageService()
-{
-}
-
-SelectionImageService::~SelectionImageService()
-{
-}
-
-NS_IMETHODIMP
-SelectionImageService::GetImage(PRInt16 aSelectionValue, imgIContainer **aContainer)
-{
-  *aContainer = nsnull;
-
-  nsCOMPtr<imgIContainer>* container = &mContainer;
-  nsILookAndFeel::nsColorID colorID;
-  if (aSelectionValue == nsISelectionController::SELECTION_ON) {
-    colorID = nsILookAndFeel::eColor_TextSelectBackground;
-  } else if (aSelectionValue == nsISelectionController::SELECTION_ATTENTION) {
-    colorID = nsILookAndFeel::eColor_TextSelectBackgroundAttention;
-  } else {
-    container = &mDisabledContainer;
-    colorID = nsILookAndFeel::eColor_TextSelectBackgroundDisabled;
-  }
-
-  if (!*container) {
-    nsresult result;
-    *container = do_CreateInstance("@mozilla.org/image/container;1", &result);
-    if (NS_FAILED(result))
-      return result;
-
-    nscolor color = NS_RGB(255, 255, 255);
-    nsCOMPtr<nsILookAndFeel> look = do_GetService(kLookAndFeelCID);
-    if (look)
-      look->GetColor(colorID, color);
-    CreateImage(color, *container);
-  }
-
-  *aContainer = *container; 
-  NS_ADDREF(*aContainer);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SelectionImageService::Reset()
-{
-  mContainer = 0;
-  mDisabledContainer = 0;
-  return NS_OK;
-}
-
-#define SEL_IMAGE_WIDTH 32
-#define SEL_IMAGE_HEIGHT 32
-#define SEL_ALPHA_AMOUNT 128
-
-nsresult
-SelectionImageService::CreateImage(nscolor aImageColor, imgIContainer *aContainer)
-{
-  if (aContainer)
-  {
-    nsresult result = aContainer->Init(SEL_IMAGE_WIDTH,SEL_IMAGE_HEIGHT,nsnull);
-    if (NS_SUCCEEDED(result))
-    {
-      nsCOMPtr<gfxIImageFrame> image = do_CreateInstance("@mozilla.org/gfx/image/frame;2",&result);
-      if (NS_SUCCEEDED(result) && image)
-      {
-        image->Init(0, 0, SEL_IMAGE_WIDTH, SEL_IMAGE_HEIGHT, gfxIFormats::RGB_A8, 24);
-        aContainer->AppendFrame(image);
-
-        PRUint32 bpr, abpr;
-        image->GetImageBytesPerRow(&bpr);
-        image->GetAlphaBytesPerRow(&abpr);
-
-        //it's better to temporarily go after heap than put big data on stack
-        unsigned char *row_data = (unsigned char *)malloc(bpr);
-        if (!row_data)
-          return NS_ERROR_OUT_OF_MEMORY;
-        unsigned char *alpha = (unsigned char *)malloc(abpr);
-        if (!alpha)
-        {
-          free (row_data);
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
-        unsigned char *data = row_data;
-
-        PRInt16 i;
-        for (i = 0; i < SEL_IMAGE_WIDTH; i++)
-        {
-#if defined(XP_WIN) || defined(XP_OS2)
-          *data++ = NS_GET_B(aImageColor);
-          *data++ = NS_GET_G(aImageColor);
-          *data++ = NS_GET_R(aImageColor);
-#else
-#if defined(XP_MAC) || defined(XP_MACOSX)
-          *data++ = 0;
-#endif
-          *data++ = NS_GET_R(aImageColor);
-          *data++ = NS_GET_G(aImageColor);
-          *data++ = NS_GET_B(aImageColor);
-#endif
-        }
-
-        memset((void *)alpha, SEL_ALPHA_AMOUNT, abpr);
-
-        for (i = 0; i < SEL_IMAGE_HEIGHT; i++)
-        {
-          image->SetAlphaData(alpha, abpr, i*abpr);
-          image->SetImageData(row_data,  bpr, i*bpr);
-        }
-        free(row_data);
-        free(alpha);
-        return NS_OK;
-      }
-    } 
-  }
-  return NS_ERROR_FAILURE;
-}
-
-
-nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult)
-{
-  *aResult = new SelectionImageService;
-  if (!*aResult)
-    return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aResult);
-  return NS_OK;
-}
-#endif /* MOZ_CAIRO_GFX */
-
-//end selection service
-
 void
 nsWeakFrame::Init(nsIFrame* aFrame)
 {
   Clear(mFrame ? mFrame->PresContext()->GetPresShell() : nsnull);
   mFrame = aFrame;
   if (mFrame) {
     nsIPresShell* shell = mFrame->PresContext()->GetPresShell();
     NS_WARN_IF_FALSE(shell, "Null PresShell in nsWeakFrame!");
@@ -905,32 +752,16 @@ public:
   NS_DISPLAY_DECL_NAME("SelectionOverlay")
 private:
   PRInt16 mSelectionValue;
 };
 
 void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
      nsIRenderingContext* aCtx, const nsRect& aDirtyRect)
 {
-#ifndef MOZ_CAIRO_GFX
-  nsCOMPtr<nsISelectionImageService> imageService
-      = do_GetService(kSelectionImageService);
-  if (!imageService)
-    return;
-
-
-  nsCOMPtr<imgIContainer> container;
-  imageService->GetImage(mSelectionValue, getter_AddRefs(container));
-  if (!container)
-    return;
-  
-  nsRect rect(aBuilder->ToReferenceFrame(mFrame), mFrame->GetSize());
-  rect.IntersectRect(rect, aDirtyRect);
-  aCtx->DrawTile(container, 0, 0, &rect);
-#else
   nscolor color = NS_RGB(255, 255, 255);
   
   nsILookAndFeel::nsColorID colorID;
   nsresult result;
   if (mSelectionValue == nsISelectionController::SELECTION_ON) {
     colorID = nsILookAndFeel::eColor_TextSelectBackground;
   } else if (mSelectionValue == nsISelectionController::SELECTION_ATTENTION) {
     colorID = nsILookAndFeel::eColor_TextSelectBackgroundAttention;
@@ -950,17 +781,16 @@ void nsDisplaySelectionOverlay::Paint(ns
   ctx->SetColor(c);
 
   nsRect rect(aBuilder->ToReferenceFrame(mFrame), mFrame->GetSize());
   rect.IntersectRect(rect, aDirtyRect);
   rect.ScaleRoundOut(1.0f / mFrame->PresContext()->AppUnitsPerDevPixel());
   ctx->NewPath();
   ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height), PR_TRUE);
   ctx->Fill();
-#endif
 }
 
 /********************************************************
 * Refreshes each content's frame
 *********************************************************/
 
 nsresult
 nsFrame::DisplaySelectionOverlay(nsDisplayListBuilder*   aBuilder,
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -119,19 +119,17 @@
 #include "nsObjectFrame.h"
 #include "nsIObjectFrame.h"
 #include "nsPluginNativeWindow.h"
 #include "nsPIPluginHost.h"
 #include "nsIPluginDocument.h"
 
 #include "nsThreadUtils.h"
 
-#ifdef MOZ_CAIRO_GFX
 #include "gfxContext.h"
-#endif
 
 // accessibility support
 #ifdef ACCESSIBILITY
 #include "nsIAccessibilityService.h"
 #endif
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG 1 /* Allow logging in the release build */
@@ -1223,18 +1221,16 @@ nsObjectFrame::PaintPlugin(nsIRenderingC
       /*
        * Layout now has an optimized way of painting. Now we always get
        * a new drawing surface, sized to be just what's needed. Windowless
        * plugins need a transform applied to their origin so they paint
        * in the right place. Since |SetWindow| is no longer being used
        * to tell the plugin where it is, we dispatch a NPWindow through
        * |HandleEvent| to tell the plugin when its window moved
        */
-
-#ifdef MOZ_CAIRO_GFX
       nsRefPtr<gfxContext> ctx = (gfxContext*)aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
       gfxMatrix ctxMatrix = ctx->CurrentMatrix();
       if (ctxMatrix.HasNonTranslation()) {
         // soo; in the future, we should be able to render
         // the object content to an offscreen DC, and then
         // composite it in with the right transforms.
 
         // But, we don't bother doing that, because we don't
@@ -1254,21 +1250,16 @@ nsObjectFrame::PaintPlugin(nsIRenderingC
 
       /* Set the device offsets as appropriate, for whatever our current group offsets might be */
       gfxFloat xoff, yoff;
       nsRefPtr<gfxASurface> surf = ctx->CurrentSurface(&xoff, &yoff);
 
       POINT origViewportOrigin;
       GetViewportOrgEx(hdc, &origViewportOrigin);
       SetViewportOrgEx(hdc, origViewportOrigin.x + (int) xoff, origViewportOrigin.y + (int) yoff, NULL);
-#else
-      nsTransform2D* rcTransform;
-      aRenderingContext.GetCurrentTransform(rcTransform);
-      rcTransform->GetTranslationCoord(&origin.x, &origin.y);
-#endif
 
       if ((window->x != origin.x) || (window->y != origin.y)) {
         window->x = origin.x;
         window->y = origin.y;
         doupdatewindow = PR_TRUE;
       }
 
       // if our location or visible area has changed, we need to tell the plugin
@@ -1317,21 +1308,18 @@ nsObjectFrame::PaintPlugin(nsIRenderingC
       }
 
       // FIXME - Bug 385435:
       // This expects a dirty rect relative to the plugin's rect
       // XXX I wonder if this breaks if we give the frame a border so the
       // frame origin and plugin origin are not the same
       mInstanceOwner->Paint(aDirtyRect, hdc);
 
-#ifdef MOZ_CAIRO_GFX
       RestoreDC(hdc, -1);
-
       surf->MarkDirty();
-#endif
     }
   }
 #endif
 }
 
 NS_IMETHODIMP
 nsObjectFrame::HandleEvent(nsPresContext* aPresContext,
                            nsGUIEvent*     anEvent,