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

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

Issue 178473024: Convert some Shape code to use references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase with 185393015 Created 6 years, 10 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
Index: Source/core/rendering/shapes/ShapeInfo.h
diff --git a/Source/core/rendering/shapes/ShapeInfo.h b/Source/core/rendering/shapes/ShapeInfo.h
index 00f9a02836f2176fe6ec05132b8d4b24bd47047c..fde958ed224e1ec74b26cd8addc1d792d491e7f9 100644
--- a/Source/core/rendering/shapes/ShapeInfo.h
+++ b/Source/core/rendering/shapes/ShapeInfo.h
@@ -43,16 +43,16 @@ namespace WebCore {
template<class KeyType, class InfoType>
class MappedInfo {
public:
- static InfoType* ensureInfo(const KeyType* key)
+ static InfoType& ensureInfo(const KeyType& key)
{
InfoMap& infoMap = MappedInfo<KeyType, InfoType>::infoMap();
- if (InfoType* info = infoMap.get(key))
- return info;
- typename InfoMap::AddResult result = infoMap.add(key, InfoType::createInfo(key));
- return result.storedValue->value.get();
+ if (InfoType* info = infoMap.get(&key))
+ return *info;
+ typename InfoMap::AddResult result = infoMap.add(&key, InfoType::createInfo(key));
+ return *result.storedValue->value;
}
- static void removeInfo(const KeyType* key) { infoMap().remove(key); }
- static InfoType* info(const KeyType* key) { return infoMap().get(key); }
+ static void removeInfo(const KeyType& key) { infoMap().remove(&key); }
+ static InfoType* info(const KeyType& key) { return infoMap().get(&key); }
private:
typedef HashMap<const KeyType*, OwnPtr<InfoType> > InfoMap;
static InfoMap& infoMap()
@@ -68,33 +68,29 @@ class ShapeInfo {
public:
virtual ~ShapeInfo() { }
- void setShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight)
+ void setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize)
adamk 2014/03/04 19:45:05 Changing this to take a size seems out of scope fo
{
- switch (resolvedLayoutBox()) {
+ switch (referenceBox()) {
case MarginBox:
- logicalHeight += m_renderer->marginLogicalHeight();
- logicalWidth += m_renderer->marginLogicalWidth();
+ newReferenceBoxLogicalSize.expand(m_renderer.marginLogicalWidth(), m_renderer.marginLogicalHeight());
break;
case BorderBox:
break;
case PaddingBox:
- logicalHeight -= m_renderer->borderLogicalHeight();
- logicalWidth -= m_renderer->borderLogicalWidth();
+ newReferenceBoxLogicalSize.shrink(m_renderer.borderLogicalWidth(), m_renderer.borderLogicalHeight());
break;
case ContentBox:
- logicalHeight -= m_renderer->borderAndPaddingLogicalHeight();
- logicalWidth -= m_renderer->borderAndPaddingLogicalWidth();
+ newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingLogicalWidth(), m_renderer.borderAndPaddingLogicalHeight());
break;
case BoxMissing:
// A non-missing box value must be supplied.
ASSERT_NOT_REACHED();
}
- LayoutSize newLogicalSize(logicalWidth, logicalHeight);
- if (m_shapeLogicalSize == newLogicalSize)
+ if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize)
return;
- dirtyShapeSize();
- m_shapeLogicalSize = newLogicalSize;
+ markShapeAsDirty();
+ m_referenceBoxLogicalSize = newReferenceBoxLogicalSize;
}
SegmentList computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const;
@@ -106,39 +102,39 @@ public:
LayoutUnit shapeLogicalWidth() const { return computedShapeLogicalBoundingBox().width(); }
LayoutUnit shapeLogicalHeight() const { return computedShapeLogicalBoundingBox().height(); }
- LayoutUnit logicalLineTop() const { return m_shapeLineTop + logicalTopOffset(); }
- LayoutUnit logicalLineBottom() const { return m_shapeLineTop + m_lineHeight + logicalTopOffset(); }
+ LayoutUnit logicalLineTop() const { return m_referenceBoxLineTop + logicalTopOffset(); }
+ LayoutUnit logicalLineBottom() const { return m_referenceBoxLineTop + m_lineHeight + logicalTopOffset(); }
- LayoutUnit shapeContainingBlockHeight() const { return (m_renderer->style()->boxSizing() == CONTENT_BOX) ? (m_shapeLogicalSize.height() + m_renderer->borderAndPaddingLogicalHeight()) : m_shapeLogicalSize.height(); }
+ LayoutUnit shapeContainingBlockHeight() const { return (m_renderer.style()->boxSizing() == CONTENT_BOX) ? (m_referenceBoxLogicalSize.height() + m_renderer.borderAndPaddingLogicalHeight()) : m_referenceBoxLogicalSize.height(); }
virtual bool lineOverlapsShapeBounds() const = 0;
- void dirtyShapeSize() { m_shape.clear(); }
- bool shapeSizeDirty() { return !m_shape.get(); }
- const RenderType* owner() const { return m_renderer; }
- LayoutSize shapeSize() const { return m_shapeLogicalSize; }
+ void markShapeAsDirty() { m_shape.clear(); }
adamk 2014/03/04 19:45:05 This rename, too, seems out of scope
+ bool isShapeDirty() { return !m_shape.get(); }
+ const RenderType& owner() const { return m_renderer; }
+ LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; }
protected:
- ShapeInfo(const RenderType* renderer): m_renderer(renderer) { }
+ ShapeInfo(const RenderType& renderer): m_renderer(renderer) { }
- const Shape* computedShape() const;
+ const Shape& computedShape() const;
- virtual LayoutBox resolvedLayoutBox() const = 0;
+ virtual LayoutBox referenceBox() const = 0;
adamk 2014/03/04 19:45:05 And this one...
virtual LayoutRect computedShapeLogicalBoundingBox() const = 0;
virtual ShapeValue* shapeValue() const = 0;
virtual void getIntervals(LayoutUnit, LayoutUnit, SegmentList&) const = 0;
LayoutUnit logicalTopOffset() const
{
- switch (resolvedLayoutBox()) {
+ switch (referenceBox()) {
case MarginBox:
- return -m_renderer->marginBefore();
+ return -m_renderer.marginBefore();
case BorderBox:
return LayoutUnit();
case PaddingBox:
- return m_renderer->borderBefore();
+ return m_renderer.borderBefore();
case ContentBox:
- return m_renderer->borderAndPaddingBefore();
+ return m_renderer.borderAndPaddingBefore();
case BoxMissing:
// A non-missing box value must be supplied.
ASSERT_NOT_REACHED();
@@ -148,15 +144,15 @@ protected:
LayoutUnit logicalLeftOffset() const
{
- switch (resolvedLayoutBox()) {
+ switch (referenceBox()) {
case MarginBox:
- return -m_renderer->marginStart();
+ return -m_renderer.marginStart();
case BorderBox:
return LayoutUnit();
case PaddingBox:
- return m_renderer->borderStart();
+ return m_renderer.borderStart();
case ContentBox:
- return m_renderer->borderAndPaddingStart();
+ return m_renderer.borderAndPaddingStart();
case BoxMissing:
// A non-missing box value must be supplied.
ASSERT_NOT_REACHED();
@@ -164,14 +160,14 @@ protected:
return LayoutUnit();
}
- LayoutUnit m_shapeLineTop;
+ LayoutUnit m_referenceBoxLineTop;
LayoutUnit m_lineHeight;
- const RenderType* m_renderer;
+ const RenderType& m_renderer;
private:
mutable OwnPtr<Shape> m_shape;
- LayoutSize m_shapeLogicalSize;
+ LayoutSize m_referenceBoxLogicalSize;
};
bool checkShapeImageOrigin(Document&, ImageResource&);

Powered by Google App Engine
This is Rietveld 408576698