OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #include "core/style/ComputedStyle.h" | 23 #include "core/style/ComputedStyle.h" |
24 | 24 |
| 25 #include "core/css/CSSPaintValue.h" |
| 26 #include "core/css/CSSPropertyEquality.h" |
25 #include "core/css/resolver/StyleResolver.h" | 27 #include "core/css/resolver/StyleResolver.h" |
26 #include "core/layout/LayoutTheme.h" | 28 #include "core/layout/LayoutTheme.h" |
27 #include "core/layout/TextAutosizer.h" | 29 #include "core/layout/TextAutosizer.h" |
28 #include "core/style/AppliedTextDecoration.h" | 30 #include "core/style/AppliedTextDecoration.h" |
29 #include "core/style/BorderEdge.h" | 31 #include "core/style/BorderEdge.h" |
30 #include "core/style/ContentData.h" | 32 #include "core/style/ContentData.h" |
31 #include "core/style/DataEquivalency.h" | 33 #include "core/style/DataEquivalency.h" |
32 #include "core/style/ComputedStyleConstants.h" | 34 #include "core/style/ComputedStyleConstants.h" |
33 #include "core/style/QuotesData.h" | 35 #include "core/style/QuotesData.h" |
34 #include "core/style/ShadowList.h" | 36 #include "core/style/ShadowList.h" |
35 #include "core/style/StyleImage.h" | 37 #include "core/style/StyleImage.h" |
36 #include "core/style/StyleInheritedData.h" | 38 #include "core/style/StyleInheritedData.h" |
37 #include "core/style/StyleVariableData.h" | 39 #include "core/style/StyleVariableData.h" |
38 #include "platform/LengthFunctions.h" | 40 #include "platform/LengthFunctions.h" |
39 #include "platform/RuntimeEnabledFeatures.h" | 41 #include "platform/RuntimeEnabledFeatures.h" |
40 #include "platform/fonts/Font.h" | 42 #include "platform/fonts/Font.h" |
41 #include "platform/fonts/FontSelector.h" | 43 #include "platform/fonts/FontSelector.h" |
42 #include "platform/geometry/FloatRoundedRect.h" | 44 #include "platform/geometry/FloatRoundedRect.h" |
43 #include "platform/graphics/GraphicsContext.h" | 45 #include "platform/graphics/GraphicsContext.h" |
44 #include "platform/transforms/RotateTransformOperation.h" | 46 #include "platform/transforms/RotateTransformOperation.h" |
45 #include "platform/transforms/ScaleTransformOperation.h" | 47 #include "platform/transforms/ScaleTransformOperation.h" |
46 #include "platform/transforms/TranslateTransformOperation.h" | 48 #include "platform/transforms/TranslateTransformOperation.h" |
47 #include "wtf/MathExtras.h" | 49 #include "wtf/MathExtras.h" |
| 50 #include "wtf/PtrUtil.h" |
48 | 51 |
49 #include <algorithm> | 52 #include <algorithm> |
50 | 53 |
51 namespace blink { | 54 namespace blink { |
52 | 55 |
53 struct SameSizeAsBorderValue { | 56 struct SameSizeAsBorderValue { |
54 RGBA32 m_color; | 57 RGBA32 m_color; |
55 unsigned m_width; | 58 unsigned m_width; |
56 }; | 59 }; |
57 | 60 |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 || (visitedLinkBorderBottomColor() != other.visitedLinkBorderBottomC
olor() && borderBottomWidth()) | 758 || (visitedLinkBorderBottomColor() != other.visitedLinkBorderBottomC
olor() && borderBottomWidth()) |
756 || (visitedLinkBorderTopColor() != other.visitedLinkBorderTopColor()
&& borderTopWidth()) | 759 || (visitedLinkBorderTopColor() != other.visitedLinkBorderTopColor()
&& borderTopWidth()) |
757 || (visitedLinkOutlineColor() != other.visitedLinkOutlineColor() &&
outlineWidth()) | 760 || (visitedLinkOutlineColor() != other.visitedLinkOutlineColor() &&
outlineWidth()) |
758 || (visitedLinkBackgroundColor() != other.visitedLinkBackgroundColor
())) | 761 || (visitedLinkBackgroundColor() != other.visitedLinkBackgroundColor
())) |
759 return true; | 762 return true; |
760 } | 763 } |
761 | 764 |
762 if (resize() != other.resize()) | 765 if (resize() != other.resize()) |
763 return true; | 766 return true; |
764 | 767 |
| 768 if (rareNonInheritedData->m_paintImages) { |
| 769 for (const auto& image : *rareNonInheritedData->m_paintImages) { |
| 770 if (diffNeedsPaintInvalidationObjectForPaintImage(image, other)) |
| 771 return true; |
| 772 } |
| 773 } |
| 774 |
765 return false; | 775 return false; |
766 } | 776 } |
767 | 777 |
| 778 bool ComputedStyle::diffNeedsPaintInvalidationObjectForPaintImage(const StyleIma
ge* image, const ComputedStyle& other) const |
| 779 { |
| 780 CSSPaintValue* value = toCSSPaintValue(image->cssValue()); |
| 781 |
| 782 // NOTE: If the invalidation properties vectors are null, we are invalid as |
| 783 // we haven't yet been painted (and can't provide the invalidation |
| 784 // properties yet). |
| 785 if (!value->nativeInvalidationProperties() || !value->customInvalidationProp
erties()) |
| 786 return true; |
| 787 |
| 788 for (CSSPropertyID propertyID : *value->nativeInvalidationProperties()) { |
| 789 // TODO(ikilpatrick): remove isInterpolableProperty check once |
| 790 // CSSPropertyEquality::propertiesEqual correctly handles all properties
. |
| 791 if (!CSSPropertyMetadata::isInterpolableProperty(propertyID) || !CSSProp
ertyEquality::propertiesEqual(propertyID, *this, other)) |
| 792 return true; |
| 793 } |
| 794 |
| 795 if (variables() || other.variables()) { |
| 796 for (const AtomicString& property : *value->customInvalidationProperties
()) { |
| 797 CSSVariableData* thisVar = variables() ? variables()->getVariable(pr
operty) : nullptr; |
| 798 CSSVariableData* otherVar = other.variables() ? other.variables()->g
etVariable(property) : nullptr; |
| 799 |
| 800 if (!dataEquivalent(thisVar, otherVar)) |
| 801 return true; |
| 802 } |
| 803 } |
| 804 |
| 805 return false; |
| 806 } |
| 807 |
768 void ComputedStyle::updatePropertySpecificDifferences(const ComputedStyle& other
, StyleDifference& diff) const | 808 void ComputedStyle::updatePropertySpecificDifferences(const ComputedStyle& other
, StyleDifference& diff) const |
769 { | 809 { |
770 // StyleAdjuster has ensured that zIndex is non-auto only if it's applicable
. | 810 // StyleAdjuster has ensured that zIndex is non-auto only if it's applicable
. |
771 if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != ot
her.m_box->hasAutoZIndex()) | 811 if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != ot
her.m_box->hasAutoZIndex()) |
772 diff.setZIndexChanged(); | 812 diff.setZIndexChanged(); |
773 | 813 |
774 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { | 814 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { |
775 if (!transformDataEquivalent(other)) | 815 if (!transformDataEquivalent(other)) |
776 diff.setTransformChanged(); | 816 diff.setTransformChanged(); |
777 | 817 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 || rareInheritedData->visitedLinkTextFillColor() != other.rareIn
heritedData->visitedLinkTextFillColor() | 852 || rareInheritedData->visitedLinkTextFillColor() != other.rareIn
heritedData->visitedLinkTextFillColor() |
813 || rareInheritedData->visitedLinkTextStrokeColor() != other.rare
InheritedData->visitedLinkTextStrokeColor() | 853 || rareInheritedData->visitedLinkTextStrokeColor() != other.rare
InheritedData->visitedLinkTextStrokeColor() |
814 || rareInheritedData->visitedLinkTextEmphasisColor() != other.ra
reInheritedData->visitedLinkTextEmphasisColor() | 854 || rareInheritedData->visitedLinkTextEmphasisColor() != other.ra
reInheritedData->visitedLinkTextEmphasisColor() |
815 || rareInheritedData->textEmphasisFill != other.rareInheritedDat
a->textEmphasisFill | 855 || rareInheritedData->textEmphasisFill != other.rareInheritedDat
a->textEmphasisFill |
816 || rareInheritedData->appliedTextDecorations != other.rareInheri
tedData->appliedTextDecorations)) { | 856 || rareInheritedData->appliedTextDecorations != other.rareInheri
tedData->appliedTextDecorations)) { |
817 diff.setTextDecorationOrColorChanged(); | 857 diff.setTextDecorationOrColorChanged(); |
818 } | 858 } |
819 } | 859 } |
820 } | 860 } |
821 | 861 |
| 862 void ComputedStyle::addPaintImage(StyleImage* image) |
| 863 { |
| 864 if (!rareNonInheritedData.access()->m_paintImages) |
| 865 rareNonInheritedData.access()->m_paintImages = WTF::wrapUnique(new Vecto
r<Persistent<StyleImage>>()); |
| 866 rareNonInheritedData.access()->m_paintImages->append(image); |
| 867 } |
| 868 |
822 void ComputedStyle::addCursor(StyleImage* image, bool hotSpotSpecified, const In
tPoint& hotSpot) | 869 void ComputedStyle::addCursor(StyleImage* image, bool hotSpotSpecified, const In
tPoint& hotSpot) |
823 { | 870 { |
824 if (!rareInheritedData.access()->cursorData) | 871 if (!rareInheritedData.access()->cursorData) |
825 rareInheritedData.access()->cursorData = new CursorList; | 872 rareInheritedData.access()->cursorData = new CursorList; |
826 rareInheritedData.access()->cursorData->append(CursorData(image, hotSpotSpec
ified, hotSpot)); | 873 rareInheritedData.access()->cursorData->append(CursorData(image, hotSpotSpec
ified, hotSpot)); |
827 } | 874 } |
828 | 875 |
829 void ComputedStyle::setCursorList(CursorList* other) | 876 void ComputedStyle::setCursorList(CursorList* other) |
830 { | 877 { |
831 rareInheritedData.access()->cursorData = other; | 878 rareInheritedData.access()->cursorData = other; |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 if (!shadowList) | 1853 if (!shadowList) |
1807 return false; | 1854 return false; |
1808 for (size_t i = shadowList->shadows().size(); i--; ) { | 1855 for (size_t i = shadowList->shadows().size(); i--; ) { |
1809 if (shadowList->shadows()[i].color().isCurrentColor()) | 1856 if (shadowList->shadows()[i].color().isCurrentColor()) |
1810 return true; | 1857 return true; |
1811 } | 1858 } |
1812 return false; | 1859 return false; |
1813 } | 1860 } |
1814 | 1861 |
1815 } // namespace blink | 1862 } // namespace blink |
OLD | NEW |