OLD | NEW |
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 bool includePadding = bgLayer.clip() == ContentFillBox; | 473 bool includePadding = bgLayer.clip() == ContentFillBox; |
474 LayoutRect clipRect = LayoutRect(scrolledPaintRect.x() + bLeft + (includ
ePadding ? pLeft : LayoutUnit()), | 474 LayoutRect clipRect = LayoutRect(scrolledPaintRect.x() + bLeft + (includ
ePadding ? pLeft : LayoutUnit()), |
475 scrolledPaintRect.y() + borderTop() + (includePadding ? paddingTop()
: LayoutUnit()), | 475 scrolledPaintRect.y() + borderTop() + (includePadding ? paddingTop()
: LayoutUnit()), |
476 scrolledPaintRect.width() - bLeft - bRight - (includePadding ? pLeft
+ pRight : LayoutUnit()), | 476 scrolledPaintRect.width() - bLeft - bRight - (includePadding ? pLeft
+ pRight : LayoutUnit()), |
477 scrolledPaintRect.height() - borderTop() - borderBottom() - (include
Padding ? paddingTop() + paddingBottom() : LayoutUnit())); | 477 scrolledPaintRect.height() - borderTop() - borderBottom() - (include
Padding ? paddingTop() + paddingBottom() : LayoutUnit())); |
478 backgroundClipStateSaver.save(); | 478 backgroundClipStateSaver.save(); |
479 context->clip(clipRect); | 479 context->clip(clipRect); |
480 | 480 |
481 break; | 481 break; |
482 } | 482 } |
483 case TextFillBox: { | |
484 // First figure out how big the mask has to be. It should be no bigger
than what we need | |
485 // to actually render, so we should intersect the dirty rect with the bo
rder box of the background. | |
486 maskRect = pixelSnappedIntRect(rect); | |
487 maskRect.intersect(paintInfo.rect); | |
488 | |
489 // We draw the background into a separate layer, to be later masked with
yet another layer | |
490 // holding the text content. | |
491 backgroundClipStateSaver.save(); | |
492 context->clip(maskRect); | |
493 context->beginTransparencyLayer(1); | |
494 | |
495 break; | |
496 } | |
497 case BorderFillBox: | 483 case BorderFillBox: |
498 break; | 484 break; |
499 default: | 485 default: |
500 ASSERT_NOT_REACHED(); | 486 ASSERT_NOT_REACHED(); |
501 break; | 487 break; |
502 } | 488 } |
503 | 489 |
504 // Paint the color first underneath all images, culled if background image o
ccludes it. | 490 // Paint the color first underneath all images, culled if background image o
ccludes it. |
505 // FIXME: In the bgLayer->hasFiniteBounds() case, we could improve the culli
ng test | 491 // FIXME: In the bgLayer->hasFiniteBounds() case, we could improve the culli
ng test |
506 // by verifying whether the background image covers the entire layout rect. | 492 // by verifying whether the background image covers the entire layout rect. |
(...skipping 30 matching lines...) Expand all Loading... |
537 InterpolationQuality interpolationQuality = chooseInterpolationQuali
ty(context, image.get(), &bgLayer, geometry.tileSize()); | 523 InterpolationQuality interpolationQuality = chooseInterpolationQuali
ty(context, image.get(), &bgLayer, geometry.tileSize()); |
538 if (bgLayer.maskSourceType() == MaskLuminance) | 524 if (bgLayer.maskSourceType() == MaskLuminance) |
539 context->setColorFilter(ColorFilterLuminanceToAlpha); | 525 context->setColorFilter(ColorFilterLuminanceToAlpha); |
540 InterpolationQuality previousInterpolationQuality = context->imageIn
terpolationQuality(); | 526 InterpolationQuality previousInterpolationQuality = context->imageIn
terpolationQuality(); |
541 context->setImageInterpolationQuality(interpolationQuality); | 527 context->setImageInterpolationQuality(interpolationQuality); |
542 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r
elativePhase(), geometry.tileSize(), | 528 context->drawTiledImage(image.get(), geometry.destRect(), geometry.r
elativePhase(), geometry.tileSize(), |
543 compositeOp, bgLayer.blendMode(), geometry.spaceSize()); | 529 compositeOp, bgLayer.blendMode(), geometry.spaceSize()); |
544 context->setImageInterpolationQuality(previousInterpolationQuality); | 530 context->setImageInterpolationQuality(previousInterpolationQuality); |
545 } | 531 } |
546 } | 532 } |
547 | |
548 if (bgLayer.clip() == TextFillBox) { | |
549 // Create the text mask layer. | |
550 context->setCompositeOperation(CompositeDestinationIn); | |
551 context->beginTransparencyLayer(1); | |
552 | |
553 // FIXME: Workaround for https://code.google.com/p/skia/issues/detail?id
=1291. | |
554 context->clearRect(maskRect); | |
555 | |
556 // Now draw the text into the mask. We do this by painting using a speci
al paint phase that signals to | |
557 // InlineTextBoxes that they should just add their contents to the clip. | |
558 PaintInfo info(context, maskRect, PaintPhaseTextClip, PaintBehaviorForce
BlackText, 0); | |
559 context->setCompositeOperation(CompositeSourceOver); | |
560 if (box) { | |
561 RootInlineBox& root = box->root(); | |
562 box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrol
ledPaintRect.y() - box->y()), root.lineTop(), root.lineBottom()); | |
563 } else { | |
564 LayoutSize localOffset = isBox() ? toRenderBox(this)->locationOffset
() : LayoutSize(); | |
565 paint(info, scrolledPaintRect.location() - localOffset); | |
566 } | |
567 | |
568 context->endLayer(); | |
569 context->endLayer(); | |
570 } | |
571 } | 533 } |
572 | 534 |
573 static inline int resolveWidthForRatio(int height, const FloatSize& intrinsicRat
io) | 535 static inline int resolveWidthForRatio(int height, const FloatSize& intrinsicRat
io) |
574 { | 536 { |
575 return ceilf(height * intrinsicRatio.width() / intrinsicRatio.height()); | 537 return ceilf(height * intrinsicRatio.width() / intrinsicRatio.height()); |
576 } | 538 } |
577 | 539 |
578 static inline int resolveHeightForRatio(int width, const FloatSize& intrinsicRat
io) | 540 static inline int resolveHeightForRatio(int width, const FloatSize& intrinsicRat
io) |
579 { | 541 { |
580 return ceilf(width * intrinsicRatio.height() / intrinsicRatio.width()); | 542 return ceilf(width * intrinsicRatio.height() / intrinsicRatio.width()); |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2529 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); | 2491 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); |
2530 for (RenderObject* child = slowFirstChild(); child; ) { | 2492 for (RenderObject* child = slowFirstChild(); child; ) { |
2531 // Save our next sibling as moveChildTo will clear it. | 2493 // Save our next sibling as moveChildTo will clear it. |
2532 RenderObject* nextSibling = child->nextSibling(); | 2494 RenderObject* nextSibling = child->nextSibling(); |
2533 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); | 2495 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); |
2534 child = nextSibling; | 2496 child = nextSibling; |
2535 } | 2497 } |
2536 } | 2498 } |
2537 | 2499 |
2538 } // namespace blink | 2500 } // namespace blink |
OLD | NEW |