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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditingStyle.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc.
3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2010, 2011 Google 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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 properties.remove(index); 120 properties.remove(index);
121 continue; 121 continue;
122 } 122 }
123 ++index; 123 ++index;
124 } 124 }
125 } 125 }
126 return properties; 126 return properties;
127 } 127 }
128 128
129 template <class StyleDeclarationType> 129 template <class StyleDeclarationType>
130 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyEditingProperties(Sty leDeclarationType* style, EditingPropertiesType type = OnlyInheritableEditingPro perties) 130 static RawPtr<MutableStylePropertySet> copyEditingProperties(StyleDeclarationTyp e* style, EditingPropertiesType type = OnlyInheritableEditingProperties)
131 { 131 {
132 if (type == AllEditingProperties) 132 if (type == AllEditingProperties)
133 return style->copyPropertiesInSet(allEditingProperties()); 133 return style->copyPropertiesInSet(allEditingProperties());
134 return style->copyPropertiesInSet(inheritableEditingProperties()); 134 return style->copyPropertiesInSet(inheritableEditingProperties());
135 } 135 }
136 136
137 static inline bool isEditingProperty(int id) 137 static inline bool isEditingProperty(int id)
138 { 138 {
139 return allEditingProperties().contains(static_cast<CSSPropertyID>(id)); 139 return allEditingProperties().contains(static_cast<CSSPropertyID>(id));
140 } 140 }
141 141
142 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS tyle(PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style, EditingPropertie sType type = OnlyInheritableEditingProperties) 142 static RawPtr<MutableStylePropertySet> editingStyleFromComputedStyle(RawPtr<CSSC omputedStyleDeclaration> style, EditingPropertiesType type = OnlyInheritableEdit ingProperties)
143 { 143 {
144 if (!style) 144 if (!style)
145 return MutableStylePropertySet::create(HTMLQuirksMode); 145 return MutableStylePropertySet::create(HTMLQuirksMode);
146 return copyEditingProperties(style.get(), type); 146 return copyEditingProperties(style.get(), type);
147 } 147 }
148 148
149 static PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ensureComputedStyle(c onst Position& position) 149 static RawPtr<CSSComputedStyleDeclaration> ensureComputedStyle(const Position& p osition)
150 { 150 {
151 Element* elem = associatedElementOf(position); 151 Element* elem = associatedElementOf(position);
152 if (!elem) 152 if (!elem)
153 return nullptr; 153 return nullptr;
154 return CSSComputedStyleDeclaration::create(elem); 154 return CSSComputedStyleDeclaration::create(elem);
155 } 155 }
156 156
157 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); 157 static RawPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styl eWithRedundantProperties, CSSStyleDeclaration* baseStyle);
158 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV aluesMatch }; 158 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV aluesMatch };
159 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac yFontSizeMode); 159 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac yFontSizeMode);
160 static bool isTransparentColorValue(CSSValue*); 160 static bool isTransparentColorValue(CSSValue*);
161 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); 161 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
162 static bool hasTransparentBackgroundColor(StylePropertySet*); 162 static bool hasTransparentBackgroundColor(StylePropertySet*);
163 static PassRefPtrWillBeRawPtr<CSSValue> backgroundColorValueInEffect(Node*); 163 static RawPtr<CSSValue> backgroundColorValueInEffect(Node*);
164 164
165 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu ivalent> { 165 class HTMLElementEquivalent : public GarbageCollected<HTMLElementEquivalent> {
166 USING_FAST_MALLOC_WILL_BE_REMOVED(HTMLElementEquivalent);
167 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent);
168 public: 166 public:
169 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) 167 static RawPtr<HTMLElementEquivalent> create(CSSPropertyID propertyID, CSSVal ueID primitiveValue, const HTMLQualifiedName& tagName)
170 { 168 {
171 return adoptPtrWillBeNoop(new HTMLElementEquivalent(propertyID, primitiv eValue, tagName)); 169 return (new HTMLElementEquivalent(propertyID, primitiveValue, tagName));
172 } 170 }
173 171
174 virtual bool matches(const Element* element) const { return !m_tagName || el ement->hasTagName(*m_tagName); } 172 virtual bool matches(const Element* element) const { return !m_tagName || el ement->hasTagName(*m_tagName); }
175 virtual bool hasAttribute() const { return false; } 173 virtual bool hasAttribute() const { return false; }
176 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re turn style->getPropertyCSSValue(m_propertyID); } 174 virtual bool propertyExistsInStyle(const StylePropertySet* style) const { re turn style->getPropertyCSSValue(m_propertyID); }
177 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const; 175 virtual bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const;
178 virtual void addToStyle(Element*, EditingStyle*) const; 176 virtual void addToStyle(Element*, EditingStyle*) const;
179 177
180 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_primitiveValue); } 178 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_primitiveValue); }
181 179
182 protected: 180 protected:
183 HTMLElementEquivalent(CSSPropertyID); 181 HTMLElementEquivalent(CSSPropertyID);
184 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName); 182 HTMLElementEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName);
185 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu alifiedName& tagName); 183 HTMLElementEquivalent(CSSPropertyID, CSSValueID primitiveValue, const HTMLQu alifiedName& tagName);
186 const CSSPropertyID m_propertyID; 184 const CSSPropertyID m_propertyID;
187 const RefPtrWillBeMember<CSSPrimitiveValue> m_primitiveValue; 185 const Member<CSSPrimitiveValue> m_primitiveValue;
188 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t ag names are const global. 186 const HTMLQualifiedName* m_tagName; // We can store a pointer because HTML t ag names are const global.
189 }; 187 };
190 188
191 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent);
192
193 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id) 189 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id)
194 : m_propertyID(id) 190 : m_propertyID(id)
195 , m_tagName(0) 191 , m_tagName(0)
196 { 192 {
197 } 193 }
198 194
199 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi edName& tagName) 195 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, const HTMLQualifi edName& tagName)
200 : m_propertyID(id) 196 : m_propertyID(id)
201 , m_tagName(&tagName) 197 , m_tagName(&tagName)
202 { 198 {
203 } 199 }
204 200
205 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit iveValue, const HTMLQualifiedName& tagName) 201 HTMLElementEquivalent::HTMLElementEquivalent(CSSPropertyID id, CSSValueID primit iveValue, const HTMLQualifiedName& tagName)
206 : m_propertyID(id) 202 : m_propertyID(id)
207 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue)) 203 , m_primitiveValue(CSSPrimitiveValue::createIdentifier(primitiveValue))
208 , m_tagName(&tagName) 204 , m_tagName(&tagName)
209 { 205 {
210 ASSERT(primitiveValue != CSSValueInvalid); 206 ASSERT(primitiveValue != CSSValueInvalid);
211 } 207 }
212 208
213 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro pertySet* style) const 209 bool HTMLElementEquivalent::valueIsPresentInStyle(HTMLElement* element, StylePro pertySet* style) const
214 { 210 {
215 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID ); 211 RawPtr<CSSValue> value = style->getPropertyCSSValue(m_propertyID);
216 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit iveValue(value.get())->getValueID() == m_primitiveValue->getValueID(); 212 return matches(element) && value && value->isPrimitiveValue() && toCSSPrimit iveValue(value.get())->getValueID() == m_primitiveValue->getValueID();
217 } 213 }
218 214
219 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const 215 void HTMLElementEquivalent::addToStyle(Element*, EditingStyle* style) const
220 { 216 {
221 style->setProperty(m_propertyID, m_primitiveValue->cssText()); 217 style->setProperty(m_propertyID, m_primitiveValue->cssText());
222 } 218 }
223 219
224 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent { 220 class HTMLTextDecorationEquivalent final : public HTMLElementEquivalent {
225 public: 221 public:
226 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSValueID primi tiveValue, const HTMLQualifiedName& tagName) 222 static RawPtr<HTMLElementEquivalent> create(CSSValueID primitiveValue, const HTMLQualifiedName& tagName)
227 { 223 {
228 return adoptPtrWillBeNoop(new HTMLTextDecorationEquivalent(primitiveValu e, tagName)); 224 return (new HTMLTextDecorationEquivalent(primitiveValue, tagName));
229 } 225 }
230 bool propertyExistsInStyle(const StylePropertySet*) const override; 226 bool propertyExistsInStyle(const StylePropertySet*) const override;
231 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override; 227 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override;
232 228
233 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); } 229 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); }
234 230
235 private: 231 private:
236 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const HTMLQualifiedN ame& tagName); 232 HTMLTextDecorationEquivalent(CSSValueID primitiveValue, const HTMLQualifiedN ame& tagName);
237 }; 233 };
238 234
239 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const HTMLQualifiedName& tagName) 235 HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(CSSValueID primitiveV alue, const HTMLQualifiedName& tagName)
240 : HTMLElementEquivalent(textDecorationPropertyForEditing(), primitiveValue, tagName) 236 : HTMLElementEquivalent(textDecorationPropertyForEditing(), primitiveValue, tagName)
241 // m_propertyID is used in HTMLElementEquivalent::addToStyle 237 // m_propertyID is used in HTMLElementEquivalent::addToStyle
242 { 238 {
243 } 239 }
244 240
245 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const 241 bool HTMLTextDecorationEquivalent::propertyExistsInStyle(const StylePropertySet* style) const
246 { 242 {
247 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) 243 return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)
248 || style->getPropertyCSSValue(textDecorationPropertyForEditing()); 244 || style->getPropertyCSSValue(textDecorationPropertyForEditing());
249 } 245 }
250 246
251 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S tylePropertySet* style) const 247 bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(HTMLElement* element, S tylePropertySet* style) const
252 { 248 {
253 RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSProp ertyWebkitTextDecorationsInEffect); 249 RawPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTe xtDecorationsInEffect);
254 if (!styleValue) 250 if (!styleValue)
255 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing ()); 251 styleValue = style->getPropertyCSSValue(textDecorationPropertyForEditing ());
256 return matches(element) && styleValue && styleValue->isValueList() && toCSSV alueList(styleValue.get())->hasValue(m_primitiveValue.get()); 252 return matches(element) && styleValue && styleValue->isValueList() && toCSSV alueList(styleValue.get())->hasValue(m_primitiveValue.get());
257 } 253 }
258 254
259 class HTMLAttributeEquivalent : public HTMLElementEquivalent { 255 class HTMLAttributeEquivalent : public HTMLElementEquivalent {
260 public: 256 public:
261 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const HTMLQualifiedName& tagName, const QualifiedName& attrName) 257 static RawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, cons t HTMLQualifiedName& tagName, const QualifiedName& attrName)
262 { 258 {
263 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, tagNam e, attrName)); 259 return (new HTMLAttributeEquivalent(propertyID, tagName, attrName));
264 } 260 }
265 static PassOwnPtrWillBeRawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, const QualifiedName& attrName) 261 static RawPtr<HTMLAttributeEquivalent> create(CSSPropertyID propertyID, cons t QualifiedName& attrName)
266 { 262 {
267 return adoptPtrWillBeNoop(new HTMLAttributeEquivalent(propertyID, attrNa me)); 263 return (new HTMLAttributeEquivalent(propertyID, attrName));
268 } 264 }
269 265
270 bool matches(const Element* element) const override { return HTMLElementEqui valent::matches(element) && element->hasAttribute(m_attrName); } 266 bool matches(const Element* element) const override { return HTMLElementEqui valent::matches(element) && element->hasAttribute(m_attrName); }
271 bool hasAttribute() const override { return true; } 267 bool hasAttribute() const override { return true; }
272 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override; 268 bool valueIsPresentInStyle(HTMLElement*, StylePropertySet*) const override;
273 void addToStyle(Element*, EditingStyle*) const override; 269 void addToStyle(Element*, EditingStyle*) const override;
274 virtual PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const; 270 virtual RawPtr<CSSValue> attributeValueAsCSSValue(Element*) const;
275 inline const QualifiedName& attributeName() const { return m_attrName; } 271 inline const QualifiedName& attributeName() const { return m_attrName; }
276 272
277 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); } 273 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLElementEquivalent::trace(visitor); }
278 274
279 protected: 275 protected:
280 HTMLAttributeEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName, con st QualifiedName& attrName); 276 HTMLAttributeEquivalent(CSSPropertyID, const HTMLQualifiedName& tagName, con st QualifiedName& attrName);
281 HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& attrName); 277 HTMLAttributeEquivalent(CSSPropertyID, const QualifiedName& attrName);
282 const QualifiedName& m_attrName; // We can store a reference because HTML at tribute names are const global. 278 const QualifiedName& m_attrName; // We can store a reference because HTML at tribute names are const global.
283 }; 279 };
284 280
285 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const HTMLQua lifiedName& tagName, const QualifiedName& attrName) 281 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const HTMLQua lifiedName& tagName, const QualifiedName& attrName)
286 : HTMLElementEquivalent(id, tagName) 282 : HTMLElementEquivalent(id, tagName)
287 , m_attrName(attrName) 283 , m_attrName(attrName)
288 { 284 {
289 } 285 }
290 286
291 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi edName& attrName) 287 HTMLAttributeEquivalent::HTMLAttributeEquivalent(CSSPropertyID id, const Qualifi edName& attrName)
292 : HTMLElementEquivalent(id) 288 : HTMLElementEquivalent(id)
293 , m_attrName(attrName) 289 , m_attrName(attrName)
294 { 290 {
295 } 291 }
296 292
297 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP ropertySet* style) const 293 bool HTMLAttributeEquivalent::valueIsPresentInStyle(HTMLElement* element, StyleP ropertySet* style) const
298 { 294 {
299 RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element); 295 RawPtr<CSSValue> value = attributeValueAsCSSValue(element);
300 RefPtrWillBeRawPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_prope rtyID); 296 RawPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_propertyID);
301 297
302 return compareCSSValuePtr(value, styleValue); 298 return compareCSSValuePtr(value, styleValue);
303 } 299 }
304 300
305 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style) const 301 void HTMLAttributeEquivalent::addToStyle(Element* element, EditingStyle* style) const
306 { 302 {
307 if (RefPtrWillBeRawPtr<CSSValue> value = attributeValueAsCSSValue(element)) 303 if (RawPtr<CSSValue> value = attributeValueAsCSSValue(element))
308 style->setProperty(m_propertyID, value->cssText()); 304 style->setProperty(m_propertyID, value->cssText());
309 } 305 }
310 306
311 PassRefPtrWillBeRawPtr<CSSValue> HTMLAttributeEquivalent::attributeValueAsCSSVal ue(Element* element) const 307 RawPtr<CSSValue> HTMLAttributeEquivalent::attributeValueAsCSSValue(Element* elem ent) const
312 { 308 {
313 ASSERT(element); 309 ASSERT(element);
314 const AtomicString& value = element->getAttribute(m_attrName); 310 const AtomicString& value = element->getAttribute(m_attrName);
315 if (value.isNull()) 311 if (value.isNull())
316 return nullptr; 312 return nullptr;
317 313
318 RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = nullptr; 314 RawPtr<MutableStylePropertySet> dummyStyle = nullptr;
319 dummyStyle = MutableStylePropertySet::create(HTMLQuirksMode); 315 dummyStyle = MutableStylePropertySet::create(HTMLQuirksMode);
320 dummyStyle->setProperty(m_propertyID, value); 316 dummyStyle->setProperty(m_propertyID, value);
321 return dummyStyle->getPropertyCSSValue(m_propertyID); 317 return dummyStyle->getPropertyCSSValue(m_propertyID);
322 } 318 }
323 319
324 class HTMLFontSizeEquivalent final : public HTMLAttributeEquivalent { 320 class HTMLFontSizeEquivalent final : public HTMLAttributeEquivalent {
325 public: 321 public:
326 static PassOwnPtrWillBeRawPtr<HTMLFontSizeEquivalent> create() 322 static RawPtr<HTMLFontSizeEquivalent> create()
327 { 323 {
328 return adoptPtrWillBeNoop(new HTMLFontSizeEquivalent()); 324 return (new HTMLFontSizeEquivalent());
329 } 325 }
330 PassRefPtrWillBeRawPtr<CSSValue> attributeValueAsCSSValue(Element*) const ov erride; 326 RawPtr<CSSValue> attributeValueAsCSSValue(Element*) const override;
331 327
332 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); } 328 DEFINE_INLINE_VIRTUAL_TRACE() { HTMLAttributeEquivalent::trace(visitor); }
333 329
334 private: 330 private:
335 HTMLFontSizeEquivalent(); 331 HTMLFontSizeEquivalent();
336 }; 332 };
337 333
338 HTMLFontSizeEquivalent::HTMLFontSizeEquivalent() 334 HTMLFontSizeEquivalent::HTMLFontSizeEquivalent()
339 : HTMLAttributeEquivalent(CSSPropertyFontSize, HTMLNames::fontTag, HTMLNames ::sizeAttr) 335 : HTMLAttributeEquivalent(CSSPropertyFontSize, HTMLNames::fontTag, HTMLNames ::sizeAttr)
340 { 336 {
341 } 337 }
342 338
343 PassRefPtrWillBeRawPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValu e(Element* element) const 339 RawPtr<CSSValue> HTMLFontSizeEquivalent::attributeValueAsCSSValue(Element* eleme nt) const
344 { 340 {
345 ASSERT(element); 341 ASSERT(element);
346 const AtomicString& value = element->getAttribute(m_attrName); 342 const AtomicString& value = element->getAttribute(m_attrName);
347 if (value.isNull()) 343 if (value.isNull())
348 return nullptr; 344 return nullptr;
349 CSSValueID size; 345 CSSValueID size;
350 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size)) 346 if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size))
351 return nullptr; 347 return nullptr;
352 return CSSPrimitiveValue::createIdentifier(size); 348 return CSSPrimitiveValue::createIdentifier(size);
353 } 349 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe xtAlign), getIdentifierValue(style, CSSPropertyDirection)); 457 return textAlignResolvingStartAndEnd(getIdentifierValue(style, CSSPropertyTe xtAlign), getIdentifierValue(style, CSSPropertyDirection));
462 } 458 }
463 459
464 void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude) 460 void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude)
465 { 461 {
466 if (isTabHTMLSpanElementTextNode(node)) 462 if (isTabHTMLSpanElementTextNode(node))
467 node = tabSpanElement(node)->parentNode(); 463 node = tabSpanElement(node)->parentNode();
468 else if (isTabHTMLSpanElement(node)) 464 else if (isTabHTMLSpanElement(node))
469 node = node->parentNode(); 465 node = node->parentNode();
470 466
471 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CS SComputedStyleDeclaration::create(node); 467 RawPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = CSSComputedSty leDeclaration::create(node);
472 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition); 468 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosi tion ? computedStyleAtPosition->copyProperties() : editingStyleFromComputedStyle (computedStyleAtPosition);
473 469
474 if (propertiesToInclude == EditingPropertiesInEffect) { 470 if (propertiesToInclude == EditingPropertiesInEffect) {
475 if (RefPtrWillBeRawPtr<CSSValue> value = backgroundColorValueInEffect(no de)) 471 if (RawPtr<CSSValue> value = backgroundColorValueInEffect(node))
476 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt()); 472 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssTe xt());
477 if (RefPtrWillBeRawPtr<CSSValue> value = computedStyleAtPosition->getPro pertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) 473 if (RawPtr<CSSValue> value = computedStyleAtPosition->getPropertyCSSValu e(CSSPropertyWebkitTextDecorationsInEffect))
478 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t()); 474 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssTex t());
479 } 475 }
480 476
481 if (node && node->ensureComputedStyle()) { 477 if (node && node->ensureComputedStyle()) {
482 const ComputedStyle* computedStyle = node->ensureComputedStyle(); 478 const ComputedStyle* computedStyle = node->ensureComputedStyle();
483 removeTextFillAndStrokeColorsIfNeeded(computedStyle); 479 removeTextFillAndStrokeColorsIfNeeded(computedStyle);
484 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio n.get()); 480 replaceFontSizeByKeywordIfPossible(computedStyle, computedStyleAtPositio n.get());
485 } 481 }
486 482
487 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont(); 483 m_isMonospaceFont = computedStyleAtPosition->isMonospaceFont();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 if (!m_mutableStyle) 515 if (!m_mutableStyle)
520 return; 516 return;
521 517
522 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) { 518 if (m_mutableStyle->getPropertyCSSValue(CSSPropertyFontSize)) {
523 // Explicit font size overrides any delta. 519 // Explicit font size overrides any delta.
524 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); 520 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
525 return; 521 return;
526 } 522 }
527 523
528 // Get the adjustment amount out of the style. 524 // Get the adjustment amount out of the style.
529 RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSS PropertyWebkitFontSizeDelta); 525 RawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(CSSPropertyWebk itFontSizeDelta);
530 if (!value || !value->isPrimitiveValue()) 526 if (!value || !value->isPrimitiveValue())
531 return; 527 return;
532 528
533 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); 529 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
534 530
535 // Only PX handled now. If we handle more types in the future, perhaps 531 // Only PX handled now. If we handle more types in the future, perhaps
536 // a switch statement here would be more appropriate. 532 // a switch statement here would be more appropriate.
537 if (!primitiveValue->isPx()) 533 if (!primitiveValue->isPx())
538 return; 534 return;
539 535
540 m_fontSizeDelta = primitiveValue->getFloatValue(); 536 m_fontSizeDelta = primitiveValue->getFloatValue();
541 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta); 537 m_mutableStyle->removeProperty(CSSPropertyWebkitFontSizeDelta);
542 } 538 }
543 539
544 bool EditingStyle::isEmpty() const 540 bool EditingStyle::isEmpty() const
545 { 541 {
546 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta == NoFontDelta; 542 return (!m_mutableStyle || m_mutableStyle->isEmpty()) && m_fontSizeDelta == NoFontDelta;
547 } 543 }
548 544
549 bool EditingStyle::textDirection(WritingDirection& writingDirection) const 545 bool EditingStyle::textDirection(WritingDirection& writingDirection) const
550 { 546 {
551 if (!m_mutableStyle) 547 if (!m_mutableStyle)
552 return false; 548 return false;
553 549
554 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyUnicodeBidi); 550 RawPtr<CSSValue> unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSProper tyUnicodeBidi);
555 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 551 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
556 return false; 552 return false;
557 553
558 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal ueID(); 554 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->getVal ueID();
559 if (isEmbedOrIsolate(unicodeBidiValue)) { 555 if (isEmbedOrIsolate(unicodeBidiValue)) {
560 RefPtrWillBeRawPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSV alue(CSSPropertyDirection); 556 RawPtr<CSSValue> direction = m_mutableStyle->getPropertyCSSValue(CSSProp ertyDirection);
561 if (!direction || !direction->isPrimitiveValue()) 557 if (!direction || !direction->isPrimitiveValue())
562 return false; 558 return false;
563 559
564 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection; 560 writingDirection = toCSSPrimitiveValue(direction.get())->getValueID() == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
565 561
566 return true; 562 return true;
567 } 563 }
568 564
569 if (unicodeBidiValue == CSSValueNormal) { 565 if (unicodeBidiValue == CSSValueNormal) {
570 writingDirection = NaturalWritingDirection; 566 writingDirection = NaturalWritingDirection;
(...skipping 13 matching lines...) Expand all
584 extractFontSizeDelta(); 580 extractFontSizeDelta();
585 } 581 }
586 582
587 void EditingStyle::clear() 583 void EditingStyle::clear()
588 { 584 {
589 m_mutableStyle.clear(); 585 m_mutableStyle.clear();
590 m_isMonospaceFont = false; 586 m_isMonospaceFont = false;
591 m_fontSizeDelta = NoFontDelta; 587 m_fontSizeDelta = NoFontDelta;
592 } 588 }
593 589
594 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::copy() const 590 RawPtr<EditingStyle> EditingStyle::copy() const
595 { 591 {
596 RefPtrWillBeRawPtr<EditingStyle> copy = EditingStyle::create(); 592 RawPtr<EditingStyle> copy = EditingStyle::create();
597 if (m_mutableStyle) 593 if (m_mutableStyle)
598 copy->m_mutableStyle = m_mutableStyle->mutableCopy(); 594 copy->m_mutableStyle = m_mutableStyle->mutableCopy();
599 copy->m_isMonospaceFont = m_isMonospaceFont; 595 copy->m_isMonospaceFont = m_isMonospaceFont;
600 copy->m_fontSizeDelta = m_fontSizeDelta; 596 copy->m_fontSizeDelta = m_fontSizeDelta;
601 return copy; 597 return copy;
602 } 598 }
603 599
604 // This is the list of CSS properties that apply specially to block-level elemen ts. 600 // This is the list of CSS properties that apply specially to block-level elemen ts.
605 static const CSSPropertyID staticBlockProperties[] = { 601 static const CSSPropertyID staticBlockProperties[] = {
606 CSSPropertyOrphans, 602 CSSPropertyOrphans,
(...skipping 18 matching lines...) Expand all
625 }; 621 };
626 622
627 static const Vector<CSSPropertyID>& blockPropertiesVector() 623 static const Vector<CSSPropertyID>& blockPropertiesVector()
628 { 624 {
629 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); 625 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
630 if (properties.isEmpty()) 626 if (properties.isEmpty())
631 CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticBlockPro perties, WTF_ARRAY_LENGTH(staticBlockProperties), properties); 627 CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(staticBlockPro perties, WTF_ARRAY_LENGTH(staticBlockProperties), properties);
632 return properties; 628 return properties;
633 } 629 }
634 630
635 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveBlockProperti es() 631 RawPtr<EditingStyle> EditingStyle::extractAndRemoveBlockProperties()
636 { 632 {
637 RefPtrWillBeRawPtr<EditingStyle> blockProperties = EditingStyle::create(); 633 RawPtr<EditingStyle> blockProperties = EditingStyle::create();
638 if (!m_mutableStyle) 634 if (!m_mutableStyle)
639 return blockProperties; 635 return blockProperties;
640 636
641 blockProperties->m_mutableStyle = m_mutableStyle->copyPropertiesInSet(blockP ropertiesVector()); 637 blockProperties->m_mutableStyle = m_mutableStyle->copyPropertiesInSet(blockP ropertiesVector());
642 removeBlockProperties(); 638 removeBlockProperties();
643 639
644 return blockProperties; 640 return blockProperties;
645 } 641 }
646 642
647 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::extractAndRemoveTextDirection () 643 RawPtr<EditingStyle> EditingStyle::extractAndRemoveTextDirection()
648 { 644 {
649 RefPtrWillBeRawPtr<EditingStyle> textDirection = EditingStyle::create(); 645 RawPtr<EditingStyle> textDirection = EditingStyle::create();
650 textDirection->m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMo de); 646 textDirection->m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMo de);
651 textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueI solate, m_mutableStyle->propertyIsImportant(CSSPropertyUnicodeBidi)); 647 textDirection->m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, CSSValueI solate, m_mutableStyle->propertyIsImportant(CSSPropertyUnicodeBidi));
652 textDirection->m_mutableStyle->setProperty(CSSPropertyDirection, m_mutableSt yle->getPropertyValue(CSSPropertyDirection), 648 textDirection->m_mutableStyle->setProperty(CSSPropertyDirection, m_mutableSt yle->getPropertyValue(CSSPropertyDirection),
653 m_mutableStyle->propertyIsImportant(CSSPropertyDirection)); 649 m_mutableStyle->propertyIsImportant(CSSPropertyDirection));
654 650
655 m_mutableStyle->removeProperty(CSSPropertyUnicodeBidi); 651 m_mutableStyle->removeProperty(CSSPropertyUnicodeBidi);
656 m_mutableStyle->removeProperty(CSSPropertyDirection); 652 m_mutableStyle->removeProperty(CSSPropertyDirection);
657 653
658 return textDirection; 654 return textDirection;
659 } 655 }
660 656
661 void EditingStyle::removeBlockProperties() 657 void EditingStyle::removeBlockProperties()
662 { 658 {
663 if (!m_mutableStyle) 659 if (!m_mutableStyle)
664 return; 660 return;
665 661
666 m_mutableStyle->removePropertiesInSet(blockPropertiesVector().data(), blockP ropertiesVector().size()); 662 m_mutableStyle->removePropertiesInSet(blockPropertiesVector().data(), blockP ropertiesVector().size());
667 } 663 }
668 664
669 void EditingStyle::removeStyleAddedByElement(Element* element) 665 void EditingStyle::removeStyleAddedByElement(Element* element)
670 { 666 {
671 if (!element || !element->parentNode()) 667 if (!element || !element->parentNode())
672 return; 668 return;
673 RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromCo mputedStyle(CSSComputedStyleDeclaration::create(element->parentNode()), AllEditi ngProperties); 669 RawPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle( CSSComputedStyleDeclaration::create(element->parentNode()), AllEditingProperties );
674 RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComp utedStyle(CSSComputedStyleDeclaration::create(element), AllEditingProperties); 670 RawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CS SComputedStyleDeclaration::create(element), AllEditingProperties);
675 nodeStyle->removeEquivalentProperties(parentStyle.get()); 671 nodeStyle->removeEquivalentProperties(parentStyle.get());
676 m_mutableStyle->removeEquivalentProperties(nodeStyle.get()); 672 m_mutableStyle->removeEquivalentProperties(nodeStyle.get());
677 } 673 }
678 674
679 void EditingStyle::removeStyleConflictingWithStyleOfElement(Element* element) 675 void EditingStyle::removeStyleConflictingWithStyleOfElement(Element* element)
680 { 676 {
681 if (!element || !element->parentNode() || !m_mutableStyle) 677 if (!element || !element->parentNode() || !m_mutableStyle)
682 return; 678 return;
683 679
684 RefPtrWillBeRawPtr<MutableStylePropertySet> parentStyle = editingStyleFromCo mputedStyle(CSSComputedStyleDeclaration::create(element->parentNode()), AllEditi ngProperties); 680 RawPtr<MutableStylePropertySet> parentStyle = editingStyleFromComputedStyle( CSSComputedStyleDeclaration::create(element->parentNode()), AllEditingProperties );
685 RefPtrWillBeRawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComp utedStyle(CSSComputedStyleDeclaration::create(element), AllEditingProperties); 681 RawPtr<MutableStylePropertySet> nodeStyle = editingStyleFromComputedStyle(CS SComputedStyleDeclaration::create(element), AllEditingProperties);
686 nodeStyle->removeEquivalentProperties(parentStyle.get()); 682 nodeStyle->removeEquivalentProperties(parentStyle.get());
687 683
688 unsigned propertyCount = nodeStyle->propertyCount(); 684 unsigned propertyCount = nodeStyle->propertyCount();
689 for (unsigned i = 0; i < propertyCount; ++i) 685 for (unsigned i = 0; i < propertyCount; ++i)
690 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id()); 686 m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id());
691 } 687 }
692 688
693 void EditingStyle::collapseTextDecorationProperties() 689 void EditingStyle::collapseTextDecorationProperties()
694 { 690 {
695 if (!m_mutableStyle) 691 if (!m_mutableStyle)
696 return; 692 return;
697 693
698 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPr opertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect); 694 RawPtr<CSSValue> textDecorationsInEffect = m_mutableStyle->getPropertyCSSVal ue(CSSPropertyWebkitTextDecorationsInEffect);
699 if (!textDecorationsInEffect) 695 if (!textDecorationsInEffect)
700 return; 696 return;
701 697
702 if (textDecorationsInEffect->isValueList()) 698 if (textDecorationsInEffect->isValueList())
703 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr opertyForEditing())); 699 m_mutableStyle->setProperty(textDecorationPropertyForEditing(), textDeco rationsInEffect->cssText(), m_mutableStyle->propertyIsImportant(textDecorationPr opertyForEditing()));
704 else 700 else
705 m_mutableStyle->removeProperty(textDecorationPropertyForEditing()); 701 m_mutableStyle->removeProperty(textDecorationPropertyForEditing());
706 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 702 m_mutableStyle->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
707 } 703 }
708 704
(...skipping 11 matching lines...) Expand all
720 716
721 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const 717 TriState EditingStyle::triStateOfStyle(EditingStyle* style) const
722 { 718 {
723 if (!style || !style->m_mutableStyle) 719 if (!style || !style->m_mutableStyle)
724 return FalseTriState; 720 return FalseTriState;
725 return triStateOfStyle(style->m_mutableStyle->ensureCSSStyleDeclaration(), D oNotIgnoreTextOnlyProperties); 721 return triStateOfStyle(style->m_mutableStyle->ensureCSSStyleDeclaration(), D oNotIgnoreTextOnlyProperties);
726 } 722 }
727 723
728 TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, Shou ldIgnoreTextOnlyProperties shouldIgnoreTextOnlyProperties) const 724 TriState EditingStyle::triStateOfStyle(CSSStyleDeclaration* styleToCompare, Shou ldIgnoreTextOnlyProperties shouldIgnoreTextOnlyProperties) const
729 { 725 {
730 RefPtrWillBeRawPtr<MutableStylePropertySet> difference = getPropertiesNotIn( m_mutableStyle.get(), styleToCompare); 726 RawPtr<MutableStylePropertySet> difference = getPropertiesNotIn(m_mutableSty le.get(), styleToCompare);
731 727
732 if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties) 728 if (shouldIgnoreTextOnlyProperties == IgnoreTextOnlyProperties)
733 difference->removePropertiesInSet(textOnlyProperties, WTF_ARRAY_LENGTH(t extOnlyProperties)); 729 difference->removePropertiesInSet(textOnlyProperties, WTF_ARRAY_LENGTH(t extOnlyProperties));
734 730
735 if (difference->isEmpty()) 731 if (difference->isEmpty())
736 return TrueTriState; 732 return TrueTriState;
737 if (difference->propertyCount() == m_mutableStyle->propertyCount()) 733 if (difference->propertyCount() == m_mutableStyle->propertyCount())
738 return FalseTriState; 734 return FalseTriState;
739 735
740 return MixedTriState; 736 return MixedTriState;
741 } 737 }
742 738
743 TriState EditingStyle::triStateOfStyle(const VisibleSelection& selection) const 739 TriState EditingStyle::triStateOfStyle(const VisibleSelection& selection) const
744 { 740 {
745 if (!selection.isCaretOrRange()) 741 if (!selection.isCaretOrRange())
746 return FalseTriState; 742 return FalseTriState;
747 743
748 if (selection.isCaret()) 744 if (selection.isCaret())
749 return triStateOfStyle(EditingStyle::styleAtSelectionStart(selection).ge t()); 745 return triStateOfStyle(EditingStyle::styleAtSelectionStart(selection).ge t());
750 746
751 TriState state = FalseTriState; 747 TriState state = FalseTriState;
752 bool nodeIsStart = true; 748 bool nodeIsStart = true;
753 for (Node& node : NodeTraversal::startsAt(selection.start().anchorNode())) { 749 for (Node& node : NodeTraversal::startsAt(selection.start().anchorNode())) {
754 if (node.layoutObject() && node.hasEditableStyle()) { 750 if (node.layoutObject() && node.hasEditableStyle()) {
755 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> nodeStyle = CSSCompu tedStyleDeclaration::create(&node); 751 RawPtr<CSSComputedStyleDeclaration> nodeStyle = CSSComputedStyleDecl aration::create(&node);
756 if (nodeStyle) { 752 if (nodeStyle) {
757 TriState nodeState = triStateOfStyle(nodeStyle.get(), node.isTex tNode() ? EditingStyle::DoNotIgnoreTextOnlyProperties : EditingStyle::IgnoreText OnlyProperties); 753 TriState nodeState = triStateOfStyle(nodeStyle.get(), node.isTex tNode() ? EditingStyle::DoNotIgnoreTextOnlyProperties : EditingStyle::IgnoreText OnlyProperties);
758 if (nodeIsStart) { 754 if (nodeIsStart) {
759 state = nodeState; 755 state = nodeState;
760 nodeIsStart = false; 756 nodeIsStart = false;
761 } else if (state != nodeState && node.isTextNode()) { 757 } else if (state != nodeState && node.isTextNode()) {
762 state = MixedTriState; 758 state = MixedTriState;
763 break; 759 break;
764 } 760 }
765 } 761 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 813
818 conflictingProperties->append(propertyID); 814 conflictingProperties->append(propertyID);
819 815
820 if (extractedStyle) 816 if (extractedStyle)
821 extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValu e(propertyID), inlineStyle->propertyIsImportant(propertyID)); 817 extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValu e(propertyID), inlineStyle->propertyIsImportant(propertyID));
822 } 818 }
823 819
824 return conflictingProperties && !conflictingProperties->isEmpty(); 820 return conflictingProperties && !conflictingProperties->isEmpty();
825 } 821 }
826 822
827 static const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent>>& htmlEl ementEquivalents() 823 static const HeapVector<Member<HTMLElementEquivalent>>& htmlElementEquivalents()
828 { 824 {
829 DEFINE_STATIC_LOCAL(WillBePersistentHeapVector<OwnPtrWillBeMember<HTMLElemen tEquivalent>>, HTMLElementEquivalents, ()); 825 DEFINE_STATIC_LOCAL(PersistentHeapVector<Member<HTMLElementEquivalent>>, HTM LElementEquivalents, ());
830 if (!HTMLElementEquivalents.size()) { 826 if (!HTMLElementEquivalents.size()) {
831 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontWeight, CSSValueBold, HTMLNames::bTag)); 827 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontWeight, CSSValueBold, HTMLNames::bTag));
832 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontWeight, CSSValueBold, HTMLNames::strongTag)); 828 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontWeight, CSSValueBold, HTMLNames::strongTag));
833 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV erticalAlign, CSSValueSub, HTMLNames::subTag)); 829 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV erticalAlign, CSSValueSub, HTMLNames::subTag));
834 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV erticalAlign, CSSValueSuper, HTMLNames::supTag)); 830 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyV erticalAlign, CSSValueSuper, HTMLNames::supTag));
835 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontStyle, CSSValueItalic, HTMLNames::iTag)); 831 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontStyle, CSSValueItalic, HTMLNames::iTag));
836 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontStyle, CSSValueItalic, HTMLNames::emTag)); 832 HTMLElementEquivalents.append(HTMLElementEquivalent::create(CSSPropertyF ontStyle, CSSValueItalic, HTMLNames::emTag));
837 833
838 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa lueUnderline, HTMLNames::uTag)); 834 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa lueUnderline, HTMLNames::uTag));
839 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa lueLineThrough, HTMLNames::sTag)); 835 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa lueLineThrough, HTMLNames::sTag));
840 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa lueLineThrough, HTMLNames::strikeTag)); 836 HTMLElementEquivalents.append(HTMLTextDecorationEquivalent::create(CSSVa lueLineThrough, HTMLNames::strikeTag));
841 } 837 }
842 838
843 return HTMLElementEquivalents; 839 return HTMLElementEquivalents;
844 } 840 }
845 841
846 842
847 bool EditingStyle::conflictsWithImplicitStyleOfElement(HTMLElement* element, Edi tingStyle* extractedStyle, ShouldExtractMatchingStyle shouldExtractMatchingStyle ) const 843 bool EditingStyle::conflictsWithImplicitStyleOfElement(HTMLElement* element, Edi tingStyle* extractedStyle, ShouldExtractMatchingStyle shouldExtractMatchingStyle ) const
848 { 844 {
849 if (!m_mutableStyle) 845 if (!m_mutableStyle)
850 return false; 846 return false;
851 847
852 const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent>>& HTMLEleme ntEquivalents = htmlElementEquivalents(); 848 const HeapVector<Member<HTMLElementEquivalent>>& HTMLElementEquivalents = ht mlElementEquivalents();
853 for (size_t i = 0; i < HTMLElementEquivalents.size(); ++i) { 849 for (size_t i = 0; i < HTMLElementEquivalents.size(); ++i) {
854 const HTMLElementEquivalent* equivalent = HTMLElementEquivalents[i].get( ); 850 const HTMLElementEquivalent* equivalent = HTMLElementEquivalents[i].get( );
855 if (equivalent->matches(element) && equivalent->propertyExistsInStyle(m_ mutableStyle.get()) 851 if (equivalent->matches(element) && equivalent->propertyExistsInStyle(m_ mutableStyle.get())
856 && (shouldExtractMatchingStyle == ExtractMatchingStyle || !equivalen t->valueIsPresentInStyle(element, m_mutableStyle.get()))) { 852 && (shouldExtractMatchingStyle == ExtractMatchingStyle || !equivalen t->valueIsPresentInStyle(element, m_mutableStyle.get()))) {
857 if (extractedStyle) 853 if (extractedStyle)
858 equivalent->addToStyle(element, extractedStyle); 854 equivalent->addToStyle(element, extractedStyle);
859 return true; 855 return true;
860 } 856 }
861 } 857 }
862 return false; 858 return false;
863 } 859 }
864 860
865 static const WillBeHeapVector<OwnPtrWillBeMember<HTMLAttributeEquivalent>>& html AttributeEquivalents() 861 static const HeapVector<Member<HTMLAttributeEquivalent>>& htmlAttributeEquivalen ts()
866 { 862 {
867 DEFINE_STATIC_LOCAL(WillBePersistentHeapVector<OwnPtrWillBeMember<HTMLAttrib uteEquivalent>>, HTMLAttributeEquivalents, ()); 863 DEFINE_STATIC_LOCAL(PersistentHeapVector<Member<HTMLAttributeEquivalent>>, H TMLAttributeEquivalents, ());
868 if (!HTMLAttributeEquivalents.size()) { 864 if (!HTMLAttributeEquivalents.size()) {
869 // elementIsStyledSpanOrHTMLEquivalent depends on the fact each HTMLAttr iuteEquivalent matches exactly one attribute 865 // elementIsStyledSpanOrHTMLEquivalent depends on the fact each HTMLAttr iuteEquivalent matches exactly one attribute
870 // of exactly one element except dirAttr. 866 // of exactly one element except dirAttr.
871 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyColor, HTMLNames::fontTag, HTMLNames::colorAttr)); 867 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyColor, HTMLNames::fontTag, HTMLNames::colorAttr));
872 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyFontFamily, HTMLNames::fontTag, HTMLNames::faceAttr)); 868 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyFontFamily, HTMLNames::fontTag, HTMLNames::faceAttr));
873 HTMLAttributeEquivalents.append(HTMLFontSizeEquivalent::create()); 869 HTMLAttributeEquivalents.append(HTMLFontSizeEquivalent::create());
874 870
875 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyDirection, HTMLNames::dirAttr)); 871 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyDirection, HTMLNames::dirAttr));
876 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyUnicodeBidi, HTMLNames::dirAttr)); 872 HTMLAttributeEquivalents.append(HTMLAttributeEquivalent::create(CSSPrope rtyUnicodeBidi, HTMLNames::dirAttr));
877 } 873 }
878 874
879 return HTMLAttributeEquivalents; 875 return HTMLAttributeEquivalents;
880 } 876 }
881 877
882 bool EditingStyle::conflictsWithImplicitStyleOfAttributes(HTMLElement* element) const 878 bool EditingStyle::conflictsWithImplicitStyleOfAttributes(HTMLElement* element) const
883 { 879 {
884 ASSERT(element); 880 ASSERT(element);
885 if (!m_mutableStyle) 881 if (!m_mutableStyle)
886 return false; 882 return false;
887 883
888 const WillBeHeapVector<OwnPtrWillBeMember<HTMLAttributeEquivalent>>& HTMLAtt ributeEquivalents = htmlAttributeEquivalents(); 884 const HeapVector<Member<HTMLAttributeEquivalent>>& HTMLAttributeEquivalents = htmlAttributeEquivalents();
889 for (const auto& equivalent : HTMLAttributeEquivalents) { 885 for (const auto& equivalent : HTMLAttributeEquivalents) {
890 if (equivalent->matches(element) && equivalent->propertyExistsInStyle(m_ mutableStyle.get()) 886 if (equivalent->matches(element) && equivalent->propertyExistsInStyle(m_ mutableStyle.get())
891 && !equivalent->valueIsPresentInStyle(element, m_mutableStyle.get()) ) 887 && !equivalent->valueIsPresentInStyle(element, m_mutableStyle.get()) )
892 return true; 888 return true;
893 } 889 }
894 890
895 return false; 891 return false;
896 } 892 }
897 893
898 bool EditingStyle::extractConflictingImplicitStyleOfAttributes(HTMLElement* elem ent, ShouldPreserveWritingDirection shouldPreserveWritingDirection, 894 bool EditingStyle::extractConflictingImplicitStyleOfAttributes(HTMLElement* elem ent, ShouldPreserveWritingDirection shouldPreserveWritingDirection,
899 EditingStyle* extractedStyle, Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingStyle shouldExtractMatchingStyle) const 895 EditingStyle* extractedStyle, Vector<QualifiedName>& conflictingAttributes, ShouldExtractMatchingStyle shouldExtractMatchingStyle) const
900 { 896 {
901 ASSERT(element); 897 ASSERT(element);
902 // HTMLAttributeEquivalent::addToStyle doesn't support unicode-bidi and dire ction properties 898 // HTMLAttributeEquivalent::addToStyle doesn't support unicode-bidi and dire ction properties
903 ASSERT(!extractedStyle || shouldPreserveWritingDirection == PreserveWritingD irection); 899 ASSERT(!extractedStyle || shouldPreserveWritingDirection == PreserveWritingD irection);
904 if (!m_mutableStyle) 900 if (!m_mutableStyle)
905 return false; 901 return false;
906 902
907 const WillBeHeapVector<OwnPtrWillBeMember<HTMLAttributeEquivalent>>& HTMLAtt ributeEquivalents = htmlAttributeEquivalents(); 903 const HeapVector<Member<HTMLAttributeEquivalent>>& HTMLAttributeEquivalents = htmlAttributeEquivalents();
908 bool removed = false; 904 bool removed = false;
909 for (const auto& attribute : HTMLAttributeEquivalents) { 905 for (const auto& attribute : HTMLAttributeEquivalents) {
910 const HTMLAttributeEquivalent* equivalent = attribute.get(); 906 const HTMLAttributeEquivalent* equivalent = attribute.get();
911 907
912 // unicode-bidi and direction are pushed down separately so don't push d own with other styles. 908 // unicode-bidi and direction are pushed down separately so don't push d own with other styles.
913 if (shouldPreserveWritingDirection == PreserveWritingDirection && equiva lent->attributeName() == HTMLNames::dirAttr) 909 if (shouldPreserveWritingDirection == PreserveWritingDirection && equiva lent->attributeName() == HTMLNames::dirAttr)
914 continue; 910 continue;
915 911
916 if (!equivalent->matches(element) || !equivalent->propertyExistsInStyle( m_mutableStyle.get()) 912 if (!equivalent->matches(element) || !equivalent->propertyExistsInStyle( m_mutableStyle.get())
917 || (shouldExtractMatchingStyle == DoNotExtractMatchingStyle && equiv alent->valueIsPresentInStyle(element, m_mutableStyle.get()))) 913 || (shouldExtractMatchingStyle == DoNotExtractMatchingStyle && equiv alent->valueIsPresentInStyle(element, m_mutableStyle.get())))
(...skipping 13 matching lines...) Expand all
931 return !m_mutableStyle || getPropertiesNotIn(m_mutableStyle.get(), CSSComput edStyleDeclaration::create(node).get())->isEmpty(); 927 return !m_mutableStyle || getPropertiesNotIn(m_mutableStyle.get(), CSSComput edStyleDeclaration::create(node).get())->isEmpty();
932 } 928 }
933 929
934 bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* elemen t) 930 bool EditingStyle::elementIsStyledSpanOrHTMLEquivalent(const HTMLElement* elemen t)
935 { 931 {
936 ASSERT(element); 932 ASSERT(element);
937 bool elementIsSpanOrElementEquivalent = false; 933 bool elementIsSpanOrElementEquivalent = false;
938 if (isHTMLSpanElement(*element)) { 934 if (isHTMLSpanElement(*element)) {
939 elementIsSpanOrElementEquivalent = true; 935 elementIsSpanOrElementEquivalent = true;
940 } else { 936 } else {
941 const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent>>& HTMLE lementEquivalents = htmlElementEquivalents(); 937 const HeapVector<Member<HTMLElementEquivalent>>& HTMLElementEquivalents = htmlElementEquivalents();
942 size_t i; 938 size_t i;
943 for (i = 0; i < HTMLElementEquivalents.size(); ++i) { 939 for (i = 0; i < HTMLElementEquivalents.size(); ++i) {
944 if (HTMLElementEquivalents[i]->matches(element)) { 940 if (HTMLElementEquivalents[i]->matches(element)) {
945 elementIsSpanOrElementEquivalent = true; 941 elementIsSpanOrElementEquivalent = true;
946 break; 942 break;
947 } 943 }
948 } 944 }
949 } 945 }
950 946
951 AttributeCollection attributes = element->attributes(); 947 AttributeCollection attributes = element->attributes();
952 if (attributes.isEmpty()) 948 if (attributes.isEmpty())
953 return elementIsSpanOrElementEquivalent; // span, b, etc... without any attributes 949 return elementIsSpanOrElementEquivalent; // span, b, etc... without any attributes
954 950
955 unsigned matchedAttributes = 0; 951 unsigned matchedAttributes = 0;
956 const WillBeHeapVector<OwnPtrWillBeMember<HTMLAttributeEquivalent>>& HTMLAtt ributeEquivalents = htmlAttributeEquivalents(); 952 const HeapVector<Member<HTMLAttributeEquivalent>>& HTMLAttributeEquivalents = htmlAttributeEquivalents();
957 for (const auto& equivalent : HTMLAttributeEquivalents) { 953 for (const auto& equivalent : HTMLAttributeEquivalents) {
958 if (equivalent->matches(element) && equivalent->attributeName() != HTMLN ames::dirAttr) 954 if (equivalent->matches(element) && equivalent->attributeName() != HTMLN ames::dirAttr)
959 matchedAttributes++; 955 matchedAttributes++;
960 } 956 }
961 957
962 if (!elementIsSpanOrElementEquivalent && !matchedAttributes) 958 if (!elementIsSpanOrElementEquivalent && !matchedAttributes)
963 return false; // element is not a span, a html element equivalent, or fo nt element. 959 return false; // element is not a span, a html element equivalent, or fo nt element.
964 960
965 if (element->getAttribute(HTMLNames::classAttr) == AppleStyleSpanClass) 961 if (element->getAttribute(HTMLNames::classAttr) == AppleStyleSpanClass)
966 matchedAttributes++; 962 matchedAttributes++;
(...skipping 15 matching lines...) Expand all
982 } 978 }
983 979
984 void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit ingDirection shouldPreserveWritingDirection) 980 void EditingStyle::prepareToApplyAt(const Position& position, ShouldPreserveWrit ingDirection shouldPreserveWritingDirection)
985 { 981 {
986 if (!m_mutableStyle) 982 if (!m_mutableStyle)
987 return; 983 return;
988 984
989 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o nly removes the editing style. 985 // ReplaceSelectionCommand::handleStyleSpans() requires that this function o nly removes the editing style.
990 // If this function was modified in the future to delete all redundant prope rties, then add a boolean value to indicate 986 // If this function was modified in the future to delete all redundant prope rties, then add a boolean value to indicate
991 // which one of editingStyleAtPosition or computedStyle is called. 987 // which one of editingStyleAtPosition or computedStyle is called.
992 RefPtrWillBeRawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::crea te(position, EditingPropertiesInEffect); 988 RawPtr<EditingStyle> editingStyleAtPosition = EditingStyle::create(position, EditingPropertiesInEffect);
993 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g et(); 989 StylePropertySet* styleAtPosition = editingStyleAtPosition->m_mutableStyle.g et();
994 990
995 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = nullptr; 991 RawPtr<CSSValue> unicodeBidi = nullptr;
996 RefPtrWillBeRawPtr<CSSValue> direction = nullptr; 992 RawPtr<CSSValue> direction = nullptr;
997 if (shouldPreserveWritingDirection == PreserveWritingDirection) { 993 if (shouldPreserveWritingDirection == PreserveWritingDirection) {
998 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi ); 994 unicodeBidi = m_mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi );
999 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection); 995 direction = m_mutableStyle->getPropertyCSSValue(CSSPropertyDirection);
1000 } 996 }
1001 997
1002 m_mutableStyle->removeEquivalentProperties(styleAtPosition); 998 m_mutableStyle->removeEquivalentProperties(styleAtPosition);
1003 999
1004 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin gStartAndEnd(styleAtPosition)) 1000 if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvin gStartAndEnd(styleAtPosition))
1005 m_mutableStyle->removeProperty(CSSPropertyTextAlign); 1001 m_mutableStyle->removeProperty(CSSPropertyTextAlign);
1006 1002
1007 if (getFontColor(m_mutableStyle.get()) == getFontColor(styleAtPosition)) 1003 if (getFontColor(m_mutableStyle.get()) == getFontColor(styleAtPosition))
1008 m_mutableStyle->removeProperty(CSSPropertyColor); 1004 m_mutableStyle->removeProperty(CSSPropertyColor);
1009 1005
1010 if (hasTransparentBackgroundColor(m_mutableStyle.get()) 1006 if (hasTransparentBackgroundColor(m_mutableStyle.get())
1011 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgr oundColor).get()) == backgroundColorInEffect(position.computeContainerNode())) 1007 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgr oundColor).get()) == backgroundColorInEffect(position.computeContainerNode()))
1012 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); 1008 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor);
1013 1009
1014 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) { 1010 if (unicodeBidi && unicodeBidi->isPrimitiveValue()) {
1015 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue( unicodeBidi.get())->getValueID()); 1011 m_mutableStyle->setProperty(CSSPropertyUnicodeBidi, toCSSPrimitiveValue( unicodeBidi.get())->getValueID());
1016 if (direction && direction->isPrimitiveValue()) 1012 if (direction && direction->isPrimitiveValue())
1017 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu e(direction.get())->getValueID()); 1013 m_mutableStyle->setProperty(CSSPropertyDirection, toCSSPrimitiveValu e(direction.get())->getValueID());
1018 } 1014 }
1019 } 1015 }
1020 1016
1021 void EditingStyle::mergeTypingStyle(Document* document) 1017 void EditingStyle::mergeTypingStyle(Document* document)
1022 { 1018 {
1023 ASSERT(document); 1019 ASSERT(document);
1024 1020
1025 RefPtrWillBeRawPtr<EditingStyle> typingStyle = document->frame()->selection( ).typingStyle(); 1021 RawPtr<EditingStyle> typingStyle = document->frame()->selection().typingStyl e();
1026 if (!typingStyle || typingStyle == this) 1022 if (!typingStyle || typingStyle == this)
1027 return; 1023 return;
1028 1024
1029 mergeStyle(typingStyle->style(), OverrideValues); 1025 mergeStyle(typingStyle->style(), OverrideValues);
1030 } 1026 }
1031 1027
1032 void EditingStyle::mergeInlineStyleOfElement(HTMLElement* element, CSSPropertyOv errideMode mode, PropertiesToInclude propertiesToInclude) 1028 void EditingStyle::mergeInlineStyleOfElement(HTMLElement* element, CSSPropertyOv errideMode mode, PropertiesToInclude propertiesToInclude)
1033 { 1029 {
1034 ASSERT(element); 1030 ASSERT(element);
1035 if (!element->inlineStyle()) 1031 if (!element->inlineStyle())
(...skipping 12 matching lines...) Expand all
1048 } 1044 }
1049 } 1045 }
1050 1046
1051 static inline bool elementMatchesAndPropertyIsNotInInlineStyleDecl(const HTMLEle mentEquivalent* equivalent, const Element* element, 1047 static inline bool elementMatchesAndPropertyIsNotInInlineStyleDecl(const HTMLEle mentEquivalent* equivalent, const Element* element,
1052 EditingStyle::CSSPropertyOverrideMode mode, StylePropertySet* style) 1048 EditingStyle::CSSPropertyOverrideMode mode, StylePropertySet* style)
1053 { 1049 {
1054 return equivalent->matches(element) && (!element->inlineStyle() || !equivale nt->propertyExistsInStyle(element->inlineStyle())) 1050 return equivalent->matches(element) && (!element->inlineStyle() || !equivale nt->propertyExistsInStyle(element->inlineStyle()))
1055 && (mode == EditingStyle::OverrideValues || !equivalent->propertyExistsI nStyle(style)); 1051 && (mode == EditingStyle::OverrideValues || !equivalent->propertyExistsI nStyle(style));
1056 } 1052 }
1057 1053
1058 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> extractEditingProperties( const StylePropertySet* style, EditingStyle::PropertiesToInclude propertiesToInc lude) 1054 static RawPtr<MutableStylePropertySet> extractEditingProperties(const StylePrope rtySet* style, EditingStyle::PropertiesToInclude propertiesToInclude)
1059 { 1055 {
1060 if (!style) 1056 if (!style)
1061 return nullptr; 1057 return nullptr;
1062 1058
1063 switch (propertiesToInclude) { 1059 switch (propertiesToInclude) {
1064 case EditingStyle::AllProperties: 1060 case EditingStyle::AllProperties:
1065 case EditingStyle::EditingPropertiesInEffect: 1061 case EditingStyle::EditingPropertiesInEffect:
1066 return copyEditingProperties(style, AllEditingProperties); 1062 return copyEditingProperties(style, AllEditingProperties);
1067 case EditingStyle::OnlyEditingInheritableProperties: 1063 case EditingStyle::OnlyEditingInheritableProperties:
1068 return copyEditingProperties(style, OnlyInheritableEditingProperties); 1064 return copyEditingProperties(style, OnlyInheritableEditingProperties);
1069 } 1065 }
1070 1066
1071 ASSERT_NOT_REACHED(); 1067 ASSERT_NOT_REACHED();
1072 return nullptr; 1068 return nullptr;
1073 } 1069 }
1074 1070
1075 void EditingStyle::mergeInlineAndImplicitStyleOfElement(Element* element, CSSPro pertyOverrideMode mode, PropertiesToInclude propertiesToInclude) 1071 void EditingStyle::mergeInlineAndImplicitStyleOfElement(Element* element, CSSPro pertyOverrideMode mode, PropertiesToInclude propertiesToInclude)
1076 { 1072 {
1077 RefPtrWillBeRawPtr<EditingStyle> styleFromRules = EditingStyle::create(); 1073 RawPtr<EditingStyle> styleFromRules = EditingStyle::create();
1078 styleFromRules->mergeStyleFromRulesForSerialization(element); 1074 styleFromRules->mergeStyleFromRulesForSerialization(element);
1079 1075
1080 if (element->inlineStyle()) 1076 if (element->inlineStyle())
1081 styleFromRules->m_mutableStyle->mergeAndOverrideOnConflict(element->inli neStyle()); 1077 styleFromRules->m_mutableStyle->mergeAndOverrideOnConflict(element->inli neStyle());
1082 1078
1083 styleFromRules->m_mutableStyle = extractEditingProperties(styleFromRules->m_ mutableStyle.get(), propertiesToInclude); 1079 styleFromRules->m_mutableStyle = extractEditingProperties(styleFromRules->m_ mutableStyle.get(), propertiesToInclude);
1084 mergeStyle(styleFromRules->m_mutableStyle.get(), mode); 1080 mergeStyle(styleFromRules->m_mutableStyle.get(), mode);
1085 1081
1086 const WillBeHeapVector<OwnPtrWillBeMember<HTMLElementEquivalent>>& elementEq uivalents = htmlElementEquivalents(); 1082 const HeapVector<Member<HTMLElementEquivalent>>& elementEquivalents = htmlEl ementEquivalents();
1087 for (const auto& equivalent : elementEquivalents) { 1083 for (const auto& equivalent : elementEquivalents) {
1088 if (elementMatchesAndPropertyIsNotInInlineStyleDecl(equivalent.get(), el ement, mode, m_mutableStyle.get())) 1084 if (elementMatchesAndPropertyIsNotInInlineStyleDecl(equivalent.get(), el ement, mode, m_mutableStyle.get()))
1089 equivalent->addToStyle(element, this); 1085 equivalent->addToStyle(element, this);
1090 } 1086 }
1091 1087
1092 const WillBeHeapVector<OwnPtrWillBeMember<HTMLAttributeEquivalent>>& attribu teEquivalents = htmlAttributeEquivalents(); 1088 const HeapVector<Member<HTMLAttributeEquivalent>>& attributeEquivalents = ht mlAttributeEquivalents();
1093 for (const auto& attribute : attributeEquivalents) { 1089 for (const auto& attribute : attributeEquivalents) {
1094 if (attribute->attributeName() == HTMLNames::dirAttr) 1090 if (attribute->attributeName() == HTMLNames::dirAttr)
1095 continue; // We don't want to include directionality 1091 continue; // We don't want to include directionality
1096 if (elementMatchesAndPropertyIsNotInInlineStyleDecl(attribute.get(), ele ment, mode, m_mutableStyle.get())) 1092 if (elementMatchesAndPropertyIsNotInInlineStyleDecl(attribute.get(), ele ment, mode, m_mutableStyle.get()))
1097 attribute->addToStyle(element, this); 1093 attribute->addToStyle(element, this);
1098 } 1094 }
1099 } 1095 }
1100 1096
1101 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::wrappingStyleForAnnotatedSeri alization(ContainerNode* context) 1097 RawPtr<EditingStyle> EditingStyle::wrappingStyleForAnnotatedSerialization(Contai nerNode* context)
1102 { 1098 {
1103 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::create(contex t, EditingStyle::EditingPropertiesInEffect); 1099 RawPtr<EditingStyle> wrappingStyle = EditingStyle::create(context, EditingSt yle::EditingPropertiesInEffect);
1104 1100
1105 // Styles that Mail blockquotes contribute should only be placed on the Mail 1101 // Styles that Mail blockquotes contribute should only be placed on the Mail
1106 // blockquote, to help us differentiate those styles from ones that the user 1102 // blockquote, to help us differentiate those styles from ones that the user
1107 // has applied. This helps us get the color of content pasted into 1103 // has applied. This helps us get the color of content pasted into
1108 // blockquotes right. 1104 // blockquotes right.
1109 wrappingStyle->removeStyleAddedByElement(toHTMLElement(enclosingNodeOfType(f irstPositionInOrBeforeNode(context), isMailHTMLBlockquoteElement, CanCrossEditin gBoundary))); 1105 wrappingStyle->removeStyleAddedByElement(toHTMLElement(enclosingNodeOfType(f irstPositionInOrBeforeNode(context), isMailHTMLBlockquoteElement, CanCrossEditin gBoundary)));
1110 1106
1111 // Call collapseTextDecorationProperties first or otherwise it'll copy the v alue over from in-effect to text-decorations. 1107 // Call collapseTextDecorationProperties first or otherwise it'll copy the v alue over from in-effect to text-decorations.
1112 wrappingStyle->collapseTextDecorationProperties(); 1108 wrappingStyle->collapseTextDecorationProperties();
1113 1109
1114 return wrappingStyle.release(); 1110 return wrappingStyle.release();
1115 } 1111 }
1116 1112
1117 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization (ContainerNode* context) 1113 RawPtr<EditingStyle> EditingStyle::wrappingStyleForSerialization(ContainerNode* context)
1118 { 1114 {
1119 RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::create(); 1115 RawPtr<EditingStyle> wrappingStyle = EditingStyle::create();
1120 1116
1121 // When not annotating for interchange, we only preserve inline style declar ations. 1117 // When not annotating for interchange, we only preserve inline style declar ations.
1122 for (ContainerNode* node = context; node && !node->isDocumentNode(); node = node->parentNode()) { 1118 for (ContainerNode* node = context; node && !node->isDocumentNode(); node = node->parentNode()) {
1123 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) { 1119 if (node->isStyledElement() && !isMailHTMLBlockquoteElement(node)) {
1124 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues, 1120 wrappingStyle->mergeInlineAndImplicitStyleOfElement(toElement(node), EditingStyle::DoNotOverrideValues,
1125 EditingStyle::EditingPropertiesInEffect); 1121 EditingStyle::EditingPropertiesInEffect);
1126 } 1122 }
1127 } 1123 }
1128 1124
1129 return wrappingStyle.release(); 1125 return wrappingStyle.release();
(...skipping 16 matching lines...) Expand all
1146 return; 1142 return;
1147 1143
1148 if (!m_mutableStyle) { 1144 if (!m_mutableStyle) {
1149 m_mutableStyle = style->mutableCopy(); 1145 m_mutableStyle = style->mutableCopy();
1150 return; 1146 return;
1151 } 1147 }
1152 1148
1153 unsigned propertyCount = style->propertyCount(); 1149 unsigned propertyCount = style->propertyCount();
1154 for (unsigned i = 0; i < propertyCount; ++i) { 1150 for (unsigned i = 0; i < propertyCount; ++i) {
1155 StylePropertySet::PropertyReference property = style->propertyAt(i); 1151 StylePropertySet::PropertyReference property = style->propertyAt(i);
1156 RefPtrWillBeRawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue (property.id()); 1152 RawPtr<CSSValue> value = m_mutableStyle->getPropertyCSSValue(property.id ());
1157 1153
1158 // text decorations never override values 1154 // text decorations never override values
1159 if ((property.id() == textDecorationPropertyForEditing() || property.id( ) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList( ) && value) { 1155 if ((property.id() == textDecorationPropertyForEditing() || property.id( ) == CSSPropertyWebkitTextDecorationsInEffect) && property.value()->isValueList( ) && value) {
1160 if (value->isValueList()) { 1156 if (value->isValueList()) {
1161 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu eList(property.value())); 1157 mergeTextDecorationValues(toCSSValueList(value.get()), toCSSValu eList(property.value()));
1162 continue; 1158 continue;
1163 } 1159 }
1164 value = nullptr; // text-decoration: none is equivalent to not havin g the property 1160 value = nullptr; // text-decoration: none is equivalent to not havin g the property
1165 } 1161 }
1166 1162
1167 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value)) 1163 if (mode == OverrideValues || (mode == DoNotOverrideValues && !value))
1168 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant()); 1164 m_mutableStyle->setProperty(property.id(), property.value()->cssText (), property.isImportant());
1169 } 1165 }
1170 } 1166 }
1171 1167
1172 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> styleFromMatchedRulesForE lement(Element* element, unsigned rulesToInclude) 1168 static RawPtr<MutableStylePropertySet> styleFromMatchedRulesForElement(Element* element, unsigned rulesToInclude)
1173 { 1169 {
1174 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create(HTMLQuirksMode); 1170 RawPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(HTML QuirksMode);
1175 RefPtrWillBeRawPtr<StyleRuleList> matchedRules = element->document().ensureS tyleResolver().styleRulesForElement(element, rulesToInclude); 1171 RawPtr<StyleRuleList> matchedRules = element->document().ensureStyleResolver ().styleRulesForElement(element, rulesToInclude);
1176 if (matchedRules) { 1172 if (matchedRules) {
1177 for (unsigned i = 0; i < matchedRules->size(); ++i) 1173 for (unsigned i = 0; i < matchedRules->size(); ++i)
1178 style->mergeAndOverrideOnConflict(&matchedRules->at(i)->properties() ); 1174 style->mergeAndOverrideOnConflict(&matchedRules->at(i)->properties() );
1179 } 1175 }
1180 return style.release(); 1176 return style.release();
1181 } 1177 }
1182 1178
1183 void EditingStyle::mergeStyleFromRules(Element* element) 1179 void EditingStyle::mergeStyleFromRules(Element* element)
1184 { 1180 {
1185 RefPtrWillBeRawPtr<MutableStylePropertySet> styleFromMatchedRules = styleFro mMatchedRulesForElement(element, 1181 RawPtr<MutableStylePropertySet> styleFromMatchedRules = styleFromMatchedRule sForElement(element,
1186 StyleResolver::AuthorCSSRules | StyleResolver::CrossOriginCSSRules); 1182 StyleResolver::AuthorCSSRules | StyleResolver::CrossOriginCSSRules);
1187 // Styles from the inline style declaration, held in the variable "style", t ake precedence 1183 // Styles from the inline style declaration, held in the variable "style", t ake precedence
1188 // over those from matched rules. 1184 // over those from matched rules.
1189 if (m_mutableStyle) 1185 if (m_mutableStyle)
1190 styleFromMatchedRules->mergeAndOverrideOnConflict(m_mutableStyle.get()); 1186 styleFromMatchedRules->mergeAndOverrideOnConflict(m_mutableStyle.get());
1191 1187
1192 clear(); 1188 clear();
1193 m_mutableStyle = styleFromMatchedRules; 1189 m_mutableStyle = styleFromMatchedRules;
1194 } 1190 }
1195 1191
1196 void EditingStyle::mergeStyleFromRulesForSerialization(Element* element) 1192 void EditingStyle::mergeStyleFromRulesForSerialization(Element* element)
1197 { 1193 {
1198 mergeStyleFromRules(element); 1194 mergeStyleFromRules(element);
1199 1195
1200 // The property value, if it's a percentage, may not reflect the actual comp uted value. 1196 // The property value, if it's a percentage, may not reflect the actual comp uted value.
1201 // For example: style="height: 1%; overflow: visible;" in quirksmode 1197 // For example: style="height: 1%; overflow: visible;" in quirksmode
1202 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot copy/paste fidelity problem 1198 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot copy/paste fidelity problem
1203 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS SComputedStyleDeclaration::create(element); 1199 RawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CSSComputedSty leDeclaration::create(element);
1204 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle PropertySet::create(HTMLQuirksMode); 1200 RawPtr<MutableStylePropertySet> fromComputedStyle = MutableStylePropertySet: :create(HTMLQuirksMode);
1205 { 1201 {
1206 unsigned propertyCount = m_mutableStyle->propertyCount(); 1202 unsigned propertyCount = m_mutableStyle->propertyCount();
1207 for (unsigned i = 0; i < propertyCount; ++i) { 1203 for (unsigned i = 0; i < propertyCount; ++i) {
1208 StylePropertySet::PropertyReference property = m_mutableStyle->prope rtyAt(i); 1204 StylePropertySet::PropertyReference property = m_mutableStyle->prope rtyAt(i);
1209 CSSValue* value = property.value(); 1205 CSSValue* value = property.value();
1210 if (!value->isPrimitiveValue()) 1206 if (!value->isPrimitiveValue())
1211 continue; 1207 continue;
1212 if (toCSSPrimitiveValue(value)->isPercentage()) { 1208 if (toCSSPrimitiveValue(value)->isPercentage()) {
1213 if (RefPtrWillBeRawPtr<CSSValue> computedPropertyValue = compute dStyleForElement->getPropertyCSSValue(property.id())) 1209 if (RawPtr<CSSValue> computedPropertyValue = computedStyleForEle ment->getPropertyCSSValue(property.id()))
1214 fromComputedStyle->addRespectingCascade(CSSProperty(property .id(), computedPropertyValue)); 1210 fromComputedStyle->addRespectingCascade(CSSProperty(property .id(), computedPropertyValue));
1215 } 1211 }
1216 } 1212 }
1217 } 1213 }
1218 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); 1214 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get());
1219 } 1215 }
1220 1216
1221 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper tiesFrom, StylePropertySet* style) 1217 static void removePropertiesInStyle(MutableStylePropertySet* styleToRemoveProper tiesFrom, StylePropertySet* style)
1222 { 1218 {
1223 unsigned propertyCount = style->propertyCount(); 1219 unsigned propertyCount = style->propertyCount();
1224 Vector<CSSPropertyID> propertiesToRemove(propertyCount); 1220 Vector<CSSPropertyID> propertiesToRemove(propertyCount);
1225 for (unsigned i = 0; i < propertyCount; ++i) 1221 for (unsigned i = 0; i < propertyCount; ++i)
1226 propertiesToRemove[i] = style->propertyAt(i).id(); 1222 propertiesToRemove[i] = style->propertyAt(i).id();
1227 1223
1228 styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data() , propertiesToRemove.size()); 1224 styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data() , propertiesToRemove.size());
1229 } 1225 }
1230 1226
1231 void EditingStyle::removeStyleFromRulesAndContext(Element* element, ContainerNod e* context) 1227 void EditingStyle::removeStyleFromRulesAndContext(Element* element, ContainerNod e* context)
1232 { 1228 {
1233 ASSERT(element); 1229 ASSERT(element);
1234 if (!m_mutableStyle) 1230 if (!m_mutableStyle)
1235 return; 1231 return;
1236 1232
1237 // 1. Remove style from matched rules because style remain without repeating it in inline style declaration 1233 // 1. Remove style from matched rules because style remain without repeating it in inline style declaration
1238 RefPtrWillBeRawPtr<MutableStylePropertySet> styleFromMatchedRules = styleFro mMatchedRulesForElement(element, StyleResolver::AllButEmptyCSSRules); 1234 RawPtr<MutableStylePropertySet> styleFromMatchedRules = styleFromMatchedRule sForElement(element, StyleResolver::AllButEmptyCSSRules);
1239 if (styleFromMatchedRules && !styleFromMatchedRules->isEmpty()) 1235 if (styleFromMatchedRules && !styleFromMatchedRules->isEmpty())
1240 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatch edRules->ensureCSSStyleDeclaration()); 1236 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), styleFromMatch edRules->ensureCSSStyleDeclaration());
1241 1237
1242 // 2. Remove style present in context and not overriden by matched rules. 1238 // 2. Remove style present in context and not overriden by matched rules.
1243 RefPtrWillBeRawPtr<EditingStyle> computedStyle = EditingStyle::create(contex t, EditingPropertiesInEffect); 1239 RawPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingPr opertiesInEffect);
1244 if (computedStyle->m_mutableStyle) { 1240 if (computedStyle->m_mutableStyle) {
1245 if (!computedStyle->m_mutableStyle->getPropertyCSSValue(CSSPropertyBackg roundColor)) 1241 if (!computedStyle->m_mutableStyle->getPropertyCSSValue(CSSPropertyBackg roundColor))
1246 computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColo r, CSSValueTransparent); 1242 computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColo r, CSSValueTransparent);
1247 1243
1248 removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMa tchedRules.get()); 1244 removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMa tchedRules.get());
1249 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), computedStyle- >m_mutableStyle->ensureCSSStyleDeclaration()); 1245 m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), computedStyle- >m_mutableStyle->ensureCSSStyleDeclaration());
1250 } 1246 }
1251 1247
1252 // 3. If this element is a span and has display: inline or float: none, remo ve them unless they are overriden by rules. 1248 // 3. If this element is a span and has display: inline or float: none, remo ve them unless they are overriden by rules.
1253 // These rules are added by serialization code to wrap text nodes. 1249 // These rules are added by serialization code to wrap text nodes.
1254 if (isStyleSpanOrSpanWithOnlyStyleAttribute(element)) { 1250 if (isStyleSpanOrSpanWithOnlyStyleAttribute(element)) {
1255 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyDisplay) && g etIdentifierValue(m_mutableStyle.get(), CSSPropertyDisplay) == CSSValueInline) 1251 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyDisplay) && g etIdentifierValue(m_mutableStyle.get(), CSSPropertyDisplay) == CSSValueInline)
1256 m_mutableStyle->removeProperty(CSSPropertyDisplay); 1252 m_mutableStyle->removeProperty(CSSPropertyDisplay);
1257 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyFloat) && get IdentifierValue(m_mutableStyle.get(), CSSPropertyFloat) == CSSValueNone) 1253 if (!styleFromMatchedRules->getPropertyCSSValue(CSSPropertyFloat) && get IdentifierValue(m_mutableStyle.get(), CSSPropertyFloat) == CSSValueNone)
1258 m_mutableStyle->removeProperty(CSSPropertyFloat); 1254 m_mutableStyle->removeProperty(CSSPropertyFloat);
1259 } 1255 }
1260 } 1256 }
1261 1257
1262 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) 1258 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element)
1263 { 1259 {
1264 if (!m_mutableStyle || m_mutableStyle->isEmpty()) 1260 if (!m_mutableStyle || m_mutableStyle->isEmpty())
1265 return; 1261 return;
1266 1262
1267 RefPtrWillBeRawPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesFor Element(element, StyleResolver::UAAndUserCSSRules); 1263 RawPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesForElement(elem ent, StyleResolver::UAAndUserCSSRules);
1268 1264
1269 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); 1265 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get());
1270 } 1266 }
1271 1267
1272 void EditingStyle::addAbsolutePositioningFromElement(const Element& element) 1268 void EditingStyle::addAbsolutePositioningFromElement(const Element& element)
1273 { 1269 {
1274 LayoutRect rect = element.boundingBox(); 1270 LayoutRect rect = element.boundingBox();
1275 LayoutObject* layoutObject = element.layoutObject(); 1271 LayoutObject* layoutObject = element.layoutObject();
1276 1272
1277 LayoutUnit x = rect.x(); 1273 LayoutUnit x = rect.x();
(...skipping 19 matching lines...) Expand all
1297 void EditingStyle::forceInline() 1293 void EditingStyle::forceInline()
1298 { 1294 {
1299 if (!m_mutableStyle) 1295 if (!m_mutableStyle)
1300 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode); 1296 m_mutableStyle = MutableStylePropertySet::create(HTMLQuirksMode);
1301 const bool propertyIsImportant = true; 1297 const bool propertyIsImportant = true;
1302 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant); 1298 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant);
1303 } 1299 }
1304 1300
1305 int EditingStyle::legacyFontSize(Document* document) const 1301 int EditingStyle::legacyFontSize(Document* document) const
1306 { 1302 {
1307 RefPtrWillBeRawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue( CSSPropertyFontSize); 1303 RawPtr<CSSValue> cssValue = m_mutableStyle->getPropertyCSSValue(CSSPropertyF ontSize);
1308 if (!cssValue || !cssValue->isPrimitiveValue()) 1304 if (!cssValue || !cssValue->isPrimitiveValue())
1309 return 0; 1305 return 0;
1310 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get ()), 1306 return legacyFontSizeFromCSSValue(document, toCSSPrimitiveValue(cssValue.get ()),
1311 m_isMonospaceFont, AlwaysUseLegacyFontSize); 1307 m_isMonospaceFont, AlwaysUseLegacyFontSize);
1312 } 1308 }
1313 1309
1314 PassRefPtrWillBeRawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const V isibleSelection& selection, bool shouldUseBackgroundColorInEffect) 1310 RawPtr<EditingStyle> EditingStyle::styleAtSelectionStart(const VisibleSelection& selection, bool shouldUseBackgroundColorInEffect)
1315 { 1311 {
1316 if (selection.isNone()) 1312 if (selection.isNone())
1317 return nullptr; 1313 return nullptr;
1318 1314
1319 Position position = adjustedSelectionStartForStyleComputation(selection); 1315 Position position = adjustedSelectionStartForStyleComputation(selection);
1320 1316
1321 // If the pos is at the end of a text node, then this node is not fully sele cted. 1317 // If the pos is at the end of a text node, then this node is not fully sele cted.
1322 // Move it to the next deep equivalent position to avoid removing the style from this node. 1318 // Move it to the next deep equivalent position to avoid removing the style from this node.
1323 // e.g. if pos was at Position("hello", 5) in <b>hello<div>world</div></b>, we want Position("world", 0) instead. 1319 // e.g. if pos was at Position("hello", 5) in <b>hello<div>world</div></b>, we want Position("world", 0) instead.
1324 // We only do this for range because caret at Position("hello", 5) in <b>hel lo</b>world should give you font-weight: bold. 1320 // We only do this for range because caret at Position("hello", 5) in <b>hel lo</b>world should give you font-weight: bold.
1325 Node* positionNode = position.computeContainerNode(); 1321 Node* positionNode = position.computeContainerNode();
1326 if (selection.isRange() && positionNode && positionNode->isTextNode() && pos ition.computeOffsetInContainerNode() == positionNode->maxCharacterOffset()) 1322 if (selection.isRange() && positionNode && positionNode->isTextNode() && pos ition.computeOffsetInContainerNode() == positionNode->maxCharacterOffset())
1327 position = nextVisuallyDistinctCandidate(position); 1323 position = nextVisuallyDistinctCandidate(position);
1328 1324
1329 Element* element = associatedElementOf(position); 1325 Element* element = associatedElementOf(position);
1330 if (!element) 1326 if (!element)
1331 return nullptr; 1327 return nullptr;
1332 1328
1333 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(element, Editi ngStyle::AllProperties); 1329 RawPtr<EditingStyle> style = EditingStyle::create(element, EditingStyle::All Properties);
1334 style->mergeTypingStyle(&element->document()); 1330 style->mergeTypingStyle(&element->document());
1335 1331
1336 // If background color is transparent, traverse parent nodes until we hit a different value or document root 1332 // If background color is transparent, traverse parent nodes until we hit a different value or document root
1337 // Also, if the selection is a range, ignore the background color at the sta rt of selection, 1333 // Also, if the selection is a range, ignore the background color at the sta rt of selection,
1338 // and find the background color of the common ancestor. 1334 // and find the background color of the common ancestor.
1339 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare ntBackgroundColor(style->m_mutableStyle.get()))) { 1335 if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTranspare ntBackgroundColor(style->m_mutableStyle.get()))) {
1340 const EphemeralRange range(selection.toNormalizedEphemeralRange()); 1336 const EphemeralRange range(selection.toNormalizedEphemeralRange());
1341 if (PassRefPtrWillBeRawPtr<CSSValue> value = backgroundColorValueInEffec t(Range::commonAncestorContainer(range.startPosition().computeContainerNode(), r ange.endPosition().computeContainerNode()))) 1337 if (RawPtr<CSSValue> value = backgroundColorValueInEffect(Range::commonA ncestorContainer(range.startPosition().computeContainerNode(), range.endPosition ().computeContainerNode())))
1342 style->setProperty(CSSPropertyBackgroundColor, value->cssText()); 1338 style->setProperty(CSSPropertyBackgroundColor, value->cssText());
1343 } 1339 }
1344 1340
1345 return style; 1341 return style;
1346 } 1342 }
1347 1343
1348 static bool isUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID valueID) 1344 static bool isUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID valueID)
1349 { 1345 {
1350 return valueID == CSSValueEmbed || valueID == CSSValueBidiOverride 1346 return valueID == CSSValueEmbed || valueID == CSSValueBidiOverride
1351 || valueID == CSSValueWebkitIsolate || valueID == CSSValueWebkitIsolateO verride || valueID == CSSValueWebkitPlaintext 1347 || valueID == CSSValueWebkitIsolate || valueID == CSSValueWebkitIsolateO verride || valueID == CSSValueWebkitPlaintext
(...skipping 16 matching lines...) Expand all
1368 Position end; 1364 Position end;
1369 if (selection.isRange()) { 1365 if (selection.isRange()) {
1370 end = mostBackwardCaretPosition(selection.end()); 1366 end = mostBackwardCaretPosition(selection.end());
1371 1367
1372 ASSERT(end.document()); 1368 ASSERT(end.document());
1373 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE quivalent(), end.parentAnchoredEquivalent())->pastLastNode(); 1369 Node* pastLast = Range::create(*end.document(), position.parentAnchoredE quivalent(), end.parentAnchoredEquivalent())->pastLastNode();
1374 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) { 1370 for (Node* n = node; n && n != pastLast; n = NodeTraversal::next(*n)) {
1375 if (!n->isStyledElement()) 1371 if (!n->isStyledElement())
1376 continue; 1372 continue;
1377 1373
1378 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedS tyleDeclaration::create(n); 1374 RawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclarat ion::create(n);
1379 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValu e(CSSPropertyUnicodeBidi); 1375 RawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropert yUnicodeBidi);
1380 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1376 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1381 continue; 1377 continue;
1382 1378
1383 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get()) ->getValueID(); 1379 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get()) ->getValueID();
1384 if (isUnicodeBidiNestedOrMultipleEmbeddings(unicodeBidiValue)) 1380 if (isUnicodeBidiNestedOrMultipleEmbeddings(unicodeBidiValue))
1385 return NaturalWritingDirection; 1381 return NaturalWritingDirection;
1386 } 1382 }
1387 } 1383 }
1388 1384
1389 if (selection.isCaret()) { 1385 if (selection.isCaret()) {
1390 WritingDirection direction; 1386 WritingDirection direction;
1391 if (typingStyle && typingStyle->textDirection(direction)) { 1387 if (typingStyle && typingStyle->textDirection(direction)) {
1392 hasNestedOrMultipleEmbeddings = false; 1388 hasNestedOrMultipleEmbeddings = false;
1393 return direction; 1389 return direction;
1394 } 1390 }
1395 node = selection.visibleStart().deepEquivalent().anchorNode(); 1391 node = selection.visibleStart().deepEquivalent().anchorNode();
1396 } 1392 }
1397 1393
1398 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position 1394 // The selection is either a caret with no typing attributes or a range in w hich no embedding is added, so just use the start position
1399 // to decide. 1395 // to decide.
1400 Node* block = enclosingBlock(node); 1396 Node* block = enclosingBlock(node);
1401 WritingDirection foundDirection = NaturalWritingDirection; 1397 WritingDirection foundDirection = NaturalWritingDirection;
1402 1398
1403 for (; node != block; node = node->parentNode()) { 1399 for (; node != block; node = node->parentNode()) {
1404 if (!node->isStyledElement()) 1400 if (!node->isStyledElement())
1405 continue; 1401 continue;
1406 1402
1407 Element* element = toElement(node); 1403 Element* element = toElement(node);
1408 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyle Declaration::create(element); 1404 RawPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration: :create(element);
1409 RefPtrWillBeRawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CS SPropertyUnicodeBidi); 1405 RawPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUni codeBidi);
1410 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1406 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue())
1411 continue; 1407 continue;
1412 1408
1413 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge tValueID(); 1409 CSSValueID unicodeBidiValue = toCSSPrimitiveValue(unicodeBidi.get())->ge tValueID();
1414 if (unicodeBidiValue == CSSValueNormal) 1410 if (unicodeBidiValue == CSSValueNormal)
1415 continue; 1411 continue;
1416 1412
1417 if (unicodeBidiValue == CSSValueBidiOverride) 1413 if (unicodeBidiValue == CSSValueBidiOverride)
1418 return NaturalWritingDirection; 1414 return NaturalWritingDirection;
1419 1415
1420 ASSERT(isEmbedOrIsolate(unicodeBidiValue)); 1416 ASSERT(isEmbedOrIsolate(unicodeBidiValue));
1421 RefPtrWillBeRawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSP ropertyDirection); 1417 RawPtr<CSSValue> direction = style->getPropertyCSSValue(CSSPropertyDirec tion);
1422 if (!direction || !direction->isPrimitiveValue()) 1418 if (!direction || !direction->isPrimitiveValue())
1423 continue; 1419 continue;
1424 1420
1425 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID(); 1421 int directionValue = toCSSPrimitiveValue(direction.get())->getValueID();
1426 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl) 1422 if (directionValue != CSSValueLtr && directionValue != CSSValueRtl)
1427 continue; 1423 continue;
1428 1424
1429 if (foundDirection != NaturalWritingDirection) 1425 if (foundDirection != NaturalWritingDirection)
1430 return NaturalWritingDirection; 1426 return NaturalWritingDirection;
1431 1427
1432 // In the range case, make sure that the embedding element persists unti l the end of the range. 1428 // In the range case, make sure that the embedding element persists unti l the end of the range.
1433 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element)) 1429 if (selection.isRange() && !end.anchorNode()->isDescendantOf(element))
1434 return NaturalWritingDirection; 1430 return NaturalWritingDirection;
1435 1431
1436 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection; 1432 foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirec tion : RightToLeftWritingDirection;
1437 } 1433 }
1438 hasNestedOrMultipleEmbeddings = false; 1434 hasNestedOrMultipleEmbeddings = false;
1439 return foundDirection; 1435 return foundDirection;
1440 } 1436 }
1441 1437
1442 DEFINE_TRACE(EditingStyle) 1438 DEFINE_TRACE(EditingStyle)
1443 { 1439 {
1444 visitor->trace(m_mutableStyle); 1440 visitor->trace(m_mutableStyle);
1445 } 1441 }
1446 1442
1447 static void reconcileTextDecorationProperties(MutableStylePropertySet* style) 1443 static void reconcileTextDecorationProperties(MutableStylePropertySet* style)
1448 { 1444 {
1449 RefPtrWillBeRawPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSS Value(CSSPropertyWebkitTextDecorationsInEffect); 1445 RawPtr<CSSValue> textDecorationsInEffect = style->getPropertyCSSValue(CSSPro pertyWebkitTextDecorationsInEffect);
1450 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex tDecorationPropertyForEditing()); 1446 RawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP ropertyForEditing());
1451 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense. 1447 // We shouldn't have both text-decoration and -webkit-text-decorations-in-ef fect because that wouldn't make sense.
1452 ASSERT(!textDecorationsInEffect || !textDecoration); 1448 ASSERT(!textDecorationsInEffect || !textDecoration);
1453 if (textDecorationsInEffect) { 1449 if (textDecorationsInEffect) {
1454 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn Effect->cssText()); 1450 style->setProperty(textDecorationPropertyForEditing(), textDecorationsIn Effect->cssText());
1455 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect); 1451 style->removeProperty(CSSPropertyWebkitTextDecorationsInEffect);
1456 textDecoration = textDecorationsInEffect; 1452 textDecoration = textDecorationsInEffect;
1457 } 1453 }
1458 1454
1459 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none". 1455 // If text-decoration is set to "none", remove the property because we don't want to add redundant "text-decoration: none".
1460 if (textDecoration && !textDecoration->isValueList()) 1456 if (textDecoration && !textDecoration->isValueList())
1461 style->removeProperty(textDecorationPropertyForEditing()); 1457 style->removeProperty(textDecorationPropertyForEditing());
1462 } 1458 }
1463 1459
1464 StyleChange::StyleChange(EditingStyle* style, const Position& position) 1460 StyleChange::StyleChange(EditingStyle* style, const Position& position)
1465 : m_applyBold(false) 1461 : m_applyBold(false)
1466 , m_applyItalic(false) 1462 , m_applyItalic(false)
1467 , m_applyUnderline(false) 1463 , m_applyUnderline(false)
1468 , m_applyLineThrough(false) 1464 , m_applyLineThrough(false)
1469 , m_applySubscript(false) 1465 , m_applySubscript(false)
1470 , m_applySuperscript(false) 1466 , m_applySuperscript(false)
1471 { 1467 {
1472 Document* document = position.document(); 1468 Document* document = position.document();
1473 if (!style || !style->style() || !document || !document->frame() || !associa tedElementOf(position)) 1469 if (!style || !style->style() || !document || !document->frame() || !associa tedElementOf(position))
1474 return; 1470 return;
1475 1471
1476 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyle = ensureComput edStyle(position); 1472 RawPtr<CSSComputedStyleDeclaration> computedStyle = ensureComputedStyle(posi tion);
1477 // FIXME: take care of background-color in effect 1473 // FIXME: take care of background-color in effect
1478 RefPtrWillBeRawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotI n(style->style(), computedStyle.get()); 1474 RawPtr<MutableStylePropertySet> mutableStyle = getPropertiesNotIn(style->sty le(), computedStyle.get());
1479 ASSERT(mutableStyle); 1475 ASSERT(mutableStyle);
1480 1476
1481 reconcileTextDecorationProperties(mutableStyle.get()); 1477 reconcileTextDecorationProperties(mutableStyle.get());
1482 if (!document->frame()->editor().shouldStyleWithCSS()) 1478 if (!document->frame()->editor().shouldStyleWithCSS())
1483 extractTextStyles(document, mutableStyle.get(), computedStyle->isMonospa ceFont()); 1479 extractTextStyles(document, mutableStyle.get(), computedStyle->isMonospa ceFont());
1484 1480
1485 // Changing the whitespace style in a tab span would collapse the tab into a space. 1481 // Changing the whitespace style in a tab span would collapse the tab into a space.
1486 if (isTabHTMLSpanElementTextNode(position.anchorNode()) || isTabHTMLSpanElem ent((position.anchorNode()))) 1482 if (isTabHTMLSpanElementTextNode(position.anchorNode()) || isTabHTMLSpanElem ent((position.anchorNode())))
1487 mutableStyle->removeProperty(CSSPropertyWhiteSpace); 1483 mutableStyle->removeProperty(CSSPropertyWhiteSpace);
1488 1484
(...skipping 27 matching lines...) Expand all
1516 } 1512 }
1517 1513
1518 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle); 1514 int fontStyle = getIdentifierValue(style, CSSPropertyFontStyle);
1519 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) { 1515 if (fontStyle == CSSValueItalic || fontStyle == CSSValueOblique) {
1520 style->removeProperty(CSSPropertyFontStyle); 1516 style->removeProperty(CSSPropertyFontStyle);
1521 m_applyItalic = true; 1517 m_applyItalic = true;
1522 } 1518 }
1523 1519
1524 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect 1520 // Assuming reconcileTextDecorationProperties has been called, there should not be -webkit-text-decorations-in-effect
1525 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList. 1521 // Furthermore, text-decoration: none has been trimmed so that text-decorati on property is always a CSSValueList.
1526 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(tex tDecorationPropertyForEditing()); 1522 RawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(textDecorationP ropertyForEditing());
1527 if (textDecoration && textDecoration->isValueList()) { 1523 if (textDecoration && textDecoration->isValueList()) {
1528 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP rimitiveValue::createIdentifier(CSSValueUnderline))); 1524 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, underline, (CSSP rimitiveValue::createIdentifier(CSSValueUnderline)));
1529 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS SPrimitiveValue::createIdentifier(CSSValueLineThrough))); 1525 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, lineThrough, (CS SPrimitiveValue::createIdentifier(CSSValueLineThrough)));
1530 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(text Decoration.get())->copy(); 1526 RawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.g et())->copy();
1531 if (newTextDecoration->removeAll(underline)) 1527 if (newTextDecoration->removeAll(underline))
1532 m_applyUnderline = true; 1528 m_applyUnderline = true;
1533 if (newTextDecoration->removeAll(lineThrough)) 1529 if (newTextDecoration->removeAll(lineThrough))
1534 m_applyLineThrough = true; 1530 m_applyLineThrough = true;
1535 1531
1536 // If trimTextDecorations, delete underline and line-through 1532 // If trimTextDecorations, delete underline and line-through
1537 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration PropertyForEditing()); 1533 setTextDecorationProperty(style, newTextDecoration.get(), textDecoration PropertyForEditing());
1538 } 1534 }
1539 1535
1540 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign); 1536 int verticalAlign = getIdentifierValue(style, CSSPropertyVerticalAlign);
(...skipping 11 matching lines...) Expand all
1552 if (style->getPropertyCSSValue(CSSPropertyColor)) { 1548 if (style->getPropertyCSSValue(CSSPropertyColor)) {
1553 m_applyFontColor = getFontColor(style).serialized(); 1549 m_applyFontColor = getFontColor(style).serialized();
1554 style->removeProperty(CSSPropertyColor); 1550 style->removeProperty(CSSPropertyColor);
1555 } 1551 }
1556 1552
1557 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily); 1553 m_applyFontFace = style->getPropertyValue(CSSPropertyFontFamily);
1558 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web kit.org/show_bug.cgi?id=79448 1554 // Remove single quotes for Outlook 2007 compatibility. See https://bugs.web kit.org/show_bug.cgi?id=79448
1559 m_applyFontFace.replaceWithLiteral('\'', ""); 1555 m_applyFontFace.replaceWithLiteral('\'', "");
1560 style->removeProperty(CSSPropertyFontFamily); 1556 style->removeProperty(CSSPropertyFontFamily);
1561 1557
1562 if (RefPtrWillBeRawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPr opertyFontSize)) { 1558 if (RawPtr<CSSValue> fontSize = style->getPropertyCSSValue(CSSPropertyFontSi ze)) {
1563 if (!fontSize->isPrimitiveValue()) { 1559 if (!fontSize->isPrimitiveValue()) {
1564 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t he number. Put no font size. 1560 style->removeProperty(CSSPropertyFontSize); // Can't make sense of t he number. Put no font size.
1565 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC SSPrimitiveValue(fontSize.get()), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelV aluesMatch)) { 1561 } else if (int legacyFontSize = legacyFontSizeFromCSSValue(document, toC SSPrimitiveValue(fontSize.get()), isMonospaceFont, UseLegacyFontSizeOnlyIfPixelV aluesMatch)) {
1566 m_applyFontSize = String::number(legacyFontSize); 1562 m_applyFontSize = String::number(legacyFontSize);
1567 style->removeProperty(CSSPropertyFontSize); 1563 style->removeProperty(CSSPropertyFontSize);
1568 } 1564 }
1569 } 1565 }
1570 } 1566 }
1571 1567
1572 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr opertID, CSSValue* refTextDecoration) 1568 static void diffTextDecorations(MutableStylePropertySet* style, CSSPropertyID pr opertID, CSSValue* refTextDecoration)
1573 { 1569 {
1574 RefPtrWillBeRawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(pro pertID); 1570 RawPtr<CSSValue> textDecoration = style->getPropertyCSSValue(propertID);
1575 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList()) 1571 if (!textDecoration || !textDecoration->isValueList() || !refTextDecoration || !refTextDecoration->isValueList())
1576 return; 1572 return;
1577 1573
1578 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco ration.get())->copy(); 1574 RawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDecoration.get() )->copy();
1579 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); 1575 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration);
1580 1576
1581 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) 1577 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++)
1582 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); 1578 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i));
1583 1579
1584 setTextDecorationProperty(style, newTextDecoration.get(), propertID); 1580 setTextDecorationProperty(style, newTextDecoration.get(), propertID);
1585 } 1581 }
1586 1582
1587 static bool fontWeightIsBold(CSSValue* fontWeight) 1583 static bool fontWeightIsBold(CSSValue* fontWeight)
1588 { 1584 {
(...skipping 26 matching lines...) Expand all
1615 1611
1616 static bool fontWeightNeedsResolving(CSSValue* fontWeight) 1612 static bool fontWeightNeedsResolving(CSSValue* fontWeight)
1617 { 1613 {
1618 if (!fontWeight->isPrimitiveValue()) 1614 if (!fontWeight->isPrimitiveValue())
1619 return true; 1615 return true;
1620 1616
1621 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID(); 1617 CSSValueID value = toCSSPrimitiveValue(fontWeight)->getValueID();
1622 return value == CSSValueLighter || value == CSSValueBolder; 1618 return value == CSSValueLighter || value == CSSValueBolder;
1623 } 1619 }
1624 1620
1625 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) 1621 RawPtr<MutableStylePropertySet> getPropertiesNotIn(StylePropertySet* styleWithRe dundantProperties, CSSStyleDeclaration* baseStyle)
1626 { 1622 {
1627 ASSERT(styleWithRedundantProperties); 1623 ASSERT(styleWithRedundantProperties);
1628 ASSERT(baseStyle); 1624 ASSERT(baseStyle);
1629 RefPtrWillBeRawPtr<MutableStylePropertySet> result = styleWithRedundantPrope rties->mutableCopy(); 1625 RawPtr<MutableStylePropertySet> result = styleWithRedundantProperties->mutab leCopy();
1630 1626
1631 result->removeEquivalentProperties(baseStyle); 1627 result->removeEquivalentProperties(baseStyle);
1632 1628
1633 RefPtrWillBeRawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPro pertyCSSValueInternal(CSSPropertyWebkitTextDecorationsInEffect); 1629 RawPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValu eInternal(CSSPropertyWebkitTextDecorationsInEffect);
1634 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect.get()); 1630 diffTextDecorations(result.get(), textDecorationPropertyForEditing(), baseTe xtDecorationsInEffect.get());
1635 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get()); 1631 diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
1636 1632
1637 if (RefPtrWillBeRawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSV alueInternal(CSSPropertyFontWeight)) { 1633 if (RawPtr<CSSValue> baseFontWeight = baseStyle->getPropertyCSSValueInternal (CSSPropertyFontWeight)) {
1638 if (RefPtrWillBeRawPtr<CSSValue> fontWeight = result->getPropertyCSSValu e(CSSPropertyFontWeight)) { 1634 if (RawPtr<CSSValue> fontWeight = result->getPropertyCSSValue(CSSPropert yFontWeight)) {
1639 if (!fontWeightNeedsResolving(fontWeight.get()) && !fontWeightNeedsR esolving(baseFontWeight.get()) 1635 if (!fontWeightNeedsResolving(fontWeight.get()) && !fontWeightNeedsR esolving(baseFontWeight.get())
1640 && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseF ontWeight.get()))) 1636 && (fontWeightIsBold(fontWeight.get()) == fontWeightIsBold(baseF ontWeight.get())))
1641 result->removeProperty(CSSPropertyFontWeight); 1637 result->removeProperty(CSSPropertyFontWeight);
1642 } 1638 }
1643 } 1639 }
1644 1640
1645 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getFontColor (result.get()) == getFontColor(baseStyle)) 1641 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyColor) && getFontColor (result.get()) == getFontColor(baseStyle))
1646 result->removeProperty(CSSPropertyColor); 1642 result->removeProperty(CSSPropertyColor);
1647 1643
1648 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign) 1644 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyTextAlign)
1649 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle)) 1645 && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStar tAndEnd(baseStyle))
1650 result->removeProperty(CSSPropertyTextAlign); 1646 result->removeProperty(CSSPropertyTextAlign);
1651 1647
1652 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tBackgroundColor(result.get()) == getBackgroundColor(baseStyle)) 1648 if (baseStyle->getPropertyCSSValueInternal(CSSPropertyBackgroundColor) && ge tBackgroundColor(result.get()) == getBackgroundColor(baseStyle))
1653 result->removeProperty(CSSPropertyBackgroundColor); 1649 result->removeProperty(CSSPropertyBackgroundColor);
1654 1650
1655 return result.release(); 1651 return result.release();
1656 } 1652 }
1657 1653
1658 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID) 1654 CSSValueID getIdentifierValue(StylePropertySet* style, CSSPropertyID propertyID)
1659 { 1655 {
1660 if (!style) 1656 if (!style)
1661 return CSSValueInvalid; 1657 return CSSValueInvalid;
1662 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID); 1658 RawPtr<CSSValue> value = style->getPropertyCSSValue(propertyID);
1663 if (!value || !value->isPrimitiveValue()) 1659 if (!value || !value->isPrimitiveValue())
1664 return CSSValueInvalid; 1660 return CSSValueInvalid;
1665 return toCSSPrimitiveValue(value.get())->getValueID(); 1661 return toCSSPrimitiveValue(value.get())->getValueID();
1666 } 1662 }
1667 1663
1668 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ID) 1664 CSSValueID getIdentifierValue(CSSStyleDeclaration* style, CSSPropertyID property ID)
1669 { 1665 {
1670 if (!style) 1666 if (!style)
1671 return CSSValueInvalid; 1667 return CSSValueInvalid;
1672 RefPtrWillBeRawPtr<CSSValue> value = style->getPropertyCSSValueInternal(prop ertyID); 1668 RawPtr<CSSValue> value = style->getPropertyCSSValueInternal(propertyID);
1673 if (!value || !value->isPrimitiveValue()) 1669 if (!value || !value->isPrimitiveValue())
1674 return CSSValueInvalid; 1670 return CSSValueInvalid;
1675 return toCSSPrimitiveValue(value.get())->getValueID(); 1671 return toCSSPrimitiveValue(value.get())->getValueID();
1676 } 1672 }
1677 1673
1678 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo l isMonospaceFont, LegacyFontSizeMode mode) 1674 int legacyFontSizeFromCSSValue(Document* document, CSSPrimitiveValue* value, boo l isMonospaceFont, LegacyFontSizeMode mode)
1679 { 1675 {
1680 CSSPrimitiveValue::LengthUnitType lengthType; 1676 CSSPrimitiveValue::LengthUnitType lengthType;
1681 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved( ), lengthType) 1677 if (CSSPrimitiveValue::unitTypeToLengthUnitType(value->typeWithCalcResolved( ), lengthType)
1682 && lengthType == CSSPrimitiveValue::UnitTypePixels) { 1678 && lengthType == CSSPrimitiveValue::UnitTypePixels) {
(...skipping 20 matching lines...) Expand all
1703 if (cssValue->isColorValue()) 1699 if (cssValue->isColorValue())
1704 return !toCSSColorValue(cssValue)->value().alpha(); 1700 return !toCSSColorValue(cssValue)->value().alpha();
1705 if (!cssValue->isPrimitiveValue()) 1701 if (!cssValue->isPrimitiveValue())
1706 return false; 1702 return false;
1707 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); 1703 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue);
1708 return value->getValueID() == CSSValueTransparent; 1704 return value->getValueID() == CSSValueTransparent;
1709 } 1705 }
1710 1706
1711 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style) 1707 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
1712 { 1708 {
1713 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(C SSPropertyBackgroundColor); 1709 RawPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(CSSPropertyBa ckgroundColor);
1714 return isTransparentColorValue(cssValue.get()); 1710 return isTransparentColorValue(cssValue.get());
1715 } 1711 }
1716 1712
1717 bool hasTransparentBackgroundColor(StylePropertySet* style) 1713 bool hasTransparentBackgroundColor(StylePropertySet* style)
1718 { 1714 {
1719 RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSProper tyBackgroundColor); 1715 RawPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackground Color);
1720 return isTransparentColorValue(cssValue.get()); 1716 return isTransparentColorValue(cssValue.get());
1721 } 1717 }
1722 1718
1723 PassRefPtrWillBeRawPtr<CSSValue> backgroundColorValueInEffect(Node* node) 1719 RawPtr<CSSValue> backgroundColorValueInEffect(Node* node)
1724 { 1720 {
1725 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1721 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) {
1726 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); 1722 RawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDecl aration::create(ancestor);
1727 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1723 if (!hasTransparentBackgroundColor(ancestorStyle.get()))
1728 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); 1724 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor );
1729 } 1725 }
1730 return nullptr; 1726 return nullptr;
1731 } 1727 }
1732 1728
1733 } // namespace blink 1729 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698