Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: sky/engine/core/editing/EditingStyle.h

Issue 780443002: Remove dead code from EditingStyle. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: try again Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sky/engine/core/editing/EditingStyle.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 class Position; 59 class Position;
60 class QualifiedName; 60 class QualifiedName;
61 class RenderStyle; 61 class RenderStyle;
62 class StylePropertySet; 62 class StylePropertySet;
63 class VisibleSelection; 63 class VisibleSelection;
64 64
65 class EditingStyle final : public RefCounted<EditingStyle> { 65 class EditingStyle final : public RefCounted<EditingStyle> {
66 public: 66 public:
67 67
68 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties, EditingPropertiesInEffect }; 68 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties, EditingPropertiesInEffect };
69 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserv eWritingDirection };
70 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatching Style };
71 static float NoFontDelta; 69 static float NoFontDelta;
72 70
73 static PassRefPtr<EditingStyle> create() 71 static PassRefPtr<EditingStyle> create()
74 { 72 {
75 return adoptRef(new EditingStyle()); 73 return adoptRef(new EditingStyle());
76 } 74 }
77 75
78 static PassRefPtr<EditingStyle> create(ContainerNode* node, PropertiesToIncl ude propertiesToInclude = OnlyEditingInheritableProperties) 76 static PassRefPtr<EditingStyle> create(ContainerNode* node, PropertiesToIncl ude propertiesToInclude = OnlyEditingInheritableProperties)
79 { 77 {
80 return adoptRef(new EditingStyle(node, propertiesToInclude)); 78 return adoptRef(new EditingStyle(node, propertiesToInclude));
(...skipping 10 matching lines...) Expand all
91 } 89 }
92 90
93 static PassRefPtr<EditingStyle> create(CSSPropertyID propertyID, const Strin g& value) 91 static PassRefPtr<EditingStyle> create(CSSPropertyID propertyID, const Strin g& value)
94 { 92 {
95 return adoptRef(new EditingStyle(propertyID, value)); 93 return adoptRef(new EditingStyle(propertyID, value));
96 } 94 }
97 95
98 ~EditingStyle(); 96 ~EditingStyle();
99 97
100 MutableStylePropertySet* style() { return m_mutableStyle.get(); } 98 MutableStylePropertySet* style() { return m_mutableStyle.get(); }
101 bool textDirection(WritingDirection&) const; 99
102 bool isEmpty() const; 100 bool isEmpty() const;
103 void overrideWithStyle(const StylePropertySet*); 101
104 void clear(); 102 void clear();
105 PassRefPtr<EditingStyle> copy() const; 103 PassRefPtr<EditingStyle> copy() const;
106 PassRefPtr<EditingStyle> extractAndRemoveBlockProperties(); 104
107 PassRefPtr<EditingStyle> extractAndRemoveTextDirection();
108 void removeBlockProperties(); 105 void removeBlockProperties();
109 void removeStyleAddedByElement(Element*);
110 void removeStyleConflictingWithStyleOfElement(Element*);
111 void collapseTextDecorationProperties();
112 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreT extOnlyProperties };
113 TriState triStateOfStyle(EditingStyle*) const;
114 TriState triStateOfStyle(const VisibleSelection&) const;
115 bool conflictsWithInlineStyleOfElement(HTMLElement* element) const { return conflictsWithInlineStyleOfElement(element, 0, 0); }
116 bool conflictsWithInlineStyleOfElement(HTMLElement* element, EditingStyle* e xtractedStyle, Vector<CSSPropertyID>& conflictingProperties) const
117 {
118 return conflictsWithInlineStyleOfElement(element, extractedStyle, &confl ictingProperties);
119 }
120 bool conflictsWithImplicitStyleOfElement(HTMLElement*, EditingStyle* extract edStyle = 0, ShouldExtractMatchingStyle = DoNotExtractMatchingStyle) const;
121 bool conflictsWithImplicitStyleOfAttributes(HTMLElement*) const;
122 bool extractConflictingImplicitStyleOfAttributes(HTMLElement*, ShouldPreserv eWritingDirection, EditingStyle* extractedStyle,
123 Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingS tyle) const;
124 bool styleIsPresentInComputedStyleOfNode(Node*) const;
125 106
126 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*); 107 static bool elementIsStyledSpanOrHTMLEquivalent(const HTMLElement*);
127 108
128 void mergeTypingStyle(Document*); 109 void mergeTypingStyle(Document*);
129 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues };
130 void mergeInlineStyleOfElement(HTMLElement*, CSSPropertyOverrideMode, Proper tiesToInclude = AllProperties);
131 static PassRefPtr<EditingStyle> wrappingStyleForSerialization(ContainerNode* context, bool shouldAnnotate);
132 void mergeStyleFromRules(Element*);
133 void mergeStyleFromRulesForSerialization(Element*);
134 void removeStyleFromRulesAndContext(Element*, ContainerNode* context);
135 void removePropertiesInElementDefaultStyle(Element*);
136 void addAbsolutePositioningFromElement(const Element&);
137 void forceInline();
138 int legacyFontSize(Document*) const;
139
140 float fontSizeDelta() const { return m_fontSizeDelta; }
141 bool hasFontSizeDelta() const { return m_fontSizeDelta != NoFontDelta; }
142
143 static PassRefPtr<EditingStyle> styleAtSelectionStart(const VisibleSelection &, bool shouldUseBackgroundColorInEffect = false);
144 static WritingDirection textDirectionForSelection(const VisibleSelection&, E ditingStyle* typingStyle, bool& hasNestedOrMultipleEmbeddings);
145 110
146 private: 111 private:
147 EditingStyle(); 112 EditingStyle();
148 EditingStyle(ContainerNode*, PropertiesToInclude); 113 EditingStyle(ContainerNode*, PropertiesToInclude);
149 EditingStyle(const Position&, PropertiesToInclude); 114 EditingStyle(const Position&, PropertiesToInclude);
150 explicit EditingStyle(const StylePropertySet*); 115 explicit EditingStyle(const StylePropertySet*);
151 EditingStyle(CSSPropertyID, const String& value); 116 EditingStyle(CSSPropertyID, const String& value);
152 void init(Node*, PropertiesToInclude); 117 void init(Node*, PropertiesToInclude);
153 void removeTextFillAndStrokeColorsIfNeeded(RenderStyle*); 118 void removeTextFillAndStrokeColorsIfNeeded(RenderStyle*);
154 void setProperty(CSSPropertyID, const String& value, bool important = false) ; 119 void setProperty(CSSPropertyID, const String& value, bool important = false) ;
155 void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclar ation*); 120 void replaceFontSizeByKeywordIfPossible(RenderStyle*, CSSComputedStyleDeclar ation*);
156 void extractFontSizeDelta(); 121 void extractFontSizeDelta();
157 TriState triStateOfStyle(CSSStyleDeclaration* styleToCompare, ShouldIgnoreTe xtOnlyProperties) const; 122
158 bool conflictsWithInlineStyleOfElement(HTMLElement*, EditingStyle* extracted Style, Vector<CSSPropertyID>* conflictingProperties) const; 123 enum CSSPropertyOverrideMode { OverrideValues, DoNotOverrideValues };
159 void mergeInlineAndImplicitStyleOfElement(Element*, CSSPropertyOverrideMode, PropertiesToInclude);
160 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode); 124 void mergeStyle(const StylePropertySet*, CSSPropertyOverrideMode);
161 125
162 RefPtr<MutableStylePropertySet> m_mutableStyle; 126 RefPtr<MutableStylePropertySet> m_mutableStyle;
163 FixedPitchFontType m_fixedPitchFontType; 127 FixedPitchFontType m_fixedPitchFontType;
164 float m_fontSizeDelta; 128 float m_fontSizeDelta;
165 129
166 friend class HTMLElementEquivalent; 130 friend class HTMLElementEquivalent;
167 friend class HTMLAttributeEquivalent; 131 friend class HTMLAttributeEquivalent;
168 }; 132 };
169 133
170 class StyleChange {
171 public:
172 StyleChange()
173 : m_applyBold(false)
174 , m_applyItalic(false)
175 , m_applyUnderline(false)
176 , m_applyLineThrough(false)
177 , m_applySubscript(false)
178 , m_applySuperscript(false)
179 { }
180
181 StyleChange(EditingStyle*, const Position&);
182
183 String cssStyle() const { return m_cssStyle; }
184 bool applyBold() const { return m_applyBold; }
185 bool applyItalic() const { return m_applyItalic; }
186 bool applyUnderline() const { return m_applyUnderline; }
187 bool applyLineThrough() const { return m_applyLineThrough; }
188 bool applySubscript() const { return m_applySubscript; }
189 bool applySuperscript() const { return m_applySuperscript; }
190 bool applyFontColor() const { return m_applyFontColor.length() > 0; }
191 bool applyFontFace() const { return m_applyFontFace.length() > 0; }
192 bool applyFontSize() const { return m_applyFontSize.length() > 0; }
193
194 String fontColor() { return m_applyFontColor; }
195 String fontFace() { return m_applyFontFace; }
196 String fontSize() { return m_applyFontSize; }
197
198 bool operator==(const StyleChange& other)
199 {
200 return m_cssStyle == other.m_cssStyle
201 && m_applyBold == other.m_applyBold
202 && m_applyItalic == other.m_applyItalic
203 && m_applyUnderline == other.m_applyUnderline
204 && m_applyLineThrough == other.m_applyLineThrough
205 && m_applySubscript == other.m_applySubscript
206 && m_applySuperscript == other.m_applySuperscript
207 && m_applyFontColor == other.m_applyFontColor
208 && m_applyFontFace == other.m_applyFontFace
209 && m_applyFontSize == other.m_applyFontSize;
210 }
211 bool operator!=(const StyleChange& other)
212 {
213 return !(*this == other);
214 }
215 private:
216 void extractTextStyles(Document*, MutableStylePropertySet*, FixedPitchFontTy pe);
217
218 String m_cssStyle;
219 bool m_applyBold;
220 bool m_applyItalic;
221 bool m_applyUnderline;
222 bool m_applyLineThrough;
223 bool m_applySubscript;
224 bool m_applySuperscript;
225 String m_applyFontColor;
226 String m_applyFontFace;
227 String m_applyFontSize;
228 };
229
230 // FIXME: Remove these functions or make them non-global to discourage using CSS StyleDeclaration directly.
231 CSSValueID getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID);
232 CSSValueID getIdentifierValue(StylePropertySet*, CSSPropertyID);
233
234 } // namespace blink 134 } // namespace blink
235 135
236 #endif // SKY_ENGINE_CORE_EDITING_EDITINGSTYLE_H_ 136 #endif // SKY_ENGINE_CORE_EDITING_EDITINGSTYLE_H_
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/editing/EditingStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698