OLD | NEW |
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 * Copyright (C) 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 { | 150 { |
151 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineS
tyle; | 151 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineS
tyle; |
152 if (!inlineStyle) | 152 if (!inlineStyle) |
153 inlineStyle = StylePropertySet::create(strictToCSSParserMode(isHTMLEleme
nt() && !document()->inQuirksMode())); | 153 inlineStyle = StylePropertySet::create(strictToCSSParserMode(isHTMLEleme
nt() && !document()->inQuirksMode())); |
154 else if (!inlineStyle->isMutable()) | 154 else if (!inlineStyle->isMutable()) |
155 inlineStyle = inlineStyle->copy(); | 155 inlineStyle = inlineStyle->copy(); |
156 ASSERT(inlineStyle->isMutable()); | 156 ASSERT(inlineStyle->isMutable()); |
157 return static_cast<MutableStylePropertySet*>(inlineStyle.get()); | 157 return static_cast<MutableStylePropertySet*>(inlineStyle.get()); |
158 } | 158 } |
159 | 159 |
160 void StyledElement::attributeChanged(const QualifiedName& name, const AtomicStri
ng& newValue) | 160 void StyledElement::attributeChanged(const QualifiedName& name, const AtomicStri
ng& newValue, AttributeModificationReason reason) |
161 { | 161 { |
162 if (name == styleAttr) | 162 if (name == styleAttr) |
163 styleAttributeChanged(newValue); | 163 styleAttributeChanged(newValue, reason); |
164 else if (isPresentationAttribute(name)) { | 164 else if (isPresentationAttribute(name)) { |
165 elementData()->m_presentationAttributeStyleIsDirty = true; | 165 elementData()->m_presentationAttributeStyleIsDirty = true; |
166 setNeedsStyleRecalc(InlineStyleChange); | 166 setNeedsStyleRecalc(InlineStyleChange); |
167 } | 167 } |
168 | 168 |
169 Element::attributeChanged(name, newValue); | 169 Element::attributeChanged(name, newValue, reason); |
170 } | 170 } |
171 | 171 |
172 PropertySetCSSStyleDeclaration* StyledElement::inlineStyleCSSOMWrapper() | 172 PropertySetCSSStyleDeclaration* StyledElement::inlineStyleCSSOMWrapper() |
173 { | 173 { |
174 if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper()) | 174 if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper()) |
175 return 0; | 175 return 0; |
176 PropertySetCSSStyleDeclaration* cssomWrapper = ensureUniqueElementData()->m_
inlineStyle->cssStyleDeclaration(); | 176 PropertySetCSSStyleDeclaration* cssomWrapper = ensureUniqueElementData()->m_
inlineStyle->cssStyleDeclaration(); |
177 ASSERT(cssomWrapper && cssomWrapper->parentElement() == this); | 177 ASSERT(cssomWrapper && cssomWrapper->parentElement() == this); |
178 return cssomWrapper; | 178 return cssomWrapper; |
179 } | 179 } |
(...skipping 10 matching lines...) Expand all Loading... |
190 // This makes wrapperless property sets immutable and so cacheable. | 190 // This makes wrapperless property sets immutable and so cacheable. |
191 if (inlineStyle && !inlineStyle->isMutable()) | 191 if (inlineStyle && !inlineStyle->isMutable()) |
192 inlineStyle.clear(); | 192 inlineStyle.clear(); |
193 | 193 |
194 if (!inlineStyle) | 194 if (!inlineStyle) |
195 inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, thi
s); | 195 inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, thi
s); |
196 else | 196 else |
197 inlineStyle->parseDeclaration(newStyleString, document()->elementSheet()
->contents()); | 197 inlineStyle->parseDeclaration(newStyleString, document()->elementSheet()
->contents()); |
198 } | 198 } |
199 | 199 |
200 void StyledElement::styleAttributeChanged(const AtomicString& newStyleString) | 200 void StyledElement::styleAttributeChanged(const AtomicString& newStyleString, At
tributeModificationReason modificationReason) |
201 { | 201 { |
202 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); | 202 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); |
203 if (document() && document()->scriptableDocumentParser() && !document()->isI
nDocumentWrite()) | 203 if (document() && document()->scriptableDocumentParser() && !document()->isI
nDocumentWrite()) |
204 startLineNumber = document()->scriptableDocumentParser()->lineNumber(); | 204 startLineNumber = document()->scriptableDocumentParser()->lineNumber(); |
205 | 205 |
206 if (newStyleString.isNull()) { | 206 if (newStyleString.isNull()) { |
207 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapp
er()) | 207 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapp
er()) |
208 cssomWrapper->clearParentElement(); | 208 cssomWrapper->clearParentElement(); |
209 ensureUniqueElementData()->m_inlineStyle.clear(); | 209 ensureUniqueElementData()->m_inlineStyle.clear(); |
210 } else if (document()->contentSecurityPolicy()->allowInlineStyle(document()-
>url(), startLineNumber)) | 210 } else if (modificationReason == ModifiedByCloning || document()->contentSec
urityPolicy()->allowInlineStyle(document()->url(), startLineNumber)) |
211 setInlineStyleFromString(newStyleString); | 211 setInlineStyleFromString(newStyleString); |
212 | 212 |
213 elementData()->m_styleAttributeIsDirty = false; | 213 elementData()->m_styleAttributeIsDirty = false; |
214 | 214 |
215 setNeedsStyleRecalc(InlineStyleChange); | 215 setNeedsStyleRecalc(InlineStyleChange); |
216 InspectorInstrumentation::didInvalidateStyleAttr(document(), this); | 216 InspectorInstrumentation::didInvalidateStyleAttr(document(), this); |
217 } | 217 } |
218 | 218 |
219 void StyledElement::inlineStyleChanged() | 219 void StyledElement::inlineStyleChanged() |
220 { | 220 { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 { | 372 { |
373 style->setProperty(propertyID, cssValuePool().createValue(value, unit)); | 373 style->setProperty(propertyID, cssValuePool().createValue(value, unit)); |
374 } | 374 } |
375 | 375 |
376 void StyledElement::addPropertyToPresentationAttributeStyle(MutableStyleProperty
Set* style, CSSPropertyID propertyID, const String& value) | 376 void StyledElement::addPropertyToPresentationAttributeStyle(MutableStyleProperty
Set* style, CSSPropertyID propertyID, const String& value) |
377 { | 377 { |
378 style->setProperty(propertyID, value, false, document()->elementSheet()->con
tents()); | 378 style->setProperty(propertyID, value, false, document()->elementSheet()->con
tents()); |
379 } | 379 } |
380 | 380 |
381 } | 381 } |
OLD | NEW |