<?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>140542</bug_id>
          
          <creation_ts>2015-01-16 03:38:18 -0800</creation_ts>
          <short_desc>::first-line skips out-of-flow elements but doesn&apos;t affect the next block</short_desc>
          <delta_ts>2022-07-24 13:55:23 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>140541</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Manuel Rego Casasnovas">rego</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>koivisto</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1061803</commentid>
    <comment_count>0</comment_count>
      <attachid>244759</attachid>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2015-01-16 03:38:18 -0800</bug_when>
    <thetext>Created attachment 244759
Example to reproduce the issue

First bug #140541 should be fixed, but this issue was present before (Safari 7) and it&apos;s still present in Blink (https://code.google.com/p/chromium/issues/detail?id=449475).

Example (attached) to reproduce the issue (&quot;Green&quot; should be green and &quot;Black&quot; should be black):
&lt;style&gt;
    .first-line-green::first-line {
        color: lime;
    }

    .float {
        float: left;
    }
&lt;/style&gt;
&lt;div class=&quot;first-line-green&quot;&gt;
    &lt;div class=&quot;float&quot;&gt;
        Black
    &lt;/div&gt;
    &lt;div&gt;Green&lt;/div&gt;
&lt;/div&gt;

In the example the text &quot;Green&quot; appears in black.

Once bug #140541 is fixed, this problem might be probably because of &quot;::first-line&quot; skips the floated element as expected, but it doesn&apos;t select the &quot;Green&quot; text because of it&apos;s not the first child.
Probably it&apos;s due to the condition &quot;parentBlock-&gt;firstChild() != firstLineBlock&quot; in RenderBlock::firstLineBlock() (but if you remove this condition other simple cases will fail):
    if (firstLineBlock-&gt;isReplaced() || firstLineBlock-&gt;isFloating()
        || !parentBlock || parentBlock-&gt;firstChild() != firstLineBlock || !isRenderBlockFlowOrRenderButton(*parentBlock))
        break;

However, if you remove the &quot;&lt;div&gt;&quot; wrapping &quot;Green&quot; it worked as expected (once bug #140541 is fixed it&apos;ll work as expected):
&lt;style&gt;
    .first-line-green::first-line {
        color: lime;
    }

    .float {
        float: left;
    }
&lt;/style&gt;
&lt;div class=&quot;first-line-green&quot;&gt;
    &lt;div class=&quot;float&quot;&gt;
        Black
    &lt;/div&gt;
    Green
&lt;/div&gt;

BTW, the same happens if you use a positioned element.

From the spec (http://www.w3.org/TR/css3-selectors/#first-formatted-line):
&quot;The first formatted line of an element may occur inside a block-level descendant in the same flow (i.e., a block-level descendant that is not out-of-flow due to floating or positioning). For example, the first line of the DIV in &lt;DIV&gt;&lt;P&gt;This line...&lt;/P&gt;&lt;/DIV&gt; is the first line of the P (assuming that both P and DIV are block-level).&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886364</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-07-24 10:24:34 -0700</bug_when>
    <thetext>I am able to reproduce this bug in Safari 15.6 on macOS 12.5 using attached test case and the output is &quot;BlackGreen&quot; text as Black and it matches with Firefox Nightly 104 which also show this text as &quot;Black&quot; except Chrome Canary 106, which show &quot;Green&quot; from text string as &quot;Green&quot;.

I am not clear on web-spec so I don&apos;t know which browser is showing correct behavior but I just wanted to share updated testing results. Thanks!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>244759</attachid>
            <date>2015-01-16 03:38:18 -0800</date>
            <delta_ts>2015-01-16 03:38:18 -0800</delta_ts>
            <desc>Example to reproduce the issue</desc>
            <filename>first-line-float.html</filename>
            <type>text/html</type>
            <size>229</size>
            <attacher name="Manuel Rego Casasnovas">rego</attacher>
            
              <data encoding="base64">PHN0eWxlPgogICAgLmZpcnN0LWxpbmUtZ3JlZW46OmZpcnN0LWxpbmUgewogICAgICAgIGNvbG9y
OiBsaW1lOwogICAgfQoKICAgIC5mbG9hdCB7CiAgICAgICAgZmxvYXQ6IGxlZnQ7CiAgICB9Cjwv
c3R5bGU+CjxkaXYgY2xhc3M9ImZpcnN0LWxpbmUtZ3JlZW4iPgogICAgPGRpdiBjbGFzcz0iZmxv
YXQiPgogICAgICAgIEJsYWNrCiAgICA8L2Rpdj4KICAgIDxkaXY+R3JlZW48L2Rpdj4KPC9kaXY+
Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>