Bug 669028 part.13 layout should use mozilla::LookAndFeel rather than nsILookAndFeel r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 09 Sep 2011 11:27:13 +0900
changeset 76819 8f20dc5f4c8fe4384be9f9dc9f04a01b3b8d3bd6
parent 76818 36da7ff7039c54ecc28c3968f02166c5bf5978ab
child 76820 4a5d378339d95a1507fb498c69bd0caf265c8c50
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersroc
bugs669028
milestone9.0a1
Bug 669028 part.13 layout should use mozilla::LookAndFeel rather than nsILookAndFeel r=roc
layout/base/nsCaret.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/forms/nsFormControlFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsFrameSetFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsTextFrameThebes.cpp
layout/mathml/nsMathMLChar.cpp
layout/svg/base/src/nsSVGGlyphFrame.cpp
layout/tables/nsTableCellFrame.cpp
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -53,27 +53,27 @@
 #include "nsIDOMRange.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsIDOMCharacterData.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsRenderingContext.h"
 #include "nsPresContext.h"
-#include "nsILookAndFeel.h"
 #include "nsBlockFrame.h"
 #include "nsISelectionController.h"
 #include "nsDisplayList.h"
 #include "nsCaret.h"
 #include "nsTextFrame.h"
 #include "nsXULPopupManager.h"
 #include "nsMenuPopupFrame.h"
 #include "nsTextFragment.h"
 #include "nsThemeConstants.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/LookAndFeel.h"
 
 // The bidi indicator hangs off the caret to one side, to show which
 // direction the typing is in. It needs to be at least 2x2 to avoid looking like 
 // an insignificant dot
 static const PRInt32 kMinBidiIndicatorPixels = 2;
 
 #ifdef IBMBIDI
 #include "nsIBidiKeyboard.h"
@@ -176,37 +176,28 @@ nsCaret::~nsCaret()
 //-----------------------------------------------------------------------------
 nsresult nsCaret::Init(nsIPresShell *inPresShell)
 {
   NS_ENSURE_ARG(inPresShell);
 
   mPresShell = do_GetWeakReference(inPresShell);    // the presshell owns us, so no addref
   NS_ASSERTION(mPresShell, "Hey, pres shell should support weak refs");
 
-  // get nsILookAndFeel from the pres context, which has one cached.
-  nsILookAndFeel *lookAndFeel = nsnull;
-  nsPresContext *presContext = inPresShell->GetPresContext();
-  
-  // XXX we should just do this nsILookAndFeel consultation every time
+  // XXX we should just do this LookAndFeel consultation every time
   // we need these values.
-  mCaretWidthCSSPx = 1;
-  mCaretAspectRatio = 0;
-  if (presContext && (lookAndFeel = presContext->LookAndFeel())) {
-    PRInt32 tempInt;
-    float tempFloat;
-    if (NS_SUCCEEDED(lookAndFeel->GetMetric(nsILookAndFeel::eMetric_CaretWidth, tempInt)))
-      mCaretWidthCSSPx = (nscoord)tempInt;
-    if (NS_SUCCEEDED(lookAndFeel->GetMetric(nsILookAndFeel::eMetricFloat_CaretAspectRatio, tempFloat)))
-      mCaretAspectRatio = tempFloat;
-    if (NS_SUCCEEDED(lookAndFeel->GetMetric(nsILookAndFeel::eMetric_CaretBlinkTime, tempInt)))
-      mBlinkRate = (PRUint32)tempInt;
-    if (NS_SUCCEEDED(lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ShowCaretDuringSelection, tempInt)))
-      mShowDuringSelection = tempInt ? PR_TRUE : PR_FALSE;
-  }
-  
+  mCaretWidthCSSPx = LookAndFeel::GetInt(LookAndFeel::eIntID_CaretWidth, 1);
+  mCaretAspectRatio =
+    LookAndFeel::GetFloat(LookAndFeel::eFloatID_CaretAspectRatio, 0.0f);
+
+  mBlinkRate = static_cast<PRUint32>(
+    LookAndFeel::GetInt(LookAndFeel::eIntID_CaretBlinkTime, mBlinkRate));
+  mShowDuringSelection =
+    LookAndFeel::GetInt(LookAndFeel::eIntID_ShowCaretDuringSelection,
+                        mShowDuringSelection ? 1 : 0) != 0;
+
   // get the selection from the pres shell, and set ourselves up as a selection
   // listener
 
   nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShell);
   if (!selCon)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsISelection> domSelection;
