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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
697 offset.move(absPos.x(), absPos.y()); | 697 offset.move(absPos.x(), absPos.y()); |
698 return toIntSize(offset); | 698 return toIntSize(offset); |
699 } | 699 } |
700 | 700 |
701 FloatQuad LayoutBox::absoluteContentQuad() const | 701 FloatQuad LayoutBox::absoluteContentQuad() const |
702 { | 702 { |
703 LayoutRect rect = contentBoxRect(); | 703 LayoutRect rect = contentBoxRect(); |
704 return localToAbsoluteQuad(FloatRect(rect)); | 704 return localToAbsoluteQuad(FloatRect(rect)); |
705 } | 705 } |
706 | 706 |
707 LayoutRect LayoutBox::backgroundClipRect() const | 707 LayoutRect LayoutBox::backgroundRect(BackgroundRectOpacity rectOpacity) const |
trchen
2016/08/13 00:14:08
I'm worried about the semantic of this function be
flackr
2016/08/16 17:52:51
When called with OpaqueBackgroundRect from backgro
trchen
2016/08/17 01:22:55
Great idea. It totally sounds clearer!
| |
708 { | 708 { |
709 // TODO(flackr): Check for the maximum background clip rect. | 709 EFillBox backgroundBox = TextFillBox; |
710 switch (style()->backgroundClip()) { | 710 // Find the largest background rect of the given opaqueness. |
711 if (const FillLayer* current = &(style()->backgroundLayers())) { | |
712 do { | |
713 const FillLayer* cur = current; | |
714 current = current->next(); | |
715 if (rectOpacity == OpaqueBackgroundRect) { | |
716 if (cur->blendMode() != WebBlendModeNormal || cur->composite() ! = CompositeSourceOver) | |
717 continue; | |
chrishtr
2016/08/12 17:03:00
Indentation.
flackr
2016/08/16 17:52:51
Done.
| |
718 // Check if the image or color has alpha. | |
719 if (const StyleImage* image = cur->image()) { | |
720 if (!image->knownToBeOpaque(*this)) | |
721 continue; | |
722 } else { | |
trchen
2016/08/13 00:06:42
}
if (!current->next()) {
1. A layer with translu
flackr
2016/08/16 17:52:51
Yes, that is why we continue to the next layer if
trchen
2016/08/17 01:22:55
The background color is always applicable even if
flackr
2016/08/17 18:20:55
Thanks for the clarification. Done, but needed to
| |
723 Color backgroundColor = resolveColor(CSSPropertyBackgroundCo lor); | |
724 if (backgroundColor.hasAlpha()) | |
725 continue; | |
726 } | |
727 } | |
728 EFillBox currentClip = cur->clip(); | |
729 // Adjust clip if attachment is local. | |
730 if (currentClip == BorderFillBox && cur->attachment() == LocalBackgr oundAttachment) | |
731 currentClip = PaddingFillBox; | |
732 backgroundBox = enclosingFillBox(backgroundBox, currentClip); | |
trchen
2016/08/13 00:06:42
I'm worried about this line, because the unscrolle
flackr
2016/08/16 17:52:51
Right, I think we should treat background-attachme
trchen
2016/08/17 01:22:55
Agreed. We can do that plus a comment to explain.
flackr
2016/08/17 18:20:55
Done, and added a test for this case.
| |
733 } while (current); | |
734 } | |
735 switch (backgroundBox) { | |
711 case BorderFillBox: | 736 case BorderFillBox: |
712 // A 'border-box' clip on scrollable elements local attachment is treate d as 'padding-box'. | |
713 // https://www.w3.org/TR/css3-background/#the-background-attachment | |
714 if (!style()->isOverflowVisible() && style()->backgroundLayers().attachm ent() == LocalBackgroundAttachment) | |
chrishtr
2016/08/12 17:03:00
Why can you remove this?
trchen
2016/08/13 00:06:42
The matching logic is in line 730 on the right sid
| |
715 return paddingBoxRect(); | |
716 return borderBoxRect(); | 737 return borderBoxRect(); |
717 break; | 738 break; |
718 case PaddingFillBox: | 739 case PaddingFillBox: |
719 return paddingBoxRect(); | 740 return paddingBoxRect(); |
720 break; | 741 break; |
721 case ContentFillBox: | 742 case ContentFillBox: |
722 return contentBoxRect(); | 743 return contentBoxRect(); |
723 break; | 744 break; |
724 default: | 745 default: |
725 break; | 746 break; |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1369 return false; | 1390 return false; |
1370 paintedExtent = LayoutRect(geometry.destRect()); | 1391 paintedExtent = LayoutRect(geometry.destRect()); |
1371 return true; | 1392 return true; |
1372 } | 1393 } |
1373 | 1394 |
1374 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c onst | 1395 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c onst |
1375 { | 1396 { |
1376 if (isDocumentElement() || backgroundStolenForBeingBody()) | 1397 if (isDocumentElement() || backgroundStolenForBeingBody()) |
1377 return false; | 1398 return false; |
1378 | 1399 |
1379 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); | |
1380 if (backgroundColor.hasAlpha()) | |
1381 return false; | |
1382 | |
1383 // If the element has appearance, it might be painted by theme. | 1400 // If the element has appearance, it might be painted by theme. |
1384 // We cannot be sure if theme paints the background opaque. | 1401 // We cannot be sure if theme paints the background opaque. |
1385 // In this case it is safe to not assume opaqueness. | 1402 // In this case it is safe to not assume opaqueness. |
1386 // FIXME: May be ask theme if it paints opaque. | 1403 // FIXME: May be ask theme if it paints opaque. |
1387 if (style()->hasAppearance()) | 1404 if (style()->hasAppearance()) |
1388 return false; | 1405 return false; |
1389 // FIXME: Check the opaqueness of background images. | 1406 // FIXME: Check the opaqueness of background images. |
1390 | 1407 |
1391 // FIXME: Use rounded rect if border radius is present. | 1408 // FIXME: Use rounded rect if border radius is present. |
1392 if (style()->hasBorderRadius()) | 1409 if (style()->hasBorderRadius()) |
1393 return false; | 1410 return false; |
1394 if (hasClipPath()) | 1411 if (hasClipPath()) |
1395 return false; | 1412 return false; |
1396 // FIXME: The background color clip is defined by the last layer. | 1413 if (style()->hasBlendMode()) |
1397 if (style()->backgroundLayers().next()) | |
1398 return false; | 1414 return false; |
1399 return backgroundClipRect().contains(localRect); | 1415 return backgroundRect(OpaqueBackgroundRect).contains(localRect); |
1400 } | 1416 } |
1401 | 1417 |
1402 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) | 1418 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) |
1403 { | 1419 { |
1404 const ComputedStyle& childStyle = childBox.styleRef(); | 1420 const ComputedStyle& childStyle = childBox.styleRef(); |
1405 if (childStyle.position() != StaticPosition && childBox.containingBlock() != childBox.parent()) | 1421 if (childStyle.position() != StaticPosition && childBox.containingBlock() != childBox.parent()) |
1406 return false; | 1422 return false; |
1407 if (childStyle.visibility() != EVisibility::Visible || childStyle.shapeOutsi de()) | 1423 if (childStyle.visibility() != EVisibility::Visible || childStyle.shapeOutsi de()) |
1408 return false; | 1424 return false; |
1409 if (childBox.size().isZero()) | 1425 if (childBox.size().isZero()) |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 LayoutBoxModelObject::mapLocalToAncestor(ancestor, transformState, mode); | 1778 LayoutBoxModelObject::mapLocalToAncestor(ancestor, transformState, mode); |
1763 } | 1779 } |
1764 | 1780 |
1765 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo rmState& transformState, MapCoordinatesFlags mode) const | 1781 void LayoutBox::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Transfo rmState& transformState, MapCoordinatesFlags mode) const |
1766 { | 1782 { |
1767 if (this == ancestor) | 1783 if (this == ancestor) |
1768 return; | 1784 return; |
1769 | 1785 |
1770 bool isFixedPos = style()->position() == FixedPosition; | 1786 bool isFixedPos = style()->position() == FixedPosition; |
1771 | 1787 |
1772 if (style()->canContainFixedPositionObjects() && !isFixedPos) { | 1788 // If this box has a transform or contains paint, it acts as a fixed positio n container for fixed descendants, |
1773 // If this box has a transform or contains paint, it acts as a fixed pos ition container for fixed descendants, | 1789 // and may itself also be fixed position. So propagate 'fixed' up only if th is box is fixed position. |
1774 // and may itself also be fixed position. So propagate 'fixed' up only i f this box is fixed position. | 1790 if (style()->canContainFixedPositionObjects() && !isFixedPos) |
1775 mode &= ~IsFixed; | 1791 mode &= ~IsFixed; |
1776 } else if (isFixedPos) { | 1792 else if (isFixedPos) |
1777 mode |= IsFixed; | 1793 mode |= IsFixed; |
1778 } | |
1779 | 1794 |
1780 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); | 1795 LayoutBoxModelObject::mapAncestorToLocal(ancestor, transformState, mode); |
1781 } | 1796 } |
1782 | 1797 |
1783 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const | 1798 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o) const |
1784 { | 1799 { |
1785 ASSERT(o == container()); | 1800 ASSERT(o == container()); |
1786 | 1801 |
1787 LayoutSize offset; | 1802 LayoutSize offset; |
1788 if (isInFlowPositioned()) | 1803 if (isInFlowPositioned()) |
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4994 m_rareData->m_snapAreas->remove(&snapArea); | 5009 m_rareData->m_snapAreas->remove(&snapArea); |
4995 } | 5010 } |
4996 } | 5011 } |
4997 | 5012 |
4998 SnapAreaSet* LayoutBox::snapAreas() const | 5013 SnapAreaSet* LayoutBox::snapAreas() const |
4999 { | 5014 { |
5000 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | 5015 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
5001 } | 5016 } |
5002 | 5017 |
5003 } // namespace blink | 5018 } // namespace blink |
OLD | NEW |