Bug 1520722 Part 1 - Remove NS_BLOCK_NEEDS_BIDI_RESOLUTION flag from ColumnSpanWrapperFrame. r=dbaron
authorTing-Yu Lin <aethanyc@gmail.com>
Thu, 31 Jan 2019 20:19:19 +0000
changeset 456390 506261cc5d79c01c770fcb2e9d450ba8e92c98b1
parent 456389 b325e24cae399094ec4f704a64905014b386bfae
child 456391 1617ad03a14ef357d9e68c103f9291ea8982759a
push id19
push usermdeboer@mozilla.com
push dateFri, 01 Feb 2019 10:05:45 +0000
reviewersdbaron
bugs1520722
milestone67.0a1
Bug 1520722 Part 1 - Remove NS_BLOCK_NEEDS_BIDI_RESOLUTION flag from ColumnSpanWrapperFrame. r=dbaron Calling nsBlockFrame::ResolveBidi() on ColumnSpanWrapperFrame may cause nsColumnSetFrame's non-fluid continuations being converted into fluid ones in JoinInlineAncestors(). Since ColumnSpanWrapperFrame can only have nsColumnSetFrame and column-span wrappers kids, no need to perform bidi resolution. This doesn't affect column contents because they'll inherit "unicode-bidi" from ColumnSetWrapperFrame in ua.css. Differential Revision: https://phabricator.services.mozilla.com/D17550
layout/generic/ColumnSetWrapperFrame.cpp
layout/generic/ColumnSetWrapperFrame.h
testing/web-platform/meta/css/css-multicol/multicol-span-all-008.html.ini
testing/web-platform/tests/css/css-multicol/multicol-span-all-008-ref.html
testing/web-platform/tests/css/css-multicol/multicol-span-all-008.html
--- a/layout/generic/ColumnSetWrapperFrame.cpp
+++ b/layout/generic/ColumnSetWrapperFrame.cpp
@@ -28,16 +28,25 @@ NS_IMPL_FRAMEARENA_HELPERS(ColumnSetWrap
 
 NS_QUERYFRAME_HEAD(ColumnSetWrapperFrame)
   NS_QUERYFRAME_ENTRY(ColumnSetWrapperFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
 
 ColumnSetWrapperFrame::ColumnSetWrapperFrame(ComputedStyle* aStyle)
     : nsBlockFrame(aStyle, kClassID) {}
 
+void ColumnSetWrapperFrame::Init(nsIContent* aContent,
+                                 nsContainerFrame* aParent,
+                                 nsIFrame* aPrevInFlow) {
+  nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
+
+  // ColumnSetWrapperFrame doesn't need to call ResolveBidi().
+  RemoveStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
+}
+
 nsContainerFrame* ColumnSetWrapperFrame::GetContentInsertionFrame() {
   nsIFrame* columnSet = PrincipalChildList().OnlyChild();
   if (columnSet) {
     // We have only one child, which means we don't have any column-span
     // descendants. Thus we can safely return our only ColumnSet child's
     // insertion frame as ours.
     MOZ_ASSERT(columnSet->IsColumnSetFrame());
     return columnSet->GetContentInsertionFrame();
@@ -122,16 +131,26 @@ void ColumnSetWrapperFrame::InsertFrames
 }
 
 void ColumnSetWrapperFrame::RemoveFrame(ChildListID aListID,
                                         nsIFrame* aOldFrame) {
   MOZ_ASSERT_UNREACHABLE("Unsupported operation!");
   nsBlockFrame::RemoveFrame(aListID, aOldFrame);
 }
 
+void ColumnSetWrapperFrame::MarkIntrinsicISizesDirty() {
+  nsBlockFrame::MarkIntrinsicISizesDirty();
+
+  // The parent's method adds NS_BLOCK_NEEDS_BIDI_RESOLUTION to all our
+  // continuations. Clear the bit because we don't want to call ResolveBidi().
+  for (nsIFrame* f = FirstContinuation(); f; f = f->GetNextContinuation()) {
+    f->RemoveStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
+  }
+}
+
 #ifdef DEBUG
 
 /* static */ void ColumnSetWrapperFrame::AssertColumnSpanWrapperSubtreeIsSane(
     const nsIFrame* aFrame) {
   MOZ_ASSERT(aFrame->IsColumnSpan(), "aFrame is not column-span?");
 
   if (!nsLayoutUtils::GetStyleFrame(const_cast<nsIFrame*>(aFrame))
            ->Style()
--- a/layout/generic/ColumnSetWrapperFrame.h
+++ b/layout/generic/ColumnSetWrapperFrame.h
@@ -27,31 +27,36 @@ class ColumnSetWrapperFrame final : publ
  public:
   NS_DECL_FRAMEARENA_HELPERS(ColumnSetWrapperFrame)
   NS_DECL_QUERYFRAME
 
   friend nsBlockFrame* ::NS_NewColumnSetWrapperFrame(nsIPresShell* aPresShell,
                                                      ComputedStyle* aStyle,
                                                      nsFrameState aStateFlags);
 
+  void Init(nsIContent* aContent, nsContainerFrame* aParent,
+            nsIFrame* aPrevInFlow) override;
+
   nsContainerFrame* GetContentInsertionFrame() override;
 
   void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
 
 #ifdef DEBUG_FRAME_DUMP
   nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
   void AppendFrames(ChildListID aListID, nsFrameList& aFrameList) override;
 
   void InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
                     nsFrameList& aFrameList) override;
 
   void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override;
 
+  void MarkIntrinsicISizesDirty() override;
+
  private:
   explicit ColumnSetWrapperFrame(ComputedStyle* aStyle);
   ~ColumnSetWrapperFrame() override = default;
 
 #ifdef DEBUG
   static void AssertColumnSpanWrapperSubtreeIsSane(const nsIFrame* aFrame);
 
   // True if frame constructor has finished building this frame and all of
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/css/css-multicol/multicol-span-all-008.html.ini
@@ -0,0 +1,2 @@
+[multicol-span-all-008.html]
+  prefs: [layout.css.column-span.enabled:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-multicol/multicol-span-all-008-ref.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+  <meta charset="utf-8">
+  <title>CSS Multi-column Layout Test Reference: Test a bidi-override multi-column container with a dir=rtl column-span:all child</title>
+  <link rel="author" title="Ting-Yu Lin" href="tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="http://www.mozilla.org/">
+
+  <style>
+  body {
+    column-count: 1;
+    column-rule: 6px solid;
+    width: 400px;
+    outline: 1px solid black;
+  }
+  h3 {
+    /* "column-count: 1" makes this behave like a real spanner. */
+    outline: 1px solid blue;
+  }
+  </style>
+
+  <body>
+    <div>block1</div>
+    <h3 dir="rtl">spanner</h3>
+    <div>block2</div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-multicol/multicol-span-all-008.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+  <meta charset="utf-8">
+  <title>CSS Multi-column Layout Test: Test a bidi-override multi-column container with a dir=rtl column-span:all child</title>
+  <link rel="author" title="Ting-Yu Lin" href="tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="http://www.mozilla.org/">
+  <link rel="help" href="https://drafts.csswg.org/css-multicol-1/#column-span">
+  <link rel="match" href="multicol-span-all-008-ref.html">
+  <meta name="assert" content="This test checks the page is rendered correctly for a bidi-override multi-column container with a dir=rtl column-span:all child.">
+
+  <style>
+  article {
+    column-count: 3;
+    column-rule: 6px solid;
+    width: 400px;
+    outline: 1px solid black;
+    unicode-bidi: bidi-override; /* Needed to trigger bidi resolution. */
+  }
+  h3 {
+    column-span: all;
+    outline: 1px solid blue;
+  }
+  </style>
+
+  <article>
+    <div>block1</div>
+    <h3 dir="rtl">spanner</h3>
+    <div>block2</div>
+  </article>
+</html>