<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>138394</bug_id>
          
          <creation_ts>2006-12-05 16:58:16 +0000</creation_ts>
          <short_desc>Computed line-height is incorrect</short_desc>
          <delta_ts>2006-12-05 19:31:32 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>konqueror</product>
          <component>kjs</component>
          <version>unspecified</version>
          <rep_platform>Ubuntu</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Mark Wubben">bugs+konq</reporter>
          <assigned_to name="Konqueror Bugs">konqueror-bugs-null</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>491742</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Wubben">bugs+konq</who>
    <bug_when>2006-12-05 16:58:16 +0000</bug_when>
    <thetext>Version:            (using KDE KDE 3.5.5)
Installed from:    Ubuntu Packages
OS:                Linux

When retrieving the line-height of an element from it&apos;s computed style, Konqueror returns a value of 8.05306e+08px instead of the actual line-height. To query for the computed line-height of a certain node:

document.defaultView.getComputedStyle(node, null)[&apos;lineHeight&apos;]

An example can be found at &lt;http://tests.novemberborn.net/sifr3/experiments/tuning/line-height.html&gt;. Here the line-height is 8px, but it should be equal the &quot;working height&quot; of 13 px as it is in other browsers. Of course, if you change the font size, the heights should change as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491745</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Wubben">bugs+konq</who>
    <bug_when>2006-12-05 16:59:55 +0000</bug_when>
    <thetext>This is Konqueror 3.5.5.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491753</commentid>
    <comment_count>2</comment_count>
      <attachid>18803</attachid>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-12-05 17:47:42 +0000</bug_when>
    <thetext>Created attachment 18803
patch, that&apos;s what the checkbox means; silly bugzilal

OK, this is one cut at trying to fix it, just using the renderer&apos;s computation
instead of trying to replicate it. Allan or Germain, could you take a look?

A couple comments, though:
1) Seems like we don&apos;t support pseudo-elements for getComputedStyle at all?
2) CSS2.1 has the following:
&quot;&lt;number&gt; 
The used value of the property is this number multiplied by the element&apos;s font
size. Negative values are illegal. The computed value is the same as the
specified value.&quot;

In particular, this suggests that e.g. line-height: 0.5 should have computed
value 0.5. Now firefox returns the pixel height, and opera 9 doesn&apos;t seem to
understand this syntax at all (computed value is &quot;normal&quot;, no effect on
rendering) --- and if I am not mis-understanding the meaning of the term, I&apos;d
think the spec language is kinda suspect here; wouldn&apos;t the px value be the
more useful computed value?

3) I am not sure I like the whole interoperation of RenderStyle and
RenderObject here (and this diff kind of underlines this, using both for the
&apos;normal&apos; case); but this is getting outside my area, so...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491756</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Wubben">bugs+konq</who>
    <bug_when>2006-12-05 17:58:23 +0000</bug_when>
    <thetext>Maksim, thanks for looking into this.

In the specific test case mentioned above I&apos;m using a 1em value, which inherits the font size [1]. This is a specific need for my program, and it works great on Firefox, Safari and Opera.

[1]: http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491762</commentid>
    <comment_count>4</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-12-05 18:17:48 +0000</bug_when>
    <thetext>Thanks for the link, it explains things --- so normally the computed values are inherited, and &quot;used values&quot; are used? And, actually, looking through the code (but not testing) I think the renderer handles it right, and this explains the split of responsibility in the code a lot better. I think I&apos;ll revise the patch... though I am not sure I want to return the specified value for number height in JS --- it&apos;s always risky to follow the spec over market leaders..
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491764</commentid>
    <comment_count>5</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-12-05 18:34:11 +0000</bug_when>
    <thetext>Doh, I am a moron. This is much, much, simpler than I thought --- I should have noticed the e08 in your message, and not just the 8px in the output. 
Fix upcoming, and it&apos;s trivial.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491765</commentid>
    <comment_count>6</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-12-05 18:36:11 +0000</bug_when>
    <thetext>SVN commit 610820 by orlovich:

Make sure to use the value() in computation, and not
the internal _length which also merges in the bitfields for type(!!!)
Also add some (likely somewhat excessive) comments explaining what the code
is doing.
BUG:138394


 M  +8 -3      css_renderstyledeclarationimpl.cpp  


--- branches/KDE/3.5/kdelibs/khtml/css/css_renderstyledeclarationimpl.cpp #610819:610820
@@ -666,16 +666,21 @@
         return new CSSPrimitiveValueImpl(style-&gt;letterSpacing(), CSSPrimitiveValue::CSS_PX);
     case CSS_PROP_LINE_HEIGHT:
     {
+        // Note: internally a specified &lt;number&gt; value gets encoded as a percentage,
+        // so the isPercent() case corresponds to the &lt;number&gt; case; 
+        // values &lt; 0  are used to mark &quot;normal&quot;; and specified %%
+        // get computed down to px by the time they get to RenderStyle 
+        // already
         Length length(style-&gt;lineHeight());
-        if (length.value() &lt; 0)
+        if (length.value() &lt; 0) 
             return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL);
         if (length.isPercent()) {
             //XXX: merge from webcore the computedStyle/specifiedStyle distinction in rendering/font.h
             float computedSize = style-&gt;htmlFont().getFontDef().size;
-            return new CSSPrimitiveValueImpl((int)(length._length * computedSize) / 100, CSSPrimitiveValue::CSS_PX);
+            return new CSSPrimitiveValueImpl((int)(length.value() * computedSize) / 100, CSSPrimitiveValue::CSS_PX);
         }
         else {
-            return new CSSPrimitiveValueImpl(length._length, CSSPrimitiveValue::CSS_PX);
+            return new CSSPrimitiveValueImpl(length.value(), CSSPrimitiveValue::CSS_PX);
         }
     }
     case CSS_PROP_LIST_STYLE_IMAGE:
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491767</commentid>
    <comment_count>7</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-12-05 18:43:20 +0000</bug_when>
    <thetext>Anyway, thanks a lot for the report --- there were actually many other spots where this was broken, and I followed up and fixed them up. 

One question, though: would it be OK with you if we add your test page to our regression test suite? (Though I guess I&apos;ll have to write some TCs for the other cases, anyway)


</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>491776</commentid>
    <comment_count>8</comment_count>
    <who name="Mark Wubben">bugs+konq</who>
    <bug_when>2006-12-05 19:31:32 +0000</bug_when>
    <thetext>That&apos;s the fastest bugfix time I&apos;ve ever seen for a browser!

Looking at the code it seems you are returning a pixel value? This of course would be best as it&apos;s what Firefox, Opera and Safari do.

Feel free to use the test case, although you might want to isolate it a bit more.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>18803</attachid>
            <date>2006-12-05 17:47:42 +0000</date>
            <delta_ts>2006-12-05 17:47:42 +0000</delta_ts>
            <desc>patch, that&apos;s what the checkbox means; silly bugzilal</desc>
            <filename>line_height.diff</filename>
            <type>text/plain</type>
            <size>1198</size>
            <attacher name="Maksim Orlovich">maksim</attacher>
            
              <data encoding="base64">SW5kZXg6IGNzcy9jc3NfcmVuZGVyc3R5bGVkZWNsYXJhdGlvbmltcGwuY3BwCj09PT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