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

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: Some more reference code 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..3dfd6f15d94fcc21c6dfdcc1881201b70cdcbc4b 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()
@@ -72,18 +72,18 @@ public:
{
switch (resolvedLayoutBox()) {
case MarginBox:
- logicalHeight += m_renderer->marginLogicalHeight();
- logicalWidth += m_renderer->marginLogicalWidth();
+ logicalHeight += m_renderer.marginLogicalHeight();
+ logicalWidth += m_renderer.marginLogicalWidth();
break;
case BorderBox:
break;
case PaddingBox:
- logicalHeight -= m_renderer->borderLogicalHeight();
- logicalWidth -= m_renderer->borderLogicalWidth();
+ logicalHeight -= m_renderer.borderLogicalHeight();
+ logicalWidth -= m_renderer.borderLogicalWidth();
break;
case ContentBox:
- logicalHeight -= m_renderer->borderAndPaddingLogicalHeight();
- logicalWidth -= m_renderer->borderAndPaddingLogicalWidth();
+ logicalHeight -= m_renderer.borderAndPaddingLogicalHeight();
+ logicalWidth -= m_renderer.borderAndPaddingLogicalWidth();
break;
case BoxMissing:
// A non-missing box value must be supplied.
@@ -109,19 +109,19 @@ public:
LayoutUnit logicalLineTop() const { return m_shapeLineTop + logicalTopOffset(); }
LayoutUnit logicalLineBottom() const { return m_shapeLineTop + 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_shapeLogicalSize.height() + m_renderer.borderAndPaddingLogicalHeight()) : m_shapeLogicalSize.height(); }
virtual bool lineOverlapsShapeBounds() const = 0;
void dirtyShapeSize() { m_shape.clear(); }
bool shapeSizeDirty() { return !m_shape.get(); }
- const RenderType* owner() const { return m_renderer; }
+ const RenderType& owner() const { return m_renderer; }
LayoutSize shapeSize() const { return m_shapeLogicalSize; }
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 LayoutRect computedShapeLogicalBoundingBox() const = 0;
@@ -132,13 +132,13 @@ protected:
{
switch (resolvedLayoutBox()) {
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();
@@ -150,13 +150,13 @@ protected:
{
switch (resolvedLayoutBox()) {
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();
@@ -167,7 +167,7 @@ protected:
LayoutUnit m_shapeLineTop;
LayoutUnit m_lineHeight;
- const RenderType* m_renderer;
+ const RenderType& m_renderer;
private:
mutable OwnPtr<Shape> m_shape;

Powered by Google App Engine
This is Rietveld 408576698