Set baseLevel and paraLevel properties on empty frames. Bug 489887, r+sr=roc
authorSimon Montagu <smontagu@smontagu.org>
Tue, 28 Apr 2009 02:23:53 -0700
changeset 27869 37f01fdbb22e90774f95da1f4ff56be809134139
parent 27868 5a8a199bd62aeadef2cfe34a585630c22033111e
child 27870 c6fe0a8a592990097c3f98d8eb7e3d8fa125bea0
push idunknown
push userunknown
push dateunknown
bugs489887
milestone1.9.2a1pre
Set baseLevel and paraLevel properties on empty frames. Bug 489887, r+sr=roc
layout/base/nsBidiPresUtils.cpp
layout/reftests/bidi/489887-1-ref.html
layout/reftests/bidi/489887-1.html
layout/reftests/bidi/reftest.list
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -397,16 +397,23 @@ nsBidiPresUtils::Resolve(nsBlockFrame*  
         content = frame->GetContent();
         if (!content) {
           mSuccess = NS_OK;
           break;
         }
         contentTextLength = content->TextLength();
         if (contentTextLength == 0) {
           frame->AdjustOffsetsForBidi(0, 0);
+          // Set the base level and embedding level of the current run even
+          // on an empty frame. Otherwise frame reordering will not be correct.
+          propTable->SetProperty(frame, nsGkAtoms::embeddingLevel,
+                                 NS_INT32_TO_PTR(embeddingLevel),
+                                 nsnull, nsnull);
+          propTable->SetProperty(frame, nsGkAtoms::baseLevel,
+                                 NS_INT32_TO_PTR(paraLevel), nsnull, nsnull);
           continue;
         }
         PRInt32 start, end;
         frame->GetOffsets(start, end);
         fragmentLength = end - start;
         contentOffset = start;
         isTextFrame = PR_TRUE;
       } // if text frame
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bidi/489887-1-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/javascript">
+function boom()
+{
+  document.getElementById("w").firstChild.data = "";
+
+}
+</script>
+</head>
+<body onload="boom();">
+<div><span>&#x06cd;</span><span id="w"> </span><span>&#x06cb;</span></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bidi/489887-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/javascript">
+function boom()
+{
+  document.getElementById("w").firstChild.data = "";
+  document.documentElement.appendChild(document.body);
+}
+</script>
+</head>
+<body onload="boom();">
+<div><span>&#x06cd;</span><span id="w"> </span><span>&#x06cb;</span></div>
+</body>
+</html>
--- a/layout/reftests/bidi/reftest.list
+++ b/layout/reftests/bidi/reftest.list
@@ -31,8 +31,9 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") ==
 == 409375.html 409375-ref.html
 == 413542-1.html 413542-1-ref.html
 == 413542-2.html 413542-2-ref.html
 == 413928-1.html 413928-1-ref.html
 == 413928-2.html 413928-2-ref.html
 == 425338-1a.html 425338-1-ref.html
 == 425338-1b.html 425338-1-ref.html
 == 489517-1.html 489517-1-ref.html
+== 489887-1.html 489887-1-ref.html