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

Side by Side Diff: third_party/WebKit/Source/core/layout/shapes/RasterShape.h

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
1 /* 1 /*
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2013 Adobe Systems Incorporated. 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 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 17 matching lines...) Expand all
28 */ 28 */
29 29
30 #ifndef RasterShape_h 30 #ifndef RasterShape_h
31 #define RasterShape_h 31 #define RasterShape_h
32 32
33 #include "core/layout/shapes/Shape.h" 33 #include "core/layout/shapes/Shape.h"
34 #include "core/layout/shapes/ShapeInterval.h" 34 #include "core/layout/shapes/ShapeInterval.h"
35 #include "platform/geometry/FloatRect.h" 35 #include "platform/geometry/FloatRect.h"
36 #include "wtf/Assertions.h" 36 #include "wtf/Assertions.h"
37 #include "wtf/Vector.h" 37 #include "wtf/Vector.h"
38 #include <memory>
39 38
40 namespace blink { 39 namespace blink {
41 40
42 class RasterShapeIntervals { 41 class RasterShapeIntervals {
43 USING_FAST_MALLOC(RasterShapeIntervals); 42 USING_FAST_MALLOC(RasterShapeIntervals);
44 public: 43 public:
45 RasterShapeIntervals(unsigned size, int offset = 0) 44 RasterShapeIntervals(unsigned size, int offset = 0)
46 : m_offset(offset) 45 : m_offset(offset)
47 { 46 {
48 m_intervals.resize(clampTo<int>(size)); 47 m_intervals.resize(clampTo<int>(size));
49 } 48 }
50 49
51 void initializeBounds(); 50 void initializeBounds();
52 const IntRect& bounds() const { return m_bounds; } 51 const IntRect& bounds() const { return m_bounds; }
53 bool isEmpty() const { return m_bounds.isEmpty(); } 52 bool isEmpty() const { return m_bounds.isEmpty(); }
54 53
55 IntShapeInterval& intervalAt(int y) 54 IntShapeInterval& intervalAt(int y)
56 { 55 {
57 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvals.size()); 56 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvals.size());
58 return m_intervals[y + m_offset]; 57 return m_intervals[y + m_offset];
59 } 58 }
60 59
61 const IntShapeInterval& intervalAt(int y) const 60 const IntShapeInterval& intervalAt(int y) const
62 { 61 {
63 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvals.size()); 62 ASSERT(y + m_offset >= 0 && static_cast<unsigned>(y + m_offset) < m_inte rvals.size());
64 return m_intervals[y + m_offset]; 63 return m_intervals[y + m_offset];
65 } 64 }
66 65
67 std::unique_ptr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeM argin) const; 66 PassOwnPtr<RasterShapeIntervals> computeShapeMarginIntervals(int shapeMargin ) const;
68 67
69 void buildBoundsPath(Path&) const; 68 void buildBoundsPath(Path&) const;
70 69
71 private: 70 private:
72 int size() const { return m_intervals.size(); } 71 int size() const { return m_intervals.size(); }
73 int offset() const { return m_offset; } 72 int offset() const { return m_offset; }
74 int minY() const { return -m_offset; } 73 int minY() const { return -m_offset; }
75 int maxY() const { return -m_offset + m_intervals.size(); } 74 int maxY() const { return -m_offset + m_intervals.size(); }
76 75
77 IntRect m_bounds; 76 IntRect m_bounds;
78 Vector<IntShapeInterval> m_intervals; 77 Vector<IntShapeInterval> m_intervals;
79 int m_offset; 78 int m_offset;
80 }; 79 };
81 80
82 class RasterShape final : public Shape { 81 class RasterShape final : public Shape {
83 WTF_MAKE_NONCOPYABLE(RasterShape); 82 WTF_MAKE_NONCOPYABLE(RasterShape);
84 public: 83 public:
85 RasterShape(std::unique_ptr<RasterShapeIntervals> intervals, const IntSize& marginRectSize) 84 RasterShape(PassOwnPtr<RasterShapeIntervals> intervals, const IntSize& margi nRectSize)
86 : m_intervals(std::move(intervals)) 85 : m_intervals(std::move(intervals))
87 , m_marginRectSize(marginRectSize) 86 , m_marginRectSize(marginRectSize)
88 { 87 {
89 m_intervals->initializeBounds(); 88 m_intervals->initializeBounds();
90 } 89 }
91 90
92 LayoutRect shapeMarginLogicalBoundingBox() const override { return static_ca st<LayoutRect>(marginIntervals().bounds()); } 91 LayoutRect shapeMarginLogicalBoundingBox() const override { return static_ca st<LayoutRect>(marginIntervals().bounds()); }
93 bool isEmpty() const override { return m_intervals->isEmpty(); } 92 bool isEmpty() const override { return m_intervals->isEmpty(); }
94 LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHei ght) const override; 93 LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHei ght) const override;
95 void buildDisplayPaths(DisplayPaths& paths) const override 94 void buildDisplayPaths(DisplayPaths& paths) const override
96 { 95 {
97 m_intervals->buildBoundsPath(paths.shape); 96 m_intervals->buildBoundsPath(paths.shape);
98 if (shapeMargin()) 97 if (shapeMargin())
99 marginIntervals().buildBoundsPath(paths.marginShape); 98 marginIntervals().buildBoundsPath(paths.marginShape);
100 } 99 }
101 100
102 private: 101 private:
103 const RasterShapeIntervals& marginIntervals() const; 102 const RasterShapeIntervals& marginIntervals() const;
104 103
105 std::unique_ptr<RasterShapeIntervals> m_intervals; 104 OwnPtr<RasterShapeIntervals> m_intervals;
106 mutable std::unique_ptr<RasterShapeIntervals> m_marginIntervals; 105 mutable OwnPtr<RasterShapeIntervals> m_marginIntervals;
107 IntSize m_marginRectSize; 106 IntSize m_marginRectSize;
108 }; 107 };
109 108
110 } // namespace blink 109 } // namespace blink
111 110
112 #endif // RasterShape_h 111 #endif // RasterShape_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698