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, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 offset.move(absPos.x(), absPos.y()); | 700 offset.move(absPos.x(), absPos.y()); |
701 return toIntSize(offset); | 701 return toIntSize(offset); |
702 } | 702 } |
703 | 703 |
704 FloatQuad LayoutBox::absoluteContentQuad() const | 704 FloatQuad LayoutBox::absoluteContentQuad() const |
705 { | 705 { |
706 LayoutRect rect = contentBoxRect(); | 706 LayoutRect rect = contentBoxRect(); |
707 return localToAbsoluteQuad(FloatRect(rect)); | 707 return localToAbsoluteQuad(FloatRect(rect)); |
708 } | 708 } |
709 | 709 |
710 LayoutRect LayoutBox::backgroundClipRect() const | 710 LayoutRect LayoutBox::backgroundRect(BackgroundRectType rectType) const |
711 { | 711 { |
712 // TODO(flackr): Check for the maximum background clip rect. | 712 EFillBox backgroundBox = TextFillBox; |
713 switch (style()->backgroundClip()) { | 713 // Find the largest background rect of the given opaqueness. |
| 714 if (const FillLayer* current = &(style()->backgroundLayers())) { |
| 715 do { |
| 716 const FillLayer* cur = current; |
| 717 current = current->next(); |
| 718 if (rectType == BackgroundKnownOpaqueRect) { |
| 719 if (cur->blendMode() != WebBlendModeNormal || cur->composite() !
= CompositeSourceOver) |
| 720 continue; |
| 721 |
| 722 bool layerKnownOpaque = false; |
| 723 // Check if the image or color has alpha. |
| 724 if (const StyleImage* image = cur->image()) { |
| 725 if (image->knownToBeOpaque(*this)) |
| 726 layerKnownOpaque = true; |
| 727 } |
| 728 |
| 729 // The background color is painted into the last layer. |
| 730 if (!cur->next()) { |
| 731 Color backgroundColor = resolveColor(CSSPropertyBackgroundCo
lor); |
| 732 if (!backgroundColor.hasAlpha()) |
| 733 layerKnownOpaque = true; |
| 734 } |
| 735 |
| 736 // If neither the image nor the color are opaque then skip this
layer. |
| 737 if (!layerKnownOpaque) |
| 738 continue; |
| 739 } |
| 740 EFillBox currentClip = cur->clip(); |
| 741 // Restrict clip if attachment is local. |
| 742 if (currentClip == BorderFillBox && cur->attachment() == LocalBackgr
oundAttachment) |
| 743 currentClip = PaddingFillBox; |
| 744 |
| 745 // If we're asking for the clip rect, a content-box clipped fill lay
er can be scrolled |
| 746 // into the padding box of the overflow container. |
| 747 if (rectType == BackgroundClipRect |
| 748 && currentClip == ContentFillBox && cur->attachment() == LocalBa
ckgroundAttachment) { |
| 749 currentClip = PaddingFillBox; |
| 750 } |
| 751 |
| 752 backgroundBox = enclosingFillBox(backgroundBox, currentClip); |
| 753 } while (current); |
| 754 } |
| 755 switch (backgroundBox) { |
714 case BorderFillBox: | 756 case BorderFillBox: |
715 // A 'border-box' clip on scrollable elements local attachment is treate
d as 'padding-box'. | |
716 // https://www.w3.org/TR/css3-background/#the-background-attachment | |
717 if (!style()->isOverflowVisible() && style()->backgroundLayers().attachm
ent() == LocalBackgroundAttachment) | |
718 return paddingBoxRect(); | |
719 return borderBoxRect(); | 757 return borderBoxRect(); |
720 break; | 758 break; |
721 case PaddingFillBox: | 759 case PaddingFillBox: |
722 return paddingBoxRect(); | 760 return paddingBoxRect(); |
723 break; | 761 break; |
724 case ContentFillBox: | 762 case ContentFillBox: |
725 return contentBoxRect(); | 763 return contentBoxRect(); |
726 break; | 764 break; |
727 default: | 765 default: |
728 break; | 766 break; |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 return false; | 1427 return false; |
1390 paintedExtent = LayoutRect(geometry.destRect()); | 1428 paintedExtent = LayoutRect(geometry.destRect()); |
1391 return true; | 1429 return true; |
1392 } | 1430 } |
1393 | 1431 |
1394 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
onst | 1432 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
onst |
1395 { | 1433 { |
1396 if (isDocumentElement() || backgroundStolenForBeingBody()) | 1434 if (isDocumentElement() || backgroundStolenForBeingBody()) |
1397 return false; | 1435 return false; |
1398 | 1436 |
1399 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); | |
1400 if (backgroundColor.hasAlpha()) | |
1401 return false; | |
1402 | |
1403 // If the element has appearance, it might be painted by theme. | 1437 // If the element has appearance, it might be painted by theme. |
1404 // We cannot be sure if theme paints the background opaque. | 1438 // We cannot be sure if theme paints the background opaque. |
1405 // In this case it is safe to not assume opaqueness. | 1439 // In this case it is safe to not assume opaqueness. |
1406 // FIXME: May be ask theme if it paints opaque. | 1440 // FIXME: May be ask theme if it paints opaque. |
1407 if (style()->hasAppearance()) | 1441 if (style()->hasAppearance()) |
1408 return false; | 1442 return false; |
1409 // FIXME: Check the opaqueness of background images. | 1443 // FIXME: Check the opaqueness of background images. |
1410 | 1444 |
1411 // FIXME: Use rounded rect if border radius is present. | 1445 // FIXME: Use rounded rect if border radius is present. |
1412 if (style()->hasBorderRadius()) | 1446 if (style()->hasBorderRadius()) |
1413 return false; | 1447 return false; |
1414 if (hasClipPath()) | 1448 if (hasClipPath()) |
1415 return false; | 1449 return false; |
1416 // FIXME: The background color clip is defined by the last layer. | 1450 if (style()->hasBlendMode()) |
1417 if (style()->backgroundLayers().next()) | |
1418 return false; | 1451 return false; |
1419 return backgroundClipRect().contains(localRect); | 1452 return backgroundRect(BackgroundKnownOpaqueRect).contains(localRect); |
1420 } | 1453 } |
1421 | 1454 |
1422 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) | 1455 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) |
1423 { | 1456 { |
1424 const ComputedStyle& childStyle = childBox.styleRef(); | 1457 const ComputedStyle& childStyle = childBox.styleRef(); |
1425 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) | 1458 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) |
1426 return false; | 1459 return false; |
1427 if (childStyle.visibility() != EVisibility::Visible || childStyle.shapeOutsi
de()) | 1460 if (childStyle.visibility() != EVisibility::Visible || childStyle.shapeOutsi
de()) |
1428 return false; | 1461 return false; |
1429 if (childBox.size().isZero()) | 1462 if (childBox.size().isZero()) |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 LayoutBoxModelObject::mapLocalToAncestor(ancestor, transformState, mode); | 1810 LayoutBoxModelObject::mapLocalToAncestor(ancestor, transformState, mode); |
1778 } | 1811 } |
1779 | 1812 |
1780 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo
rmState& transformState, MapCoordinatesFlags mode) const | 1813 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo
rmState& transformState, MapCoordinatesFlags mode) const |
1781 { | 1814 { |
1782 if (this == ancestor) | 1815 if (this == ancestor) |
1783 return; | 1816 return; |
1784 | 1817 |
1785 bool isFixedPos = style()->position() == FixedPosition; | 1818 bool isFixedPos = style()->position() == FixedPosition; |
1786 | 1819 |
1787 if (style()->canContainFixedPositionObjects() && !isFixedPos) { | 1820 // If this box has a transform or contains paint, it acts as a fixed positio
n container for fixed descendants, |
1788 // If this box has a transform or contains paint, it acts as a fixed pos
ition container for fixed descendants, | 1821 // and may itself also be fixed position. So propagate 'fixed' up only if th
is box is fixed position. |
1789 // and may itself also be fixed position. So propagate 'fixed' up only i
f this box is fixed position. | 1822 if (style()->canContainFixedPositionObjects() && !isFixedPos) |
1790 mode &= ~IsFixed; | 1823 mode &= ~IsFixed; |
1791 } else if (isFixedPos) { | 1824 else if (isFixedPos) |
1792 mode |= IsFixed; | 1825 mode |= IsFixed; |
1793 } | |
1794 | 1826 |
1795 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); | 1827 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); |
1796 } | 1828 } |
1797 | 1829 |
1798 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const | 1830 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const |
1799 { | 1831 { |
1800 ASSERT(o == container()); | 1832 ASSERT(o == container()); |
1801 | 1833 |
1802 LayoutSize offset; | 1834 LayoutSize offset; |
1803 if (isInFlowPositioned()) | 1835 if (isInFlowPositioned()) |
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4797 m_rareData->m_snapAreas->remove(&snapArea); | 4829 m_rareData->m_snapAreas->remove(&snapArea); |
4798 } | 4830 } |
4799 } | 4831 } |
4800 | 4832 |
4801 SnapAreaSet* LayoutBox::snapAreas() const | 4833 SnapAreaSet* LayoutBox::snapAreas() const |
4802 { | 4834 { |
4803 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4835 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
4804 } | 4836 } |
4805 | 4837 |
4806 } // namespace blink | 4838 } // namespace blink |
OLD | NEW |