| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 * | 22 * |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef StyleRareInheritedData_h | 25 #ifndef StyleRareInheritedData_h |
| 26 #define StyleRareInheritedData_h | 26 #define StyleRareInheritedData_h |
| 27 | 27 |
| 28 #include "core/CoreExport.h" | |
| 29 #include "core/css/StyleColor.h" | |
| 30 #include "core/style/TextSizeAdjust.h" | |
| 31 #include "platform/Length.h" | |
| 32 #include "platform/graphics/Color.h" | |
| 33 #include "platform/heap/Handle.h" | |
| 34 #include "platform/text/TabSize.h" | |
| 35 #include "wtf/PassRefPtr.h" | |
| 36 #include "wtf/RefCounted.h" | |
| 37 #include "wtf/RefVector.h" | |
| 38 #include "wtf/text/AtomicString.h" | |
| 39 | |
| 40 namespace blink { | 28 namespace blink { |
| 41 | 29 |
| 42 class AppliedTextDecoration; | 30 enum CSSPropertyID { |
| 43 class CursorData; | 31 CSSPropertyStopColor = 197, |
| 44 class QuotesData; | 32 CSSPropertyTextDecorationColor = 214, |
| 45 class ShadowList; | 33 CSSPropertyWebkitTextFillColor = 298, |
| 46 class StyleImage; | 34 }; |
| 47 class StyleVariableData; | |
| 48 | 35 |
| 49 typedef RefVector<AppliedTextDecoration> AppliedTextDecorationList; | 36 typedef unsigned RGBA32; // RGBA quadruplet |
| 50 typedef HeapVector<CursorData> CursorList; | |
| 51 | 37 |
| 52 // This struct is for rarely used inherited CSS3, CSS2, and WebKit-specific prop
erties. | 38 RGBA32 makeRGB(int r, int g, int b); |
| 53 // By grouping them together, we save space, and only allocate this object when
someone | 39 |
| 54 // actually uses one of these properties. | 40 inline int alphaChannel(RGBA32 color) { return (color >> 24) & 0xFF; } |
| 55 // TODO(sashab): Move this into a private class on ComputedStyle, and remove | 41 |
| 56 // all methods on it, merging them into copy/creation methods on ComputedStyle | 42 class Color { |
| 57 // instead. Keep the allocation logic, only allocating a new object if needed. | |
| 58 class CORE_EXPORT StyleRareInheritedData : public RefCounted<StyleRareInheritedD
ata> { | |
| 59 public: | 43 public: |
| 60 static PassRefPtr<StyleRareInheritedData> create() { return adoptRef(new Sty
leRareInheritedData); } | 44 Color() : m_color(Color::transparent) { } |
| 61 PassRefPtr<StyleRareInheritedData> copy() const { return adoptRef(new StyleR
areInheritedData(*this)); } | 45 Color(RGBA32 color) : m_color(color) { } |
| 46 Color(int r, int g, int b) : m_color(makeRGB(r, g, b)) { } |
| 47 |
| 48 bool hasAlpha() const { return alpha() < 255; } |
| 49 |
| 50 int alpha() const { return alphaChannel(m_color); } |
| 51 |
| 52 RGBA32 rgb() const { return m_color; } // Preserve the alpha. |
| 53 |
| 54 static const RGBA32 black = 0xFF000000; |
| 55 static const RGBA32 transparent = 0x00000000; |
| 56 |
| 57 private: |
| 58 RGBA32 m_color; |
| 59 }; |
| 60 |
| 61 inline bool operator==(const Color& a, const Color& b) |
| 62 { |
| 63 return a.rgb() == b.rgb(); |
| 64 } |
| 65 |
| 66 inline bool operator!=(const Color& a, const Color& b) |
| 67 { |
| 68 return !(a == b); |
| 69 } |
| 70 |
| 71 |
| 72 class StyleColor { |
| 73 public: |
| 74 StyleColor() : m_currentColor(true) { } |
| 75 StyleColor(Color color) : m_color(color), m_currentColor(false) { } |
| 76 static StyleColor currentColor() { return StyleColor(); } |
| 77 |
| 78 bool isCurrentColor() const { return m_currentColor; } |
| 79 Color getColor() const { /*ASSERT(!isCurrentColor());*/ return m_color; } |
| 80 |
| 81 Color resolve(Color currentColor) const { return m_currentColor ? currentCol
or : m_color; } |
| 82 |
| 83 private: |
| 84 Color m_color; |
| 85 bool m_currentColor; |
| 86 }; |
| 87 |
| 88 inline bool operator==(const StyleColor& a, const StyleColor& b) |
| 89 { |
| 90 if (a.isCurrentColor() || b.isCurrentColor()) |
| 91 return a.isCurrentColor() && b.isCurrentColor(); |
| 92 return a.getColor() == b.getColor(); |
| 93 } |
| 94 |
| 95 inline bool operator!=(const StyleColor& a, const StyleColor& b) |
| 96 { |
| 97 return !(a == b); |
| 98 } |
| 99 |
| 100 class StyleRareInheritedData { |
| 101 public: |
| 62 ~StyleRareInheritedData(); | 102 ~StyleRareInheritedData(); |
| 63 | 103 |
| 64 bool operator==(const StyleRareInheritedData&) const; | 104 StyleColor textStrokeColor() const |
| 65 bool operator!=(const StyleRareInheritedData& o) const | |
| 66 { | 105 { |
| 67 return !(*this == o); | 106 return m_textStrokeColorIsCurrentColor ? StyleColor::currentColor() : St
yleColor(m_textStrokeColor); |
| 68 } | 107 } |
| 69 bool shadowDataEquivalent(const StyleRareInheritedData&) const; | 108 StyleColor visitedLinkTextFillColor() const |
| 70 bool quotesDataEquivalent(const StyleRareInheritedData&) const; | 109 { |
| 110 return m_visitedLinkTextFillColorIsCurrentColor ? StyleColor::currentCol
or() : StyleColor(m_visitedLinkTextFillColor); |
| 111 } |
| 71 | 112 |
| 72 Persistent<StyleImage> listStyleImage; | 113 void setVisitedLinkTextFillColor(const StyleColor& color) |
| 73 | 114 { |
| 74 StyleColor textStrokeColor() const { return m_textStrokeColorIsCurrentColor
? StyleColor::currentColor() : StyleColor(m_textStrokeColor); } | 115 m_visitedLinkTextFillColor = color.resolve(Color()); |
| 75 StyleColor textFillColor() const { return m_textFillColorIsCurrentColor ? St
yleColor::currentColor() : StyleColor(m_textFillColor); } | 116 m_visitedLinkTextFillColorIsCurrentColor = color.isCurrentColor(); |
| 76 StyleColor textEmphasisColor() const { return m_textEmphasisColorIsCurrentCo
lor ? StyleColor::currentColor() : StyleColor(m_textEmphasisColor); } | 117 } |
| 77 StyleColor visitedLinkTextStrokeColor() const { return m_visitedLinkTextStro
keColorIsCurrentColor ? StyleColor::currentColor() : StyleColor(m_visitedLinkTex
tStrokeColor); } | |
| 78 StyleColor visitedLinkTextFillColor() const { return m_visitedLinkTextFillCo
lorIsCurrentColor ? StyleColor::currentColor() : StyleColor(m_visitedLinkTextFil
lColor); } | |
| 79 StyleColor visitedLinkTextEmphasisColor() const { return m_visitedLinkTextEm
phasisColorIsCurrentColor ? StyleColor::currentColor() : StyleColor(m_visitedLin
kTextEmphasisColor); } | |
| 80 | |
| 81 void setTextStrokeColor(const StyleColor& color) { m_textStrokeColor = color
.resolve(Color()); m_textStrokeColorIsCurrentColor = color.isCurrentColor(); } | |
| 82 void setTextFillColor(const StyleColor& color) { m_textFillColor = color.res
olve(Color()); m_textFillColorIsCurrentColor = color.isCurrentColor(); } | |
| 83 void setTextEmphasisColor(const StyleColor& color) { m_textEmphasisColor = c
olor.resolve(Color()); m_textEmphasisColorIsCurrentColor = color.isCurrentColor(
); } | |
| 84 void setVisitedLinkTextStrokeColor(const StyleColor& color) { m_visitedLinkT
extStrokeColor = color.resolve(Color()); m_visitedLinkTextStrokeColorIsCurrentCo
lor = color.isCurrentColor(); } | |
| 85 void setVisitedLinkTextFillColor(const StyleColor& color) { m_visitedLinkTex
tFillColor = color.resolve(Color()); m_visitedLinkTextFillColorIsCurrentColor =
color.isCurrentColor(); } | |
| 86 void setVisitedLinkTextEmphasisColor(const StyleColor& color) { m_visitedLin
kTextEmphasisColor = color.resolve(Color()); m_visitedLinkTextEmphasisColorIsCur
rentColor = color.isCurrentColor(); } | |
| 87 | 118 |
| 88 Color m_textStrokeColor; | 119 Color m_textStrokeColor; |
| 89 float textStrokeWidth; | |
| 90 Color m_textFillColor; | |
| 91 Color m_textEmphasisColor; | |
| 92 | |
| 93 Color m_visitedLinkTextStrokeColor; | |
| 94 Color m_visitedLinkTextFillColor; | 120 Color m_visitedLinkTextFillColor; |
| 95 Color m_visitedLinkTextEmphasisColor; | |
| 96 | |
| 97 RefPtr<ShadowList> textShadow; // Our text shadow information for shadowed t
ext drawing. | |
| 98 AtomicString highlight; // Apple-specific extension for custom highlight ren
dering. | |
| 99 | |
| 100 Persistent<CursorList> cursorData; | |
| 101 | |
| 102 Length indent; | |
| 103 float m_effectiveZoom; | |
| 104 | |
| 105 // Paged media properties. | |
| 106 short widows; | |
| 107 short orphans; | |
| 108 | 121 |
| 109 unsigned m_textStrokeColorIsCurrentColor : 1; | 122 unsigned m_textStrokeColorIsCurrentColor : 1; |
| 110 unsigned m_textFillColorIsCurrentColor : 1; | |
| 111 unsigned m_textEmphasisColorIsCurrentColor : 1; | |
| 112 unsigned m_visitedLinkTextStrokeColorIsCurrentColor : 1; | |
| 113 unsigned m_visitedLinkTextFillColorIsCurrentColor : 1; | 123 unsigned m_visitedLinkTextFillColorIsCurrentColor : 1; |
| 114 unsigned m_visitedLinkTextEmphasisColorIsCurrentColor : 1; | |
| 115 | 124 |
| 116 unsigned textSecurity : 2; // ETextSecurity | 125 StyleColor m_textDecorationColor; |
| 117 unsigned userModify : 2; // EUserModify (editing) | 126 StyleColor m_visitedLinkTextDecorationColor; |
| 118 unsigned wordBreak : 2; // EWordBreak | |
| 119 unsigned overflowWrap : 1; // EOverflowWrap | |
| 120 unsigned lineBreak : 3; // LineBreak | |
| 121 unsigned userSelect : 2; // EUserSelect | |
| 122 unsigned speak : 3; // ESpeak | |
| 123 unsigned hyphens : 2; // Hyphens | |
| 124 unsigned textEmphasisFill : 1; // TextEmphasisFill | |
| 125 unsigned textEmphasisMark : 3; // TextEmphasisMark | |
| 126 unsigned textEmphasisPosition : 1; // TextEmphasisPosition | |
| 127 unsigned m_textAlignLast : 3; // TextAlignLast | |
| 128 unsigned m_textJustify : 2; // TextJustify | |
| 129 unsigned m_textOrientation : 2; // TextOrientation | |
| 130 unsigned m_textCombine : 1; // CSS3 text-combine-upright properties | |
| 131 unsigned m_textIndentLine : 1; // TextIndentEachLine | |
| 132 unsigned m_textIndentType : 1; // TextIndentHanging | |
| 133 // CSS Image Values Level 3 | |
| 134 unsigned m_imageRendering : 3; // EImageRendering | |
| 135 unsigned m_textUnderlinePosition : 1; // TextUnderlinePosition | |
| 136 unsigned m_rubyPosition : 1; // RubyPosition | |
| 137 | 127 |
| 138 // Though will-change is not itself an inherited property, the intent | 128 StyleRareInheritedData(); |
| 139 // expressed by 'will-change: contents' includes descendants. | 129 }; |
| 140 unsigned m_subtreeWillChangeContents : 1; | |
| 141 | 130 |
| 142 unsigned m_selfOrAncestorHasDirAutoAttribute : 1; | |
| 143 | |
| 144 unsigned m_respectImageOrientation : 1; | |
| 145 | |
| 146 unsigned m_snapHeightPosition : 7; | |
| 147 | |
| 148 AtomicString hyphenationString; | |
| 149 short hyphenationLimitBefore; | |
| 150 short hyphenationLimitAfter; | |
| 151 short hyphenationLimitLines; | |
| 152 | |
| 153 uint8_t m_snapHeightUnit; | |
| 154 | |
| 155 AtomicString textEmphasisCustomMark; | |
| 156 RefPtr<QuotesData> quotes; | |
| 157 | |
| 158 Color tapHighlightColor; | |
| 159 | |
| 160 RefPtr<AppliedTextDecorationList> appliedTextDecorations; | |
| 161 TabSize m_tabSize; | |
| 162 | |
| 163 RefPtr<StyleVariableData> variables; | |
| 164 TextSizeAdjust m_textSizeAdjust; | |
| 165 | |
| 166 private: | |
| 167 StyleRareInheritedData(); | |
| 168 StyleRareInheritedData(const StyleRareInheritedData&); | |
| 169 }; | |
| 170 | 131 |
| 171 } // namespace blink | 132 } // namespace blink |
| 172 | 133 |
| 173 #endif // StyleRareInheritedData_h | 134 #endif // StyleRareInheritedData_h |
| OLD | NEW |