Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: sky/engine/core/css/CSSCursorImageValue.cpp

Issue 1076623002: Remove our impressive amount of CSS Cursor code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2006 Rob Buis <buis@kde.org>
3 * (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2008 Apple 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 #include "sky/engine/config.h"
23 #include "sky/engine/core/css/CSSCursorImageValue.h"
24
25 #include "sky/engine/core/css/CSSImageSetValue.h"
26 #include "sky/engine/core/fetch/ImageResource.h"
27 #include "sky/engine/core/fetch/ResourceFetcher.h"
28 #include "sky/engine/core/rendering/style/StyleFetchedImage.h"
29 #include "sky/engine/core/rendering/style/StyleFetchedImageSet.h"
30 #include "sky/engine/core/rendering/style/StyleImage.h"
31 #include "sky/engine/core/rendering/style/StylePendingImage.h"
32 #include "sky/engine/wtf/MathExtras.h"
33 #include "sky/engine/wtf/text/StringBuilder.h"
34 #include "sky/engine/wtf/text/WTFString.h"
35
36 namespace blink {
37
38 CSSCursorImageValue::CSSCursorImageValue(PassRefPtr<CSSValue> imageValue, bool h asHotSpot, const IntPoint& hotSpot)
39 : CSSValue(CursorImageClass)
40 , m_imageValue(imageValue)
41 , m_hasHotSpot(hasHotSpot)
42 , m_hotSpot(hotSpot)
43 , m_accessedImage(false)
44 {
45 }
46
47 CSSCursorImageValue::~CSSCursorImageValue()
48 {
49 // The below teardown is all handled by weak pointer processing in oilpan.
50 #if !ENABLE(OILPAN)
51 if (!isSVGCursor())
52 return;
53 #endif
54 }
55
56 String CSSCursorImageValue::customCSSText() const
57 {
58 StringBuilder result;
59 result.append(m_imageValue->cssText());
60 if (m_hasHotSpot) {
61 result.append(' ');
62 result.appendNumber(m_hotSpot.x());
63 result.append(' ');
64 result.appendNumber(m_hotSpot.y());
65 }
66 return result.toString();
67 }
68
69 StyleImage* CSSCursorImageValue::cachedImage(ResourceFetcher* loader, float devi ceScaleFactor)
70 {
71 if (m_imageValue->isImageSetValue())
72 return toCSSImageSetValue(m_imageValue.get())->cachedImageSet(loader, de viceScaleFactor);
73
74 if (!m_accessedImage) {
75 m_accessedImage = true;
76
77 if (m_imageValue->isImageValue())
78 m_image = toCSSImageValue(m_imageValue.get())->cachedImage(loader);
79 }
80
81 if (m_image && m_image->isImageResource())
82 return toStyleFetchedImage(m_image);
83 return 0;
84 }
85
86 StyleImage* CSSCursorImageValue::cachedOrPendingImage(float deviceScaleFactor)
87 {
88 // Need to delegate completely so that changes in device scale factor can be handled appropriately.
89 if (m_imageValue->isImageSetValue())
90 return toCSSImageSetValue(m_imageValue.get())->cachedOrPendingImageSet(d eviceScaleFactor);
91
92 if (!m_image)
93 m_image = StylePendingImage::create(this);
94
95 return m_image.get();
96 }
97
98 bool CSSCursorImageValue::isSVGCursor() const
99 {
100 if (m_imageValue->isImageValue()) {
101 RefPtr<CSSImageValue> imageValue = toCSSImageValue(m_imageValue.get());
102 KURL kurl(ParsedURLString, imageValue->url());
103 return kurl.hasFragmentIdentifier();
104 }
105 return false;
106 }
107
108 String CSSCursorImageValue::cachedImageURL()
109 {
110 if (!m_image || !m_image->isImageResource())
111 return String();
112 return toStyleFetchedImage(m_image)->cachedImage()->url().string();
113 }
114
115 void CSSCursorImageValue::clearImageResource()
116 {
117 m_image = nullptr;
118 m_accessedImage = false;
119 }
120
121 bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const
122 {
123 return m_hasHotSpot ? other.m_hasHotSpot && m_hotSpot == other.m_hotSpot : ! other.m_hasHotSpot
124 && compareCSSValuePtr(m_imageValue, other.m_imageValue);
125 }
126
127 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/CSSCursorImageValue.h ('k') | sky/engine/core/css/CSSPrimitiveValueMappings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698