source: webkit/trunk/Source/WebCore/css/CSSCanvasValue.cpp

Last change on this file was 278253, checked in by Darin Adler, 4 years ago

Remove WTF::Optional synonym for std::optional, using that class template directly instead
https://bugs.webkit.org/show_bug.cgi?id=226433

Reviewed by Chris Dumez.

Source/JavaScriptCore:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:

(ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead
of Optional<>. Also use * instead of value() and nest the definition of the local inside an if
statement in the case where it's an optional.

  • inspector/scripts/tests/expected/*: Regenerated these results.

Source/WebCore:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebCore/PAL:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebDriver:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebKit:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • Scripts/webkit/tests: Regenerated expected results, by running the command "python

Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?)

Source/WebKitLegacy/ios:

  • WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename

Optional<> to std::optional<>.

Source/WebKitLegacy/mac:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebKitLegacy/win:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WTF:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • wtf/Optional.h: Remove WTF::Optional.

Tools:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
24 */
25
26#include "config.h"
27#include "CSSCanvasValue.h"
28
29#include "RenderElement.h"
30
31namespace WebCore {
32
33CSSCanvasValue::~CSSCanvasValue()
34{
35 if (m_element)
36 m_element->removeObserver(m_canvasObserver);
37}
38
39String CSSCanvasValue::customCSSText() const
40{
41 return makeString("-webkit-canvas(", m_name, ')');
42}
43
44void CSSCanvasValue::canvasChanged(HTMLCanvasElement&, const std::optional<FloatRect>& changedRect)
45{
46 if (!changedRect)
47 return;
48
49 auto imageChangeRect = enclosingIntRect(changedRect.value());
50 for (auto it = clients().begin(), end = clients().end(); it != end; ++it)
51 it->key->imageChanged(static_cast<WrappedImagePtr>(this), &imageChangeRect);
52}
53
54void CSSCanvasValue::canvasResized(HTMLCanvasElement&)
55{
56 for (auto it = clients().begin(), end = clients().end(); it != end; ++it)
57 it->key->imageChanged(static_cast<WrappedImagePtr>(this));
58}
59
60void CSSCanvasValue::canvasDestroyed(HTMLCanvasElement& element)
61{
62 ASSERT_UNUSED(&element, &element == m_element);
63 m_element = nullptr;
64}
65
66FloatSize CSSCanvasValue::fixedSize(const RenderElement& renderer)
67{
68 if (HTMLCanvasElement* elt = element(renderer.document()))
69 return FloatSize(elt->width(), elt->height());
70 return { };
71}
72
73HTMLCanvasElement* CSSCanvasValue::element(Document& document)
74{
75 if (!m_element) {
76 m_element = document.getCSSCanvasElement(m_name);
77 if (!m_element)
78 return nullptr;
79 m_element->addObserver(m_canvasObserver);
80 }
81 return m_element;
82}
83
84RefPtr<Image> CSSCanvasValue::image(RenderElement& renderer, const FloatSize& /*size*/)
85{
86 ASSERT(clients().contains(&renderer));
87 HTMLCanvasElement* element = this->element(renderer.document());
88 if (!element || !element->buffer())
89 return nullptr;
90 return element->copiedImage();
91}
92
93bool CSSCanvasValue::equals(const CSSCanvasValue& other) const
94{
95 return m_name == other.m_name;
96}
97
98} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.