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

Side by Side Diff: sky/engine/core/rendering/shapes/ShapeOutsideInfo.h

Issue 703563002: Remove shape-outside. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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) 2012 Adobe Systems Incorporated. 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 *
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 #ifndef ShapeOutsideInfo_h
31 #define ShapeOutsideInfo_h
32
33 #include "core/rendering/shapes/Shape.h"
34 #include "core/rendering/style/RenderStyle.h"
35 #include "core/rendering/style/ShapeValue.h"
36 #include "platform/geometry/FloatRect.h"
37 #include "platform/geometry/LayoutSize.h"
38 #include "wtf/OwnPtr.h"
39
40 namespace blink {
41
42 class RenderBlockFlow;
43 class RenderBox;
44 class FloatingObject;
45
46 class ShapeOutsideDeltas final {
47 public:
48 ShapeOutsideDeltas()
49 : m_lineOverlapsShape(false)
50 , m_isValid(false)
51 {
52 }
53
54 ShapeOutsideDeltas(LayoutUnit leftMarginBoxDelta, LayoutUnit rightMarginBoxD elta, bool lineOverlapsShape, LayoutUnit borderBoxLineTop, LayoutUnit lineHeight )
55 : m_leftMarginBoxDelta(leftMarginBoxDelta)
56 , m_rightMarginBoxDelta(rightMarginBoxDelta)
57 , m_borderBoxLineTop(borderBoxLineTop)
58 , m_lineHeight(lineHeight)
59 , m_lineOverlapsShape(lineOverlapsShape)
60 , m_isValid(true)
61 {
62 }
63
64 bool isForLine(LayoutUnit borderBoxLineTop, LayoutUnit lineHeight)
65 {
66 return m_isValid && m_borderBoxLineTop == borderBoxLineTop && m_lineHeig ht == lineHeight;
67 }
68
69 bool isValid() { return m_isValid; }
70 LayoutUnit leftMarginBoxDelta() { ASSERT(m_isValid); return m_leftMarginBoxD elta; }
71 LayoutUnit rightMarginBoxDelta() { ASSERT(m_isValid); return m_rightMarginBo xDelta; }
72 bool lineOverlapsShape() { ASSERT(m_isValid); return m_lineOverlapsShape; }
73
74 private:
75 LayoutUnit m_leftMarginBoxDelta;
76 LayoutUnit m_rightMarginBoxDelta;
77 LayoutUnit m_borderBoxLineTop;
78 LayoutUnit m_lineHeight;
79 bool m_lineOverlapsShape : 1;
80 bool m_isValid : 1;
81 };
82
83 class ShapeOutsideInfo final {
84 WTF_MAKE_FAST_ALLOCATED;
85 public:
86 void setReferenceBoxLogicalSize(LayoutSize);
87
88 LayoutUnit shapeLogicalTop() const { return computedShape().shapeMarginLogic alBoundingBox().y() + logicalTopOffset(); }
89 LayoutUnit shapeLogicalBottom() const { return computedShape().shapeMarginLo gicalBoundingBox().maxY() + logicalTopOffset(); }
90 LayoutUnit shapeLogicalLeft() const { return computedShape().shapeMarginLogi calBoundingBox().x() + logicalLeftOffset(); }
91 LayoutUnit shapeLogicalRight() const { return computedShape().shapeMarginLog icalBoundingBox().maxX() + logicalLeftOffset(); }
92 LayoutUnit shapeLogicalWidth() const { return computedShape().shapeMarginLog icalBoundingBox().width(); }
93 LayoutUnit shapeLogicalHeight() const { return computedShape().shapeMarginLo gicalBoundingBox().height(); }
94
95 static PassOwnPtr<ShapeOutsideInfo> createInfo(const RenderBox& renderer) { return adoptPtr(new ShapeOutsideInfo(renderer)); }
96 static bool isEnabledFor(const RenderBox&);
97
98 ShapeOutsideDeltas computeDeltasForContainingBlockLine(const RenderBlockFlow &, const FloatingObject&, LayoutUnit lineTop, LayoutUnit lineHeight);
99
100 static ShapeOutsideInfo& ensureInfo(const RenderBox& key)
101 {
102 InfoMap& infoMap = ShapeOutsideInfo::infoMap();
103 if (ShapeOutsideInfo* info = infoMap.get(&key))
104 return *info;
105 InfoMap::AddResult result = infoMap.add(&key, ShapeOutsideInfo::createIn fo(key));
106 return *result.storedValue->value;
107 }
108 static void removeInfo(const RenderBox& key) { infoMap().remove(&key); }
109 static ShapeOutsideInfo* info(const RenderBox& key) { return infoMap().get(& key); }
110
111 void markShapeAsDirty() { m_shape.clear(); }
112 bool isShapeDirty() { return !m_shape.get(); }
113 LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; }
114
115 LayoutRect computedShapePhysicalBoundingBox() const;
116 FloatPoint shapeToRendererPoint(FloatPoint) const;
117 FloatSize shapeToRendererSize(FloatSize) const;
118 const Shape& computedShape() const;
119
120 protected:
121 ShapeOutsideInfo(const RenderBox& renderer)
122 : m_renderer(renderer)
123 { }
124
125 private:
126 PassOwnPtr<Shape> createShapeForImage(StyleImage*, float shapeImageThreshold , float margin) const;
127
128 LayoutUnit logicalTopOffset() const;
129 LayoutUnit logicalLeftOffset() const;
130
131 typedef HashMap<const RenderBox*, OwnPtr<ShapeOutsideInfo> > InfoMap;
132 static InfoMap& infoMap()
133 {
134 DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ());
135 return staticInfoMap;
136 }
137
138 const RenderBox& m_renderer;
139 mutable OwnPtr<Shape> m_shape;
140 LayoutSize m_referenceBoxLogicalSize;
141 ShapeOutsideDeltas m_shapeOutsideDeltas;
142 };
143
144 }
145 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/shapes/ShapeInterval.h ('k') | sky/engine/core/rendering/shapes/ShapeOutsideInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698