| 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 * (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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 if (!inSynchronizationOfLazyAttribute) | 970 if (!inSynchronizationOfLazyAttribute) |
| 971 willModifyAttribute(existingAttributeName, existingAttribute->value(), n
ewValue); | 971 willModifyAttribute(existingAttributeName, existingAttribute->value(), n
ewValue); |
| 972 | 972 |
| 973 if (newValue != existingAttribute->value()) { | 973 if (newValue != existingAttribute->value()) { |
| 974 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below | 974 // If there is an Attr node hooked to this attribute, the Attr::setValue
() call below |
| 975 // will write into the ElementData. | 975 // will write into the ElementData. |
| 976 // FIXME: Refactor this so it makes some sense. | 976 // FIXME: Refactor this so it makes some sense. |
| 977 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? nullptr :
attrIfExists(existingAttributeName)) | 977 if (RefPtr<Attr> attrNode = inSynchronizationOfLazyAttribute ? nullptr :
attrIfExists(existingAttributeName)) |
| 978 attrNode->setValue(newValue); | 978 attrNode->setValue(newValue); |
| 979 else | 979 else |
| 980 ensureUniqueElementData()->attributeItem(index)->setValue(newValue); | 980 ensureUniqueElementData().attributeItem(index)->setValue(newValue); |
| 981 } | 981 } |
| 982 | 982 |
| 983 if (!inSynchronizationOfLazyAttribute) | 983 if (!inSynchronizationOfLazyAttribute) |
| 984 didModifyAttribute(existingAttributeName, newValue); | 984 didModifyAttribute(existingAttributeName, newValue); |
| 985 } | 985 } |
| 986 | 986 |
| 987 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b
ool inQuirksMode) | 987 static inline AtomicString makeIdForStyleResolution(const AtomicString& value, b
ool inQuirksMode) |
| 988 { | 988 { |
| 989 if (inQuirksMode) | 989 if (inQuirksMode) |
| 990 return value.lower(); | 990 return value.lower(); |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 return attrNode; // This Attr is already attached to the element. | 1956 return attrNode; // This Attr is already attached to the element. |
| 1957 | 1957 |
| 1958 // InUseAttributeError: Raised if node is an Attr that is already an attribu
te of another Element object. | 1958 // InUseAttributeError: Raised if node is an Attr that is already an attribu
te of another Element object. |
| 1959 // The DOM user must explicitly clone Attr nodes to re-use them in other ele
ments. | 1959 // The DOM user must explicitly clone Attr nodes to re-use them in other ele
ments. |
| 1960 if (attrNode->ownerElement()) { | 1960 if (attrNode->ownerElement()) { |
| 1961 exceptionState.throwDOMException(InUseAttributeError, "The node provided
is an attribute node that is already an attribute of another Element; attribute
nodes must be explicitly cloned."); | 1961 exceptionState.throwDOMException(InUseAttributeError, "The node provided
is an attribute node that is already an attribute of another Element; attribute
nodes must be explicitly cloned."); |
| 1962 return nullptr; | 1962 return nullptr; |
| 1963 } | 1963 } |
| 1964 | 1964 |
| 1965 synchronizeAllAttributes(); | 1965 synchronizeAllAttributes(); |
| 1966 UniqueElementData* elementData = ensureUniqueElementData(); | 1966 UniqueElementData& elementData = ensureUniqueElementData(); |
| 1967 | 1967 |
| 1968 size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(),
shouldIgnoreAttributeCase()); | 1968 size_t index = elementData.getAttributeItemIndex(attrNode->qualifiedName(),
shouldIgnoreAttributeCase()); |
| 1969 if (index != kNotFound) { | 1969 if (index != kNotFound) { |
| 1970 if (oldAttrNode) | 1970 if (oldAttrNode) |
| 1971 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a
ttributeItem(index)->value()); | 1971 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData.at
tributeItem(index)->value()); |
| 1972 else | 1972 else |
| 1973 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el
ementData->attributeItem(index)->value()); | 1973 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el
ementData.attributeItem(index)->value()); |
| 1974 } | 1974 } |
| 1975 | 1975 |
| 1976 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No
tInSynchronizationOfLazyAttribute); | 1976 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No
tInSynchronizationOfLazyAttribute); |
| 1977 | 1977 |
| 1978 attrNode->attachToElement(this); | 1978 attrNode->attachToElement(this); |
| 1979 treeScope().adoptIfNeeded(*attrNode); | 1979 treeScope().adoptIfNeeded(*attrNode); |
| 1980 ensureAttrNodeListForElement(this).append(attrNode); | 1980 ensureAttrNodeListForElement(this).append(attrNode); |
| 1981 | 1981 |
| 1982 return oldAttrNode.release(); | 1982 return oldAttrNode.release(); |
| 1983 } | 1983 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 QualifiedName parsedName = anyName; | 2031 QualifiedName parsedName = anyName; |
| 2032 if (!parseAttributeName(parsedName, namespaceURI, qualifiedName, exceptionSt
ate)) | 2032 if (!parseAttributeName(parsedName, namespaceURI, qualifiedName, exceptionSt
ate)) |
| 2033 return; | 2033 return; |
| 2034 setAttribute(parsedName, value); | 2034 setAttribute(parsedName, value); |
| 2035 } | 2035 } |
| 2036 | 2036 |
| 2037 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) | 2037 void Element::removeAttributeInternal(size_t index, SynchronizationOfLazyAttribu
te inSynchronizationOfLazyAttribute) |
| 2038 { | 2038 { |
| 2039 ASSERT_WITH_SECURITY_IMPLICATION(index < attributeCount()); | 2039 ASSERT_WITH_SECURITY_IMPLICATION(index < attributeCount()); |
| 2040 | 2040 |
| 2041 UniqueElementData* elementData = ensureUniqueElementData(); | 2041 UniqueElementData& elementData = ensureUniqueElementData(); |
| 2042 | 2042 |
| 2043 QualifiedName name = elementData->attributeItem(index)->name(); | 2043 QualifiedName name = elementData.attributeItem(index)->name(); |
| 2044 AtomicString valueBeingRemoved = elementData->attributeItem(index)->value(); | 2044 AtomicString valueBeingRemoved = elementData.attributeItem(index)->value(); |
| 2045 | 2045 |
| 2046 if (!inSynchronizationOfLazyAttribute) { | 2046 if (!inSynchronizationOfLazyAttribute) { |
| 2047 if (!valueBeingRemoved.isNull()) | 2047 if (!valueBeingRemoved.isNull()) |
| 2048 willModifyAttribute(name, valueBeingRemoved, nullAtom); | 2048 willModifyAttribute(name, valueBeingRemoved, nullAtom); |
| 2049 } | 2049 } |
| 2050 | 2050 |
| 2051 if (RefPtr<Attr> attrNode = attrIfExists(name)) | 2051 if (RefPtr<Attr> attrNode = attrIfExists(name)) |
| 2052 detachAttrNodeFromElementWithValue(attrNode.get(), elementData->attribut
eItem(index)->value()); | 2052 detachAttrNodeFromElementWithValue(attrNode.get(), elementData.attribute
Item(index)->value()); |
| 2053 | 2053 |
| 2054 elementData->removeAttribute(index); | 2054 elementData.removeAttribute(index); |
| 2055 | 2055 |
| 2056 if (!inSynchronizationOfLazyAttribute) | 2056 if (!inSynchronizationOfLazyAttribute) |
| 2057 didRemoveAttribute(name); | 2057 didRemoveAttribute(name); |
| 2058 } | 2058 } |
| 2059 | 2059 |
| 2060 void Element::addAttributeInternal(const QualifiedName& name, const AtomicString
& value, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute) | 2060 void Element::addAttributeInternal(const QualifiedName& name, const AtomicString
& value, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute) |
| 2061 { | 2061 { |
| 2062 if (!inSynchronizationOfLazyAttribute) | 2062 if (!inSynchronizationOfLazyAttribute) |
| 2063 willModifyAttribute(name, nullAtom, value); | 2063 willModifyAttribute(name, nullAtom, value); |
| 2064 ensureUniqueElementData()->addAttribute(name, value); | 2064 ensureUniqueElementData().addAttribute(name, value); |
| 2065 if (!inSynchronizationOfLazyAttribute) | 2065 if (!inSynchronizationOfLazyAttribute) |
| 2066 didAddAttribute(name, value); | 2066 didAddAttribute(name, value); |
| 2067 } | 2067 } |
| 2068 | 2068 |
| 2069 void Element::removeAttribute(const AtomicString& name) | 2069 void Element::removeAttribute(const AtomicString& name) |
| 2070 { | 2070 { |
| 2071 if (!elementData()) | 2071 if (!elementData()) |
| 2072 return; | 2072 return; |
| 2073 | 2073 |
| 2074 AtomicString localName = shouldIgnoreAttributeCase() ? name.lower() : name; | 2074 AtomicString localName = shouldIgnoreAttributeCase() ? name.lower() : name; |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3313 CSSStyleDeclaration* Element::style() | 3313 CSSStyleDeclaration* Element::style() |
| 3314 { | 3314 { |
| 3315 if (!isStyledElement()) | 3315 if (!isStyledElement()) |
| 3316 return 0; | 3316 return 0; |
| 3317 return ensureElementRareData().ensureInlineCSSStyleDeclaration(this); | 3317 return ensureElementRareData().ensureInlineCSSStyleDeclaration(this); |
| 3318 } | 3318 } |
| 3319 | 3319 |
| 3320 MutableStylePropertySet* Element::ensureMutableInlineStyle() | 3320 MutableStylePropertySet* Element::ensureMutableInlineStyle() |
| 3321 { | 3321 { |
| 3322 ASSERT(isStyledElement()); | 3322 ASSERT(isStyledElement()); |
| 3323 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineS
tyle; | 3323 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData().m_inlineSt
yle; |
| 3324 if (!inlineStyle) { | 3324 if (!inlineStyle) { |
| 3325 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H
TMLQuirksMode : HTMLStandardMode; | 3325 CSSParserMode mode = (!isHTMLElement() || document().inQuirksMode()) ? H
TMLQuirksMode : HTMLStandardMode; |
| 3326 inlineStyle = MutableStylePropertySet::create(mode); | 3326 inlineStyle = MutableStylePropertySet::create(mode); |
| 3327 } else if (!inlineStyle->isMutable()) { | 3327 } else if (!inlineStyle->isMutable()) { |
| 3328 inlineStyle = inlineStyle->mutableCopy(); | 3328 inlineStyle = inlineStyle->mutableCopy(); |
| 3329 } | 3329 } |
| 3330 return toMutableStylePropertySet(inlineStyle); | 3330 return toMutableStylePropertySet(inlineStyle); |
| 3331 } | 3331 } |
| 3332 | 3332 |
| 3333 void Element::clearMutableInlineStyleIfEmpty() | 3333 void Element::clearMutableInlineStyleIfEmpty() |
| 3334 { | 3334 { |
| 3335 if (ensureMutableInlineStyle()->isEmpty()) { | 3335 if (ensureMutableInlineStyle()->isEmpty()) { |
| 3336 ensureUniqueElementData()->m_inlineStyle.clear(); | 3336 ensureUniqueElementData().m_inlineStyle.clear(); |
| 3337 } | 3337 } |
| 3338 } | 3338 } |
| 3339 | 3339 |
| 3340 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString
) | 3340 inline void Element::setInlineStyleFromString(const AtomicString& newStyleString
) |
| 3341 { | 3341 { |
| 3342 ASSERT(isStyledElement()); | 3342 ASSERT(isStyledElement()); |
| 3343 RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle; | 3343 RefPtr<StylePropertySet>& inlineStyle = elementData()->m_inlineStyle; |
| 3344 | 3344 |
| 3345 // Avoid redundant work if we're using shared attribute data with already pa
rsed inline style. | 3345 // Avoid redundant work if we're using shared attribute data with already pa
rsed inline style. |
| 3346 if (inlineStyle && !elementData()->isUnique()) | 3346 if (inlineStyle && !elementData()->isUnique()) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3360 } | 3360 } |
| 3361 | 3361 |
| 3362 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut
eModificationReason modificationReason) | 3362 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut
eModificationReason modificationReason) |
| 3363 { | 3363 { |
| 3364 ASSERT(isStyledElement()); | 3364 ASSERT(isStyledElement()); |
| 3365 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); | 3365 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); |
| 3366 if (document().scriptableDocumentParser() && !document().isInDocumentWrite()
) | 3366 if (document().scriptableDocumentParser() && !document().isInDocumentWrite()
) |
| 3367 startLineNumber = document().scriptableDocumentParser()->lineNumber(); | 3367 startLineNumber = document().scriptableDocumentParser()->lineNumber(); |
| 3368 | 3368 |
| 3369 if (newStyleString.isNull()) { | 3369 if (newStyleString.isNull()) { |
| 3370 ensureUniqueElementData()->m_inlineStyle.clear(); | 3370 ensureUniqueElementData().m_inlineStyle.clear(); |
| 3371 } else if (modificationReason == ModifiedByCloning || document().contentSecu
rityPolicy()->allowInlineStyle(document().url(), startLineNumber)) { | 3371 } else if (modificationReason == ModifiedByCloning || document().contentSecu
rityPolicy()->allowInlineStyle(document().url(), startLineNumber)) { |
| 3372 setInlineStyleFromString(newStyleString); | 3372 setInlineStyleFromString(newStyleString); |
| 3373 } | 3373 } |
| 3374 | 3374 |
| 3375 elementData()->m_styleAttributeIsDirty = false; | 3375 elementData()->m_styleAttributeIsDirty = false; |
| 3376 | 3376 |
| 3377 setNeedsStyleRecalc(LocalStyleChange); | 3377 setNeedsStyleRecalc(LocalStyleChange); |
| 3378 InspectorInstrumentation::didInvalidateStyleAttr(this); | 3378 InspectorInstrumentation::didInvalidateStyleAttr(this); |
| 3379 } | 3379 } |
| 3380 | 3380 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3436 ASSERT(isStyledElement()); | 3436 ASSERT(isStyledElement()); |
| 3437 if (!inlineStyle()) | 3437 if (!inlineStyle()) |
| 3438 return; | 3438 return; |
| 3439 ensureMutableInlineStyle()->clear(); | 3439 ensureMutableInlineStyle()->clear(); |
| 3440 inlineStyleChanged(); | 3440 inlineStyleChanged(); |
| 3441 } | 3441 } |
| 3442 | 3442 |
| 3443 void Element::updatePresentationAttributeStyle() | 3443 void Element::updatePresentationAttributeStyle() |
| 3444 { | 3444 { |
| 3445 // ShareableElementData doesn't store presentation attribute style, so make
sure we have a UniqueElementData. | 3445 // ShareableElementData doesn't store presentation attribute style, so make
sure we have a UniqueElementData. |
| 3446 UniqueElementData* elementData = ensureUniqueElementData(); | 3446 UniqueElementData& elementData = ensureUniqueElementData(); |
| 3447 elementData->m_presentationAttributeStyleIsDirty = false; | 3447 elementData.m_presentationAttributeStyleIsDirty = false; |
| 3448 elementData->m_presentationAttributeStyle = computePresentationAttributeStyl
e(*this); | 3448 elementData.m_presentationAttributeStyle = computePresentationAttributeStyle
(*this); |
| 3449 } | 3449 } |
| 3450 | 3450 |
| 3451 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, CSSValueID identifier) | 3451 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, CSSValueID identifier) |
| 3452 { | 3452 { |
| 3453 ASSERT(isStyledElement()); | 3453 ASSERT(isStyledElement()); |
| 3454 style->setProperty(propertyID, cssValuePool().createIdentifierValue(identifi
er)); | 3454 style->setProperty(propertyID, cssValuePool().createIdentifierValue(identifi
er)); |
| 3455 } | 3455 } |
| 3456 | 3456 |
| 3457 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitTypes unit) | 3457 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitTypes unit) |
| 3458 { | 3458 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3510 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems | 3510 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems |
| 3511 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 | 3511 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 |
| 3512 if (hasTagName(optionTag) || hasTagName(optgroupTag)) | 3512 if (hasTagName(optionTag) || hasTagName(optgroupTag)) |
| 3513 return false; | 3513 return false; |
| 3514 if (FullscreenElementStack::isActiveFullScreenElement(this)) | 3514 if (FullscreenElementStack::isActiveFullScreenElement(this)) |
| 3515 return false; | 3515 return false; |
| 3516 return true; | 3516 return true; |
| 3517 } | 3517 } |
| 3518 | 3518 |
| 3519 } // namespace WebCore | 3519 } // namespace WebCore |
| OLD | NEW |