Changeset 47650 in webkit
- Timestamp:
- Aug 21, 2009 5:33:18 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r47649 r47650 1 2009-08-21 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Beth Dakin. 4 5 Rendering tests for 6 [CSS3 Backgrounds and Borders] Add support for the "contain" value for 7 background-size 8 https://bugs.webkit.org/show_bug.cgi?id=27573 9 and 10 [CSS3 Backgrounds and Borders] Add support for the "cover" value for 11 background-size 12 https://bugs.webkit.org/show_bug.cgi?id=27574 13 14 * fast/backgrounds/size/contain-and-cover-expected.checksum: Added. 15 * fast/backgrounds/size/contain-and-cover-expected.png: Added. 16 * fast/backgrounds/size/contain-and-cover-expected.txt: Added. 17 * fast/backgrounds/size/contain-and-cover.html: Added. 18 * fast/backgrounds/size/resources/SquirrelFish.svg: Added!!! 19 1 20 2009-08-21 Michelangelo De Simone <micdesim@gmail.com> 2 21 -
trunk/WebCore/ChangeLog
r47649 r47650 1 2009-08-21 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Beth Dakin. 4 5 Rendering changes to complete 6 [CSS3 Backgrounds and Borders] Add support for the "contain" value for 7 background-size 8 https://bugs.webkit.org/show_bug.cgi?id=27573 9 and 10 [CSS3 Backgrounds and Borders] Add support for the "cover" value for 11 background-size 12 https://bugs.webkit.org/show_bug.cgi?id=27574 13 14 Test: fast/backgrounds/size/contain-and-cover.html 15 16 * rendering/RenderBoxModelObject.cpp: 17 (WebCore::RenderBoxModelObject::calculateBackgroundSize): 18 * rendering/RenderObject.cpp: 19 (WebCore::mustRepaintFillLayers): 20 1 21 2009-08-21 Michelangelo De Simone <micdesim@gmail.com> 2 22 -
trunk/WebCore/rendering/RenderBoxModelObject.cpp
r47630 r47650 499 499 bg->setImageContainerSize(IntSize(scaledWidth, scaledHeight)); // Use the box established by background-origin. 500 500 501 if (bgLayer->size().type == SizeLength) { 502 int w = scaledWidth; 503 int h = scaledHeight; 504 Length bgWidth = bgLayer->size().size.width(); 505 Length bgHeight = bgLayer->size().size.height(); 506 507 if (bgWidth.isFixed()) 508 w = bgWidth.value(); 509 else if (bgWidth.isPercent()) 510 w = bgWidth.calcValue(scaledWidth); 511 512 if (bgHeight.isFixed()) 513 h = bgHeight.value(); 514 else if (bgHeight.isPercent()) 515 h = bgHeight.calcValue(scaledHeight); 516 517 // If one of the values is auto we have to use the appropriate 518 // scale to maintain our aspect ratio. 519 if (bgWidth.isAuto() && !bgHeight.isAuto()) 520 w = bg->imageSize(this, style()->effectiveZoom()).width() * h / bg->imageSize(this, style()->effectiveZoom()).height(); 521 else if (!bgWidth.isAuto() && bgHeight.isAuto()) 522 h = bg->imageSize(this, style()->effectiveZoom()).height() * w / bg->imageSize(this, style()->effectiveZoom()).width(); 523 else if (bgWidth.isAuto() && bgHeight.isAuto()) { 524 // If both width and height are auto, we just want to use the image's 525 // intrinsic size. 526 w = bg->imageSize(this, style()->effectiveZoom()).width(); 527 h = bg->imageSize(this, style()->effectiveZoom()).height(); 528 } 529 530 return IntSize(max(1, w), max(1, h)); 531 } else 532 return bg->imageSize(this, style()->effectiveZoom()); 501 EFillSizeType type = bgLayer->size().type; 502 503 switch (type) { 504 case SizeLength: { 505 int w = scaledWidth; 506 int h = scaledHeight; 507 Length bgWidth = bgLayer->size().size.width(); 508 Length bgHeight = bgLayer->size().size.height(); 509 510 if (bgWidth.isFixed()) 511 w = bgWidth.value(); 512 else if (bgWidth.isPercent()) 513 w = bgWidth.calcValue(scaledWidth); 514 515 if (bgHeight.isFixed()) 516 h = bgHeight.value(); 517 else if (bgHeight.isPercent()) 518 h = bgHeight.calcValue(scaledHeight); 519 520 // If one of the values is auto we have to use the appropriate 521 // scale to maintain our aspect ratio. 522 if (bgWidth.isAuto() && !bgHeight.isAuto()) 523 w = bg->imageSize(this, style()->effectiveZoom()).width() * h / bg->imageSize(this, style()->effectiveZoom()).height(); 524 else if (!bgWidth.isAuto() && bgHeight.isAuto()) 525 h = bg->imageSize(this, style()->effectiveZoom()).height() * w / bg->imageSize(this, style()->effectiveZoom()).width(); 526 else if (bgWidth.isAuto() && bgHeight.isAuto()) { 527 // If both width and height are auto, we just want to use the image's 528 // intrinsic size. 529 w = bg->imageSize(this, style()->effectiveZoom()).width(); 530 h = bg->imageSize(this, style()->effectiveZoom()).height(); 531 } 532 533 return IntSize(max(1, w), max(1, h)); 534 } 535 case Contain: 536 case Cover: { 537 IntSize imageIntrinsicSize = bg->imageSize(this, 1); 538 float horizontalScaleFactor = static_cast<float>(scaledWidth) / imageIntrinsicSize.width(); 539 float verticalScaleFactor = static_cast<float>(scaledHeight) / imageIntrinsicSize.height(); 540 float scaleFactor = type == Contain ? min(horizontalScaleFactor, verticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor); 541 542 return IntSize(max<int>(1, imageIntrinsicSize.width() * scaleFactor), max<int>(1, imageIntrinsicSize.height() * scaleFactor)); 543 } 544 case SizeNone: 545 ASSERT_NOT_REACHED(); 546 break; 547 } 548 return bg->imageSize(this, style()->effectiveZoom()); 533 549 } 534 550 -
trunk/WebCore/rendering/RenderObject.cpp
r47630 r47650 660 660 if (layer->size().size.width().isPercent() || layer->size().size.height().isPercent()) 661 661 return true; 662 } else if ( img->usesImageContainerSize())662 } else if (layer->size().type == Contain || layer->size().type == Cover || img->usesImageContainerSize()) 663 663 return true; 664 664
Note: See TracChangeset
for help on using the changeset viewer.