@@ -547,20 +538,20 @@ void nsCaret::PaintCaret(nsDisplayListBu
   // -moz-fieldtext (the color of the text in a textbox). If it doesn't match
   // we are likely in contenteditable or a custom widget and we risk being hard to see
   // against the background. In that case, fall back to the CSS color.
   nsPresContext* presContext = aForFrame->PresContext();
 
   if (GetHookRect().IsEmpty() && presContext) {
     nsITheme *theme = presContext->GetTheme();
     if (theme && theme->ThemeSupportsWidget(presContext, aForFrame, NS_THEME_TEXTFIELD_CARET)) {
-      nsILookAndFeel* lookAndFeel = presContext->LookAndFeel();
       nscolor fieldText;
-      if (NS_SUCCEEDED(lookAndFeel->GetColor(nsILookAndFeel::eColor__moz_fieldtext, fieldText)) &&
-          fieldText == foregroundColor) {
+      nsresult rv = LookAndFeel::GetColor(LookAndFeel::eColorID__moz_fieldtext,
+                                          &fieldText);
+      if (NS_SUCCEEDED(rv) && fieldText == foregroundColor) {
         theme->DrawWidgetBackground(aCtx, aForFrame, NS_THEME_TEXTFIELD_CARET,
                                     drawCaretRect, drawCaretRect);
         return;
       }
     }
   }
 
   aCtx->SetColor(foregroundColor);
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -50,18 +50,17 @@
 #include "nsPIDOMWindow.h"
 #include "nsStyleSet.h"
 #include "nsImageLoader.h"
 #include "nsIContent.h"
 #include "nsIFrame.h"
 #include "nsIURL.h"
 #include "nsIDocument.h"
 #include "nsStyleContext.h"
-#include "nsILookAndFeel.h"
-#include "nsWidgetsCID.h"
+#include "mozilla/LookAndFeel.h"
 #include "nsIComponentManager.h"
 #include "nsIURIContentListener.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIServiceManager.h"
 #include "nsIDOMElement.h"
 #include "nsContentPolicyUtils.h"
 #include "nsIDOMWindow.h"
@@ -175,17 +174,16 @@ IsVisualCharset(const nsCString& aCharse
 
 static PLDHashOperator
 destroy_loads(const void * aKey, nsRefPtr<nsImageLoader>& aData, void* closure)
 {
   aData->Destroy();
   return PL_DHASH_NEXT;
 }
 
-static NS_DEFINE_CID(kLookAndFeelCID,  NS_LOOKANDFEEL_CID);
 #include "nsContentCID.h"
 
   // 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), mMinFontSize(0),
     mTextZoom(1.0), mFullZoom(1.0), mPageSize(-1, -1), mPPScale(1.0f),
@@ -324,17 +322,16 @@ nsPresContext::~nsPresContext()
   Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
                                   "layout.css.dpi",
                                   this);
   Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
                                   "layout.css.devPixelsPerPx",
                                   this);
 
   NS_IF_RELEASE(mDeviceContext);
-  NS_IF_RELEASE(mLookAndFeel);
   NS_IF_RELEASE(mLanguage);
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsPresContext)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPresContext)
    NS_INTERFACE_MAP_ENTRY(nsISupports)
    NS_INTERFACE_MAP_ENTRY(nsIObserver)
@@ -354,17 +351,16 @@ TraverseImageLoader(const void * aKey, n
 
   return PL_DHASH_NEXT;
 }
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsPresContext)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocument);
   // NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mDeviceContext); // not xpcom
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mEventManager, nsIObserver);
-  // NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mLookAndFeel); // a service
   // NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mLanguage); // an atom
 
   for (PRUint32 i = 0; i < IMAGE_LOAD_TYPE_COUNT; ++i)
     tmp->mImageLoaders[i].Enumerate(TraverseImageLoader, &cb);
 
   // NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTheme); // a service
   // NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLangService); // a service
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrintSettings);
@@ -377,17 +373,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   if (tmp->mEventManager) {
     // unclear if these are needed, but can't hurt
     tmp->mEventManager->NotifyDestroyPresContext(tmp);
     tmp->mEventManager->SetPresContext(nsnull);
 
     NS_RELEASE(tmp->mEventManager);
   }
 
-  // NS_RELEASE(tmp->mLookAndFeel); // a service
   // NS_RELEASE(tmp->mLanguage); // an atom
 
   // NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTheme); // a service
   // NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mLangService); // a service
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPrintSettings);
   if (tmp->mPrefChangedTimer)
   {
     tmp->mPrefChangedTimer->Cancel();
@@ -589,17 +584,18 @@ nsPresContext::GetDocumentColorPreferenc
   nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryReferent(mContainer));
   if (docShell) {
     PRInt32 docShellType;
     docShell->GetItemType(&docShellType);
     if (nsIDocShellTreeItem::typeChrome == docShellType) {
       usePrefColors = PR_FALSE;
     }
     else {
-      mLookAndFeel->GetMetric(nsILookAndFeel::eMetric_UseAccessibilityTheme, useAccessibilityTheme);
+      useAccessibilityTheme =
+        LookAndFeel::GetInt(LookAndFeel::eIntID_UseAccessibilityTheme, 0);
       usePrefColors = !useAccessibilityTheme;
     }
 
   }
   if (usePrefColors) {
     usePrefColors =
       !Preferences::GetBool("browser.display.use_system_colors", PR_FALSE);
   }
@@ -614,22 +610,22 @@ nsPresContext::GetDocumentColorPreferenc
 
     colorStr = Preferences::GetCString("browser.display.background_color");
 
     if (!colorStr.IsEmpty()) {
       mBackgroundColor = MakeColorPref(colorStr);
     }
   }
   else {
-    mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
-    mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
-    mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowForeground,
-                           mDefaultColor);
-    mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground,
-                           mBackgroundColor);
+    mDefaultColor =
+      LookAndFeel::GetColor(LookAndFeel::eColorID_WindowForeground,
+                            NS_RGB(0x00, 0x00, 0x00));
+    mBackgroundColor =
+      LookAndFeel::GetColor(LookAndFeel::eColorID_WindowBackground,
+                            NS_RGB(0xFF, 0xFF, 0xFF));
   }
 
   // Wherever we got the default background color from, ensure it is
   // opaque.
   mBackgroundColor = NS_ComposeColors(NS_RGB(0xFF, 0xFF, 0xFF),
                                       mBackgroundColor);
 
   mUseDocumentColors = !useAccessibilityTheme &&
@@ -889,24 +885,16 @@ nsPresContext::Init(nsDeviceContext* aDe
 
   if (mDeviceContext->SetPixelScale(mFullZoom))
     mDeviceContext->FlushFontCache();
   mCurAppUnitsPerDevPixel = AppUnitsPerDevPixel();
 
   for (PRUint32 i = 0; i < IMAGE_LOAD_TYPE_COUNT; ++i)
     if (!mImageLoaders[i].Init())
       return NS_ERROR_OUT_OF_MEMORY;
-  
-  // Get the look and feel service here; default colors will be initialized
-  // from calling GetUserPreferences() when we get a presshell.
-  nsresult rv = CallGetService(kLookAndFeelCID, &mLookAndFeel);
-  if (NS_FAILED(rv)) {
-    NS_ERROR("LookAndFeel service must be implemented for this toolkit");
-    return rv;
-  }
 
   mEventManager = new nsEventStateManager();
   NS_ADDREF(mEventManager);
 
   mTransitionManager = new nsTransitionManager(this);
 
   mAnimationManager = new nsAnimationManager(this);
 
@@ -984,17 +972,17 @@ nsPresContext::Init(nsDeviceContext* aDe
                                 this);
   Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
                                 "layout.css.dpi",
                                 this);
   Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
                                 "layout.css.devPixelsPerPx",
                                 this);
 
