| 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 rectOpacity) 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 (rectOpacity == BackgroundKnownOpaqueRect) { |
| 719 if (cur->blendMode() != WebBlendModeNormal || cur->composite() !
= CompositeSourceOver) |
| 720 continue; |
| 721 // Check if the image or color has alpha. |
| 722 if (const StyleImage* image = cur->image()) { |
| 723 if (!image->knownToBeOpaque(*this)) |
| 724 continue; |
| 725 } else if (!cur->next()) { |
| 726 Color backgroundColor = resolveColor(CSSPropertyBackgroundCo
lor); |
| 727 if (backgroundColor.hasAlpha()) |
| 728 continue; |
| 729 } else { |
| 730 continue; |
| 731 } |
| 732 } |
| 733 EFillBox currentClip = cur->clip(); |
| 734 // Adjust clip if attachment is local. |
| 735 if (currentClip == BorderFillBox && cur->attachment() == LocalBackgr
oundAttachment) |
| 736 currentClip = PaddingFillBox; |
| 737 backgroundBox = enclosingFillBox(backgroundBox, currentClip); |
| 738 } while (current); |
| 739 } |
| 740 switch (backgroundBox) { |
| 714 case BorderFillBox: | 741 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(); | 742 return borderBoxRect(); |
| 720 break; | 743 break; |
| 721 case PaddingFillBox: | 744 case PaddingFillBox: |
| 722 return paddingBoxRect(); | 745 return paddingBoxRect(); |
| 723 break; | 746 break; |
| 724 case ContentFillBox: | 747 case ContentFillBox: |
| 725 return contentBoxRect(); | 748 return contentBoxRect(); |
| 726 break; | 749 break; |
| 727 default: | 750 default: |
| 728 break; | 751 break; |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 return false; | 1395 return false; |
| 1373 paintedExtent = LayoutRect(geometry.destRect()); | 1396 paintedExtent = LayoutRect(geometry.destRect()); |
| 1374 return true; | 1397 return true; |
| 1375 } | 1398 } |
| 1376 | 1399 |
| 1377 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
onst | 1400 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
onst |
| 1378 { | 1401 { |
| 1379 if (isDocumentElement() || backgroundStolenForBeingBody()) | 1402 if (isDocumentElement() || backgroundStolenForBeingBody()) |
| 1380 return false; | 1403 return false; |
| 1381 | 1404 |
| 1382 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); | |
| 1383 if (backgroundColor.hasAlpha()) | |
| 1384 return false; | |
| 1385 | |
| 1386 // If the element has appearance, it might be painted by theme. | 1405 // If the element has appearance, it might be painted by theme. |
| 1387 // We cannot be sure if theme paints the background opaque. | 1406 // We cannot be sure if theme paints the background opaque. |
| 1388 // In this case it is safe to not assume opaqueness. | 1407 // In this case it is safe to not assume opaqueness. |
| 1389 // FIXME: May be ask theme if it paints opaque. | 1408 // FIXME: May be ask theme if it paints opaque. |
| 1390 if (style()->hasAppearance()) | 1409 if (style()->hasAppearance()) |
| 1391 return false; | 1410 return false; |
| 1392 // FIXME: Check the opaqueness of background images. | 1411 // FIXME: Check the opaqueness of background images. |
| 1393 | 1412 |
| 1394 // FIXME: Use rounded rect if border radius is present. | 1413 // FIXME: Use rounded rect if border radius is present. |
| 1395 if (style()->hasBorderRadius()) | 1414 if (style()->hasBorderRadius()) |
| 1396 return false; | 1415 return false; |
| 1397 if (hasClipPath()) | 1416 if (hasClipPath()) |
| 1398 return false; | 1417 return false; |
| 1399 // FIXME: The background color clip is defined by the last layer. | 1418 if (style()->hasBlendMode()) |
| 1400 if (style()->backgroundLayers().next()) | |
| 1401 return false; | 1419 return false; |
| 1402 return backgroundClipRect().contains(localRect); | 1420 return backgroundRect(BackgroundKnownOpaqueRect).contains(localRect); |
| 1403 } | 1421 } |
| 1404 | 1422 |
| 1405 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) | 1423 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) |
| 1406 { | 1424 { |
| 1407 const ComputedStyle& childStyle = childBox.styleRef(); | 1425 const ComputedStyle& childStyle = childBox.styleRef(); |
| 1408 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) | 1426 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) |
| 1409 return false; | 1427 return false; |
| 1410 if (childStyle.visibility() != EVisibility::Visible || childStyle.shapeOutsi
de()) | 1428 if (childStyle.visibility() != EVisibility::Visible || childStyle.shapeOutsi
de()) |
| 1411 return false; | 1429 return false; |
| 1412 if (childBox.size().isZero()) | 1430 if (childBox.size().isZero()) |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 LayoutBoxModelObject::mapLocalToAncestor(ancestor, transformState, mode); | 1766 LayoutBoxModelObject::mapLocalToAncestor(ancestor, transformState, mode); |
| 1749 } | 1767 } |
| 1750 | 1768 |
| 1751 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo
rmState& transformState, MapCoordinatesFlags mode) const | 1769 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo
rmState& transformState, MapCoordinatesFlags mode) const |
| 1752 { | 1770 { |
| 1753 if (this == ancestor) | 1771 if (this == ancestor) |
| 1754 return; | 1772 return; |
| 1755 | 1773 |
| 1756 bool isFixedPos = style()->position() == FixedPosition; | 1774 bool isFixedPos = style()->position() == FixedPosition; |
| 1757 | 1775 |
| 1758 if (style()->canContainFixedPositionObjects() && !isFixedPos) { | 1776 // If this box has a transform or contains paint, it acts as a fixed positio
n container for fixed descendants, |
| 1759 // If this box has a transform or contains paint, it acts as a fixed pos
ition container for fixed descendants, | 1777 // and may itself also be fixed position. So propagate 'fixed' up only if th
is box is fixed position. |
| 1760 // and may itself also be fixed position. So propagate 'fixed' up only i
f this box is fixed position. | 1778 if (style()->canContainFixedPositionObjects() && !isFixedPos) |
| 1761 mode &= ~IsFixed; | 1779 mode &= ~IsFixed; |
| 1762 } else if (isFixedPos) { | 1780 else if (isFixedPos) |
| 1763 mode |= IsFixed; | 1781 mode |= IsFixed; |
| 1764 } | |
| 1765 | 1782 |
| 1766 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); | 1783 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); |
| 1767 } | 1784 } |
| 1768 | 1785 |
| 1769 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const | 1786 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const |
| 1770 { | 1787 { |
| 1771 ASSERT(o == container()); | 1788 ASSERT(o == container()); |
| 1772 | 1789 |
| 1773 LayoutSize offset; | 1790 LayoutSize offset; |
| 1774 if (isInFlowPositioned()) | 1791 if (isInFlowPositioned()) |
| (...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4768 m_rareData->m_snapAreas->remove(&snapArea); | 4785 m_rareData->m_snapAreas->remove(&snapArea); |
| 4769 } | 4786 } |
| 4770 } | 4787 } |
| 4771 | 4788 |
| 4772 SnapAreaSet* LayoutBox::snapAreas() const | 4789 SnapAreaSet* LayoutBox::snapAreas() const |
| 4773 { | 4790 { |
| 4774 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 4791 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
| 4775 } | 4792 } |
| 4776 | 4793 |
| 4777 } // namespace blink | 4794 } // namespace blink |
| OLD | NEW |