<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>179754</bug_id>
          
          <creation_ts>2017-11-16 01:34:31 -0800</creation_ts>
          <short_desc>firstLineBaseline called on non-laid out cell content during HTML table layout</short_desc>
          <delta_ts>2017-11-16 01:34:31 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tables</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=174131</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Frédéric Wang Nélar">fred.wang</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>alex</cc>
    
    <cc>jfernandez</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1372554</commentid>
    <comment_count>0</comment_count>
      <attachid>327053</attachid>
    <who name="Frédéric Wang Nélar">fred.wang</who>
    <bug_when>2017-11-16 01:34:31 -0800</bug_when>
    <thetext>Created attachment 327053
Testcase

This was originally reported in bug 174131 for RenderMathMLScripts::firstLineBaseline which is the only implementation asserting !needsLayout(). However, it turns out that this not specific to MathML, so I&apos;m opening it here so that people more familiar with HTML table layout can comment. Actually, the use of firstLineBaseline in MathML is really an implementation detail inherited from the old flexbox-based approach and we might change it in the future, see for example bug 155879.

Basically, RenderTableCell::layout() starts with the following line:

    int oldCellBaseline = cellBaselinePosition();
    layoutBlock(cellWidthChanged)

Then cellBaselinePosition() calls RenderBlockFlow::firstLineBaseline before the layout of the cell, which in turn may call RenderBlock::firstLineBaseline (if !childrenInline()) which will finally call firstLineBaseline on children. But these children are non laid out either.

Here are the firstLineBaseline implementations:

 find -type f -name &apos;*.h&apos; | xargs grep firstLineBaseline
./RenderBox.h:    virtual std::optional&lt;int&gt; firstLineBaseline() const { return std::optional&lt;int&gt;(); }
./RenderBlock.h:    std::optional&lt;int&gt; firstLineBaseline() const override;
./RenderTableSection.h:    std::optional&lt;int&gt; firstLineBaseline() const override;
./RenderTable.h:    std::optional&lt;int&gt; firstLineBaseline() const override;
./RenderMenuList.h:    std::optional&lt;int&gt; firstLineBaseline() const override { return RenderBlock::firstLineBaseline(); }
./RenderFlexibleBox.h:    std::optional&lt;int&gt; firstLineBaseline() const override;
./RenderTextControl.h:    std::optional&lt;int&gt; firstLineBaseline() const override { return RenderBlock::firstLineBaseline(); }
./RenderGrid.h:    std::optional&lt;int&gt; firstLineBaseline() const final;
./RenderBlockFlow.h:    std::optional&lt;int&gt; firstLineBaseline() const override;
./mathml/RenderMathMLOperator.h:    std::optional&lt;int&gt; firstLineBaseline() const final;
./mathml/RenderMathMLRow.h:    std::optional&lt;int&gt; firstLineBaseline() const override;
./mathml/RenderMathMLSpace.h:    std::optional&lt;int&gt; firstLineBaseline() const final;
./mathml/RenderMathMLToken.h:    std::optional&lt;int&gt; firstLineBaseline() const override;
./mathml/RenderMathMLFraction.h:    std::optional&lt;int&gt; firstLineBaseline() const final;
./mathml/RenderMathMLScripts.h:    std::optional&lt;int&gt; firstLineBaseline() const final;
./mathml/RenderMathMLPadded.h:    std::optional&lt;int&gt; firstLineBaseline() const final;
./mathml/RenderMathMLBlock.h:        return child.firstLineBaseline().value_or(child.logicalHeight());
./mathml/RenderMathMLBlock.h:    std::optional&lt;int&gt; firstLineBaseline() const final;

The attached testcase will hit many of these functions with needsLayout() == false.

The question is: is it OK to get firstLineBaseline on boxes that are non laid out yet? Maybe it&apos;s fine to return a dummy value for the initial &quot;oldCellBaseline&quot;. Or maybe we should explicitly do an early return with a null optional (that&apos;s what happen for RenderFlexibleBox and RenderGrid implementations in the testcase) so that cellBaselinePosition() will use the fallback value instead of the wrong value? Maybe this special handling can just happen for RenderTableCell and all the other implementations should ASSERT(!needsLayout())? Any other idea?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>327053</attachid>
            <date>2017-11-16 01:34:31 -0800</date>
            <delta_ts>2017-11-16 01:34:31 -0800</delta_ts>
            <desc>Testcase</desc>
            <filename>firstLineBaseline-before-layout.html</filename>
            <type>text/html</type>
            <size>3540</size>
            <attacher name="Frédéric Wang Nélar">fred.wang</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPmZpcnN0TGluZUJhc2Vs
