| 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 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/rendering/shapes/ShapeOutsideInfo.h" | 31 #include "core/rendering/shapes/ShapeOutsideInfo.h" |
| 32 | 32 |
| 33 #include "core/rendering/FloatingObjects.h" | 33 #include "core/rendering/FloatingObjects.h" |
| 34 #include "core/rendering/RenderBlockFlow.h" | 34 #include "core/rendering/RenderBlockFlow.h" |
| 35 #include "core/rendering/RenderBox.h" | 35 #include "core/rendering/RenderBox.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 bool ShapeOutsideInfo::isEnabledFor(const RenderBox* box) | 38 bool ShapeOutsideInfo::isEnabledFor(const RenderBox& box) |
| 39 { | 39 { |
| 40 ShapeValue* shapeValue = box->style()->shapeOutside(); | 40 ShapeValue* shapeValue = box.style()->shapeOutside(); |
| 41 if (!box->isFloating() || !shapeValue) | 41 if (!box.isFloating() || !shapeValue) |
| 42 return false; | 42 return false; |
| 43 | 43 |
| 44 switch (shapeValue->type()) { | 44 switch (shapeValue->type()) { |
| 45 case ShapeValue::Shape: | 45 case ShapeValue::Shape: |
| 46 return shapeValue->shape(); | 46 return shapeValue->shape(); |
| 47 case ShapeValue::Image: | 47 case ShapeValue::Image: |
| 48 return shapeValue->isImageValid() && checkShapeImageOrigin(box->document
(), *(shapeValue->image()->cachedImage())); | 48 return shapeValue->isImageValid() && checkShapeImageOrigin(box.document(
), *(shapeValue->image()->cachedImage())); |
| 49 case ShapeValue::Box: | 49 case ShapeValue::Box: |
| 50 return true; | 50 return true; |
| 51 case ShapeValue::Outside: | 51 case ShapeValue::Outside: |
| 52 return false; | 52 return false; |
| 53 } | 53 } |
| 54 | 54 |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow*
containingBlock, const FloatingObject* floatingObject, LayoutUnit lineTop, Layo
utUnit lineHeight) | 58 void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow&
containingBlock, const FloatingObject& floatingObject, LayoutUnit lineTop, Layo
utUnit lineHeight) |
| 59 { | 59 { |
| 60 LayoutUnit borderBoxTop = containingBlock->logicalTopForFloat(floatingObject
) + std::max(LayoutUnit(), containingBlock->marginBeforeForChild(m_renderer)); | 60 LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(&floatingObject
) + std::max(LayoutUnit(), containingBlock.marginBeforeForChild(&m_renderer)); |
| 61 LayoutUnit borderBoxLineTop = lineTop - borderBoxTop; | 61 LayoutUnit borderBoxLineTop = lineTop - borderBoxTop; |
| 62 | 62 |
| 63 if (isShapeDirty() || m_borderBoxLineTop != borderBoxLineTop || m_lineHeight
!= lineHeight) { | 63 if (isShapeDirty() || m_borderBoxLineTop != borderBoxLineTop || m_lineHeight
!= lineHeight) { |
| 64 m_borderBoxLineTop = borderBoxLineTop; | 64 m_borderBoxLineTop = borderBoxLineTop; |
| 65 m_referenceBoxLineTop = borderBoxLineTop - logicalTopOffset(); | 65 m_referenceBoxLineTop = borderBoxLineTop - logicalTopOffset(); |
| 66 m_lineHeight = lineHeight; | 66 m_lineHeight = lineHeight; |
| 67 | 67 |
| 68 LayoutUnit floatMarginBoxWidth = containingBlock->logicalWidthForFloat(f
loatingObject); | 68 LayoutUnit floatMarginBoxWidth = containingBlock.logicalWidthForFloat(&f
loatingObject); |
| 69 | 69 |
| 70 if (lineOverlapsShapeBounds()) { | 70 if (lineOverlapsShapeBounds()) { |
| 71 SegmentList segments = computeSegmentsForLine(borderBoxLineTop, line
Height); | 71 SegmentList segments = computeSegmentsForLine(borderBoxLineTop, line
Height); |
| 72 if (segments.size()) { | 72 if (segments.size()) { |
| 73 LayoutUnit rawLeftMarginBoxDelta = segments.first().logicalLeft
+ containingBlock->marginStartForChild(m_renderer); | 73 LayoutUnit rawLeftMarginBoxDelta = segments.first().logicalLeft
+ containingBlock.marginStartForChild(&m_renderer); |
| 74 m_leftMarginBoxDelta = clampTo<LayoutUnit>(rawLeftMarginBoxDelta
, LayoutUnit(), floatMarginBoxWidth); | 74 m_leftMarginBoxDelta = clampTo<LayoutUnit>(rawLeftMarginBoxDelta
, LayoutUnit(), floatMarginBoxWidth); |
| 75 | 75 |
| 76 LayoutUnit rawRightMarginBoxDelta = segments.last().logicalRight
- containingBlock->logicalWidthForChild(m_renderer) - containingBlock->marginEn
dForChild(m_renderer); | 76 LayoutUnit rawRightMarginBoxDelta = segments.last().logicalRight
- containingBlock.logicalWidthForChild(&m_renderer) - containingBlock.marginEnd
ForChild(&m_renderer); |
| 77 m_rightMarginBoxDelta = clampTo<LayoutUnit>(rawRightMarginBoxDel
ta, -floatMarginBoxWidth, LayoutUnit()); | 77 m_rightMarginBoxDelta = clampTo<LayoutUnit>(rawRightMarginBoxDel
ta, -floatMarginBoxWidth, LayoutUnit()); |
| 78 m_lineOverlapsShape = true; | 78 m_lineOverlapsShape = true; |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Lines that do not overlap the shape should act as if the float | 83 // Lines that do not overlap the shape should act as if the float |
| 84 // wasn't there for layout purposes. So we set the deltas to remove the | 84 // wasn't there for layout purposes. So we set the deltas to remove the |
| 85 // entire width of the float. | 85 // entire width of the float. |
| 86 m_leftMarginBoxDelta = floatMarginBoxWidth; | 86 m_leftMarginBoxDelta = floatMarginBoxWidth; |
| 87 m_rightMarginBoxDelta = -floatMarginBoxWidth; | 87 m_rightMarginBoxDelta = -floatMarginBoxWidth; |
| 88 m_lineOverlapsShape = false; | 88 m_lineOverlapsShape = false; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 ShapeValue* ShapeOutsideInfo::shapeValue() const | 92 ShapeValue* ShapeOutsideInfo::shapeValue() const |
| 93 { | 93 { |
| 94 return m_renderer->style()->shapeOutside(); | 94 return m_renderer.style()->shapeOutside(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } | 97 } |
| OLD | NEW |