From de2fa93bc535e47e28cfdd4d5e853048ebba22ab Mon Sep 17 00:00:00 2001 From: "mats.palmgren%bredband.net" Date: Sun, 6 May 2007 10:29:58 +0000 Subject: [PATCH] Incremental reflow bug with direction:rtl and bidi-override. b=375716 r=uriber sr=dbaron --- layout/base/nsBidiPresUtils.cpp | 30 +++++++++++++------------- layout/reftests/bugs/375716-1-ref.html | 18 ++++++++++++++++ layout/reftests/bugs/375716-1.html | 24 +++++++++++++++++++++ layout/reftests/bugs/reftest.list | 1 + 4 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 layout/reftests/bugs/375716-1-ref.html create mode 100644 layout/reftests/bugs/375716-1.html diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index e9262fced84..0ae7df2a8e9 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -485,7 +485,6 @@ nsBidiPresUtils::InitLogicalArray(nsPresContext* aPresContext, PRBool aAddMarkers) { nsIFrame* frame; - nsIFrame* directionalFrame; nsresult res = NS_OK; nsIPresShell* shell = aPresContext->PresShell(); @@ -494,11 +493,10 @@ nsBidiPresUtils::InitLogicalArray(nsPresContext* aPresContext, for (frame = aCurrentFrame; frame && frame != aNextInFlow; frame = frame->GetNextSibling()) { - directionalFrame = nsnull; + PRUnichar ch = 0; if (aAddMarkers && - frame->IsFrameOfType(nsIFrame::eBidiInlineContainer) && - !frame->GetPrevContinuation()) { + frame->IsFrameOfType(nsIFrame::eBidiInlineContainer)) { const nsStyleVisibility* vis = frame->GetStyleVisibility(); const nsStyleTextReset* text = frame->GetStyleTextReset(); switch (text->mUnicodeBidi) { @@ -508,28 +506,31 @@ nsBidiPresUtils::InitLogicalArray(nsPresContext* aPresContext, styleContext = frame->GetStyleContext(); if (NS_STYLE_DIRECTION_RTL == vis->mDirection) { - directionalFrame = NS_NewDirectionalFrame(shell, styleContext, kRLE); + ch = kRLE; } else if (NS_STYLE_DIRECTION_LTR == vis->mDirection) { - directionalFrame = NS_NewDirectionalFrame(shell, styleContext, kLRE); + ch = kLRE; } break; case NS_STYLE_UNICODE_BIDI_OVERRIDE: styleContext = frame->GetStyleContext(); if (NS_STYLE_DIRECTION_RTL == vis->mDirection) { - directionalFrame = NS_NewDirectionalFrame(shell, styleContext, kRLO); + ch = kRLO; } else if (NS_STYLE_DIRECTION_LTR == vis->mDirection) { - directionalFrame = NS_NewDirectionalFrame(shell, styleContext, kLRO); + ch = kLRO; } break; } // Create a directional frame before the first frame of an // element specifying embedding or override - if (directionalFrame) { - mLogicalFrames.AppendElement(directionalFrame); + if (ch != 0 && !frame->GetPrevContinuation()) { + nsIFrame* dirFrame = NS_NewDirectionalFrame(shell, styleContext, ch); + if (dirFrame) { + mLogicalFrames.AppendElement(dirFrame); + } } } @@ -551,13 +552,12 @@ nsBidiPresUtils::InitLogicalArray(nsPresContext* aPresContext, } // If the element is attributed by dir, indicate direction pop (add PDF frame) - if (directionalFrame && !frame->GetNextContinuation()) { - directionalFrame = NS_NewDirectionalFrame(shell, styleContext, kPDF); - + if (ch != 0 && !frame->GetNextContinuation()) { // Create a directional frame after the last frame of an // element specifying embedding or override - if (directionalFrame) { - mLogicalFrames.AppendElement(directionalFrame); + nsIFrame* dirFrame = NS_NewDirectionalFrame(shell, styleContext, kPDF); + if (dirFrame) { + mLogicalFrames.AppendElement(dirFrame); } } } // for diff --git a/layout/reftests/bugs/375716-1-ref.html b/layout/reftests/bugs/375716-1-ref.html new file mode 100644 index 00000000000..4128dea4b78 --- /dev/null +++ b/layout/reftests/bugs/375716-1-ref.html @@ -0,0 +1,18 @@ + +Bug 375716 - Incremental reflow bug with direction: rtl and bidi-override + + +
+ +text text text text +‮text text text text text‬ +text + +
+ diff --git a/layout/reftests/bugs/375716-1.html b/layout/reftests/bugs/375716-1.html new file mode 100644 index 00000000000..48622405df7 --- /dev/null +++ b/layout/reftests/bugs/375716-1.html @@ -0,0 +1,24 @@ + +Bug 375716 - Incremental reflow bug with direction: rtl and bidi-override + + + +
+ +text text text text +text text text text text +text + +
+ diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 23eeb2d93a7..066ab91512b 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -222,6 +222,7 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 372037-1.html 372037-1-ref.html # bug 3 == 374038-1.xul 374038-1-ref.xul == 374038-2.xul 374038-2-ref.xul == 374193-1.xhtml about:blank +== 375716-1.html 375716-1-ref.html == 376484-1.html 376484-1-ref.html == 377603-1.html 377603-1-ref.html == 378535-1.html 378535-1-ref.html