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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 if (bleedAvoidance == BackgroundBleedShrinkBackground) { | 502 if (bleedAvoidance == BackgroundBleedShrinkBackground) { |
503 // We shrink the rectangle by one pixel on each side because the bleed i
s one pixel maximum. | 503 // We shrink the rectangle by one pixel on each side because the bleed i
s one pixel maximum. |
504 return getBackgroundRoundedRect(shrinkRectByOnePixel(context, borderRect
), box, boxSize.width(), boxSize.height(), includeLogicalLeftEdge, includeLogica
lRightEdge); | 504 return getBackgroundRoundedRect(shrinkRectByOnePixel(context, borderRect
), box, boxSize.width(), boxSize.height(), includeLogicalLeftEdge, includeLogica
lRightEdge); |
505 } | 505 } |
506 if (bleedAvoidance == BackgroundBleedBackgroundOverBorder) | 506 if (bleedAvoidance == BackgroundBleedBackgroundOverBorder) |
507 return style()->getRoundedInnerBorderFor(borderRect, includeLogicalLeftE
dge, includeLogicalRightEdge); | 507 return style()->getRoundedInnerBorderFor(borderRect, includeLogicalLeftE
dge, includeLogicalRightEdge); |
508 | 508 |
509 return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.he
ight(), includeLogicalLeftEdge, includeLogicalRightEdge); | 509 return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.he
ight(), includeLogicalLeftEdge, includeLogicalRightEdge); |
510 } | 510 } |
511 | 511 |
512 static void applyBoxShadowForBackground(GraphicsContext* context, RenderStyle* s
tyle) | 512 static void applyBoxShadowForBackground(GraphicsContext* context, const RenderOb
ject* renderer) |
513 { | 513 { |
514 const ShadowData* boxShadow = style->boxShadow(); | 514 const ShadowData* boxShadow = renderer->style()->boxShadow(); |
515 while (boxShadow->style() != Normal) | 515 while (boxShadow->style() != Normal) |
516 boxShadow = boxShadow->next(); | 516 boxShadow = boxShadow->next(); |
517 | 517 |
518 FloatSize shadowOffset(boxShadow->x(), boxShadow->y()); | 518 FloatSize shadowOffset(boxShadow->x(), boxShadow->y()); |
519 context->setShadow(shadowOffset, boxShadow->blur(), boxShadow->color(), | 519 context->setShadow(shadowOffset, boxShadow->blur(), renderer->resolveColor(b
oxShadow->color()), |
520 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); | 520 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); |
521 } | 521 } |
522 | 522 |
523 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
nst Color& color, const FillLayer* bgLayer, const LayoutRect& rect, | 523 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
nst Color& color, const FillLayer* bgLayer, const LayoutRect& rect, |
524 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz
e& boxSize, CompositeOperator op, RenderObject* backgroundObject) | 524 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const LayoutSiz
e& boxSize, CompositeOperator op, RenderObject* backgroundObject) |
525 { | 525 { |
526 GraphicsContext* context = paintInfo.context; | 526 GraphicsContext* context = paintInfo.context; |
527 if (context->paintingDisabled() || rect.isEmpty()) | 527 if (context->paintingDisabled() || rect.isEmpty()) |
528 return; | 528 return; |
529 | 529 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 bool colorVisible = bgColor.isValid() && bgColor.alpha(); | 566 bool colorVisible = bgColor.isValid() && bgColor.alpha(); |
567 | 567 |
568 // Fast path for drawing simple color backgrounds. | 568 // Fast path for drawing simple color backgrounds. |
569 if (!isRoot && !clippedWithLocalScrolling && !shouldPaintBackgroundImage &&
isBorderFill && !bgLayer->next()) { | 569 if (!isRoot && !clippedWithLocalScrolling && !shouldPaintBackgroundImage &&
isBorderFill && !bgLayer->next()) { |
570 if (!colorVisible) | 570 if (!colorVisible) |
571 return; | 571 return; |
572 | 572 |
573 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli
edToBackground(bleedAvoidance, box); | 573 bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppli
edToBackground(bleedAvoidance, box); |
574 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp
pliedToBackground); | 574 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAp
pliedToBackground); |
575 if (boxShadowShouldBeAppliedToBackground) | 575 if (boxShadowShouldBeAppliedToBackground) |
576 applyBoxShadowForBackground(context, style()); | 576 applyBoxShadowForBackground(context, this); |
577 | 577 |
578 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparency
Layer) { | 578 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparency
Layer) { |
579 RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance(
context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge); | 579 RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance(
context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge); |
580 if (border.isRenderable()) | 580 if (border.isRenderable()) |
581 context->fillRoundedRect(border, bgColor); | 581 context->fillRoundedRect(border, bgColor); |
582 else { | 582 else { |
583 context->save(); | 583 context->save(); |
584 clipRoundedInnerRect(context, rect, border); | 584 clipRoundedInnerRect(context, rect, border); |
585 context->fillRect(border.rect(), bgColor); | 585 context->fillRect(border.rect(), bgColor); |
586 context->restore(); | 586 context->restore(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 Color baseColor; | 710 Color baseColor; |
711 bool shouldClearBackground = false; | 711 bool shouldClearBackground = false; |
712 if (isOpaqueRoot) { | 712 if (isOpaqueRoot) { |
713 baseColor = view()->frameView()->baseBackgroundColor(); | 713 baseColor = view()->frameView()->baseBackgroundColor(); |
714 if (!baseColor.alpha()) | 714 if (!baseColor.alpha()) |
715 shouldClearBackground = true; | 715 shouldClearBackground = true; |
716 } | 716 } |
717 | 717 |
718 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould
BeAppliedToBackground); | 718 GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShould
BeAppliedToBackground); |
719 if (boxShadowShouldBeAppliedToBackground) | 719 if (boxShadowShouldBeAppliedToBackground) |
720 applyBoxShadowForBackground(context, style()); | 720 applyBoxShadowForBackground(context, this); |
721 | 721 |
722 if (baseColor.alpha()) { | 722 if (baseColor.alpha()) { |
723 if (bgColor.alpha()) | 723 if (bgColor.alpha()) |
724 baseColor = baseColor.blend(bgColor); | 724 baseColor = baseColor.blend(bgColor); |
725 | 725 |
726 context->fillRect(backgroundRect, baseColor, CompositeCopy); | 726 context->fillRect(backgroundRect, baseColor, CompositeCopy); |
727 } else if (bgColor.alpha()) { | 727 } else if (bgColor.alpha()) { |
728 CompositeOperator operation = shouldClearBackground ? CompositeC
opy : context->compositeOperation(); | 728 CompositeOperator operation = shouldClearBackground ? CompositeC
opy : context->compositeOperation(); |
729 context->fillRect(backgroundRect, bgColor, operation); | 729 context->fillRect(backgroundRect, bgColor, operation); |
730 } else if (shouldClearBackground) | 730 } else if (shouldClearBackground) |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 if (innerThird.isRounded() && bleedAvoidance != BackgroundBleedU
seTransparencyLayer) | 1777 if (innerThird.isRounded() && bleedAvoidance != BackgroundBleedU
seTransparencyLayer) |
1778 path.addRoundedRect(innerThird); | 1778 path.addRoundedRect(innerThird); |
1779 else | 1779 else |
1780 path.addRect(innerThird.rect()); | 1780 path.addRect(innerThird.rect()); |
1781 } | 1781 } |
1782 | 1782 |
1783 if (innerBorder.isRounded()) | 1783 if (innerBorder.isRounded()) |
1784 path.addRoundedRect(innerBorder); | 1784 path.addRoundedRect(innerBorder); |
1785 else | 1785 else |
1786 path.addRect(innerBorder.rect()); | 1786 path.addRect(innerBorder.rect()); |
1787 | 1787 |
1788 graphicsContext->setFillRule(RULE_EVENODD); | 1788 graphicsContext->setFillRule(RULE_EVENODD); |
1789 graphicsContext->setFillColor(edges[firstVisibleEdge].color); | 1789 graphicsContext->setFillColor(edges[firstVisibleEdge].color); |
1790 graphicsContext->fillPath(path); | 1790 graphicsContext->fillPath(path); |
1791 return; | 1791 return; |
1792 } | 1792 } |
1793 // Avoid creating transparent layers | 1793 // Avoid creating transparent layers |
1794 if (haveAllSolidEdges && numEdgesVisible != 4 && !outerBorder.isRounded(
) && haveAlphaColor) { | 1794 if (haveAllSolidEdges && numEdgesVisible != 4 && !outerBorder.isRounded(
) && haveAlphaColor) { |
1795 Path path; | 1795 Path path; |
1796 | 1796 |
1797 for (int i = BSTop; i <= BSLeft; ++i) { | 1797 for (int i = BSTop; i <= BSLeft; ++i) { |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 { | 2282 { |
2283 graphicsContext->clip(calculateSideRectIncludingInner(outerBorder, edges, si
de)); | 2283 graphicsContext->clip(calculateSideRectIncludingInner(outerBorder, edges, si
de)); |
2284 graphicsContext->clipOutRoundedRect(calculateAdjustedInnerBorder(innerBorder
, side)); | 2284 graphicsContext->clipOutRoundedRect(calculateAdjustedInnerBorder(innerBorder
, side)); |
2285 } | 2285 } |
2286 | 2286 |
2287 void RenderBoxModelObject::getBorderEdgeInfo(BorderEdge edges[], const RenderSty
le* style, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const | 2287 void RenderBoxModelObject::getBorderEdgeInfo(BorderEdge edges[], const RenderSty
le* style, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const |
2288 { | 2288 { |
2289 bool horizontal = style->isHorizontalWritingMode(); | 2289 bool horizontal = style->isHorizontalWritingMode(); |
2290 | 2290 |
2291 edges[BSTop] = BorderEdge(style->borderTopWidth(), | 2291 edges[BSTop] = BorderEdge(style->borderTopWidth(), |
2292 style->visitedDependentColor(CSSPropertyBorderTopColor), | 2292 resolveColor(style, CSSPropertyBorderTopColor), |
2293 style->borderTopStyle(), | 2293 style->borderTopStyle(), |
2294 style->borderTopIsTransparent(), | 2294 style->borderTopIsTransparent(), |
2295 horizontal || includeLogicalLeftEdge); | 2295 horizontal || includeLogicalLeftEdge); |
2296 | 2296 |
2297 edges[BSRight] = BorderEdge(style->borderRightWidth(), | 2297 edges[BSRight] = BorderEdge(style->borderRightWidth(), |
2298 style->visitedDependentColor(CSSPropertyBorderRightColor), | 2298 resolveColor(style, CSSPropertyBorderRightColor), |
2299 style->borderRightStyle(), | 2299 style->borderRightStyle(), |
2300 style->borderRightIsTransparent(), | 2300 style->borderRightIsTransparent(), |
2301 !horizontal || includeLogicalRightEdge); | 2301 !horizontal || includeLogicalRightEdge); |
2302 | 2302 |
2303 edges[BSBottom] = BorderEdge(style->borderBottomWidth(), | 2303 edges[BSBottom] = BorderEdge(style->borderBottomWidth(), |
2304 style->visitedDependentColor(CSSPropertyBorderBottomColor), | 2304 resolveColor(style, CSSPropertyBorderBottomColor), |
2305 style->borderBottomStyle(), | 2305 style->borderBottomStyle(), |
2306 style->borderBottomIsTransparent(), | 2306 style->borderBottomIsTransparent(), |
2307 horizontal || includeLogicalRightEdge); | 2307 horizontal || includeLogicalRightEdge); |
2308 | 2308 |
2309 edges[BSLeft] = BorderEdge(style->borderLeftWidth(), | 2309 edges[BSLeft] = BorderEdge(style->borderLeftWidth(), |
2310 style->visitedDependentColor(CSSPropertyBorderLeftColor), | 2310 resolveColor(style, CSSPropertyBorderLeftColor), |
2311 style->borderLeftStyle(), | 2311 style->borderLeftStyle(), |
2312 style->borderLeftIsTransparent(), | 2312 style->borderLeftIsTransparent(), |
2313 !horizontal || includeLogicalLeftEdge); | 2313 !horizontal || includeLogicalLeftEdge); |
2314 } | 2314 } |
2315 | 2315 |
2316 bool RenderBoxModelObject::borderObscuresBackgroundEdge(const FloatSize& context
Scale) const | 2316 bool RenderBoxModelObject::borderObscuresBackgroundEdge(const FloatSize& context
Scale) const |
2317 { | 2317 { |
2318 BorderEdge edges[4]; | 2318 BorderEdge edges[4]; |
2319 getBorderEdgeInfo(edges, style()); | 2319 getBorderEdgeInfo(edges, style()); |
2320 | 2320 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2367 return false; | 2367 return false; |
2368 hasOneNormalBoxShadow = true; | 2368 hasOneNormalBoxShadow = true; |
2369 | 2369 |
2370 if (currentShadow->spread()) | 2370 if (currentShadow->spread()) |
2371 return false; | 2371 return false; |
2372 } | 2372 } |
2373 | 2373 |
2374 if (!hasOneNormalBoxShadow) | 2374 if (!hasOneNormalBoxShadow) |
2375 return false; | 2375 return false; |
2376 | 2376 |
2377 Color backgroundColor = style()->visitedDependentColor(CSSPropertyBackground
Color); | 2377 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); |
2378 if (!backgroundColor.isValid() || backgroundColor.hasAlpha()) | 2378 if (!backgroundColor.isValid() || backgroundColor.hasAlpha()) |
2379 return false; | 2379 return false; |
2380 | 2380 |
2381 const FillLayer* lastBackgroundLayer = style()->backgroundLayers(); | 2381 const FillLayer* lastBackgroundLayer = style()->backgroundLayers(); |
2382 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB
ackgroundLayer->next()) | 2382 for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastB
ackgroundLayer->next()) |
2383 lastBackgroundLayer = next; | 2383 lastBackgroundLayer = next; |
2384 | 2384 |
2385 if (lastBackgroundLayer->clip() != BorderFillBox) | 2385 if (lastBackgroundLayer->clip() != BorderFillBox) |
2386 return false; | 2386 return false; |
2387 | 2387 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 if (shadow->style() != shadowStyle) | 2429 if (shadow->style() != shadowStyle) |
2430 continue; | 2430 continue; |
2431 | 2431 |
2432 IntSize shadowOffset(shadow->x(), shadow->y()); | 2432 IntSize shadowOffset(shadow->x(), shadow->y()); |
2433 int shadowBlur = shadow->blur(); | 2433 int shadowBlur = shadow->blur(); |
2434 int shadowSpread = shadow->spread(); | 2434 int shadowSpread = shadow->spread(); |
2435 | 2435 |
2436 if (shadowOffset.isZero() && !shadowBlur && !shadowSpread) | 2436 if (shadowOffset.isZero() && !shadowBlur && !shadowSpread) |
2437 continue; | 2437 continue; |
2438 | 2438 |
2439 const Color& shadowColor = shadow->color(); | 2439 const Color& shadowColor = resolveColor(shadow->color()); |
2440 | 2440 |
2441 if (shadow->style() == Normal) { | 2441 if (shadow->style() == Normal) { |
2442 RoundedRect fillRect = border; | 2442 RoundedRect fillRect = border; |
2443 fillRect.inflate(shadowSpread); | 2443 fillRect.inflate(shadowSpread); |
2444 if (fillRect.isEmpty()) | 2444 if (fillRect.isEmpty()) |
2445 continue; | 2445 continue; |
2446 | 2446 |
2447 IntRect shadowRect(border.rect()); | 2447 IntRect shadowRect(border.rect()); |
2448 shadowRect.inflate(shadowBlur + shadowSpread); | 2448 shadowRect.inflate(shadowBlur + shadowSpread); |
2449 shadowRect.move(shadowOffset); | 2449 shadowRect.move(shadowOffset); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); | 2742 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); |
2743 for (RenderObject* child = startChild; child && child != endChild; ) { | 2743 for (RenderObject* child = startChild; child && child != endChild; ) { |
2744 // Save our next sibling as moveChildTo will clear it. | 2744 // Save our next sibling as moveChildTo will clear it. |
2745 RenderObject* nextSibling = child->nextSibling(); | 2745 RenderObject* nextSibling = child->nextSibling(); |
2746 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); | 2746 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); |
2747 child = nextSibling; | 2747 child = nextSibling; |
2748 } | 2748 } |
2749 } | 2749 } |
2750 | 2750 |
2751 } // namespace WebCore | 2751 } // namespace WebCore |
OLD | NEW |