| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 2 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 3 * Copyright (C) 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above | 9 * 1. Redistributions of source code must retain the above |
| 10 * copyright notice, this list of conditions and the following | 10 * copyright notice, this list of conditions and the following |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
| 26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
| 27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 * SUCH DAMAGE. | 28 * SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/css/WebKitCSSViewportRule.h" | 32 #include "core/css/CSSViewportRule.h" |
| 33 | 33 |
| 34 #if ENABLE(CSS_DEVICE_ADAPTATION) | 34 #if ENABLE(CSS_DEVICE_ADAPTATION) |
| 35 | 35 |
| 36 #include "core/css/PropertySetCSSStyleDeclaration.h" | 36 #include "core/css/PropertySetCSSStyleDeclaration.h" |
| 37 #include "core/css/StylePropertySet.h" | 37 #include "core/css/StylePropertySet.h" |
| 38 #include "core/css/StyleRule.h" | 38 #include "core/css/StyleRule.h" |
| 39 #include "core/dom/WebCoreMemoryInstrumentation.h" | 39 #include "core/dom/WebCoreMemoryInstrumentation.h" |
| 40 #include <wtf/text/StringBuilder.h> | 40 #include "wtf/text/StringBuilder.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 WebKitCSSViewportRule::WebKitCSSViewportRule(StyleRuleViewport* viewportRule, CS
SStyleSheet* sheet) | 44 CSSViewportRule::CSSViewportRule(StyleRuleViewport* viewportRule, CSSStyleSheet*
sheet) |
| 45 : CSSRule(sheet) | 45 : CSSRule(sheet) |
| 46 , m_viewportRule(viewportRule) | 46 , m_viewportRule(viewportRule) |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 WebKitCSSViewportRule::~WebKitCSSViewportRule() | 50 CSSViewportRule::~CSSViewportRule() |
| 51 { | 51 { |
| 52 if (m_propertiesCSSOMWrapper) | 52 if (m_propertiesCSSOMWrapper) |
| 53 m_propertiesCSSOMWrapper->clearParentRule(); | 53 m_propertiesCSSOMWrapper->clearParentRule(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 CSSStyleDeclaration* WebKitCSSViewportRule::style() const | 56 CSSStyleDeclaration* CSSViewportRule::style() const |
| 57 { | 57 { |
| 58 if (!m_propertiesCSSOMWrapper) | 58 if (!m_propertiesCSSOMWrapper) |
| 59 m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_viewpo
rtRule->mutableProperties(), const_cast<WebKitCSSViewportRule*>(this)); | 59 m_propertiesCSSOMWrapper = StyleRuleCSSStyleDeclaration::create(m_viewpo
rtRule->mutableProperties(), const_cast<CSSViewportRule*>(this)); |
| 60 | 60 |
| 61 return m_propertiesCSSOMWrapper.get(); | 61 return m_propertiesCSSOMWrapper.get(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 String WebKitCSSViewportRule::cssText() const | 64 String CSSViewportRule::cssText() const |
| 65 { | 65 { |
| 66 StringBuilder result; | 66 StringBuilder result; |
| 67 result.appendLiteral("@-webkit-viewport { "); | 67 result.appendLiteral("@-webkit-viewport { "); |
| 68 | 68 |
| 69 String decls = m_viewportRule->properties()->asText(); | 69 String decls = m_viewportRule->properties()->asText(); |
| 70 result.append(decls); | 70 result.append(decls); |
| 71 if (!decls.isEmpty()) | 71 if (!decls.isEmpty()) |
| 72 result.append(' '); | 72 result.append(' '); |
| 73 | 73 |
| 74 result.append('}'); | 74 result.append('}'); |
| 75 | 75 |
| 76 return result.toString(); | 76 return result.toString(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void WebKitCSSViewportRule::reattach(StyleRuleBase* rule) | 79 void CSSViewportRule::reattach(StyleRuleBase* rule) |
| 80 { | 80 { |
| 81 ASSERT(rule); | 81 ASSERT(rule); |
| 82 ASSERT_WITH_SECURITY_IMPLICATION(rule->isViewportRule()); | 82 ASSERT_WITH_SECURITY_IMPLICATION(rule->isViewportRule()); |
| 83 m_viewportRule = static_cast<StyleRuleViewport*>(rule); | 83 m_viewportRule = static_cast<StyleRuleViewport*>(rule); |
| 84 | 84 |
| 85 if (m_propertiesCSSOMWrapper) | 85 if (m_propertiesCSSOMWrapper) |
| 86 m_propertiesCSSOMWrapper->reattach(m_viewportRule->mutableProperties()); | 86 m_propertiesCSSOMWrapper->reattach(m_viewportRule->mutableProperties()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void WebKitCSSViewportRule::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo
) const | 89 void CSSViewportRule::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) cons
t |
| 90 { | 90 { |
| 91 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); | 91 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); |
| 92 CSSRule::reportMemoryUsage(memoryObjectInfo); | 92 CSSRule::reportMemoryUsage(memoryObjectInfo); |
| 93 info.addMember(m_viewportRule, "viewportRule"); | 93 info.addMember(m_viewportRule, "viewportRule"); |
| 94 info.addMember(m_propertiesCSSOMWrapper, "propertiesCSSOMWrapper"); | 94 info.addMember(m_propertiesCSSOMWrapper, "propertiesCSSOMWrapper"); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace WebCore | 97 } // namespace WebCore |
| 98 | 98 |
| 99 #endif // ENABLE(CSS_DEVICE_ADAPTATION) | 99 #endif // ENABLE(CSS_DEVICE_ADAPTATION) |
| OLD | NEW |