| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/css/CSSCanvasValue.h" | 27 #include "core/css/CSSCanvasValue.h" |
| 28 | 28 |
| 29 #include "core/rendering/RenderObject.h" | 29 #include "core/layout/LayoutObject.h" |
| 30 #include "wtf/text/StringBuilder.h" | 30 #include "wtf/text/StringBuilder.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 CSSCanvasValue::~CSSCanvasValue() | 34 CSSCanvasValue::~CSSCanvasValue() |
| 35 { | 35 { |
| 36 #if !ENABLE(OILPAN) | 36 #if !ENABLE(OILPAN) |
| 37 if (m_element) | 37 if (m_element) |
| 38 m_element->removeObserver(m_canvasObserver.get()); | 38 m_element->removeObserver(m_canvasObserver.get()); |
| 39 #endif | 39 #endif |
| 40 } | 40 } |
| 41 | 41 |
| 42 String CSSCanvasValue::customCSSText() const | 42 String CSSCanvasValue::customCSSText() const |
| 43 { | 43 { |
| 44 StringBuilder result; | 44 StringBuilder result; |
| 45 result.appendLiteral("-webkit-canvas("); | 45 result.appendLiteral("-webkit-canvas("); |
| 46 result.append(m_name); | 46 result.append(m_name); |
| 47 result.append(')'); | 47 result.append(')'); |
| 48 return result.toString(); | 48 return result.toString(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void CSSCanvasValue::canvasChanged(HTMLCanvasElement*, const FloatRect& changedR
ect) | 51 void CSSCanvasValue::canvasChanged(HTMLCanvasElement*, const FloatRect& changedR
ect) |
| 52 { | 52 { |
| 53 IntRect imageChangeRect = enclosingIntRect(changedRect); | 53 IntRect imageChangeRect = enclosingIntRect(changedRect); |
| 54 for (const auto& curr : clients()) | 54 for (const auto& curr : clients()) |
| 55 const_cast<RenderObject*>(curr.key)->imageChanged(static_cast<WrappedIma
gePtr>(this), &imageChangeRect); | 55 const_cast<LayoutObject*>(curr.key)->imageChanged(static_cast<WrappedIma
gePtr>(this), &imageChangeRect); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CSSCanvasValue::canvasResized(HTMLCanvasElement*) | 58 void CSSCanvasValue::canvasResized(HTMLCanvasElement*) |
| 59 { | 59 { |
| 60 for (const auto& curr : clients()) | 60 for (const auto& curr : clients()) |
| 61 const_cast<RenderObject*>(curr.key)->imageChanged(static_cast<WrappedIma
gePtr>(this)); | 61 const_cast<LayoutObject*>(curr.key)->imageChanged(static_cast<WrappedIma
gePtr>(this)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 #if !ENABLE(OILPAN) | 64 #if !ENABLE(OILPAN) |
| 65 void CSSCanvasValue::canvasDestroyed(HTMLCanvasElement* element) | 65 void CSSCanvasValue::canvasDestroyed(HTMLCanvasElement* element) |
| 66 { | 66 { |
| 67 ASSERT_UNUSED(element, element == m_element); | 67 ASSERT_UNUSED(element, element == m_element); |
| 68 m_element = nullptr; | 68 m_element = nullptr; |
| 69 } | 69 } |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 IntSize CSSCanvasValue::fixedSize(const RenderObject* renderer) | 72 IntSize CSSCanvasValue::fixedSize(const LayoutObject* renderer) |
| 73 { | 73 { |
| 74 if (HTMLCanvasElement* elt = element(&renderer->document())) | 74 if (HTMLCanvasElement* elt = element(&renderer->document())) |
| 75 return IntSize(elt->width(), elt->height()); | 75 return IntSize(elt->width(), elt->height()); |
| 76 return IntSize(); | 76 return IntSize(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 HTMLCanvasElement* CSSCanvasValue::element(Document* document) | 79 HTMLCanvasElement* CSSCanvasValue::element(Document* document) |
| 80 { | 80 { |
| 81 if (!m_element) { | 81 if (!m_element) { |
| 82 m_element = &document->getCSSCanvasElement(m_name); | 82 m_element = &document->getCSSCanvasElement(m_name); |
| 83 m_element->addObserver(m_canvasObserver.get()); | 83 m_element->addObserver(m_canvasObserver.get()); |
| 84 } | 84 } |
| 85 return m_element; | 85 return m_element; |
| 86 } | 86 } |
| 87 | 87 |
| 88 PassRefPtr<Image> CSSCanvasValue::image(RenderObject* renderer, const IntSize& /
*size*/) | 88 PassRefPtr<Image> CSSCanvasValue::image(LayoutObject* renderer, const IntSize& /
*size*/) |
| 89 { | 89 { |
| 90 ASSERT(clients().contains(renderer)); | 90 ASSERT(clients().contains(renderer)); |
| 91 HTMLCanvasElement* elt = element(&renderer->document()); | 91 HTMLCanvasElement* elt = element(&renderer->document()); |
| 92 if (!elt) | 92 if (!elt) |
| 93 return nullptr; | 93 return nullptr; |
| 94 return elt->copiedImage(FrontBuffer); | 94 return elt->copiedImage(FrontBuffer); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool CSSCanvasValue::equals(const CSSCanvasValue& other) const | 97 bool CSSCanvasValue::equals(const CSSCanvasValue& other) const |
| 98 { | 98 { |
| 99 return m_name == other.m_name; | 99 return m_name == other.m_name; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void CSSCanvasValue::traceAfterDispatch(Visitor* visitor) | 102 void CSSCanvasValue::traceAfterDispatch(Visitor* visitor) |
| 103 { | 103 { |
| 104 visitor->trace(m_canvasObserver); | 104 visitor->trace(m_canvasObserver); |
| 105 visitor->trace(m_element); | 105 visitor->trace(m_element); |
| 106 CSSImageGeneratorValue::traceAfterDispatch(visitor); | 106 CSSImageGeneratorValue::traceAfterDispatch(visitor); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace blink | 109 } // namespace blink |
| OLD | NEW |