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

Side by Side Diff: Source/core/css/PropertySetCSSStyleDeclaration.cpp

Issue 717933002: Clean up after getPropertyCSSValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase / fix debug compile? Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/PropertySetCSSStyleDeclaration.h ('k') | Source/core/css/RGBColor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 willMutate(); 165 willMutate();
166 166
167 // FIXME: Detect syntax errors and set exceptionState. 167 // FIXME: Detect syntax errors and set exceptionState.
168 propertySet().parseDeclaration(text, contextStyleSheet()); 168 propertySet().parseDeclaration(text, contextStyleSheet());
169 169
170 didMutate(PropertyChanged); 170 didMutate(PropertyChanged);
171 171
172 mutationScope.enqueueMutationRecord(); 172 mutationScope.enqueueMutationRecord();
173 } 173 }
174 174
175 PassRefPtrWillBeRawPtr<CSSValue> AbstractPropertySetCSSStyleDeclaration::getProp ertyCSSValue(const String& propertyName)
176 {
177 CSSPropertyID propertyID = cssPropertyID(propertyName);
178 if (!propertyID)
179 return nullptr;
180 return cloneAndCacheForCSSOM(propertySet().getPropertyCSSValue(propertyID).g et());
181 }
182
183 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String &pr opertyName) 175 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String &pr opertyName)
184 { 176 {
185 CSSPropertyID propertyID = cssPropertyID(propertyName); 177 CSSPropertyID propertyID = cssPropertyID(propertyName);
186 if (!propertyID) 178 if (!propertyID)
187 return String(); 179 return String();
188 return propertySet().getPropertyValue(propertyID); 180 return propertySet().getPropertyValue(propertyID);
189 } 181 }
190 182
191 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName) 183 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName)
192 { 184 {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 willMutate(); 255 willMutate();
264 256
265 bool changed = propertySet().setProperty(propertyID, value, important, conte xtStyleSheet()); 257 bool changed = propertySet().setProperty(propertyID, value, important, conte xtStyleSheet());
266 258
267 didMutate(changed ? PropertyChanged : NoChanges); 259 didMutate(changed ? PropertyChanged : NoChanges);
268 260
269 if (changed) 261 if (changed)
270 mutationScope.enqueueMutationRecord(); 262 mutationScope.enqueueMutationRecord();
271 } 263 }
272 264
273 CSSValue* AbstractPropertySetCSSStyleDeclaration::cloneAndCacheForCSSOM(CSSValue * internalValue)
274 {
275 if (!internalValue)
276 return 0;
277
278 // The map is here to maintain the object identity of the CSSValues over mul tiple invocations.
279 // FIXME: It is likely that the identity is not important for web compatibil ity and this code should be removed.
280 if (!m_cssomCSSValueClones)
281 m_cssomCSSValueClones = adoptPtrWillBeNoop(new WillBeHeapHashMap<RawPtrW illBeMember<CSSValue>, RefPtrWillBeMember<CSSValue> >);
282
283 RefPtrWillBeMember<CSSValue>& clonedValue = m_cssomCSSValueClones->add(inter nalValue, RefPtrWillBeMember<CSSValue>()).storedValue->value;
284 if (!clonedValue)
285 clonedValue = internalValue->cloneForCSSOM();
286 return clonedValue.get();
287 }
288
289 StyleSheetContents* AbstractPropertySetCSSStyleDeclaration::contextStyleSheet() const 265 StyleSheetContents* AbstractPropertySetCSSStyleDeclaration::contextStyleSheet() const
290 { 266 {
291 CSSStyleSheet* cssStyleSheet = parentStyleSheet(); 267 CSSStyleSheet* cssStyleSheet = parentStyleSheet();
292 return cssStyleSheet ? cssStyleSheet->contents() : 0; 268 return cssStyleSheet ? cssStyleSheet->contents() : 0;
293 } 269 }
294 270
295 PassRefPtrWillBeRawPtr<MutableStylePropertySet> AbstractPropertySetCSSStyleDecla ration::copyProperties() const 271 PassRefPtrWillBeRawPtr<MutableStylePropertySet> AbstractPropertySetCSSStyleDecla ration::copyProperties() const
296 { 272 {
297 return propertySet().mutableCopy(); 273 return propertySet().mutableCopy();
298 } 274 }
299 275
300 bool AbstractPropertySetCSSStyleDeclaration::cssPropertyMatches(CSSPropertyID pr opertyID, const CSSValue* propertyValue) const 276 bool AbstractPropertySetCSSStyleDeclaration::cssPropertyMatches(CSSPropertyID pr opertyID, const CSSValue* propertyValue) const
301 { 277 {
302 return propertySet().propertyMatches(propertyID, propertyValue); 278 return propertySet().propertyMatches(propertyID, propertyValue);
303 } 279 }
304 280
305 void AbstractPropertySetCSSStyleDeclaration::trace(Visitor* visitor) 281 void AbstractPropertySetCSSStyleDeclaration::trace(Visitor* visitor)
306 { 282 {
307 #if ENABLE(OILPAN)
308 visitor->trace(m_cssomCSSValueClones);
309 #endif
310 CSSStyleDeclaration::trace(visitor); 283 CSSStyleDeclaration::trace(visitor);
311 } 284 }
312 285
313 StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(MutableStylePropertyS et& propertySetArg, CSSRule* parentRule) 286 StyleRuleCSSStyleDeclaration::StyleRuleCSSStyleDeclaration(MutableStylePropertyS et& propertySetArg, CSSRule* parentRule)
314 : PropertySetCSSStyleDeclaration(propertySetArg) 287 : PropertySetCSSStyleDeclaration(propertySetArg)
315 #if !ENABLE(OILPAN) 288 #if !ENABLE(OILPAN)
316 , m_refCount(1) 289 , m_refCount(1)
317 #endif 290 #endif
318 , m_parentRule(parentRule) 291 , m_parentRule(parentRule)
319 { 292 {
(...skipping 24 matching lines...) Expand all
344 #endif 317 #endif
345 318
346 void StyleRuleCSSStyleDeclaration::willMutate() 319 void StyleRuleCSSStyleDeclaration::willMutate()
347 { 320 {
348 if (m_parentRule && m_parentRule->parentStyleSheet()) 321 if (m_parentRule && m_parentRule->parentStyleSheet())
349 m_parentRule->parentStyleSheet()->willMutateRules(); 322 m_parentRule->parentStyleSheet()->willMutateRules();
350 } 323 }
351 324
352 void StyleRuleCSSStyleDeclaration::didMutate(MutationType type) 325 void StyleRuleCSSStyleDeclaration::didMutate(MutationType type)
353 { 326 {
354 if (type == PropertyChanged)
355 m_cssomCSSValueClones.clear();
356
357 // Style sheet mutation needs to be signaled even if the change failed. will MutateRules/didMutateRules must pair. 327 // Style sheet mutation needs to be signaled even if the change failed. will MutateRules/didMutateRules must pair.
358 if (m_parentRule && m_parentRule->parentStyleSheet()) 328 if (m_parentRule && m_parentRule->parentStyleSheet())
359 m_parentRule->parentStyleSheet()->didMutateRules(); 329 m_parentRule->parentStyleSheet()->didMutateRules();
360 } 330 }
361 331
362 CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const 332 CSSStyleSheet* StyleRuleCSSStyleDeclaration::parentStyleSheet() const
363 { 333 {
364 return m_parentRule ? m_parentRule->parentStyleSheet() : 0; 334 return m_parentRule ? m_parentRule->parentStyleSheet() : 0;
365 } 335 }
366 336
(...skipping 17 matching lines...) Expand all
384 MutableStylePropertySet& InlineCSSStyleDeclaration::propertySet() const 354 MutableStylePropertySet& InlineCSSStyleDeclaration::propertySet() const
385 { 355 {
386 return m_parentElement->ensureMutableInlineStyle(); 356 return m_parentElement->ensureMutableInlineStyle();
387 } 357 }
388 358
389 void InlineCSSStyleDeclaration::didMutate(MutationType type) 359 void InlineCSSStyleDeclaration::didMutate(MutationType type)
390 { 360 {
391 if (type == NoChanges) 361 if (type == NoChanges)
392 return; 362 return;
393 363
394 m_cssomCSSValueClones.clear();
395
396 if (!m_parentElement) 364 if (!m_parentElement)
397 return; 365 return;
398 366
399 m_parentElement->clearMutableInlineStyleIfEmpty(); 367 m_parentElement->clearMutableInlineStyleIfEmpty();
400 m_parentElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForT racing::create(StyleChangeReason::StyleSheetChange)); 368 m_parentElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForT racing::create(StyleChangeReason::StyleSheetChange));
401 m_parentElement->invalidateStyleAttribute(); 369 m_parentElement->invalidateStyleAttribute();
402 StyleAttributeMutationScope(this).didInvalidateStyleAttr(); 370 StyleAttributeMutationScope(this).didInvalidateStyleAttr();
403 } 371 }
404 372
405 CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const 373 CSSStyleSheet* InlineCSSStyleDeclaration::parentStyleSheet() const
(...skipping 13 matching lines...) Expand all
419 } 387 }
420 #endif 388 #endif
421 389
422 void InlineCSSStyleDeclaration::trace(Visitor* visitor) 390 void InlineCSSStyleDeclaration::trace(Visitor* visitor)
423 { 391 {
424 visitor->trace(m_parentElement); 392 visitor->trace(m_parentElement);
425 AbstractPropertySetCSSStyleDeclaration::trace(visitor); 393 AbstractPropertySetCSSStyleDeclaration::trace(visitor);
426 } 394 }
427 395
428 } // namespace blink 396 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/PropertySetCSSStyleDeclaration.h ('k') | Source/core/css/RGBColor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698