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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 } | 831 } |
832 | 832 |
833 if (!container) | 833 if (!container) |
834 return 0; | 834 return 0; |
835 if (container->hasClipOrOverflowClip()) | 835 if (container->hasClipOrOverflowClip()) |
836 return container; | 836 return container; |
837 } | 837 } |
838 return 0; | 838 return 0; |
839 } | 839 } |
840 | 840 |
841 static bool mustRepaintFillLayers(const RenderObject& renderer, const FillLayer*
layer) | 841 bool RenderObject::canRenderBorderImage() const |
| 842 { |
| 843 ASSERT(style()->hasBorder()); |
| 844 |
| 845 StyleImage* borderImage = style()->borderImage().image(); |
| 846 return borderImage && borderImage->canRender(*this, style()->effectiveZoom()
) && borderImage->isLoaded(); |
| 847 } |
| 848 |
| 849 bool RenderObject::mustRepaintFillLayersOnWidthChange(const FillLayer& layer) co
nst |
842 { | 850 { |
843 // Nobody will use multiple layers without wanting fancy positioning. | 851 // Nobody will use multiple layers without wanting fancy positioning. |
844 if (layer->next()) | 852 if (layer.next()) |
845 return true; | 853 return true; |
846 | 854 |
847 // Make sure we have a valid image. | 855 // Make sure we have a valid image. |
848 StyleImage* img = layer->image(); | 856 StyleImage* img = layer.image(); |
849 if (!img || !img->canRender(renderer, renderer.style()->effectiveZoom())) | 857 if (!img || !img->canRender(*this, style()->effectiveZoom())) |
850 return false; | 858 return false; |
851 | 859 |
852 if (!layer->xPosition().isZero() || !layer->yPosition().isZero()) | 860 if (layer.repeatX() != RepeatFill && layer.repeatX() != NoRepeatFill) |
853 return true; | 861 return true; |
854 | 862 |
855 EFillSizeType sizeType = layer->sizeType(); | 863 if (layer.xPosition().isPercent() && !layer.xPosition().isZero()) |
| 864 return true; |
| 865 |
| 866 if (layer.backgroundXOrigin() != LeftEdge) |
| 867 return true; |
| 868 |
| 869 EFillSizeType sizeType = layer.sizeType(); |
856 | 870 |
857 if (sizeType == Contain || sizeType == Cover) | 871 if (sizeType == Contain || sizeType == Cover) |
858 return true; | 872 return true; |
859 | 873 |
860 if (sizeType == SizeLength) { | 874 if (sizeType == SizeLength) { |
861 if (layer->sizeLength().width().isPercent() || layer->sizeLength().heigh
t().isPercent()) | 875 if (layer.sizeLength().width().isPercent() && !layer.sizeLength().width(
).isZero()) |
862 return true; | 876 return true; |
863 if (img->isGeneratedImage() && (layer->sizeLength().width().isAuto() ||
layer->sizeLength().height().isAuto())) | 877 if (img->isGeneratedImage() && layer.sizeLength().width().isAuto()) |
864 return true; | 878 return true; |
865 } else if (img->usesImageContainerSize()) { | 879 } else if (img->usesImageContainerSize()) { |
866 return true; | 880 return true; |
867 } | 881 } |
868 | 882 |
869 return false; | 883 return false; |
870 } | 884 } |
871 | 885 |
872 bool RenderObject::borderImageIsLoadedAndCanBeRendered() const | 886 bool RenderObject::mustRepaintFillLayersOnHeightChange(const FillLayer& layer) c
onst |
873 { | 887 { |
874 ASSERT(style()->hasBorder()); | 888 // Nobody will use multiple layers without wanting fancy positioning. |
| 889 if (layer.next()) |
| 890 return true; |
875 | 891 |
876 StyleImage* borderImage = style()->borderImage().image(); | 892 // Make sure we have a valid image. |
877 return borderImage && borderImage->canRender(*this, style()->effectiveZoom()
) && borderImage->isLoaded(); | 893 StyleImage* img = layer.image(); |
| 894 if (!img || !img->canRender(*this, style()->effectiveZoom())) |
| 895 return false; |
| 896 |
| 897 if (layer.repeatY() != RepeatFill && layer.repeatY() != NoRepeatFill) |
| 898 return true; |
| 899 |
| 900 if (layer.yPosition().isPercent() && !layer.yPosition().isZero()) |
| 901 return true; |
| 902 |
| 903 if (layer.backgroundYOrigin() != TopEdge) |
| 904 return true; |
| 905 |
| 906 EFillSizeType sizeType = layer.sizeType(); |
| 907 |
| 908 if (sizeType == Contain || sizeType == Cover) |
| 909 return true; |
| 910 |
| 911 if (sizeType == SizeLength) { |
| 912 if (layer.sizeLength().height().isPercent() && !layer.sizeLength().heigh
t().isZero()) |
| 913 return true; |
| 914 if (img->isGeneratedImage() && layer.sizeLength().height().isAuto()) |
| 915 return true; |
| 916 } else if (img->usesImageContainerSize()) { |
| 917 return true; |
| 918 } |
| 919 |
| 920 return false; |
878 } | 921 } |
879 | 922 |
880 bool RenderObject::mustRepaintBackgroundOrBorder() const | 923 bool RenderObject::mustRepaintBackgroundOrBorderOnWidthChange() const |
881 { | 924 { |
882 if (hasMask() && mustRepaintFillLayers(*this, style()->maskLayers())) | 925 if (hasMask() && mustRepaintFillLayersOnWidthChange(*style()->maskLayers())) |
883 return true; | 926 return true; |
884 | 927 |
885 // If we don't have a background/border/mask, then nothing to do. | 928 // If we don't have a background/border/mask, then nothing to do. |
886 if (!hasBoxDecorations()) | 929 if (!hasBoxDecorations()) |
887 return false; | 930 return false; |
888 | 931 |
889 if (mustRepaintFillLayers(*this, style()->backgroundLayers())) | 932 if (mustRepaintFillLayersOnWidthChange(*style()->backgroundLayers())) |
| 933 return true; |
| 934 |
| 935 // Our fill layers are ok. Let's check border. |
| 936 if (style()->hasBorder() && canRenderBorderImage()) |
| 937 return true; |
| 938 |
| 939 return false; |
| 940 } |
| 941 |
| 942 bool RenderObject::mustRepaintBackgroundOrBorderOnHeightChange() const |
| 943 { |
| 944 if (hasMask() && mustRepaintFillLayersOnHeightChange(*style()->maskLayers())
) |
| 945 return true; |
| 946 |
| 947 // If we don't have a background/border/mask, then nothing to do. |
| 948 if (!hasBoxDecorations()) |
| 949 return false; |
| 950 |
| 951 if (mustRepaintFillLayersOnHeightChange(*style()->backgroundLayers())) |
890 return true; | 952 return true; |
891 | 953 |
892 // Our fill layers are ok. Let's check border. | 954 // Our fill layers are ok. Let's check border. |
893 if (style()->hasBorder() && borderImageIsLoadedAndCanBeRendered()) | 955 if (style()->hasBorder() && canRenderBorderImage()) |
894 return true; | 956 return true; |
895 | 957 |
896 return false; | 958 return false; |
897 } | 959 } |
898 | 960 |
899 void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
int y1, int x2, int y2, | 961 void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1,
int y1, int x2, int y2, |
900 BoxSide side, Color color, EBorderStyle st
yle, | 962 BoxSide side, Color color, EBorderStyle st
yle, |
901 int adjacentWidth1, int adjacentWidth2, bo
ol antialias) | 963 int adjacentWidth1, int adjacentWidth2, bo
ol antialias) |
902 { | 964 { |
903 int thickness; | 965 int thickness; |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 | 1656 |
1595 if (invalidationReason == InvalidationIncremental && compositingState() != P
aintsIntoOwnBacking && newLocation != oldLocation) | 1657 if (invalidationReason == InvalidationIncremental && compositingState() != P
aintsIntoOwnBacking && newLocation != oldLocation) |
1596 invalidationReason = InvalidationLocationChange; | 1658 invalidationReason = InvalidationLocationChange; |
1597 | 1659 |
1598 // If the bounds are the same then we know that none of the statements below | 1660 // If the bounds are the same then we know that none of the statements below |
1599 // can match, so we can early out since we will not need to do any | 1661 // can match, so we can early out since we will not need to do any |
1600 // invalidation. | 1662 // invalidation. |
1601 if (invalidationReason == InvalidationIncremental && oldBounds == newBounds) | 1663 if (invalidationReason == InvalidationIncremental && oldBounds == newBounds) |
1602 return false; | 1664 return false; |
1603 | 1665 |
1604 if (invalidationReason == InvalidationIncremental && mustRepaintBackgroundOr
Border()) | 1666 if (invalidationReason == InvalidationIncremental) { |
1605 invalidationReason = InvalidationBoundsChangeWithBackground; | 1667 if (oldBounds.width() != newBounds.width() && mustRepaintBackgroundOrBor
derOnWidthChange()) |
| 1668 invalidationReason = InvalidationBoundsChangeWithBackground; |
| 1669 else if (oldBounds.height() != newBounds.height() && mustRepaintBackgrou
ndOrBorderOnHeightChange()) |
| 1670 invalidationReason = InvalidationBoundsChangeWithBackground; |
| 1671 } |
1606 | 1672 |
1607 // If we shifted, we don't know the exact reason so we are conservative and
trigger a full invalidation. Shifting could | 1673 // If we shifted, we don't know the exact reason so we are conservative and
trigger a full invalidation. Shifting could |
1608 // be caused by some layout property (left / top) or some in-flow renderer i
nserted / removed before us in the tree. | 1674 // be caused by some layout property (left / top) or some in-flow renderer i
nserted / removed before us in the tree. |
1609 if (invalidationReason == InvalidationIncremental && newBounds.location() !=
oldBounds.location()) | 1675 if (invalidationReason == InvalidationIncremental && newBounds.location() !=
oldBounds.location()) |
1610 invalidationReason = InvalidationBoundsChange; | 1676 invalidationReason = InvalidationBoundsChange; |
1611 | 1677 |
1612 // If the size is zero on one of our bounds then we know we're going to have | 1678 // If the size is zero on one of our bounds then we know we're going to have |
1613 // to do a full invalidation of either old bounds or new bounds. If we fall | 1679 // to do a full invalidation of either old bounds or new bounds. If we fall |
1614 // into the incremental invalidation we'll issue two invalidations instead | 1680 // into the incremental invalidation we'll issue two invalidations instead |
1615 // of one. | 1681 // of one. |
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 { | 3525 { |
3460 if (object1) { | 3526 if (object1) { |
3461 const WebCore::RenderObject* root = object1; | 3527 const WebCore::RenderObject* root = object1; |
3462 while (root->parent()) | 3528 while (root->parent()) |
3463 root = root->parent(); | 3529 root = root->parent(); |
3464 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3530 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
3465 } | 3531 } |
3466 } | 3532 } |
3467 | 3533 |
3468 #endif | 3534 #endif |
OLD | NEW |