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

Side by Side Diff: Source/core/rendering/style/ShadowList.h

Issue 356123002: Consolidate some text shadow code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rendererToUse -> renderer() Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/style/ShadowList.cpp » ('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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ShadowList_h 31 #ifndef ShadowList_h
32 #define ShadowList_h 32 #define ShadowList_h
33 33
34 #include "core/rendering/style/ShadowData.h" 34 #include "core/rendering/style/ShadowData.h"
35 #include "platform/geometry/LayoutRect.h" 35 #include "platform/geometry/LayoutRect.h"
36 #include "platform/graphics/DrawLooperBuilder.h"
37 #include "wtf/PassOwnPtr.h"
36 #include "wtf/RefCounted.h" 38 #include "wtf/RefCounted.h"
37 #include "wtf/Vector.h" 39 #include "wtf/Vector.h"
38 40
39 namespace WebCore { 41 namespace WebCore {
40 42
41 class FloatRect; 43 class FloatRect;
42 class LayoutRect; 44 class LayoutRect;
43 45
44 typedef Vector<ShadowData, 1> ShadowDataVector; 46 typedef Vector<ShadowData, 1> ShadowDataVector;
45 47
46 // These are used to store shadows in specified order, but we usually want to 48 // These are used to store shadows in specified order, but we usually want to
47 // iterate over them backwards as the first-specified shadow is painted on top. 49 // iterate over them backwards as the first-specified shadow is painted on top.
48 class ShadowList : public RefCounted<ShadowList> { 50 class ShadowList : public RefCounted<ShadowList> {
49 public: 51 public:
50 // This consumes passed in vector. 52 // This consumes passed in vector.
51 static PassRefPtr<ShadowList> adopt(ShadowDataVector& shadows) 53 static PassRefPtr<ShadowList> adopt(ShadowDataVector& shadows)
52 { 54 {
53 return adoptRef(new ShadowList(shadows)); 55 return adoptRef(new ShadowList(shadows));
54 } 56 }
55 const ShadowDataVector& shadows() const { return m_shadows; } 57 const ShadowDataVector& shadows() const { return m_shadows; }
56 bool operator==(const ShadowList& o) const { return m_shadows == o.m_shadows ; } 58 bool operator==(const ShadowList& o) const { return m_shadows == o.m_shadows ; }
57 bool operator!=(const ShadowList& o) const { return !(*this == o); } 59 bool operator!=(const ShadowList& o) const { return !(*this == o); }
58 60
59 static PassRefPtr<ShadowList> blend(const ShadowList* from, const ShadowList * to, double progress); 61 static PassRefPtr<ShadowList> blend(const ShadowList* from, const ShadowList * to, double progress);
60 62
61 void adjustRectForShadow(LayoutRect&, float additionalOutlineSize = 0) const ; 63 void adjustRectForShadow(LayoutRect&, float additionalOutlineSize = 0) const ;
62 void adjustRectForShadow(FloatRect&, float additionalOutlineSize = 0) const; 64 void adjustRectForShadow(FloatRect&, float additionalOutlineSize = 0) const;
63 65
66 PassOwnPtr<DrawLooperBuilder> createDrawLooper(DrawLooperBuilder::ShadowAlph aMode, bool isHorizontal = true) const;
67
64 private: 68 private:
65 ShadowList(ShadowDataVector& shadows) 69 ShadowList(ShadowDataVector& shadows)
66 { 70 {
67 // If we have no shadows, we use a null ShadowList 71 // If we have no shadows, we use a null ShadowList
68 ASSERT(!shadows.isEmpty()); 72 ASSERT(!shadows.isEmpty());
69 m_shadows.swap(shadows); 73 m_shadows.swap(shadows);
70 m_shadows.shrinkToFit(); 74 m_shadows.shrinkToFit();
71 } 75 }
72 ShadowDataVector m_shadows; 76 ShadowDataVector m_shadows;
73 }; 77 };
74 78
75 } // namespace WebCore 79 } // namespace WebCore
76 80
77 #endif // ShadowList_h 81 #endif // ShadowList_h
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/style/ShadowList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698