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

Side by Side Diff: sky/engine/core/css/resolver/StyleResourceLoader.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
« no previous file with comments | « sky/engine/core/css/resolver/StyleBuilderCustom.cpp ('k') | sky/engine/core/frame/FrameView.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 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. 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. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 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 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, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #include "sky/engine/config.h" 23 #include "sky/engine/config.h"
24 #include "sky/engine/core/css/resolver/StyleResourceLoader.h" 24 #include "sky/engine/core/css/resolver/StyleResourceLoader.h"
25 25
26 #include "gen/sky/core/CSSPropertyNames.h" 26 #include "gen/sky/core/CSSPropertyNames.h"
27 #include "sky/engine/core/css/CSSCursorImageValue.h"
28 #include "sky/engine/core/css/CSSImageValue.h" 27 #include "sky/engine/core/css/CSSImageValue.h"
29 #include "sky/engine/core/css/resolver/ElementStyleResources.h" 28 #include "sky/engine/core/css/resolver/ElementStyleResources.h"
30 #include "sky/engine/core/fetch/ResourceFetcher.h" 29 #include "sky/engine/core/fetch/ResourceFetcher.h"
31 #include "sky/engine/core/rendering/style/FillLayer.h" 30 #include "sky/engine/core/rendering/style/FillLayer.h"
32 #include "sky/engine/core/rendering/style/RenderStyle.h" 31 #include "sky/engine/core/rendering/style/RenderStyle.h"
33 #include "sky/engine/core/rendering/style/StyleFetchedImage.h" 32 #include "sky/engine/core/rendering/style/StyleFetchedImage.h"
34 #include "sky/engine/core/rendering/style/StyleFetchedImageSet.h" 33 #include "sky/engine/core/rendering/style/StyleFetchedImageSet.h"
35 #include "sky/engine/core/rendering/style/StyleGeneratedImage.h" 34 #include "sky/engine/core/rendering/style/StyleGeneratedImage.h"
36 #include "sky/engine/core/rendering/style/StylePendingImage.h" 35 #include "sky/engine/core/rendering/style/StylePendingImage.h"
37 36
38 namespace blink { 37 namespace blink {
39 38
40 StyleResourceLoader::StyleResourceLoader(ResourceFetcher* fetcher) 39 StyleResourceLoader::StyleResourceLoader(ResourceFetcher* fetcher)
41 : m_fetcher(fetcher) 40 : m_fetcher(fetcher)
42 { 41 {
43 } 42 }
44 43
45 PassRefPtr<StyleImage> StyleResourceLoader::loadPendingImage(StylePendingImage* pendingImage, float deviceScaleFactor) 44 PassRefPtr<StyleImage> StyleResourceLoader::loadPendingImage(StylePendingImage* pendingImage, float deviceScaleFactor)
46 { 45 {
47 if (CSSImageValue* imageValue = pendingImage->cssImageValue()) 46 if (CSSImageValue* imageValue = pendingImage->cssImageValue())
48 return imageValue->cachedImage(m_fetcher, ResourceFetcher::defaultResour ceOptions()); 47 return imageValue->cachedImage(m_fetcher, ResourceFetcher::defaultResour ceOptions());
49 48
50 if (CSSImageGeneratorValue* imageGeneratorValue 49 if (CSSImageGeneratorValue* imageGeneratorValue
51 = pendingImage->cssImageGeneratorValue()) { 50 = pendingImage->cssImageGeneratorValue()) {
52 imageGeneratorValue->loadSubimages(m_fetcher); 51 imageGeneratorValue->loadSubimages(m_fetcher);
53 return StyleGeneratedImage::create(imageGeneratorValue); 52 return StyleGeneratedImage::create(imageGeneratorValue);
54 } 53 }
55 54
56 if (CSSCursorImageValue* cursorImageValue
57 = pendingImage->cssCursorImageValue())
58 return cursorImageValue->cachedImage(m_fetcher, deviceScaleFactor);
59
60 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue()) 55 if (CSSImageSetValue* imageSetValue = pendingImage->cssImageSetValue())
61 return imageSetValue->cachedImageSet(m_fetcher, deviceScaleFactor, Resou rceFetcher::defaultResourceOptions()); 56 return imageSetValue->cachedImageSet(m_fetcher, deviceScaleFactor, Resou rceFetcher::defaultResourceOptions());
62 57
63 return nullptr; 58 return nullptr;
64 } 59 }
65 60
66 void StyleResourceLoader::loadPendingImages(RenderStyle* style, ElementStyleReso urces& elementStyleResources) 61 void StyleResourceLoader::loadPendingImages(RenderStyle* style, ElementStyleReso urces& elementStyleResources)
67 { 62 {
68 if (elementStyleResources.pendingImageProperties().isEmpty()) 63 if (elementStyleResources.pendingImageProperties().isEmpty())
69 return; 64 return;
70 65
71 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe ndingImageProperties().end().keys(); 66 PendingImagePropertyMap::const_iterator::Keys end = elementStyleResources.pe ndingImageProperties().end().keys();
72 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource s.pendingImageProperties().begin().keys(); it != end; ++it) { 67 for (PendingImagePropertyMap::const_iterator::Keys it = elementStyleResource s.pendingImageProperties().begin().keys(); it != end; ++it) {
73 CSSPropertyID currentProperty = *it; 68 CSSPropertyID currentProperty = *it;
74 69
75 switch (currentProperty) { 70 switch (currentProperty) {
76 case CSSPropertyBackgroundImage: { 71 case CSSPropertyBackgroundImage: {
77 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) { 72 for (FillLayer* backgroundLayer = &style->accessBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
78 if (backgroundLayer->image() && backgroundLayer->image()->isPend ingImage()) 73 if (backgroundLayer->image() && backgroundLayer->image()->isPend ingImage())
79 backgroundLayer->setImage(loadPendingImage(toStylePendingIma ge(backgroundLayer->image()), elementStyleResources.deviceScaleFactor())); 74 backgroundLayer->setImage(loadPendingImage(toStylePendingIma ge(backgroundLayer->image()), elementStyleResources.deviceScaleFactor()));
80 } 75 }
81 break; 76 break;
82 } 77 }
83 case CSSPropertyCursor: {
84 if (CursorList* cursorList = style->cursors()) {
85 for (size_t i = 0; i < cursorList->size(); ++i) {
86 CursorData& currentCursor = cursorList->at(i);
87 if (StyleImage* image = currentCursor.image()) {
88 if (image->isPendingImage())
89 currentCursor.setImage(loadPendingImage(toStylePendi ngImage(image), elementStyleResources.deviceScaleFactor()));
90 }
91 }
92 }
93 break;
94 }
95 case CSSPropertyListStyleImage: { 78 case CSSPropertyListStyleImage: {
96 if (style->listStyleImage() && style->listStyleImage()->isPendingIma ge()) 79 if (style->listStyleImage() && style->listStyleImage()->isPendingIma ge())
97 style->setListStyleImage(loadPendingImage(toStylePendingImage(st yle->listStyleImage()), elementStyleResources.deviceScaleFactor())); 80 style->setListStyleImage(loadPendingImage(toStylePendingImage(st yle->listStyleImage()), elementStyleResources.deviceScaleFactor()));
98 break; 81 break;
99 } 82 }
100 case CSSPropertyBorderImageSource: { 83 case CSSPropertyBorderImageSource: {
101 if (style->borderImageSource() && style->borderImageSource()->isPend ingImage()) 84 if (style->borderImageSource() && style->borderImageSource()->isPend ingImage())
102 style->setBorderImageSource(loadPendingImage(toStylePendingImage (style->borderImageSource()), elementStyleResources.deviceScaleFactor())); 85 style->setBorderImageSource(loadPendingImage(toStylePendingImage (style->borderImageSource()), elementStyleResources.deviceScaleFactor()));
103 break; 86 break;
104 } 87 }
105 default: 88 default:
106 ASSERT_NOT_REACHED(); 89 ASSERT_NOT_REACHED();
107 } 90 }
108 } 91 }
109 92
110 elementStyleResources.clearPendingImageProperties(); 93 elementStyleResources.clearPendingImageProperties();
111 } 94 }
112 95
113 void StyleResourceLoader::loadPendingResources(RenderStyle* renderStyle, Element StyleResources& elementStyleResources) 96 void StyleResourceLoader::loadPendingResources(RenderStyle* renderStyle, Element StyleResources& elementStyleResources)
114 { 97 {
115 // Start loading images referenced by this style. 98 // Start loading images referenced by this style.
116 loadPendingImages(renderStyle, elementStyleResources); 99 loadPendingImages(renderStyle, elementStyleResources);
117 } 100 }
118 101
119 } 102 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/StyleBuilderCustom.cpp ('k') | sky/engine/core/frame/FrameView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698