Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 4 | * Copyright (C) 2013 Google Inc. All rights reserved. |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Library General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Library General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Library General Public License |
| 17 | * along with this library; see the file COPYING.LIB. If not, write to |
| 18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #ifndef ElementStyleResources_h |
| 24 | #define ElementStyleResources_h |
| 25 | |
| 26 | #include "CSSPropertyNames.h" |
| 27 | #include "core/css/CSSSVGDocumentValue.h" |
| 28 | #include "core/css/CSSValue.h" |
| 29 | #include "wtf/HashMap.h" |
| 30 | |
| 31 | namespace WebCore { |
| 32 | |
| 33 | class FilterOperation; |
| 34 | |
| 35 | typedef HashMap<FilterOperation*, RefPtr<CSSSVGDocumentValue> > PendingSVGDocumentMap; |
| 36 | typedef HashMap<CSSPropertyID, RefPtr<CSSValue> > PendingImagePropertyMap; |
| 37 | |
| 38 | // Holds information about resources, requested by stylesheets. |
| 39 | // Lifetime: per-element style resolve. |
| 40 | // FIXME: At least for the moment, the lifetime actually matches that of StyleResolverState, |
| 41 | // but all data is cleared for each element resolve. We must investigate performance |
| 42 | // implications of matching effective and intended lifetime. |
| 43 | class ElementStyleResources { |
| 44 | WTF_MAKE_NONCOPYABLE(ElementStyleResources); |
| 45 | public: |
| 46 | ElementStyleResources(); |
| 47 | |
| 48 | const PendingImagePropertyMap& pendingImageProperties() const { return m_pendingImageProperties; } |
| 49 | const PendingSVGDocumentMap& pendingSVGDocuments() const { return m_pendingSVGDocuments; } |
| 50 | |
| 51 | void setHasPendingShaders(bool hasPendingShaders) { m_hasPendingShaders = hasPendingShaders; } |
| 52 | bool hasPendingShaders() const { return m_hasPendingShaders; } |
| 53 | |
| 54 | float deviceScaleFactor() const { return m_deviceScaleFactor; } |
| 55 | void setDeviceScaleFactor(float deviceScaleFactor) { m_deviceScaleFactor = deviceScaleFactor; } |
| 56 | |
| 57 | void addPendingImageProperty(const CSSPropertyID&, CSSValue*); |
| 58 | void addPendingSVGDocument(FilterOperation*, CSSSVGDocumentValue*); |
| 59 | |
| 60 | void clear(); |
| 61 | |
| 62 | private: |
| 63 | PendingImagePropertyMap m_pendingImageProperties; |
| 64 | PendingSVGDocumentMap m_pendingSVGDocuments; |
| 65 | bool m_hasPendingShaders; |
| 66 | float m_deviceScaleFactor; |
| 67 | }; |
| 68 | |
| 69 | } // namespace WebCore |
| 70 | |
| 71 | #endif // ElementStyleResources_h |