| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above | |
| 9 * copyright notice, this list of conditions and the following | |
| 10 * disclaimer. | |
| 11 * 2. Redistributions in binary form must reproduce the above | |
| 12 * copyright notice, this list of conditions and the following | |
| 13 * disclaimer in the documentation and/or other materials | |
| 14 * provided with the distribution. | |
| 15 * | |
| 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY | |
| 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE | |
| 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | |
| 21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
| 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | |
| 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 27 * SUCH DAMAGE. | |
| 28 */ | |
| 29 | |
| 30 #include "config.h" | |
| 31 #include "core/rendering/shapes/ShapeInsideInfo.h" | |
| 32 | |
| 33 #include "core/rendering/InlineIterator.h" | |
| 34 #include "core/rendering/RenderBlock.h" | |
| 35 | |
| 36 namespace WebCore { | |
| 37 | |
| 38 LineSegmentRange::LineSegmentRange(const InlineIterator& start, const InlineIter
ator& end) | |
| 39 : start(start.root(), start.object(), start.offset()) | |
| 40 , end(end.root(), end.object(), end.offset()) | |
| 41 { | |
| 42 } | |
| 43 | |
| 44 bool ShapeInsideInfo::isEnabledFor(const RenderBlock& renderer) | |
| 45 { | |
| 46 ShapeValue* shapeValue = renderer.style()->resolvedShapeInside(); | |
| 47 if (!shapeValue) | |
| 48 return false; | |
| 49 | |
| 50 switch (shapeValue->type()) { | |
| 51 case ShapeValue::Shape: | |
| 52 return shapeValue->shape() && shapeValue->shape()->type() != BasicShape:
:BasicShapeInsetType; | |
| 53 case ShapeValue::Image: | |
| 54 return shapeValue->isImageValid() && checkShapeImageOrigin(renderer.docu
ment(), *(shapeValue->image()->cachedImage())); | |
| 55 case ShapeValue::Box: | |
| 56 return true; | |
| 57 case ShapeValue::Outside: | |
| 58 return false; | |
| 59 } | |
| 60 | |
| 61 return false; | |
| 62 } | |
| 63 | |
| 64 bool ShapeInsideInfo::updateSegmentsForLine(LayoutSize lineOffset, LayoutUnit li
neHeight) | |
| 65 { | |
| 66 bool result = updateSegmentsForLine(lineOffset.height(), lineHeight); | |
| 67 for (size_t i = 0; i < m_segments.size(); i++) { | |
| 68 m_segments[i].logicalLeft -= lineOffset.width(); | |
| 69 m_segments[i].logicalRight -= lineOffset.width(); | |
| 70 } | |
| 71 return result; | |
| 72 } | |
| 73 | |
| 74 bool ShapeInsideInfo::updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineH
eight) | |
| 75 { | |
| 76 ASSERT(lineHeight >= 0); | |
| 77 m_referenceBoxLineTop = lineTop - logicalTopOffset(); | |
| 78 m_lineHeight = lineHeight; | |
| 79 m_segments.clear(); | |
| 80 m_segmentRanges.clear(); | |
| 81 | |
| 82 if (lineOverlapsShapeBounds()) | |
| 83 m_segments = computeSegmentsForLine(lineTop, lineHeight); | |
| 84 | |
| 85 return m_segments.size(); | |
| 86 } | |
| 87 | |
| 88 bool ShapeInsideInfo::adjustLogicalLineTop(float minSegmentWidth) | |
| 89 { | |
| 90 const Shape& shape = computedShape(); | |
| 91 if (m_lineHeight <= 0 || logicalLineTop() > shapeLogicalBottom()) | |
| 92 return false; | |
| 93 | |
| 94 LayoutUnit newLineTop; | |
| 95 if (shape.firstIncludedIntervalLogicalTop(m_referenceBoxLineTop, FloatSize(m
inSegmentWidth, m_lineHeight.toFloat()), newLineTop)) { | |
| 96 if (newLineTop > m_referenceBoxLineTop) { | |
| 97 m_referenceBoxLineTop = newLineTop; | |
| 98 return true; | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 return false; | |
| 103 } | |
| 104 | |
| 105 ShapeValue* ShapeInsideInfo::shapeValue() const | |
| 106 { | |
| 107 return m_renderer.style()->resolvedShapeInside(); | |
| 108 } | |
| 109 | |
| 110 const RenderStyle* ShapeInsideInfo::styleForWritingMode() const | |
| 111 { | |
| 112 return m_renderer.style(); | |
| 113 } | |
| 114 | |
| 115 LayoutUnit ShapeInsideInfo::computeFirstFitPositionForFloat(const FloatSize& flo
atSize) const | |
| 116 { | |
| 117 if (!floatSize.width() || shapeLogicalBottom() < logicalLineTop()) | |
| 118 return 0; | |
| 119 | |
| 120 LayoutUnit firstFitPosition = 0; | |
| 121 if (computedShape().firstIncludedIntervalLogicalTop(m_referenceBoxLineTop, f
loatSize, firstFitPosition) && (m_referenceBoxLineTop <= firstFitPosition)) | |
| 122 return firstFitPosition; | |
| 123 | |
| 124 return 0; | |
| 125 } | |
| 126 | |
| 127 } | |
| OLD | NEW |