Merge the last green changeset on mozilla-inbound to mozilla-central

This commit is contained in:
Ehsan Akhgari 2011-07-13 11:40:03 -04:00
commit 3e4044476c
31 changed files with 840 additions and 866 deletions

View File

@ -41,8 +41,10 @@ var progressListener4 = {
onLocationChange: function onLocationChange() {
ok(expectListener4, "didn't call progressListener4 for the first location change");
gBrowser.removeProgressListener(this);
gBrowser.addTab();
gBrowser.removeCurrentTab();
finish();
executeSoon(function () {
gBrowser.addTab();
gBrowser.removeCurrentTab();
finish();
});
}
};

View File

@ -110,9 +110,11 @@ function runNextTest() {
let onHidden = onHiddenArray.shift();
info("[Test #" + gTestIndex + "] popup hidden (" + onHiddenArray.length + " hides remaining)");
onHidden.call(nextTest, this);
if (!onHiddenArray.length)
goNext();
executeSoon(function () {
onHidden.call(nextTest, this);
if (!onHiddenArray.length)
goNext();
});
}, onHiddenArray.length);
info("[Test #" + gTestIndex + "] added listeners; panel state: " + PopupNotifications.isPanelOpen);
}
@ -739,4 +741,4 @@ function dismissNotification(popup) {
executeSoon(function () {
EventUtils.synthesizeKey("VK_ESCAPE", {});
});
}
}

View File

@ -84,13 +84,17 @@ var gTabsListener = {
// Reset arrays.
this._loadedURIs.length = 0;
// Close all tabs.
while (gBrowser.tabs.length > 1)
gBrowser.removeCurrentTab();
this._openTabsCount = 0;
// Test finished. This will move to the next one.
waitForFocus(gCurrentTest.finish, gBrowser.ownerDocument.defaultView);
executeSoon(function () {
// Close all tabs.
while (gBrowser.tabs.length > 1)
gBrowser.removeCurrentTab();
// Test finished. This will move to the next one.
waitForFocus(gCurrentTest.finish, gBrowser.ownerDocument.defaultView);
});
}
}
}

View File

@ -103,6 +103,7 @@
#include "nsFrameManager.h"
#include "nsFrameLoader.h"
#include "nsBidi.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "CanvasUtils.h"
@ -2738,10 +2739,6 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
nsIDocument* document = presShell->GetDocument();
nsBidiPresUtils* bidiUtils = presShell->GetPresContext()->GetBidiUtils();
if (!bidiUtils)
return NS_ERROR_FAILURE;
// replace all the whitespace characters with U+0020 SPACE
nsAutoString textToDraw(aRawText);
TextReplaceWhitespaceCharacters(textToDraw);
@ -2787,15 +2784,17 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
// calls bidi algo twice since it needs the full text width and the
// bounding boxes before rendering anything
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord);
nsBidi bidiEngine;
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord,
&bidiEngine);
if (NS_FAILED(rv))
return rv;
@ -2894,15 +2893,16 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
processor.mThebes = ctx;
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull,
&bidiEngine);
if (NS_FAILED(rv))
return rv;
@ -2931,15 +2931,16 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
ApplyStyle(STYLE_FILL);
}
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull,
&bidiEngine);
// this needs to be restored before function can return
if (doUseIntermediateSurface) {

View File

@ -100,6 +100,7 @@
#include "nsFrameManager.h"
#include "nsFrameLoader.h"
#include "nsBidi.h"
#include "nsBidiPresUtils.h"
#include "Layers.h"
#include "CanvasUtils.h"
@ -3196,11 +3197,6 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
nsIDocument* document = presShell->GetDocument();
nsBidiPresUtils* bidiUtils = presShell->GetPresContext()->GetBidiUtils();
if (!bidiUtils) {
return NS_ERROR_FAILURE;
}
// replace all the whitespace characters with U+0020 SPACE
nsAutoString textToDraw(aRawText);
TextReplaceWhitespaceCharacters(textToDraw);
@ -3251,15 +3247,17 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
// calls bidi algo twice since it needs the full text width and the
// bounding boxes before rendering anything
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord);
nsBidi bidiEngine;
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_MEASURE,
nsnull,
0,
&totalWidthCoord,
&bidiEngine);
if (NS_FAILED(rv)) {
return rv;
}
@ -3350,15 +3348,16 @@ nsCanvasRenderingContext2DAzure::DrawOrMeasureText(const nsAString& aRawText,
// don't ever need to measure the bounding box twice
processor.mDoMeasureBoundingBox = PR_FALSE;
rv = bidiUtils->ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull);
rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
textToDraw.Length(),
isRTL ? NSBIDI_RTL : NSBIDI_LTR,
presShell->GetPresContext(),
processor,
nsBidiPresUtils::MODE_DRAW,
nsnull,
0,
nsnull,
&bidiEngine);
mTarget->SetTransform(oldTransform);

View File