-  rv = mEventManager->Init();
+  nsresult rv = mEventManager->Init();
   NS_ENSURE_SUCCESS(rv, rv);
 
   mEventManager->SetPresContext(this);
 
 #ifdef DEBUG
   mInitialized = PR_TRUE;
 #endif
 
@@ -1542,19 +1530,19 @@ nsPresContext::ThemeChangedInternal()
   
   // Tell the theme that it changed, so it can flush any handles to stale theme
   // data.
   if (mTheme && sThemeChanged) {
     mTheme->ThemeChanged();
     sThemeChanged = PR_FALSE;
   }
 
-  // Clear all cached nsILookAndFeel colors.
-  if (mLookAndFeel && sLookAndFeelChanged) {
-    mLookAndFeel->LookAndFeelChanged();
+  // Clear all cached LookAndFeel colors.
+  if (sLookAndFeelChanged) {
+    LookAndFeel::Refresh();
     sLookAndFeelChanged = PR_FALSE;
   }
 
   // This will force the system metrics to be generated the next time they're used
   nsCSSRuleProcessor::FreeSystemMetrics();
 
   // Changes to system metrics can change media queries on them.
   MediaFeatureValuesChanged(PR_TRUE);
@@ -1579,19 +1567,19 @@ nsPresContext::SysColorChanged()
   }
 }
 
 void
 nsPresContext::SysColorChangedInternal()
 {
   mPendingSysColorChanged = PR_FALSE;
   
-  if (mLookAndFeel && sLookAndFeelChanged) {
+  if (sLookAndFeelChanged) {
      // Don't use the cached values for the system colors
-    mLookAndFeel->LookAndFeelChanged();
+    LookAndFeel::Refresh();
     sLookAndFeelChanged = PR_FALSE;
   }
    
   // Reset default background and foreground colors for the document since
   // they may be using system colors
   GetDocumentColorPreferences();
 
   // The system color values are computed to colors in the style data,
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -86,17 +86,16 @@ class imgIRequest;
 class nsFontMetrics;
 class nsIFrame;
 class nsFrameManager;
 class nsILinkHandler;
 class nsStyleContext;
 class nsIAtom;
 class nsEventStateManager;
 class nsIURI;
-class nsILookAndFeel;
 class nsICSSPseudoComparator;
 class nsIAtom;
 struct nsStyleBackground;
 struct nsStyleBorder;
 class nsIRunnable;
 class gfxUserFontSet;
 class nsUserFontSet;
 struct nsFontFaceRuleContainer;
@@ -293,22 +292,16 @@ public:
 #ifdef _IMPL_NS_LAYOUT
   void SetImageAnimationMode(PRUint16 aMode)
   { SetImageAnimationModeInternal(aMode); }
 #else
   void SetImageAnimationMode(PRUint16 aMode)
   { SetImageAnimationModeExternal(aMode); }
 #endif
 
-  /**
-   * Get cached look and feel service.  This is faster than obtaining it
-   * through the service manager.
-   */
-  nsILookAndFeel* LookAndFeel() { return mLookAndFeel; }
-
   /** 
    * Get medium of presentation
    */
   nsIAtom* Medium() { return mMedium; }
 
   void* AllocateFromShell(size_t aSize)
   {
     if (mShell)
@@ -1045,17 +1038,16 @@ protected:
   nsIPresShell*         mShell;         // [WEAK]
   nsCOMPtr<nsIDocument> mDocument;
   nsDeviceContext*     mDeviceContext; // [STRONG] could be weak, but
                                         // better safe than sorry.
                                         // Cannot reintroduce cycles
                                         // since there is no dependency
                                         // from gfx back to layout.
   nsEventStateManager* mEventManager;   // [STRONG]
-  nsILookAndFeel*       mLookAndFeel;   // [STRONG]
   nsRefPtr<nsRefreshDriver> mRefreshDriver;
   nsRefPtr<nsTransitionManager> mTransitionManager;
   nsRefPtr<nsAnimationManager> mAnimationManager;
   nsIAtom*              mMedium;        // initialized by subclass ctors;
                                         // weak pointer to static atom
 
   nsILinkHandler*       mLinkHandler;   // [WEAK]
 
--- a/layout/forms/nsFormControlFrame.cpp
+++ b/layout/forms/nsFormControlFrame.cpp
@@ -34,17 +34,19 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsFormControlFrame.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsEventStateManager.h"
-#include "nsILookAndFeel.h"
+#include "mozilla/LookAndFeel.h"
+
+using namespace mozilla;
 
 //#define FCF_NOISY
 
 const PRInt32 kSizeNotSet = -1;
 
 nsFormControlFrame::nsFormControlFrame(nsStyleContext* aContext) :
   nsLeafFrame(aContext)
 {
@@ -182,19 +184,17 @@ nsFormControlFrame::GetFormProperty(nsIA
 
 // static
 nsRect
 nsFormControlFrame::GetUsableScreenRect(nsPresContext* aPresContext)
 {
   nsRect screen;
 
   nsDeviceContext *context = aPresContext->DeviceContext();
-  PRInt32 dropdownCanOverlapOSBar = PR_FALSE;
-  nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
-  lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar,
-                         dropdownCanOverlapOSBar);
+  PRInt32 dropdownCanOverlapOSBar =
+    LookAndFeel::GetInt(LookAndFeel::eIntID_MenusCanOverlapOSBar, 0);
   if ( dropdownCanOverlapOSBar )
     context->GetRect(screen);
   else
     context->GetClientRect(screen);
 
   return screen;
 }
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -62,17 +62,16 @@
 #include "nsEventStateManager.h"
 #include "nsEventListenerManager.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
-#include "nsILookAndFeel.h"
 #include "nsFontMetrics.h"
 #include "nsIScrollableFrame.h"
 #include "nsIDOMNSEvent.h"
 #include "nsGUIEvent.h"
 #include "nsIServiceManager.h"
 #include "nsINodeInfo.h"
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
@@ -80,16 +79,19 @@
 #include "nsHTMLSelectElement.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsCSSRendering.h"
 #include "nsITheme.h"
 #include "nsIDOMEventListener.h"
 #include "nsLayoutUtils.h"
 #include "nsDisplayList.h"
 #include "nsContentUtils.h"
+#include "mozilla/LookAndFeel.h"
+
+using namespace mozilla;
 
 // Constants
 const nscoord kMaxDropDownRows          = 20; // This matches the setting for 4.x browsers
 const PRInt32 kNothingSelected          = -1;
 
 // Static members
 nsListControlFrame * nsListControlFrame::mFocused = nsnull;
 nsString * nsListControlFrame::sIncrementalString = nsnull;
@@ -331,21 +333,20 @@ void nsListControlFrame::PaintFocus(nsRe
     nsCOMPtr<nsIDOMHTMLOptionElement> domOpt =
       do_QueryInterface(focusedContent);
     if (domOpt) {
       domOpt->GetSelected(&lastItemIsSelected);
     }
   }
 
   // set up back stop colors and then ask L&F service for the real colors
-  nscolor color;
-  presContext->LookAndFeel()->
-    GetColor(lastItemIsSelected ?
-             nsILookAndFeel::eColor_WidgetSelectForeground :
-             nsILookAndFeel::eColor_WidgetSelectBackground, color);
+  nscolor color =
+    LookAndFeel::GetColor(lastItemIsSelected ?
+                            LookAndFeel::eColorID_WidgetSelectForeground :
+                            LookAndFeel::eColorID_WidgetSelectBackground);
 
   nsCSSRendering::PaintFocus(presContext, aRC, fRect, color);
 }
 
 void
 nsListControlFrame::InvalidateFocus()
 {
   if (mFocused != this)
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -99,19 +99,17 @@
 #ifdef IBMBIDI
 #include "nsBidiPresUtils.h"
 #endif
 
 // For triple-click pref
 #include "nsIServiceManager.h"
 #include "imgIContainer.h"
 #include "imgIRequest.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"
 #include "nsIObjectLoadingContent.h"
@@ -119,22 +117,21 @@
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGEffects.h"
 #include "nsChangeHint.h"
 
 #include "gfxContext.h"
 #include "CSSCalc.h"
 
 #include "mozilla/Preferences.h"
+#include "mozilla/LookAndFeel.h"
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
-static NS_DEFINE_CID(kLookAndFeelCID,  NS_LOOKANDFEEL_CID);
-
 // Struct containing cached metrics for box-wrapped frames.
 struct nsBoxLayoutMetrics
 {
   nsSize mPrefSize;
   nsSize mMinSize;
   nsSize mMaxSize;
 
   nsSize mBlockMinSize;
@@ -1056,32 +1053,27 @@ public:
   NS_DISPLAY_DECL_NAME("SelectionOverlay", TYPE_SELECTION_OVERLAY)
 private:
   PRInt16 mSelectionValue;
 };
 
 void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
                                       nsRenderingContext* aCtx)
 {
-  nscolor color = NS_RGB(255, 255, 255);
-  
-  nsILookAndFeel::nsColorID colorID;
+  LookAndFeel::ColorID colorID;
   nsresult result;
   if (mSelectionValue == nsISelectionController::SELECTION_ON) {
-    colorID = nsILookAndFeel::eColor_TextSelectBackground;
+    colorID = LookAndFeel::eColorID_TextSelectBackground;
   } else if (mSelectionValue == nsISelectionController::SELECTION_ATTENTION) {
-    colorID = nsILookAndFeel::eColor_TextSelectBackgroundAttention;
+    colorID = LookAndFeel::eColorID_TextSelectBackgroundAttention;
   } else {
-    colorID = nsILookAndFeel::eColor_TextSelectBackgroundDisabled;
-  }
-
-  nsCOMPtr<nsILookAndFeel> look;
-  look = do_GetService(kLookAndFeelCID, &result);
-  if (NS_SUCCEEDED(result) && look)
-    look->GetColor(colorID, color);
+    colorID = LookAndFeel::eColorID_TextSelectBackgroundDisabled;
+  }
+
+  nscolor color = LookAndFeel::GetColor(colorID, NS_RGB(255, 255, 255));
 
   gfxRGBA c(color);
   c.a = .5;
 
   gfxContext *ctx = aCtx->ThebesContext();
   ctx->SetColor(c);
 
   nsIntRect pxRect =
--- a/layout/generic/nsFrameSetFrame.cpp
+++ b/layout/generic/nsFrameSetFrame.cpp
@@ -52,46 +52,43 @@
 #include "nsIView.h"
 #include "nsIViewManager.h"
 #include "nsWidgetsCID.h"
 #include "nsGkAtoms.h"
 #include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
 #include "nsStyleContext.h"
 #include "nsHTMLParts.h"
-#include "nsILookAndFeel.h"
-#include "nsWidgetsCID.h"
 #include "nsIComponentManager.h"
 #include "nsGUIEvent.h"
 #include "nsRenderingContext.h"
 #include "nsIServiceManager.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsINameSpaceManager.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsAutoPtr.h"
 #include "nsStyleSet.h"
 #include "mozilla/dom/Element.h"
 #include "nsDisplayList.h"
 #include "nsNodeUtils.h"
 #include "mozAutoDocUpdate.h"
 #include "mozilla/Preferences.h"
 #include "nsHTMLFrameSetElement.h"
+#include "mozilla/LookAndFeel.h"
 
 using namespace mozilla;
 
 // masks for mEdgeVisibility
 #define LEFT_VIS   0x0001
 #define RIGHT_VIS  0x0002
 #define TOP_VIS    0x0004
 #define BOTTOM_VIS 0x0008
 #define ALL_VIS    0x000F
 #define NONE_VIS   0x0000
 
-static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
-
 /*******************************************************************************
  * nsFramesetDrag
  ******************************************************************************/
 nsFramesetDrag::nsFramesetDrag() 
 {
   UnSet();
 }
 
@@ -1680,34 +1677,33 @@ nsHTMLFramesetBorderFrame::BuildDisplayL
   return aLists.Content()->AppendNewToTop(
       new (aBuilder) nsDisplayFramesetBorder(aBuilder, this));
 }
 
 void nsHTMLFramesetBorderFrame::PaintBorder(nsRenderingContext& aRenderingContext,
                                             nsPoint aPt)
 {
   nscolor WHITE    = NS_RGB(255, 255, 255);
-  nscolor bgColor  = NS_RGB(200,200,200);
-  nscolor fgColor  = NS_RGB(0,0,0);
-  nscolor hltColor = NS_RGB(255,255,255);
-  nscolor sdwColor = NS_RGB(128,128,128);
+
+  nscolor bgColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetBackground,
+                          NS_RGB(200,200,200));
+  nscolor fgColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetForeground,
+                          NS_RGB(0,0,0));
+  nscolor hltColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DHighlight,
+                          NS_RGB(255,255,255));
+  nscolor sdwColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DShadow,
+                          NS_RGB(128,128,128));
 
   nsRenderingContext::AutoPushTranslation
     translate(&aRenderingContext, aPt);
 
