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

Unified Diff: Source/core/rendering/shapes/ShapeOutsideInfo.h

Issue 460103002: Refactor ShapeOutsideInfo so it isn't mutated for each line (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update for review comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/line/LineWidth.cpp ('k') | Source/core/rendering/shapes/ShapeOutsideInfo.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/shapes/ShapeOutsideInfo.h
diff --git a/Source/core/rendering/shapes/ShapeOutsideInfo.h b/Source/core/rendering/shapes/ShapeOutsideInfo.h
index b51fda1b6cc547d6e9ad121c246fef3bc2ad6436..9596e528af4f6b77fc326e50a67bd43565a805c7 100644
--- a/Source/core/rendering/shapes/ShapeOutsideInfo.h
+++ b/Source/core/rendering/shapes/ShapeOutsideInfo.h
@@ -43,6 +43,43 @@ class RenderBlockFlow;
class RenderBox;
class FloatingObject;
+class ShapeOutsideDeltas FINAL {
+public:
+ ShapeOutsideDeltas()
+ : m_lineOverlapsShape(false)
+ , m_isValid(false)
+ {
+ }
+
+ ShapeOutsideDeltas(LayoutUnit leftMarginBoxDelta, LayoutUnit rightMarginBoxDelta, bool lineOverlapsShape, LayoutUnit borderBoxLineTop, LayoutUnit lineHeight)
+ : m_leftMarginBoxDelta(leftMarginBoxDelta)
+ , m_rightMarginBoxDelta(rightMarginBoxDelta)
+ , m_borderBoxLineTop(borderBoxLineTop)
+ , m_lineHeight(lineHeight)
+ , m_lineOverlapsShape(lineOverlapsShape)
+ , m_isValid(true)
+ {
+ }
+
+ bool isForLine(LayoutUnit borderBoxLineTop, LayoutUnit lineHeight)
+ {
+ return m_isValid && m_borderBoxLineTop == borderBoxLineTop && m_lineHeight == lineHeight;
+ }
+
+ bool isValid() { return m_isValid; }
+ LayoutUnit leftMarginBoxDelta() { ASSERT(m_isValid); return m_leftMarginBoxDelta; }
+ LayoutUnit rightMarginBoxDelta() { ASSERT(m_isValid); return m_rightMarginBoxDelta; }
+ bool lineOverlapsShape() { ASSERT(m_isValid); return m_lineOverlapsShape; }
+
+private:
+ LayoutUnit m_leftMarginBoxDelta;
+ LayoutUnit m_rightMarginBoxDelta;
+ LayoutUnit m_borderBoxLineTop;
+ LayoutUnit m_lineHeight;
+ bool m_lineOverlapsShape : 1;
+ bool m_isValid : 1;
+};
+
class ShapeOutsideInfo FINAL {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -55,21 +92,10 @@ public:
LayoutUnit shapeLogicalWidth() const { return computedShape().shapeMarginLogicalBoundingBox().width(); }
LayoutUnit shapeLogicalHeight() const { return computedShape().shapeMarginLogicalBoundingBox().height(); }
- LayoutUnit logicalLineTop() const { return m_referenceBoxLineTop + logicalTopOffset(); }
- LayoutUnit logicalLineBottom() const { return m_referenceBoxLineTop + m_lineHeight + logicalTopOffset(); }
-
- LayoutUnit leftMarginBoxDelta() const { return m_leftMarginBoxDelta; }
- LayoutUnit rightMarginBoxDelta() const { return m_rightMarginBoxDelta; }
- bool lineOverlapsShape() const { return m_lineOverlapsShape; }
-
static PassOwnPtr<ShapeOutsideInfo> createInfo(const RenderBox& renderer) { return adoptPtr(new ShapeOutsideInfo(renderer)); }
static bool isEnabledFor(const RenderBox&);
- void updateDeltasForContainingBlockLine(const RenderBlockFlow&, const FloatingObject&, LayoutUnit lineTop, LayoutUnit lineHeight);
- bool lineOverlapsShapeBounds() const
- {
- return computedShape().lineOverlapsShapeMarginBounds(m_referenceBoxLineTop, m_lineHeight);
- }
+ ShapeOutsideDeltas computeDeltasForContainingBlockLine(const RenderBlockFlow&, const FloatingObject&, LayoutUnit lineTop, LayoutUnit lineHeight);
static ShapeOutsideInfo& ensureInfo(const RenderBox& key)
{
@@ -94,7 +120,6 @@ public:
protected:
ShapeOutsideInfo(const RenderBox& renderer)
: m_renderer(renderer)
- , m_lineOverlapsShape(false)
{ }
private:
@@ -110,16 +135,10 @@ private:
return staticInfoMap;
}
- LayoutUnit m_referenceBoxLineTop;
- LayoutUnit m_lineHeight;
-
const RenderBox& m_renderer;
mutable OwnPtr<Shape> m_shape;
LayoutSize m_referenceBoxLogicalSize;
- LayoutUnit m_leftMarginBoxDelta;
- LayoutUnit m_rightMarginBoxDelta;
- LayoutUnit m_borderBoxLineTop;
- bool m_lineOverlapsShape;
+ ShapeOutsideDeltas m_shapeOutsideDeltas;
};
}
« no previous file with comments | « Source/core/rendering/line/LineWidth.cpp ('k') | Source/core/rendering/shapes/ShapeOutsideInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698