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

Side by Side Diff: Source/core/rendering/exclusions/ExclusionShapeInfo.h

Issue 14892005: [CSS Exclusions] ExclusionShape bounding box methods should return LayoutRects (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: reverted LineSegment logicalLeft,Right type change Created 7 years, 7 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) 2012 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 static InfoType* info(const KeyType* key) { return infoMap().get(key); } 55 static InfoType* info(const KeyType* key) { return infoMap().get(key); }
56 private: 56 private:
57 typedef HashMap<const KeyType*, OwnPtr<InfoType> > InfoMap; 57 typedef HashMap<const KeyType*, OwnPtr<InfoType> > InfoMap;
58 static InfoMap& infoMap() 58 static InfoMap& infoMap()
59 { 59 {
60 DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ()); 60 DEFINE_STATIC_LOCAL(InfoMap, staticInfoMap, ());
61 return staticInfoMap; 61 return staticInfoMap;
62 } 62 }
63 }; 63 };
64 64
65 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co nst, void (ExclusionShape::*intervalGetter)(float, float, SegmentList&) const> 65 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co nst, void (ExclusionShape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList& ) const>
66 class ExclusionShapeInfo { 66 class ExclusionShapeInfo {
67 WTF_MAKE_FAST_ALLOCATED; 67 WTF_MAKE_FAST_ALLOCATED;
68 public: 68 public:
69 virtual ~ExclusionShapeInfo() { } 69 virtual ~ExclusionShapeInfo() { }
70 70
71 void setShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight) 71 void setShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight)
72 { 72 {
73 if (m_renderer->style()->boxSizing() == CONTENT_BOX) { 73 if (m_renderer->style()->boxSizing() == CONTENT_BOX) {
74 logicalWidth -= m_renderer->borderAndPaddingLogicalWidth(); 74 logicalWidth -= m_renderer->borderAndPaddingLogicalWidth();
75 logicalHeight -= m_renderer->borderAndPaddingLogicalHeight(); 75 logicalHeight -= m_renderer->borderAndPaddingLogicalHeight();
76 } 76 }
77 77
78 if (m_shapeLogicalWidth == logicalWidth && m_shapeLogicalHeight == logic alHeight) 78 if (m_shapeLogicalWidth == logicalWidth && m_shapeLogicalHeight == logic alHeight)
79 return; 79 return;
80 dirtyShapeSize(); 80 dirtyShapeSize();
81 m_shapeLogicalWidth = logicalWidth; 81 m_shapeLogicalWidth = logicalWidth;
82 m_shapeLogicalHeight = logicalHeight; 82 m_shapeLogicalHeight = logicalHeight;
83 } 83 }
84 84
85 virtual bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeigh t); 85 virtual bool computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeigh t);
86 86
87 LayoutUnit shapeLogicalTop() const { return floatLogicalTopToLayoutUnit(comp utedShapeLogicalBoundingBox().y()) + logicalTopOffset(); } 87 LayoutUnit shapeLogicalTop() const { return computedShapeLogicalBoundingBox( ).y() + logicalTopOffset(); }
88 LayoutUnit shapeLogicalBottom() const { return floatLogicalBottomToLayoutUni t(computedShapeLogicalBoundingBox().maxY()) + logicalTopOffset(); } 88 LayoutUnit shapeLogicalBottom() const { return computedShapeLogicalBoundingB ox().maxY() + logicalTopOffset(); }
89 LayoutUnit shapeLogicalLeft() const { return computedShapeLogicalBoundingBox ().x() + logicalLeftOffset(); } 89 LayoutUnit shapeLogicalLeft() const { return computedShapeLogicalBoundingBox ().x() + logicalLeftOffset(); }
90 LayoutUnit shapeLogicalRight() const { return computedShapeLogicalBoundingBo x().maxX() + logicalLeftOffset(); } 90 LayoutUnit shapeLogicalRight() const { return computedShapeLogicalBoundingBo x().maxX() + logicalLeftOffset(); }
91 LayoutUnit shapeLogicalWidth() const { return computedShapeLogicalBoundingBo x().width(); } 91 LayoutUnit shapeLogicalWidth() const { return computedShapeLogicalBoundingBo x().width(); }
92 LayoutUnit shapeLogicalHeight() const { return computedShapeLogicalBoundingB ox().height(); } 92 LayoutUnit shapeLogicalHeight() const { return computedShapeLogicalBoundingB ox().height(); }
93 93
94 LayoutUnit logicalLineTop() const { return m_shapeLineTop + logicalTopOffset (); } 94 LayoutUnit logicalLineTop() const { return m_shapeLineTop + logicalTopOffset (); }
95 LayoutUnit logicalLineBottom() const { return m_shapeLineTop + m_lineHeight + logicalTopOffset(); } 95 LayoutUnit logicalLineBottom() const { return m_shapeLineTop + m_lineHeight + logicalTopOffset(); }
96 96
97 bool lineOverlapsShapeBounds() const { return logicalLineTop() < shapeLogica lBottom() && logicalLineBottom() >= shapeLogicalTop(); } 97 bool lineOverlapsShapeBounds() const { return logicalLineTop() < shapeLogica lBottom() && logicalLineBottom() >= shapeLogicalTop(); }
98 98
99 void dirtyShapeSize() { m_shape.clear(); } 99 void dirtyShapeSize() { m_shape.clear(); }
100 bool shapeSizeDirty() { return !m_shape.get(); } 100 bool shapeSizeDirty() { return !m_shape.get(); }
101 const RenderType* owner() const { return m_renderer; } 101 const RenderType* owner() const { return m_renderer; }
102 102
103 protected: 103 protected:
104 ExclusionShapeInfo(const RenderType* renderer): m_renderer(renderer) { } 104 ExclusionShapeInfo(const RenderType* renderer): m_renderer(renderer) { }
105 105
106 const ExclusionShape* computedShape() const; 106 const ExclusionShape* computedShape() const;
107 virtual FloatRect computedShapeLogicalBoundingBox() const = 0; 107 virtual LayoutRect computedShapeLogicalBoundingBox() const = 0;
108
109 // Use ceil and floor to ensure that the returned LayoutUnit value is within the shape's bounds.
110 LayoutUnit floatLogicalTopToLayoutUnit(float logicalTop) const { return Layo utUnit::fromFloatCeil(logicalTop); }
111 LayoutUnit floatLogicalBottomToLayoutUnit(float logicalBottom) const { retur n LayoutUnit::fromFloatFloor(logicalBottom); }
112 108
113 LayoutUnit logicalTopOffset() const; 109 LayoutUnit logicalTopOffset() const;
114 LayoutUnit logicalLeftOffset() const { return m_renderer->style()->boxSizing () == CONTENT_BOX ? m_renderer->borderStart() + m_renderer->paddingStart() : Lay outUnit(); } 110 LayoutUnit logicalLeftOffset() const { return m_renderer->style()->boxSizing () == CONTENT_BOX ? m_renderer->borderStart() + m_renderer->paddingStart() : Lay outUnit(); }
115 111
116 LayoutUnit m_shapeLineTop; 112 LayoutUnit m_shapeLineTop;
117 LayoutUnit m_lineHeight; 113 LayoutUnit m_lineHeight;
118 SegmentList m_segments; 114 SegmentList m_segments;
119 115
120 private: 116 private:
121 mutable OwnPtr<ExclusionShape> m_shape; 117 mutable OwnPtr<ExclusionShape> m_shape;
122 118
123 LayoutUnit m_shapeLogicalWidth; 119 LayoutUnit m_shapeLogicalWidth;
124 LayoutUnit m_shapeLogicalHeight; 120 LayoutUnit m_shapeLogicalHeight;
125 const RenderType* m_renderer; 121 const RenderType* m_renderer;
126 }; 122 };
127 } 123 }
128 #endif 124 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/exclusions/ExclusionShape.cpp ('k') | Source/core/rendering/exclusions/ExclusionShapeInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698