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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
720 break; | 720 break; |
721 case ContentFillBox: | 721 case ContentFillBox: |
722 return contentBoxRect(); | 722 return contentBoxRect(); |
723 break; | 723 break; |
724 default: | 724 default: |
725 break; | 725 break; |
726 } | 726 } |
727 return LayoutRect(); | 727 return LayoutRect(); |
728 } | 728 } |
729 | 729 |
730 LayoutRect LayoutBox::opaqueBackgroundClipRect() const | |
731 { | |
732 EFillBox backgroundClip = TextFillBox; | |
733 // Find the largest opaque background clip rect. | |
734 // TODO(flackr): Unify with the above method. | |
735 if (const FillLayer* current = &(style()->backgroundLayers())) { | |
736 do { | |
737 const FillLayer* cur = current; | |
738 current = current->next(); | |
739 if (cur->blendMode() != WebBlendModeNormal || cur->composite() != Co mpositeSourceOver) | |
740 continue; | |
741 // Check if the image or color has alpha. | |
742 if (const StyleImage* image = cur->image()) { | |
743 if (!image->knownToBeOpaque(*this)) | |
744 continue; | |
745 } else { | |
746 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor) ; | |
747 if (backgroundColor.hasAlpha()) | |
748 continue; | |
749 } | |
750 EFillBox currentClip = cur->clip(); | |
751 // Adjust clip if attachment is local. | |
752 if (currentClip == BorderFillBox && cur->attachment() == LocalBackgr oundAttachment) | |
753 currentClip = PaddingFillBox; | |
754 // TODO(flackr): Expose and use clipMax method from FillLayer.cpp. | |
755 if (currentClip < backgroundClip) | |
756 backgroundClip = currentClip; | |
757 } while (current); | |
758 } | |
759 switch (backgroundClip) { | |
760 case BorderFillBox: | |
761 return borderBoxRect(); | |
762 break; | |
763 case PaddingFillBox: | |
764 return paddingBoxRect(); | |
765 break; | |
766 case ContentFillBox: | |
767 return contentBoxRect(); | |
768 break; | |
769 default: | |
770 break; | |
771 } | |
772 return LayoutRect(); | |
773 } | |
774 | |
730 void LayoutBox::addOutlineRects(Vector<LayoutRect>& rects, const LayoutPoint& ad ditionalOffset, IncludeBlockVisualOverflowOrNot) const | 775 void LayoutBox::addOutlineRects(Vector<LayoutRect>& rects, const LayoutPoint& ad ditionalOffset, IncludeBlockVisualOverflowOrNot) const |
731 { | 776 { |
732 rects.append(LayoutRect(additionalOffset, size())); | 777 rects.append(LayoutRect(additionalOffset, size())); |
733 } | 778 } |
734 | 779 |
735 bool LayoutBox::canResize() const | 780 bool LayoutBox::canResize() const |
736 { | 781 { |
737 // We need a special case for <iframe> because they never have | 782 // We need a special case for <iframe> because they never have |
738 // hasOverflowClip(). However, they do "implicitly" clip their contents, so | 783 // hasOverflowClip(). However, they do "implicitly" clip their contents, so |
739 // we want to allow resizing them also. | 784 // we want to allow resizing them also. |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1388 return false; | 1433 return false; |
1389 paintedExtent = LayoutRect(geometry.destRect()); | 1434 paintedExtent = LayoutRect(geometry.destRect()); |
1390 return true; | 1435 return true; |
1391 } | 1436 } |
1392 | 1437 |
1393 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c onst | 1438 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c onst |
1394 { | 1439 { |
1395 if (isDocumentElement() || backgroundStolenForBeingBody()) | 1440 if (isDocumentElement() || backgroundStolenForBeingBody()) |
1396 return false; | 1441 return false; |
1397 | 1442 |
1398 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); | |
1399 if (backgroundColor.hasAlpha()) | |
1400 return false; | |
1401 | |
1402 // If the element has appearance, it might be painted by theme. | 1443 // If the element has appearance, it might be painted by theme. |
1403 // We cannot be sure if theme paints the background opaque. | 1444 // We cannot be sure if theme paints the background opaque. |
1404 // In this case it is safe to not assume opaqueness. | 1445 // In this case it is safe to not assume opaqueness. |
1405 // FIXME: May be ask theme if it paints opaque. | 1446 // FIXME: May be ask theme if it paints opaque. |
1406 if (style()->hasAppearance()) | 1447 if (style()->hasAppearance()) |
1407 return false; | 1448 return false; |
1408 // FIXME: Check the opaqueness of background images. | 1449 // FIXME: Check the opaqueness of background images. |
1409 | 1450 |
1410 // FIXME: Use rounded rect if border radius is present. | 1451 // FIXME: Use rounded rect if border radius is present. |
1411 if (style()->hasBorderRadius()) | 1452 if (style()->hasBorderRadius()) |
1412 return false; | 1453 return false; |
1413 if (hasClipPath()) | 1454 if (hasClipPath()) |
1414 return false; | 1455 return false; |
1415 // FIXME: The background color clip is defined by the last layer. | 1456 if (style()->hasBlendMode()) |
1416 if (style()->backgroundLayers().next()) | |
1417 return false; | 1457 return false; |
1418 return backgroundClipRect().contains(localRect); | 1458 return opaqueBackgroundClipRect().contains(localRect); |
1419 } | 1459 } |
1420 | 1460 |
1421 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) | 1461 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) |
1422 { | 1462 { |
1423 const ComputedStyle& childStyle = childBox.styleRef(); | 1463 const ComputedStyle& childStyle = childBox.styleRef(); |
1424 if (childStyle.position() != StaticPosition && childBox.containingBlock() != childBox.parent()) | 1464 if (childStyle.position() != StaticPosition && childBox.containingBlock() != childBox.parent()) |
1425 return false; | 1465 return false; |
1426 if (childStyle.visibility() != VISIBLE || childStyle.shapeOutside()) | 1466 if (childStyle.visibility() != VISIBLE || childStyle.shapeOutside()) |
1427 return false; | 1467 return false; |
1428 if (childBox.size().isZero()) | 1468 if (childBox.size().isZero()) |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1783 } | 1823 } |
1784 | 1824 |
1785 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo rmState& transformState, MapCoordinatesFlags mode) const | 1825 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo rmState& transformState, MapCoordinatesFlags mode) const |
1786 { | 1826 { |
1787 if (this == ancestor) | 1827 if (this == ancestor) |
1788 return; | 1828 return; |
1789 | 1829 |
1790 bool isFixedPos = style()->position() == FixedPosition; | 1830 bool isFixedPos = style()->position() == FixedPosition; |
1791 | 1831 |
1792 if (style()->canContainFixedPositionObjects() && !isFixedPos) { | 1832 if (style()->canContainFixedPositionObjects() && !isFixedPos) { |
1793 // If this box has a transform or contains paint, it acts as a fixed pos ition container for fixed descendants, | 1833 // If this box has a transform or contains paint, it acts as a fixed pos ition container for fixed descendants, |
Stephen Chennney
2016/07/27 22:33:36
The previous method has the comment outside the bl
flackr
2016/07/28 14:39:20
Done.
| |
1794 // and may itself also be fixed position. So propagate 'fixed' up only i f this box is fixed position. | 1834 // and may itself also be fixed position. So propagate 'fixed' up only i f this box is fixed position. |
1795 mode &= ~IsFixed; | 1835 mode &= ~IsFixed; |
1796 } else if (isFixedPos) { | 1836 } else if (isFixedPos) { |
1797 mode |= IsFixed; | 1837 mode |= IsFixed; |
1798 } | 1838 } |
1799 | 1839 |
1800 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); | 1840 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); |
1801 } | 1841 } |
1802 | 1842 |
1803 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const | 1843 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const |
(...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4985 m_rareData->m_snapAreas->remove(&snapArea); | 5025 m_rareData->m_snapAreas->remove(&snapArea); |
4986 } | 5026 } |
4987 } | 5027 } |
4988 | 5028 |
4989 SnapAreaSet* LayoutBox::snapAreas() const | 5029 SnapAreaSet* LayoutBox::snapAreas() const |
4990 { | 5030 { |
4991 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 5031 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
4992 } | 5032 } |
4993 | 5033 |
4994 } // namespace blink | 5034 } // namespace blink |
OLD | NEW |