-  {
-    nsCOMPtr<nsILookAndFeel> lookAndFeel = do_GetService(kLookAndFeelCID);
-    if (lookAndFeel) {
-      lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground,  bgColor);
-      lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground,  fgColor);
-      lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow,    sdwColor);
-      lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DHighlight, hltColor);
-    }
-  }
-
   nscoord widthInPixels = nsPresContext::AppUnitsToIntCSSPixels(mWidth);
   nscoord pixelWidth    = nsPresContext::CSSPixelsToAppUnits(1);
 
   if (widthInPixels <= 0)
     return;
 
   nsPoint start(0,0);
   nsPoint end((mVertical) ? 0 : mRect.width, (mVertical) ? mRect.height : 0);
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -73,17 +73,17 @@
 #include "nsContentUtils.h"
 #include "nsLayoutUtils.h"
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 #include "nsBidiUtils.h"
 #include "nsFrameManager.h"
 #include "mozilla/Preferences.h"
-#include "nsILookAndFeel.h"
+#include "mozilla/LookAndFeel.h"
 #include "mozilla/dom/Element.h"
 #include "FrameLayerBuilder.h"
 #include "nsSMILKeySpline.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
@@ -1457,21 +1457,18 @@ nsGfxScrollFrameInner::nsGfxScrollFrameI
   , mVerticalOverflow(PR_FALSE)
   , mPostedReflowCallback(PR_FALSE)
   , mMayHaveDirtyFixedChildren(PR_FALSE)
   , mUpdateScrollbarAttributes(PR_FALSE)
   , mCollapsedResizer(PR_FALSE)
   , mShouldBuildLayer(PR_FALSE)
 {
   // lookup if we're allowed to overlap the content from the look&feel object
-  PRInt32 canOverlap;
-  nsPresContext* presContext = mOuter->PresContext();
-  presContext->LookAndFeel()->
-    GetMetric(nsILookAndFeel::eMetric_ScrollbarsCanOverlapContent, canOverlap);
-  mScrollbarsCanOverlapContent = canOverlap;
+  mScrollbarsCanOverlapContent =
+    LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollbarsCanOverlapContent) != 0;
   mScrollingActive = IsAlwaysActive();
 }
 
 nsGfxScrollFrameInner::~nsGfxScrollFrameInner()
 {
   if (mActivityExpirationState.IsTracked()) {
     gScrollFrameActivityTracker->RemoveObject(this);
   }
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -85,17 +85,16 @@
 #include "nsIUGenCategory.h"
 #include "nsUnicharUtilCIID.h"
 
 #include "nsTextFragment.h"
 #include "nsGkAtoms.h"
 #include "nsFrameSelection.h"
 #include "nsISelection.h"
 #include "nsIDOMRange.h"
-#include "nsILookAndFeel.h"
 #include "nsCSSRendering.h"
 #include "nsContentUtils.h"
 #include "nsLineBreaker.h"
 #include "nsIWordBreaker.h"
 #include "nsGenericDOMDataNode.h"
 
 #include "nsILineIterator.h"
 
@@ -110,16 +109,17 @@
 
 #include "gfxFont.h"
 #include "gfxContext.h"
 #include "gfxTextRunWordCache.h"
 #include "gfxImageSurface.h"
 
 #include "mozilla/dom/Element.h"
 #include "mozilla/Util.h" // for DebugOnly
+#include "mozilla/LookAndFeel.h"
 
 #ifdef NS_DEBUG
 #undef NOISY_BLINK
 #undef NOISY_REFLOW
 #undef NOISY_TRIM
 #else
 #undef NOISY_BLINK
 #undef NOISY_REFLOW
@@ -3265,22 +3265,20 @@ nsTextPaintStyle::GetSelectionColors(nsc
 
 void
 nsTextPaintStyle::GetHighlightColors(nscolor* aForeColor,
                                      nscolor* aBackColor)
 {
   NS_ASSERTION(aForeColor, "aForeColor is null");
   NS_ASSERTION(aBackColor, "aBackColor is null");
   
-  nsILookAndFeel* look = mPresContext->LookAndFeel();
-  nscolor foreColor, backColor;
-  look->GetColor(nsILookAndFeel::eColor_TextHighlightBackground,
-                 backColor);
-  look->GetColor(nsILookAndFeel::eColor_TextHighlightForeground,
-                 foreColor);
+  nscolor backColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextHighlightBackground);
+  nscolor foreColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextHighlightForeground);
   EnsureSufficientContrast(&foreColor, &backColor);
   *aForeColor = foreColor;
   *aBackColor = backColor;
 }
 
 void
 nsTextPaintStyle::GetURLSecondaryColor(nscolor* aForeColor)
 {
@@ -3352,24 +3350,22 @@ nsTextPaintStyle::InitCommonColors()
     mSufficientContrast = 0;
     mInitCommonColors = PR_TRUE;
     return;
   }
 
   NS_ASSERTION(NS_GET_A(defaultBgColor) == 255,
                "default background color is not opaque");
 
