Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 381473002: Use reference for FillLayer if possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 const ShadowData& boxShadow = shadowList->shadows()[i]; 399 const ShadowData& boxShadow = shadowList->shadows()[i];
400 if (boxShadow.style() != Normal) 400 if (boxShadow.style() != Normal)
401 continue; 401 continue;
402 FloatSize shadowOffset(boxShadow.x(), boxShadow.y()); 402 FloatSize shadowOffset(boxShadow.x(), boxShadow.y());
403 context->setShadow(shadowOffset, boxShadow.blur(), boxShadow.color(), 403 context->setShadow(shadowOffset, boxShadow.blur(), boxShadow.color(),
404 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::Shad owIgnoresAlpha); 404 DrawLooperBuilder::ShadowRespectsTransforms, DrawLooperBuilder::Shad owIgnoresAlpha);
405 return; 405 return;
406 } 406 }
407 } 407 }
408 408
409 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer* bgLayer, const LayoutRect& rect, 409 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co nst Color& color, const FillLayer& bgLayer, const LayoutRect& rect,
410 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, CompositeOperator op, RenderObject* backgroundObject) 410 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz e& boxSize, CompositeOperator op, RenderObject* backgroundObject)
411 { 411 {
412 GraphicsContext* context = paintInfo.context; 412 GraphicsContext* context = paintInfo.context;
413 if (context->paintingDisabled() || rect.isEmpty()) 413 if (context->paintingDisabled() || rect.isEmpty())
414 return; 414 return;
415 415
416 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true; 416 bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true;
417 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true; 417 bool includeRightEdge = box ? box->includeLogicalRightEdge() : true;
418 418
419 bool hasRoundedBorder = style()->hasBorderRadius() && (includeLeftEdge || in cludeRightEdge); 419 bool hasRoundedBorder = style()->hasBorderRadius() && (includeLeftEdge || in cludeRightEdge);
420 bool clippedWithLocalScrolling = hasOverflowClip() && bgLayer->attachment() == LocalBackgroundAttachment; 420 bool clippedWithLocalScrolling = hasOverflowClip() && bgLayer.attachment() = = LocalBackgroundAttachment;
421 bool isBorderFill = bgLayer->clip() == BorderFillBox; 421 bool isBorderFill = bgLayer.clip() == BorderFillBox;
422 bool isRoot = this->isDocumentElement(); 422 bool isRoot = this->isDocumentElement();
423 423
424 Color bgColor = color; 424 Color bgColor = color;
425 StyleImage* bgImage = bgLayer->image(); 425 StyleImage* bgImage = bgLayer.image();
426 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(*this, style ()->effectiveZoom()); 426 bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(*this, style ()->effectiveZoom());
427 427
428 bool forceBackgroundToWhite = false; 428 bool forceBackgroundToWhite = false;
429 if (document().printing()) { 429 if (document().printing()) {
430 if (style()->printColorAdjust() == PrintColorAdjustEconomy) 430 if (style()->printColorAdjust() == PrintColorAdjustEconomy)
431 forceBackgroundToWhite = true; 431 forceBackgroundToWhite = true;
432 if (document().settings() && document().settings()->shouldPrintBackgroun ds()) 432 if (document().settings() && document().settings()->shouldPrintBackgroun ds())
433 forceBackgroundToWhite = false; 433 forceBackgroundToWhite = false;
434 } 434 }
435 435
436 // When printing backgrounds is disabled or using economy mode, 436 // When printing backgrounds is disabled or using economy mode,
437 // change existing background colors and images to a solid white background. 437 // change existing background colors and images to a solid white background.
438 // If there's no bg color or image, leave it untouched to avoid affecting tr ansparency. 438 // If there's no bg color or image, leave it untouched to avoid affecting tr ansparency.
439 // We don't try to avoid loading the background images, because this style f lag is only set 439 // We don't try to avoid loading the background images, because this style f lag is only set
440 // when printing, and at that point we've already loaded the background imag es anyway. (To avoid 440 // when printing, and at that point we've already loaded the background imag es anyway. (To avoid
441 // loading the background images we'd have to do this check when applying st yles rather than 441 // loading the background images we'd have to do this check when applying st yles rather than
442 // while rendering.) 442 // while rendering.)
443 if (forceBackgroundToWhite) { 443 if (forceBackgroundToWhite) {
444 // Note that we can't reuse this variable below because the bgColor migh t be changed 444 // Note that we can't reuse this variable below because the bgColor migh t be changed
445 bool shouldPaintBackgroundColor = !bgLayer->next() && bgColor.alpha(); 445 bool shouldPaintBackgroundColor = !bgLayer.next() && bgColor.alpha();
446 if (shouldPaintBackgroundImage || shouldPaintBackgroundColor) { 446 if (shouldPaintBackgroundImage || shouldPaintBackgroundColor) {
447 bgColor = Color::white; 447 bgColor = Color::white;
448 shouldPaintBackgroundImage = false; 448 shouldPaintBackgroundImage = false;
449 } 449 }
450 } 450 }
451 451
452 bool colorVisible = bgColor.alpha(); 452 bool colorVisible = bgColor.alpha();
453 453
454 // Fast path for drawing simple color backgrounds. 454 // Fast path for drawing simple color backgrounds.
455 if (!isRoot && !clippedWithLocalScrolling && !shouldPaintBackgroundImage && isBorderFill && !bgLayer->next()) { 455 if (!isRoot && !clippedWithLocalScrolling && !shouldPaintBackgroundImage && isBorderFill && !bgLayer.next()) {
456 if (!colorVisible) 456 if (!colorVisible)
457 return; 457 return;
458 458
459 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli edToBackground(bleedAvoidance, box); 459 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli edToBackground(bleedAvoidance, box);
460 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp pliedToBackground); 460 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp pliedToBackground);
461 if (boxShadowShouldBeAppliedToBackground) 461 if (boxShadowShouldBeAppliedToBackground)
462 applyBoxShadowForBackground(context, this); 462 applyBoxShadowForBackground(context, this);
463 463
464 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedClipBackground) { 464 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedClipBackground) {
465 RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance( context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge); 465 RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance( context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge);
(...skipping 12 matching lines...) Expand all
478 return; 478 return;
479 } 479 }
480 480
481 // BorderFillBox radius clipping is taken care of by BackgroundBleedClipBack ground 481 // BorderFillBox radius clipping is taken care of by BackgroundBleedClipBack ground
482 bool clipToBorderRadius = hasRoundedBorder && !(isBorderFill && bleedAvoidan ce == BackgroundBleedClipBackground); 482 bool clipToBorderRadius = hasRoundedBorder && !(isBorderFill && bleedAvoidan ce == BackgroundBleedClipBackground);
483 GraphicsContextStateSaver clipToBorderStateSaver(*context, clipToBorderRadiu s); 483 GraphicsContextStateSaver clipToBorderStateSaver(*context, clipToBorderRadiu s);
484 if (clipToBorderRadius) { 484 if (clipToBorderRadius) {
485 RoundedRect border = isBorderFill ? backgroundRoundedRectAdjustedForBlee dAvoidance(context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, include RightEdge) : getBackgroundRoundedRect(rect, box, boxSize.width(), boxSize.height (), includeLeftEdge, includeRightEdge); 485 RoundedRect border = isBorderFill ? backgroundRoundedRectAdjustedForBlee dAvoidance(context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, include RightEdge) : getBackgroundRoundedRect(rect, box, boxSize.width(), boxSize.height (), includeLeftEdge, includeRightEdge);
486 486
487 // Clip to the padding or content boxes as necessary. 487 // Clip to the padding or content boxes as necessary.
488 if (bgLayer->clip() == ContentFillBox) { 488 if (bgLayer.clip() == ContentFillBox) {
489 border = style()->getRoundedInnerBorderFor(border.rect(), 489 border = style()->getRoundedInnerBorderFor(border.rect(),
490 paddingTop() + borderTop(), paddingBottom() + borderBottom(), pa ddingLeft() + borderLeft(), paddingRight() + borderRight(), includeLeftEdge, inc ludeRightEdge); 490 paddingTop() + borderTop(), paddingBottom() + borderBottom(), pa ddingLeft() + borderLeft(), paddingRight() + borderRight(), includeLeftEdge, inc ludeRightEdge);
491 } else if (bgLayer->clip() == PaddingFillBox) 491 } else if (bgLayer.clip() == PaddingFillBox)
492 border = style()->getRoundedInnerBorderFor(border.rect(), includeLef tEdge, includeRightEdge); 492 border = style()->getRoundedInnerBorderFor(border.rect(), includeLef tEdge, includeRightEdge);
493 493
494 clipRoundedInnerRect(context, rect, border); 494 clipRoundedInnerRect(context, rect, border);
495 } 495 }
496 496
497 int bLeft = includeLeftEdge ? borderLeft() : 0; 497 int bLeft = includeLeftEdge ? borderLeft() : 0;
498 int bRight = includeRightEdge ? borderRight() : 0; 498 int bRight = includeRightEdge ? borderRight() : 0;
499 LayoutUnit pLeft = includeLeftEdge ? paddingLeft() : LayoutUnit(); 499 LayoutUnit pLeft = includeLeftEdge ? paddingLeft() : LayoutUnit();
500 LayoutUnit pRight = includeRightEdge ? paddingRight() : LayoutUnit(); 500 LayoutUnit pRight = includeRightEdge ? paddingRight() : LayoutUnit();
501 501
502 GraphicsContextStateSaver clipWithScrollingStateSaver(*context, clippedWithL ocalScrolling); 502 GraphicsContextStateSaver clipWithScrollingStateSaver(*context, clippedWithL ocalScrolling);
503 LayoutRect scrolledPaintRect = rect; 503 LayoutRect scrolledPaintRect = rect;
504 if (clippedWithLocalScrolling) { 504 if (clippedWithLocalScrolling) {
505 // Clip to the overflow area. 505 // Clip to the overflow area.
506 RenderBox* thisBox = toRenderBox(this); 506 RenderBox* thisBox = toRenderBox(this);
507 context->clip(thisBox->overflowClipRect(rect.location())); 507 context->clip(thisBox->overflowClipRect(rect.location()));
508 508
509 // Adjust the paint rect to reflect a scrolled content box with borders at the ends. 509 // Adjust the paint rect to reflect a scrolled content box with borders at the ends.
510 IntSize offset = thisBox->scrolledContentOffset(); 510 IntSize offset = thisBox->scrolledContentOffset();
511 scrolledPaintRect.move(-offset); 511 scrolledPaintRect.move(-offset);
512 scrolledPaintRect.setWidth(bLeft + thisBox->scrollWidth() + bRight); 512 scrolledPaintRect.setWidth(bLeft + thisBox->scrollWidth() + bRight);
513 scrolledPaintRect.setHeight(borderTop() + thisBox->scrollHeight() + bord erBottom()); 513 scrolledPaintRect.setHeight(borderTop() + thisBox->scrollHeight() + bord erBottom());
514 } 514 }
515 515
516 GraphicsContextStateSaver backgroundClipStateSaver(*context, false); 516 GraphicsContextStateSaver backgroundClipStateSaver(*context, false);
517 IntRect maskRect; 517 IntRect maskRect;
518 518
519 switch (bgLayer->clip()) { 519 switch (bgLayer.clip()) {
520 case PaddingFillBox: 520 case PaddingFillBox:
521 case ContentFillBox: { 521 case ContentFillBox: {
522 if (clipToBorderRadius) 522 if (clipToBorderRadius)
523 break; 523 break;
524 524
525 // Clip to the padding or content boxes as necessary. 525 // Clip to the padding or content boxes as necessary.
526 bool includePadding = bgLayer->clip() == ContentFillBox; 526 bool includePadding = bgLayer.clip() == ContentFillBox;
527 LayoutRect clipRect = LayoutRect(scrolledPaintRect.x() + bLeft + (includ ePadding ? pLeft : LayoutUnit()), 527 LayoutRect clipRect = LayoutRect(scrolledPaintRect.x() + bLeft + (includ ePadding ? pLeft : LayoutUnit()),
528 scrolledPaintRect.y() + borderTop() + (includePadding ? paddingTop() : LayoutUnit()), 528 scrolledPaintRect.y() + borderTop() + (includePadding ? paddingTop() : LayoutUnit()),
529 scrolledPaintRect.width() - bLeft - bRight - (includePadding ? pLeft + pRight : LayoutUnit()), 529 scrolledPaintRect.width() - bLeft - bRight - (includePadding ? pLeft + pRight : LayoutUnit()),
530 scrolledPaintRect.height() - borderTop() - borderBottom() - (include Padding ? paddingTop() + paddingBottom() : LayoutUnit())); 530 scrolledPaintRect.height() - borderTop() - borderBottom() - (include Padding ? paddingTop() + paddingBottom() : LayoutUnit()));
531 backgroundClipStateSaver.save(); 531 backgroundClipStateSaver.save();
532 context->clip(clipRect); 532 context->clip(clipRect);
533 533
534 break; 534 break;
535 } 535 }
536 case TextFillBox: { 536 case TextFillBox: {
(...skipping 15 matching lines...) Expand all
552 default: 552 default:
553 ASSERT_NOT_REACHED(); 553 ASSERT_NOT_REACHED();
554 break; 554 break;
555 } 555 }
556 556
557 // Only fill with a base color (e.g., white) if we're the root document, sin ce iframes/frames with 557 // Only fill with a base color (e.g., white) if we're the root document, sin ce iframes/frames with
558 // no background in the child document should show the parent's background. 558 // no background in the child document should show the parent's background.
559 bool isOpaqueRoot = false; 559 bool isOpaqueRoot = false;
560 if (isRoot) { 560 if (isRoot) {
561 isOpaqueRoot = true; 561 isOpaqueRoot = true;
562 if (!bgLayer->next() && bgColor.hasAlpha() && view()->frameView()) { 562 if (!bgLayer.next() && bgColor.hasAlpha() && view()->frameView()) {
563 Element* ownerElement = document().ownerElement(); 563 Element* ownerElement = document().ownerElement();
564 if (ownerElement) { 564 if (ownerElement) {
565 if (!isHTMLFrameElement(*ownerElement)) { 565 if (!isHTMLFrameElement(*ownerElement)) {
566 // Locate the <body> element using the DOM. This is easier than trying 566 // Locate the <body> element using the DOM. This is easier than trying
567 // to crawl around a render tree with potential :before/:aft er content and 567 // to crawl around a render tree with potential :before/:aft er content and
568 // anonymous blocks created by inline <body> tags etc. We c an locate the <body> 568 // anonymous blocks created by inline <body> tags etc. We c an locate the <body>
569 // render object very easily via the DOM. 569 // render object very easily via the DOM.
570 HTMLElement* body = document().body(); 570 HTMLElement* body = document().body();
571 if (body) { 571 if (body) {
572 // Can't scroll a frameset document anyway. 572 // Can't scroll a frameset document anyway.
573 isOpaqueRoot = body->hasLocalName(framesetTag); 573 isOpaqueRoot = body->hasLocalName(framesetTag);
574 } else { 574 } else {
575 // SVG documents and XML documents with SVG root nodes a re transparent. 575 // SVG documents and XML documents with SVG root nodes a re transparent.
576 isOpaqueRoot = !document().hasSVGRootNode(); 576 isOpaqueRoot = !document().hasSVGRootNode();
577 } 577 }
578 } 578 }
579 } else 579 } else
580 isOpaqueRoot = !view()->frameView()->isTransparent(); 580 isOpaqueRoot = !view()->frameView()->isTransparent();
581 } 581 }
582 view()->frameView()->setContentIsOpaque(isOpaqueRoot); 582 view()->frameView()->setContentIsOpaque(isOpaqueRoot);
583 } 583 }
584 584
585 // Paint the color first underneath all images, culled if background image o ccludes it. 585 // Paint the color first underneath all images, culled if background image o ccludes it.
586 // FIXME: In the bgLayer->hasFiniteBounds() case, we could improve the culli ng test 586 // FIXME: In the bgLayer->hasFiniteBounds() case, we could improve the culli ng test
587 // by verifying whether the background image covers the entire layout rect. 587 // by verifying whether the background image covers the entire layout rect.
588 if (!bgLayer->next()) { 588 if (!bgLayer.next()) {
589 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect)); 589 IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect));
590 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli edToBackground(bleedAvoidance, box); 590 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli edToBackground(bleedAvoidance, box);
591 if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(this) || !bgLayer->hasRepeatXY() || (isOpaqueRoot && !toRenderBox(this)->height())) { 591 if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer.hasOpaqueImage(this) || !bgLayer.hasRepeatXY() || (isOpaqueRoot && ! toRenderBox(this)->height())) {
592 if (!boxShadowShouldBeAppliedToBackground) 592 if (!boxShadowShouldBeAppliedToBackground)
593 backgroundRect.intersect(paintInfo.rect); 593 backgroundRect.intersect(paintInfo.rect);
594 594
595 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould BeAppliedToBackground); 595 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould BeAppliedToBackground);
596 if (boxShadowShouldBeAppliedToBackground) 596 if (boxShadowShouldBeAppliedToBackground)
597 applyBoxShadowForBackground(context, this); 597 applyBoxShadowForBackground(context, this);
598 598
599 if (isOpaqueRoot) { 599 if (isOpaqueRoot) {
600 // If we have an alpha and we are painting the root element, go ahead and blend with the base background color. 600 // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
601 Color baseColor = view()->frameView()->baseBackgroundColor(); 601 Color baseColor = view()->frameView()->baseBackgroundColor();
(...skipping 14 matching lines...) Expand all
616 } 616 }
617 } 617 }
618 } 618 }
619 619
620 // no progressive loading of the background image 620 // no progressive loading of the background image
621 if (shouldPaintBackgroundImage) { 621 if (shouldPaintBackgroundImage) {
622 BackgroundImageGeometry geometry; 622 BackgroundImageGeometry geometry;
623 calculateBackgroundImageGeometry(paintInfo.paintContainer(), bgLayer, sc rolledPaintRect, geometry, backgroundObject); 623 calculateBackgroundImageGeometry(paintInfo.paintContainer(), bgLayer, sc rolledPaintRect, geometry, backgroundObject);
624 geometry.clip(paintInfo.rect); 624 geometry.clip(paintInfo.rect);
625 if (!geometry.destRect().isEmpty()) { 625 if (!geometry.destRect().isEmpty()) {
626 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer- >composite() : op; 626 CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer. composite() : op;
627 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : this; 627 RenderObject* clientForBackgroundImage = backgroundObject ? backgrou ndObject : this;
628 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize()); 628 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geome try.tileSize());
629 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(context, image.get(), bgLayer, geometry.tileSize()); 629 InterpolationQuality interpolationQuality = chooseInterpolationQuali ty(context, image.get(), &bgLayer, geometry.tileSize());
630 if (bgLayer->maskSourceType() == MaskLuminance) 630 if (bgLayer.maskSourceType() == MaskLuminance)
631 context->setColorFilter(ColorFilterLuminanceToAlpha); 631 context->setColorFilter(ColorFilterLuminanceToAlpha);
632 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality(); 632 InterpolationQuality previousInterpolationQuality = context->imageIn terpolationQuality();
633 context->setImageInterpolationQuality(interpolationQuality); 633 context->setImageInterpolationQuality(interpolationQuality);
634 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r elativePhase(), geometry.tileSize(), 634 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r elativePhase(), geometry.tileSize(),
635 compositeOp, bgLayer->blendMode(), geometry.spaceSize()); 635 compositeOp, bgLayer.blendMode(), geometry.spaceSize());
636 context->setImageInterpolationQuality(previousInterpolationQuality); 636 context->setImageInterpolationQuality(previousInterpolationQuality);
637 } 637 }
638 } 638 }
639 639
640 if (bgLayer->clip() == TextFillBox) { 640 if (bgLayer.clip() == TextFillBox) {
641 // Create the text mask layer. 641 // Create the text mask layer.
642 context->setCompositeOperation(CompositeDestinationIn); 642 context->setCompositeOperation(CompositeDestinationIn);
643 context->beginTransparencyLayer(1); 643 context->beginTransparencyLayer(1);
644 644
645 // FIXME: Workaround for https://code.google.com/p/skia/issues/detail?id =1291. 645 // FIXME: Workaround for https://code.google.com/p/skia/issues/detail?id =1291.
646 context->clearRect(maskRect); 646 context->clearRect(maskRect);
647 647
648 // Now draw the text into the mask. We do this by painting using a speci al paint phase that signals to 648 // Now draw the text into the mask. We do this by painting using a speci al paint phase that signals to
649 // InlineTextBoxes that they should just add their contents to the clip. 649 // InlineTextBoxes that they should just add their contents to the clip.
650 PaintInfo info(context, maskRect, PaintPhaseTextClip, PaintBehaviorForce BlackText, 0); 650 PaintInfo info(context, maskRect, PaintPhaseTextClip, PaintBehaviorForce BlackText, 0);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 // establishes the coordinate system for the 'background-position' property. 751 // establishes the coordinate system for the 'background-position' property.
752 return positioningAreaSize; 752 return positioningAreaSize;
753 } 753 }
754 754
755 static inline void applySubPixelHeuristicForTileSize(LayoutSize& tileSize, const IntSize& positioningAreaSize) 755 static inline void applySubPixelHeuristicForTileSize(LayoutSize& tileSize, const IntSize& positioningAreaSize)
756 { 756 {
757 tileSize.setWidth(positioningAreaSize.width() - tileSize.width() <= 1 ? tile Size.width().ceil() : tileSize.width().floor()); 757 tileSize.setWidth(positioningAreaSize.width() - tileSize.width() <= 1 ? tile Size.width().ceil() : tileSize.width().floor());
758 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t ileSize.height().ceil() : tileSize.height().floor()); 758 tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? t ileSize.height().ceil() : tileSize.height().floor());
759 } 759 }
760 760
761 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const 761 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer& fillLayer, const IntSize& positioningAreaSize) const
762 { 762 {
763 StyleImage* image = fillLayer->image(); 763 StyleImage* image = fillLayer.image();
764 EFillSizeType type = fillLayer->size().type; 764 EFillSizeType type = fillLayer.size().type;
765 765
766 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi oningAreaSize, ScaleByEffectiveZoom); 766 IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positi oningAreaSize, ScaleByEffectiveZoom);
767 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal eFactor()); 767 imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScal eFactor());
768 switch (type) { 768 switch (type) {
769 case SizeLength: { 769 case SizeLength: {
770 LayoutSize tileSize = positioningAreaSize; 770 LayoutSize tileSize = positioningAreaSize;
771 771
772 Length layerWidth = fillLayer->size().size.width(); 772 Length layerWidth = fillLayer.size().size.width();
773 Length layerHeight = fillLayer->size().size.height(); 773 Length layerHeight = fillLayer.size().size.height();
774 774
775 if (layerWidth.isFixed()) 775 if (layerWidth.isFixed())
776 tileSize.setWidth(layerWidth.value()); 776 tileSize.setWidth(layerWidth.value());
777 else if (layerWidth.isPercent()) 777 else if (layerWidth.isPercent())
778 tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize .width())); 778 tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize .width()));
779 779
780 if (layerHeight.isFixed()) 780 if (layerHeight.isFixed())
781 tileSize.setHeight(layerHeight.value()); 781 tileSize.setHeight(layerHeight.value());
782 else if (layerHeight.isPercent()) 782 else if (layerHeight.isPercent())
783 tileSize.setHeight(valueForLength(layerHeight, positioningAreaSi ze.height())); 783 tileSize.setHeight(valueForLength(layerHeight, positioningAreaSi ze.height()));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 { 873 {
874 int numberOfTiles = areaSize / tileSize; 874 int numberOfTiles = areaSize / tileSize;
875 int space = -1; 875 int space = -1;
876 876
877 if (numberOfTiles > 1) 877 if (numberOfTiles > 1)
878 space = lroundf((float)(areaSize - numberOfTiles * tileSize) / (numberOf Tiles - 1)); 878 space = lroundf((float)(areaSize - numberOfTiles * tileSize) / (numberOf Tiles - 1));
879 879
880 return space; 880 return space;
881 } 881 }
882 882
883 void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerMod elObject* paintContainer, const FillLayer* fillLayer, const LayoutRect& paintRec t, 883 void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerMod elObject* paintContainer, const FillLayer& fillLayer, const LayoutRect& paintRec t,
884 BackgroundImageGeometry& geometry, RenderObject* backgroundObject) const 884 BackgroundImageGeometry& geometry, RenderObject* backgroundObject) const
885 { 885 {
886 LayoutUnit left = 0; 886 LayoutUnit left = 0;
887 LayoutUnit top = 0; 887 LayoutUnit top = 0;
888 IntSize positioningAreaSize; 888 IntSize positioningAreaSize;
889 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); 889 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect);
890 890
891 // Determine the background positioning area and set destRect to the backgro und painting area. 891 // Determine the background positioning area and set destRect to the backgro und painting area.
892 // destRect will be adjusted later if the background is non-repeating. 892 // destRect will be adjusted later if the background is non-repeating.
893 // FIXME: transforms spec says that fixed backgrounds behave like scroll ins ide transforms. 893 // FIXME: transforms spec says that fixed backgrounds behave like scroll ins ide transforms.
894 bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment; 894 bool fixedAttachment = fillLayer.attachment() == FixedBackgroundAttachment;
895 895
896 if (RuntimeEnabledFeatures::fastMobileScrollingEnabled() 896 if (RuntimeEnabledFeatures::fastMobileScrollingEnabled()
897 && view()->frameView() 897 && view()->frameView()
898 && view()->frameView()->shouldAttemptToScrollUsingFastPath()) { 898 && view()->frameView()->shouldAttemptToScrollUsingFastPath()) {
899 // As a side effect of an optimization to blit on scroll, we do not hono r the CSS 899 // As a side effect of an optimization to blit on scroll, we do not hono r the CSS
900 // property "background-attachment: fixed" because it may result in rend ering 900 // property "background-attachment: fixed" because it may result in rend ering
901 // artifacts. Note, these artifacts only appear if we are blitting on sc roll of 901 // artifacts. Note, these artifacts only appear if we are blitting on sc roll of
902 // a page that has fixed background images. 902 // a page that has fixed background images.
903 fixedAttachment = false; 903 fixedAttachment = false;
904 } 904 }
905 905
906 if (!fixedAttachment) { 906 if (!fixedAttachment) {
907 geometry.setDestRect(snappedPaintRect); 907 geometry.setDestRect(snappedPaintRect);
908 908
909 LayoutUnit right = 0; 909 LayoutUnit right = 0;
910 LayoutUnit bottom = 0; 910 LayoutUnit bottom = 0;
911 // Scroll and Local. 911 // Scroll and Local.
912 if (fillLayer->origin() != BorderFillBox) { 912 if (fillLayer.origin() != BorderFillBox) {
913 left = borderLeft(); 913 left = borderLeft();
914 right = borderRight(); 914 right = borderRight();
915 top = borderTop(); 915 top = borderTop();
916 bottom = borderBottom(); 916 bottom = borderBottom();
917 if (fillLayer->origin() == ContentFillBox) { 917 if (fillLayer.origin() == ContentFillBox) {
918 left += paddingLeft(); 918 left += paddingLeft();
919 right += paddingRight(); 919 right += paddingRight();
920 top += paddingTop(); 920 top += paddingTop();
921 bottom += paddingBottom(); 921 bottom += paddingBottom();
922 } 922 }
923 } 923 }
924 924
925 // The background of the box generated by the root element covers the en tire canvas including 925 // The background of the box generated by the root element covers the en tire canvas including
926 // its margins. Since those were added in already, we have to factor the m out when computing 926 // its margins. Since those were added in already, we have to factor the m out when computing
927 // the background positioning area. 927 // the background positioning area.
(...skipping 16 matching lines...) Expand all
944 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint())); 944 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint()));
945 viewportRect.moveBy(-absoluteContainerOffset); 945 viewportRect.moveBy(-absoluteContainerOffset);
946 } 946 }
947 947
948 geometry.setDestRect(pixelSnappedIntRect(viewportRect)); 948 geometry.setDestRect(pixelSnappedIntRect(viewportRect));
949 positioningAreaSize = geometry.destRect().size(); 949 positioningAreaSize = geometry.destRect().size();
950 } 950 }
951 951
952 const RenderObject* clientForBackgroundImage = backgroundObject ? background Object : this; 952 const RenderObject* clientForBackgroundImage = backgroundObject ? background Object : this;
953 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize) ; 953 IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize) ;
954 fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fi llTileSize, style()->effectiveZoom()); 954 fillLayer.image()->setContainerSizeForRenderer(clientForBackgroundImage, fil lTileSize, style()->effectiveZoom());
955 geometry.setTileSize(fillTileSize); 955 geometry.setTileSize(fillTileSize);
956 956
957 EFillRepeat backgroundRepeatX = fillLayer->repeatX(); 957 EFillRepeat backgroundRepeatX = fillLayer.repeatX();
958 EFillRepeat backgroundRepeatY = fillLayer->repeatY(); 958 EFillRepeat backgroundRepeatY = fillLayer.repeatY();
959 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width (); 959 int availableWidth = positioningAreaSize.width() - geometry.tileSize().width ();
960 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei ght(); 960 int availableHeight = positioningAreaSize.height() - geometry.tileSize().hei ght();
961 961
962 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer->xPosi tion(), availableWidth); 962 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit ion(), availableWidth);
963 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil lTileSize.width() > 0) { 963 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil lTileSize.width() > 0) {
964 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() / fillTileSize.width())); 964 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() / fillTileSize.width()));
965 965
966 if (fillLayer->size().size.height().isAuto() && backgroundRepeatY != Rou ndFill) { 966 if (fillLayer.size().size.height().isAuto() && backgroundRepeatY != Roun dFill) {
967 fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.w idth() / (nrTiles * fillTileSize.width())); 967 fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.w idth() / (nrTiles * fillTileSize.width()));
968 } 968 }
969 969
970 fillTileSize.setWidth(positioningAreaSize.width() / nrTiles); 970 fillTileSize.setWidth(positioningAreaSize.width() / nrTiles);
971 geometry.setTileSize(fillTileSize); 971 geometry.setTileSize(fillTileSize);
972 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); 972 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0);
973 geometry.setSpaceSize(IntSize()); 973 geometry.setSpaceSize(IntSize());
974 } 974 }
975 975
976 LayoutUnit computedYPosition = roundedMinimumValueForLength(fillLayer->yPosi tion(), availableHeight); 976 LayoutUnit computedYPosition = roundedMinimumValueForLength(fillLayer.yPosit ion(), availableHeight);
977 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fi llTileSize.height() > 0) { 977 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fi llTileSize.height() > 0) {
978 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.height() / fillTileSize.height())); 978 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.height() / fillTileSize.height()));
979 979
980 if (fillLayer->size().size.width().isAuto() && backgroundRepeatX != Roun dFill) { 980 if (fillLayer.size().size.width().isAuto() && backgroundRepeatX != Round Fill) {
981 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei ght() / (nrTiles * fillTileSize.height())); 981 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei ght() / (nrTiles * fillTileSize.height()));
982 } 982 }
983 983
984 fillTileSize.setHeight(positioningAreaSize.height() / nrTiles); 984 fillTileSize.setHeight(positioningAreaSize.height() / nrTiles);
985 geometry.setTileSize(fillTileSize); 985 geometry.setTileSize(fillTileSize);
986 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ; 986 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ;
987 geometry.setSpaceSize(IntSize()); 987 geometry.setSpaceSize(IntSize());
988 } 988 }
989 989
990 if (backgroundRepeatX == RepeatFill) { 990 if (backgroundRepeatX == RepeatFill) {
991 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0); 991 geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().wid th() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0);
992 geometry.setSpaceSize(IntSize()); 992 geometry.setSpaceSize(IntSize());
993 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) { 993 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) {
994 int space = getSpace(positioningAreaSize.width(), geometry.tileSize().wi dth()); 994 int space = getSpace(positioningAreaSize.width(), geometry.tileSize().wi dth());
995 int actualWidth = geometry.tileSize().width() + space; 995 int actualWidth = geometry.tileSize().width() + space;
996 996
997 if (space >= 0) { 997 if (space >= 0) {
998 computedXPosition = roundedMinimumValueForLength(Length(), available Width); 998 computedXPosition = roundedMinimumValueForLength(Length(), available Width);
999 geometry.setSpaceSize(IntSize(space, 0)); 999 geometry.setSpaceSize(IntSize(space, 0));
1000 geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXP osition + left) % actualWidth : 0); 1000 geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXP osition + left) % actualWidth : 0);
1001 } else { 1001 } else {
1002 backgroundRepeatX = NoRepeatFill; 1002 backgroundRepeatX = NoRepeatFill;
1003 } 1003 }
1004 } 1004 }
1005 if (backgroundRepeatX == NoRepeatFill) { 1005 if (backgroundRepeatX == NoRepeatFill) {
1006 int xOffset = fillLayer->backgroundXOrigin() == RightEdge ? availableWid th - computedXPosition : computedXPosition; 1006 int xOffset = fillLayer.backgroundXOrigin() == RightEdge ? availableWidt h - computedXPosition : computedXPosition;
1007 geometry.setNoRepeatX(left + xOffset); 1007 geometry.setNoRepeatX(left + xOffset);
1008 geometry.setSpaceSize(IntSize(0, geometry.spaceSize().height())); 1008 geometry.setSpaceSize(IntSize(0, geometry.spaceSize().height()));
1009 } 1009 }
1010 1010
1011 if (backgroundRepeatY == RepeatFill) { 1011 if (backgroundRepeatY == RepeatFill) {
1012 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ; 1012 geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().he ight() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0) ;
1013 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); 1013 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0));
1014 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) { 1014 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) {
1015 int space = getSpace(positioningAreaSize.height(), geometry.tileSize().h eight()); 1015 int space = getSpace(positioningAreaSize.height(), geometry.tileSize().h eight());
1016 int actualHeight = geometry.tileSize().height() + space; 1016 int actualHeight = geometry.tileSize().height() + space;
1017 1017
1018 if (space >= 0) { 1018 if (space >= 0) {
1019 computedYPosition = roundedMinimumValueForLength(Length(), available Height); 1019 computedYPosition = roundedMinimumValueForLength(Length(), available Height);
1020 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), space)); 1020 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), space));
1021 geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computed YPosition + top) % actualHeight : 0); 1021 geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computed YPosition + top) % actualHeight : 0);
1022 } else { 1022 } else {
1023 backgroundRepeatY = NoRepeatFill; 1023 backgroundRepeatY = NoRepeatFill;
1024 } 1024 }
1025 } 1025 }
1026 if (backgroundRepeatY == NoRepeatFill) { 1026 if (backgroundRepeatY == NoRepeatFill) {
1027 int yOffset = fillLayer->backgroundYOrigin() == BottomEdge ? availableHe ight - computedYPosition : computedYPosition; 1027 int yOffset = fillLayer.backgroundYOrigin() == BottomEdge ? availableHei ght - computedYPosition : computedYPosition;
1028 geometry.setNoRepeatY(top + yOffset); 1028 geometry.setNoRepeatY(top + yOffset);
1029 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0)); 1029 geometry.setSpaceSize(IntSize(geometry.spaceSize().width(), 0));
1030 } 1030 }
1031 1031
1032 if (fixedAttachment) 1032 if (fixedAttachment)
1033 geometry.useFixedAttachment(snappedPaintRect.location()); 1033 geometry.useFixedAttachment(snappedPaintRect.location());
1034 1034
1035 geometry.clip(snappedPaintRect); 1035 geometry.clip(snappedPaintRect);
1036 geometry.setDestOrigin(geometry.destRect().location()); 1036 geometry.setDestOrigin(geometry.destRect().location());
1037 } 1037 }
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 return false; 2349 return false;
2350 } 2350 }
2351 2351
2352 if (!hasOneNormalBoxShadow) 2352 if (!hasOneNormalBoxShadow)
2353 return false; 2353 return false;
2354 2354
2355 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); 2355 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
2356 if (backgroundColor.hasAlpha()) 2356 if (backgroundColor.hasAlpha())
2357 return false; 2357 return false;
2358 2358
2359 const FillLayer* lastBackgroundLayer = style()->backgroundLayers(); 2359 const FillLayer* lastBackgroundLayer = &style()->backgroundLayers();
2360 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB ackgroundLayer->next()) 2360 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB ackgroundLayer->next())
2361 lastBackgroundLayer = next; 2361 lastBackgroundLayer = next;
2362 2362
2363 if (lastBackgroundLayer->clip() != BorderFillBox) 2363 if (lastBackgroundLayer->clip() != BorderFillBox)
2364 return false; 2364 return false;
2365 2365
2366 if (lastBackgroundLayer->image() && style()->hasBorderRadius()) 2366 if (lastBackgroundLayer->image() && style()->hasBorderRadius())
2367 return false; 2367 return false;
2368 2368
2369 if (inlineFlowBox && !inlineFlowBox->boxShadowCanBeAppliedToBackground(*last BackgroundLayer)) 2369 if (inlineFlowBox && !inlineFlowBox->boxShadowCanBeAppliedToBackground(*last BackgroundLayer))
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2727 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2728 for (RenderObject* child = startChild; child && child != endChild; ) { 2728 for (RenderObject* child = startChild; child && child != endChild; ) {
2729 // Save our next sibling as moveChildTo will clear it. 2729 // Save our next sibling as moveChildTo will clear it.
2730 RenderObject* nextSibling = child->nextSibling(); 2730 RenderObject* nextSibling = child->nextSibling();
2731 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2731 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2732 child = nextSibling; 2732 child = nextSibling;
2733 } 2733 }
2734 } 2734 }
2735 2735
2736 } // namespace WebCore 2736 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698