@ -339,8 +339,9 @@ FontFamily::FindStyleVariations()
PRBool
gfxFT2FontGroup::FontCallback(const nsAString& fontName,
const nsACString& genericName,
void *closure)
const nsACString& genericName,
PRBool aUseFontSet,
void *closure)
{
nsTArray<nsString> *sa = static_cast<nsTArray<nsString>*>(closure);
@ -449,6 +450,7 @@ PRUint32 getUTF8CharAndNext(const PRUint8 *aString, PRUint8 *aLength)
static PRBool
AddFontNameToArray(const nsAString& aName,
const nsACString& aGenericName,
PRBool aUseFontSet,
void *aClosure)
{
if (!aName.IsEmpty()) {

View File

@ -199,6 +199,7 @@ protected: // new functions
static PRBool FontCallback (const nsAString & fontName,
const nsACString & genericName,
PRBool aUseFontSet,
void *closure);
PRBool mEnableKerning;

View File

@ -2060,6 +2060,7 @@ gfxFontGroup::BuildFontList()
PRBool
gfxFontGroup::FindPlatformFont(const nsAString& aName,
const nsACString& aGenericName,
PRBool aUseFontSet,
void *aClosure)
{
gfxFontGroup *fontGroup = static_cast<gfxFontGroup*>(aClosure);
@ -2068,21 +2069,23 @@ gfxFontGroup::FindPlatformFont(const nsAString& aName,
PRBool needsBold;
gfxFontEntry *fe = nsnull;
// First, look up in the user font set...
// If the fontSet matches the family, we must not look for a platform
// font of the same name, even if we fail to actually get a fontEntry
// here; we'll fall back to the next name in the CSS font-family list.
PRBool foundFamily = PR_FALSE;
gfxUserFontSet *fs = fontGroup->GetUserFontSet();
if (fs) {
// If the fontSet matches the family, but the font has not yet finished
// loading (nor has its load timeout fired), the fontGroup should wait
// for the download, and not actually draw its text yet.
PRBool waitForUserFont = PR_FALSE;
fe = fs->FindFontEntry(aName, *fontStyle, foundFamily,
needsBold, waitForUserFont);
if (!fe && waitForUserFont) {
fontGroup->mSkipDrawing = PR_TRUE;
if (aUseFontSet) {
// First, look up in the user font set...
// If the fontSet matches the family, we must not look for a platform
// font of the same name, even if we fail to actually get a fontEntry
// here; we'll fall back to the next name in the CSS font-family list.
gfxUserFontSet *fs = fontGroup->GetUserFontSet();
if (fs) {
// If the fontSet matches the family, but the font has not yet finished
// loading (nor has its load timeout fired), the fontGroup should wait
// for the download, and not actually draw its text yet.
PRBool waitForUserFont = PR_FALSE;
fe = fs->FindFontEntry(aName, *fontStyle, foundFamily,
needsBold, waitForUserFont);
if (!fe && waitForUserFont) {
fontGroup->mSkipDrawing = PR_TRUE;
}
}
}
@ -2144,7 +2147,7 @@ gfxFontGroup::ForEachFont(FontCreationCallback fc,
void *closure)
{
return ForEachFontInternal(mFamilies, mStyle.language,
PR_TRUE, PR_TRUE, fc, closure);
PR_TRUE, PR_TRUE, PR_TRUE, fc, closure);
}
PRBool
@ -2154,19 +2157,22 @@ gfxFontGroup::ForEachFont(const nsAString& aFamilies,
void *closure)
{
return ForEachFontInternal(aFamilies, aLanguage,
PR_FALSE, PR_TRUE, fc, closure);
PR_FALSE, PR_TRUE, PR_TRUE, fc, closure);
}
struct ResolveData {
ResolveData(gfxFontGroup::FontCreationCallback aCallback,
nsACString& aGenericFamily,
PRBool aUseFontSet,
void *aClosure) :
mCallback(aCallback),
mGenericFamily(aGenericFamily),
mUseFontSet(aUseFontSet),
mClosure(aClosure) {
}
gfxFontGroup::FontCreationCallback mCallback;
nsCString mGenericFamily;
PRBool mUseFontSet;
void *mClosure;
};
@ -2175,6 +2181,7 @@ gfxFontGroup::ForEachFontInternal(const nsAString& aFamilies,
nsIAtom *aLanguage,
PRBool aResolveGeneric,
PRBool aResolveFontName,
PRBool aUseFontSet,
FontCreationCallback fc,
void *closure)
{
@ -2267,18 +2274,17 @@ gfxFontGroup::ForEachFontInternal(const nsAString& aFamilies,
}
}
NS_LossyConvertUTF16toASCII gf(genericFamily);
if (generic) {
ForEachFontInternal(family, groupAtom, PR_FALSE,
aResolveFontName, fc, closure);
fc(family, gf, PR_FALSE, closure);
} else if (!family.IsEmpty()) {
NS_LossyConvertUTF16toASCII gf(genericFamily);
if (aResolveFontName) {
ResolveData data(fc, gf, closure);
ResolveData data(fc, gf, aUseFontSet, closure);
PRBool aborted = PR_FALSE, needsBold;
nsresult rv = NS_OK;
PRBool foundFamily = PR_FALSE;
PRBool waitForUserFont = PR_FALSE;
if (mUserFontSet &&
if (aUseFontSet && mUserFontSet &&
mUserFontSet->FindFontEntry(family, mStyle, foundFamily,
needsBold, waitForUserFont))
{
@ -2298,7 +2304,7 @@ gfxFontGroup::ForEachFontInternal(const nsAString& aFamilies,
return PR_FALSE;
}
else {
if (!fc(family, gf, closure))
if (!fc(family, gf, aUseFontSet, closure))
return PR_FALSE;
}
}
@ -2310,7 +2316,8 @@ gfxFontGroup::ForEachFontInternal(const nsAString& aFamilies,
prefName.Append(groupString);
nsAdoptingString value = Preferences::GetString(prefName.get());
if (value) {
ForEachFontInternal(value, groupAtom, PR_FALSE, aResolveFontName,
ForEachFontInternal(value, groupAtom, PR_FALSE,
aResolveFontName, PR_FALSE,
fc, closure);
}
}
@ -2325,7 +2332,8 @@ PRBool
gfxFontGroup::FontResolverProc(const nsAString& aName, void *aClosure)
{
ResolveData *data = reinterpret_cast<ResolveData*>(aClosure);
return (data->mCallback)(aName, data->mGenericFamily, data->mClosure);
return (data->mCallback)(aName, data->mGenericFamily, data->mUseFontSet,
data->mClosure);
}
gfxTextRun *

View File

@ -2344,6 +2344,7 @@ public:
*/
typedef PRBool (*FontCreationCallback) (const nsAString& aName,
const nsACString& aGenericName,
PRBool aUseFontSet,
void *closure);
PRBool ForEachFont(const nsAString& aFamilies,
nsIAtom *aLanguage,
@ -2457,11 +2458,14 @@ protected:
* and with actual font names. If false then fc() is called with each
* family name in aFamilies (after resolving CSS/Gecko generic family names
* if aResolveGeneric).
* If aUseFontSet is true, the fontgroup's user font set is checked;
* if false then it is skipped.
*/
PRBool ForEachFontInternal(const nsAString& aFamilies,
nsIAtom *aLanguage,
PRBool aResolveGeneric,
PRBool aResolveFontName,
PRBool aUseFontSet,
FontCreationCallback fc,
void *closure);
@ -2469,6 +2473,7 @@ protected:
static PRBool FindPlatformFont(const nsAString& aName,
const nsACString& aGenericName,
PRBool aUseFontSet,
void *closure);
static NS_HIDDEN_(nsILanguageAtomService*) gLangService;

View File

@ -1816,7 +1816,7 @@ FFRECountHyphens (const nsAString &aFFREName)
static PRBool
FamilyCallback (const nsAString& fontName, const nsACString& genericName,
void *closure)
PRBool aUseFontSet, void *closure)
{
FamilyCallbackData *data = static_cast<FamilyCallbackData*>(closure);
nsTArray<nsString> *list = data->mFcFamilyList;
@ -1854,7 +1854,7 @@ FamilyCallback (const nsAString& fontName, const nsACString& genericName,
// longer includes the family name for matching against system fonts.
//
const gfxUserFontSet *userFontSet = data->mUserFontSet;
if (genericName.Length() == 0 &&
if (aUseFontSet && genericName.Length() == 0 &&
userFontSet && userFontSet->HasFamily(fontName)) {
nsAutoString userFontName =
NS_LITERAL_STRING(FONT_FACE_FAMILY_PREFIX) + fontName;
@ -1900,7 +1900,7 @@ gfxPangoFontGroup::GetFcFamilies(nsTArray<nsString> *aFcFamilyList,
FamilyCallbackData data(aFcFamilyList, mUserFontSet);
// Leave non-existing fonts in the list so that fontconfig can get the
// best match.
ForEachFontInternal(mFamilies, aLanguage, PR_TRUE, PR_FALSE,
ForEachFontInternal(mFamilies, aLanguage, PR_TRUE, PR_FALSE, PR_TRUE,
FamilyCallback, &data);
}

View File

@ -954,6 +954,9 @@ static JS_ALWAYS_INLINE JSScript *
EvalCacheLookup(JSContext *cx, JSLinearString *str, StackFrame *caller, uintN staticLevel,
JSPrincipals *principals, JSObject &scopeobj, JSScript **bucket)
{
if (!principals)
return NULL;
/*
* Cache local eval scripts indexed by source qualified by scope.
*
@ -981,7 +984,8 @@ EvalCacheLookup(JSContext *cx, JSLinearString *str, StackFrame *caller, uintN st
script->getVersion() == version &&
!script->hasSingletons &&
(script->principals == principals ||
(principals->subsume(principals, script->principals) &&
(script->principals &&
principals->subsume(principals, script->principals) &&
script->principals->subsume(script->principals, principals)))) {
/*
* Get the prior (cache-filling) eval's saved caller function.

View File

@ -773,7 +773,7 @@ public:
* The array does not need to be initialized.<p>
* The index map will result in <code>aIndexMap[aLogicalIndex]==aVisualIndex</code>.
*/
nsresult ReorderLogical(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
static nsresult ReorderLogical(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
#endif // FULL_BIDI_ENGINE
/**
* This is a convenience function that does not use a nsBidi object.
@ -794,7 +794,7 @@ public:
* The array does not need to be initialized.<p>
* The index map will result in <code>aIndexMap[aVisualIndex]==aLogicalIndex</code>.
*/
nsresult ReorderVisual(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
static nsresult ReorderVisual(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap);
#ifdef FULL_BIDI_ENGINE
/**
@ -917,7 +917,7 @@ private:
void ReorderLine(nsBidiLevel aMinLevel, nsBidiLevel aMaxLevel);
PRBool PrepareReorder(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap, nsBidiLevel *aMinLevel, nsBidiLevel *aMaxLevel);
static PRBool PrepareReorder(const nsBidiLevel *aLevels, PRInt32 aLength, PRInt32 *aIndexMap, nsBidiLevel *aMinLevel, nsBidiLevel *aMaxLevel);
PRInt32 doWriteReverse(const PRUnichar *src, PRInt32 srcLength,
PRUnichar *dest, PRUint16 options);

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,9 @@
#undef DrawText
#endif
struct BidiParagraphData;
struct BidiLineData;
/**
* A structure representing some continuation state for each frame on the line,
* used to determine the first and the last continuation frame for each
@ -118,7 +121,6 @@ class nsBidiPresUtils {
public:
nsBidiPresUtils();
~nsBidiPresUtils();
PRBool IsSuccessful(void) const;
/**
* Interface for the processor used by ProcessText. Used by process text to
@ -174,9 +176,11 @@ public:
*
* @lina 06/18/2000
*/
nsresult Resolve(nsBlockFrame* aBlockFrame);
void ResolveParagraph(nsBlockFrame* aBlockFrame);
void ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame);
static nsresult Resolve(nsBlockFrame* aBlockFrame);
static nsresult ResolveParagraph(nsBlockFrame* aBlockFrame,
BidiParagraphData* aBpd);
static void ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame,
BidiParagraphData* aBpd);
/**
* Reorder this line using Bidi engine.
@ -184,8 +188,8 @@ public:
*
* @lina 05/02/2000
*/
void ReorderFrames(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
static void ReorderFrames(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Format Unicode text, taking into account bidi capabilities
@ -194,11 +198,11 @@ public:
*
* @lina 06/18/2000
*/
nsresult FormatUnicodeText(nsPresContext* aPresContext,
PRUnichar* aText,
PRInt32& aTextLength,
nsCharType aCharType,
PRBool aIsOddLevel);
static nsresult FormatUnicodeText(nsPresContext* aPresContext,
PRUnichar* aText,
PRInt32& aTextLength,
nsCharType aCharType,
PRBool aIsOddLevel);
/**
* Reorder plain text using the Unicode Bidi algorithm and send it to
@ -217,26 +221,26 @@ public:
* @param[in,out] aPosResolve array of logical positions to resolve into visual positions; can be nsnull if this functionality is not required
* @param aPosResolveCount number of items in the aPosResolve array
*/
nsresult RenderText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
nscoord aX,
nscoord aY,
nsBidiPositionResolve* aPosResolve = nsnull,
PRInt32 aPosResolveCount = 0)
static nsresult RenderText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
nscoord aX,
nscoord aY,
nsBidiPositionResolve* aPosResolve = nsnull,
PRInt32 aPosResolveCount = 0)
{
return ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext, aRenderingContext,
aTextRunConstructionContext, MODE_DRAW, aX, aY, aPosResolve, aPosResolveCount, nsnull);
}
nscoord MeasureTextWidth(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext)
static nscoord MeasureTextWidth(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext)
{
nscoord length;
nsresult rv = ProcessTextForRenderingContext(aText, aLength, aBaseDirection, aPresContext,
@ -253,10 +257,10 @@ public:
* @param[out] aLeftMost : leftmost frame on this line
* @param[out] aRightMost : rightmost frame on this line
*/
PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine,
nsIFrame** aLeftmost,
nsIFrame** aRightmost);
static PRBool CheckLineOrder(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine,
nsIFrame** aLeftmost,
nsIFrame** aRightmost);
/**
* Get the frame to the right of the given frame, on the same line.
@ -265,9 +269,9 @@ public:
* @param aFirstFrameOnLine : first frame of the line to be tested
* @param aNumFramesOnLine : number of frames on this line
*/
nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
static nsIFrame* GetFrameToRightOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Get the frame to the left of the given frame, on the same line.
@ -276,9 +280,9 @@ public:
* @param aFirstFrameOnLine : first frame of the line to be tested
* @param aNumFramesOnLine : number of frames on this line
*/
nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
static nsIFrame* GetFrameToLeftOf(const nsIFrame* aFrame,
nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Get the bidi embedding level of the given (inline) frame.
@ -312,15 +316,16 @@ public:
* @param aPosResolveCount number of items in the aPosResolve array
* @param[out] aWidth Pointer to where the width will be stored (may be null)
*/
nsresult ProcessText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
BidiProcessor& aprocessor,
Mode aMode,
nsBidiPositionResolve* aPosResolve,
PRInt32 aPosResolveCount,
nscoord* aWidth);
static nsresult ProcessText(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
BidiProcessor& aprocessor,
Mode aMode,
nsBidiPositionResolve* aPosResolve,
PRInt32 aPosResolveCount,
nscoord* aWidth,
nsBidi* aBidiEngine);
/**
* Make a copy of a string, converting from logical to visual order
@ -335,36 +340,25 @@ public:
* @param aOverride if TRUE, the text has a bidi override, according to
* the direction in aDir
*/
void CopyLogicalToVisual(const nsAString& aSource,
nsAString& aDest,
nsBidiLevel aBaseDirection,
PRBool aOverride);
/**
* Guess at how much memory is being used by this nsBidiPresUtils instance,
* including memory used by nsBidi.
*/
PRUint32 EstimateMemoryUsed();
void Traverse(nsCycleCollectionTraversalCallback &cb) const;
void Unlink();
static void CopyLogicalToVisual(const nsAString& aSource,
nsAString& aDest,
nsBidiLevel aBaseDirection,
PRBool aOverride);
private:
nsresult ProcessTextForRenderingContext(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
Mode aMode,
nscoord aX, // DRAW only
nscoord aY, // DRAW only
nsBidiPositionResolve* aPosResolve, /* may be null */
PRInt32 aPosResolveCount,
nscoord* aWidth /* may be null */);
void AdvanceAndAppendFrame(nsIFrame** aFrame,
nsBlockInFlowLineIterator* aLineIter,
nsIFrame** aNextSibling);
static nsresult
ProcessTextForRenderingContext(const PRUnichar* aText,
PRInt32 aLength,
nsBidiDirection aBaseDirection,
nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsRenderingContext& aTextRunConstructionContext,
Mode aMode,
nscoord aX, // DRAW only
nscoord aY, // DRAW only
nsBidiPositionResolve* aPosResolve, /* may be null */
PRInt32 aPosResolveCount,
nscoord* aWidth /* may be null */);
/**
* Traverse the child frames of the block element and:
@ -374,26 +368,10 @@ private:
* than one paragraph for bidi resolution, resolve the paragraph up to that
* point.
*/
void TraverseFrames(nsBlockFrame* aBlockFrame,
nsBlockInFlowLineIterator* aLineIter,
nsIFrame* aCurrentFrame);
/**
* Initialize the logically-ordered array of frames
* using the top-level frames of a single line
*/
void InitLogicalArrayFromLine(nsIFrame* aFirstFrameOnLine,
PRInt32 aNumFramesOnLine);
/**
* Reorder the frame array from logical to visual order
*
* @param aReordered TRUE on return if the visual order is different from
* the logical order
* @param aHasRTLFrames TRUE on return if at least one of the frames is RTL
* (and therefore might have reordered descendents)
*/
nsresult Reorder(PRBool& aReordered, PRBool& aHasRTLFrames);
static void TraverseFrames(nsBlockFrame* aBlockFrame,
nsBlockInFlowLineIterator* aLineIter,
nsIFrame* aCurrentFrame,
BidiParagraphData* aBpd);
/*
* Position aFrame and it's descendants to their visual places. Also if aFrame
@ -408,10 +386,10 @@ private:
* adding its right margin)
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
*/
void RepositionFrame(nsIFrame* aFrame,
PRBool aIsOddLevel,
nscoord& aLeft,
nsContinuationStates* aContinuationStates) const;
static void RepositionFrame(nsIFrame* aFrame,
PRBool aIsOddLevel,
nscoord& aLeft,
nsContinuationStates* aContinuationStates);
/*
* Initialize the continuation state(nsFrameContinuationState) to
@ -421,8 +399,8 @@ private:
* be initialized
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
*/
void InitContinuationStates(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates) const;
static void InitContinuationStates(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates);
/*
* Determine if aFrame is leftmost or rightmost, and set aIsLeftMost and
@ -439,10 +417,10 @@ private:
* @param[out] aIsLeftMost TRUE means aFrame is leftmost frame or continuation
* @param[out] aIsRightMost TRUE means aFrame is rightmost frame or continuation
*/
void IsLeftOrRightMost(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
PRBool& aIsLeftMost /* out */,
PRBool& aIsRightMost /* out */) const;
static void IsLeftOrRightMost(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
PRBool& aIsLeftMost /* out */,
PRBool& aIsRightMost /* out */);
/**
* Adjust frame positions following their visual order
@ -451,7 +429,8 @@ private:
*
* @lina 04/11/2000
*/
void RepositionInlineFrames(nsIFrame* aFirstChild) const;
static void RepositionInlineFrames(BidiLineData* aBld,
nsIFrame* aFirstChild);
/**
* Helper method for Resolve()
@ -468,12 +447,12 @@ private:
* @see Resolve()
* @see RemoveBidiContinuation()
*/
inline
void EnsureBidiContinuation(nsIFrame* aFrame,
nsIFrame** aNewFrame,
PRInt32& aFrameIndex,
PRInt32 aStart,
PRInt32 aEnd);
static inline
nsresult EnsureBidiContinuation(nsIFrame* aFrame,
nsIFrame** aNewFrame,
PRInt32& aFrameIndex,
PRInt32 aStart,
PRInt32 aEnd);
/**
* Helper method for Resolve()
@ -491,20 +470,23 @@ private:
* @see Resolve()
* @see EnsureBidiContinuation()
*/
void RemoveBidiContinuation(nsIFrame* aFrame,
PRInt32 aFirstIndex,
PRInt32 aLastIndex,
PRInt32& aOffset) const;
void CalculateCharType(PRInt32& aOffset,
PRInt32 aCharTypeLimit,
PRInt32& aRunLimit,
PRInt32& aRunLength,
PRInt32& aRunCount,
PRUint8& aCharType,
PRUint8& aPrevCharType) const;
static void RemoveBidiContinuation(BidiParagraphData* aBpd,
nsIFrame* aFrame,
PRInt32 aFirstIndex,
PRInt32 aLastIndex,
PRInt32& aOffset);
static void CalculateCharType(nsBidi* aBidiEngine,
const PRUnichar* aText,
PRInt32& aOffset,
PRInt32 aCharTypeLimit,
PRInt32& aRunLimit,
PRInt32& aRunLength,
PRInt32& aRunCount,
PRUint8& aCharType,
PRUint8& aPrevCharType);
void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength) const;
static void StripBidiControlCharacters(PRUnichar* aText,
PRInt32& aTextLength);
static PRBool WriteLogicalToVisual(const PRUnichar* aSrc,
PRUint32 aSrcLength,
@ -512,26 +494,9 @@ private:
nsBidiLevel aBaseDirection,
nsBidi* aBidiEngine);
static void WriteReverse(const PRUnichar* aSrc,
PRUint32 aSrcLength,
PRUnichar* aDest);
nsString mBuffer;
nsTArray<PRUnichar> mEmbeddingStack;
nsTArray<nsIFrame*> mLogicalFrames;
nsTArray<nsLineBox*> mLinePerFrame;
nsTArray<nsIFrame*> mVisualFrames;
nsDataHashtable<nsISupportsHashKey, PRInt32> mContentToFrameIndex;
PRInt32 mArraySize;
PRInt32* mIndexMap;
PRUint8* mLevels;
nsresult mSuccess;
PRPackedBool mIsVisual;
nsBidiLevel mParaLevel;
nsIFrame* mPrevFrame;
nsIContent* mPrevContent;
nsBidi* mBidiEngine;
static void WriteReverse(const PRUnichar* aSrc,
PRUint32 aSrcLength,
PRUnichar* aDest);
};
#endif /* nsBidiPresUtils_h___ */

View File

@ -2854,19 +2854,15 @@ nsLayoutUtils::DrawString(const nsIFrame* aFrame,
nsresult rv = NS_ERROR_FAILURE;
nsPresContext* presContext = aFrame->PresContext();
if (presContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
if (aDirection == NS_STYLE_DIRECTION_INHERIT) {
aDirection = aFrame->GetStyleVisibility()->mDirection;
}
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == aDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
rv = bidiUtils->RenderText(aString, aLength, direction,
presContext, *aContext, *aContext,
aPoint.x, aPoint.y);
if (aDirection == NS_STYLE_DIRECTION_INHERIT) {
aDirection = aFrame->GetStyleVisibility()->mDirection;
}
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == aDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
rv = nsBidiPresUtils::RenderText(aString, aLength, direction,
presContext, *aContext, *aContext,
aPoint.x, aPoint.y);
}
if (NS_FAILED(rv))
#endif // IBMBIDI
@ -2885,16 +2881,12 @@ nsLayoutUtils::GetStringWidth(const nsIFrame* aFrame,
#ifdef IBMBIDI
nsPresContext* presContext = aFrame->PresContext();
if (presContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == vis->mDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
return bidiUtils->MeasureTextWidth(aString, aLength,
direction, presContext, *aContext);
}
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
nsBidiDirection direction =
(NS_STYLE_DIRECTION_RTL == vis->mDirection) ?
NSBIDI_RTL : NSBIDI_LTR;
return nsBidiPresUtils::MeasureTextWidth(aString, aLength,
direction, presContext, *aContext);
}
#endif // IBMBIDI
aContext->SetTextRunRTL(PR_FALSE);

View File

@ -369,8 +369,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsPresContext)
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLangService); // a service
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrintSettings);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPrefChangedTimer);
if (tmp->mBidiUtils)
tmp->mBidiUtils->Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
@ -395,8 +393,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
tmp->mPrefChangedTimer->Cancel();
tmp->mPrefChangedTimer = nsnull;
}
if (tmp->mBidiUtils)
tmp->mBidiUtils->Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -1461,15 +1457,6 @@ nsPresContext::SetBidiEnabled() const
}
}
nsBidiPresUtils*
nsPresContext::GetBidiUtils()
{
if (!mBidiUtils)
mBidiUtils = new nsBidiPresUtils;
return mBidiUtils;
}
void
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceRestyle)
{
@ -1512,15 +1499,6 @@ nsPresContext::GetBidi() const
return Document()->GetBidiOptions();
}
PRUint32
nsPresContext::GetBidiMemoryUsed()
{
if (!mBidiUtils)
return 0;
return mBidiUtils->EstimateMemoryUsed();
}
#endif //IBMBIDI
PRBool

View File

@ -757,11 +757,6 @@ public:
//Mohamed
/**
* Get a Bidi presentation utilities object
*/
NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
/**
* Set the Bidi options for the presentation context
*/
@ -774,10 +769,6 @@ public:
* include nsIDocument.
*/
NS_HIDDEN_(PRUint32) GetBidi() const;
PRUint32 GetBidiMemoryUsed();
#else
PRUint32 GetBidiMemoryUsed() { return 0; }
#endif // IBMBIDI
/**
@ -1010,7 +1001,6 @@ public:
PRUint32 result = 0;
result += sizeof(nsPresContext);
result += GetBidiMemoryUsed();
return result;
}
@ -1100,10 +1090,6 @@ protected:
PRInt32 mCurAppUnitsPerDevPixel;
PRInt32 mAutoQualityMinFontSizePixelsPref;
#ifdef IBMBIDI
nsAutoPtr<nsBidiPresUtils> mBidiUtils;
#endif
nsCOMPtr<nsITheme> mTheme;
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;

View File

@ -1434,15 +1434,6 @@ public:
return PL_DHASH_NEXT;
}
static PLDHashOperator LiveShellBidiSizeEnumerator(PresShellPtrKey *aEntry,
void *userArg)
{
PresShell *aShell = static_cast<PresShell*>(aEntry->GetKey());
PRUint32 *val = (PRUint32*)userArg;
*val += aShell->mPresContext->GetBidiMemoryUsed();
return PL_DHASH_NEXT;
}
static PRUint32
EstimateShellsMemory(nsTHashtable<PresShellPtrKey>::Enumerator aEnumerator)
{
@ -1456,10 +1447,6 @@ public:
return EstimateShellsMemory(LiveShellSizeEnumerator);
}
static PRInt64 SizeOfBidiMemoryReporter() {
return EstimateShellsMemory(LiveShellBidiSizeEnumerator);
}
protected:
void QueryIsActive();
nsresult UpdateImageLockingState();
@ -1675,13 +1662,6 @@ NS_MEMORY_REPORTER_IMPLEMENT(LayoutPresShell,
PresShell::SizeOfLayoutMemoryReporter,
"Memory used by layout PresShell, PresContext, and other related areas.")
NS_MEMORY_REPORTER_IMPLEMENT(LayoutBidi,
"explicit/layout/bidi",
KIND_HEAP,
UNITS_BYTES,
PresShell::SizeOfBidiMemoryReporter,
"Memory used by layout Bidi processor.")
PresShell::PresShell()
: mMouseLocation(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)
{
@ -1710,7 +1690,6 @@ PresShell::PresShell()
static bool registeredReporter = false;
if (!registeredReporter) {
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutPresShell));
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutBidi));
Preferences::AddBoolVarCache(&sSynthMouseMove,
"layout.reflow.synthMouseMove", PR_TRUE);
registeredReporter = true;

View File

@ -4257,11 +4257,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
if (aState.mPresContext->BidiEnabled()) {
if (!aState.mPresContext->IsVisualMode() ||
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
nsBidiPresUtils* bidiUtils = aState.mPresContext->GetBidiUtils();
if (bidiUtils && bidiUtils->IsSuccessful() ) {
bidiUtils->ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
} // bidiUtils
nsBidiPresUtils::ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
} // not visual mode
} // bidi enabled
#endif // IBMBIDI
@ -7220,11 +7216,7 @@ nsBlockFrame::ResolveBidi()
return NS_OK;
}
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (!bidiUtils)
return NS_ERROR_NULL_POINTER;
return bidiUtils->Resolve(this);
return nsBidiPresUtils::Resolve(this);
}
#endif

View File

@ -448,7 +448,6 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
return aFrame ? aFrame->GetPrevSibling() : LastChild();
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
nsBidiPresUtils* bidiUtils = mFirstChild->PresContext()->GetBidiUtils();
nsAutoLineIterator iter = parent->GetLineIterator();
if (!iter) {
@ -456,9 +455,9 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
if (parent->GetType() == nsGkAtoms::lineFrame) {
// Line frames are not bidi-splittable, so need to consider bidi reordering
if (baseLevel == NSBIDI_LTR) {
return bidiUtils->GetFrameToLeftOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToLeftOf(aFrame, mFirstChild, -1);
} else { // RTL
return bidiUtils->GetFrameToRightOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToRightOf(aFrame, mFirstChild, -1);
}
} else {
// Just get the next or prev sibling, depending on block and frame direction.
@ -493,9 +492,9 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
}
}
@ -504,9 +503,9 @@ nsFrameList::GetPrevVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine - 1, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
}
}
return frame;
@ -523,7 +522,6 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
return aFrame ? aFrame->GetPrevSibling() : mFirstChild;
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(mFirstChild);
nsBidiPresUtils* bidiUtils = mFirstChild->PresContext()->GetBidiUtils();
nsAutoLineIterator iter = parent->GetLineIterator();
if (!iter) {
@ -531,9 +529,9 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
if (parent->GetType() == nsGkAtoms::lineFrame) {
// Line frames are not bidi-splittable, so need to consider bidi reordering
if (baseLevel == NSBIDI_LTR) {
return bidiUtils->GetFrameToRightOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToRightOf(aFrame, mFirstChild, -1);
} else { // RTL
return bidiUtils->GetFrameToLeftOf(aFrame, mFirstChild, -1);
return nsBidiPresUtils::GetFrameToLeftOf(aFrame, mFirstChild, -1);
}
} else {
// Just get the next or prev sibling, depending on block and frame direction.
@ -568,9 +566,9 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(aFrame, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(aFrame, firstFrameOnLine, numFramesOnLine);
}
}
@ -580,9 +578,9 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
iter->GetLine(thisLine + 1, &firstFrameOnLine, &numFramesOnLine, lineBounds, &lineFlags);
if (baseLevel == NSBIDI_LTR) {
frame = bidiUtils->GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToRightOf(nsnull, firstFrameOnLine, numFramesOnLine);
} else { // RTL
frame = bidiUtils->GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
frame = nsBidiPresUtils::GetFrameToLeftOf(nsnull, firstFrameOnLine, numFramesOnLine);
}
}
return frame;

View File

@ -1003,21 +1003,17 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
nsresult rv = NS_ERROR_FAILURE;
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
const nsStyleVisibility* vis = GetStyleVisibility();
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
rv = bidiUtils->RenderText(str, maxFit, NSBIDI_RTL,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.XMost() - strWidth, y + maxAscent);
else
rv = bidiUtils->RenderText(str, maxFit, NSBIDI_LTR,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.x, y + maxAscent);
}
const nsStyleVisibility* vis = GetStyleVisibility();
if (vis->mDirection == NS_STYLE_DIRECTION_RTL)
rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_RTL,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.XMost() - strWidth, y + maxAscent);
else
rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_LTR,
aPresContext, aRenderingContext,
aRenderingContext,
aRect.x, y + maxAscent);
}
if (NS_FAILED(rv))
aRenderingContext.DrawString(str, maxFit, aRect.x, y + maxAscent);

View File

@ -656,11 +656,9 @@ nsLineIterator::CheckLineOrder(PRInt32 aLine,
return NS_OK;
}
nsBidiPresUtils* bidiUtils = line->mFirstChild->PresContext()->GetBidiUtils();
nsIFrame* leftmostFrame;
nsIFrame* rightmostFrame;
*aIsReordered = bidiUtils->CheckLineOrder(line->mFirstChild, line->GetChildCount(), &leftmostFrame, &rightmostFrame);
*aIsReordered = nsBidiPresUtils::CheckLineOrder(line->mFirstChild, line->GetChildCount(), &leftmostFrame, &rightmostFrame);
// map leftmost/rightmost to first/last according to paragraph direction
*aFirstVisual = mRightToLeft ? rightmostFrame : leftmostFrame;

View File

@ -106,7 +106,6 @@
#endif
#include "nsAutoPtr.h"
#include "nsBidiPresUtils.h"
#include "nsBidiUtils.h"
#include "gfxFont.h"

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 668758 - @font-face disrupts font preferences</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
margin: 50px;
font-family: serif;
}
</style>
</head>
<body>
<p>
This should be rendered using the default serif font.
</p>
<pre>
And this is preformatted text that ought to be monospaced.
</pre>
</body>
</html>

View File

@ -0,0 +1,65 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 668758 - @font-face disrupts font preferences</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/* none of these @font-face declarations should affect the rendering! */
@font-face {
font-family: Times;
src: url(../fonts/mplus/mplus-1p-black.ttf);
}
@font-face {
font-family: Times New Roman;
src: url(../fonts/mplus/mplus-1p-black.ttf);
}
@font-face {
font-family: Tms Rmn;
src: url(../fonts/mplus/mplus-1p-black.ttf);
}
@font-face {
font-family: Droid Serif;
src: url(../fonts/mplus/mplus-1p-black.ttf);
}
@font-face {
font-family: Courier;
src: url(../fonts/mplus/mplus-1p-black.ttf);
}
@font-face {
font-family: Courier New;
src: url(../fonts/mplus/mplus-1p-black.ttf);
}
@font-face {
font-family: Droid Sans Mono;
src: url(../fonts/mplus/mplus-1p-black.ttf);
}
body {
margin: 50px;
font-family: serif;
}
</style>
</head>
<body>
<p>
This should be rendered using the default serif font.
</p>
<pre>
And this is preformatted text that ought to be monospaced.
</pre>
</body>
</html>

View File

@ -99,6 +99,8 @@ HTTP(..) == load-badchecksum.html load-badchecksum-ref.html
HTTP(..) == name-collision.html name-collision-ref.html
HTTP(..) == name-collision-bad-url.html name-collision-bad-url-ref.html
HTTP(..) == name-collision-with-prefs-font.html name-collision-with-prefs-font-ref.html # bug 668758
# t2embed lib on windows is picky about fullname
HTTP(..) == load-badfullname.html load-badfullname-ref.html

View File

@ -214,9 +214,28 @@ nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
return aStatus;
}
if (NS_SUCCEEDED(aStatus)) {
// for HTTP requests, check whether the request _actually_ succeeded;
// the "request status" in aStatus does not necessarily indicate this,
// because HTTP responses such as 404 (Not Found) will still result in
// a success code and potentially an HTML error page from the server
// as the resulting data. We don't want to use that as a font.
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
if (httpChannel) {
PRBool succeeded;
nsresult rv = httpChannel->GetRequestSucceeded(&succeeded);
if (NS_SUCCEEDED(rv) && !succeeded) {
aStatus = NS_ERROR_NOT_AVAILABLE;
}
}
}
// The userFontSet is responsible for freeing the downloaded data
// (aString) when finished with it; the pointer is no longer valid
// after OnLoadComplete returns.
// This is called even in the case of a failed download (HTTP 404, etc),
// as there may still be data to be freed (e.g. an error page),
// and we need the fontSet to initiate loading the next source.
PRBool fontUpdate = userFontSet->OnLoadComplete(mFontEntry,
aString, aStringLen,
aStatus);

View File

@ -1521,48 +1521,45 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
if (!GetCharacterData(text))
return PR_FALSE;
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
nsAutoString visualText;
/*
* XXXsmontagu: The SVG spec says:
*
* http://www.w3.org/TR/SVG11/text.html#DirectionProperty
* "For the 'direction' property to have any effect, the 'unicode-bidi'
* property's value must be embed or bidi-override."
*
* The SVGTiny spec, on the other hand, says
*
* http://www.w3.org/TR/SVGTiny12/text.html#DirectionProperty
* "For the 'direction' property to have any effect on an element that
* does not by itself establish a new text chunk (such as the 'tspan'
* element in SVG 1.2 Tiny), the 'unicode-bidi' property's value must
* be embed or bidi-override."
*
* Note that this is different from HTML/CSS, where setting the 'dir'
* attribute on an inline element automatically sets unicode-bidi: embed
*
* Our current implementation of bidi in SVG does not distinguish between
* different text elements, but treats every text container frame as a
* new text chunk, so we always set the base direction according to the
* direction property
*
* See also XXXsmontagu comments in nsSVGTextFrame::UpdateGlyphPositioning
*/
// Get the unicodeBidi property from the parent, because it doesn't
// inherit
PRBool bidiOverride = (mParent->GetStyleTextReset()->mUnicodeBidi ==
NS_STYLE_UNICODE_BIDI_OVERRIDE);
nsBidiLevel baseDirection =
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ?
NSBIDI_RTL : NSBIDI_LTR;
bidiUtils->CopyLogicalToVisual(text, visualText,
baseDirection, bidiOverride);
if (!visualText.IsEmpty()) {
text = visualText;
}
nsAutoString visualText;
/*
* XXXsmontagu: The SVG spec says:
*
* http://www.w3.org/TR/SVG11/text.html#DirectionProperty
* "For the 'direction' property to have any effect, the 'unicode-bidi'
* property's value must be embed or bidi-override."
*
* The SVGTiny spec, on the other hand, says
*
* http://www.w3.org/TR/SVGTiny12/text.html#DirectionProperty
* "For the 'direction' property to have any effect on an element that
* does not by itself establish a new text chunk (such as the 'tspan'
* element in SVG 1.2 Tiny), the 'unicode-bidi' property's value must
* be embed or bidi-override."
*
* Note that this is different from HTML/CSS, where setting the 'dir'
* attribute on an inline element automatically sets unicode-bidi: embed
*
* Our current implementation of bidi in SVG does not distinguish between
* different text elements, but treats every text container frame as a
* new text chunk, so we always set the base direction according to the
* direction property
*
* See also XXXsmontagu comments in nsSVGTextFrame::UpdateGlyphPositioning
*/
// Get the unicodeBidi property from the parent, because it doesn't
// inherit
PRBool bidiOverride = (mParent->GetStyleTextReset()->mUnicodeBidi ==
NS_STYLE_UNICODE_BIDI_OVERRIDE);
nsBidiLevel baseDirection =
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL ?
NSBIDI_RTL : NSBIDI_LTR;
nsBidiPresUtils::CopyLogicalToVisual(text, visualText,
baseDirection, bidiOverride);
if (!visualText.IsEmpty()) {
text = visualText;
}
gfxMatrix m;

View File

@ -555,32 +555,28 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
if (mState & NS_FRAME_IS_BIDI) {
presContext->SetBidiEnabled();
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
const nsStyleVisibility* vis = GetStyleVisibility();
nsBidiDirection direction = (NS_STYLE_DIRECTION_RTL == vis->mDirection) ? NSBIDI_RTL : NSBIDI_LTR;
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
// We let the RenderText function calculate the mnemonic's
// underline position for us.
nsBidiPositionResolve posResolve;
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline,
&posResolve,
1);
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
mAccessKeyInfo->mAccessWidth = posResolve.visualWidth;
}
else
{
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline);
}
const nsStyleVisibility* vis = GetStyleVisibility();
nsBidiDirection direction = (NS_STYLE_DIRECTION_RTL == vis->mDirection) ? NSBIDI_RTL : NSBIDI_LTR;
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
// We let the RenderText function calculate the mnemonic's
// underline position for us.
nsBidiPositionResolve posResolve;
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline,
&posResolve,
1);
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
mAccessKeyInfo->mAccessWidth = posResolve.visualWidth;
}
else
{
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
*refContext,
aTextRect.x, baseline);
}
}
if (NS_FAILED(rv) )

View File

@ -105,7 +105,7 @@
#include "nsRenderingContext.h"
#ifdef IBMBIDI
#include "nsBidiPresUtils.h"
#include "nsBidiUtils.h"
#endif
// Enumeration function that cancels all the image requests in our cache

View File

@ -296,15 +296,14 @@ private slots:
void VisibleScreenAreaChanged(const QRect& rect) {
if (mTopLevelWidget) {
QRect r = mTopLevelWidget->geometry().toRect();
if (rect.height()) {
r.setHeight(rect.height());
}
QRegion region(scene()->views()[0]->rect());
region -= rect;
QRectF bounds = mapRectFromScene(region.boundingRect());
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
if (observerService) {
QString rect = QString("{\"left\": %1, \"top\": %2, \"right\": %3, \"bottom\": %4}")
.arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height());
.arg(bounds.x()).arg(bounds.y()).arg(bounds.width()).arg(bounds.height());
observerService->NotifyObservers(nsnull, "softkb-change", rect.utf16());
}
}