| 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 23 matching lines...) Expand all Loading... |
| 34 #include "core/rendering/RenderBlock.h" | 34 #include "core/rendering/RenderBlock.h" |
| 35 | 35 |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 LineSegmentRange::LineSegmentRange(const InlineIterator& start, const InlineIter
ator& end) | 38 LineSegmentRange::LineSegmentRange(const InlineIterator& start, const InlineIter
ator& end) |
| 39 : start(start.root(), start.object(), start.offset()) | 39 : start(start.root(), start.object(), start.offset()) |
| 40 , end(end.root(), end.object(), end.offset()) | 40 , end(end.root(), end.object(), end.offset()) |
| 41 { | 41 { |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool ShapeInsideInfo::isEnabledFor(const RenderBlock* renderer) | 44 bool ShapeInsideInfo::isEnabledFor(const RenderBlock& renderer) |
| 45 { | 45 { |
| 46 ShapeValue* shapeValue = renderer->style()->resolvedShapeInside(); | 46 ShapeValue* shapeValue = renderer.style()->resolvedShapeInside(); |
| 47 if (!shapeValue) | 47 if (!shapeValue) |
| 48 return false; | 48 return false; |
| 49 | 49 |
| 50 switch (shapeValue->type()) { | 50 switch (shapeValue->type()) { |
| 51 case ShapeValue::Shape: | 51 case ShapeValue::Shape: |
| 52 return shapeValue->shape() && shapeValue->shape()->type() != BasicShape:
:BasicShapeInsetRectangleType && shapeValue->shape()->type() != BasicShape::Basi
cShapeInsetType; | 52 return shapeValue->shape() && shapeValue->shape()->type() != BasicShape:
:BasicShapeInsetRectangleType && shapeValue->shape()->type() != BasicShape::Basi
cShapeInsetType; |
| 53 case ShapeValue::Image: | 53 case ShapeValue::Image: |
| 54 return shapeValue->isImageValid() && checkShapeImageOrigin(renderer->doc
ument(), *(shapeValue->image()->cachedImage())); | 54 return shapeValue->isImageValid() && checkShapeImageOrigin(renderer.docu
ment(), *(shapeValue->image()->cachedImage())); |
| 55 case ShapeValue::Box: | 55 case ShapeValue::Box: |
| 56 return true; | 56 return true; |
| 57 case ShapeValue::Outside: | 57 case ShapeValue::Outside: |
| 58 return false; | 58 return false; |
| 59 } | 59 } |
| 60 | 60 |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool ShapeInsideInfo::updateSegmentsForLine(LayoutSize lineOffset, LayoutUnit li
neHeight) | 64 bool ShapeInsideInfo::updateSegmentsForLine(LayoutSize lineOffset, LayoutUnit li
neHeight) |
| 65 { | 65 { |
| 66 bool result = updateSegmentsForLine(lineOffset.height(), lineHeight); | 66 bool result = updateSegmentsForLine(lineOffset.height(), lineHeight); |
| 67 for (size_t i = 0; i < m_segments.size(); i++) { | 67 for (size_t i = 0; i < m_segments.size(); i++) { |
| 68 m_segments[i].logicalLeft -= lineOffset.width(); | 68 m_segments[i].logicalLeft -= lineOffset.width(); |
| 69 m_segments[i].logicalRight -= lineOffset.width(); | 69 m_segments[i].logicalRight -= lineOffset.width(); |
| 70 } | 70 } |
| 71 return result; | 71 return result; |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool ShapeInsideInfo::updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineH
eight) | 74 bool ShapeInsideInfo::updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineH
eight) |
| 75 { | 75 { |
| 76 ASSERT(lineHeight >= 0); | 76 ASSERT(lineHeight >= 0); |
| 77 m_shapeLineTop = lineTop - logicalTopOffset(); | 77 m_referenceBoxLineTop = lineTop - logicalTopOffset(); |
| 78 m_lineHeight = lineHeight; | 78 m_lineHeight = lineHeight; |
| 79 m_segments.clear(); | 79 m_segments.clear(); |
| 80 m_segmentRanges.clear(); | 80 m_segmentRanges.clear(); |
| 81 | 81 |
| 82 if (lineOverlapsShapeBounds()) | 82 if (lineOverlapsShapeBounds()) |
| 83 m_segments = computeSegmentsForLine(lineTop, lineHeight); | 83 m_segments = computeSegmentsForLine(lineTop, lineHeight); |
| 84 | 84 |
| 85 return m_segments.size(); | 85 return m_segments.size(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool ShapeInsideInfo::adjustLogicalLineTop(float minSegmentWidth) | 88 bool ShapeInsideInfo::adjustLogicalLineTop(float minSegmentWidth) |
| 89 { | 89 { |
| 90 const Shape* shape = computedShape(); | 90 const Shape& shape = computedShape(); |
| 91 if (!shape || m_lineHeight <= 0 || logicalLineTop() > shapeLogicalBottom()) | 91 if (m_lineHeight <= 0 || logicalLineTop() > shapeLogicalBottom()) |
| 92 return false; | 92 return false; |
| 93 | 93 |
| 94 LayoutUnit newLineTop; | 94 LayoutUnit newLineTop; |
| 95 if (shape->firstIncludedIntervalLogicalTop(m_shapeLineTop, FloatSize(minSegm
entWidth, m_lineHeight), newLineTop)) { | 95 if (shape.firstIncludedIntervalLogicalTop(m_referenceBoxLineTop, FloatSize(m
inSegmentWidth, m_lineHeight), newLineTop)) { |
| 96 if (newLineTop > m_shapeLineTop) { | 96 if (newLineTop > m_referenceBoxLineTop) { |
| 97 m_shapeLineTop = newLineTop; | 97 m_referenceBoxLineTop = newLineTop; |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 | 104 |
| 105 ShapeValue* ShapeInsideInfo::shapeValue() const | 105 ShapeValue* ShapeInsideInfo::shapeValue() const |
| 106 { | 106 { |
| 107 return m_renderer->style()->resolvedShapeInside(); | 107 return m_renderer.style()->resolvedShapeInside(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 LayoutUnit ShapeInsideInfo::computeFirstFitPositionForFloat(const FloatSize& flo
atSize) const | 110 LayoutUnit ShapeInsideInfo::computeFirstFitPositionForFloat(const FloatSize& flo
atSize) const |
| 111 { | 111 { |
| 112 if (!computedShape() || !floatSize.width() || shapeLogicalBottom() < logical
LineTop()) | 112 if (!floatSize.width() || shapeLogicalBottom() < logicalLineTop()) |
| 113 return 0; | 113 return 0; |
| 114 | 114 |
| 115 LayoutUnit firstFitPosition = 0; | 115 LayoutUnit firstFitPosition = 0; |
| 116 if (computedShape()->firstIncludedIntervalLogicalTop(m_shapeLineTop, floatSi
ze, firstFitPosition) && (m_shapeLineTop <= firstFitPosition)) | 116 if (computedShape().firstIncludedIntervalLogicalTop(m_referenceBoxLineTop, f
loatSize, firstFitPosition) && (m_referenceBoxLineTop <= firstFitPosition)) |
| 117 return firstFitPosition; | 117 return firstFitPosition; |
| 118 | 118 |
| 119 return 0; | 119 return 0; |
| 120 } | 120 } |
| 121 | 121 |
| 122 } | 122 } |
| OLD | NEW |