diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 838100bfbbe..64179881b85 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -1504,7 +1504,6 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA { nsIFrame *theFrame; PRInt32 currentOffset, frameStart, frameEnd; - PRUint8 level; // XXX - I expected to be able to use pos.mResultFrame, but when we move from frame to frame // and |PeekOffset| is called recursively, pos.mResultFrame on exit is sometimes set to the original @@ -1533,9 +1532,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA pos.mContentOffset = frameEnd; // set the cursor Bidi level to the paragraph embedding level - theFrame->GetBidiProperty(context, nsLayoutAtoms::baseLevel, (void**)&level, - sizeof(level) ); - shell->SetCaretBidiLevel(level); + shell->SetCaretBidiLevel(NS_GET_BASE_LEVEL(theFrame)); break; default: @@ -1544,9 +1541,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA || (eSelectDir == aAmount) || (eSelectLine == aAmount)) { - theFrame->GetBidiProperty(context, nsLayoutAtoms::embeddingLevel, (void**)&level, - sizeof(level) ); - shell->SetCaretBidiLevel(level); + shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame)); } else BidiLevelFromMove(context, shell, pos.mResultContent, pos.mContentOffset, aKeycode); @@ -1734,13 +1729,11 @@ nsSelection::VisualSequence(nsIPresContext *aPresContext, PRBool* aNeedVisualSelection) { nsVoidArray frameArray; - PRUint8 bidiLevel, currentLevel; PRInt32 frameStart, frameEnd; PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); nsresult result = nsnull; - aCurrentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)¤tLevel, sizeof(currentLevel) ); - + PRUint8 currentLevel = NS_GET_EMBEDDING_LEVEL(aCurrentFrame); result = aSelectFrame->PeekOffset(aPresContext, aPos); while (aCurrentFrame != (aSelectFrame = aPos->mResultFrame)) { @@ -1755,7 +1748,7 @@ nsSelection::VisualSequence(nsIPresContext *aPresContext, frameArray.AppendElement(aSelectFrame); aSelectFrame->GetOffsets(frameStart, frameEnd); - aSelectFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&bidiLevel, sizeof(bidiLevel) ); + PRUint8 bidiLevel = NS_GET_EMBEDDING_LEVEL(aSelectFrame); if (currentLevel != bidiLevel) *aNeedVisualSelection = PR_TRUE; @@ -1909,16 +1902,13 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, nsCOMPtr anchorNode; PRInt32 anchorOffset; nsIFrame* anchorFrame; - PRUint8 anchorLevel; nsCOMPtr focusContent; nsCOMPtr focusNode; PRInt32 focusOffset; nsIFrame* focusFrame; - PRUint8 focusLevel; nsCOMPtr currentContent; nsCOMPtr currentNode; PRInt32 currentOffset; - PRUint8 currentLevel; nsresult result; nsIFrame* startFrame; PRBool needVisualSelection = PR_FALSE; @@ -1932,12 +1922,12 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, result = GetFrameForNodeOffset(anchorContent, anchorOffset, mHint, &anchorFrame, &anchorOffset); if (NS_FAILED(result)) return result; - anchorFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&anchorLevel, sizeof(anchorLevel) ); - + PRUint8 anchorLevel = NS_GET_EMBEDDING_LEVEL(anchorFrame); + currentContent = aPos.mResultContent; currentNode = do_QueryInterface(currentContent); currentOffset = aPos.mContentOffset; - aCurrentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)¤tLevel, sizeof(currentLevel) ); + PRUint8 currentLevel = NS_GET_EMBEDDING_LEVEL(aCurrentFrame); // Moving from simplest case to more complicated: // case 1: selection starts and ends in the same frame: no special treatment @@ -1958,8 +1948,7 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, result = GetFrameForNodeOffset(focusContent, focusOffset, hint, &focusFrame, &focusOffset); if (NS_FAILED(result)) return result; - - focusFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&focusLevel, sizeof(focusLevel) ); + PRUint8 focusLevel = NS_GET_EMBEDDING_LEVEL(focusFrame); if (currentLevel != anchorLevel) needVisualSelection = PR_TRUE; @@ -2043,9 +2032,7 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, // // If selection direction is backwards, vice versa throughout // - PRUint8 anchorBaseLevel; - PRUint8 currentBaseLevel; - anchorFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)&anchorBaseLevel, sizeof(anchorBaseLevel) ); + PRUint8 anchorBaseLevel = NS_GET_BASE_LEVEL(anchorFrame); if ((eDirNext == selectionDirection) != ((anchorLevel & 1) == (anchorBaseLevel & 1))) result = SelectToEdge(anchorFrame, anchorContent, anchorOffset, 0, PR_FALSE); else @@ -2073,8 +2060,7 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, return result; // Go to the current point - - aCurrentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)¤tBaseLevel, sizeof(currentBaseLevel) ); + PRUint8 currentBaseLevel = NS_GET_BASE_LEVEL(aCurrentFrame); // Walk the frames in visual order until we reach the beginning of the line aPos.mJumpLines = PR_FALSE; if ((currentBaseLevel & 1) == (anchorBaseLevel & 1)) @@ -2142,9 +2128,7 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, else { // we are neither at the beginning nor at the end of the frame, so we have no worries *aPrevFrame = *aNextFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); - *aPrevLevel = *aNextLevel; + *aPrevLevel = *aNextLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); return NS_OK; } @@ -2221,10 +2205,8 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, // set aNextFrame to null // set aNextLevel to the paragraph embedding level *aPrevFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); + *aPrevLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); + *aNextLevel = NS_GET_BASE_LEVEL(currentFrame); *aNextFrame = nsnull; return NS_OK; } @@ -2234,10 +2216,8 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, // set aNextFrame to the current frame // set aNextLevel to the embedding level of the current frame *aNextFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); + *aNextLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); + *aPrevLevel = NS_GET_BASE_LEVEL(currentFrame); *aPrevFrame = nsnull; return NS_OK; } @@ -2271,19 +2251,15 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, if (direction == eDirNext) { *aPrevFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); + *aPrevLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); *aNextFrame = newFrame; - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); + *aNextLevel = NS_GET_EMBEDDING_LEVEL(newFrame); } else { *aNextFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); + *aNextLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); *aPrevFrame = newFrame; - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); + *aPrevLevel = NS_GET_EMBEDDING_LEVEL(newFrame); } return NS_OK; @@ -2327,8 +2303,7 @@ NS_IMETHODIMP nsSelection::GetFrameFromLevel(nsIPresContext *aPresContext, //we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules //for speed reasons foundFrame = (nsIFrame *)isupports; - foundFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)&foundLevel, sizeof(foundLevel) ); + foundLevel = NS_GET_EMBEDDING_LEVEL(foundFrame); } while (foundLevel > aBidiLevel); @@ -2440,16 +2415,13 @@ void nsSelection::BidiLevelFromClick(nsIContent *aNode, PRUint32 aContentOffset) return; nsIFrame* clickInFrame=nsnull; - PRUint8 frameLevel; PRInt32 OffsetNotUsed; result = GetFrameForNodeOffset(aNode, aContentOffset, mHint, &clickInFrame, &OffsetNotUsed); if (NS_FAILED(result)) return; - clickInFrame->GetBidiProperty(context, nsLayoutAtoms::embeddingLevel, - (void**)&frameLevel, sizeof(frameLevel) ); - shell->SetCaretBidiLevel(frameLevel); + shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(clickInFrame)); } @@ -2593,9 +2565,7 @@ nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint& PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_FALSE); mHint = HINT(beginOfContent); HINT saveHint = mHint; - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)&level,sizeof(level)); - if (level & 1) + if (NS_GET_EMBEDDING_LEVEL(newFrame) & 1) mHint = (mHint==HINTLEFT) ? HINTRIGHT : HINTLEFT; pos.mResultContent = newContent; pos.mContentOffset = contentOffsetEnd; @@ -7606,12 +7576,12 @@ nsTypedSelection::SelectionLanguageChange(PRBool aLangRTL) PRInt32 frameStart, frameEnd; focusFrame->GetOffsets(frameStart, frameEnd); nsCOMPtr context; - PRUint8 level, levelBefore, levelAfter; + PRUint8 levelBefore, levelAfter; result = GetPresContext(getter_AddRefs(context)); if (NS_FAILED(result) || !context) return result?result:NS_ERROR_FAILURE; - focusFrame->GetBidiProperty(context, nsLayoutAtoms::embeddingLevel, (void**)&level, sizeof(level)); + PRUint8 level = NS_GET_EMBEDDING_LEVEL(focusFrame); if ((focusOffset != frameStart) && (focusOffset != frameEnd)) // the cursor is not at a frame boundary, so the level of both the characters (logically) before and after the cursor // is equal to the frame level diff --git a/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp b/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp index 3fc7148f0b9..60589fcb61b 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp +++ b/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp @@ -92,13 +92,11 @@ nsTextEditRules::CheckBidiLevelForDeletion(nsIDOMNode *aSelNode, return NS_ERROR_NULL_POINTER; PRUint8 levelAfter; - PRUint8 levelBefore; nsCOMPtr embeddingLevel = do_GetAtom("EmbeddingLevel"); // Get the bidi level of the frame before the caret - res = frameBefore->GetBidiProperty(context, embeddingLevel, (void**)&levelBefore,sizeof(PRUint8)); - if (NS_FAILED(res)) - return res; + PRUint8 levelBefore = + NS_PTR_TO_INT32(frameBefore->GetPropertyExternal(embeddingLevel, nsnull)); // If the caret is at the end of the frame, get the bidi level of the // frame after the caret @@ -118,15 +116,13 @@ nsTextEditRules::CheckBidiLevelForDeletion(nsIDOMNode *aSelNode, // there was no frameAfter, i.e. the caret is at the end of the // document -- use the base paragraph level nsCOMPtr baseLevel = do_GetAtom("BaseLevel"); - res = frameBefore->GetBidiProperty(context, baseLevel, (void**)&levelAfter,sizeof(PRUint8)); - if (NS_FAILED(res)) - return res; + levelAfter = + NS_PTR_TO_INT32(frameBefore->GetPropertyExternal(baseLevel, nsnull)); } else { - res = frameAfter->GetBidiProperty(context, embeddingLevel, (void**)&levelAfter,sizeof(PRUint8)); - if (NS_FAILED(res)) - return res; + levelAfter = + NS_PTR_TO_INT32(frameAfter->GetPropertyExternal(embeddingLevel, nsnull)); } } else diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index 052ff5bff8d..8e75d6c12cd 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -37,8 +37,6 @@ #ifdef IBMBIDI -#define FIX_FOR_BUG_40882 - #include "nsBidiPresUtils.h" #include "nsITextContent.h" #include "nsTextFragment.h" @@ -58,10 +56,7 @@ static const PRUnichar kRLE = 0x202B; static const PRUnichar kLRO = 0x202D; static const PRUnichar kRLO = 0x202E; static const PRUnichar kPDF = 0x202C; - -#ifdef FIX_FOR_BUG_40882 static const PRUnichar ALEF = 0x05D0; -#endif #define CHAR_IS_HEBREW(c) ((0x0590 <= (c)) && ((c)<= 0x05FF)) // Note: The above code are moved from gfx/src/windows/nsRenderingContextWin.cpp @@ -313,17 +308,17 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, ++lineOffset; } else { - frame->SetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - NS_INT32_TO_PTR(embeddingLevel)); - frame->SetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - NS_INT32_TO_PTR(paraLevel)); + frame->SetProperty(nsLayoutAtoms::embeddingLevel, + NS_INT32_TO_PTR(embeddingLevel)); + frame->SetProperty(nsLayoutAtoms::baseLevel, + NS_INT32_TO_PTR(paraLevel)); if (isTextFrame) { PRInt32 typeLimit = PR_MIN(logicalLimit, lineOffset + fragmentLength); CalculateCharType(lineOffset, typeLimit, logicalLimit, runLength, runCount, charType, prevType); // IBMBIDI - Egypt - Start - frame->SetBidiProperty(aPresContext,nsLayoutAtoms::charType, - NS_INT32_TO_PTR(charType)); + frame->SetProperty(nsLayoutAtoms::charType, + NS_INT32_TO_PTR(charType)); // IBMBIDI - Egypt - End if ( (runLength > 0) && (runLength < fragmentLength) ) { @@ -541,8 +536,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext, for (i = 0; i < count; i++) { frame = (nsIFrame*) (mLogicalFrames[i]); - frame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)&mLevels[i], sizeof(mLevels[i]) ); + mLevels[i] = NS_GET_EMBEDDING_LEVEL(frame); } if (!mIndexMap) { mIndexMap = new PRInt32[mArraySize]; @@ -586,7 +580,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, nsIFrame* frame = (nsIFrame*) (mVisualFrames[0]); PRInt32 i; -#ifdef FIX_FOR_BUG_40882 PRInt32 ch; PRInt32 charType; nscoord width, dWidth, alefWidth, dx; @@ -598,7 +591,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, dWidth = alefWidth = dx = 0; aRendContext->GetHints(hints); isBidiSystem = (hints & NS_RENDERING_HINT_BIDI_REORDERING); -#endif // bug nsRect rect = frame->GetRect(); @@ -609,13 +601,11 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, for (i = 1; i < count; i++) { -#ifdef FIX_FOR_BUG_40882 ch = 0; - ( (nsIFrame*)mVisualFrames[i])->GetBidiProperty(aPresContext, - nsLayoutAtoms::charType, (void**)&charType,sizeof(charType)); + charType = NS_PTR_TO_INT32(((nsIFrame*)mVisualFrames[i])-> + GetProperty(nsLayoutAtoms::charType)); if (CHARTYPE_IS_RTL(charType) ) { - frame->GetBidiProperty(aPresContext, - nsLayoutAtoms::endsInDiacritic, (void**)&ch,sizeof(ch)); + ch = NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::endsInDiacritic)); if (ch) { if (!alefWidth) { aRendContext->GetWidth(buf, 1, alefWidth, nsnull); @@ -631,23 +621,17 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, } } } -#endif // bug frame = (nsIFrame*) (mVisualFrames[i]); -#ifdef FIX_FOR_BUG_40882 if (ch) { dx += (rect.width - dWidth); frame->SetPosition(nsPoint(rect.x + dWidth, frame->GetPosition().y)); } else -#endif // bug 40882 frame->SetPosition(nsPoint(rect.XMost(), frame->GetPosition().y)); rect = frame->GetRect(); } // for -#ifdef FIX_FOR_BUG_40882 if (dx > 0) { - PRInt32 alignRight; - frame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - (void**) &alignRight,sizeof(alignRight)); + PRInt32 alignRight = NS_GET_BASE_LEVEL(frame); if (0 == (alignRight & 1) ) { const nsStyleText* styleText = frame->GetStyleText(); @@ -663,7 +647,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, } } } -#endif // bug // Now adjust inline container frames. // Example: LTR paragraph @@ -763,8 +746,7 @@ nsBidiPresUtils::EnsureBidiContinuation(nsIPresContext* aPresContext, return PR_FALSE; } } - aFrame->SetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, - (void*) *aNewFrame); + aFrame->SetProperty(nsLayoutAtoms::nextBidi, (void*) *aNewFrame); return PR_TRUE; } diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index 7867e020a3a..7867d68997b 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -579,8 +579,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n } else { - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&newBidiLevel, sizeof(newBidiLevel) ); + newBidiLevel = NS_GET_EMBEDDING_LEVEL(theFrame); presShell->SetCaretBidiLevel(newBidiLevel); bidiLevel = newBidiLevel; } @@ -625,16 +624,13 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n // Exception: when the first frame on the line has a different Bidi level from the paragraph level, there is no // real frame for the caret to be in. We have to find the first frame whose level is the same as the // paragraph level, and put the caret at the end of the frame before that. - PRUint8 baseLevel; - frameAfter->GetBidiProperty(presContext, nsLayoutAtoms::baseLevel, - (void**)&baseLevel, sizeof(baseLevel) ); + PRUint8 baseLevel = NS_GET_BASE_LEVEL(frameAfter); if (baseLevel != levelAfter) { if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameAfter, eDirNext, baseLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelAfter, sizeof(levelAfter) ); + levelAfter = NS_GET_EMBEDDING_LEVEL(theFrame); if (baseLevel & 1) // RTL paragraph: caret to the right of the rightmost character theFrameOffset = (levelAfter & 1) ? start : end; else // LTR paragraph: caret to the left of the leftmost character @@ -666,16 +662,14 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n // Exception: when the last frame on the line has a different Bidi level from the paragraph level, there is no // real frame for the caret to be in. We have to find the last frame whose level is the same as the // paragraph level, and put the caret at the end of the frame after that. - PRUint8 baseLevel; - frameBefore->GetBidiProperty(presContext, nsLayoutAtoms::baseLevel, - (void**)&baseLevel, sizeof(baseLevel) ); + + PRUint8 baseLevel = NS_GET_BASE_LEVEL(frameBefore); if (baseLevel != levelBefore) { if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameBefore, eDirPrevious, baseLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelBefore, sizeof(levelBefore) ); + levelBefore = NS_GET_EMBEDDING_LEVEL(theFrame); if (baseLevel & 1) // RTL paragraph: caret to the left of the leftmost character theFrameOffset = (levelBefore & 1) ? end : start; else // RTL paragraph: caret to the right of the rightmost character @@ -692,8 +686,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameAfter, eDirNext, bidiLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelAfter, sizeof(levelAfter) ); + levelAfter = NS_GET_EMBEDDING_LEVEL(theFrame); if (bidiLevel & 1) // c8: caret to the right of the rightmost character theFrameOffset = (levelAfter & 1) ? start : end; else // c7: caret to the left of the leftmost character @@ -707,8 +700,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameBefore, eDirPrevious, bidiLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelBefore, sizeof(levelBefore) ); + levelBefore = NS_GET_EMBEDDING_LEVEL(theFrame); if (bidiLevel & 1) // c12: caret to the left of the leftmost character theFrameOffset = (levelBefore & 1) ? end : start; else // c11: caret to the right of the rightmost character diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index 0c8b0f2d89b..fbd38a72d6e 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -1187,28 +1187,19 @@ public: } - - virtual void* GetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - PRBool aRemoveProperty) const = 0; + void* GetProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const; + virtual void* GetPropertyExternal(nsIAtom* aPropertyName, + nsresult* aStatus) const; + void* RemoveProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const; + nsresult SetProperty(nsIAtom* aPropertyName, + void* aValue, + NSFramePropertyDtorFunc aDestructor = nsnull); - virtual nsresult SetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue, - NSFramePropertyDtorFunc aPropDtorFunc) = 0; -#ifdef IBMBIDI - /** - * retrieve and set Bidi property of this frame - * @lina 5/1/2000 - */ - NS_IMETHOD GetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void** aPropertyValue, - size_t aSize ) const = 0; - NS_IMETHOD SetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue) = 0; -#endif // IBMBIDI +#define NS_GET_BASE_LEVEL(frame) \ +NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::baseLevel)) + +#define NS_GET_EMBEDDING_LEVEL(frame) \ +NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::embeddingLevel)) /** Create or retrieve the previously stored overflow area, if the frame does * not overflow and no creation is required return nsnull. diff --git a/mozilla/layout/base/src/nsBidiPresUtils.cpp b/mozilla/layout/base/src/nsBidiPresUtils.cpp index 052ff5bff8d..8e75d6c12cd 100644 --- a/mozilla/layout/base/src/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/src/nsBidiPresUtils.cpp @@ -37,8 +37,6 @@ #ifdef IBMBIDI -#define FIX_FOR_BUG_40882 - #include "nsBidiPresUtils.h" #include "nsITextContent.h" #include "nsTextFragment.h" @@ -58,10 +56,7 @@ static const PRUnichar kRLE = 0x202B; static const PRUnichar kLRO = 0x202D; static const PRUnichar kRLO = 0x202E; static const PRUnichar kPDF = 0x202C; - -#ifdef FIX_FOR_BUG_40882 static const PRUnichar ALEF = 0x05D0; -#endif #define CHAR_IS_HEBREW(c) ((0x0590 <= (c)) && ((c)<= 0x05FF)) // Note: The above code are moved from gfx/src/windows/nsRenderingContextWin.cpp @@ -313,17 +308,17 @@ nsBidiPresUtils::Resolve(nsIPresContext* aPresContext, ++lineOffset; } else { - frame->SetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - NS_INT32_TO_PTR(embeddingLevel)); - frame->SetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - NS_INT32_TO_PTR(paraLevel)); + frame->SetProperty(nsLayoutAtoms::embeddingLevel, + NS_INT32_TO_PTR(embeddingLevel)); + frame->SetProperty(nsLayoutAtoms::baseLevel, + NS_INT32_TO_PTR(paraLevel)); if (isTextFrame) { PRInt32 typeLimit = PR_MIN(logicalLimit, lineOffset + fragmentLength); CalculateCharType(lineOffset, typeLimit, logicalLimit, runLength, runCount, charType, prevType); // IBMBIDI - Egypt - Start - frame->SetBidiProperty(aPresContext,nsLayoutAtoms::charType, - NS_INT32_TO_PTR(charType)); + frame->SetProperty(nsLayoutAtoms::charType, + NS_INT32_TO_PTR(charType)); // IBMBIDI - Egypt - End if ( (runLength > 0) && (runLength < fragmentLength) ) { @@ -541,8 +536,7 @@ nsBidiPresUtils::Reorder(nsIPresContext* aPresContext, for (i = 0; i < count; i++) { frame = (nsIFrame*) (mLogicalFrames[i]); - frame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)&mLevels[i], sizeof(mLevels[i]) ); + mLevels[i] = NS_GET_EMBEDDING_LEVEL(frame); } if (!mIndexMap) { mIndexMap = new PRInt32[mArraySize]; @@ -586,7 +580,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, nsIFrame* frame = (nsIFrame*) (mVisualFrames[0]); PRInt32 i; -#ifdef FIX_FOR_BUG_40882 PRInt32 ch; PRInt32 charType; nscoord width, dWidth, alefWidth, dx; @@ -598,7 +591,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, dWidth = alefWidth = dx = 0; aRendContext->GetHints(hints); isBidiSystem = (hints & NS_RENDERING_HINT_BIDI_REORDERING); -#endif // bug nsRect rect = frame->GetRect(); @@ -609,13 +601,11 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, for (i = 1; i < count; i++) { -#ifdef FIX_FOR_BUG_40882 ch = 0; - ( (nsIFrame*)mVisualFrames[i])->GetBidiProperty(aPresContext, - nsLayoutAtoms::charType, (void**)&charType,sizeof(charType)); + charType = NS_PTR_TO_INT32(((nsIFrame*)mVisualFrames[i])-> + GetProperty(nsLayoutAtoms::charType)); if (CHARTYPE_IS_RTL(charType) ) { - frame->GetBidiProperty(aPresContext, - nsLayoutAtoms::endsInDiacritic, (void**)&ch,sizeof(ch)); + ch = NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::endsInDiacritic)); if (ch) { if (!alefWidth) { aRendContext->GetWidth(buf, 1, alefWidth, nsnull); @@ -631,23 +621,17 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, } } } -#endif // bug frame = (nsIFrame*) (mVisualFrames[i]); -#ifdef FIX_FOR_BUG_40882 if (ch) { dx += (rect.width - dWidth); frame->SetPosition(nsPoint(rect.x + dWidth, frame->GetPosition().y)); } else -#endif // bug 40882 frame->SetPosition(nsPoint(rect.XMost(), frame->GetPosition().y)); rect = frame->GetRect(); } // for -#ifdef FIX_FOR_BUG_40882 if (dx > 0) { - PRInt32 alignRight; - frame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - (void**) &alignRight,sizeof(alignRight)); + PRInt32 alignRight = NS_GET_BASE_LEVEL(frame); if (0 == (alignRight & 1) ) { const nsStyleText* styleText = frame->GetStyleText(); @@ -663,7 +647,6 @@ nsBidiPresUtils::RepositionInlineFrames(nsIPresContext* aPresContext, } } } -#endif // bug // Now adjust inline container frames. // Example: LTR paragraph @@ -763,8 +746,7 @@ nsBidiPresUtils::EnsureBidiContinuation(nsIPresContext* aPresContext, return PR_FALSE; } } - aFrame->SetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, - (void*) *aNewFrame); + aFrame->SetProperty(nsLayoutAtoms::nextBidi, (void*) *aNewFrame); return PR_TRUE; } diff --git a/mozilla/layout/base/src/nsCaret.cpp b/mozilla/layout/base/src/nsCaret.cpp index 7867e020a3a..7867d68997b 100644 --- a/mozilla/layout/base/src/nsCaret.cpp +++ b/mozilla/layout/base/src/nsCaret.cpp @@ -579,8 +579,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n } else { - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&newBidiLevel, sizeof(newBidiLevel) ); + newBidiLevel = NS_GET_EMBEDDING_LEVEL(theFrame); presShell->SetCaretBidiLevel(newBidiLevel); bidiLevel = newBidiLevel; } @@ -625,16 +624,13 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n // Exception: when the first frame on the line has a different Bidi level from the paragraph level, there is no // real frame for the caret to be in. We have to find the first frame whose level is the same as the // paragraph level, and put the caret at the end of the frame before that. - PRUint8 baseLevel; - frameAfter->GetBidiProperty(presContext, nsLayoutAtoms::baseLevel, - (void**)&baseLevel, sizeof(baseLevel) ); + PRUint8 baseLevel = NS_GET_BASE_LEVEL(frameAfter); if (baseLevel != levelAfter) { if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameAfter, eDirNext, baseLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelAfter, sizeof(levelAfter) ); + levelAfter = NS_GET_EMBEDDING_LEVEL(theFrame); if (baseLevel & 1) // RTL paragraph: caret to the right of the rightmost character theFrameOffset = (levelAfter & 1) ? start : end; else // LTR paragraph: caret to the left of the leftmost character @@ -666,16 +662,14 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n // Exception: when the last frame on the line has a different Bidi level from the paragraph level, there is no // real frame for the caret to be in. We have to find the last frame whose level is the same as the // paragraph level, and put the caret at the end of the frame after that. - PRUint8 baseLevel; - frameBefore->GetBidiProperty(presContext, nsLayoutAtoms::baseLevel, - (void**)&baseLevel, sizeof(baseLevel) ); + + PRUint8 baseLevel = NS_GET_BASE_LEVEL(frameBefore); if (baseLevel != levelBefore) { if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameBefore, eDirPrevious, baseLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelBefore, sizeof(levelBefore) ); + levelBefore = NS_GET_EMBEDDING_LEVEL(theFrame); if (baseLevel & 1) // RTL paragraph: caret to the left of the leftmost character theFrameOffset = (levelBefore & 1) ? end : start; else // RTL paragraph: caret to the right of the rightmost character @@ -692,8 +686,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameAfter, eDirNext, bidiLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelAfter, sizeof(levelAfter) ); + levelAfter = NS_GET_EMBEDDING_LEVEL(theFrame); if (bidiLevel & 1) // c8: caret to the right of the rightmost character theFrameOffset = (levelAfter & 1) ? start : end; else // c7: caret to the left of the leftmost character @@ -707,8 +700,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameBefore, eDirPrevious, bidiLevel, &theFrame))) { theFrame->GetOffsets(start, end); - theFrame->GetBidiProperty(presContext, nsLayoutAtoms::embeddingLevel, - (void**)&levelBefore, sizeof(levelBefore) ); + levelBefore = NS_GET_EMBEDDING_LEVEL(theFrame); if (bidiLevel & 1) // c12: caret to the left of the leftmost character theFrameOffset = (levelBefore & 1) ? end : start; else // c11: caret to the right of the rightmost character diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index fec133bdd18..4371f89edb7 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -300,11 +300,11 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext) nsLineBox::DeleteLineList(aPresContext, mLines); // destroy overflow lines now - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_TRUE); + nsLineList* overflowLines = RemoveOverflowLines(); if (overflowLines) { nsLineBox::DeleteLineList(aPresContext, *overflowLines); } - nsFrameList* overflowOutOfFlows = GetOverflowOutOfFlows(PR_TRUE); + nsFrameList* overflowOutOfFlows = RemoveOverflowOutOfFlows(); if (overflowOutOfFlows) { overflowOutOfFlows->DestroyFrames(aPresContext); delete overflowOutOfFlows; @@ -479,11 +479,11 @@ nsBlockFrame::GetFirstChild(nsIAtom* aListName) const return (mLines.empty()) ? nsnull : mLines.front()->mFirstChild; } else if (aListName == nsLayoutAtoms::overflowList) { - nsLineList* overflowLines = GetOverflowLines(GetPresContext(), PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); return overflowLines ? overflowLines->front()->mFirstChild : nsnull; } else if (aListName == nsLayoutAtoms::overflowOutOfFlowList) { - nsFrameList* oof = GetOverflowOutOfFlows(PR_FALSE); + nsFrameList* oof = GetOverflowOutOfFlows(); return oof ? oof->FirstChild() : nsnull; } else if (aListName == nsLayoutAtoms::floatList) { @@ -820,7 +820,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, // put continued floats at the beginning of the first overflow line. nsFrameList* overflowPlace = nsnull; if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) && - (overflowPlace = GetOverflowPlaceholders(aPresContext, PR_TRUE))) { + (overflowPlace = RemoveOverflowPlaceholders())) { PRBool gaveToAncestor = PR_FALSE; if (NS_FRAME_IS_COMPLETE(state.mReflowStatus)) { // find the nearest block ancestor that uses the same space manager @@ -833,7 +833,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (aReflowState.mSpaceManager == ancestorRS->mSpaceManager) { // Put the continued floats in ancestor since it uses the same space manager nsFrameList* ancestorPlace = - ((nsBlockFrame*)ancestor)->GetOverflowPlaceholders(aPresContext, PR_FALSE); + ((nsBlockFrame*)ancestor)->GetOverflowPlaceholders(); if (ancestorPlace) { ancestorPlace->AppendFrames(ancestor, overflowPlace->FirstChild()); } @@ -847,7 +847,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, ancestorPlace = new nsFrameList(); if (ancestorPlace) { ancestorPlace->AppendFrames(ancestor, overflowPlace->FirstChild()); - ((nsBlockFrame*)ancestor)->SetOverflowPlaceholders(aPresContext, ancestorPlace); + ((nsBlockFrame*)ancestor)->SetOverflowPlaceholders(ancestorPlace); } else return NS_ERROR_OUT_OF_MEMORY; @@ -860,7 +860,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } if (!gaveToAncestor) { PRInt32 numOverflowPlace = overflowPlace->GetLength(); - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (overflowLines) { line_iterator firstLine = overflowLines->begin(); if (firstLine->IsBlock()) { @@ -2863,7 +2863,7 @@ nsBlockFrame::UndoSplitPlaceholders(nsBlockReflowState& aState, } else { // just remove the property - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_TRUE); + nsFrameList* overflowPlace = RemoveOverflowPlaceholders(); delete overflowPlace; } // remove the next in flows of the placeholders that need to be removed @@ -3020,7 +3020,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, } // keep track of the last overflow float in case we need to undo any new additions - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); nsIFrame* lastPlaceholder = (overflowPlace) ? overflowPlace->LastChild() : nsnull; // Reflow the block into the available space @@ -3397,7 +3397,7 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, } // keep track of the last overflow float in case we need to undo any new additions - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); nsIFrame* lastPlaceholder = (overflowPlace) ? overflowPlace->LastChild() : nsnull; // Reflow the frames that are already on the line first @@ -3763,14 +3763,14 @@ nsBlockFrame::SplitPlaceholder(nsIPresContext& aPresContext, aPlaceholder.SetNextSibling(next); contFrame->SetNextSibling(nsnull); // add the placehoder to the overflow floats - nsFrameList* overflowPlace = GetOverflowPlaceholders(&aPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); if (overflowPlace) { overflowPlace->AppendFrames(this, contFrame); } else { overflowPlace = new nsFrameList(contFrame); if (overflowPlace) { - SetOverflowPlaceholders(&aPresContext, overflowPlace); + SetOverflowPlaceholders(overflowPlace); } else return NS_ERROR_NULL_POINTER; } @@ -4068,7 +4068,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, // Any below current line floats to place? if (aState.mBelowCurrentLineFloats.NotEmpty()) { // keep track of the last overflow float in case we need to undo and push the line - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); nsIFrame* lastPlaceholder = (overflowPlace) ? overflowPlace->LastChild() : nsnull; // Reflow the below-current-line floats, then add them to the // lines float list if there aren't any truncated floats. @@ -4189,7 +4189,7 @@ nsBlockFrame::PushLines(nsBlockReflowState& aState, NS_ASSERTION(!overflowLines->empty(), "should not be empty"); // this takes ownership but it won't delete it immediately so we // can keep using it. - SetOverflowLines(aState.mPresContext, overflowLines); + SetOverflowLines(overflowLines); // Mark all the overflow lines dirty so that they get reflowed when // they are pulled up by our next-in-flow. @@ -4209,7 +4209,7 @@ nsBlockFrame::PushLines(nsBlockReflowState& aState, aLineBefore->LastChild()->SetNextSibling(nsnull); #ifdef DEBUG - VerifyOverflowSituation(aState.mPresContext); + VerifyOverflowSituation(); #endif } @@ -4221,7 +4221,7 @@ PRBool nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) { #ifdef DEBUG - VerifyOverflowSituation(aPresContext); + VerifyOverflowSituation(); #endif PRBool drained = PR_FALSE; nsLineList* overflowLines; @@ -4229,7 +4229,7 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) // First grab the prev-in-flows overflow lines nsBlockFrame* prevBlock = (nsBlockFrame*) mPrevInFlow; if (nsnull != prevBlock) { - overflowLines = prevBlock->GetOverflowLines(aPresContext, PR_TRUE); + overflowLines = prevBlock->RemoveOverflowLines(); if (nsnull != overflowLines) { NS_ASSERTION(! overflowLines->empty(), "overflow lines should never be set and empty"); @@ -4264,7 +4264,7 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) delete overflowLines; // Out-of-flow floats need to be reparented too. - nsFrameList* overflowOutOfFlows = prevBlock->GetOverflowOutOfFlows(PR_TRUE); + nsFrameList* overflowOutOfFlows = prevBlock->RemoveOverflowOutOfFlows(); if (overflowOutOfFlows) { for (nsIFrame* f = overflowOutOfFlows->FirstChild(); f; f = f->GetNextSibling()) { @@ -4280,7 +4280,7 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) } // Now grab our own overflow lines - overflowLines = GetOverflowLines(aPresContext, PR_TRUE); + overflowLines = RemoveOverflowLines(); if (overflowLines) { NS_ASSERTION(! overflowLines->empty(), "overflow lines should never be set and empty"); @@ -4302,20 +4302,28 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) // to put them on any child list since BuildFloatList will put // them on some child list. All we need to do is remove the // property. - nsFrameList* overflowOutOfFlows = GetOverflowOutOfFlows(PR_TRUE); + nsFrameList* overflowOutOfFlows = RemoveOverflowOutOfFlows(); delete overflowOutOfFlows; } return drained; } nsLineList* -nsBlockFrame::GetOverflowLines(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const +nsBlockFrame::GetOverflowLines() const { - nsLineList* lines = - NS_STATIC_CAST(nsLineList*, GetProperty(aPresContext, - nsLayoutAtoms::overflowLinesProperty, - aRemoveProperty)); + nsLineList* lines = + NS_STATIC_CAST(nsLineList*, + GetProperty(nsLayoutAtoms::overflowLinesProperty)); + NS_ASSERTION(!lines || !lines->empty(), "value should never be stored as empty"); + return lines; +} + +nsLineList* +nsBlockFrame::RemoveOverflowLines() const +{ + nsLineList* lines = + NS_STATIC_CAST(nsLineList*, + RemoveProperty(nsLayoutAtoms::overflowLinesProperty)); NS_ASSERTION(!lines || !lines->empty(), "value should never be stored as empty"); return lines; } @@ -4337,13 +4345,12 @@ DestroyOverflowLines(nsIPresContext* aPresContext, // This takes ownership of aOverflowLines. // XXX We should allocate overflowLines from presShell arena! nsresult -nsBlockFrame::SetOverflowLines(nsIPresContext* aPresContext, - nsLineList* aOverflowLines) +nsBlockFrame::SetOverflowLines(nsLineList* aOverflowLines) { NS_ASSERTION(aOverflowLines, "null lines"); NS_ASSERTION(!aOverflowLines->empty(), "empty lines"); - nsresult rv = SetProperty(aPresContext, nsLayoutAtoms::overflowLinesProperty, + nsresult rv = SetProperty(nsLayoutAtoms::overflowLinesProperty, aOverflowLines, DestroyOverflowLines); // Verify that we didn't overwrite an existing overflow list NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow list"); @@ -4351,11 +4358,17 @@ nsBlockFrame::SetOverflowLines(nsIPresContext* aPresContext, } nsFrameList* -nsBlockFrame::GetOverflowOutOfFlows(PRBool aRemoveProperty) const +nsBlockFrame::GetOverflowOutOfFlows() const { return NS_STATIC_CAST(nsFrameList*, - GetProperty(GetPresContext(), nsLayoutAtoms::overflowOutOfFlowsProperty, - aRemoveProperty)); + GetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty)); +} + +nsFrameList* +nsBlockFrame::RemoveOverflowOutOfFlows() const +{ + return NS_STATIC_CAST(nsFrameList*, + RemoveProperty(nsLayoutAtoms::overflowOutOfFlowsProperty)); } // Destructor function for the overflowPlaceholders frame property @@ -4373,7 +4386,7 @@ DestroyOverflowOOFs(nsIPresContext* aPresContext, nsresult nsBlockFrame::SetOverflowOutOfFlows(nsFrameList* aOOFs) { - nsresult rv = SetProperty(GetPresContext(), nsLayoutAtoms::overflowOutOfFlowsProperty, + nsresult rv = SetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty, aOOFs, DestroyOverflowOOFs); // Verify that we didn't overwrite an existing overflow list NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow float list"); @@ -4381,14 +4394,19 @@ nsBlockFrame::SetOverflowOutOfFlows(nsFrameList* aOOFs) } nsFrameList* -nsBlockFrame::GetOverflowPlaceholders(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const +nsBlockFrame::GetOverflowPlaceholders() const { - nsFrameList* placeholders = + return + NS_STATIC_CAST(nsFrameList*, + GetProperty(nsLayoutAtoms::overflowPlaceholdersProperty)); +} + +nsFrameList* +nsBlockFrame::RemoveOverflowPlaceholders() const +{ + return NS_STATIC_CAST(nsFrameList*, - GetProperty(aPresContext, nsLayoutAtoms::overflowPlaceholdersProperty, - aRemoveProperty)); - return placeholders; + RemoveProperty(nsLayoutAtoms::overflowPlaceholdersProperty)); } // Destructor function for the overflowPlaceholders frame property @@ -4405,10 +4423,9 @@ DestroyOverflowPlaceholders(nsIPresContext* aPresContext, // This takes ownership of aOverflowLines. // XXX We should allocate overflowLines from presShell arena! nsresult -nsBlockFrame::SetOverflowPlaceholders(nsIPresContext* aPresContext, - nsFrameList* aOverflowPlaceholders) +nsBlockFrame::SetOverflowPlaceholders(nsFrameList* aOverflowPlaceholders) { - nsresult rv = SetProperty(aPresContext, nsLayoutAtoms::overflowPlaceholdersProperty, + nsresult rv = SetProperty(nsLayoutAtoms::overflowPlaceholdersProperty, aOverflowPlaceholders, DestroyOverflowPlaceholders); // Verify that we didn't overwrite an existing overflow list NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow placeholder list"); @@ -4888,18 +4905,15 @@ nsBlockFrame::DeleteNextInFlowChild(nsIPresContext* aPresContext, nsIFrame* prevInFlow; aNextInFlow->GetPrevInFlow(&prevInFlow); NS_PRECONDITION(prevInFlow, "bad next-in-flow"); - NS_PRECONDITION(IsChild(aPresContext, aNextInFlow), "bad geometric parent"); + NS_PRECONDITION(IsChild(aNextInFlow), "bad geometric parent"); #ifdef IBMBIDI - nsIFrame* nextBidi; - prevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, - (void**) &nextBidi,sizeof(nextBidi)); - if (nextBidi != aNextInFlow) { -#endif // IBMBIDI - DoRemoveFrame(aPresContext, aNextInFlow); -#ifdef IBMBIDI - } + if (!(prevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) || + (NS_STATIC_CAST(nsIFrame*, + prevInFlow->GetProperty(nsLayoutAtoms::nextBidi)) != + aNextInFlow)) #endif // IBMBIDI + DoRemoveFrame(aPresContext, aNextInFlow); } //////////////////////////////////////////////////////////////////////// @@ -5701,7 +5715,7 @@ void nsBlockFrame::ClearLineCursor() { return; } - GetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, PR_TRUE); + RemoveProperty(nsLayoutAtoms::lineCursorProperty); RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -5711,7 +5725,7 @@ void nsBlockFrame::SetupLineCursor() { return; } - SetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, + SetProperty(nsLayoutAtoms::lineCursorProperty, mLines.front(), nsnull); AddStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -5722,7 +5736,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) { } nsLineBox* property = NS_STATIC_CAST(nsLineBox*, - GetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, PR_FALSE)); + GetProperty(nsLayoutAtoms::lineCursorProperty)); line_iterator cursor = mLines.begin(property); nsRect cursorArea = cursor->GetCombinedArea(); @@ -5738,7 +5752,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) { } if (cursor.get() != property) { - SetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, + SetProperty(nsLayoutAtoms::lineCursorProperty, cursor.get(), nsnull); } @@ -6059,7 +6073,7 @@ InSiblingList(nsLineList& aLines, nsIFrame* aFrame) } PRBool -nsBlockFrame::IsChild(nsIPresContext* aPresContext, nsIFrame* aFrame) +nsBlockFrame::IsChild(nsIFrame* aFrame) { // Continued out-of-flows don't satisfy InLineList(), continued out-of-flows // and placeholders don't satisfy InSiblingList(). @@ -6081,7 +6095,7 @@ nsBlockFrame::IsChild(nsIPresContext* aPresContext, nsIFrame* aFrame) (skipSiblingList || InSiblingList(mLines, aFrame))) { return PR_TRUE; } - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (overflowLines && (skipLineList || InLineList(*overflowLines, aFrame)) && (skipSiblingList || InSiblingList(*overflowLines, aFrame))) { return PR_TRUE; @@ -6441,7 +6455,7 @@ nsBlockFrame::BuildFloatList() // and not dropped from the frame tree! // Note that overflow lines do not have any float cache set up for them, // because the float cache contains only laid-out floats - nsLineList* overflowLines = GetOverflowLines(GetPresContext(), PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (overflowLines) { head = nsnull; current = nsnull; @@ -6541,11 +6555,11 @@ nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) // list. But its never possible for multiple frames to have overflow // lists. Check that this fact is actually true. void -nsBlockFrame::VerifyOverflowSituation(nsIPresContext* aPresContext) +nsBlockFrame::VerifyOverflowSituation() { nsBlockFrame* flow = (nsBlockFrame*) GetFirstInFlow(); while (nsnull != flow) { - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (nsnull != overflowLines) { NS_ASSERTION(! overflowLines->empty(), "should not be empty if present"); NS_ASSERTION(overflowLines->front()->mFirstChild, "bad overflow list"); diff --git a/mozilla/layout/generic/nsBlockFrame.h b/mozilla/layout/generic/nsBlockFrame.h index e69d7382c8c..d46abe28954 100644 --- a/mozilla/layout/generic/nsBlockFrame.h +++ b/mozilla/layout/generic/nsBlockFrame.h @@ -541,25 +541,24 @@ protected: //---------------------------------------- - nsLineList* GetOverflowLines(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const; - nsresult SetOverflowLines(nsIPresContext* aPresContext, - nsLineList* aOverflowLines); + nsLineList* GetOverflowLines() const; + nsLineList* RemoveOverflowLines() const; + nsresult SetOverflowLines(nsLineList* aOverflowLines); - nsFrameList* GetOverflowPlaceholders(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const; - nsresult SetOverflowPlaceholders(nsIPresContext* aPresContext, - nsFrameList* aOverflowPlaceholders); + nsFrameList* GetOverflowPlaceholders() const; + nsFrameList* RemoveOverflowPlaceholders() const; + nsresult SetOverflowPlaceholders(nsFrameList* aOverflowPlaceholders); - nsFrameList* GetOverflowOutOfFlows(PRBool aRemoveProperty) const; + nsFrameList* GetOverflowOutOfFlows() const; + nsFrameList* RemoveOverflowOutOfFlows() const; nsresult SetOverflowOutOfFlows(nsFrameList* aFloaters); nsIFrame* LastChild(); #ifdef NS_DEBUG - PRBool IsChild(nsIPresContext* aPresContext, nsIFrame* aFrame); + PRBool IsChild(nsIFrame* aFrame); void VerifyLines(PRBool aFinalCheckOK); - void VerifyOverflowSituation(nsIPresContext* aPresContext); + void VerifyOverflowSituation(); PRInt32 GetDepth() const; #endif diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 0bb569b58c9..5d869b7cbf4 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -1111,10 +1111,10 @@ nsContainerFrame::DeleteNextInFlowChild(nsIPresContext* aPresContext, } #ifdef IBMBIDI - nsIFrame* nextBidi; - prevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, - (void**) &nextBidi,sizeof(nextBidi)); - if (nextBidi == aNextInFlow) { + if ((prevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) && + (NS_STATIC_CAST(nsIFrame*, + prevInFlow->GetProperty(nsLayoutAtoms::nextBidi)) == + aNextInFlow)) { return; } #endif // IBMBIDI diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 83fa1f09d81..0d1a9f9616c 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -4164,10 +4164,8 @@ nsFrame::GetFrameFromDirection(nsIPresContext* aPresContext, nsPeekOffsetStruct else aPos->mStartOffset = -1; #ifdef IBMBIDI - PRUint8 oldLevel, newLevel, baseLevel; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&oldLevel, sizeof(oldLevel)); - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&newLevel, sizeof(newLevel)); - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)&baseLevel, sizeof(baseLevel)); + PRUint8 oldLevel = NS_GET_EMBEDDING_LEVEL(this); + PRUint8 newLevel = NS_GET_EMBEDDING_LEVEL(newFrame); if (newLevel & 1) // The new frame is RTL, go to the other end aPos->mStartOffset = -1 - aPos->mStartOffset; @@ -4533,31 +4531,33 @@ nsFrame::IsMouseCaptured(nsIPresContext* aPresContext) return PR_FALSE; } -nsresult -nsFrame::SetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropName, +nsresult +nsIFrame::SetProperty(nsIAtom* aPropName, void* aPropValue, NSFramePropertyDtorFunc aPropDtorFunc) { - return aPresContext->FrameManager()->SetFrameProperty(this, aPropName, - aPropValue, - aPropDtorFunc); + return GetPresContext()->FrameManager()-> + SetFrameProperty(this, aPropName, aPropValue, aPropDtorFunc); } void* -nsFrame::GetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropName, - PRBool aRemoveProp) const +nsIFrame::GetProperty(nsIAtom* aPropName, nsresult* aStatus) const { - PRUint32 options = 0; + return GetPresContext()->FrameManager()-> + GetFrameProperty(this, aPropName, 0, aStatus); +} - if (aRemoveProp) { - options |= NS_IFRAME_MGR_REMOVE_PROP; - } +/* virtual */ void* +nsIFrame::GetPropertyExternal(nsIAtom* aPropName, nsresult* aStatus) const +{ + return GetProperty(aPropName, aStatus); +} - - return aPresContext->FrameManager()->GetFrameProperty(this, aPropName, - options); +void* +nsIFrame::RemoveProperty(nsIAtom* aPropName, nsresult* aStatus) const +{ + return GetPresContext()->FrameManager()-> + GetFrameProperty(this, aPropName, NS_IFRAME_MGR_REMOVE_PROP, aStatus); } /* virtual */ const nsStyleStruct* @@ -4567,50 +4567,6 @@ nsFrame::GetStyleDataExternal(nsStyleStructID aSID) const return mStyleContext->GetStyleData(aSID); } -#ifdef IBMBIDI -/** - * retrieve Bidi property of this frame - * @lina 5/1/2000 - */ - -NS_IMETHODIMP nsFrame::GetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void** aPropertyValue, - size_t aSize) const -{ - if (!aPropertyValue || !aPropertyName) { - return NS_ERROR_NULL_POINTER; - } - if ( (aSize < 1) || (aSize > sizeof(void*) ) ) { - return NS_ERROR_ILLEGAL_VALUE; - } - - memset(aPropertyValue, 0, aSize); - void* val = aPresContext->FrameManager()->GetFrameProperty(this, - aPropertyName, 0); - - if (val) { - // to fix bidi on big endian. We need to copy the right bytes from the void*, not the first aSize bytes. -#if IS_BIG_ENDIAN - memcpy(aPropertyValue, ((char*)&val)+sizeof(void*) - aSize, aSize); -#else - memcpy(aPropertyValue, &val, aSize); -#endif - } - - return NS_OK; -} - -NS_IMETHODIMP nsFrame::SetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue) -{ - return aPresContext->FrameManager()->SetFrameProperty(this, aPropertyName, - aPropertyValue, - nsnull); -} -#endif // IBMBIDI - #ifdef NS_DEBUG static void GetTagName(nsFrame* aFrame, nsIContent* aContent, PRIntn aResultSize, diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index a40bb69c5f4..6b11981bc24 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -387,26 +387,8 @@ public: NS_IMETHOD CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents); PRBool IsMouseCaptured(nsIPresContext* aPresContext); - virtual void* GetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - PRBool aRemoveProperty) const; - - virtual nsresult SetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue, - NSFramePropertyDtorFunc aPropDtorFunc); - virtual const nsStyleStruct* GetStyleDataExternal(nsStyleStructID aSID) const; -#ifdef IBMBIDI - NS_IMETHOD GetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void** aPropertyValue, - size_t aSize ) const; - NS_IMETHOD SetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue) ; -#endif // IBMBIDI #ifdef NS_DEBUG /** diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 0c8b0f2d89b..fbd38a72d6e 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -1187,28 +1187,19 @@ public: } - - virtual void* GetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - PRBool aRemoveProperty) const = 0; + void* GetProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const; + virtual void* GetPropertyExternal(nsIAtom* aPropertyName, + nsresult* aStatus) const; + void* RemoveProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const; + nsresult SetProperty(nsIAtom* aPropertyName, + void* aValue, + NSFramePropertyDtorFunc aDestructor = nsnull); - virtual nsresult SetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue, - NSFramePropertyDtorFunc aPropDtorFunc) = 0; -#ifdef IBMBIDI - /** - * retrieve and set Bidi property of this frame - * @lina 5/1/2000 - */ - NS_IMETHOD GetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void** aPropertyValue, - size_t aSize ) const = 0; - NS_IMETHOD SetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue) = 0; -#endif // IBMBIDI +#define NS_GET_BASE_LEVEL(frame) \ +NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::baseLevel)) + +#define NS_GET_EMBEDDING_LEVEL(frame) \ +NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::embeddingLevel)) /** Create or retrieve the previously stored overflow area, if the frame does * not overflow and no creation is required return nsnull. diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index a8d7cdd988c..39dba393cb0 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -61,7 +61,6 @@ #include "nsHTMLAtoms.h" #include "nsTextFragment.h" #include "nsBidiUtils.h" -#define FIX_FOR_BUG_40882 #ifdef DEBUG #undef NOISY_HORIZONTAL_ALIGN @@ -1043,16 +1042,17 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, !textContent->IsOnlyWhitespace()); // fix for bug 40882 #ifdef IBMBIDI - const nsTextFragment* frag = textContent->Text(); - if (frag->Is2b()) { - //PRBool isVisual; - //mPresContext->IsVisualMode(isVisual); - PRUnichar ch = /*(isVisual) ? - *(frag->Get2b() + frag->GetLength() - 1) :*/ *frag->Get2b(); - if (IS_BIDI_DIACRITIC(ch)) { - aFrame->SetBidiProperty(mPresContext, - nsLayoutAtoms::endsInDiacritic, - NS_INT32_TO_PTR(ch)); + if (mPresContext->BidiEnabled()) { + const nsTextFragment* frag = textContent->Text(); + if (frag->Is2b()) { + //PRBool isVisual; + //mPresContext->IsVisualMode(isVisual); + PRUnichar ch = /*(isVisual) ? + *(frag->Get2b() + frag->GetLength() - 1) :*/ *frag->Get2b(); + if (IS_BIDI_DIACRITIC(ch)) { + aFrame->SetProperty(nsLayoutAtoms::endsInDiacritic, + NS_INT32_TO_PTR(ch)); + } } } #endif // IBMBIDI diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 838100bfbbe..64179881b85 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -1504,7 +1504,6 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA { nsIFrame *theFrame; PRInt32 currentOffset, frameStart, frameEnd; - PRUint8 level; // XXX - I expected to be able to use pos.mResultFrame, but when we move from frame to frame // and |PeekOffset| is called recursively, pos.mResultFrame on exit is sometimes set to the original @@ -1533,9 +1532,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA pos.mContentOffset = frameEnd; // set the cursor Bidi level to the paragraph embedding level - theFrame->GetBidiProperty(context, nsLayoutAtoms::baseLevel, (void**)&level, - sizeof(level) ); - shell->SetCaretBidiLevel(level); + shell->SetCaretBidiLevel(NS_GET_BASE_LEVEL(theFrame)); break; default: @@ -1544,9 +1541,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA || (eSelectDir == aAmount) || (eSelectLine == aAmount)) { - theFrame->GetBidiProperty(context, nsLayoutAtoms::embeddingLevel, (void**)&level, - sizeof(level) ); - shell->SetCaretBidiLevel(level); + shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame)); } else BidiLevelFromMove(context, shell, pos.mResultContent, pos.mContentOffset, aKeycode); @@ -1734,13 +1729,11 @@ nsSelection::VisualSequence(nsIPresContext *aPresContext, PRBool* aNeedVisualSelection) { nsVoidArray frameArray; - PRUint8 bidiLevel, currentLevel; PRInt32 frameStart, frameEnd; PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); nsresult result = nsnull; - aCurrentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)¤tLevel, sizeof(currentLevel) ); - + PRUint8 currentLevel = NS_GET_EMBEDDING_LEVEL(aCurrentFrame); result = aSelectFrame->PeekOffset(aPresContext, aPos); while (aCurrentFrame != (aSelectFrame = aPos->mResultFrame)) { @@ -1755,7 +1748,7 @@ nsSelection::VisualSequence(nsIPresContext *aPresContext, frameArray.AppendElement(aSelectFrame); aSelectFrame->GetOffsets(frameStart, frameEnd); - aSelectFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&bidiLevel, sizeof(bidiLevel) ); + PRUint8 bidiLevel = NS_GET_EMBEDDING_LEVEL(aSelectFrame); if (currentLevel != bidiLevel) *aNeedVisualSelection = PR_TRUE; @@ -1909,16 +1902,13 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, nsCOMPtr anchorNode; PRInt32 anchorOffset; nsIFrame* anchorFrame; - PRUint8 anchorLevel; nsCOMPtr focusContent; nsCOMPtr focusNode; PRInt32 focusOffset; nsIFrame* focusFrame; - PRUint8 focusLevel; nsCOMPtr currentContent; nsCOMPtr currentNode; PRInt32 currentOffset; - PRUint8 currentLevel; nsresult result; nsIFrame* startFrame; PRBool needVisualSelection = PR_FALSE; @@ -1932,12 +1922,12 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, result = GetFrameForNodeOffset(anchorContent, anchorOffset, mHint, &anchorFrame, &anchorOffset); if (NS_FAILED(result)) return result; - anchorFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&anchorLevel, sizeof(anchorLevel) ); - + PRUint8 anchorLevel = NS_GET_EMBEDDING_LEVEL(anchorFrame); + currentContent = aPos.mResultContent; currentNode = do_QueryInterface(currentContent); currentOffset = aPos.mContentOffset; - aCurrentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)¤tLevel, sizeof(currentLevel) ); + PRUint8 currentLevel = NS_GET_EMBEDDING_LEVEL(aCurrentFrame); // Moving from simplest case to more complicated: // case 1: selection starts and ends in the same frame: no special treatment @@ -1958,8 +1948,7 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, result = GetFrameForNodeOffset(focusContent, focusOffset, hint, &focusFrame, &focusOffset); if (NS_FAILED(result)) return result; - - focusFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&focusLevel, sizeof(focusLevel) ); + PRUint8 focusLevel = NS_GET_EMBEDDING_LEVEL(focusFrame); if (currentLevel != anchorLevel) needVisualSelection = PR_TRUE; @@ -2043,9 +2032,7 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, // // If selection direction is backwards, vice versa throughout // - PRUint8 anchorBaseLevel; - PRUint8 currentBaseLevel; - anchorFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)&anchorBaseLevel, sizeof(anchorBaseLevel) ); + PRUint8 anchorBaseLevel = NS_GET_BASE_LEVEL(anchorFrame); if ((eDirNext == selectionDirection) != ((anchorLevel & 1) == (anchorBaseLevel & 1))) result = SelectToEdge(anchorFrame, anchorContent, anchorOffset, 0, PR_FALSE); else @@ -2073,8 +2060,7 @@ nsSelection::VisualSelectFrames(nsIPresContext *aPresContext, return result; // Go to the current point - - aCurrentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)¤tBaseLevel, sizeof(currentBaseLevel) ); + PRUint8 currentBaseLevel = NS_GET_BASE_LEVEL(aCurrentFrame); // Walk the frames in visual order until we reach the beginning of the line aPos.mJumpLines = PR_FALSE; if ((currentBaseLevel & 1) == (anchorBaseLevel & 1)) @@ -2142,9 +2128,7 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, else { // we are neither at the beginning nor at the end of the frame, so we have no worries *aPrevFrame = *aNextFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); - *aPrevLevel = *aNextLevel; + *aPrevLevel = *aNextLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); return NS_OK; } @@ -2221,10 +2205,8 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, // set aNextFrame to null // set aNextLevel to the paragraph embedding level *aPrevFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); + *aPrevLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); + *aNextLevel = NS_GET_BASE_LEVEL(currentFrame); *aNextFrame = nsnull; return NS_OK; } @@ -2234,10 +2216,8 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, // set aNextFrame to the current frame // set aNextLevel to the embedding level of the current frame *aNextFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); + *aNextLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); + *aPrevLevel = NS_GET_BASE_LEVEL(currentFrame); *aPrevFrame = nsnull; return NS_OK; } @@ -2271,19 +2251,15 @@ nsSelection::GetPrevNextBidiLevels(nsIPresContext *aPresContext, if (direction == eDirNext) { *aPrevFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); + *aPrevLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); *aNextFrame = newFrame; - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); + *aNextLevel = NS_GET_EMBEDDING_LEVEL(newFrame); } else { *aNextFrame = currentFrame; - currentFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aNextLevel, sizeof(*aNextLevel) ); + *aNextLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); *aPrevFrame = newFrame; - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)aPrevLevel, sizeof(*aPrevLevel) ); + *aPrevLevel = NS_GET_EMBEDDING_LEVEL(newFrame); } return NS_OK; @@ -2327,8 +2303,7 @@ NS_IMETHODIMP nsSelection::GetFrameFromLevel(nsIPresContext *aPresContext, //we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules //for speed reasons foundFrame = (nsIFrame *)isupports; - foundFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)&foundLevel, sizeof(foundLevel) ); + foundLevel = NS_GET_EMBEDDING_LEVEL(foundFrame); } while (foundLevel > aBidiLevel); @@ -2440,16 +2415,13 @@ void nsSelection::BidiLevelFromClick(nsIContent *aNode, PRUint32 aContentOffset) return; nsIFrame* clickInFrame=nsnull; - PRUint8 frameLevel; PRInt32 OffsetNotUsed; result = GetFrameForNodeOffset(aNode, aContentOffset, mHint, &clickInFrame, &OffsetNotUsed); if (NS_FAILED(result)) return; - clickInFrame->GetBidiProperty(context, nsLayoutAtoms::embeddingLevel, - (void**)&frameLevel, sizeof(frameLevel) ); - shell->SetCaretBidiLevel(frameLevel); + shell->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(clickInFrame)); } @@ -2593,9 +2565,7 @@ nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint& PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_FALSE); mHint = HINT(beginOfContent); HINT saveHint = mHint; - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**)&level,sizeof(level)); - if (level & 1) + if (NS_GET_EMBEDDING_LEVEL(newFrame) & 1) mHint = (mHint==HINTLEFT) ? HINTRIGHT : HINTLEFT; pos.mResultContent = newContent; pos.mContentOffset = contentOffsetEnd; @@ -7606,12 +7576,12 @@ nsTypedSelection::SelectionLanguageChange(PRBool aLangRTL) PRInt32 frameStart, frameEnd; focusFrame->GetOffsets(frameStart, frameEnd); nsCOMPtr context; - PRUint8 level, levelBefore, levelAfter; + PRUint8 levelBefore, levelAfter; result = GetPresContext(getter_AddRefs(context)); if (NS_FAILED(result) || !context) return result?result:NS_ERROR_FAILURE; - focusFrame->GetBidiProperty(context, nsLayoutAtoms::embeddingLevel, (void**)&level, sizeof(level)); + PRUint8 level = NS_GET_EMBEDDING_LEVEL(focusFrame); if ((focusOffset != frameStart) && (focusOffset != frameEnd)) // the cursor is not at a frame boundary, so the level of both the characters (logically) before and after the cursor // is equal to the frame level diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 3a8030ffb19..77638042f7b 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -877,20 +877,17 @@ nsContinuingTextFrame::Init(nsIPresContext* aPresContext, PRInt32 start, end; aPrevInFlow->GetOffsets(start, mContentOffset); - void* value; - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, &value,sizeof(value)); - SetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, value); + SetProperty(nsLayoutAtoms::embeddingLevel, + aPrevInFlow->GetProperty(nsLayoutAtoms::embeddingLevel)); + SetProperty(nsLayoutAtoms::baseLevel, + aPrevInFlow->GetProperty(nsLayoutAtoms::baseLevel)); + SetProperty(nsLayoutAtoms::charType, + aPrevInFlow->GetProperty(nsLayoutAtoms::charType)); - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, &value,sizeof(value)); - SetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, value); - - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::charType, &value,sizeof(value)); - SetBidiProperty(aPresContext, nsLayoutAtoms::charType, value); - - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, &value,sizeof(value)); + void* value = aPrevInFlow->GetProperty(nsLayoutAtoms::nextBidi); if (value) { // nextBidi // aPrevInFlow and this frame will point to the same next bidi frame. - SetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, value); + SetProperty(nsLayoutAtoms::nextBidi, value); ( (nsIFrame*) value)->GetOffsets(start, end); mContentLength = PR_MAX(1, start - mContentOffset); @@ -1384,13 +1381,13 @@ nsTextFrame::CharacterDataChanged(nsIPresContext* aPresContext, while (textFrame) { textFrame->mState |= NS_FRAME_IS_DIRTY; #ifdef IBMBIDI - nsIFrame* nextBidi; - textFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &nextBidi,sizeof(nextBidi)); - if (nextBidi) - textFrame = (nsTextFrame*)nextBidi; + void* nextBidiFrame; + if ((textFrame->mState & NS_FRAME_IS_BIDI) && + (nextBidiFrame = textFrame->GetProperty(nsLayoutAtoms::nextBidi))) + textFrame = (nsTextFrame*)nextBidiFrame; else #endif - textFrame = (nsTextFrame*)textFrame->mNextInFlow; + textFrame = (nsTextFrame*)textFrame->mNextInFlow; } } @@ -2187,7 +2184,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, PRInt16 selectionValue; nsCOMPtr lb; #ifdef IBMBIDI - PRUint8 level = 0; + PRBool isOddLevel = PR_FALSE; #endif @@ -2240,8 +2237,8 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, nsCharType charType = eCharType_LeftToRight; if (aPresContext->BidiEnabled()) { isBidiSystem = aPresContext->IsBidiSystem(); - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**) &level,sizeof(level)); - GetBidiProperty(aPresContext, nsLayoutAtoms::charType, (void**) &charType,sizeof(charType)); + isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; + charType = (nsCharType)NS_PTR_TO_INT32(GetProperty(nsLayoutAtoms::charType)); isRightToLeftOnBidiPlatform = (isBidiSystem && (eCharType_RightToLeft == charType || @@ -2259,7 +2256,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, PRInt32 rememberTextLength = textLength; #endif bidiUtils->ReorderUnicodeText(text, textLength, - charType, level & 1, isBidiSystem); + charType, isOddLevel, isBidiSystem); NS_ASSERTION(rememberTextLength == textLength, "Bidi formatting changed text length"); } } @@ -2336,7 +2333,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, } #endif /* SUNCTL */ #ifdef IBMBIDI - AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), level & 1, isBidiSystem); + AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), isOddLevel, isBidiSystem); #endif sdptr = sdptr->mNext; } @@ -2504,9 +2501,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, } #ifdef IBMBIDI // Simon -- reverse RTL text here - PRUint8 level; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - PRBool isOddLevel = (level & 1); + PRBool isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; if (isOddLevel) { PRUnichar *tStart, *tEnd; PRUnichar tSwap; @@ -2931,7 +2926,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, if (0 != textLength) { #ifdef IBMBIDI - PRUint8 level = 0; + PRBool isOddLevel = PR_FALSE; nsCharType charType = eCharType_LeftToRight; if (aPresContext->BidiEnabled()) { @@ -2939,16 +2934,14 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, aPresContext->GetBidiUtils(&bidiUtils); if (bidiUtils) { - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**) &level,sizeof(level)); - GetBidiProperty(aPresContext, nsLayoutAtoms::charType, - (void**) &charType,sizeof(charType)); + isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; + charType = (nsCharType)NS_PTR_TO_INT32(GetProperty(nsLayoutAtoms::charType)); #ifdef DEBUG PRInt32 rememberTextLength = textLength; #endif // Since we paint char by char, handle the text like on non-bidi platform bidiUtils->ReorderUnicodeText(text, textLength, charType, - level & 1, PR_FALSE); + isOddLevel, PR_FALSE); NS_ASSERTION(rememberTextLength == textLength, "Bidi formatting changed text length"); } } @@ -2990,7 +2983,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, sdptr->mStart = ip[sdptr->mStart] - mContentOffset; sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; #ifdef IBMBIDI - AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), level & 1, PR_FALSE); + AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), isOddLevel, PR_FALSE); #endif sdptr = sdptr->mNext; } @@ -3428,10 +3421,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, PRUnichar* text = paintBuffer.mBuffer; #ifdef IBMBIDI - PRBool getReversedPos = PR_FALSE; - PRUint8 level = 0; - GetBidiProperty(aCX, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - getReversedPos = level & 1; + PRBool getReversedPos = NS_GET_EMBEDDING_LEVEL(this) & 1; nscoord posX = (getReversedPos) ? (mRect.width + origin.x) - (aPoint.x - origin.x) : aPoint.x; @@ -3673,8 +3663,9 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext, break; } #ifdef IBMBIDI - GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &frame,sizeof(frame)); - if (frame) { + if ((mState & NS_FRAME_IS_BIDI) && + (frame = NS_STATIC_CAST(nsIFrame*, + GetProperty(nsLayoutAtoms::nextBidi)))) { frame->SetSelected(aPresContext, aRange, aSelected, aSpread); } #endif // IBMBIDI @@ -3776,10 +3767,7 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext, } } #ifdef IBMBIDI - PRUint8 level; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - - if (level & 1) { + if (NS_GET_EMBEDDING_LEVEL(this) & 1) { outPoint->x = mRect.width - width; } else @@ -3865,10 +3853,7 @@ NS_IMETHODIMP nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) { #ifdef IBMBIDI - PRUint8 level, baseLevel; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)&baseLevel,sizeof(baseLevel)); - PRBool isOddLevel = (level & 1); + PRBool isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; if ((eSelectCharacter == aPos->mAmount) || (eSelectWord == aPos->mAmount)) @@ -3886,7 +3871,8 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) nsIFrame *nextInFlow; #ifdef IBMBIDI if (isOddLevel) { - GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &nextInFlow,sizeof(nextInFlow)); + nextInFlow = NS_STATIC_CAST(nsIFrame*, + GetProperty(nsLayoutAtoms::nextBidi)); } else #endif @@ -4547,7 +4533,8 @@ nsTextFrame::MeasureText(nsIPresContext* aPresContext, PRInt32 start = -1, end; if (mState & NS_FRAME_IS_BIDI) { - GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &nextBidi,sizeof(nextBidi)); + nextBidi = NS_STATIC_CAST(nsTextFrame*, + GetProperty(nsLayoutAtoms::nextBidi)); if (nextBidi) { if (mContentLength < 1) { @@ -5187,7 +5174,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext, nsCharType charType = eCharType_LeftToRight; PRUint32 hints = 0; aReflowState.rendContext->GetHints(hints); - GetBidiProperty(aPresContext, nsLayoutAtoms::charType, (void**)&charType, sizeof(charType)); + charType = (nsCharType)NS_PTR_TO_INT32(GetProperty(nsLayoutAtoms::charType)); if ((eCharType_RightToLeftArabic == charType && (hints & NS_RENDERING_HINT_ARABIC_SHAPING) == NS_RENDERING_HINT_ARABIC_SHAPING) || (eCharType_RightToLeft == charType && diff --git a/mozilla/layout/generic/nsTextTransformer.cpp b/mozilla/layout/generic/nsTextTransformer.cpp index c1727dacf19..43f709e9d59 100644 --- a/mozilla/layout/generic/nsTextTransformer.cpp +++ b/mozilla/layout/generic/nsTextTransformer.cpp @@ -227,8 +227,7 @@ nsTextTransformer::Init(nsIFrame* aFrame, * We do numeric shaping in all Bidi documents. */ if (mPresContext->BidiEnabled()) { - aFrame->GetBidiProperty(mPresContext, nsLayoutAtoms::charType, - (void**)&mCharType, sizeof(mCharType)); + mCharType = (nsCharType)NS_PTR_TO_INT32(aFrame->GetProperty(nsLayoutAtoms::charType)); if (mCharType == eCharType_RightToLeftArabic) { if (aForceArabicShaping) { SetNeedsArabicShaping(PR_TRUE); diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index fec133bdd18..4371f89edb7 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -300,11 +300,11 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext) nsLineBox::DeleteLineList(aPresContext, mLines); // destroy overflow lines now - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_TRUE); + nsLineList* overflowLines = RemoveOverflowLines(); if (overflowLines) { nsLineBox::DeleteLineList(aPresContext, *overflowLines); } - nsFrameList* overflowOutOfFlows = GetOverflowOutOfFlows(PR_TRUE); + nsFrameList* overflowOutOfFlows = RemoveOverflowOutOfFlows(); if (overflowOutOfFlows) { overflowOutOfFlows->DestroyFrames(aPresContext); delete overflowOutOfFlows; @@ -479,11 +479,11 @@ nsBlockFrame::GetFirstChild(nsIAtom* aListName) const return (mLines.empty()) ? nsnull : mLines.front()->mFirstChild; } else if (aListName == nsLayoutAtoms::overflowList) { - nsLineList* overflowLines = GetOverflowLines(GetPresContext(), PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); return overflowLines ? overflowLines->front()->mFirstChild : nsnull; } else if (aListName == nsLayoutAtoms::overflowOutOfFlowList) { - nsFrameList* oof = GetOverflowOutOfFlows(PR_FALSE); + nsFrameList* oof = GetOverflowOutOfFlows(); return oof ? oof->FirstChild() : nsnull; } else if (aListName == nsLayoutAtoms::floatList) { @@ -820,7 +820,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, // put continued floats at the beginning of the first overflow line. nsFrameList* overflowPlace = nsnull; if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) && - (overflowPlace = GetOverflowPlaceholders(aPresContext, PR_TRUE))) { + (overflowPlace = RemoveOverflowPlaceholders())) { PRBool gaveToAncestor = PR_FALSE; if (NS_FRAME_IS_COMPLETE(state.mReflowStatus)) { // find the nearest block ancestor that uses the same space manager @@ -833,7 +833,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (aReflowState.mSpaceManager == ancestorRS->mSpaceManager) { // Put the continued floats in ancestor since it uses the same space manager nsFrameList* ancestorPlace = - ((nsBlockFrame*)ancestor)->GetOverflowPlaceholders(aPresContext, PR_FALSE); + ((nsBlockFrame*)ancestor)->GetOverflowPlaceholders(); if (ancestorPlace) { ancestorPlace->AppendFrames(ancestor, overflowPlace->FirstChild()); } @@ -847,7 +847,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, ancestorPlace = new nsFrameList(); if (ancestorPlace) { ancestorPlace->AppendFrames(ancestor, overflowPlace->FirstChild()); - ((nsBlockFrame*)ancestor)->SetOverflowPlaceholders(aPresContext, ancestorPlace); + ((nsBlockFrame*)ancestor)->SetOverflowPlaceholders(ancestorPlace); } else return NS_ERROR_OUT_OF_MEMORY; @@ -860,7 +860,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } if (!gaveToAncestor) { PRInt32 numOverflowPlace = overflowPlace->GetLength(); - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (overflowLines) { line_iterator firstLine = overflowLines->begin(); if (firstLine->IsBlock()) { @@ -2863,7 +2863,7 @@ nsBlockFrame::UndoSplitPlaceholders(nsBlockReflowState& aState, } else { // just remove the property - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_TRUE); + nsFrameList* overflowPlace = RemoveOverflowPlaceholders(); delete overflowPlace; } // remove the next in flows of the placeholders that need to be removed @@ -3020,7 +3020,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState, } // keep track of the last overflow float in case we need to undo any new additions - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); nsIFrame* lastPlaceholder = (overflowPlace) ? overflowPlace->LastChild() : nsnull; // Reflow the block into the available space @@ -3397,7 +3397,7 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, } // keep track of the last overflow float in case we need to undo any new additions - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); nsIFrame* lastPlaceholder = (overflowPlace) ? overflowPlace->LastChild() : nsnull; // Reflow the frames that are already on the line first @@ -3763,14 +3763,14 @@ nsBlockFrame::SplitPlaceholder(nsIPresContext& aPresContext, aPlaceholder.SetNextSibling(next); contFrame->SetNextSibling(nsnull); // add the placehoder to the overflow floats - nsFrameList* overflowPlace = GetOverflowPlaceholders(&aPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); if (overflowPlace) { overflowPlace->AppendFrames(this, contFrame); } else { overflowPlace = new nsFrameList(contFrame); if (overflowPlace) { - SetOverflowPlaceholders(&aPresContext, overflowPlace); + SetOverflowPlaceholders(overflowPlace); } else return NS_ERROR_NULL_POINTER; } @@ -4068,7 +4068,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, // Any below current line floats to place? if (aState.mBelowCurrentLineFloats.NotEmpty()) { // keep track of the last overflow float in case we need to undo and push the line - nsFrameList* overflowPlace = GetOverflowPlaceholders(aState.mPresContext, PR_FALSE); + nsFrameList* overflowPlace = GetOverflowPlaceholders(); nsIFrame* lastPlaceholder = (overflowPlace) ? overflowPlace->LastChild() : nsnull; // Reflow the below-current-line floats, then add them to the // lines float list if there aren't any truncated floats. @@ -4189,7 +4189,7 @@ nsBlockFrame::PushLines(nsBlockReflowState& aState, NS_ASSERTION(!overflowLines->empty(), "should not be empty"); // this takes ownership but it won't delete it immediately so we // can keep using it. - SetOverflowLines(aState.mPresContext, overflowLines); + SetOverflowLines(overflowLines); // Mark all the overflow lines dirty so that they get reflowed when // they are pulled up by our next-in-flow. @@ -4209,7 +4209,7 @@ nsBlockFrame::PushLines(nsBlockReflowState& aState, aLineBefore->LastChild()->SetNextSibling(nsnull); #ifdef DEBUG - VerifyOverflowSituation(aState.mPresContext); + VerifyOverflowSituation(); #endif } @@ -4221,7 +4221,7 @@ PRBool nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) { #ifdef DEBUG - VerifyOverflowSituation(aPresContext); + VerifyOverflowSituation(); #endif PRBool drained = PR_FALSE; nsLineList* overflowLines; @@ -4229,7 +4229,7 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) // First grab the prev-in-flows overflow lines nsBlockFrame* prevBlock = (nsBlockFrame*) mPrevInFlow; if (nsnull != prevBlock) { - overflowLines = prevBlock->GetOverflowLines(aPresContext, PR_TRUE); + overflowLines = prevBlock->RemoveOverflowLines(); if (nsnull != overflowLines) { NS_ASSERTION(! overflowLines->empty(), "overflow lines should never be set and empty"); @@ -4264,7 +4264,7 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) delete overflowLines; // Out-of-flow floats need to be reparented too. - nsFrameList* overflowOutOfFlows = prevBlock->GetOverflowOutOfFlows(PR_TRUE); + nsFrameList* overflowOutOfFlows = prevBlock->RemoveOverflowOutOfFlows(); if (overflowOutOfFlows) { for (nsIFrame* f = overflowOutOfFlows->FirstChild(); f; f = f->GetNextSibling()) { @@ -4280,7 +4280,7 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) } // Now grab our own overflow lines - overflowLines = GetOverflowLines(aPresContext, PR_TRUE); + overflowLines = RemoveOverflowLines(); if (overflowLines) { NS_ASSERTION(! overflowLines->empty(), "overflow lines should never be set and empty"); @@ -4302,20 +4302,28 @@ nsBlockFrame::DrainOverflowLines(nsIPresContext* aPresContext) // to put them on any child list since BuildFloatList will put // them on some child list. All we need to do is remove the // property. - nsFrameList* overflowOutOfFlows = GetOverflowOutOfFlows(PR_TRUE); + nsFrameList* overflowOutOfFlows = RemoveOverflowOutOfFlows(); delete overflowOutOfFlows; } return drained; } nsLineList* -nsBlockFrame::GetOverflowLines(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const +nsBlockFrame::GetOverflowLines() const { - nsLineList* lines = - NS_STATIC_CAST(nsLineList*, GetProperty(aPresContext, - nsLayoutAtoms::overflowLinesProperty, - aRemoveProperty)); + nsLineList* lines = + NS_STATIC_CAST(nsLineList*, + GetProperty(nsLayoutAtoms::overflowLinesProperty)); + NS_ASSERTION(!lines || !lines->empty(), "value should never be stored as empty"); + return lines; +} + +nsLineList* +nsBlockFrame::RemoveOverflowLines() const +{ + nsLineList* lines = + NS_STATIC_CAST(nsLineList*, + RemoveProperty(nsLayoutAtoms::overflowLinesProperty)); NS_ASSERTION(!lines || !lines->empty(), "value should never be stored as empty"); return lines; } @@ -4337,13 +4345,12 @@ DestroyOverflowLines(nsIPresContext* aPresContext, // This takes ownership of aOverflowLines. // XXX We should allocate overflowLines from presShell arena! nsresult -nsBlockFrame::SetOverflowLines(nsIPresContext* aPresContext, - nsLineList* aOverflowLines) +nsBlockFrame::SetOverflowLines(nsLineList* aOverflowLines) { NS_ASSERTION(aOverflowLines, "null lines"); NS_ASSERTION(!aOverflowLines->empty(), "empty lines"); - nsresult rv = SetProperty(aPresContext, nsLayoutAtoms::overflowLinesProperty, + nsresult rv = SetProperty(nsLayoutAtoms::overflowLinesProperty, aOverflowLines, DestroyOverflowLines); // Verify that we didn't overwrite an existing overflow list NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow list"); @@ -4351,11 +4358,17 @@ nsBlockFrame::SetOverflowLines(nsIPresContext* aPresContext, } nsFrameList* -nsBlockFrame::GetOverflowOutOfFlows(PRBool aRemoveProperty) const +nsBlockFrame::GetOverflowOutOfFlows() const { return NS_STATIC_CAST(nsFrameList*, - GetProperty(GetPresContext(), nsLayoutAtoms::overflowOutOfFlowsProperty, - aRemoveProperty)); + GetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty)); +} + +nsFrameList* +nsBlockFrame::RemoveOverflowOutOfFlows() const +{ + return NS_STATIC_CAST(nsFrameList*, + RemoveProperty(nsLayoutAtoms::overflowOutOfFlowsProperty)); } // Destructor function for the overflowPlaceholders frame property @@ -4373,7 +4386,7 @@ DestroyOverflowOOFs(nsIPresContext* aPresContext, nsresult nsBlockFrame::SetOverflowOutOfFlows(nsFrameList* aOOFs) { - nsresult rv = SetProperty(GetPresContext(), nsLayoutAtoms::overflowOutOfFlowsProperty, + nsresult rv = SetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty, aOOFs, DestroyOverflowOOFs); // Verify that we didn't overwrite an existing overflow list NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow float list"); @@ -4381,14 +4394,19 @@ nsBlockFrame::SetOverflowOutOfFlows(nsFrameList* aOOFs) } nsFrameList* -nsBlockFrame::GetOverflowPlaceholders(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const +nsBlockFrame::GetOverflowPlaceholders() const { - nsFrameList* placeholders = + return + NS_STATIC_CAST(nsFrameList*, + GetProperty(nsLayoutAtoms::overflowPlaceholdersProperty)); +} + +nsFrameList* +nsBlockFrame::RemoveOverflowPlaceholders() const +{ + return NS_STATIC_CAST(nsFrameList*, - GetProperty(aPresContext, nsLayoutAtoms::overflowPlaceholdersProperty, - aRemoveProperty)); - return placeholders; + RemoveProperty(nsLayoutAtoms::overflowPlaceholdersProperty)); } // Destructor function for the overflowPlaceholders frame property @@ -4405,10 +4423,9 @@ DestroyOverflowPlaceholders(nsIPresContext* aPresContext, // This takes ownership of aOverflowLines. // XXX We should allocate overflowLines from presShell arena! nsresult -nsBlockFrame::SetOverflowPlaceholders(nsIPresContext* aPresContext, - nsFrameList* aOverflowPlaceholders) +nsBlockFrame::SetOverflowPlaceholders(nsFrameList* aOverflowPlaceholders) { - nsresult rv = SetProperty(aPresContext, nsLayoutAtoms::overflowPlaceholdersProperty, + nsresult rv = SetProperty(nsLayoutAtoms::overflowPlaceholdersProperty, aOverflowPlaceholders, DestroyOverflowPlaceholders); // Verify that we didn't overwrite an existing overflow list NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow placeholder list"); @@ -4888,18 +4905,15 @@ nsBlockFrame::DeleteNextInFlowChild(nsIPresContext* aPresContext, nsIFrame* prevInFlow; aNextInFlow->GetPrevInFlow(&prevInFlow); NS_PRECONDITION(prevInFlow, "bad next-in-flow"); - NS_PRECONDITION(IsChild(aPresContext, aNextInFlow), "bad geometric parent"); + NS_PRECONDITION(IsChild(aNextInFlow), "bad geometric parent"); #ifdef IBMBIDI - nsIFrame* nextBidi; - prevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, - (void**) &nextBidi,sizeof(nextBidi)); - if (nextBidi != aNextInFlow) { -#endif // IBMBIDI - DoRemoveFrame(aPresContext, aNextInFlow); -#ifdef IBMBIDI - } + if (!(prevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) || + (NS_STATIC_CAST(nsIFrame*, + prevInFlow->GetProperty(nsLayoutAtoms::nextBidi)) != + aNextInFlow)) #endif // IBMBIDI + DoRemoveFrame(aPresContext, aNextInFlow); } //////////////////////////////////////////////////////////////////////// @@ -5701,7 +5715,7 @@ void nsBlockFrame::ClearLineCursor() { return; } - GetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, PR_TRUE); + RemoveProperty(nsLayoutAtoms::lineCursorProperty); RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -5711,7 +5725,7 @@ void nsBlockFrame::SetupLineCursor() { return; } - SetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, + SetProperty(nsLayoutAtoms::lineCursorProperty, mLines.front(), nsnull); AddStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -5722,7 +5736,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) { } nsLineBox* property = NS_STATIC_CAST(nsLineBox*, - GetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, PR_FALSE)); + GetProperty(nsLayoutAtoms::lineCursorProperty)); line_iterator cursor = mLines.begin(property); nsRect cursorArea = cursor->GetCombinedArea(); @@ -5738,7 +5752,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) { } if (cursor.get() != property) { - SetProperty(GetPresContext(), nsLayoutAtoms::lineCursorProperty, + SetProperty(nsLayoutAtoms::lineCursorProperty, cursor.get(), nsnull); } @@ -6059,7 +6073,7 @@ InSiblingList(nsLineList& aLines, nsIFrame* aFrame) } PRBool -nsBlockFrame::IsChild(nsIPresContext* aPresContext, nsIFrame* aFrame) +nsBlockFrame::IsChild(nsIFrame* aFrame) { // Continued out-of-flows don't satisfy InLineList(), continued out-of-flows // and placeholders don't satisfy InSiblingList(). @@ -6081,7 +6095,7 @@ nsBlockFrame::IsChild(nsIPresContext* aPresContext, nsIFrame* aFrame) (skipSiblingList || InSiblingList(mLines, aFrame))) { return PR_TRUE; } - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (overflowLines && (skipLineList || InLineList(*overflowLines, aFrame)) && (skipSiblingList || InSiblingList(*overflowLines, aFrame))) { return PR_TRUE; @@ -6441,7 +6455,7 @@ nsBlockFrame::BuildFloatList() // and not dropped from the frame tree! // Note that overflow lines do not have any float cache set up for them, // because the float cache contains only laid-out floats - nsLineList* overflowLines = GetOverflowLines(GetPresContext(), PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (overflowLines) { head = nsnull; current = nsnull; @@ -6541,11 +6555,11 @@ nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) // list. But its never possible for multiple frames to have overflow // lists. Check that this fact is actually true. void -nsBlockFrame::VerifyOverflowSituation(nsIPresContext* aPresContext) +nsBlockFrame::VerifyOverflowSituation() { nsBlockFrame* flow = (nsBlockFrame*) GetFirstInFlow(); while (nsnull != flow) { - nsLineList* overflowLines = GetOverflowLines(aPresContext, PR_FALSE); + nsLineList* overflowLines = GetOverflowLines(); if (nsnull != overflowLines) { NS_ASSERTION(! overflowLines->empty(), "should not be empty if present"); NS_ASSERTION(overflowLines->front()->mFirstChild, "bad overflow list"); diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h index e69d7382c8c..d46abe28954 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.h +++ b/mozilla/layout/html/base/src/nsBlockFrame.h @@ -541,25 +541,24 @@ protected: //---------------------------------------- - nsLineList* GetOverflowLines(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const; - nsresult SetOverflowLines(nsIPresContext* aPresContext, - nsLineList* aOverflowLines); + nsLineList* GetOverflowLines() const; + nsLineList* RemoveOverflowLines() const; + nsresult SetOverflowLines(nsLineList* aOverflowLines); - nsFrameList* GetOverflowPlaceholders(nsIPresContext* aPresContext, - PRBool aRemoveProperty) const; - nsresult SetOverflowPlaceholders(nsIPresContext* aPresContext, - nsFrameList* aOverflowPlaceholders); + nsFrameList* GetOverflowPlaceholders() const; + nsFrameList* RemoveOverflowPlaceholders() const; + nsresult SetOverflowPlaceholders(nsFrameList* aOverflowPlaceholders); - nsFrameList* GetOverflowOutOfFlows(PRBool aRemoveProperty) const; + nsFrameList* GetOverflowOutOfFlows() const; + nsFrameList* RemoveOverflowOutOfFlows() const; nsresult SetOverflowOutOfFlows(nsFrameList* aFloaters); nsIFrame* LastChild(); #ifdef NS_DEBUG - PRBool IsChild(nsIPresContext* aPresContext, nsIFrame* aFrame); + PRBool IsChild(nsIFrame* aFrame); void VerifyLines(PRBool aFinalCheckOK); - void VerifyOverflowSituation(nsIPresContext* aPresContext); + void VerifyOverflowSituation(); PRInt32 GetDepth() const; #endif diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 0bb569b58c9..5d869b7cbf4 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -1111,10 +1111,10 @@ nsContainerFrame::DeleteNextInFlowChild(nsIPresContext* aPresContext, } #ifdef IBMBIDI - nsIFrame* nextBidi; - prevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, - (void**) &nextBidi,sizeof(nextBidi)); - if (nextBidi == aNextInFlow) { + if ((prevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) && + (NS_STATIC_CAST(nsIFrame*, + prevInFlow->GetProperty(nsLayoutAtoms::nextBidi)) == + aNextInFlow)) { return; } #endif // IBMBIDI diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 83fa1f09d81..0d1a9f9616c 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -4164,10 +4164,8 @@ nsFrame::GetFrameFromDirection(nsIPresContext* aPresContext, nsPeekOffsetStruct else aPos->mStartOffset = -1; #ifdef IBMBIDI - PRUint8 oldLevel, newLevel, baseLevel; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&oldLevel, sizeof(oldLevel)); - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&newLevel, sizeof(newLevel)); - newFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)&baseLevel, sizeof(baseLevel)); + PRUint8 oldLevel = NS_GET_EMBEDDING_LEVEL(this); + PRUint8 newLevel = NS_GET_EMBEDDING_LEVEL(newFrame); if (newLevel & 1) // The new frame is RTL, go to the other end aPos->mStartOffset = -1 - aPos->mStartOffset; @@ -4533,31 +4531,33 @@ nsFrame::IsMouseCaptured(nsIPresContext* aPresContext) return PR_FALSE; } -nsresult -nsFrame::SetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropName, +nsresult +nsIFrame::SetProperty(nsIAtom* aPropName, void* aPropValue, NSFramePropertyDtorFunc aPropDtorFunc) { - return aPresContext->FrameManager()->SetFrameProperty(this, aPropName, - aPropValue, - aPropDtorFunc); + return GetPresContext()->FrameManager()-> + SetFrameProperty(this, aPropName, aPropValue, aPropDtorFunc); } void* -nsFrame::GetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropName, - PRBool aRemoveProp) const +nsIFrame::GetProperty(nsIAtom* aPropName, nsresult* aStatus) const { - PRUint32 options = 0; + return GetPresContext()->FrameManager()-> + GetFrameProperty(this, aPropName, 0, aStatus); +} - if (aRemoveProp) { - options |= NS_IFRAME_MGR_REMOVE_PROP; - } +/* virtual */ void* +nsIFrame::GetPropertyExternal(nsIAtom* aPropName, nsresult* aStatus) const +{ + return GetProperty(aPropName, aStatus); +} - - return aPresContext->FrameManager()->GetFrameProperty(this, aPropName, - options); +void* +nsIFrame::RemoveProperty(nsIAtom* aPropName, nsresult* aStatus) const +{ + return GetPresContext()->FrameManager()-> + GetFrameProperty(this, aPropName, NS_IFRAME_MGR_REMOVE_PROP, aStatus); } /* virtual */ const nsStyleStruct* @@ -4567,50 +4567,6 @@ nsFrame::GetStyleDataExternal(nsStyleStructID aSID) const return mStyleContext->GetStyleData(aSID); } -#ifdef IBMBIDI -/** - * retrieve Bidi property of this frame - * @lina 5/1/2000 - */ - -NS_IMETHODIMP nsFrame::GetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void** aPropertyValue, - size_t aSize) const -{ - if (!aPropertyValue || !aPropertyName) { - return NS_ERROR_NULL_POINTER; - } - if ( (aSize < 1) || (aSize > sizeof(void*) ) ) { - return NS_ERROR_ILLEGAL_VALUE; - } - - memset(aPropertyValue, 0, aSize); - void* val = aPresContext->FrameManager()->GetFrameProperty(this, - aPropertyName, 0); - - if (val) { - // to fix bidi on big endian. We need to copy the right bytes from the void*, not the first aSize bytes. -#if IS_BIG_ENDIAN - memcpy(aPropertyValue, ((char*)&val)+sizeof(void*) - aSize, aSize); -#else - memcpy(aPropertyValue, &val, aSize); -#endif - } - - return NS_OK; -} - -NS_IMETHODIMP nsFrame::SetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue) -{ - return aPresContext->FrameManager()->SetFrameProperty(this, aPropertyName, - aPropertyValue, - nsnull); -} -#endif // IBMBIDI - #ifdef NS_DEBUG static void GetTagName(nsFrame* aFrame, nsIContent* aContent, PRIntn aResultSize, diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index a40bb69c5f4..6b11981bc24 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -387,26 +387,8 @@ public: NS_IMETHOD CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents); PRBool IsMouseCaptured(nsIPresContext* aPresContext); - virtual void* GetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - PRBool aRemoveProperty) const; - - virtual nsresult SetProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue, - NSFramePropertyDtorFunc aPropDtorFunc); - virtual const nsStyleStruct* GetStyleDataExternal(nsStyleStructID aSID) const; -#ifdef IBMBIDI - NS_IMETHOD GetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void** aPropertyValue, - size_t aSize ) const; - NS_IMETHOD SetBidiProperty(nsIPresContext* aPresContext, - nsIAtom* aPropertyName, - void* aPropertyValue) ; -#endif // IBMBIDI #ifdef NS_DEBUG /** diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index a8d7cdd988c..39dba393cb0 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -61,7 +61,6 @@ #include "nsHTMLAtoms.h" #include "nsTextFragment.h" #include "nsBidiUtils.h" -#define FIX_FOR_BUG_40882 #ifdef DEBUG #undef NOISY_HORIZONTAL_ALIGN @@ -1043,16 +1042,17 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, !textContent->IsOnlyWhitespace()); // fix for bug 40882 #ifdef IBMBIDI - const nsTextFragment* frag = textContent->Text(); - if (frag->Is2b()) { - //PRBool isVisual; - //mPresContext->IsVisualMode(isVisual); - PRUnichar ch = /*(isVisual) ? - *(frag->Get2b() + frag->GetLength() - 1) :*/ *frag->Get2b(); - if (IS_BIDI_DIACRITIC(ch)) { - aFrame->SetBidiProperty(mPresContext, - nsLayoutAtoms::endsInDiacritic, - NS_INT32_TO_PTR(ch)); + if (mPresContext->BidiEnabled()) { + const nsTextFragment* frag = textContent->Text(); + if (frag->Is2b()) { + //PRBool isVisual; + //mPresContext->IsVisualMode(isVisual); + PRUnichar ch = /*(isVisual) ? + *(frag->Get2b() + frag->GetLength() - 1) :*/ *frag->Get2b(); + if (IS_BIDI_DIACRITIC(ch)) { + aFrame->SetProperty(nsLayoutAtoms::endsInDiacritic, + NS_INT32_TO_PTR(ch)); + } } } #endif // IBMBIDI diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 3a8030ffb19..77638042f7b 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -877,20 +877,17 @@ nsContinuingTextFrame::Init(nsIPresContext* aPresContext, PRInt32 start, end; aPrevInFlow->GetOffsets(start, mContentOffset); - void* value; - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, &value,sizeof(value)); - SetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, value); + SetProperty(nsLayoutAtoms::embeddingLevel, + aPrevInFlow->GetProperty(nsLayoutAtoms::embeddingLevel)); + SetProperty(nsLayoutAtoms::baseLevel, + aPrevInFlow->GetProperty(nsLayoutAtoms::baseLevel)); + SetProperty(nsLayoutAtoms::charType, + aPrevInFlow->GetProperty(nsLayoutAtoms::charType)); - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, &value,sizeof(value)); - SetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, value); - - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::charType, &value,sizeof(value)); - SetBidiProperty(aPresContext, nsLayoutAtoms::charType, value); - - aPrevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, &value,sizeof(value)); + void* value = aPrevInFlow->GetProperty(nsLayoutAtoms::nextBidi); if (value) { // nextBidi // aPrevInFlow and this frame will point to the same next bidi frame. - SetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, value); + SetProperty(nsLayoutAtoms::nextBidi, value); ( (nsIFrame*) value)->GetOffsets(start, end); mContentLength = PR_MAX(1, start - mContentOffset); @@ -1384,13 +1381,13 @@ nsTextFrame::CharacterDataChanged(nsIPresContext* aPresContext, while (textFrame) { textFrame->mState |= NS_FRAME_IS_DIRTY; #ifdef IBMBIDI - nsIFrame* nextBidi; - textFrame->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &nextBidi,sizeof(nextBidi)); - if (nextBidi) - textFrame = (nsTextFrame*)nextBidi; + void* nextBidiFrame; + if ((textFrame->mState & NS_FRAME_IS_BIDI) && + (nextBidiFrame = textFrame->GetProperty(nsLayoutAtoms::nextBidi))) + textFrame = (nsTextFrame*)nextBidiFrame; else #endif - textFrame = (nsTextFrame*)textFrame->mNextInFlow; + textFrame = (nsTextFrame*)textFrame->mNextInFlow; } } @@ -2187,7 +2184,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, PRInt16 selectionValue; nsCOMPtr lb; #ifdef IBMBIDI - PRUint8 level = 0; + PRBool isOddLevel = PR_FALSE; #endif @@ -2240,8 +2237,8 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, nsCharType charType = eCharType_LeftToRight; if (aPresContext->BidiEnabled()) { isBidiSystem = aPresContext->IsBidiSystem(); - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**) &level,sizeof(level)); - GetBidiProperty(aPresContext, nsLayoutAtoms::charType, (void**) &charType,sizeof(charType)); + isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; + charType = (nsCharType)NS_PTR_TO_INT32(GetProperty(nsLayoutAtoms::charType)); isRightToLeftOnBidiPlatform = (isBidiSystem && (eCharType_RightToLeft == charType || @@ -2259,7 +2256,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, PRInt32 rememberTextLength = textLength; #endif bidiUtils->ReorderUnicodeText(text, textLength, - charType, level & 1, isBidiSystem); + charType, isOddLevel, isBidiSystem); NS_ASSERTION(rememberTextLength == textLength, "Bidi formatting changed text length"); } } @@ -2336,7 +2333,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext, } #endif /* SUNCTL */ #ifdef IBMBIDI - AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), level & 1, isBidiSystem); + AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), isOddLevel, isBidiSystem); #endif sdptr = sdptr->mNext; } @@ -2504,9 +2501,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, } #ifdef IBMBIDI // Simon -- reverse RTL text here - PRUint8 level; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - PRBool isOddLevel = (level & 1); + PRBool isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; if (isOddLevel) { PRUnichar *tStart, *tEnd; PRUnichar tSwap; @@ -2931,7 +2926,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, if (0 != textLength) { #ifdef IBMBIDI - PRUint8 level = 0; + PRBool isOddLevel = PR_FALSE; nsCharType charType = eCharType_LeftToRight; if (aPresContext->BidiEnabled()) { @@ -2939,16 +2934,14 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, aPresContext->GetBidiUtils(&bidiUtils); if (bidiUtils) { - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, - (void**) &level,sizeof(level)); - GetBidiProperty(aPresContext, nsLayoutAtoms::charType, - (void**) &charType,sizeof(charType)); + isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; + charType = (nsCharType)NS_PTR_TO_INT32(GetProperty(nsLayoutAtoms::charType)); #ifdef DEBUG PRInt32 rememberTextLength = textLength; #endif // Since we paint char by char, handle the text like on non-bidi platform bidiUtils->ReorderUnicodeText(text, textLength, charType, - level & 1, PR_FALSE); + isOddLevel, PR_FALSE); NS_ASSERTION(rememberTextLength == textLength, "Bidi formatting changed text length"); } } @@ -2990,7 +2983,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext, sdptr->mStart = ip[sdptr->mStart] - mContentOffset; sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; #ifdef IBMBIDI - AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), level & 1, PR_FALSE); + AdjustSelectionPointsForBidi(sdptr, textLength, CHARTYPE_IS_RTL(charType), isOddLevel, PR_FALSE); #endif sdptr = sdptr->mNext; } @@ -3428,10 +3421,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, PRUnichar* text = paintBuffer.mBuffer; #ifdef IBMBIDI - PRBool getReversedPos = PR_FALSE; - PRUint8 level = 0; - GetBidiProperty(aCX, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - getReversedPos = level & 1; + PRBool getReversedPos = NS_GET_EMBEDDING_LEVEL(this) & 1; nscoord posX = (getReversedPos) ? (mRect.width + origin.x) - (aPoint.x - origin.x) : aPoint.x; @@ -3673,8 +3663,9 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext, break; } #ifdef IBMBIDI - GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &frame,sizeof(frame)); - if (frame) { + if ((mState & NS_FRAME_IS_BIDI) && + (frame = NS_STATIC_CAST(nsIFrame*, + GetProperty(nsLayoutAtoms::nextBidi)))) { frame->SetSelected(aPresContext, aRange, aSelected, aSpread); } #endif // IBMBIDI @@ -3776,10 +3767,7 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext, } } #ifdef IBMBIDI - PRUint8 level; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - - if (level & 1) { + if (NS_GET_EMBEDDING_LEVEL(this) & 1) { outPoint->x = mRect.width - width; } else @@ -3865,10 +3853,7 @@ NS_IMETHODIMP nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) { #ifdef IBMBIDI - PRUint8 level, baseLevel; - GetBidiProperty(aPresContext, nsLayoutAtoms::embeddingLevel, (void**)&level,sizeof(level)); - GetBidiProperty(aPresContext, nsLayoutAtoms::baseLevel, (void**)&baseLevel,sizeof(baseLevel)); - PRBool isOddLevel = (level & 1); + PRBool isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1; if ((eSelectCharacter == aPos->mAmount) || (eSelectWord == aPos->mAmount)) @@ -3886,7 +3871,8 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) nsIFrame *nextInFlow; #ifdef IBMBIDI if (isOddLevel) { - GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &nextInFlow,sizeof(nextInFlow)); + nextInFlow = NS_STATIC_CAST(nsIFrame*, + GetProperty(nsLayoutAtoms::nextBidi)); } else #endif @@ -4547,7 +4533,8 @@ nsTextFrame::MeasureText(nsIPresContext* aPresContext, PRInt32 start = -1, end; if (mState & NS_FRAME_IS_BIDI) { - GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi, (void**) &nextBidi,sizeof(nextBidi)); + nextBidi = NS_STATIC_CAST(nsTextFrame*, + GetProperty(nsLayoutAtoms::nextBidi)); if (nextBidi) { if (mContentLength < 1) { @@ -5187,7 +5174,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext, nsCharType charType = eCharType_LeftToRight; PRUint32 hints = 0; aReflowState.rendContext->GetHints(hints); - GetBidiProperty(aPresContext, nsLayoutAtoms::charType, (void**)&charType, sizeof(charType)); + charType = (nsCharType)NS_PTR_TO_INT32(GetProperty(nsLayoutAtoms::charType)); if ((eCharType_RightToLeftArabic == charType && (hints & NS_RENDERING_HINT_ARABIC_SHAPING) == NS_RENDERING_HINT_ARABIC_SHAPING) || (eCharType_RightToLeft == charType && diff --git a/mozilla/layout/html/base/src/nsTextTransformer.cpp b/mozilla/layout/html/base/src/nsTextTransformer.cpp index c1727dacf19..43f709e9d59 100644 --- a/mozilla/layout/html/base/src/nsTextTransformer.cpp +++ b/mozilla/layout/html/base/src/nsTextTransformer.cpp @@ -227,8 +227,7 @@ nsTextTransformer::Init(nsIFrame* aFrame, * We do numeric shaping in all Bidi documents. */ if (mPresContext->BidiEnabled()) { - aFrame->GetBidiProperty(mPresContext, nsLayoutAtoms::charType, - (void**)&mCharType, sizeof(mCharType)); + mCharType = (nsCharType)NS_PTR_TO_INT32(aFrame->GetProperty(nsLayoutAtoms::charType)); if (mCharType == eCharType_RightToLeftArabic) { if (aForceArabicShaping) { SetNeedsArabicShaping(PR_TRUE);