diff --git a/gfx/idl/nsIFontEnumerator.idl b/gfx/idl/nsIFontEnumerator.idl index 41569cd79904..92bf8a63eae1 100644 --- a/gfx/idl/nsIFontEnumerator.idl +++ b/gfx/idl/nsIFontEnumerator.idl @@ -55,7 +55,7 @@ interface nsIFontEnumerator : nsISupports /* * update the global font list - * @param None + * return true if font list is changed */ - void UpdateFontList(); + boolean updateFontList(); }; diff --git a/gfx/src/beos/nsFontMetricsBeOS.cpp b/gfx/src/beos/nsFontMetricsBeOS.cpp index 0e3fdd3341fa..f2e3a7e8c5ca 100644 --- a/gfx/src/beos/nsFontMetricsBeOS.cpp +++ b/gfx/src/beos/nsFontMetricsBeOS.cpp @@ -468,8 +468,9 @@ nsFontEnumeratorBeOS::HaveFontFor(const char* aLangGroup, PRBool* aResult) } NS_IMETHODIMP -nsFontEnumeratorBeOS::UpdateFontList() +nsFontEnumeratorBeOS::UpdateFontList(PRBool *updateFontList) { - return NS_ERROR_NOT_IMPLEMENTED; + *updateFontList = PR_FALSE; // always return false for now + return NS_OK; } diff --git a/gfx/src/gtk/nsFontMetricsGTK.cpp b/gfx/src/gtk/nsFontMetricsGTK.cpp index c5e61415f00b..1ab2bc912904 100644 --- a/gfx/src/gtk/nsFontMetricsGTK.cpp +++ b/gfx/src/gtk/nsFontMetricsGTK.cpp @@ -4199,7 +4199,8 @@ nsFontEnumeratorGTK::HaveFontFor(const char* aLangGroup, PRBool* aResult) } NS_IMETHODIMP -nsFontEnumeratorGTK::UpdateFontList() +nsFontEnumeratorGTK::UpdateFontList(PRBool *updateFontList) { - return NS_ERROR_NOT_IMPLEMENTED; + *updateFontList = PR_FALSE; // always return false for now + return NS_OK; } diff --git a/gfx/src/mac/nsDeviceContextMac.cpp b/gfx/src/mac/nsDeviceContextMac.cpp index a44f4b73788c..bbf02645480c 100644 --- a/gfx/src/mac/nsDeviceContextMac.cpp +++ b/gfx/src/mac/nsDeviceContextMac.cpp @@ -1238,7 +1238,8 @@ nsFontEnumeratorMac::HaveFontFor(const char* aLangGroup,PRBool* aResult) } NS_IMETHODIMP -nsFontEnumeratorMac::UpdateFontList() +nsFontEnumeratorMac::UpdateFontList(PRBool *updateFontList) { - return NS_ERROR_NOT_IMPLEMENTED; + *updateFontList = PR_FALSE; // always return false for now + return NS_OK; } diff --git a/gfx/src/os2/nsFontMetricsOS2.cpp b/gfx/src/os2/nsFontMetricsOS2.cpp index 7f1e65665ff3..79d849dc2b3a 100644 --- a/gfx/src/os2/nsFontMetricsOS2.cpp +++ b/gfx/src/os2/nsFontMetricsOS2.cpp @@ -1516,8 +1516,9 @@ nsFontEnumeratorOS2::HaveFontFor(const char* aLangGroup, PRBool* aResult) } NS_IMETHODIMP -nsFontEnumeratorOS2::UpdateFontList() +nsFontEnumeratorOS2::UpdateFontList(PRBool *updateFontList) { - return NS_ERROR_NOT_IMPLEMENTED; + *updateFontList = PR_FALSE; // always return false for now + return NS_OK; } diff --git a/gfx/src/photon/nsFontMetricsPh.cpp b/gfx/src/photon/nsFontMetricsPh.cpp index fe24ea1fd458..49181d68679f 100644 --- a/gfx/src/photon/nsFontMetricsPh.cpp +++ b/gfx/src/photon/nsFontMetricsPh.cpp @@ -586,7 +586,8 @@ NS_IMETHODIMP } NS_IMETHODIMP - nsFontEnumeratorPh::UpdateFontList() + nsFontEnumeratorPh::UpdateFontList(PRBool *updateFontList) { - return NS_ERROR_NOT_IMPLEMENTED; + *updateFontList = PR_FALSE; // always return false for now + return NS_OK; } diff --git a/gfx/src/qt/nsFontMetricsQT.cpp b/gfx/src/qt/nsFontMetricsQT.cpp index 9d81891778f8..be977846495f 100644 --- a/gfx/src/qt/nsFontMetricsQT.cpp +++ b/gfx/src/qt/nsFontMetricsQT.cpp @@ -2180,8 +2180,9 @@ nsFontEnumeratorQT::HaveFontFor(const char *aLangGroup,PRBool *aResult) } NS_IMETHODIMP -nsFontEnumeratorQT::UpdateFontList() +nsFontEnumeratorQT::UpdateFontList(PRBool *updateFontList) { - return NS_ERROR_NOT_IMPLEMENTED; + *updateFontList = PR_FALSE; // always return false for now + return NS_OK; } diff --git a/gfx/src/windows/nsFontMetricsWin.cpp b/gfx/src/windows/nsFontMetricsWin.cpp index 8306c30330f5..212f6e523c02 100644 --- a/gfx/src/windows/nsFontMetricsWin.cpp +++ b/gfx/src/windows/nsFontMetricsWin.cpp @@ -4709,9 +4709,25 @@ nsFontEnumeratorWin::HaveFontFor(const char* aLangGroup, PRBool* aResult) return NS_OK; } -NS_IMETHODIMP -nsFontEnumeratorWin::UpdateFontList() +NS_IMETHODIMP +nsFontEnumeratorWin::UpdateFontList(PRBool *updateFontList) { + PRBool haveFontForLang = PR_FALSE; + int charSetCounter = 0; + PRUint16 maskBitBefore = 0; + + // initialize updateFontList + *updateFontList = PR_FALSE; + + // iterate langGoup; skip DEFAULT + for (charSetCounter = 1; charSetCounter < eCharSet_COUNT; charSetCounter++) { + HaveFontFor(gCharSetInfo[charSetCounter].mLangGroup, &haveFontForLang); + if (haveFontForLang) { + maskBitBefore |= PR_BIT(charSetCounter); + haveFontForLang = PR_FALSE; + } + } + // delete gGlobalFont if (nsFontMetricsWin::gGlobalFonts) { for (int i = 0; i < nsFontMetricsWin::gGlobalFontsCount; i++) { @@ -4732,5 +4748,17 @@ nsFontEnumeratorWin::UpdateFontList() } ::ReleaseDC(nsnull, dc); + PRUint16 maskBitAfter = 0; + // iterate langGoup again; skip DEFAULT + for (charSetCounter = 1; charSetCounter < eCharSet_COUNT; charSetCounter++) { + HaveFontFor(gCharSetInfo[charSetCounter].mLangGroup, &haveFontForLang); + if (haveFontForLang) { + maskBitAfter |= PR_BIT(charSetCounter); + haveFontForLang = PR_FALSE; + } + } + + // check for change + *updateFontList = (maskBitBefore != maskBitAfter); return NS_OK; } diff --git a/gfx/src/xlib/nsFontMetricsXlib.cpp b/gfx/src/xlib/nsFontMetricsXlib.cpp index 8336251e01e0..31f1e80244e8 100644 --- a/gfx/src/xlib/nsFontMetricsXlib.cpp +++ b/gfx/src/xlib/nsFontMetricsXlib.cpp @@ -4318,9 +4318,10 @@ nsFontEnumeratorXlib::HaveFontFor(const char* aLangGroup, PRBool* aResult) return NS_OK; } -NS_IMETHODIMP -nsFontEnumeratorXlib::UpdateFontList() +NS_IMETHODIMP +nsFontEnumeratorXlib::UpdateFontList(PRBool *updateFontList) { - return NS_ERROR_NOT_IMPLEMENTED; + *updateFontList = PR_FALSE; // always return false for now + return NS_OK; } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 69b9cd195a95..1b7ecc125f19 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -450,15 +450,6 @@ nsPresContext::PreferenceChanged(const char* aPrefName) return; } - // XXX for WM_FONTCHANGE messages, only flush the font cache (bug=89493) - // because nsObjectFrame can't handle a reframe at this time - if (strcmp(aPrefName,"font.internaluseonly.changed") == 0) { - if (mDeviceContext) { - mDeviceContext->FlushFontCache(); - } - return; - } - // Initialize our state from the user preferences GetUserPreferences(); diff --git a/layout/base/src/nsPresContext.cpp b/layout/base/src/nsPresContext.cpp index 69b9cd195a95..1b7ecc125f19 100644 --- a/layout/base/src/nsPresContext.cpp +++ b/layout/base/src/nsPresContext.cpp @@ -450,15 +450,6 @@ nsPresContext::PreferenceChanged(const char* aPrefName) return; } - // XXX for WM_FONTCHANGE messages, only flush the font cache (bug=89493) - // because nsObjectFrame can't handle a reframe at this time - if (strcmp(aPrefName,"font.internaluseonly.changed") == 0) { - if (mDeviceContext) { - mDeviceContext->FlushFontCache(); - } - return; - } - // Initialize our state from the user preferences GetUserPreferences(); diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index feeafde60be5..c95396582098 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -2998,24 +2998,27 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT case WM_FONTCHANGE: { nsresult rv; + PRBool didChange = PR_FALSE; // update the global font list nsCOMPtr fontEnum = do_GetService("@mozilla.org/gfx/fontenumerator;1", &rv); if (NS_SUCCEEDED(rv)) { - fontEnum->UpdateFontList(); - } - - // update device context font cache - // Dirty but easiest way: - // Changing nsIPref entry which triggers callbacks - // and flows into calling mDeviceContext->FlushFontCache() - // to update the font cache in all the instance of Browsers - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - PRBool fontInternalChange = PR_FALSE; - pPrefs->GetBoolPref("font.internaluseonly.changed", &fontInternalChange); - pPrefs->SetBoolPref("font.internaluseonly.changed", !fontInternalChange); - } + fontEnum->UpdateFontList(&didChange); + //didChange is TRUE only if new font langGroup is added to the list. + if (didChange) { + // update device context font cache + // Dirty but easiest way: + // Changing nsIPref entry which triggers callbacks + // and flows into calling mDeviceContext->FlushFontCache() + // to update the font cache in all the instance of Browsers + nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv)) { + PRBool fontInternalChange = PR_FALSE; + pPrefs->GetBoolPref("font.internaluseonly.changed", &fontInternalChange); + pPrefs->SetBoolPref("font.internaluseonly.changed", !fontInternalChange); + } + } + } //if (NS_SUCCEEDED(rv)) } break;