aW5lIGJlZm9yZSBsYXlvdXQ8L3RpdGxlPgogICAgPG1ldGEgY2hhcnNldD0idXRmLTgiLz4KICAg
IDxzdHlsZT4KICAgICAgLmZsZXggewogICAgICAgIGRpc3BsYXk6IGZsZXg7CiAgICAgIH0KICAg
ICAgLmdyaWQgewogICAgICAgIGRpc3BsYXk6IGdyaWQ7CiAgICAgICAgZ3JpZC10ZW1wbGF0ZS1j
b2x1bW5zOiAxMDBweCAxMDBweCAxMDBweDsKICAgICAgICBncmlkLWdhcDogMTBweDsKICAgICAg
ICBiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmOwogICAgICAgIGNvbG9yOiAjNDQ0OwogICAgICB9CiAg
ICAgIC5ib3ggewogICAgICAgIGJhY2tncm91bmQtY29sb3I6ICM0NDQ7CiAgICAgICAgY29sb3I6
ICNmZmY7CiAgICAgICAgYm9yZGVyLXJhZGl1czogNXB4OwogICAgICAgIHBhZGRpbmc6IDIwcHg7
CiAgICAgICAgZm9ud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CSAgICAgIDxkaXYgY2xhc3M9ImJv
eCI+RTwvZGl2PgoJICAgICAgPGRpdiBjbGFzcz0iYm94Ij5GPC9kaXY+CgkgICAgPC9kaXY+CiAg
ICAgICAgICA8L3RkPgogICAgICAgIDwvdHI+CiAgICAgIDwvdGFibGU+CiAgICA8L3A+CgogICAg
PHA+UmVuZGVyTWF0aE1MT3BlcmF0b3I6CiAgICAgIDx0YWJsZT4KICAgICAgICA8dHI+CiAgICAg
ICAgICA8dGQ+CiAgICAgICAgICAgIDxtYXRoIGRpc3BsYXk9ImJsb2NrIj4KICAgICAgICAgICAg
ICA8bXRleHQ+QTwvbXRleHQ+CiAgICAgICAgICAgIDwvbWF0aD4KICAgICAgICAgIDwvdGQ+CiAg
ICAgICAgPC90cj4KICAgICAgPC90YWJsZT4KICAgIDwvcD4KCiAgICA8cD5SZW5kZXJNYXRoTUxS
b3c6CiAgICAgIDx0YWJsZT4KICAgICAgICA8dHI+CiAgICAgICAgICA8dGQ+CiAgICAgICAgICAg
IDxtYXRoIGRpc3BsYXk9ImJsb2NrIj48L21hdGg+CiAgICAgICAgICA8L3RkPgogICAgICAgIDwv
dHI+CiAgICAgIDwvdGFibGU+CiAgICA8L3A+CgogICAgPHA+UmVuZGVyTWF0aE1MU3BhY2U6CiAg
ICAgIDx0YWJsZT4KICAgICAgICA8dHI+CiAgICAgICAgICA8dGQ+CiAgICAgICAgICAgIDxtYXRo
IGRpc3BsYXk9ImJsb2NrIj4KICAgICAgICAgICAgICA8bXNwYWNlIGhlaWdodD0iMTBweCIgZGVw
dGg9IjMwcHgiPjwvbXNwYWNlPgogICAgICAgICAgICA8L21hdGg+CiAgICAgICAgICA8L3RkPgog
ICAgICAgIDwvdHI+CiAgICAgIDwvdGFibGU+CiAgICA8L3A+CiAgICAKICAgIDxwPlJlbmRlck1h
dGhNTFRva2VuOgogICAgICA8dGFibGU+CiAgICAgICAgPHRyPgogICAgICAgICAgPHRkPgogICAg
ICAgICAgICA8bWF0aCBkaXNwbGF5PSJibG9jayI+CiAgICAgICAgICAgICAgPG10ZXh0PkE8L210
ZXh0PgogICAgICAgICAgICA8L21hdGg+CiAgICAgICAgICA8L3RkPgogICAgICAgIDwvdHI+CiAg
ICAgIDwvdGFibGU+CiAgICA8L3A+CgogICAgPHA+UmVuZGVyTWF0aE1MRnJhY3Rpb246CiAgICAg
IDx0YWJsZT4KICAgICAgICA8dHI+CiAgICAgICAgICA8dGQ+CiAgICAgICAgICAgIDxtYXRoIGRp
c3BsYXk9ImJsb2NrIj4KICAgICAgICAgICAgICA8bWZyYWM+CiAgICAgICAgICAgICAgICA8bWk+
QTwvbWk+CiAgICAgICAgICAgICAgICA8bWk+QjwvbWk+CiAgICAgICAgICAgICAgPC9tZnJhYz4K
ICAgICAgICAgICAgPC9tYXRoPgogICAgICAgICAgPC90ZD4KICAgICAgICA8L3RyPgogICAgICA8
L3RhYmxlPgogICAgPC9wPgoKICAgIDxwPlJlbmRlck1hdGhNTFNjcmlwdHM6CiAgICAgIDx0YWJs
ZT4KICAgICAgICA8dHI+CiAgICAgICAgICA8dGQ+CiAgICAgICAgICAgIDxtYXRoIGRpc3BsYXk9
ImJsb2NrIj4KICAgICAgICAgICAgICA8bXN1Yj4KICAgICAgICAgICAgICAgIDxtaT5BPC9taT4K
ICAgICAgICAgICAgICAgIDxtaT5CPC9taT4KICAgICAgICAgICAgICA8L21zdWI+CiAgICAgICAg
ICAgIDwvbWF0aD4KICAgICAgICAgIDwvdGQ+CiAgICAgICAgPC90cj4KICAgICAgPC90YWJsZT4K
ICAgIDwvcD4KCiAgICA8cD5SZW5kZXJNYXRoTUxQYWRkZWQ6CiAgICAgIDx0YWJsZT4KICAgICAg
ICA8dHI+CiAgICAgICAgICA8dGQ+CiAgICAgICAgICAgIDxtYXRoIGRpc3BsYXk9ImJsb2NrIj4K
ICAgICAgICAgICAgICA8bXBhZGRlZCBoZWlnaHQ9IjEwcHgiIGRlcHRoPSIzMHB4Ij48L21wYWRk
ZWQ+CiAgICAgICAgICAgIDwvbWF0aD4KICAgICAgICAgIDwvdGQ+CiAgICAgICAgPC90cj4KICAg
ICAgPC90YWJsZT4KICAgIDwvcD4KCiAgICA8cD5SZW5kZXJNYXRoTUxCbG9jayAoaW52YWxpZCBt
YXJrdXApOgogICAgICA8dGFibGU+CiAgICAgICAgPHRyPgogICAgICAgICAgPHRkPgogICAgICAg
ICAgICA8bWF0aCBkaXNwbGF5PSJibG9jayI+CiAgICAgICAgICAgICAgPG1mcmFjPgogICAgICAg
ICAgICAgICAgPG1pPng8L21pPgogICAgICAgICAgICAgIDwvbWZyYWM+CiAgICAgICAgICAgIDwv
bWF0aD4KICAgICAgICAgIDwvdGQ+CiAgICAgICAgPC90cj4KICAgICAgPC90YWJsZT4KICAgIDwv
cD4KCiAgICA8cD5SZW5kZXJNYXRoTUxUYWJsZToKICAgICAgPHRhYmxlPgogICAgICAgIDx0cj4K
ICAgICAgICAgIDx0ZD4KICAgICAgICAgICAgPG1hdGggZGlzcGxheT0iYmxvY2siPgogICAgICAg
ICAgICAgIDxtdGFibGU+PC9tdGFibGU+CiAgICAgICAgICAgIDwvbWF0aD4KICAgICAgICAgIDwv
dGQ+CiAgICAgICAgPC90cj4KICAgICAgPC90YWJsZT4KICAgIDwvcD4KCiAgPC9ib2R5Pgo8L2h0
bWw+CgoK
</data>

          </attachment>
      

    </bug>

</bugzilla>