-  nsILookAndFeel* look = mPresContext->LookAndFeel();
-  nscolor defaultWindowBackgroundColor, selectionTextColor, selectionBGColor;
-  look->GetColor(nsILookAndFeel::eColor_TextSelectBackground,
-                 selectionBGColor);
-  look->GetColor(nsILookAndFeel::eColor_TextSelectForeground,
-                 selectionTextColor);
-  look->GetColor(nsILookAndFeel::eColor_WindowBackground,
-                 defaultWindowBackgroundColor);
+  nscolor defaultWindowBackgroundColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_WindowBackground);
+  nscolor selectionTextColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectForeground);
+  nscolor selectionBGColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground);
 
   mSufficientContrast =
     NS_MIN(NS_MIN(NS_SUFFICIENT_LUMINOSITY_DIFFERENCE,
                   NS_LUMINOSITY_DIFFERENCE(selectionTextColor,
                                            selectionBGColor)),
                   NS_LUMINOSITY_DIFFERENCE(defaultWindowBackgroundColor,
                                            selectionBGColor));
 
@@ -3423,38 +3419,36 @@ nsTextPaintStyle::InitSelectionColors()
     if (sc) {
       mSelectionBGColor =
         sc->GetVisitedDependentColor(eCSSProperty_background_color);
       mSelectionTextColor = sc->GetVisitedDependentColor(eCSSProperty_color);
       return PR_TRUE;
     }
   }
 
