| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 CSSBoxType referenceBox(const ShapeValue& shapeValue) | 42 CSSBoxType referenceBox(const ShapeValue& shapeValue) |
| 43 { | 43 { |
| 44 if (shapeValue.cssBox() == BoxMissing) | 44 if (shapeValue.cssBox() == BoxMissing) |
| 45 return MarginBox; | 45 return MarginBox; |
| 46 return shapeValue.cssBox(); | 46 return shapeValue.cssBox(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogi
calSize) | 49 void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogi
calSize) |
| 50 { | 50 { |
| 51 bool isHorizontalWritingMode = m_renderer.containingBlock()->style()->isHori
zontalWritingMode(); | |
| 52 switch (referenceBox(*m_renderer.style()->shapeOutside())) { | 51 switch (referenceBox(*m_renderer.style()->shapeOutside())) { |
| 53 case MarginBox: | 52 case MarginBox: |
| 54 if (isHorizontalWritingMode) | 53 newReferenceBoxLogicalSize.expand(m_renderer.marginWidth(), m_renderer.m
arginHeight()); |
| 55 newReferenceBoxLogicalSize.expand(m_renderer.marginWidth(), m_render
er.marginHeight()); | |
| 56 else | |
| 57 newReferenceBoxLogicalSize.expand(m_renderer.marginHeight(), m_rende
rer.marginWidth()); | |
| 58 break; | 54 break; |
| 59 case BorderBox: | 55 case BorderBox: |
| 60 break; | 56 break; |
| 61 case PaddingBox: | 57 case PaddingBox: |
| 62 if (isHorizontalWritingMode) | 58 newReferenceBoxLogicalSize.shrink(m_renderer.borderWidth(), m_renderer.b
orderHeight()); |
| 63 newReferenceBoxLogicalSize.shrink(m_renderer.borderWidth(), m_render
er.borderHeight()); | |
| 64 else | |
| 65 newReferenceBoxLogicalSize.shrink(m_renderer.borderHeight(), m_rende
rer.borderWidth()); | |
| 66 break; | 59 break; |
| 67 case ContentBox: | 60 case ContentBox: |
| 68 if (isHorizontalWritingMode) | 61 newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingWidth(), m_
renderer.borderAndPaddingHeight()); |
| 69 newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingWidth()
, m_renderer.borderAndPaddingHeight()); | |
| 70 else | |
| 71 newReferenceBoxLogicalSize.shrink(m_renderer.borderAndPaddingHeight(
), m_renderer.borderAndPaddingWidth()); | |
| 72 break; | 62 break; |
| 73 case BoxMissing: | 63 case BoxMissing: |
| 74 ASSERT_NOT_REACHED(); | 64 ASSERT_NOT_REACHED(); |
| 75 break; | 65 break; |
| 76 } | 66 } |
| 77 | 67 |
| 78 if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize) | 68 if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize) |
| 79 return; | 69 return; |
| 80 markShapeAsDirty(); | 70 markShapeAsDirty(); |
| 81 m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; | 71 m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 case ContentBox: return borderAndPaddingBeforeInWritingMode(m_renderer); | 164 case ContentBox: return borderAndPaddingBeforeInWritingMode(m_renderer); |
| 175 case BoxMissing: break; | 165 case BoxMissing: break; |
| 176 } | 166 } |
| 177 | 167 |
| 178 ASSERT_NOT_REACHED(); | 168 ASSERT_NOT_REACHED(); |
| 179 return LayoutUnit(); | 169 return LayoutUnit(); |
| 180 } | 170 } |
| 181 | 171 |
| 182 inline LayoutUnit borderStartWithStyleForWritingMode(const RenderBox& renderer,
const RenderStyle* style) | 172 inline LayoutUnit borderStartWithStyleForWritingMode(const RenderBox& renderer,
const RenderStyle* style) |
| 183 { | 173 { |
| 184 if (style->isHorizontalWritingMode()) { | |
| 185 if (style->isLeftToRightDirection()) | |
| 186 return renderer.borderLeft(); | |
| 187 | |
| 188 return renderer.borderRight(); | |
| 189 } | |
| 190 if (style->isLeftToRightDirection()) | 174 if (style->isLeftToRightDirection()) |
| 191 return renderer.borderTop(); | 175 return renderer.borderLeft(); |
| 192 | 176 return renderer.borderRight(); |
| 193 return renderer.borderBottom(); | |
| 194 } | 177 } |
| 195 | 178 |
| 196 inline LayoutUnit borderAndPaddingStartWithStyleForWritingMode(const RenderBox&
renderer, const RenderStyle* style) | 179 inline LayoutUnit borderAndPaddingStartWithStyleForWritingMode(const RenderBox&
renderer, const RenderStyle* style) |
| 197 { | 180 { |
| 198 if (style->isHorizontalWritingMode()) { | 181 if (style->isLeftToRightDirection()) |
| 199 if (style->isLeftToRightDirection()) | 182 return renderer.borderLeft() + renderer.paddingLeft(); |
| 200 return renderer.borderLeft() + renderer.paddingLeft(); | |
| 201 | 183 |
| 202 return renderer.borderRight() + renderer.paddingRight(); | 184 return renderer.borderRight() + renderer.paddingRight(); |
| 203 } | |
| 204 if (style->isLeftToRightDirection()) | |
| 205 return renderer.borderTop() + renderer.paddingTop(); | |
| 206 | |
| 207 return renderer.borderBottom() + renderer.paddingBottom(); | |
| 208 } | 185 } |
| 209 | 186 |
| 210 LayoutUnit ShapeOutsideInfo::logicalLeftOffset() const | 187 LayoutUnit ShapeOutsideInfo::logicalLeftOffset() const |
| 211 { | 188 { |
| 212 switch (referenceBox(*m_renderer.style()->shapeOutside())) { | 189 switch (referenceBox(*m_renderer.style()->shapeOutside())) { |
| 213 case MarginBox: return -m_renderer.marginStart(m_renderer.containingBlock()-
>style()); | 190 case MarginBox: return -m_renderer.marginStart(m_renderer.containingBlock()-
>style()); |
| 214 case BorderBox: return LayoutUnit(); | 191 case BorderBox: return LayoutUnit(); |
| 215 case PaddingBox: return borderStartWithStyleForWritingMode(m_renderer, m_ren
derer.containingBlock()->style()); | 192 case PaddingBox: return borderStartWithStyleForWritingMode(m_renderer, m_ren
derer.containingBlock()->style()); |
| 216 case ContentBox: return borderAndPaddingStartWithStyleForWritingMode(m_rende
rer, m_renderer.containingBlock()->style()); | 193 case ContentBox: return borderAndPaddingStartWithStyleForWritingMode(m_rende
rer, m_renderer.containingBlock()->style()); |
| 217 case BoxMissing: break; | 194 case BoxMissing: break; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 244 { | 221 { |
| 245 // FIXME(sky): Remove this. | 222 // FIXME(sky): Remove this. |
| 246 return ShapeOutsideDeltas(); | 223 return ShapeOutsideDeltas(); |
| 247 } | 224 } |
| 248 | 225 |
| 249 LayoutRect ShapeOutsideInfo::computedShapePhysicalBoundingBox() const | 226 LayoutRect ShapeOutsideInfo::computedShapePhysicalBoundingBox() const |
| 250 { | 227 { |
| 251 LayoutRect physicalBoundingBox = computedShape().shapeMarginLogicalBoundingB
ox(); | 228 LayoutRect physicalBoundingBox = computedShape().shapeMarginLogicalBoundingB
ox(); |
| 252 physicalBoundingBox.setX(physicalBoundingBox.x() + logicalLeftOffset()); | 229 physicalBoundingBox.setX(physicalBoundingBox.x() + logicalLeftOffset()); |
| 253 | 230 |
| 254 if (m_renderer.style()->isFlippedBlocksWritingMode()) | 231 // FIXME(sky): Doing this twice doesn't seem right, but it's what the old co
de did. |
| 255 physicalBoundingBox.setY(m_renderer.logicalHeight() - physicalBoundingBo
x.maxY()); | 232 physicalBoundingBox.setY(physicalBoundingBox.y() + logicalTopOffset()); |
| 256 else | 233 physicalBoundingBox.setY(physicalBoundingBox.y() + logicalTopOffset()); |
| 257 physicalBoundingBox.setY(physicalBoundingBox.y() + logicalTopOffset()); | |
| 258 | |
| 259 if (!m_renderer.style()->isHorizontalWritingMode()) | |
| 260 physicalBoundingBox = physicalBoundingBox.transposedRect(); | |
| 261 else | |
| 262 physicalBoundingBox.setY(physicalBoundingBox.y() + logicalTopOffset()); | |
| 263 | 234 |
| 264 return physicalBoundingBox; | 235 return physicalBoundingBox; |
| 265 } | 236 } |
| 266 | 237 |
| 267 FloatPoint ShapeOutsideInfo::shapeToRendererPoint(FloatPoint point) const | 238 FloatPoint ShapeOutsideInfo::shapeToRendererPoint(FloatPoint point) const |
| 268 { | 239 { |
| 269 FloatPoint result = FloatPoint(point.x() + logicalLeftOffset(), point.y() +
logicalTopOffset()); | 240 return FloatPoint(point.x() + logicalLeftOffset(), point.y() + logicalTopOff
set()); |
| 270 if (m_renderer.style()->isFlippedBlocksWritingMode()) | |
| 271 result.setY(m_renderer.logicalHeight() - result.y()); | |
| 272 if (!m_renderer.style()->isHorizontalWritingMode()) | |
| 273 result = result.transposedPoint(); | |
| 274 return result; | |
| 275 } | 241 } |
| 276 | 242 |
| 277 FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const | 243 FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const |
| 278 { | 244 { |
| 279 if (!m_renderer.style()->isHorizontalWritingMode()) | |
| 280 return size.transposedSize(); | |
| 281 return size; | 245 return size; |
| 282 } | 246 } |
| 283 | 247 |
| 284 } // namespace blink | 248 } // namespace blink |
| OLD | NEW |