Bug 581536 - Part 2: Reconstruct the document element frames when the dir attribute is set on the document; r=bzbarsky a=blocking-betaN+
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 15 Dec 2010 12:26:54 -0800
changeset 61102 80df95979d3af65c8501c29d41dc86d941c5a2e4
parent 61101 f3432e1de08529930142e00a7da7519955ff5e24
child 61103 7294ab636e1d10985ac01d53ecbd1cd21e59b645
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky, blocking-betaN
bugs581536
milestone2.0b10pre
Bug 581536 - Part 2: Reconstruct the document element frames when the dir attribute is set on the document; r=bzbarsky a=blocking-betaN+
layout/base/nsFrameManager.cpp
layout/base/nsPresContext.cpp
layout/reftests/forms/reftest.list
layout/reftests/forms/textarea-in-dynamic-rtl-doc.html
layout/reftests/forms/textarea-rtl-dynamic-attr.html
layout/reftests/forms/textarea-rtl-dynamic-style.html
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -979,17 +979,19 @@ CaptureChange(nsStyleContext* aOldContex
 {
   nsChangeHint ourChange = aOldContext->CalcStyleDifference(aNewContext);
   NS_ASSERTION(!(ourChange & nsChangeHint_ReflowFrame) ||
                (ourChange & nsChangeHint_NeedReflow),
                "Reflow hint bits set without actually asking for a reflow");
 
   NS_UpdateHint(ourChange, aChangeToAssume);
   if (NS_UpdateHint(aMinChange, ourChange)) {
-    aChangeList->AppendChange(aFrame, aContent, ourChange);
+    if (!(ourChange & nsChangeHint_ReconstructFrame) || aContent) {
+      aChangeList->AppendChange(aFrame, aContent, ourChange);
+    }
   }
   return aMinChange;
 }
 
 /**
  * Recompute style for aFrame and accumulate changes into aChangeList
  * given that aMinChange is already accumulated for an ancestor.
  * aParentContent is the content node used to resolve the parent style
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1457,18 +1457,21 @@ nsPresContext::SetBidi(PRUint32 aSource,
     SetVisualMode(PR_FALSE);
   }
   else {
     nsIDocument* doc = mShell->GetDocument();
     if (doc) {
       SetVisualMode(IsVisualCharset(doc->GetDocumentCharacterSet()));
     }
   }
-  if (aForceRestyle) {
-    RebuildAllStyleData(NS_STYLE_HINT_REFLOW);
+  if (aForceRestyle && mShell) {
+    // Reconstruct the root document element's frame and its children,
+    // because we need to trigger frame reconstruction for direction change.
+    RebuildUserFontSet();
+    mShell->ReconstructFrames();
   }
 }
 
 PRUint32
 nsPresContext::GetBidi() const
 {
   return Document()->GetBidiOptions();
 }
--- a/layout/reftests/forms/reftest.list
+++ b/layout/reftests/forms/reftest.list
@@ -17,16 +17,17 @@ HTTP(..) == text-control-baseline-1.html
 skip-if(winWidget) == textarea-resize-background.html textarea-resize-background-ref.html
 != textarea-ltr.html textarea-rtl.html
 != textarea-ltr-scrollbar.html textarea-rtl-scrollbar.html
 != textarea-in-ltr-doc-scrollbar.html textarea-in-rtl-doc-scrollbar.html
 != textarea-ltr.html textarea-no-resize.html
 != textarea-rtl.html textarea-no-resize.html
 == textarea-rtl.html textarea-rtl-dynamic-attr.html
 == textarea-rtl.html textarea-rtl-dynamic-style.html
+== textarea-rtl.html textarea-in-dynamic-rtl-doc.html
 == textarea-setvalue-framereconstruction-1.html textarea-setvalue-framereconstruction-ref.html
 
 == radio-label-dynamic.html radio-label-dynamic-ref.html
 == out-of-bounds-selectedindex.html out-of-bounds-selectedindex-ref.html # test for bug 471741
 != indeterminate-checked.html indeterminate-checked-notref.html
 != indeterminate-unchecked.html indeterminate-unchecked-notref.html
 != indeterminate-native-checked.html indeterminate-native-checked-notref.html
 != indeterminate-native-unchecked.html indeterminate-native-unchecked-notref.html
copy from layout/reftests/forms/textarea-rtl.html
copy to layout/reftests/forms/textarea-in-dynamic-rtl-doc.html
--- a/layout/reftests/forms/textarea-rtl.html
+++ b/layout/reftests/forms/textarea-in-dynamic-rtl-doc.html
@@ -1,10 +1,18 @@
 <!DOCTYPE HTML>
-<html>
+<html class="reftest-wait">
  <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <title></title>
  </head>
- <body>
-  <textarea dir="rtl" cols=20 rows=4></textarea>
+ <body style="text-align: left">
+  <textarea cols=20 rows=4></textarea>
+  <script>
+    onload = function() {
+      setTimeout(function() {
+        document.dir = "rtl";
+        document.documentElement.removeAttribute("class");
+      });
+    };
+  </script>
  </body>
 </html>