Changeset 19155 for S60/trunk/WebCore

Show
Ignore:
Timestamp:
01/26/07 08:55:39 (2 years ago)
Author:
brmorris
Message:

yongjzha

Reviewed by <zbujtas@gmail.com>
DESC: PNUN-6XJJLF When use css border property outset, and set border color to blue, the browser
shows black at the bottom edge and right edge.
fix: correct RGB to HSV and HSV to RGB conversion algorithms in KWQColor.cpp

http://bugs.webkit.org/show_bug.cgi?id=12393

Location:
S60/trunk/WebCore
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • S60/trunk/WebCore/ChangeLog

    r19125 r19155  
     12007-01-24  yongjzha  
     2 
     3        Reviewed by <zbujtas@gmail.com> 
     4        DESC: PNUN-6XJJLF When use css border property outset, and set border color to blue, the browser 
     5        shows black at the bottom edge and right edge. 
     6        fix: correct RGB to HSV and HSV to RGB conversion algorithms in KWQColor.cpp 
     7 
     8        http://bugs.webkit.org/show_bug.cgi?id=12393 
     9 
     10        WARNING: NO TEST CASES ADDED OR CHANGED 
     11 
     12        * kwq/KWQColor.cpp: 
     13        (QColor::hsv): 
     14        (QColor::setHsv): 
     15        (QColor::light): 
     16        (QColor::dark): 
     17        * kwq/KWQColor.h: 
     18 
    119bujtas  <zbujtas@gmail.com> 
    220 
  • S60/trunk/WebCore/kwq/KWQColor.cpp

    r15736 r19155  
    8888} 
    8989 
    90 void QColor::hsv(int *h, int *s, int *v) const 
    91 { 
    92     int r = red(); 
    93     int g = green(); 
    94     int b = blue(); 
    95     int i, w, x, f; 
    96  
     90// r,g,b values are from 0 to 1 
     91// h = [0,360], s = [0,1], v = [0,1] 
     92//      if s == 0, then h = -1 (undefined) 
     93void QColor::hsv(float *h, float *s, float *v) const 
     94{ 
     95    float r = red()/255.0f; 
     96    float g = green()/255.0f; 
     97    float b = blue()/255.0f; 
     98    float i, w, x, f; 
     99 
     100    // x = min(r, g, b) 
     101    // w = max(r, g, b) 
    97102    x = w = r; 
    98103 
    99104    if (g > x) { 
     105        w = g; 
     106    } 
     107    if (g < w) { 
    100108        x = g; 
    101109    } 
    102     if (g < w) { 
    103         w = g; 
    104     } 
    105110 
    106111    if (b > x) { 
     112        w = b; 
     113    } 
     114    if (b < w) { 
    107115        x = b; 
    108     } 
    109     if (b < w) { 
    110         w = b; 
    111116    } 
    112117 
     
    120125        i = (r == x) ? 3 : ((g == x) ? 5 : 1); 
    121126        *h = i - f /(w - x); 
     127        *h *= 60; 
     128        if( *h<0 ) 
     129            *h += 360; 
     130 
    122131        if (w != 0) 
    123132            *s = (w - x)/w; 
     
    128137} 
    129138 
    130 void QColor::setHsv(int h, int s, int v) 
    131 { 
    132     int i, f, p, q, t; 
     139void QColor::setHsv(float h, float s, float v) 
     140{ 
     141    float i, f, p, q, t; 
    133142 
    134143    if( s == 0 ) { 
    135144        // achromatic (gray) 
    136         setRgb(v, v, v); 
     145        int c = v*255; 
     146        setRgb(c, c, c); 
    137147        return; 
    138148    } 
    139149 
    140150    h /= 60;      // sector 0 to 5 
    141     i = (int)floor(h); 
     151    i = floor(h); 
    142152    f = h - i;      // factorial part of h 
    143153    p = v * (1 - s); 
    144154    q = v * (1 - s * f); 
    145155    t = v * (1 - s * (1 - f)); 
    146  
    147     switch( i ) { 
     156     
     157    switch( (int)i ) { 
    148158        case 0: 
    149             setRgb(v, t, p); 
     159            setRgb(v*255, t*255, p*255); 
    150160            break; 
    151161        case 1: 
    152             setRgb(q, v, p); 
     162            setRgb(q*255, v*255, p*255); 
    153163            break; 
    154164        case 2: 
    155             setRgb(p, v, t); 
     165            setRgb(p*255, v*255, t*255); 
    156166            break; 
    157167        case 3: 
    158             setRgb(p, q, v); 
     168            setRgb(p*255, q*255, v*255); 
    159169            break; 
    160170        case 4: 
    161             setRgb(t, p, v); 
     171            setRgb(t*255, p*255, v*255); 
    162172            break; 
    163173        default:    // case 5: 
    164             setRgb(v, p, q); 
     174            setRgb(v*255, p*255, q*255); 
    165175            break; 
    166176    } 
     
    178188    } 
    179189 
    180     int h, s, v; 
     190    float h, s, v; 
    181191 
    182192    hsv(&h, &s, &v); 
     
    208218    } 
    209219 
    210     int h, s, v; 
     220    float h, s, v; 
    211221 
    212222    hsv(&h, &s, &v); 
  • S60/trunk/WebCore/kwq/KWQColor.h

    r14062 r19155  
    3232class TRgb; 
    3333 
    34 typedef unsigned int QRgb;                      // RGBA quadruplet 
     34typedef unsigned int QRgb;          // RGBA quadruplet 
    3535 
    3636QRgb qRgb(int r, int g, int b); 
     
    6060    void setRgb(int rgb) { color = rgb; valid = true; /* Alpha may be set. Preserve it. */ } 
    6161 
    62     void hsv(int *, int *, int *) const; 
    63     void setHsv(int h, int s, int v); 
     62    void hsv(float *, float *, float *) const; 
     63    void setHsv(float h, float s, float v); 
    6464 
    6565    QColor light(int f = 150) const;