[webkit-changes] cvs commit: WebCore/layout-tests/fast/backgrounds 001.html

David hyatt at opensource.apple.com
Fri Jun 10 22:01:18 PDT 2005


hyatt       05/06/10 22:01:18

  Modified:    .        ChangeLog
               khtml/rendering render_box.cpp
  Added:       layout-tests/fast/backgrounds 001.html
  Log:
  	Fix for 3237, background image repeats when it shouldn't.  The Radar bug is 4005553.  Patch from
  	Nate Cook.
  
          Reviewed by darin and hyatt
  
          Test cases added: fast/backgrounds/001.html
  
          * khtml/rendering/render_box.cpp:
          (RenderBox::paintBackgroundExtended):
          * layout-tests/fast/backgrounds/001.html: Added.
  
  Revision  Changes    Path
  1.4256    +13 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4255
  retrieving revision 1.4256
  diff -u -r1.4255 -r1.4256
  --- ChangeLog	11 Jun 2005 01:57:58 -0000	1.4255
  +++ ChangeLog	11 Jun 2005 05:01:12 -0000	1.4256
  @@ -1,5 +1,18 @@
   2005-06-10  David Hyatt  <hyatt at apple.com>
   
  +	Fix for 3237, background image repeats when it shouldn't.  The Radar bug is 4005553.  Patch from
  +	Nate Cook.
  +	
  +        Reviewed by darin and hyatt
  +
  +        Test cases added: fast/backgrounds/001.html
  +
  +        * khtml/rendering/render_box.cpp:
  +        (RenderBox::paintBackgroundExtended):
  +        * layout-tests/fast/backgrounds/001.html: Added.
  +
  +2005-06-10  David Hyatt  <hyatt at apple.com>
  +
   	Merge Allan Jensen's fix for 3236.
   	
           Reviewed by hyatt
  
  
  
  1.154     +26 -24    WebCore/khtml/rendering/render_box.cpp
  
  Index: render_box.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_box.cpp,v
  retrieving revision 1.153
  retrieving revision 1.154
  diff -u -r1.153 -r1.154
  --- render_box.cpp	18 Apr 2005 20:57:04 -0000	1.153
  +++ render_box.cpp	11 Jun 2005 05:01:17 -0000	1.154
  @@ -424,22 +424,25 @@
                       cx = _tx + xPosition;
                   else {
                       cx = _tx;
  -                    if (pixw == 0)
  -                        sx = 0;
  -                    else {
  +                    if (pixw > 0) {
                           sx = -xPosition;
                           cw += xPosition;
                       }
                   }
                   cx += bleft;
               } else {
  +                // repeat over x or background is wider than box
                   cw = w;
                   cx = _tx;
  -                if (pixw == 0)
  -                    sx = 0;
  -                else {
  -                    sx =  pixw - ((bgLayer->backgroundXPosition().minWidth(pw-pixw)) % pixw );
  -                    sx -= bleft % pixw;
  +                if (pixw > 0) {
  +					int xPosition = bgLayer->backgroundXPosition().minWidth(pw-pixw);
  +					if ((xPosition > 0) && (bgr == NO_REPEAT)) {
  +						cx += xPosition;
  +						cw -= xPosition;
  +					} else {
  +						sx =  pixw - (xPosition % pixw );
  +						sx -= bleft % pixw;
  +					}
                   }
               }
   
  @@ -450,9 +453,7 @@
                       cy = _ty + yPosition;
                   else {
                       cy = _ty;
  -                    if (pixh == 0)
  -                        sy = 0;
  -                    else {
  +                    if (pixh > 0) {
                           sy = -yPosition;
                           ch += yPosition;
                       }
  @@ -460,13 +461,18 @@
                   
                   cy += borderTop();
               } else {
  +                // repeat over y or background is taller than box
                   ch = h;
                   cy = _ty;
  -                if(pixh == 0){
  -                    sy = 0;
  -                }else{
  -                    sy = pixh - ((bgLayer->backgroundYPosition().minWidth(ph-pixh)) % pixh );
  -                    sy -= borderTop() % pixh;
  +                if (pixh > 0) {
  +					int yPosition = bgLayer->backgroundYPosition().minWidth(ph-pixh);
  +					if ((yPosition > 0) && (bgr == NO_REPEAT)) {
  +						cy += yPosition;
  +						ch -= yPosition;
  +					} else {
  +						sy = pixh - (yPosition % pixh );
  +						sy -= borderTop() % pixh;
  +					}
                   }
               }
           }
  @@ -486,9 +492,7 @@
               } else {
                   cw = pw;
                   cx = vr.x();
  -                if(pixw == 0){
  -                    sx = 0;
  -                }else{
  +                if (pixw > 0) {
                       sx =  pixw - ((bgLayer->backgroundXPosition().minWidth(pw-pixw)) % pixw );
                   }
               }
  @@ -499,13 +503,11 @@
               } else {
                   ch = ph;
                   cy = vr.y();
  -                if(pixh == 0){
  -                    sy = 0;
  -                }else{
  +                if (pixh > 0) {
                       sy = pixh - ((bgLayer->backgroundYPosition().minWidth(ph-pixh)) % pixh );
                   }
               }
  -
  +			
               QRect fix(cx,cy,cw,ch);
               QRect ele(_tx,_ty,w,h);
               QRect b = fix.intersect(ele);
  @@ -516,7 +518,7 @@
   
   
   //        kdDebug() << "cx="<<cx << " cy="<<cy<< " cw="<<cw << " ch="<<ch << " sx="<<sx << " sy="<<sy << endl;
  -
  +		
           if (cw>0 && ch>0)
               p->drawTiledPixmap(cx, cy, cw, ch, bg->tiled_pixmap(c), sx, sy);
       }
  
  
  
  1.1                  WebCore/layout-tests/fast/backgrounds/001.html
  
  Index: 001.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  <html>
  <head>
  <title>Box with larger background image</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta http-equiv="Content-Style-Type" content="text/css">
  
  <style type="text/css">
  .one {background-image: url(http://natecook.com/layout-tests/resources/bg_position_larger.gif); background-position: 10px 10px;
         background-repeat: no-repeat; background-color: green; width: 50px; height: 50px;}
  </style>
  </head>
  
  <body>
  
  The box below should be solid green. If there are 10 pixels of red visible on the top and left, the background image is being repeated improperly.
  </p>
  <p class="one">
  </p>
  
  </body>
  </html>
  
  
  



More information about the webkit-changes mailing list