<?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>23248</bug_id>
          
          <creation_ts>2009-01-12 02:07:50 -0800</creation_ts>
          <short_desc>CSS class change result in inconsistent layout</short_desc>
          <delta_ts>2022-07-11 16:38:53 -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>525.x (Safari 3.2)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam Wu">Adam_5Wu</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>robert</cc>
    
    <cc>stalcup</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>105315</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Wu">Adam_5Wu</who>
    <bug_when>2009-01-12 02:07:50 -0800</bug_when>
    <thetext>As shown in the sample html:

The element &lt;label&gt; initially has a class name &quot;Top&quot;, which is associated to style &quot;display: block&quot;; this makes the label displayed above the text input;

Then, by clicking on the &quot;Right&quot; button, the class name of the label is reassigned to &quot;Right&quot;, which is associated to style &quot;float: right&quot;. The label now should be displayed on the same line with the text input, to the right; but on Safari 3.2.1, the label is still displayed above the text input, and become right aligned.

However, again on Safari 3.2.1, if the &quot;Left&quot; button (which has no style associated to it) is clicked first (essentially removes style &quot;display: block&quot;), then the &quot;Right&quot; button, the label&apos;s layout is rendered as expected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105316</commentid>
    <comment_count>1</comment_count>
      <attachid>26628</attachid>
    <who name="Adam Wu">Adam_5Wu</who>
    <bug_when>2009-01-12 02:10:00 -0800</bug_when>
    <thetext>Created attachment 26628
Sample html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105317</commentid>
    <comment_count>2</comment_count>
    <who name="Adam Wu">Adam_5Wu</who>
    <bug_when>2009-01-12 02:14:02 -0800</bug_when>
    <thetext>Google Chrome (1.0.154) also has the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110351</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-02-19 23:11:09 -0800</bug_when>
    <thetext>Confirmed with r41058; this is not a regression from Safari/WebKit 3.2.1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110405</commentid>
    <comment_count>4</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2009-02-20 10:19:34 -0800</bug_when>
    <thetext>This bug is tricky.

The layout issue is basically caused by our inability to compute the correct m_maxPrefWidth for a rendering like this:

&lt;div style=&quot;position:absolute&quot;&gt;
&lt;div style=&quot;float:right&quot;&gt;Hello&lt;/div&gt;
&lt;div&gt;&lt;input type=text&gt;&lt;/div&gt;
&lt;/div&gt;

It&apos;s hard for us to tell whether the float is going to fit into the next block in calcBlockPrefWidths.

In the real test case attached to the bug, the initial display:block on the first div causes us to create an anonymous block to wrap the input field.  When the first div is switched to just being floating instead, we could technically revert back to being inline again and remove the anonymous block (pulling its kids back up).

So either trying to fix maxPrefWidth or trying to make anonymous blocks go away properly when float/position changes would fix the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111127</commentid>
    <comment_count>5</comment_count>
    <who name="Neelima">neelima.web</who>
    <bug_when>2009-02-25 23:55:25 -0800</bug_when>
    <thetext>I have done some analysis on this bug. 
1)I found issue in Node::Diff()
I have done some changes in Node::Diff () by adding one more condition, which will detach the previous node with their respective properties and again attach with new properties to the node.
Node::StyleChange Node::diff( RenderStyle *s1, RenderStyle *s2 )
{
.........
.........
else  if (*s1 != *s2)
    ch = Detach; 
	OR
else  if (display1 == display2 || fl1 == fl2 ||
 (s1 &amp;&amp; s2 &amp;&amp; s1-&gt;contentDataEquivalent(s2)))
	ch = Detach;
.........
.........
}
	I have tested and the fix seems to be working fine. Kindly let me know whether this is a correct approach?

2)Need Clarification: I tried with another approach to resolve the same issue.
Whenever  select  from left to right or Right to Top, the style is setting to Block level in CSSStyleSelectos::adjustRenderStylefunction() of  CSSStyleSelector.cpp,  I had  tried to change ‘setDisplay’ value to inline for the ‘case :Top to Right’ but it’s not working. I found that in CSSStyleSelectos::adjustRenderStylefunction() , they are forcefully setting inline-level roots to  be block-level , if someone attempts to float an inline. See the below code:
void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
{
// Mutate the display to BLOCK or TABLE for certain cases, e.g., if //someone attempts to position or float an inline, compact, or run-in.  //Cache the original display, since it may be needed for positioned //elements that have to compute their static normal flow positions.  //We also force inline-level roots to be block-level.
if (style-&gt;display() != BLOCK &amp;&amp; style-&gt;display() != TABLE &amp;&amp; style-&gt;display() != BOX &amp;&amp; (style-&gt;position() == AbsolutePosition || style-&gt;position() == FixedPosition || style-&gt;floating() != FNONE ||
             (e &amp;&amp; e-&gt;document()-&gt;documentElement() == e))) {
            if (style-&gt;display() == INLINE_TABLE)
                style-&gt;setDisplay(TABLE);
            else if (style-&gt;display() == INLINE_BOX)
                style-&gt;setDisplay(BOX);
            else if (style-&gt;display() == LIST_ITEM) {
  // It is a WinIE bug that floated list items lose their //bullets, so we&apos;ll emulate the quirk, but only in quirks mode.
                if (!m_checker.m_strictParsing &amp;&amp; style-&gt;floating() != FNONE)
                    style-&gt;setDisplay(BLOCK);
            }
else
         style-&gt;setDisplay(BLOCK); // This part of code is getting hit when I					// change from left to right or right to top 
	

        }
Please let me know why it has been done like this?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>379154</commentid>
    <comment_count>6</comment_count>
    <who name="john stalcup">stalcup</who>
    <bug_when>2011-04-04 15:53:01 -0700</bug_when>
    <thetext>this bug appears to be fixed now</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>732888</commentid>
    <comment_count>7</comment_count>
    <who name="Robert Hogan">robert</who>
    <bug_when>2012-10-02 11:43:28 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; this bug appears to be fixed now

No, it&apos;s still valid.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1882215</commentid>
    <comment_count>8</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2022-07-11 16:38:53 -0700</bug_when>
    <thetext>Safari, Chrome, and Firefox show the same rendering behavior for this test case. I do not believe any further compatibility issue remains.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>26628</attachid>
            <date>2009-01-12 02:10:00 -0800</date>
            <delta_ts>2009-01-12 02:10:00 -0800</delta_ts>
            <desc>Sample html</desc>
            <filename>Test.html</filename>
            <type>text/html</type>
            <size>1025</size>
            <attacher name="Adam Wu">Adam_5Wu</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgU3RyaWN0Ly9FTiIg
Imh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXN0cmljdC5kdGQiPg0KPGh0
bWwgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiIHhtbDpsYW5nPSJlbiIgbGFu
Zz0iZW4iPg0KICA8aGVhZD4NCiAgICA8dGl0bGU+RmxvYXQgY2xhc3MgdGVzdDwvdGl0bGU+DQog
ICAgPHN0eWxlPg0KICAgICAgbGFiZWwuVG9wIHsNCiAg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