<?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>24511</bug_id>
          
          <creation_ts>2009-03-11 04:54:47 -0700</creation_ts>
          <short_desc>Computed style margins calculated incorrectly for sized elements.</short_desc>
          <delta_ts>2010-04-17 11:54:43 -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>420+</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>13343</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="Nigel White">nigelw</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>alex</cc>
    
    <cc>ap</cc>
    
    <cc>jameskay</cc>
    
    <cc>jonathan</cc>
    
    <cc>nigelw</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>113162</commentid>
    <comment_count>0</comment_count>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-03-11 04:54:47 -0700</bug_when>
    <thetext>This affects Safari 4 beta, and Chrome 0.4

When an element is explicitly sized within another sized element, so that there is empty space to its right, the *computed style* returned for the inner element&apos;s margin-right value is the width of that empty space.

This is not correct. That&apos;s just empty space.

To illustrate, I have included a very simple  test page.

It uses the ExtJs library just as a vehicle to get the computed style. It has an Element class which encapsulates a DOM element, and this offers a getMargins method which requests the *computed&quot; style for the element.

To run this example, download the ExtJs SDK. Drop this page into examples/&lt;any directory&gt;

On Webkit based browsers, the red DIV reports its left+right margin total to be 300

On Firefox, it is correctly reported as zero.

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Margin bug&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;../../adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;../../ext-all.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
Ext.onReady(function() {
	var inner = Ext.get(&quot;inner&quot;);
	var m = inner.getMargins(&apos;lr&apos;);
	inner.update(&apos;My left+right margins are &apos; + m);
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;div id=&quot;outer&quot; style=&quot;height:300px;width:500px;border:1px solid black&quot;&gt;
	&lt;div id=&quot;inner&quot; style=&quot;height:200px;width:200px;background-color:red&quot;&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113184</commentid>
    <comment_count>1</comment_count>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-03-11 08:00:19 -0700</bug_when>
    <thetext>Of course It affects Chrome 2.* too. I just updated Chrome from the latest build channel.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122663</commentid>
    <comment_count>2</comment_count>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-05-22 07:46:28 -0700</bug_when>
    <thetext>Is this not an outrageously bad bug?!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123109</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Monahan">jonathan</who>
    <bug_when>2009-05-26 02:03:28 -0700</bug_when>
    <thetext>*** This bug has been confirmed by popular vote. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>147045</commentid>
    <comment_count>4</comment_count>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-09-14 07:04:03 -0700</bug_when>
    <thetext>Any progress on this one?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>152635</commentid>
    <comment_count>5</comment_count>
      <attachid>40706</attachid>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-10-06 03:11:05 -0700</bug_when>
    <thetext>Created attachment 40706
So simple. Just run it. It gets the computed margins WRONG!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>152636</commentid>
    <comment_count>6</comment_count>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-10-06 03:11:50 -0700</bug_when>
    <thetext>The simple test:

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Margin bug&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
runTest = function() {
    var inner = document.getElementById(&quot;inner&quot;);
    var lm = parseInt(document.defaultView.getComputedStyle(inner, null).marginLeft, 10);
    var rm = parseInt(document.defaultView.getComputedStyle(inner, null).marginRight, 10);
    var m = lm + rm;
    inner.innerHTML =&apos;My left+right margins are &apos; + m;
};
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;runTest();&quot;&gt;
&lt;div id=&quot;outer&quot; style=&quot;height:300px;width:500px;border:1px solid black&quot;&gt;
    &lt;div id=&quot;inner&quot; style=&quot;height:200px;width:200px;background-color:red&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>167552</commentid>
    <comment_count>7</comment_count>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-12-01 03:02:32 -0800</bug_when>
    <thetext>HEY!

Can we have some action on this?!

This is a BUG and a bad one!

It simply reports a completely erroneous margin value. SO we cannot work out how much space is taken up by an element including its margins!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>167906</commentid>
    <comment_count>8</comment_count>
    <who name="James Kay">jameskay</who>
    <bug_when>2009-12-02 00:31:41 -0800</bug_when>
    <thetext>I&apos;d like to add my &quot;voice&quot; to this: please would someone take a look?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>167955</commentid>
    <comment_count>9</comment_count>
    <who name="Nigel White">nigelw</who>
    <bug_when>2009-12-02 04:12:58 -0800</bug_when>
    <thetext>This is a duplicate of https://bugs.webkit.org/show_bug.cgi?id=13343 which has
several people waiting on it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>213604</commentid>
    <comment_count>10</comment_count>
    <who name="Alexander Willner">alex</who>
    <bug_when>2010-04-17 08:30:00 -0700</bug_when>
    <thetext>According Chromium bug report: http://code.google.com/p/chromium/issues/detail?id=23816</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>213640</commentid>
    <comment_count>11</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-04-17 11:54:32 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; This is a duplicate of https://bugs.webkit.org/show_bug.cgi?id=13343

Thanks, marking as such.

*** This bug has been marked as a duplicate of bug 13343 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>40706</attachid>
            <date>2009-10-06 03:11:05 -0700</date>
            <delta_ts>2009-10-06 03:11:05 -0700</delta_ts>
            <desc>So simple. Just run it. It gets the computed margins WRONG!</desc>
            <filename>margin-bug.html</filename>
            <type>text/html</type>
            <size>644</size>
            <attacher name="Nigel White">nigelw</attacher>
            
              <data encoding="base64">PGh0bWw+DQo8aGVhZD4NCjx0aXRsZT5NYXJnaW4gYnVnPC90aXRsZT4NCjxzY3JpcHQgdHlwZT0i
dGV4dC9qYXZhc2NyaXB0Ij4NCnJ1blRlc3QgPSBmdW5jdGlvbigpIHsNCiAgICB2YXIgaW5uZXIg
PSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiaW5uZXIiKTsNCiAgICB2YXIgbG0gPSBwYXJzZUlu
dChkb2N1bWVudC5kZWZhdWx0Vmlldy5nZXRDb21wdXRlZFN0eWxlKGlubmVyLCBudWxsKS5tYXJn
aW5MZWZ0LCAxMCk7DQogICAgdmFyIHJtID0gcGFyc2VJbnQoZG9jdW1lbnQuZGVmYXVsdFZpZXcu
Z2V0Q29tcHV0ZWRTdHlsZShpbm5lciwgbnVsbCkubWFyZ2luUmlnaHQsIDEwKTsNCiAgICB2YXIg
bSA9IGxtICsgcm07DQogICAgaW5uZXIuaW5uZXJIVE1MID0nTXkgbGVmdCtyaWdodCBtYXJnaW5z
IGFyZSAnICsgbTsNCn07DQo8L3NjcmlwdD4NCjwvaGVhZD4NCjxib2R5IG9ubG9hZD0icnVuVGVz
dCgpOyI+DQo8ZGl2IGlkPSJvdXRlciIgc3R5bGU9ImhlaWdodDozMDBweDt3aWR0aDo1MDBweDti
b3JkZXI6MXB4IHNvbGlkIGJsYWNrIj4NCiAgICA8ZGl2IGlkPSJpbm5lciIgc3R5bGU9ImhlaWdo
dDoyMDBweDt3aWR0aDoyMDBweDtiYWNrZ3JvdW5kLWNvbG9yOnJlZCI+PC9kaXY+DQo8L2Rpdj4N
CjwvYm9keT4NCjwvaHRtbD4=
</data>

          </attachment>
      

    </bug>

</bugzilla>