From a4b06cfcbffaf9dd1fa9f7e7eab11b835de9681c Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Mon, 9 Aug 2004 21:19:15 +0000 Subject: [PATCH] Eliminating mCharset mode of prescontex. Bug 253489, r+sr=roc git-svn-id: svn://10.0.0.236/trunk@160548 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresContext.cpp | 16 +++++++++------- mozilla/layout/base/nsPresContext.h | 3 +-- mozilla/layout/base/public/nsPresContext.h | 3 +-- mozilla/layout/base/src/nsPresContext.cpp | 16 +++++++++------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 58f8f3a80a0..e3626a5629f 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -730,18 +730,18 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (mLangService) { doc->AddCharSetObserver(this); - UpdateCharSet(doc->GetDocumentCharacterSet().get()); + UpdateCharSet(doc->GetDocumentCharacterSet()); } } } } void -nsPresContext::UpdateCharSet(const char* aCharSet) +nsPresContext::UpdateCharSet(const nsAFlatCString& aCharSet) { if (mLangService) { NS_IF_RELEASE(mLangGroup); - mLangGroup = mLangService->LookupCharSet(aCharSet).get(); // addrefs + mLangGroup = mLangService->LookupCharSet(aCharSet.get()).get(); // addrefs if (mLangGroup == nsLayoutAtoms::Japanese && mEnableJapaneseTransform) { mLanguageSpecificTransformType = @@ -762,7 +762,6 @@ nsPresContext::UpdateCharSet(const char* aCharSet) } #ifdef IBMBIDI //ahmed - mCharset=aCharSet; switch (GET_BIDI_OPTION_TEXTTYPE(mBidi)) { @@ -776,7 +775,7 @@ nsPresContext::UpdateCharSet(const char* aCharSet) case IBMBIDI_TEXTTYPE_CHARSET: default: - SetVisualMode(IsVisualCharset(mCharset)); + SetVisualMode(IsVisualCharset(aCharSet)); } #endif // IBMBIDI } @@ -787,7 +786,7 @@ nsPresContext::Observe(nsISupports* aSubject, const PRUnichar* aData) { if (!nsCRT::strcmp(aTopic, "charset")) { - UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get()); + UpdateCharSet(NS_LossyConvertUCS2toASCII(aData)); mDeviceContext->FlushFontCache(); ClearStyleDataAndReflow(); @@ -1114,7 +1113,10 @@ nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow) SetVisualMode(PR_FALSE); } else { - SetVisualMode(IsVisualCharset(mCharset) ); + nsIDocument* doc = mShell->GetDocument(); + if (doc) { + SetVisualMode(IsVisualCharset(doc->GetDocumentCharacterSet())); + } } if (mShell && aForceReflow) { ClearStyleDataAndReflow(); diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index ba1811448b0..729575b94ca 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -589,7 +589,7 @@ protected: NS_HIDDEN_(void) GetUserPreferences(); NS_HIDDEN_(void) GetFontPreferences(); - NS_HIDDEN_(void) UpdateCharSet(const char* aCharSet); + NS_HIDDEN_(void) UpdateCharSet(const nsAFlatCString& aCharSet); // IMPORTANT: The ownership implicit in the following member variables // has been explicitly checked. If you add any members to this class, @@ -615,7 +615,6 @@ protected: #ifdef IBMBIDI nsBidiPresUtils* mBidiUtils; - nsCString mCharset; // the charset we are using #endif nsCOMPtr mTheme; diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index ba1811448b0..729575b94ca 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -589,7 +589,7 @@ protected: NS_HIDDEN_(void) GetUserPreferences(); NS_HIDDEN_(void) GetFontPreferences(); - NS_HIDDEN_(void) UpdateCharSet(const char* aCharSet); + NS_HIDDEN_(void) UpdateCharSet(const nsAFlatCString& aCharSet); // IMPORTANT: The ownership implicit in the following member variables // has been explicitly checked. If you add any members to this class, @@ -615,7 +615,6 @@ protected: #ifdef IBMBIDI nsBidiPresUtils* mBidiUtils; - nsCString mCharset; // the charset we are using #endif nsCOMPtr mTheme; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 58f8f3a80a0..e3626a5629f 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -730,18 +730,18 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (mLangService) { doc->AddCharSetObserver(this); - UpdateCharSet(doc->GetDocumentCharacterSet().get()); + UpdateCharSet(doc->GetDocumentCharacterSet()); } } } } void -nsPresContext::UpdateCharSet(const char* aCharSet) +nsPresContext::UpdateCharSet(const nsAFlatCString& aCharSet) { if (mLangService) { NS_IF_RELEASE(mLangGroup); - mLangGroup = mLangService->LookupCharSet(aCharSet).get(); // addrefs + mLangGroup = mLangService->LookupCharSet(aCharSet.get()).get(); // addrefs if (mLangGroup == nsLayoutAtoms::Japanese && mEnableJapaneseTransform) { mLanguageSpecificTransformType = @@ -762,7 +762,6 @@ nsPresContext::UpdateCharSet(const char* aCharSet) } #ifdef IBMBIDI //ahmed - mCharset=aCharSet; switch (GET_BIDI_OPTION_TEXTTYPE(mBidi)) { @@ -776,7 +775,7 @@ nsPresContext::UpdateCharSet(const char* aCharSet) case IBMBIDI_TEXTTYPE_CHARSET: default: - SetVisualMode(IsVisualCharset(mCharset)); + SetVisualMode(IsVisualCharset(aCharSet)); } #endif // IBMBIDI } @@ -787,7 +786,7 @@ nsPresContext::Observe(nsISupports* aSubject, const PRUnichar* aData) { if (!nsCRT::strcmp(aTopic, "charset")) { - UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get()); + UpdateCharSet(NS_LossyConvertUCS2toASCII(aData)); mDeviceContext->FlushFontCache(); ClearStyleDataAndReflow(); @@ -1114,7 +1113,10 @@ nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow) SetVisualMode(PR_FALSE); } else { - SetVisualMode(IsVisualCharset(mCharset) ); + nsIDocument* doc = mShell->GetDocument(); + if (doc) { + SetVisualMode(IsVisualCharset(doc->GetDocumentCharacterSet())); + } } if (mShell && aForceReflow) { ClearStyleDataAndReflow();