mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
added look and feel accessor to pres context
This commit is contained in:
parent
7ee5f20bcd
commit
e76b661939
@ -36,6 +36,9 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@ -53,6 +56,8 @@ PrefChangedCallback(const char* aPrefName, void* instance_data)
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIPresContextIID, NS_IPRESCONTEXT_IID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
nsPresContext::nsPresContext()
|
||||
: mDefaultFont("Times", NS_FONT_STYLE_NORMAL,
|
||||
@ -76,7 +81,8 @@ nsPresContext::nsPresContext()
|
||||
#else
|
||||
mWidgetRenderingMode = eWidgetRendering_Gfx;
|
||||
#endif
|
||||
|
||||
|
||||
mLookAndFeel = nsnull;
|
||||
|
||||
#ifdef _WIN32
|
||||
// XXX This needs to be elsewhere, e.g., part of nsIDeviceContext
|
||||
@ -106,6 +112,8 @@ nsPresContext::~nsPresContext()
|
||||
if (mEventManager)
|
||||
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
||||
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
|
||||
// Unregister preference callbacks
|
||||
if (mPrefs) {
|
||||
mPrefs->UnregisterCallback("browser.", PrefChangedCallback, (void*)this);
|
||||
@ -368,6 +376,28 @@ nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetLookAndFeel(nsILookAndFeel** aLookAndFeel)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aLookAndFeel, "null ptr");
|
||||
if (nsnull == aLookAndFeel) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsresult result = NS_OK;
|
||||
if (! mLookAndFeel) {
|
||||
result = nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull,
|
||||
kILookAndFeelIID, (void**)&mLookAndFeel);
|
||||
if (NS_FAILED(result)) {
|
||||
mLookAndFeel = nsnull;
|
||||
}
|
||||
}
|
||||
NS_IF_ADDREF(mLookAndFeel);
|
||||
*aLookAndFeel = mLookAndFeel;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBaseURL(nsIURI** aResult)
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ class nsIAtom;
|
||||
class nsString;
|
||||
class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0x0a5d12e0, 0x944e, 0x11d1, \
|
||||
@ -108,6 +109,11 @@ public:
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0;
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get look and feel object
|
||||
*/
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel) = 0;
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
*/
|
||||
|
@ -41,6 +41,7 @@ class nsIAtom;
|
||||
class nsString;
|
||||
class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0x0a5d12e0, 0x944e, 0x11d1, \
|
||||
@ -108,6 +109,11 @@ public:
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0;
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get look and feel object
|
||||
*/
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel) = 0;
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
*/
|
||||
|
@ -41,6 +41,7 @@ class nsIAtom;
|
||||
class nsString;
|
||||
class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0x0a5d12e0, 0x944e, 0x11d1, \
|
||||
@ -108,6 +109,11 @@ public:
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0;
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get look and feel object
|
||||
*/
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel) = 0;
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
*/
|
||||
|
@ -36,6 +36,9 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@ -53,6 +56,8 @@ PrefChangedCallback(const char* aPrefName, void* instance_data)
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIPresContextIID, NS_IPRESCONTEXT_IID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
nsPresContext::nsPresContext()
|
||||
: mDefaultFont("Times", NS_FONT_STYLE_NORMAL,
|
||||
@ -76,7 +81,8 @@ nsPresContext::nsPresContext()
|
||||
#else
|
||||
mWidgetRenderingMode = eWidgetRendering_Gfx;
|
||||
#endif
|
||||
|
||||
|
||||
mLookAndFeel = nsnull;
|
||||
|
||||
#ifdef _WIN32
|
||||
// XXX This needs to be elsewhere, e.g., part of nsIDeviceContext
|
||||
@ -106,6 +112,8 @@ nsPresContext::~nsPresContext()
|
||||
if (mEventManager)
|
||||
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
||||
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
|
||||
// Unregister preference callbacks
|
||||
if (mPrefs) {
|
||||
mPrefs->UnregisterCallback("browser.", PrefChangedCallback, (void*)this);
|
||||
@ -368,6 +376,28 @@ nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetLookAndFeel(nsILookAndFeel** aLookAndFeel)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aLookAndFeel, "null ptr");
|
||||
if (nsnull == aLookAndFeel) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsresult result = NS_OK;
|
||||
if (! mLookAndFeel) {
|
||||
result = nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull,
|
||||
kILookAndFeelIID, (void**)&mLookAndFeel);
|
||||
if (NS_FAILED(result)) {
|
||||
mLookAndFeel = nsnull;
|
||||
}
|
||||
}
|
||||
NS_IF_ADDREF(mLookAndFeel);
|
||||
*aLookAndFeel = mLookAndFeel;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBaseURL(nsIURI** aResult)
|
||||
{
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode);
|
||||
NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult);
|
||||
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode);
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel);
|
||||
NS_IMETHOD GetBaseURL(nsIURI** aURLResult);
|
||||
NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0;
|
||||
NS_IMETHOD ResolveStyleContextFor(nsIContent* aContent,
|
||||
@ -131,6 +132,7 @@ protected:
|
||||
nsCOMPtr<nsIImageGroup> mImageGroup;
|
||||
nsILinkHandler* mLinkHandler; // [WEAK]
|
||||
nsISupports* mContainer; // [WEAK]
|
||||
nsILookAndFeel* mLookAndFeel;
|
||||
nsFont mDefaultFont;
|
||||
nsFont mDefaultFixedFont;
|
||||
PRInt32 mFontScaler;
|
||||
|
Loading…
x
Reference in New Issue
Block a user