<?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>100507</bug_id>
          
          <creation_ts>2012-10-26 05:06:54 -0700</creation_ts>
          <short_desc>Progress bar shadow tree sometimes is not relayouted.</short_desc>
          <delta_ts>2012-10-29 02:18:01 -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>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>83664</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>0</everconfirmed>
          <reporter name="Andrey Khalyavin">halyavin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>tasak</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>751908</commentid>
    <comment_count>0</comment_count>
      <attachid>170899</attachid>
    <who name="Andrey Khalyavin">halyavin</who>
    <bug_when>2012-10-26 05:06:54 -0700</bug_when>
    <thetext>Created attachment 170899
test page

Progress bar shadow tree sometimes is not relayouted.
Steps to reproduce:
1. Open page in attachment.
2. Click on a button.
3. See that first bar is updated while second bar is not.

What is going on behind the cover:
HTMLProgressElement has a shadow tree which consist in 3 nested divs. The most nested div (HTMLProgressElement::m_value) represents progress bar value and is updated by HTMLProgressElement::didElementStateChange method.

When javascripts on the page sets the second progress bar value, m_value node loses IsStyleAttributeValidFlag flag. Then &lt;progress&gt; element is inserted into tree and InDocumentFlag is set in m_value. Then Element::recalcStyle is called on HTMLProgressElement and it executes reattach method for it. Method reattach calls attach and as result m_value receives IsAttachedFlag. Then HTMLProgressElement::attach calls didElementStateChange method which calls m_value-&gt;setWidthPercentage which sets InlineStyleChange flag to m_value node and ChildNeedsStyleRecalc flag to all its parent nodes. But then reattach methods returns and Element::recalcStyle calls clearNeedsStyleRecalc and clearChildNeedsStyleRecalc methods on HTMLProgressElement node. 

So now we have m_value node that needs style recalculation but HTMLProgressElement node doesn&apos;t have ChildNeedsStyleRecalcFlag flag. As a result, any subsequent changes to progress element doesn&apos;t do anything since m_value is already marked as needed to recalculate style. But m_value never recalculates style since HTMLProgressElement doesn&apos;t have ChildNeedsRecalcFlag.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>753180</commentid>
    <comment_count>1</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2012-10-29 02:18:01 -0700</bug_when>
    <thetext>The reason why progress bar is not re-layouted is:
- HTMLProgressElement updates inline styles, i.e. setWidthPercentage, in HTMLProgressElement::attach().
- Element::recalcStyle updates HTMLProgressElement&apos;s style by using &quot;reattach()&quot;.

Element::reaclcStyle()
...
            // FIXME: The style gets computed twice by calling attach. We could do better if we passed the style along.
            reattach();
            // attach recalculates the style for all children. No need to do it twice.
            clearNeedsStyleRecalc();
            clearChildNeedsStyleRecalc();
...

So after reattach(), clearNeedsStyleRecalc() and clearChildNeedsStyleRecalc() reset update flags set by setWidthPercentage. Now ProgressValueElement has had &quot;InlineStyleChange&quot; style change type, but its relayout flag is cleared. This disables &quot;setNeedsStyleRecalc&quot; to relayout:

void Node::setNeedsStyleRecalc(...)
...
    if (existingChangeType == NoStyleChange)
        markAncestorsWithChildNeedsStyleRecalc();
...

I will fix this issue by bug 83664.

Best regards,
Takashi Sakamoto

*** This bug has been marked as a duplicate of bug 83664 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>170899</attachid>
            <date>2012-10-26 05:06:54 -0700</date>
            <delta_ts>2012-10-26 05:06:54 -0700</delta_ts>
            <desc>test page</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>758</size>
            <attacher name="Andrey Khalyavin">halyavin</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3Jp
cHQiPgogIGZ1bmN0aW9uIGFkZF9wcm9ncmVzc19iYXIoKQogIHsKICAgIGJhZCA9IGRvY3VtZW50
LmNyZWF0ZUVsZW1lbnQoInByb2dyZXNzIik7CiAgICBiYWQuaWQ9ImJhZCI7CiAgICBiYWQuc2V0
QXR0cmlidXRlKCJtaW4iLDApOwogICAgYmFkLm1heD0xMDA7CgogICAgYmFkLnNldEF0dHJpYnV0
ZSgidmFsdWUiLDEwKTsgICAgICAgICAgICAgICAgIC8vUHJvYmxlbSBsaW5lIDEKICAgIGJhZC5z
ZXRBdHRyaWJ1dGUoInN0eWxlIiwgImJvcmRlcjpzb2xpZCByZWQiKTsgLy9Qcm9ibGVtIGxpbmUg
MgoKICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCdib2R5JylbMF0uYXBwZW5kQ2hp
bGQoYmFkKTsKICB9CgogIGZ1bmN0aW9uIGNoYW5nZV92YWx1ZSgpCiAgewogICAgZG9jdW1lbnQu
Z2V0RWxlbWVudEJ5SWQoJ2dvb2QnKS52YWx1ZSA9IDUwOwogICAgZG9jdW1lbnQuZ2V0RWxlbWVu
dEJ5SWQoJ2JhZCcpLnZhbHVlID0gNTA7CiAgfQo8L3NjcmlwdD4KPC9oZWFkPgoKPGJvZHkgb25s
b2FkPSJhZGRfcHJvZ3Jlc3NfYmFyKCk7Ij4KICAgIDxidXR0b24gb25jbGljaz0iY2hhbmdlX3Zh
bHVlKCk7Ij5DbGljazwvYnV0dG9uPgoKICAgIDxwcm9ncmVzcyBpZD0iZ29vZCIgbWluPSIwIiBt
YXg9IjEwMCIgdmFsdWU9IjEwIiBzdHlsZT0iYm9yZGVyOnNvbGlkIHJlZCI+PC9wcm9ncmVzcz4K
PC9ib2R5PgoKPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>