-  nsILookAndFeel* look = mPresContext->LookAndFeel();
-
-  nscolor selectionBGColor;
-  look->GetColor(nsILookAndFeel::eColor_TextSelectBackground,
-                 selectionBGColor);
+  nscolor selectionBGColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground);
 
   if (selectionStatus == nsISelectionController::SELECTION_ATTENTION) {
-    look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundAttention,
-                   mSelectionBGColor);
+    mSelectionBGColor =
+      LookAndFeel::GetColor(
+        LookAndFeel::eColorID_TextSelectBackgroundAttention);
     mSelectionBGColor  = EnsureDifferentColors(mSelectionBGColor,
                                                selectionBGColor);
   } else if (selectionStatus != nsISelectionController::SELECTION_ON) {
-    look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundDisabled,
-                   mSelectionBGColor);
+    mSelectionBGColor =
+      LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackgroundDisabled);
     mSelectionBGColor  = EnsureDifferentColors(mSelectionBGColor,
                                                selectionBGColor);
   } else {
     mSelectionBGColor = selectionBGColor;
   }
 
-  look->GetColor(nsILookAndFeel::eColor_TextSelectForeground,
-                 mSelectionTextColor);
+  mSelectionTextColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectForeground);
 
   // On MacOS X, we don't exchange text color and BG color.
   if (mSelectionTextColor == NS_DONT_CHANGE_COLOR) {
     nscoord frameColor = mFrame->GetVisitedDependentColor(eCSSProperty_color);
     mSelectionTextColor = EnsureDifferentColors(frameColor, mSelectionBGColor);
   } else {
     EnsureSufficientContrast(&mSelectionTextColor, &mSelectionBGColor);
   }
