mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-06 22:53:08 +00:00
bug 71370; author=simon@softel.co.il; r=attinasi; sr=erik; implement bidi
(bidirectional text) for languages such as Arabic and Hebrew; from IBM bidi project; not part of build yet (due to #ifdef IBMBIDI)
This commit is contained in:
parent
c642b23048
commit
a6910ae277
@ -30,7 +30,7 @@
|
||||
* identified per MPL Section 3.3
|
||||
*
|
||||
* Date Modified by Description of modification
|
||||
* 03/20/2000 IBM Corp. BiDi - ability to change the default direction of the browser
|
||||
* 03/20/2000 IBM Corp. Bidi - ability to change the default direction of the browser
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,6 +51,9 @@
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIUBidiUtils.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// #define NOISY_DEBUG
|
||||
@ -1022,6 +1025,9 @@ void StyleTextImpl::ResetFrom(const nsStyleText* aParent, nsIPresContext* aPresC
|
||||
}
|
||||
mTextIndent = aParent->mTextIndent;
|
||||
mWordSpacing = aParent->mWordSpacing;
|
||||
#ifdef IBMBIDI
|
||||
mUnicodeBidi = aParent->mUnicodeBidi;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
else {
|
||||
mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
|
||||
@ -1032,6 +1038,9 @@ void StyleTextImpl::ResetFrom(const nsStyleText* aParent, nsIPresContext* aPresC
|
||||
mLineHeight.SetNormalValue();
|
||||
mTextIndent.SetCoordValue(0);
|
||||
mWordSpacing.SetNormalValue();
|
||||
#ifdef IBMBIDI
|
||||
mUnicodeBidi = NS_STYLE_UNICODE_BIDI_INHERIT;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
}
|
||||
|
||||
@ -1054,6 +1063,9 @@ PRInt32 StyleTextImpl::CalcDifference(const StyleTextImpl& aOther) const
|
||||
(mLineHeight == aOther.mLineHeight) &&
|
||||
(mTextIndent == aOther.mTextIndent) &&
|
||||
(mWordSpacing == aOther.mWordSpacing) &&
|
||||
#ifdef IBMBIDI
|
||||
(mUnicodeBidi == aOther.mUnicodeBidi) &&
|
||||
#endif // IBMBIDI
|
||||
(mVerticalAlign == aOther.mVerticalAlign)) {
|
||||
if (mTextDecoration == aOther.mTextDecoration) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
@ -1077,6 +1089,9 @@ PRUint32 StyleTextImpl::ComputeCRC32(PRUint32 aCrc) const
|
||||
crc = StyleCoordCRC(crc,&mTextIndent);
|
||||
crc = StyleCoordCRC(crc,&mWordSpacing);
|
||||
crc = StyleCoordCRC(crc,&mVerticalAlign);
|
||||
#ifdef IBMBIDI
|
||||
crc = AccumulateCRC(crc,(const char *)&mUnicodeBidi,sizeof(mUnicodeBidi));
|
||||
#endif // IBMBIDI
|
||||
#endif
|
||||
return crc;
|
||||
}
|
||||
@ -1111,7 +1126,16 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext*
|
||||
mVisible = aParent->mVisible;
|
||||
}
|
||||
else {
|
||||
#ifdef IBMBIDI
|
||||
nsBidiOptions mBidioptions;
|
||||
aPresContext->GetBidi(&mBidioptions);
|
||||
if (GET_BIDI_OPTION_DIRECTION(mBidioptions) == IBMBIDI_TEXTDIRECTION_RTL)
|
||||
mDirection = NS_STYLE_DIRECTION_RTL;
|
||||
else
|
||||
mDirection = NS_STYLE_DIRECTION_LTR;
|
||||
#else // ifdef IBMBIDI
|
||||
aPresContext->GetDefaultDirection(&mDirection);
|
||||
#endif // IBMBIDI
|
||||
aPresContext->GetLanguage(getter_AddRefs(mLanguage));
|
||||
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
||||
}
|
||||
@ -1123,11 +1147,17 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext*
|
||||
mOverflow = NS_STYLE_OVERFLOW_VISIBLE;
|
||||
mClipFlags = NS_STYLE_CLIP_AUTO;
|
||||
mClip.SetRect(0,0,0,0);
|
||||
#ifdef IBMBIDI
|
||||
mExplicitDirection = NS_STYLE_DIRECTION_INHERIT;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)
|
||||
{
|
||||
mDirection = aSource.mDirection;
|
||||
#ifdef IBMBIDI
|
||||
mExplicitDirection = aSource.mExplicitDirection;
|
||||
#endif // IBMBIDI
|
||||
mDisplay = aSource.mDisplay;
|
||||
mFloats = aSource.mFloats;
|
||||
mBreakType = aSource.mBreakType;
|
||||
@ -1143,6 +1173,9 @@ void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)
|
||||
void StyleDisplayImpl::CopyTo(nsStyleDisplay& aDest) const
|
||||
{
|
||||
aDest.mDirection = mDirection;
|
||||
#ifdef IBMBIDI
|
||||
aDest.mExplicitDirection = mExplicitDirection;
|
||||
#endif // IBMBIDI
|
||||
aDest.mDisplay = mDisplay;
|
||||
aDest.mFloats = mFloats;
|
||||
aDest.mBreakType = mBreakType;
|
||||
@ -1187,6 +1220,9 @@ PRUint32 StyleDisplayImpl::ComputeCRC32(PRUint32 aCrc) const
|
||||
PRUint32 crc = aCrc;
|
||||
#ifdef COMPUTE_STYLEDATA_CRC
|
||||
crc = AccumulateCRC(crc,(const char *)&mDirection,sizeof(mDirection));
|
||||
#ifdef IBMBIDI
|
||||
crc = AccumulateCRC(crc,(const char *)&mExplicitDirection,sizeof(mExplicitDirection));
|
||||
#endif // IBMBIDI
|
||||
crc = AccumulateCRC(crc,(const char *)&mDisplay,sizeof(mDisplay));
|
||||
crc = AccumulateCRC(crc,(const char *)&mFloats,sizeof(mFloats));
|
||||
crc = AccumulateCRC(crc,(const char *)&mBreakType,sizeof(mBreakType));
|
||||
|
@ -177,7 +177,11 @@ public:
|
||||
* buffer. Like operator= except a length is specified instead of
|
||||
* assuming 0 termination.
|
||||
*/
|
||||
#ifdef IBMBIDI
|
||||
PRBool SetTo(const PRUnichar* aBuffer, PRInt32 aLength);
|
||||
#else
|
||||
void SetTo(const PRUnichar* aBuffer, PRInt32 aLength);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the given
|
||||
|
@ -2110,6 +2110,21 @@ MapDeclarationTextInto(nsICSSDeclaration* aDeclaration,
|
||||
// word-spacing: normal, length, inherit
|
||||
SetCoord(ourText->mWordSpacing, text->mWordSpacing, parentText->mWordSpacing,
|
||||
SETCOORD_LH | SETCOORD_NORMAL, aFont->mFont, aPresContext);
|
||||
#ifdef IBMBIDI
|
||||
// unicode-bidi: enum, normal, inherit
|
||||
// normal means that override prohibited
|
||||
if (eCSSUnit_Normal == ourText->mUnicodeBidi.GetUnit() ) {
|
||||
text->mUnicodeBidi = NS_STYLE_UNICODE_BIDI_NORMAL;
|
||||
}
|
||||
else {
|
||||
if (eCSSUnit_Enumerated == ourText->mUnicodeBidi.GetUnit() ) {
|
||||
text->mUnicodeBidi = ourText->mUnicodeBidi.GetIntValue();
|
||||
}
|
||||
if (NS_STYLE_UNICODE_BIDI_INHERIT == text->mUnicodeBidi) {
|
||||
text->mUnicodeBidi = parentText->mUnicodeBidi;
|
||||
}
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2145,6 +2160,13 @@ MapDeclarationDisplayInto(nsICSSDeclaration* aDeclaration,
|
||||
// direction: enum, inherit
|
||||
if (eCSSUnit_Enumerated == ourDisplay->mDirection.GetUnit()) {
|
||||
display->mDirection = ourDisplay->mDirection.GetIntValue();
|
||||
#ifdef IBMBIDI
|
||||
display->mExplicitDirection = display->mDirection;
|
||||
|
||||
if (NS_STYLE_DIRECTION_RTL == display->mDirection) {
|
||||
aPresContext->EnableBidi();
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
else if (eCSSUnit_Inherit == ourDisplay->mDirection.GetUnit()) {
|
||||
display->mDirection = parentDisplay->mDirection;
|
||||
|
@ -177,7 +177,11 @@ public:
|
||||
* buffer. Like operator= except a length is specified instead of
|
||||
* assuming 0 termination.
|
||||
*/
|
||||
#ifdef IBMBIDI
|
||||
PRBool SetTo(const PRUnichar* aBuffer, PRInt32 aLength);
|
||||
#else
|
||||
void SetTo(const PRUnichar* aBuffer, PRInt32 aLength);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Change the contents of this fragment to be a copy of the given
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsMemory.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIUBidiUtils.h"
|
||||
#endif
|
||||
|
||||
nsTextFragment::~nsTextFragment()
|
||||
{
|
||||
@ -139,9 +142,16 @@ nsTextFragment::SetTo(PRUnichar* aBuffer, PRInt32 aLength, PRBool aRelease)
|
||||
mState.mLength = aLength;
|
||||
}
|
||||
|
||||
#ifdef IBMBIDI
|
||||
PRBool
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
nsTextFragment::SetTo(const PRUnichar* aBuffer, PRInt32 aLength)
|
||||
{
|
||||
#ifdef IBMBIDI
|
||||
PRBool bidiEnabled = PR_FALSE;
|
||||
#endif // IBMBIDI
|
||||
ReleaseText();
|
||||
if (0 != aLength) {
|
||||
// See if we need to store the data in ucs2 or not
|
||||
@ -152,7 +162,14 @@ nsTextFragment::SetTo(const PRUnichar* aBuffer, PRInt32 aLength)
|
||||
PRUnichar ch = *ucp++;
|
||||
if (ch >> 8) {
|
||||
need2 = PR_TRUE;
|
||||
#ifdef IBMBIDI
|
||||
if (CHAR_IS_BIDI(ch) ) {
|
||||
bidiEnabled = PR_TRUE;
|
||||
#endif // IBMBIDI
|
||||
break;
|
||||
#ifdef IBMBIDI
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,6 +206,9 @@ nsTextFragment::SetTo(const PRUnichar* aBuffer, PRInt32 aLength)
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef IBMBIDI
|
||||
return bidiEnabled;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -97,6 +97,10 @@ class nsISupportsArray;
|
||||
#define VERIFY_REFLOW_INCLUDE_SPACE_MANAGER 0x40
|
||||
#define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x80
|
||||
|
||||
#ifdef IBMBIDI // Constant for Set/Get CursorBidiLevel
|
||||
#define BIDI_LEVEL_UNDEFINED 0x80
|
||||
#endif
|
||||
|
||||
// for PostAttributeChanged
|
||||
enum nsAttributeChangeType {
|
||||
eChangeType_Set = 0, // Set attribute
|
||||
@ -512,6 +516,28 @@ public:
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
#endif
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* SetCursorBidiLevel will set the Bidi embedding level for the cursor. 0-63
|
||||
*/
|
||||
NS_IMETHOD SetCursorBidiLevel(PRUint8 aLevel) = 0;
|
||||
|
||||
/**
|
||||
* GetCursorBidiLevel will get the Bidi embedding level for the cursor. 0-63
|
||||
*/
|
||||
NS_IMETHOD GetCursorBidiLevel(PRUint8 *aOutLevel) = 0;
|
||||
|
||||
/**
|
||||
* UndefineCursorBidiLevel will set the Bidi embedding level for the cursor to an out-of-range value
|
||||
*/
|
||||
NS_IMETHOD UndefineCursorBidiLevel(void) = 0;
|
||||
|
||||
/**
|
||||
* Reconstruct and reflow frame model
|
||||
*/
|
||||
NS_IMETHOD BidiStyleChangeReflow(void) = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -58,6 +58,9 @@
|
||||
#include "nsIBox.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiPresUtils.h"
|
||||
#endif // IBMBIDI
|
||||
|
||||
int
|
||||
PrefChangedCallback(const char* aPrefName, void* instance_data)
|
||||
@ -71,6 +74,21 @@ PrefChangedCallback(const char* aPrefName, void* instance_data)
|
||||
return 0; // PREF_OK
|
||||
}
|
||||
|
||||
#ifdef IBMBIDI
|
||||
PRBool
|
||||
IsVisualCharset(const nsAutoString& aCharset)
|
||||
{
|
||||
if (aCharset.EqualsIgnoreCase("ibm864") // Arabic//ahmed
|
||||
|| aCharset.EqualsIgnoreCase("ibm862") // Hebrew
|
||||
|| aCharset.EqualsIgnoreCase("iso-8859-8") ) { // Hebrew
|
||||
return PR_TRUE; // visual text type
|
||||
}
|
||||
else {
|
||||
return PR_FALSE; // logical text type
|
||||
}
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
#include "nsContentCID.h"
|
||||
static NS_DEFINE_CID(kEventStateManagerCID, NS_EVENTSTATEMANAGER_CID);
|
||||
@ -121,6 +139,12 @@ nsPresContext::nsPresContext()
|
||||
mDefaultDirection = NS_STYLE_DIRECTION_LTR;
|
||||
mLanguageSpecificTransformType = eLanguageSpecificTransformType_Unknown;
|
||||
mIsRenderingOnlySelection = PR_FALSE;
|
||||
#ifdef IBMBIDI
|
||||
mIsVisual = PR_FALSE;
|
||||
mBidiUtils = nsnull;
|
||||
mIsBidiSystem = PR_FALSE;
|
||||
mBidi = 0;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
nsPresContext::~nsPresContext()
|
||||
@ -155,6 +179,11 @@ nsPresContext::~nsPresContext()
|
||||
mPrefs->UnregisterCallback("browser.visited_color", PrefChangedCallback, (void*)this);
|
||||
mPrefs->UnregisterCallback("image.animation_mode", PrefChangedCallback, (void*)this);
|
||||
}
|
||||
#ifdef IBMBIDI
|
||||
if (mBidiUtils) {
|
||||
delete mBidiUtils;
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
@ -486,6 +515,12 @@ nsPresContext::UpdateCharSet(const PRUnichar* aCharSet)
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef IBMBIDI
|
||||
//ahmed
|
||||
mCharset=aCharSet;
|
||||
|
||||
SetVisualMode(IsVisualCharset(mCharset) );
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1293,6 +1328,136 @@ nsPresContext::GetDefaultDirection(PRUint8* aDirection)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef IBMBIDI
|
||||
//ahmed
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::IsArabicEncoding(PRBool& aResult)
|
||||
{
|
||||
aResult=PR_FALSE;
|
||||
if ( (mCharset.EqualsIgnoreCase("ibm864") )||(mCharset.EqualsIgnoreCase("ibm864i") )||(mCharset.EqualsIgnoreCase("windows-1256") )||(mCharset.EqualsIgnoreCase("iso-8859-6") ))
|
||||
aResult=PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::IsVisRTL(PRBool& aResult)
|
||||
{
|
||||
aResult=PR_FALSE;
|
||||
if ( (mIsVisual)&&(GET_BIDI_OPTION_DIRECTION(mBidi) == IBMBIDI_TEXTDIRECTION_RTL) )
|
||||
aResult=PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::BidiEnabled(PRBool& aBidiEnabled) const
|
||||
{
|
||||
aBidiEnabled = PR_FALSE;
|
||||
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::BidiEnabled");
|
||||
if (mShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mShell->GetDocument(getter_AddRefs(doc) );
|
||||
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::BidiEnabled");
|
||||
if (doc) {
|
||||
doc->BidiEnabled(aBidiEnabled);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::EnableBidi() const
|
||||
{
|
||||
if (mShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mShell->GetDocument(getter_AddRefs(doc) );
|
||||
if (doc) {
|
||||
doc->EnableBidi();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetVisualMode(PRBool aIsVisual)
|
||||
{
|
||||
mIsVisual = aIsVisual;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::IsVisualMode(PRBool& aIsVisual) const
|
||||
{
|
||||
aIsVisual = mIsVisual;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBidiUtils(nsBidiPresUtils** aBidiUtils)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mBidiUtils) {
|
||||
mBidiUtils = new nsBidiPresUtils;
|
||||
if (!mBidiUtils) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
*aBidiUtils = mBidiUtils;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPresContext::SetBidi(nsBidiOptions aSource, PRBool aForceReflow)
|
||||
{
|
||||
mBidi = aSource;
|
||||
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(mBidi)
|
||||
|| IBMBIDI_NUMERAL_HINDI == GET_BIDI_OPTION_NUMERAL(mBidi)) {
|
||||
EnableBidi();
|
||||
}
|
||||
if (IBMBIDI_TEXTTYPE_VISUAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
||||
SetVisualMode(PR_TRUE);
|
||||
}
|
||||
else if (IBMBIDI_TEXTTYPE_LOGICAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
||||
SetVisualMode(PR_FALSE);
|
||||
}
|
||||
else {
|
||||
SetVisualMode(IsVisualCharset(mCharset) );
|
||||
}
|
||||
if (mShell && aForceReflow) {
|
||||
RemapStyleAndReflow();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPresContext::GetBidi(nsBidiOptions * aDest)
|
||||
{
|
||||
if (aDest)
|
||||
*aDest = mBidi;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//Mohamed 17-1-01
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetIsBidiSystem(PRBool aIsBidi)
|
||||
{
|
||||
mIsBidiSystem = aIsBidi;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetIsBidiSystem(PRBool& aResult) const
|
||||
{
|
||||
aResult = mIsBidiSystem;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBidiCharset(nsAutoString &aCharSet)
|
||||
{
|
||||
aCharSet = mCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
//Mohamed End
|
||||
|
||||
#endif //IBMBIDI
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetDefaultDirection(PRUint8 aDirection)
|
||||
|
@ -41,6 +41,11 @@
|
||||
#include "nsColor.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsILanguageAtom.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIUBidiUtils.h"
|
||||
class nsAutoString;
|
||||
class nsBidiPresUtils;
|
||||
#endif // IBMBIDI
|
||||
|
||||
struct nsFont;
|
||||
|
||||
@ -373,6 +378,94 @@ public:
|
||||
NS_IMETHOD GetLanguageSpecificTransformType(
|
||||
nsLanguageSpecificTransformType* aType) = 0;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* Check if bidi enabled (set depending on the presence of RTL
|
||||
* characters or when default directionality is RTL).
|
||||
* If enabled, we should apply the Unicode Bidi Algorithm
|
||||
*
|
||||
* @lina 07/12/2000
|
||||
*/
|
||||
NS_IMETHOD BidiEnabled(PRBool& aBidiEnabled) const = 0;
|
||||
|
||||
/**
|
||||
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
|
||||
*
|
||||
* @lina 07/12/2000
|
||||
*/
|
||||
NS_IMETHOD EnableBidi(void) const = 0;
|
||||
|
||||
/**
|
||||
* Set visual or implicit mode into the pres context.
|
||||
*
|
||||
* Visual directionality is a presentation method that displays text
|
||||
* as if it were a uni-directional, according to the primary display
|
||||
* direction only.
|
||||
*
|
||||
* Implicit directionality is a presentation method in which the
|
||||
* direction is determined by the Bidi algorithm according to the
|
||||
* category of the characters and the category of the adjacent
|
||||
* characters, and according to their primary direction.
|
||||
*
|
||||
* @lina 05/02/2000
|
||||
*/
|
||||
NS_IMETHOD SetVisualMode(PRBool aIsVisual) = 0;
|
||||
|
||||
/**
|
||||
* Check whether the content should be treated as visual.
|
||||
*
|
||||
* @lina 05/02/2000
|
||||
*/
|
||||
NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const = 0;
|
||||
|
||||
//Mohamed
|
||||
|
||||
/**
|
||||
* Get a Bidi presentation utilities object
|
||||
*/
|
||||
NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils) = 0;
|
||||
|
||||
/**
|
||||
* Set the Bidi options for the presentation context
|
||||
*/
|
||||
NS_IMETHOD SetBidi(nsBidiOptions Source, PRBool aForceReflow = PR_FALSE) = 0;
|
||||
|
||||
/**
|
||||
* Get the Bidi options for the presentation context
|
||||
*/
|
||||
NS_IMETHOD GetBidi(nsBidiOptions * Dist) = 0;
|
||||
//ahmed
|
||||
|
||||
/**
|
||||
* Check for Bidi text mode and direction
|
||||
* @return aResult == TRUE if the text mode is visual and the direction is right-to-left
|
||||
*/
|
||||
NS_IMETHOD IsVisRTL(PRBool &aResult) = 0;
|
||||
|
||||
/**
|
||||
* Check for Arabic encoding
|
||||
* @return aResult == TRUE if the document encoding is an Arabic codepage
|
||||
*/
|
||||
NS_IMETHOD IsArabicEncoding(PRBool &aResult) = 0;
|
||||
|
||||
/**
|
||||
* Set the Bidi capabilities of the system
|
||||
* @param aIsBidi == TRUE if the system has the capability of reordering Bidi text
|
||||
*/
|
||||
NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi) = 0;
|
||||
|
||||
/**
|
||||
* Get the Bidi capabilities of the system
|
||||
* @return aResult == TRUE if the system has the capability of reordering Bidi text
|
||||
*/
|
||||
NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the document charset
|
||||
*/
|
||||
NS_IMETHOD GetBidiCharset(nsAutoString &aCharSet) = 0;
|
||||
#endif // IBMBIDI
|
||||
|
||||
/**
|
||||
* Render only Selection
|
||||
*/
|
||||
|
@ -220,6 +220,10 @@ struct nsHTMLReflowState {
|
||||
// is from the top of the frame tree.
|
||||
PRInt32 mReflowDepth;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
nscoord mRightEdge;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// hook for attaching debug info (e.g. tables may attach a timer during reflow)
|
||||
void* mDebugHook;
|
||||
|
@ -187,6 +187,11 @@ typedef PRUint32 nsFrameState;
|
||||
// unchanged during the life-time of the frame.
|
||||
#define NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE 0x00010000
|
||||
|
||||
#ifdef IBMBIDI
|
||||
// If this bit is set, the frame itself is a bidi continuation,
|
||||
// or is incomplete (its next sibling is a bidi continuation)
|
||||
#define NS_FRAME_IS_BIDI 0x00200000
|
||||
#endif
|
||||
|
||||
// The lower 20 bits of the frame state word are reserved by this API.
|
||||
#define NS_FRAME_RESERVED 0x000FFFFF
|
||||
@ -1117,6 +1122,20 @@ public:
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible) = 0;
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* retrieve and set Bidi property of this frame
|
||||
* @lina 5/1/2000
|
||||
*/
|
||||
NS_IMETHOD GetBidiProperty(nsIPresContext* aPresContext,
|
||||
nsIAtom* aPropertyName,
|
||||
void** aPropertyValue,
|
||||
long aSize = sizeof(void*) ) const = 0;
|
||||
NS_IMETHOD SetBidiProperty(nsIPresContext* aPresContext,
|
||||
nsIAtom* aPropertyName,
|
||||
void* aPropertyValue) const = 0;
|
||||
#endif // IBMBIDI
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
|
||||
|
@ -41,6 +41,11 @@
|
||||
#include "nsColor.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsILanguageAtom.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIUBidiUtils.h"
|
||||
class nsAutoString;
|
||||
class nsBidiPresUtils;
|
||||
#endif // IBMBIDI
|
||||
|
||||
struct nsFont;
|
||||
|
||||
@ -373,6 +378,94 @@ public:
|
||||
NS_IMETHOD GetLanguageSpecificTransformType(
|
||||
nsLanguageSpecificTransformType* aType) = 0;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* Check if bidi enabled (set depending on the presence of RTL
|
||||
* characters or when default directionality is RTL).
|
||||
* If enabled, we should apply the Unicode Bidi Algorithm
|
||||
*
|
||||
* @lina 07/12/2000
|
||||
*/
|
||||
NS_IMETHOD BidiEnabled(PRBool& aBidiEnabled) const = 0;
|
||||
|
||||
/**
|
||||
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
|
||||
*
|
||||
* @lina 07/12/2000
|
||||
*/
|
||||
NS_IMETHOD EnableBidi(void) const = 0;
|
||||
|
||||
/**
|
||||
* Set visual or implicit mode into the pres context.
|
||||
*
|
||||
* Visual directionality is a presentation method that displays text
|
||||
* as if it were a uni-directional, according to the primary display
|
||||
* direction only.
|
||||
*
|
||||
* Implicit directionality is a presentation method in which the
|
||||
* direction is determined by the Bidi algorithm according to the
|
||||
* category of the characters and the category of the adjacent
|
||||
* characters, and according to their primary direction.
|
||||
*
|
||||
* @lina 05/02/2000
|
||||
*/
|
||||
NS_IMETHOD SetVisualMode(PRBool aIsVisual) = 0;
|
||||
|
||||
/**
|
||||
* Check whether the content should be treated as visual.
|
||||
*
|
||||
* @lina 05/02/2000
|
||||
*/
|
||||
NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const = 0;
|
||||
|
||||
//Mohamed
|
||||
|
||||
/**
|
||||
* Get a Bidi presentation utilities object
|
||||
*/
|
||||
NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils) = 0;
|
||||
|
||||
/**
|
||||
* Set the Bidi options for the presentation context
|
||||
*/
|
||||
NS_IMETHOD SetBidi(nsBidiOptions Source, PRBool aForceReflow = PR_FALSE) = 0;
|
||||
|
||||
/**
|
||||
* Get the Bidi options for the presentation context
|
||||
*/
|
||||
NS_IMETHOD GetBidi(nsBidiOptions * Dist) = 0;
|
||||
//ahmed
|
||||
|
||||
/**
|
||||
* Check for Bidi text mode and direction
|
||||
* @return aResult == TRUE if the text mode is visual and the direction is right-to-left
|
||||
*/
|
||||
NS_IMETHOD IsVisRTL(PRBool &aResult) = 0;
|
||||
|
||||
/**
|
||||
* Check for Arabic encoding
|
||||
* @return aResult == TRUE if the document encoding is an Arabic codepage
|
||||
*/
|
||||
NS_IMETHOD IsArabicEncoding(PRBool &aResult) = 0;
|
||||
|
||||
/**
|
||||
* Set the Bidi capabilities of the system
|
||||
* @param aIsBidi == TRUE if the system has the capability of reordering Bidi text
|
||||
*/
|
||||
NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi) = 0;
|
||||
|
||||
/**
|
||||
* Get the Bidi capabilities of the system
|
||||
* @return aResult == TRUE if the system has the capability of reordering Bidi text
|
||||
*/
|
||||
NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the document charset
|
||||
*/
|
||||
NS_IMETHOD GetBidiCharset(nsAutoString &aCharSet) = 0;
|
||||
#endif // IBMBIDI
|
||||
|
||||
/**
|
||||
* Render only Selection
|
||||
*/
|
||||
|
@ -97,6 +97,10 @@ class nsISupportsArray;
|
||||
#define VERIFY_REFLOW_INCLUDE_SPACE_MANAGER 0x40
|
||||
#define VERIFY_REFLOW_DURING_RESIZE_REFLOW 0x80
|
||||
|
||||
#ifdef IBMBIDI // Constant for Set/Get CursorBidiLevel
|
||||
#define BIDI_LEVEL_UNDEFINED 0x80
|
||||
#endif
|
||||
|
||||
// for PostAttributeChanged
|
||||
enum nsAttributeChangeType {
|
||||
eChangeType_Set = 0, // Set attribute
|
||||
@ -512,6 +516,28 @@ public:
|
||||
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
|
||||
#endif
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* SetCursorBidiLevel will set the Bidi embedding level for the cursor. 0-63
|
||||
*/
|
||||
NS_IMETHOD SetCursorBidiLevel(PRUint8 aLevel) = 0;
|
||||
|
||||
/**
|
||||
* GetCursorBidiLevel will get the Bidi embedding level for the cursor. 0-63
|
||||
*/
|
||||
NS_IMETHOD GetCursorBidiLevel(PRUint8 *aOutLevel) = 0;
|
||||
|
||||
/**
|
||||
* UndefineCursorBidiLevel will set the Bidi embedding level for the cursor to an out-of-range value
|
||||
*/
|
||||
NS_IMETHOD UndefineCursorBidiLevel(void) = 0;
|
||||
|
||||
/**
|
||||
* Reconstruct and reflow frame model
|
||||
*/
|
||||
NS_IMETHOD BidiStyleChangeReflow(void) = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -381,6 +381,9 @@ struct nsStyleText : public nsStyleStruct {
|
||||
PRUint8 mTextDecoration; // [reset] see nsStyleConsts.h
|
||||
PRUint8 mTextTransform; // [inherited] see nsStyleConsts.h
|
||||
PRUint8 mWhiteSpace; // [inherited] see nsStyleConsts.h
|
||||
#ifdef IBMBIDI
|
||||
PRUint8 mUnicodeBidi; // [inherited] see nsStyleConsts.h
|
||||
#endif // IBMBIDI
|
||||
|
||||
nsStyleCoord mLetterSpacing; // [inherited]
|
||||
nsStyleCoord mLineHeight; // [inherited]
|
||||
@ -398,6 +401,9 @@ struct nsStyleDisplay : public nsStyleStruct {
|
||||
~nsStyleDisplay(void) {};
|
||||
|
||||
PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
|
||||
#ifdef IBMBIDI
|
||||
PRUint8 mExplicitDirection ; // [reset] see nsStyleConsts.h NS_STYLE_DIRECTION_*
|
||||
#endif
|
||||
PRUint8 mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
|
||||
PRUint8 mFloats; // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
|
||||
PRUint8 mBreakType; // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
|
||||
|
@ -41,6 +41,11 @@
|
||||
#include "nsColor.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsILanguageAtom.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIUBidiUtils.h"
|
||||
class nsAutoString;
|
||||
class nsBidiPresUtils;
|
||||
#endif // IBMBIDI
|
||||
|
||||
struct nsFont;
|
||||
|
||||
@ -373,6 +378,94 @@ public:
|
||||
NS_IMETHOD GetLanguageSpecificTransformType(
|
||||
nsLanguageSpecificTransformType* aType) = 0;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* Check if bidi enabled (set depending on the presence of RTL
|
||||
* characters or when default directionality is RTL).
|
||||
* If enabled, we should apply the Unicode Bidi Algorithm
|
||||
*
|
||||
* @lina 07/12/2000
|
||||
*/
|
||||
NS_IMETHOD BidiEnabled(PRBool& aBidiEnabled) const = 0;
|
||||
|
||||
/**
|
||||
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
|
||||
*
|
||||
* @lina 07/12/2000
|
||||
*/
|
||||
NS_IMETHOD EnableBidi(void) const = 0;
|
||||
|
||||
/**
|
||||
* Set visual or implicit mode into the pres context.
|
||||
*
|
||||
* Visual directionality is a presentation method that displays text
|
||||
* as if it were a uni-directional, according to the primary display
|
||||
* direction only.
|
||||
*
|
||||
* Implicit directionality is a presentation method in which the
|
||||
* direction is determined by the Bidi algorithm according to the
|
||||
* category of the characters and the category of the adjacent
|
||||
* characters, and according to their primary direction.
|
||||
*
|
||||
* @lina 05/02/2000
|
||||
*/
|
||||
NS_IMETHOD SetVisualMode(PRBool aIsVisual) = 0;
|
||||
|
||||
/**
|
||||
* Check whether the content should be treated as visual.
|
||||
*
|
||||
* @lina 05/02/2000
|
||||
*/
|
||||
NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const = 0;
|
||||
|
||||
//Mohamed
|
||||
|
||||
/**
|
||||
* Get a Bidi presentation utilities object
|
||||
*/
|
||||
NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils) = 0;
|
||||
|
||||
/**
|
||||
* Set the Bidi options for the presentation context
|
||||
*/
|
||||
NS_IMETHOD SetBidi(nsBidiOptions Source, PRBool aForceReflow = PR_FALSE) = 0;
|
||||
|
||||
/**
|
||||
* Get the Bidi options for the presentation context
|
||||
*/
|
||||
NS_IMETHOD GetBidi(nsBidiOptions * Dist) = 0;
|
||||
//ahmed
|
||||
|
||||
/**
|
||||
* Check for Bidi text mode and direction
|
||||
* @return aResult == TRUE if the text mode is visual and the direction is right-to-left
|
||||
*/
|
||||
NS_IMETHOD IsVisRTL(PRBool &aResult) = 0;
|
||||
|
||||
/**
|
||||
* Check for Arabic encoding
|
||||
* @return aResult == TRUE if the document encoding is an Arabic codepage
|
||||
*/
|
||||
NS_IMETHOD IsArabicEncoding(PRBool &aResult) = 0;
|
||||
|
||||
/**
|
||||
* Set the Bidi capabilities of the system
|
||||
* @param aIsBidi == TRUE if the system has the capability of reordering Bidi text
|
||||
*/
|
||||
NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi) = 0;
|
||||
|
||||
/**
|
||||
* Get the Bidi capabilities of the system
|
||||
* @return aResult == TRUE if the system has the capability of reordering Bidi text
|
||||
*/
|
||||
NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the document charset
|
||||
*/
|
||||
NS_IMETHOD GetBidiCharset(nsAutoString &aCharSet) = 0;
|
||||
#endif // IBMBIDI
|
||||
|
||||
/**
|
||||
* Render only Selection
|
||||
*/
|
||||
|
@ -58,6 +58,9 @@
|
||||
#include "nsIBox.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiPresUtils.h"
|
||||
#endif // IBMBIDI
|
||||
|
||||
int
|
||||
PrefChangedCallback(const char* aPrefName, void* instance_data)
|
||||
@ -71,6 +74,21 @@ PrefChangedCallback(const char* aPrefName, void* instance_data)
|
||||
return 0; // PREF_OK
|
||||
}
|
||||
|
||||
#ifdef IBMBIDI
|
||||
PRBool
|
||||
IsVisualCharset(const nsAutoString& aCharset)
|
||||
{
|
||||
if (aCharset.EqualsIgnoreCase("ibm864") // Arabic//ahmed
|
||||
|| aCharset.EqualsIgnoreCase("ibm862") // Hebrew
|
||||
|| aCharset.EqualsIgnoreCase("iso-8859-8") ) { // Hebrew
|
||||
return PR_TRUE; // visual text type
|
||||
}
|
||||
else {
|
||||
return PR_FALSE; // logical text type
|
||||
}
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
#include "nsContentCID.h"
|
||||
static NS_DEFINE_CID(kEventStateManagerCID, NS_EVENTSTATEMANAGER_CID);
|
||||
@ -121,6 +139,12 @@ nsPresContext::nsPresContext()
|
||||
mDefaultDirection = NS_STYLE_DIRECTION_LTR;
|
||||
mLanguageSpecificTransformType = eLanguageSpecificTransformType_Unknown;
|
||||
mIsRenderingOnlySelection = PR_FALSE;
|
||||
#ifdef IBMBIDI
|
||||
mIsVisual = PR_FALSE;
|
||||
mBidiUtils = nsnull;
|
||||
mIsBidiSystem = PR_FALSE;
|
||||
mBidi = 0;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
nsPresContext::~nsPresContext()
|
||||
@ -155,6 +179,11 @@ nsPresContext::~nsPresContext()
|
||||
mPrefs->UnregisterCallback("browser.visited_color", PrefChangedCallback, (void*)this);
|
||||
mPrefs->UnregisterCallback("image.animation_mode", PrefChangedCallback, (void*)this);
|
||||
}
|
||||
#ifdef IBMBIDI
|
||||
if (mBidiUtils) {
|
||||
delete mBidiUtils;
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
@ -486,6 +515,12 @@ nsPresContext::UpdateCharSet(const PRUnichar* aCharSet)
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef IBMBIDI
|
||||
//ahmed
|
||||
mCharset=aCharSet;
|
||||
|
||||
SetVisualMode(IsVisualCharset(mCharset) );
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1293,6 +1328,136 @@ nsPresContext::GetDefaultDirection(PRUint8* aDirection)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef IBMBIDI
|
||||
//ahmed
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::IsArabicEncoding(PRBool& aResult)
|
||||
{
|
||||
aResult=PR_FALSE;
|
||||
if ( (mCharset.EqualsIgnoreCase("ibm864") )||(mCharset.EqualsIgnoreCase("ibm864i") )||(mCharset.EqualsIgnoreCase("windows-1256") )||(mCharset.EqualsIgnoreCase("iso-8859-6") ))
|
||||
aResult=PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::IsVisRTL(PRBool& aResult)
|
||||
{
|
||||
aResult=PR_FALSE;
|
||||
if ( (mIsVisual)&&(GET_BIDI_OPTION_DIRECTION(mBidi) == IBMBIDI_TEXTDIRECTION_RTL) )
|
||||
aResult=PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::BidiEnabled(PRBool& aBidiEnabled) const
|
||||
{
|
||||
aBidiEnabled = PR_FALSE;
|
||||
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::BidiEnabled");
|
||||
if (mShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mShell->GetDocument(getter_AddRefs(doc) );
|
||||
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::BidiEnabled");
|
||||
if (doc) {
|
||||
doc->BidiEnabled(aBidiEnabled);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::EnableBidi() const
|
||||
{
|
||||
if (mShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mShell->GetDocument(getter_AddRefs(doc) );
|
||||
if (doc) {
|
||||
doc->EnableBidi();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetVisualMode(PRBool aIsVisual)
|
||||
{
|
||||
mIsVisual = aIsVisual;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::IsVisualMode(PRBool& aIsVisual) const
|
||||
{
|
||||
aIsVisual = mIsVisual;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBidiUtils(nsBidiPresUtils** aBidiUtils)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mBidiUtils) {
|
||||
mBidiUtils = new nsBidiPresUtils;
|
||||
if (!mBidiUtils) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
*aBidiUtils = mBidiUtils;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPresContext::SetBidi(nsBidiOptions aSource, PRBool aForceReflow)
|
||||
{
|
||||
mBidi = aSource;
|
||||
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(mBidi)
|
||||
|| IBMBIDI_NUMERAL_HINDI == GET_BIDI_OPTION_NUMERAL(mBidi)) {
|
||||
EnableBidi();
|
||||
}
|
||||
if (IBMBIDI_TEXTTYPE_VISUAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
||||
SetVisualMode(PR_TRUE);
|
||||
}
|
||||
else if (IBMBIDI_TEXTTYPE_LOGICAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
||||
SetVisualMode(PR_FALSE);
|
||||
}
|
||||
else {
|
||||
SetVisualMode(IsVisualCharset(mCharset) );
|
||||
}
|
||||
if (mShell && aForceReflow) {
|
||||
RemapStyleAndReflow();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPresContext::GetBidi(nsBidiOptions * aDest)
|
||||
{
|
||||
if (aDest)
|
||||
*aDest = mBidi;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//Mohamed 17-1-01
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetIsBidiSystem(PRBool aIsBidi)
|
||||
{
|
||||
mIsBidiSystem = aIsBidi;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetIsBidiSystem(PRBool& aResult) const
|
||||
{
|
||||
aResult = mIsBidiSystem;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBidiCharset(nsAutoString &aCharSet)
|
||||
{
|
||||
aCharSet = mCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
//Mohamed End
|
||||
|
||||
#endif //IBMBIDI
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetDefaultDirection(PRUint8 aDirection)
|
||||
|
@ -50,6 +50,9 @@
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIUBidiUtils.h"
|
||||
#endif
|
||||
|
||||
// Base class for concrete presentation context classes
|
||||
class nsPresContext : public nsIPresContext, public nsIObserver {
|
||||
@ -167,6 +170,25 @@ public:
|
||||
NS_IMETHOD Observe(nsISupports* aSubject, const PRUnichar* aTopic,
|
||||
const PRUnichar* aData);
|
||||
|
||||
#ifdef IBMBIDI
|
||||
NS_IMETHOD BidiEnabled(PRBool& aBidiEnabled) const;
|
||||
NS_IMETHOD EnableBidi(void) const;
|
||||
NS_IMETHOD IsVisualMode(PRBool& aIsVisual) const;
|
||||
NS_IMETHOD SetVisualMode(PRBool aIsVisual);
|
||||
NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils);
|
||||
NS_IMETHOD SetBidi(nsBidiOptions aSource, PRBool aForceReflow = PR_FALSE);
|
||||
NS_IMETHOD GetBidi(nsBidiOptions * aDest);
|
||||
//ahmed
|
||||
NS_IMETHOD IsVisRTL(PRBool &aResult);
|
||||
NS_IMETHOD IsArabicEncoding(PRBool &aResult);
|
||||
|
||||
//Mohamed 17-1-01
|
||||
NS_IMETHOD SetIsBidiSystem(PRBool aIsBidi);
|
||||
NS_IMETHOD GetIsBidiSystem(PRBool &aResult) const;
|
||||
NS_IMETHOD GetBidiCharset(nsAutoString &aCharSet);
|
||||
//Mohamed End
|
||||
#endif // IBMBIDI
|
||||
|
||||
protected:
|
||||
nsPresContext();
|
||||
virtual ~nsPresContext();
|
||||
@ -213,8 +235,19 @@ protected:
|
||||
PRPackedBool mImageAnimationStopped; // image animation stopped
|
||||
PRPackedBool mStopped; // loading stopped
|
||||
PRPackedBool mStopChrome; // should we stop chrome?
|
||||
#ifdef IBMBIDI
|
||||
PRPackedBool mIsVisual; // is the Bidi text mode visual
|
||||
PRPackedBool mIsBidiSystem; // is the system capable of doing Bidi reordering
|
||||
#endif // IBMBIDI
|
||||
PRUint8 mDefaultDirection;
|
||||
PRPackedBool mIsRenderingOnlySelection;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
nsBidiPresUtils* mBidiUtils;
|
||||
nsBidiOptions mBidi;
|
||||
nsAutoString mCharset; // the charset we are using
|
||||
#endif // IBMBIDI
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool mInitialized;
|
||||
#endif
|
||||
|
@ -220,6 +220,10 @@ struct nsHTMLReflowState {
|
||||
// is from the top of the frame tree.
|
||||
PRInt32 mReflowDepth;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
nscoord mRightEdge;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// hook for attaching debug info (e.g. tables may attach a timer during reflow)
|
||||
void* mDebugHook;
|
||||
|
@ -187,6 +187,11 @@ typedef PRUint32 nsFrameState;
|
||||
// unchanged during the life-time of the frame.
|
||||
#define NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE 0x00010000
|
||||
|
||||
#ifdef IBMBIDI
|
||||
// If this bit is set, the frame itself is a bidi continuation,
|
||||
// or is incomplete (its next sibling is a bidi continuation)
|
||||
#define NS_FRAME_IS_BIDI 0x00200000
|
||||
#endif
|
||||
|
||||
// The lower 20 bits of the frame state word are reserved by this API.
|
||||
#define NS_FRAME_RESERVED 0x000FFFFF
|
||||
@ -1117,6 +1122,20 @@ public:
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
PRBool aCheckVis,
|
||||
PRBool* aIsVisible) = 0;
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* retrieve and set Bidi property of this frame
|
||||
* @lina 5/1/2000
|
||||
*/
|
||||
NS_IMETHOD GetBidiProperty(nsIPresContext* aPresContext,
|
||||
nsIAtom* aPropertyName,
|
||||
void** aPropertyValue,
|
||||
long aSize = sizeof(void*) ) const = 0;
|
||||
NS_IMETHOD SetBidiProperty(nsIPresContext* aPresContext,
|
||||
nsIAtom* aPropertyName,
|
||||
void* aPropertyValue) const = 0;
|
||||
#endif // IBMBIDI
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
|
||||
|
@ -2110,6 +2110,21 @@ MapDeclarationTextInto(nsICSSDeclaration* aDeclaration,
|
||||
// word-spacing: normal, length, inherit
|
||||
SetCoord(ourText->mWordSpacing, text->mWordSpacing, parentText->mWordSpacing,
|
||||
SETCOORD_LH | SETCOORD_NORMAL, aFont->mFont, aPresContext);
|
||||
#ifdef IBMBIDI
|
||||
// unicode-bidi: enum, normal, inherit
|
||||
// normal means that override prohibited
|
||||
if (eCSSUnit_Normal == ourText->mUnicodeBidi.GetUnit() ) {
|
||||
text->mUnicodeBidi = NS_STYLE_UNICODE_BIDI_NORMAL;
|
||||
}
|
||||
else {
|
||||
if (eCSSUnit_Enumerated == ourText->mUnicodeBidi.GetUnit() ) {
|
||||
text->mUnicodeBidi = ourText->mUnicodeBidi.GetIntValue();
|
||||
}
|
||||
if (NS_STYLE_UNICODE_BIDI_INHERIT == text->mUnicodeBidi) {
|
||||
text->mUnicodeBidi = parentText->mUnicodeBidi;
|
||||
}
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2145,6 +2160,13 @@ MapDeclarationDisplayInto(nsICSSDeclaration* aDeclaration,
|
||||
// direction: enum, inherit
|
||||
if (eCSSUnit_Enumerated == ourDisplay->mDirection.GetUnit()) {
|
||||
display->mDirection = ourDisplay->mDirection.GetIntValue();
|
||||
#ifdef IBMBIDI
|
||||
display->mExplicitDirection = display->mDirection;
|
||||
|
||||
if (NS_STYLE_DIRECTION_RTL == display->mDirection) {
|
||||
aPresContext->EnableBidi();
|
||||
}
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
else if (eCSSUnit_Inherit == ourDisplay->mDirection.GetUnit()) {
|
||||
display->mDirection = parentDisplay->mDirection;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* identified per MPL Section 3.3
|
||||
*
|
||||
* Date Modified by Description of modification
|
||||
* 03/20/2000 IBM Corp. BiDi - ability to change the default direction of the browser
|
||||
* 03/20/2000 IBM Corp. Bidi - ability to change the default direction of the browser
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,6 +51,9 @@
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIUBidiUtils.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// #define NOISY_DEBUG
|
||||
@ -1022,6 +1025,9 @@ void StyleTextImpl::ResetFrom(const nsStyleText* aParent, nsIPresContext* aPresC
|
||||
}
|
||||
mTextIndent = aParent->mTextIndent;
|
||||
mWordSpacing = aParent->mWordSpacing;
|
||||
#ifdef IBMBIDI
|
||||
mUnicodeBidi = aParent->mUnicodeBidi;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
else {
|
||||
mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
|
||||
@ -1032,6 +1038,9 @@ void StyleTextImpl::ResetFrom(const nsStyleText* aParent, nsIPresContext* aPresC
|
||||
mLineHeight.SetNormalValue();
|
||||
mTextIndent.SetCoordValue(0);
|
||||
mWordSpacing.SetNormalValue();
|
||||
#ifdef IBMBIDI
|
||||
mUnicodeBidi = NS_STYLE_UNICODE_BIDI_INHERIT;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
}
|
||||
|
||||
@ -1054,6 +1063,9 @@ PRInt32 StyleTextImpl::CalcDifference(const StyleTextImpl& aOther) const
|
||||
(mLineHeight == aOther.mLineHeight) &&
|
||||
(mTextIndent == aOther.mTextIndent) &&
|
||||
(mWordSpacing == aOther.mWordSpacing) &&
|
||||
#ifdef IBMBIDI
|
||||
(mUnicodeBidi == aOther.mUnicodeBidi) &&
|
||||
#endif // IBMBIDI
|
||||
(mVerticalAlign == aOther.mVerticalAlign)) {
|
||||
if (mTextDecoration == aOther.mTextDecoration) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
@ -1077,6 +1089,9 @@ PRUint32 StyleTextImpl::ComputeCRC32(PRUint32 aCrc) const
|
||||
crc = StyleCoordCRC(crc,&mTextIndent);
|
||||
crc = StyleCoordCRC(crc,&mWordSpacing);
|
||||
crc = StyleCoordCRC(crc,&mVerticalAlign);
|
||||
#ifdef IBMBIDI
|
||||
crc = AccumulateCRC(crc,(const char *)&mUnicodeBidi,sizeof(mUnicodeBidi));
|
||||
#endif // IBMBIDI
|
||||
#endif
|
||||
return crc;
|
||||
}
|
||||
@ -1111,7 +1126,16 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext*
|
||||
mVisible = aParent->mVisible;
|
||||
}
|
||||
else {
|
||||
#ifdef IBMBIDI
|
||||
nsBidiOptions mBidioptions;
|
||||
aPresContext->GetBidi(&mBidioptions);
|
||||
if (GET_BIDI_OPTION_DIRECTION(mBidioptions) == IBMBIDI_TEXTDIRECTION_RTL)
|
||||
mDirection = NS_STYLE_DIRECTION_RTL;
|
||||
else
|
||||
mDirection = NS_STYLE_DIRECTION_LTR;
|
||||
#else // ifdef IBMBIDI
|
||||
aPresContext->GetDefaultDirection(&mDirection);
|
||||
#endif // IBMBIDI
|
||||
aPresContext->GetLanguage(getter_AddRefs(mLanguage));
|
||||
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
||||
}
|
||||
@ -1123,11 +1147,17 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext*
|
||||
mOverflow = NS_STYLE_OVERFLOW_VISIBLE;
|
||||
mClipFlags = NS_STYLE_CLIP_AUTO;
|
||||
mClip.SetRect(0,0,0,0);
|
||||
#ifdef IBMBIDI
|
||||
mExplicitDirection = NS_STYLE_DIRECTION_INHERIT;
|
||||
#endif // IBMBIDI
|
||||
}
|
||||
|
||||
void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)
|
||||
{
|
||||
mDirection = aSource.mDirection;
|
||||
#ifdef IBMBIDI
|
||||
mExplicitDirection = aSource.mExplicitDirection;
|
||||
#endif // IBMBIDI
|
||||
mDisplay = aSource.mDisplay;
|
||||
mFloats = aSource.mFloats;
|
||||
mBreakType = aSource.mBreakType;
|
||||
@ -1143,6 +1173,9 @@ void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)
|
||||
void StyleDisplayImpl::CopyTo(nsStyleDisplay& aDest) const
|
||||
{
|
||||
aDest.mDirection = mDirection;
|
||||
#ifdef IBMBIDI
|
||||
aDest.mExplicitDirection = mExplicitDirection;
|
||||
#endif // IBMBIDI
|
||||
aDest.mDisplay = mDisplay;
|
||||
aDest.mFloats = mFloats;
|
||||
aDest.mBreakType = mBreakType;
|
||||
@ -1187,6 +1220,9 @@ PRUint32 StyleDisplayImpl::ComputeCRC32(PRUint32 aCrc) const
|
||||
PRUint32 crc = aCrc;
|
||||
#ifdef COMPUTE_STYLEDATA_CRC
|
||||
crc = AccumulateCRC(crc,(const char *)&mDirection,sizeof(mDirection));
|
||||
#ifdef IBMBIDI
|
||||
crc = AccumulateCRC(crc,(const char *)&mExplicitDirection,sizeof(mExplicitDirection));
|
||||
#endif // IBMBIDI
|
||||
crc = AccumulateCRC(crc,(const char *)&mDisplay,sizeof(mDisplay));
|
||||
crc = AccumulateCRC(crc,(const char *)&mFloats,sizeof(mFloats));
|
||||
crc = AccumulateCRC(crc,(const char *)&mBreakType,sizeof(mBreakType));
|
||||
|
Loading…
x
Reference in New Issue
Block a user