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

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

Issue 164803002: Handle CSSImageValue URLs in inline styles in templates correctly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed template usage Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/parser/BisonCSSParser-in.cpp ('k') | Source/core/html/HTMLBodyElement.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 18 matching lines...) Expand all
29 #include "CSSValueKeywords.h" 29 #include "CSSValueKeywords.h"
30 #include "RuntimeEnabledFeatures.h" 30 #include "RuntimeEnabledFeatures.h"
31 #include "SVGNames.h" 31 #include "SVGNames.h"
32 #include "XMLNames.h" 32 #include "XMLNames.h"
33 #include "bindings/v8/Dictionary.h" 33 #include "bindings/v8/Dictionary.h"
34 #include "bindings/v8/ExceptionMessages.h" 34 #include "bindings/v8/ExceptionMessages.h"
35 #include "bindings/v8/ExceptionState.h" 35 #include "bindings/v8/ExceptionState.h"
36 #include "core/accessibility/AXObjectCache.h" 36 #include "core/accessibility/AXObjectCache.h"
37 #include "core/animation/DocumentTimeline.h" 37 #include "core/animation/DocumentTimeline.h"
38 #include "core/animation/css/CSSAnimations.h" 38 #include "core/animation/css/CSSAnimations.h"
39 #include "core/css/CSSImageValue.h"
39 #include "core/css/CSSStyleSheet.h" 40 #include "core/css/CSSStyleSheet.h"
40 #include "core/css/CSSValuePool.h" 41 #include "core/css/CSSValuePool.h"
41 #include "core/css/PropertySetCSSStyleDeclaration.h" 42 #include "core/css/PropertySetCSSStyleDeclaration.h"
42 #include "core/css/StylePropertySet.h" 43 #include "core/css/StylePropertySet.h"
43 #include "core/css/parser/BisonCSSParser.h" 44 #include "core/css/parser/BisonCSSParser.h"
44 #include "core/css/resolver/StyleResolver.h" 45 #include "core/css/resolver/StyleResolver.h"
45 #include "core/dom/Attr.h" 46 #include "core/dom/Attr.h"
46 #include "core/dom/CSSSelectorWatch.h" 47 #include "core/dom/CSSSelectorWatch.h"
47 #include "core/dom/ClientRect.h" 48 #include "core/dom/ClientRect.h"
48 #include "core/dom/ClientRectList.h" 49 #include "core/dom/ClientRectList.h"
(...skipping 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 // Do not dispatch a DOMSubtreeModified event here; see bug 81141. 3047 // Do not dispatch a DOMSubtreeModified event here; see bug 81141.
3047 } 3048 }
3048 3049
3049 void Element::didRemoveAttribute(const QualifiedName& name) 3050 void Element::didRemoveAttribute(const QualifiedName& name)
3050 { 3051 {
3051 attributeChanged(name, nullAtom); 3052 attributeChanged(name, nullAtom);
3052 InspectorInstrumentation::didRemoveDOMAttr(this, name.localName()); 3053 InspectorInstrumentation::didRemoveDOMAttr(this, name.localName());
3053 dispatchSubtreeModifiedEvent(); 3054 dispatchSubtreeModifiedEvent();
3054 } 3055 }
3055 3056
3057 static bool needsURLResolutionForInlineStyle(const Element& element, const Docum ent& oldDocument, const Document& newDocument)
3058 {
3059 if (oldDocument == newDocument)
3060 return false;
3061 if (oldDocument.baseURL() == newDocument.baseURL())
3062 return false;
3063 const StylePropertySet* style = element.inlineStyle();
3064 if (!style)
3065 return false;
3066 for (unsigned i = 0; i < style->propertyCount(); ++i) {
3067 // FIXME: Should handle all URL-based properties: CSSImageSetValue, CSSC ursorImageValue, etc.
3068 if (style->propertyAt(i).value()->isImageValue())
3069 return true;
3070 }
3071 return false;
3072 }
3073
3074 static void reResolveURLsInInlineStyle(const Document& document, MutableStylePro pertySet& style)
3075 {
3076 for (unsigned i = 0; i < style.propertyCount(); ++i) {
3077 StylePropertySet::PropertyReference property = style.propertyAt(i);
3078 // FIXME: Should handle all URL-based properties: CSSImageSetValue, CSSC ursorImageValue, etc.
3079 if (property.value()->isImageValue())
3080 toCSSImageValue(property.value())->reResolveURL(document);
3081 }
3082 }
3083
3056 void Element::didMoveToNewDocument(Document& oldDocument) 3084 void Element::didMoveToNewDocument(Document& oldDocument)
3057 { 3085 {
3058 Node::didMoveToNewDocument(oldDocument); 3086 Node::didMoveToNewDocument(oldDocument);
3059 3087
3060 // If the documents differ by quirks mode then they differ by case sensitivi ty 3088 // If the documents differ by quirks mode then they differ by case sensitivi ty
3061 // 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
3062 // to pick up the new casing in the ElementData. 3090 // to pick up the new casing in the ElementData.
3063 if (oldDocument.inQuirksMode() != document().inQuirksMode()) { 3091 if (oldDocument.inQuirksMode() != document().inQuirksMode()) {
3064 if (hasID()) 3092 if (hasID())
3065 setIdAttribute(getIdAttribute()); 3093 setIdAttribute(getIdAttribute());
3066 if (hasClass()) 3094 if (hasClass())
3067 setAttribute(HTMLNames::classAttr, getClassAttribute()); 3095 setAttribute(HTMLNames::classAttr, getClassAttribute());
3068 } 3096 }
3097
3098 if (needsURLResolutionForInlineStyle(*this, oldDocument, document()))
3099 reResolveURLsInInlineStyle(document(), *ensureMutableInlineStyle());
3069 } 3100 }
3070 3101
3071 void Element::updateNamedItemRegistration(const AtomicString& oldName, const Ato micString& newName) 3102 void Element::updateNamedItemRegistration(const AtomicString& oldName, const Ato micString& newName)
3072 { 3103 {
3073 if (!document().isHTMLDocument()) 3104 if (!document().isHTMLDocument())
3074 return; 3105 return;
3075 3106
3076 if (!oldName.isEmpty()) 3107 if (!oldName.isEmpty())
3077 toHTMLDocument(document()).removeNamedItem(oldName); 3108 toHTMLDocument(document()).removeNamedItem(oldName);
3078 3109
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 if (other.hasClass() || other.hasID()) 3270 if (other.hasClass() || other.hasID())
3240 ownerDocumentsHaveDifferentCaseSensitivity = other.document().inQuirksMo de() != document().inQuirksMode(); 3271 ownerDocumentsHaveDifferentCaseSensitivity = other.document().inQuirksMo de() != document().inQuirksMode();
3241 3272
3242 // If 'other' has a mutable ElementData, convert it to an immutable one so w e can share it between both elements. 3273 // If 'other' has a mutable ElementData, convert it to an immutable one so w e can share it between both elements.
3243 // We can only do this if there are no presentation attributes and sharing t he data won't result in different case sensitivity of class or id. 3274 // We can only do this if there are no presentation attributes and sharing t he data won't result in different case sensitivity of class or id.
3244 if (other.m_elementData->isUnique() 3275 if (other.m_elementData->isUnique()
3245 && !ownerDocumentsHaveDifferentCaseSensitivity 3276 && !ownerDocumentsHaveDifferentCaseSensitivity
3246 && !other.m_elementData->presentationAttributeStyle()) 3277 && !other.m_elementData->presentationAttributeStyle())
3247 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem entData*>(other.m_elementData.get())->makeShareableCopy(); 3278 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem entData*>(other.m_elementData.get())->makeShareableCopy();
3248 3279
3249 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity) 3280 if (!other.m_elementData->isUnique() && !ownerDocumentsHaveDifferentCaseSens itivity && !needsURLResolutionForInlineStyle(other, other.document(), document() ))
3250 m_elementData = other.m_elementData; 3281 m_elementData = other.m_elementData;
3251 else 3282 else
3252 m_elementData = other.m_elementData->makeUniqueCopy(); 3283 m_elementData = other.m_elementData->makeUniqueCopy();
3253 3284
3254 unsigned length = m_elementData->length(); 3285 unsigned length = m_elementData->length();
3255 for (unsigned i = 0; i < length; ++i) { 3286 for (unsigned i = 0; i < length; ++i) {
3256 const Attribute* attribute = const_cast<const ElementData*>(m_elementDat a.get())->attributeItem(i); 3287 const Attribute* attribute = const_cast<const ElementData*>(m_elementDat a.get())->attributeItem(i);
3257 attributeChangedFromParserOrByCloning(attribute->name(), attribute->valu e(), ModifiedByCloning); 3288 attributeChangedFromParserOrByCloning(attribute->name(), attribute->valu e(), ModifiedByCloning);
3258 } 3289 }
3259 } 3290 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 // 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
3511 // 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
3512 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3543 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3513 return false; 3544 return false;
3514 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3545 if (FullscreenElementStack::isActiveFullScreenElement(this))
3515 return false; 3546 return false;
3516 return true; 3547 return true;
3517 } 3548 }
3518 3549
3519 } // namespace WebCore 3550 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/parser/BisonCSSParser-in.cpp ('k') | Source/core/html/HTMLBodyElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698