Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 return staticInfoMap; | 61 return staticInfoMap; |
| 62 } | 62 } |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 template<class RenderType> | 65 template<class RenderType> |
| 66 class ShapeInfo { | 66 class ShapeInfo { |
| 67 WTF_MAKE_FAST_ALLOCATED; | 67 WTF_MAKE_FAST_ALLOCATED; |
| 68 public: | 68 public: |
| 69 virtual ~ShapeInfo() { } | 69 virtual ~ShapeInfo() { } |
| 70 | 70 |
| 71 void setShapeSize(LayoutUnit logicalWidth, LayoutUnit logicalHeight) | 71 void setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize) |
| 72 { | 72 { |
| 73 switch (resolvedLayoutBox()) { | 73 switch (referenceBox()) { |
| 74 case MarginBox: | 74 case MarginBox: |
| 75 logicalHeight += m_renderer->marginLogicalHeight(); | 75 newReferenceBoxLogicalSize.expand(m_renderer->marginLogicalWidth(), m_renderer->marginLogicalHeight()); |
| 76 logicalWidth += m_renderer->marginLogicalWidth(); | |
| 77 break; | 76 break; |
| 78 case BorderBox: | 77 case BorderBox: |
| 79 break; | 78 break; |
| 80 case PaddingBox: | 79 case PaddingBox: |
| 81 logicalHeight -= m_renderer->borderLogicalHeight(); | 80 newReferenceBoxLogicalSize.shrink(m_renderer->borderLogicalWidth(), m_renderer->borderLogicalHeight()); |
| 82 logicalWidth -= m_renderer->borderLogicalWidth(); | |
| 83 break; | 81 break; |
| 84 case ContentBox: | 82 case ContentBox: |
| 85 logicalHeight -= m_renderer->borderAndPaddingLogicalHeight(); | 83 newReferenceBoxLogicalSize.shrink(m_renderer->borderAndPaddingLogica lWidth(), m_renderer->borderAndPaddingLogicalHeight()); |
| 86 logicalWidth -= m_renderer->borderAndPaddingLogicalWidth(); | |
| 87 break; | 84 break; |
| 88 case BoxMissing: | 85 case BoxMissing: |
| 89 // A non-missing box value must be supplied. | 86 // A non-missing box value must be supplied. |
| 90 ASSERT_NOT_REACHED(); | 87 ASSERT_NOT_REACHED(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 LayoutSize newLogicalSize(logicalWidth, logicalHeight); | 90 if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize) |
| 94 if (m_shapeLogicalSize == newLogicalSize) | |
| 95 return; | 91 return; |
| 96 dirtyShapeSize(); | 92 markShapeAsDirty(); |
| 97 m_shapeLogicalSize = newLogicalSize; | 93 m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; |
| 98 } | 94 } |
| 99 | 95 |
| 100 SegmentList computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight ) const; | 96 SegmentList computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight ) const; |
| 101 | 97 |
| 102 LayoutUnit shapeLogicalTop() const { return computedShapeLogicalBoundingBox( ).y() + logicalTopOffset(); } | 98 LayoutUnit shapeLogicalTop() const { return computedShapeLogicalBoundingBox( ).y() + logicalTopOffset(); } |
| 103 LayoutUnit shapeLogicalBottom() const { return computedShapeLogicalBoundingB ox().maxY() + logicalTopOffset(); } | 99 LayoutUnit shapeLogicalBottom() const { return computedShapeLogicalBoundingB ox().maxY() + logicalTopOffset(); } |
| 104 LayoutUnit shapeLogicalLeft() const { return computedShapeLogicalBoundingBox ().x() + logicalLeftOffset(); } | 100 LayoutUnit shapeLogicalLeft() const { return computedShapeLogicalBoundingBox ().x() + logicalLeftOffset(); } |
| 105 LayoutUnit shapeLogicalRight() const { return computedShapeLogicalBoundingBo x().maxX() + logicalLeftOffset(); } | 101 LayoutUnit shapeLogicalRight() const { return computedShapeLogicalBoundingBo x().maxX() + logicalLeftOffset(); } |
| 106 LayoutUnit shapeLogicalWidth() const { return computedShapeLogicalBoundingBo x().width(); } | 102 LayoutUnit shapeLogicalWidth() const { return computedShapeLogicalBoundingBo x().width(); } |
| 107 LayoutUnit shapeLogicalHeight() const { return computedShapeLogicalBoundingB ox().height(); } | 103 LayoutUnit shapeLogicalHeight() const { return computedShapeLogicalBoundingB ox().height(); } |
| 108 | 104 |
| 109 LayoutUnit logicalLineTop() const { return m_shapeLineTop + logicalTopOffset (); } | 105 LayoutUnit logicalLineTop() const { return m_referenceBoxLineTop + logicalTo pOffset(); } |
| 110 LayoutUnit logicalLineBottom() const { return m_shapeLineTop + m_lineHeight + logicalTopOffset(); } | 106 LayoutUnit logicalLineBottom() const { return m_referenceBoxLineTop + m_line Height + logicalTopOffset(); } |
| 111 | 107 |
| 112 LayoutUnit shapeContainingBlockHeight() const { return (m_renderer->style()- >boxSizing() == CONTENT_BOX) ? (m_shapeLogicalSize.height() + m_renderer->border AndPaddingLogicalHeight()) : m_shapeLogicalSize.height(); } | 108 LayoutUnit shapeContainingBlockHeight() const { return (m_renderer->style()- >boxSizing() == CONTENT_BOX) ? (m_referenceBoxLogicalSize.height() + m_renderer- >borderAndPaddingLogicalHeight()) : m_referenceBoxLogicalSize.height(); } |
| 113 | 109 |
| 114 virtual bool lineOverlapsShapeBounds() const = 0; | 110 virtual bool lineOverlapsShapeBounds() const = 0; |
| 115 | 111 |
| 116 void dirtyShapeSize() { m_shape.clear(); } | 112 void markShapeAsDirty() { m_shape.clear(); } |
| 117 bool shapeSizeDirty() { return !m_shape.get(); } | 113 bool isShapeDirty() { return !m_shape.get(); } |
| 118 const RenderType* owner() const { return m_renderer; } | 114 const RenderType* owner() const { return m_renderer; } |
| 119 LayoutSize shapeSize() const { return m_shapeLogicalSize; } | 115 LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; } |
| 120 | 116 |
| 121 protected: | 117 protected: |
| 122 ShapeInfo(const RenderType* renderer): m_renderer(renderer) { } | 118 ShapeInfo(const RenderType* renderer): m_renderer(renderer) { } |
| 123 | 119 |
| 124 const Shape* computedShape() const; | 120 const Shape* computedShape() const; |
| 125 | 121 |
| 126 virtual LayoutBox resolvedLayoutBox() const = 0; | 122 virtual LayoutBox referenceBox() const = 0; |
|
leviw_travelin_and_unemployed
2014/03/03 23:07:20
I'm not sure how much is me understanding the spec
| |
| 127 virtual LayoutRect computedShapeLogicalBoundingBox() const = 0; | 123 virtual LayoutRect computedShapeLogicalBoundingBox() const = 0; |
| 128 virtual ShapeValue* shapeValue() const = 0; | 124 virtual ShapeValue* shapeValue() const = 0; |
| 129 virtual void getIntervals(LayoutUnit, LayoutUnit, SegmentList&) const = 0; | 125 virtual void getIntervals(LayoutUnit, LayoutUnit, SegmentList&) const = 0; |
| 130 | 126 |
| 131 LayoutUnit logicalTopOffset() const | 127 LayoutUnit logicalTopOffset() const |
| 132 { | 128 { |
| 133 switch (resolvedLayoutBox()) { | 129 switch (referenceBox()) { |
| 134 case MarginBox: | 130 case MarginBox: |
| 135 return -m_renderer->marginBefore(); | 131 return -m_renderer->marginBefore(); |
| 136 case BorderBox: | 132 case BorderBox: |
| 137 return LayoutUnit(); | 133 return LayoutUnit(); |
| 138 case PaddingBox: | 134 case PaddingBox: |
| 139 return m_renderer->borderBefore(); | 135 return m_renderer->borderBefore(); |
| 140 case ContentBox: | 136 case ContentBox: |
| 141 return m_renderer->borderAndPaddingBefore(); | 137 return m_renderer->borderAndPaddingBefore(); |
| 142 case BoxMissing: | 138 case BoxMissing: |
| 143 // A non-missing box value must be supplied. | 139 // A non-missing box value must be supplied. |
| 144 ASSERT_NOT_REACHED(); | 140 ASSERT_NOT_REACHED(); |
| 145 } | 141 } |
| 146 return LayoutUnit(); | 142 return LayoutUnit(); |
| 147 } | 143 } |
| 148 | 144 |
| 149 LayoutUnit logicalLeftOffset() const | 145 LayoutUnit logicalLeftOffset() const |
| 150 { | 146 { |
| 151 switch (resolvedLayoutBox()) { | 147 switch (referenceBox()) { |
| 152 case MarginBox: | 148 case MarginBox: |
| 153 return -m_renderer->marginStart(); | 149 return -m_renderer->marginStart(); |
| 154 case BorderBox: | 150 case BorderBox: |
| 155 return LayoutUnit(); | 151 return LayoutUnit(); |
| 156 case PaddingBox: | 152 case PaddingBox: |
| 157 return m_renderer->borderStart(); | 153 return m_renderer->borderStart(); |
| 158 case ContentBox: | 154 case ContentBox: |
| 159 return m_renderer->borderAndPaddingStart(); | 155 return m_renderer->borderAndPaddingStart(); |
| 160 case BoxMissing: | 156 case BoxMissing: |
| 161 // A non-missing box value must be supplied. | 157 // A non-missing box value must be supplied. |
| 162 ASSERT_NOT_REACHED(); | 158 ASSERT_NOT_REACHED(); |
| 163 } | 159 } |
| 164 return LayoutUnit(); | 160 return LayoutUnit(); |
| 165 } | 161 } |
| 166 | 162 |
| 167 LayoutUnit m_shapeLineTop; | 163 LayoutUnit m_referenceBoxLineTop; |
| 168 LayoutUnit m_lineHeight; | 164 LayoutUnit m_lineHeight; |
| 169 | 165 |
| 170 const RenderType* m_renderer; | 166 const RenderType* m_renderer; |
| 171 | 167 |
| 172 private: | 168 private: |
| 173 mutable OwnPtr<Shape> m_shape; | 169 mutable OwnPtr<Shape> m_shape; |
| 174 LayoutSize m_shapeLogicalSize; | 170 LayoutSize m_referenceBoxLogicalSize; |
| 175 }; | 171 }; |
| 176 | 172 |
| 177 bool checkShapeImageOrigin(Document&, ImageResource&); | 173 bool checkShapeImageOrigin(Document&, ImageResource&); |
| 178 | 174 |
| 179 } | 175 } |
| 180 #endif | 176 #endif |
| OLD | NEW |