| 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 19 matching lines...) Expand all Loading... |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/rendering/exclusions/ExclusionShapeInfo.h" | 31 #include "core/rendering/exclusions/ExclusionShapeInfo.h" |
| 32 | 32 |
| 33 #include "core/rendering/exclusions/ExclusionShape.h" | 33 #include "core/rendering/exclusions/ExclusionShape.h" |
| 34 #include "core/rendering/RenderBlock.h" | 34 #include "core/rendering/RenderBlock.h" |
| 35 #include "core/rendering/RenderBox.h" | 35 #include "core/rendering/RenderBox.h" |
| 36 #include "core/rendering/RenderRegion.h" | 36 #include "core/rendering/RenderRegion.h" |
| 37 #include "core/rendering/style/RenderStyle.h" | 37 #include "core/rendering/style/RenderStyle.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co
nst, void (ExclusionShape::*intervalGetter)(float, float, SegmentList&) const> | 40 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co
nst, void (ExclusionShape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&
) const> |
| 41 const ExclusionShape* ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter
>::computedShape() const | 41 const ExclusionShape* ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter
>::computedShape() const |
| 42 { | 42 { |
| 43 if (ExclusionShape* exclusionShape = m_shape.get()) | 43 if (ExclusionShape* exclusionShape = m_shape.get()) |
| 44 return exclusionShape; | 44 return exclusionShape; |
| 45 | 45 |
| 46 ExclusionShapeValue* shapeValue = (m_renderer->style()->*shapeGetter)(); | 46 ExclusionShapeValue* shapeValue = (m_renderer->style()->*shapeGetter)(); |
| 47 BasicShape* shape = (shapeValue && shapeValue->type() == ExclusionShapeValue
::SHAPE) ? shapeValue->shape() : 0; | 47 BasicShape* shape = (shapeValue && shapeValue->type() == ExclusionShapeValue
::SHAPE) ? shapeValue->shape() : 0; |
| 48 | 48 |
| 49 ASSERT(shape); | 49 ASSERT(shape); |
| 50 | 50 |
| 51 m_shape = ExclusionShape::createExclusionShape(shape, m_shapeLogicalWidth, m
_shapeLogicalHeight, m_renderer->style()->writingMode(), m_renderer->style()->sh
apeMargin(), m_renderer->style()->shapePadding()); | 51 m_shape = ExclusionShape::createExclusionShape(shape, LayoutSize(m_shapeLogi
calWidth, m_shapeLogicalHeight), m_renderer->style()->writingMode(), m_renderer-
>style()->shapeMargin(), m_renderer->style()->shapePadding()); |
| 52 ASSERT(m_shape); | 52 ASSERT(m_shape); |
| 53 return m_shape.get(); | 53 return m_shape.get(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co
nst, void (ExclusionShape::*intervalGetter)(float, float, SegmentList&) const> | 56 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co
nst, void (ExclusionShape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&
) const> |
| 57 LayoutUnit ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter>::logicalT
opOffset() const | 57 LayoutUnit ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter>::logicalT
opOffset() const |
| 58 { | 58 { |
| 59 LayoutUnit logicalTopOffset = m_renderer->style()->boxSizing() == CONTENT_BO
X ? m_renderer->borderBefore() + m_renderer->paddingBefore() : LayoutUnit(); | 59 LayoutUnit logicalTopOffset = m_renderer->style()->boxSizing() == CONTENT_BO
X ? m_renderer->borderBefore() + m_renderer->paddingBefore() : LayoutUnit(); |
| 60 // Content in a flow thread is relative to the beginning of the thread, but
the shape calculation should be relative to the current region. | 60 // Content in a flow thread is relative to the beginning of the thread, but
the shape calculation should be relative to the current region. |
| 61 if (m_renderer->isRenderRegion()) | 61 if (m_renderer->isRenderRegion()) |
| 62 logicalTopOffset += toRenderRegion(m_renderer)->logicalTopForFlowThreadC
ontent(); | 62 logicalTopOffset += toRenderRegion(m_renderer)->logicalTopForFlowThreadC
ontent(); |
| 63 return logicalTopOffset; | 63 return logicalTopOffset; |
| 64 } | 64 } |
| 65 | 65 |
| 66 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co
nst, void (ExclusionShape::*intervalGetter)(float, float, SegmentList&) const> | 66 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() co
nst, void (ExclusionShape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&
) const> |
| 67 bool ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter>::computeSegment
sForLine(LayoutUnit lineTop, LayoutUnit lineHeight) | 67 bool ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter>::computeSegment
sForLine(LayoutUnit lineTop, LayoutUnit lineHeight) |
| 68 { | 68 { |
| 69 ASSERT(lineHeight >= 0); | 69 ASSERT(lineHeight >= 0); |
| 70 m_shapeLineTop = lineTop - logicalTopOffset(); | 70 m_shapeLineTop = lineTop - logicalTopOffset(); |
| 71 m_lineHeight = lineHeight; | 71 m_lineHeight = lineHeight; |
| 72 m_segments.clear(); | 72 m_segments.clear(); |
| 73 | 73 |
| 74 if (lineOverlapsShapeBounds()) | 74 if (lineOverlapsShapeBounds()) |
| 75 (computedShape()->*intervalGetter)(m_shapeLineTop, std::min(m_lineHeight
, shapeLogicalBottom() - lineTop), m_segments); | 75 (computedShape()->*intervalGetter)(m_shapeLineTop, std::min(m_lineHeight
, shapeLogicalBottom() - lineTop), m_segments); |
| 76 | 76 |
| 77 LayoutUnit logicalLeftOffset = this->logicalLeftOffset(); | 77 LayoutUnit logicalLeftOffset = this->logicalLeftOffset(); |
| 78 for (size_t i = 0; i < m_segments.size(); i++) { | 78 for (size_t i = 0; i < m_segments.size(); i++) { |
| 79 m_segments[i].logicalLeft += logicalLeftOffset; | 79 m_segments[i].logicalLeft += logicalLeftOffset; |
| 80 m_segments[i].logicalRight += logicalLeftOffset; | 80 m_segments[i].logicalRight += logicalLeftOffset; |
| 81 } | 81 } |
| 82 | 82 |
| 83 return m_segments.size(); | 83 return m_segments.size(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 template class ExclusionShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside
, &ExclusionShape::getIncludedIntervals>; | 86 template class ExclusionShapeInfo<RenderBlock, &RenderStyle::resolvedShapeInside
, &ExclusionShape::getIncludedIntervals>; |
| 87 template class ExclusionShapeInfo<RenderBox, &RenderStyle::shapeOutside, &Exclus
ionShape::getExcludedIntervals>; | 87 template class ExclusionShapeInfo<RenderBox, &RenderStyle::shapeOutside, &Exclus
ionShape::getExcludedIntervals>; |
| 88 } | 88 } |
| OLD | NEW |