@@ -3464,69 +3458,68 @@ nsTextPaintStyle::InitSelectionColors()
 nsTextPaintStyle::nsSelectionStyle*
 nsTextPaintStyle::GetSelectionStyle(PRInt32 aIndex)
 {
   InitSelectionStyle(aIndex);
   return &mSelectionStyle[aIndex];
 }
 
 struct StyleIDs {
-  nsILookAndFeel::nsColorID mForeground, mBackground, mLine;
-  nsILookAndFeel::nsMetricID mLineStyle;
-  nsILookAndFeel::nsMetricFloatID mLineRelativeSize;
+  LookAndFeel::ColorID mForeground, mBackground, mLine;
+  LookAndFeel::IntID mLineStyle;
+  LookAndFeel::FloatID mLineRelativeSize;
 };
 static StyleIDs SelectionStyleIDs[] = {
-  { nsILookAndFeel::eColor_IMERawInputForeground,
-    nsILookAndFeel::eColor_IMERawInputBackground,
-    nsILookAndFeel::eColor_IMERawInputUnderline,
-    nsILookAndFeel::eMetric_IMERawInputUnderlineStyle,
-    nsILookAndFeel::eMetricFloat_IMEUnderlineRelativeSize },
-  { nsILookAndFeel::eColor_IMESelectedRawTextForeground,
-    nsILookAndFeel::eColor_IMESelectedRawTextBackground,
-    nsILookAndFeel::eColor_IMESelectedRawTextUnderline,
-    nsILookAndFeel::eMetric_IMESelectedRawTextUnderlineStyle,
-    nsILookAndFeel::eMetricFloat_IMEUnderlineRelativeSize },
-  { nsILookAndFeel::eColor_IMEConvertedTextForeground,
-    nsILookAndFeel::eColor_IMEConvertedTextBackground,
-    nsILookAndFeel::eColor_IMEConvertedTextUnderline,
-    nsILookAndFeel::eMetric_IMEConvertedTextUnderlineStyle,
-    nsILookAndFeel::eMetricFloat_IMEUnderlineRelativeSize },
-  { nsILookAndFeel::eColor_IMESelectedConvertedTextForeground,
-    nsILookAndFeel::eColor_IMESelectedConvertedTextBackground,
-    nsILookAndFeel::eColor_IMESelectedConvertedTextUnderline,
-    nsILookAndFeel::eMetric_IMESelectedConvertedTextUnderline,
-    nsILookAndFeel::eMetricFloat_IMEUnderlineRelativeSize },
-  { nsILookAndFeel::eColor_LAST_COLOR,
-    nsILookAndFeel::eColor_LAST_COLOR,
-    nsILookAndFeel::eColor_SpellCheckerUnderline,
-    nsILookAndFeel::eMetric_SpellCheckerUnderlineStyle,
-    nsILookAndFeel::eMetricFloat_SpellCheckerUnderlineRelativeSize }
+  { LookAndFeel::eColorID_IMERawInputForeground,
+    LookAndFeel::eColorID_IMERawInputBackground,
+    LookAndFeel::eColorID_IMERawInputUnderline,
+    LookAndFeel::eIntID_IMERawInputUnderlineStyle,
+    LookAndFeel::eFloatID_IMEUnderlineRelativeSize },
+  { LookAndFeel::eColorID_IMESelectedRawTextForeground,
+    LookAndFeel::eColorID_IMESelectedRawTextBackground,
+    LookAndFeel::eColorID_IMESelectedRawTextUnderline,
+    LookAndFeel::eIntID_IMESelectedRawTextUnderlineStyle,
+    LookAndFeel::eFloatID_IMEUnderlineRelativeSize },
+  { LookAndFeel::eColorID_IMEConvertedTextForeground,
+    LookAndFeel::eColorID_IMEConvertedTextBackground,
+    LookAndFeel::eColorID_IMEConvertedTextUnderline,
+    LookAndFeel::eIntID_IMEConvertedTextUnderlineStyle,
+    LookAndFeel::eFloatID_IMEUnderlineRelativeSize },
+  { LookAndFeel::eColorID_IMESelectedConvertedTextForeground,
+    LookAndFeel::eColorID_IMESelectedConvertedTextBackground,
+    LookAndFeel::eColorID_IMESelectedConvertedTextUnderline,
+    LookAndFeel::eIntID_IMESelectedConvertedTextUnderline,
+    LookAndFeel::eFloatID_IMEUnderlineRelativeSize },
+  { LookAndFeel::eColorID_LAST_COLOR,
+    LookAndFeel::eColorID_LAST_COLOR,
+    LookAndFeel::eColorID_SpellCheckerUnderline,
+    LookAndFeel::eIntID_SpellCheckerUnderlineStyle,
+    LookAndFeel::eFloatID_SpellCheckerUnderlineRelativeSize }
 };
 
 void
 nsTextPaintStyle::InitSelectionStyle(PRInt32 aIndex)
 {
   NS_ASSERTION(aIndex >= 0 && aIndex < 5, "aIndex is invalid");
   nsSelectionStyle* selectionStyle = &mSelectionStyle[aIndex];
   if (selectionStyle->mInit)
     return;
 
   StyleIDs* styleIDs = &SelectionStyleIDs[aIndex];
 
-  nsILookAndFeel* look = mPresContext->LookAndFeel();
   nscolor foreColor, backColor;
-  if (styleIDs->mForeground == nsILookAndFeel::eColor_LAST_COLOR) {
+  if (styleIDs->mForeground == LookAndFeel::eColorID_LAST_COLOR) {
     foreColor = NS_SAME_AS_FOREGROUND_COLOR;
   } else {
-    look->GetColor(styleIDs->mForeground, foreColor);
-  }
-  if (styleIDs->mBackground == nsILookAndFeel::eColor_LAST_COLOR) {
+    foreColor = LookAndFeel::GetColor(styleIDs->mForeground);
+  }
+  if (styleIDs->mBackground == LookAndFeel::eColorID_LAST_COLOR) {
     backColor = NS_TRANSPARENT;
   } else {
-    look->GetColor(styleIDs->mBackground, backColor);
+    backColor = LookAndFeel::GetColor(styleIDs->mBackground);
   }
 
   // Convert special color to actual color
   NS_ASSERTION(foreColor != NS_TRANSPARENT,
                "foreColor cannot be NS_TRANSPARENT");
   NS_ASSERTION(backColor != NS_SAME_AS_FOREGROUND_COLOR,
                "backColor cannot be NS_SAME_AS_FOREGROUND_COLOR");
   NS_ASSERTION(backColor != NS_40PERCENT_FOREGROUND_COLOR,
@@ -3559,30 +3552,25 @@ nsTextPaintStyle::GetSelectionUnderline(
                                         float* aRelativeSize,
                                         PRUint8* aStyle)
 {
   NS_ASSERTION(aPresContext, "aPresContext is null");
   NS_ASSERTION(aRelativeSize, "aRelativeSize is null");
   NS_ASSERTION(aStyle, "aStyle is null");
   NS_ASSERTION(aIndex >= 0 && aIndex < 5, "Index out of range");
 
-  nsILookAndFeel* look = aPresContext->LookAndFeel();
-
   StyleIDs& styleID = SelectionStyleIDs[aIndex];
-  nscolor color;
-  float size;
-  PRInt32 style;
-
-  look->GetColor(styleID.mLine, color);
-  look->GetMetric(styleID.mLineStyle, style);
+
+  nscolor color = LookAndFeel::GetColor(styleID.mLine);
+  PRInt32 style = LookAndFeel::GetInt(styleID.mLineStyle);
   if (style > NS_STYLE_TEXT_DECORATION_STYLE_MAX) {
     NS_ERROR("Invalid underline style value is specified");
     style = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
   }
-  look->GetMetric(styleID.mLineRelativeSize, size);
+  float size = LookAndFeel::GetFloat(styleID.mLineRelativeSize);
 
   NS_ASSERTION(size, "selection underline relative size must be larger than 0");
 
   if (aLineColor) {
     *aLineColor = color;
   }
   *aRelativeSize = size;
   *aStyle = style;
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -53,17 +53,17 @@
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsIPersistentProperties2.h"
 #include "nsIServiceManager.h"
 #include "nsIObserverService.h"
 #include "nsIObserver.h"
 #include "nsNetUtil.h"
 
-#include "nsILookAndFeel.h"
+#include "mozilla/LookAndFeel.h"
 #include "nsCSSRendering.h"
 #include "prprf.h"         // For PR_snprintf()
 
 #include "nsDisplayList.h"
 
 #include "nsMathMLOperators.h"
 #include "nsMathMLChar.h"
 
@@ -1847,19 +1847,19 @@ public:
 private:
   nsRect    mRect;
 };
 
 void nsDisplayMathMLSelectionRect::Paint(nsDisplayListBuilder* aBuilder,
                                          nsRenderingContext* aCtx)
 {
   // get color to use for selection from the look&feel object
-  nscolor bgColor = NS_RGB(0, 0, 0);
-  mFrame->PresContext()->LookAndFeel()->
-      GetColor(nsILookAndFeel::eColor_TextSelectBackground, bgColor);
+  nscolor bgColor =
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground,
+                          NS_RGB(0, 0, 0));
   aCtx->SetColor(bgColor);
   aCtx->FillRect(mRect + ToReferenceFrame());
 }
 
 class nsDisplayMathMLCharBackground : public nsDisplayItem {
 public:
   nsDisplayMathMLCharBackground(nsDisplayListBuilder* aBuilder,
                                 nsIFrame* aFrame, const nsRect& aRect,
@@ -2051,18 +2051,18 @@ nsMathMLChar::PaintForeground(nsPresCont
     // Set default context to the parent context
     styleContext = parentContext;
   }
 
   // Set color ...
   nscolor fgColor = styleContext->GetStyleColor()->mColor;
   if (aIsSelected) {
     // get color to use for selection from the look&feel object
-    aPresContext->LookAndFeel()->
-      GetColor(nsILookAndFeel::eColor_TextSelectForeground, fgColor);
+    fgColor = LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectForeground,
+                                    fgColor);
   }
   aRenderingContext.SetColor(fgColor);
 
   nsFont theFont(styleContext->GetStyleFont()->mFont);
   if (! mFamily.IsEmpty()) {
     theFont.name = mFamily;
   }
   nsRefPtr<nsFontMetrics> fm;
--- a/layout/svg/base/src/nsSVGGlyphFrame.cpp
+++ b/layout/svg/base/src/nsSVGGlyphFrame.cpp
@@ -32,17 +32,17 @@
  * 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 "nsSVGTextFrame.h"
-#include "nsILookAndFeel.h"
+#include "mozilla/LookAndFeel.h"
 #include "nsTextFragment.h"
 #include "nsBidiPresUtils.h"
 #include "nsSVGUtils.h"
 #include "SVGLengthList.h"
 #include "nsIDOMSVGLength.h"
 #include "nsIDOMSVGRect.h"
 #include "DOMSVGPoint.h"
 #include "nsSVGGlyphFrame.h"
@@ -1002,21 +1002,21 @@ nsSVGGlyphFrame::GetHighlight(PRUint32 *
   }
 #endif
   
   if (details) {
     NS_ASSERTION(details->mNext==nsnull, "can't do multiple selection ranges");
 
     *charnum=CompressIndex(details->mStart, fragment);
     *nchars=CompressIndex(details->mEnd, fragment)-*charnum;  
-    
-    nsILookAndFeel *look = presContext->LookAndFeel();
 
-    look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, *background);
-    look->GetColor(nsILookAndFeel::eColor_TextSelectForeground, *foreground);
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground,
+                          background);
+    LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectForeground,
+                          foreground);
 
     SelectionDetails *dp = details;
     while ((dp=details->mNext) != nsnull) {
       delete details;
       details = dp;
     }
     delete details;
   }
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -60,17 +60,19 @@
 #include "nsIDOMNode.h"
 #include "nsINameSpaceManager.h"
 #include "nsDisplayList.h"
 #include "nsLayoutUtils.h"
 #include "nsTextFrame.h"
 
 //TABLECELL SELECTION
 #include "nsFrameSelection.h"
-#include "nsILookAndFeel.h"
+#include "mozilla/LookAndFeel.h"
+
+using namespace mozilla;
 
 
 nsTableCellFrame::nsTableCellFrame(nsStyleContext* aContext) :
   nsHTMLContainerFrame(aContext)
 {
   mColIndex = 0;
   mPriorAvailWidth = 0;
 
@@ -323,19 +325,18 @@ nsTableCellFrame::DecorateForSelection(n
       presContext->PresShell()->FrameSelection();
 
     if (frameSelection->GetTableCellSelection()) {
       nscolor       bordercolor;
       if (displaySelection == nsISelectionController::SELECTION_DISABLED) {
         bordercolor = NS_RGB(176,176,176);// disabled color
       }
       else {
-        presContext->LookAndFeel()->
-          GetColor(nsILookAndFeel::eColor_TextSelectBackground,
-                   bordercolor);
+        bordercolor =
+          LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground);
       }
       nscoord threePx = nsPresContext::CSSPixelsToAppUnits(3);
       if ((mRect.width > threePx) && (mRect.height > threePx))
       {
         //compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
         bordercolor = EnsureDifferentColors(bordercolor,
                                             GetStyleBackground()->mBackgroundColor);
         nsRenderingContext::AutoPushTranslation