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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 181783005: Have Element::ensureMutableInlineStyle() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/editing/EditingStyle.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 3078 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 // for class and id names so we need to go through the attribute change logi c 3089 // for class and id names so we need to go through the attribute change logi c
3090 // to pick up the new casing in the ElementData. 3090 // to pick up the new casing in the ElementData.
3091 if (oldDocument.inQuirksMode() != document().inQuirksMode()) { 3091 if (oldDocument.inQuirksMode() != document().inQuirksMode()) {
3092 if (hasID()) 3092 if (hasID())
3093 setIdAttribute(getIdAttribute()); 3093 setIdAttribute(getIdAttribute());
3094 if (hasClass()) 3094 if (hasClass())
3095 setAttribute(HTMLNames::classAttr, getClassAttribute()); 3095 setAttribute(HTMLNames::classAttr, getClassAttribute());
3096 } 3096 }
3097 3097
3098 if (needsURLResolutionForInlineStyle(*this, oldDocument, document())) 3098 if (needsURLResolutionForInlineStyle(*this, oldDocument, document()))
3099 reResolveURLsInInlineStyle(document(), *ensureMutableInlineStyle()); 3099 reResolveURLsInInlineStyle(document(), ensureMutableInlineStyle());
3100 } 3100 }
3101 3101
3102 void Element::updateNamedItemRegistration(const AtomicString& oldName, const Ato micString& newName) 3102 void Element::updateNamedItemRegistration(const AtomicString& oldName, const Ato micString& newName)
3103 { 3103 {
3104 if (!document().isHTMLDocument()) 3104 if (!document().isHTMLDocument())
3105 return; 3105 return;
3106 3106
3107 if (!oldName.isEmpty()) 3107 if (!oldName.isEmpty())
3108 toHTMLDocument(document()).removeNamedItem(oldName); 3108 toHTMLDocument(document()).removeNamedItem(oldName);
3109 3109
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom); 3341 inlineStyle ? AtomicString(inlineStyle->asText()) : nullAtom);
3342 } 3342 }
3343 3343
3344 CSSStyleDeclaration* Element::style() 3344 CSSStyleDeclaration* Element::style()
3345 { 3345 {
3346 if (!isStyledElement()) 3346 if (!isStyledElement())
3347 return 0; 3347 return 0;
3348 return ensureElementRareData().ensureInlineCSSStyleDeclaration(this); 3348 return ensureElementRareData().ensureInlineCSSStyleDeclaration(this);
3349 } 3349 }
3350 3350
3351 MutableStylePropertySet* Element::ensureMutableInlineStyle() 3351 MutableStylePropertySet& Element::ensureMutableInlineStyle()
3352 { 3352 {
3353 ASSERT(isStyledElement()); 3353 ASSERT(isStyledElement());
3354 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle; 3354 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt yle;
3355 if (!inlineStyle) { 3355 if (!inlineStyle) {
3356 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode; 3356 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H TMLQuirksMode : HTMLStandardMode;
3357 inlineStyle = MutableStylePropertySet::create(mode); 3357 inlineStyle = MutableStylePropertySet::create(mode);
3358 } else if (!inlineStyle->isMutable()) { 3358 } else if (!inlineStyle->isMutable()) {
3359 inlineStyle = inlineStyle->mutableCopy(); 3359 inlineStyle = inlineStyle->mutableCopy();
3360 } 3360 }
3361 return toMutableStylePropertySet(inlineStyle); 3361 return *toMutableStylePropertySet(inlineStyle);
3362 } 3362 }
3363 3363
3364 void Element::clearMutableInlineStyleIfEmpty() 3364 void Element::clearMutableInlineStyleIfEmpty()
3365 { 3365 {
3366 if (ensureMutableInlineStyle()->isEmpty()) { 3366 if (ensureMutableInlineStyle().isEmpty()) {
3367 ensureUniqueElementData().m_inlineStyle.clear(); 3367 ensureUniqueElementData().m_inlineStyle.clear();
3368 } 3368 }
3369 } 3369 }
3370 3370
3371 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString ) 3371 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString )
3372 { 3372 {
3373 ASSERT(isStyledElement()); 3373 ASSERT(isStyledElement());
3374 RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle; 3374 RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle;
3375 3375
3376 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style. 3376 // Avoid redundant work if we're using shared attribute data with already pa rsed inline style.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 ASSERT(isStyledElement()); 3414 ASSERT(isStyledElement());
3415 setNeedsStyleRecalc(LocalStyleChange); 3415 setNeedsStyleRecalc(LocalStyleChange);
3416 ASSERT(elementData()); 3416 ASSERT(elementData());
3417 elementData()->m_styleAttributeIsDirty = true; 3417 elementData()->m_styleAttributeIsDirty = true;
3418 InspectorInstrumentation::didInvalidateStyleAttr(this); 3418 InspectorInstrumentation::didInvalidateStyleAttr(this);
3419 } 3419 }
3420 3420
3421 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important) 3421 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi fier, bool important)
3422 { 3422 {
3423 ASSERT(isStyledElement()); 3423 ASSERT(isStyledElement());
3424 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createIde ntifierValue(identifier), important); 3424 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIden tifierValue(identifier), important);
3425 inlineStyleChanged(); 3425 inlineStyleChanged();
3426 return true; 3426 return true;
3427 } 3427 }
3428 3428
3429 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSPropertyID ide ntifier, bool important) 3429 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSPropertyID ide ntifier, bool important)
3430 { 3430 {
3431 ASSERT(isStyledElement()); 3431 ASSERT(isStyledElement());
3432 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createIde ntifierValue(identifier), important); 3432 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createIden tifierValue(identifier), important);
3433 inlineStyleChanged(); 3433 inlineStyleChanged();
3434 return true; 3434 return true;
3435 } 3435 }
3436 3436
3437 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitTypes unit, bool important) 3437 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS PrimitiveValue::UnitTypes unit, bool important)
3438 { 3438 {
3439 ASSERT(isStyledElement()); 3439 ASSERT(isStyledElement());
3440 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createVal ue(value, unit), important); 3440 ensureMutableInlineStyle().setProperty(propertyID, cssValuePool().createValu e(value, unit), important);
3441 inlineStyleChanged(); 3441 inlineStyleChanged();
3442 return true; 3442 return true;
3443 } 3443 }
3444 3444
3445 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important) 3445 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val ue, bool important)
3446 { 3446 {
3447 ASSERT(isStyledElement()); 3447 ASSERT(isStyledElement());
3448 bool changes = ensureMutableInlineStyle()->setProperty(propertyID, value, im portant, document().elementSheet().contents()); 3448 bool changes = ensureMutableInlineStyle().setProperty(propertyID, value, imp ortant, document().elementSheet().contents());
3449 if (changes) 3449 if (changes)
3450 inlineStyleChanged(); 3450 inlineStyleChanged();
3451 return changes; 3451 return changes;
3452 } 3452 }
3453 3453
3454 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID) 3454 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID)
3455 { 3455 {
3456 ASSERT(isStyledElement()); 3456 ASSERT(isStyledElement());
3457 if (!inlineStyle()) 3457 if (!inlineStyle())
3458 return false; 3458 return false;
3459 bool changes = ensureMutableInlineStyle()->removeProperty(propertyID); 3459 bool changes = ensureMutableInlineStyle().removeProperty(propertyID);
3460 if (changes) 3460 if (changes)
3461 inlineStyleChanged(); 3461 inlineStyleChanged();
3462 return changes; 3462 return changes;
3463 } 3463 }
3464 3464
3465 void Element::removeAllInlineStyleProperties() 3465 void Element::removeAllInlineStyleProperties()
3466 { 3466 {
3467 ASSERT(isStyledElement()); 3467 ASSERT(isStyledElement());
3468 if (!inlineStyle()) 3468 if (!inlineStyle())
3469 return; 3469 return;
3470 ensureMutableInlineStyle()->clear(); 3470 ensureMutableInlineStyle().clear();
3471 inlineStyleChanged(); 3471 inlineStyleChanged();
3472 } 3472 }
3473 3473
3474 void Element::updatePresentationAttributeStyle() 3474 void Element::updatePresentationAttributeStyle()
3475 { 3475 {
3476 // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData. 3476 // ShareableElementData doesn't store presentation attribute style, so make sure we have a UniqueElementData.
3477 UniqueElementData& elementData = ensureUniqueElementData(); 3477 UniqueElementData& elementData = ensureUniqueElementData();
3478 elementData.m_presentationAttributeStyleIsDirty = false; 3478 elementData.m_presentationAttributeStyleIsDirty = false;
3479 elementData.m_presentationAttributeStyle = computePresentationAttributeStyle (*this); 3479 elementData.m_presentationAttributeStyle = computePresentationAttributeStyle (*this);
3480 } 3480 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3541 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3542 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3542 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3543 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3543 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3544 return false; 3544 return false;
3545 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3545 if (FullscreenElementStack::isActiveFullScreenElement(this))
3546 return false; 3546 return false;
3547 return true; 3547 return true;
3548 } 3548 }
3549 3549
3550 } // namespace WebCore 3550 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/editing/EditingStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698