<?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>273219</bug_id>
          
          <creation_ts>2024-04-24 16:06:31 -0700</creation_ts>
          <short_desc>Stop TextIterator from checking margin when adding double newlines after &lt;p&gt;</short_desc>
          <delta_ts>2024-04-27 07:02:11 -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>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>176776</dup_id>
          
          <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="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2031012</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-24 16:06:31 -0700</bug_when>
    <thetext>Hi Team,

While looking into Blink commits, I noticed the test expectation changes between our current vs Blink and noticed that we don&apos;t have this merged / aligned:

Blink Commit: https://chromium.googlesource.com/chromium/src.git/+/8ff781cd5c1aabca068247de9a3f143645e80422

I took following test as example: fast/css-generated-content/hover-inline-expected.txt (See from source.chromium.org vs GitHub webkit repo) - Chrome / Blink adds additional space.

WebKit Source: https://github.com/WebKit/WebKit/blob/983b6c8a16f0fbe166336a0c9653cd8eca72f639/Source/WebCore/editing/TextIterator.cpp#L929

___

In above, if I do following:

Current:

RefPtr element = dynamicDowncast&lt;HTMLElement&gt;(node);
    if (!element || (!hasHeaderTag(*element) &amp;&amp; !is&lt;HTMLParagraphElement&gt;(*element)))
        return false;

to:

RefPtr element = dynamicDowncast&lt;HTMLElement&gt;(node);
    if (is&lt;HTMLParagraphElement&gt;(*element))
        return true;

    if (!element || !hasHeaderTag(*element))
        return false;

___

In debug build, it leads to following &apos;assert&apos; while running WPT test (e.g., https://wpt.fyi/results/html/dom/elements/the-innertext-and-outertext-properties/getter.html?label=master&amp;label=experimental&amp;aligned&amp;q=innertext)

ASSERTION FAILED: m_ptr
/Users/ahmadsaleem/Documents/GitHub/WebKit/WebKitBuild/Debug/usr/local/include/wtf/RefPtr.h(68) : T &amp;WTF::RefPtr&lt;WebCore::HTMLElement&gt;::operator*() const [T = WebCore::HTMLElement, _PtrTraits = WTF::RawPtrTraits&lt;WebCore::HTMLElement&gt;, _RefDerefTraits = WTF::DefaultRefDerefTraits&lt;WebCore::HTMLElement&gt;]
2024-04-24 19:45:05.336 MiniBrowser[43249:479598] WebContent process crashed; reloading

___

Just wanted to raise so we can track and fix it.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2031026</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-24 16:35:38 -0700</bug_when>
    <thetext>We can just change this whole function to follow like this:

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/iterators/text_iterator.cc;l=702?q=the-innertext-idl-attribute

and it will or might progress few WPT tests in: https://wpt.fyi/results/html/dom/elements/the-innertext-and-outertext-properties/getter.html?label=master&amp;label=experimental&amp;aligned&amp;q=innertext</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2031030</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-24 16:53:12 -0700</bug_when>
    <thetext>This progresses six tests without leading to crashes:

static bool shouldEmitExtraNewlineForNode(Node&amp; node)
{
    // https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
    // // Append two required linebreaks after a &lt;p&gt; element.

    CheckedPtr renderBox = dynamicDowncast&lt;RenderBox&gt;(node.renderer());
    if (!renderBox || !renderBox-&gt;height())
        return false;

    return node.hasTagName(pTag);
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2031675</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-27 07:02:11 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 176776 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>