eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 1 | /* |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 | * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 | * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 | * (C) 2001 Dirk Mueller (mueller@kde.org) |
fpizlo@apple.com | 197cd32 | 2018-03-17 06:11:00 +0000 | [diff] [blame] | 6 | * Copyright (C) 2003-2018 Apple Inc. All rights reserved. |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Library General Public |
| 10 | * License as published by the Free Software Foundation; either |
| 11 | * version 2 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Library General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Library General Public License |
| 19 | * along with this library; see the file COPYING.LIB. If not, write to |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 | * Boston, MA 02110-1301, USA. |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 22 | * |
| 23 | */ |
| 24 | |
commit-queue@webkit.org | d862d77 | 2016-10-31 22:07:53 +0000 | [diff] [blame] | 25 | #pragma once |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 26 | |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 27 | #include "CSSPrimitiveValue.h" |
| 28 | #include "CSSPropertyNames.h" |
alexis@webkit.org | 71873a0 | 2013-06-19 22:07:23 +0000 | [diff] [blame] | 29 | #include "CSSValueKeywords.h" |
darin | a51de91 | 2007-04-29 20:32:51 +0000 | [diff] [blame] | 30 | #include "Element.h" |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 31 | |
| 32 | namespace WebCore { |
| 33 | |
weinig@apple.com | c360893 | 2010-05-19 17:48:06 +0000 | [diff] [blame] | 34 | class Attribute; |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 35 | class MutableStyleProperties; |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 36 | class PropertySetCSSStyleDeclaration; |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 37 | class StyleProperties; |
justin_michaud@apple.com | 51c20fe | 2018-12-18 18:51:05 +0000 | [diff] [blame] | 38 | class StylePropertyMap; |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 39 | |
darin | a51de91 | 2007-04-29 20:32:51 +0000 | [diff] [blame] | 40 | class StyledElement : public Element { |
fpizlo@apple.com | 197cd32 | 2018-03-17 06:11:00 +0000 | [diff] [blame] | 41 | WTF_MAKE_ISO_ALLOCATED(StyledElement); |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 42 | public: |
kling@webkit.org | 1d8f6e1 | 2012-06-29 17:20:19 +0000 | [diff] [blame] | 43 | virtual ~StyledElement(); |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 44 | |
antti@apple.com | 0f60f38 | 2016-03-08 18:11:17 +0000 | [diff] [blame] | 45 | virtual const StyleProperties* additionalPresentationAttributeStyle() const { return nullptr; } |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 46 | void invalidateStyleAttribute(); |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 47 | |
hs85.jeong@samsung.com | a08a0ad | 2015-11-03 18:24:34 +0000 | [diff] [blame] | 48 | const StyleProperties* inlineStyle() const { return elementData() ? elementData()->m_inlineStyle.get() : nullptr; } |
antti@apple.com | 85635f0 | 2012-02-16 07:39:17 +0000 | [diff] [blame] | 49 | |
alexis@webkit.org | 71873a0 | 2013-06-19 22:07:23 +0000 | [diff] [blame] | 50 | bool setInlineStyleProperty(CSSPropertyID, CSSValueID identifier, bool important = false); |
| 51 | bool setInlineStyleProperty(CSSPropertyID, CSSPropertyID identifier, bool important = false); |
simon.fraser@apple.com | 094a874 | 2019-11-13 04:41:17 +0000 | [diff] [blame] | 52 | WEBCORE_EXPORT bool setInlineStyleProperty(CSSPropertyID, double value, CSSUnitType, bool important = false); |
achristensen@apple.com | 985685e | 2014-08-22 04:21:18 +0000 | [diff] [blame] | 53 | WEBCORE_EXPORT bool setInlineStyleProperty(CSSPropertyID, const String& value, bool important = false); |
alexis.menard@openbossa.org | 51f64bf | 2012-04-03 14:18:19 +0000 | [diff] [blame] | 54 | bool removeInlineStyleProperty(CSSPropertyID); |
tasak@google.com | 5d47185 | 2012-11-06 11:33:07 +0000 | [diff] [blame] | 55 | void removeAllInlineStyleProperties(); |
akling@apple.com | 82cfd35 | 2013-02-16 23:34:22 +0000 | [diff] [blame] | 56 | |
benjamin@webkit.org | 99a1aad | 2014-02-11 02:41:00 +0000 | [diff] [blame] | 57 | static void synchronizeStyleAttributeInternal(StyledElement*); |
| 58 | void synchronizeStyleAttributeInternal() const { StyledElement::synchronizeStyleAttributeInternal(const_cast<StyledElement*>(this)); } |
antti@apple.com | 85635f0 | 2012-02-16 07:39:17 +0000 | [diff] [blame] | 59 | |
cdumez@apple.com | ea20d74 | 2017-05-08 16:50:46 +0000 | [diff] [blame] | 60 | WEBCORE_EXPORT CSSStyleDeclaration& cssomStyle(); |
justin_michaud@apple.com | 51c20fe | 2018-12-18 18:51:05 +0000 | [diff] [blame] | 61 | #if ENABLE(CSS_TYPED_OM) |
| 62 | StylePropertyMap& ensureAttributeStyleMap(); |
| 63 | #endif |
kling@webkit.org | 557087f | 2011-12-01 22:22:41 +0000 | [diff] [blame] | 64 | |
antti@apple.com | 0f60f38 | 2016-03-08 18:11:17 +0000 | [diff] [blame] | 65 | const StyleProperties* presentationAttributeStyle() const; |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 66 | virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomString&, MutableStyleProperties&) { } |
kling@webkit.org | 737834a | 2012-03-12 18:51:32 +0000 | [diff] [blame] | 67 | |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 68 | protected: |
weinig@apple.com | dedf67e | 2013-09-15 05:23:01 +0000 | [diff] [blame] | 69 | StyledElement(const QualifiedName& name, Document& document, ConstructionType type) |
weinig@apple.com | c461682 | 2013-09-15 17:10:27 +0000 | [diff] [blame] | 70 | : Element(name, document, type) |
akling@apple.com | 5032c67 | 2012-11-18 20:25:01 +0000 | [diff] [blame] | 71 | { |
| 72 | } |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 73 | |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 74 | void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason = ModifiedDirectly) override; |
bdakin | e2a4f1a | 2006-12-20 00:32:37 +0000 | [diff] [blame] | 75 | |
kling@webkit.org | 44bc0dd | 2012-02-28 22:21:02 +0000 | [diff] [blame] | 76 | virtual bool isPresentationAttribute(const QualifiedName&) const { return false; } |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 77 | |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 78 | void addPropertyToPresentationAttributeStyle(MutableStyleProperties&, CSSPropertyID, CSSValueID identifier); |
simon.fraser@apple.com | 094a874 | 2019-11-13 04:41:17 +0000 | [diff] [blame] | 79 | void addPropertyToPresentationAttributeStyle(MutableStyleProperties&, CSSPropertyID, double value, CSSUnitType); |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 80 | void addPropertyToPresentationAttributeStyle(MutableStyleProperties&, CSSPropertyID, const String& value); |
antti@apple.com | 708a278 | 2012-02-21 13:49:15 +0000 | [diff] [blame] | 81 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 82 | void addSubresourceAttributeURLs(ListHashSet<URL>&) const override; |
ddkilzer@apple.com | e9a5504 | 2008-12-23 00:00:14 +0000 | [diff] [blame] | 83 | |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 84 | private: |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 85 | void styleAttributeChanged(const AtomString& newStyleString, AttributeModificationReason); |
akling@apple.com | 191b9bc | 2012-11-17 01:34:36 +0000 | [diff] [blame] | 86 | |
antti@apple.com | 85635f0 | 2012-02-16 07:39:17 +0000 | [diff] [blame] | 87 | void inlineStyleChanged(); |
kling@webkit.org | d3ce8af | 2012-11-14 05:39:17 +0000 | [diff] [blame] | 88 | PropertySetCSSStyleDeclaration* inlineStyleCSSOMWrapper(); |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 89 | void setInlineStyleFromString(const AtomString&); |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 90 | MutableStyleProperties& ensureMutableInlineStyle(); |
leviw@chromium.org | 8bf28cc | 2012-01-29 23:41:33 +0000 | [diff] [blame] | 91 | |
kling@webkit.org | 569556d | 2012-11-12 23:52:12 +0000 | [diff] [blame] | 92 | void rebuildPresentationAttributeStyle(); |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
antti@apple.com | 0f60f38 | 2016-03-08 18:11:17 +0000 | [diff] [blame] | 95 | inline const StyleProperties* StyledElement::presentationAttributeStyle() const |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 96 | { |
akling@apple.com | 72dde2a3 | 2013-02-13 21:48:40 +0000 | [diff] [blame] | 97 | if (!elementData()) |
cdumez@apple.com | ebb5c27 | 2014-09-29 17:35:28 +0000 | [diff] [blame] | 98 | return nullptr; |
benjamin@webkit.org | 23ab9cf | 2014-01-18 22:17:09 +0000 | [diff] [blame] | 99 | if (elementData()->presentationAttributeStyleIsDirty()) |
antti@apple.com | 0f60f38 | 2016-03-08 18:11:17 +0000 | [diff] [blame] | 100 | const_cast<StyledElement&>(*this).rebuildPresentationAttributeStyle(); |
akling@apple.com | 72dde2a3 | 2013-02-13 21:48:40 +0000 | [diff] [blame] | 101 | return elementData()->presentationAttributeStyle(); |
kling@webkit.org | 8b0e843 | 2012-02-11 19:29:49 +0000 | [diff] [blame] | 102 | } |
| 103 | |
cdumez@apple.com | 3e58f0f | 2014-09-30 21:32:55 +0000 | [diff] [blame] | 104 | } // namespace WebCore |
weinig@apple.com | 65ea5f3 | 2013-10-06 19:18:54 +0000 | [diff] [blame] | 105 | |
cdumez@apple.com | 3e58f0f | 2014-09-30 21:32:55 +0000 | [diff] [blame] | 106 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyledElement) |
| 107 | static bool isType(const WebCore::Node& node) { return node.isStyledElement(); } |
| 108 | SPECIALIZE_TYPE_TRAITS_END() |