| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 clipRect.move(0, c); | 1212 clipRect.move(0, c); |
| 1213 clipRect.contract(0, c); | 1213 clipRect.contract(0, c); |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 if (!style()->clipBottom().isAuto()) | 1216 if (!style()->clipBottom().isAuto()) |
| 1217 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight())); | 1217 clipRect.contract(0, height() - valueForLength(style()->clipBottom(), he
ight())); |
| 1218 | 1218 |
| 1219 return clipRect; | 1219 return clipRect; |
| 1220 } | 1220 } |
| 1221 | 1221 |
| 1222 static LayoutUnit portionOfMarginNotConsumedByFloat(LayoutUnit childMargin, Layo
utUnit contentSide, LayoutUnit offset) | |
| 1223 { | |
| 1224 if (childMargin <= 0) | |
| 1225 return 0; | |
| 1226 LayoutUnit contentSideWithMargin = contentSide + childMargin; | |
| 1227 if (offset > contentSideWithMargin) | |
| 1228 return childMargin; | |
| 1229 return offset - contentSide; | |
| 1230 } | |
| 1231 | |
| 1232 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb) const | |
| 1233 { | |
| 1234 LayoutUnit width = cb->availableLogicalWidthForLine(false) - std::max<Layout
Unit>(0, childMarginStart) - std::max<LayoutUnit>(0, childMarginEnd); | |
| 1235 | |
| 1236 // We need to see if margins on either the start side or the end side can co
ntain the floats in question. If they can, | |
| 1237 // then just using the line width is inaccurate. In the case where a float c
ompletely fits, we don't need to use the line | |
| 1238 // offset at all, but can instead push all the way to the content edge of th
e containing block. In the case where the float | |
| 1239 // doesn't fit, we can use the line offset, but we need to grow it by the ma
rgin to reflect the fact that the margin was | |
| 1240 // "consumed" by the float. Negative margins aren't consumed by the float, a
nd so we ignore them. | |
| 1241 width += portionOfMarginNotConsumedByFloat(childMarginStart, cb->startOffset
ForContent(), cb->startOffsetForLine(false)); | |
| 1242 width += portionOfMarginNotConsumedByFloat(childMarginEnd, cb->endOffsetForC
ontent(), cb->endOffsetForLine(false)); | |
| 1243 return width; | |
| 1244 } | |
| 1245 | |
| 1246 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei
ghtType heightType) const | 1222 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei
ghtType heightType) const |
| 1247 { | 1223 { |
| 1248 return containingBlock()->availableLogicalHeight(heightType); | 1224 return containingBlock()->availableLogicalHeight(heightType); |
| 1249 } | 1225 } |
| 1250 | 1226 |
| 1251 LayoutUnit RenderBox::containingBlockAvailableLineWidth() const | |
| 1252 { | |
| 1253 RenderBlock* cb = containingBlock(); | |
| 1254 if (cb->isRenderBlockFlow()) | |
| 1255 return toRenderBlockFlow(cb)->availableLogicalWidthForLine(false); | |
| 1256 return 0; | |
| 1257 } | |
| 1258 | |
| 1259 void RenderBox::mapLocalToContainer(const RenderLayerModelObject* paintInvalidat
ionContainer, TransformState& transformState, MapCoordinatesFlags mode, const Pa
intInvalidationState* paintInvalidationState) const | 1227 void RenderBox::mapLocalToContainer(const RenderLayerModelObject* paintInvalidat
ionContainer, TransformState& transformState, MapCoordinatesFlags mode, const Pa
intInvalidationState* paintInvalidationState) const |
| 1260 { | 1228 { |
| 1261 if (paintInvalidationContainer == this) | 1229 if (paintInvalidationContainer == this) |
| 1262 return; | 1230 return; |
| 1263 | 1231 |
| 1264 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { | 1232 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
| 1265 LayoutSize offset = paintInvalidationState->paintOffset() + locationOffs
et(); | 1233 LayoutSize offset = paintInvalidationState->paintOffset() + locationOffs
et(); |
| 1266 if (style()->hasInFlowPosition() && layer()) | 1234 if (style()->hasInFlowPosition() && layer()) |
| 1267 offset += layer()->offsetForInFlowPosition(); | 1235 offset += layer()->offsetForInFlowPosition(); |
| 1268 transformState.move(offset); | 1236 transformState.move(offset); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1299 | 1267 |
| 1300 LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoi
nt& point, bool* offsetDependsOnPoint) const | 1268 LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoi
nt& point, bool* offsetDependsOnPoint) const |
| 1301 { | 1269 { |
| 1302 ASSERT(o == container()); | 1270 ASSERT(o == container()); |
| 1303 | 1271 |
| 1304 LayoutSize offset; | 1272 LayoutSize offset; |
| 1305 if (isRelPositioned()) | 1273 if (isRelPositioned()) |
| 1306 offset += offsetForInFlowPosition(); | 1274 offset += offsetForInFlowPosition(); |
| 1307 | 1275 |
| 1308 if (!isInline() || isReplaced()) | 1276 if (!isInline() || isReplaced()) |
| 1309 offset += topLeftLocationOffset(); | 1277 offset += locationOffset(); |
| 1310 | 1278 |
| 1311 if (o->hasOverflowClip()) | 1279 if (o->hasOverflowClip()) |
| 1312 offset -= toRenderBox(o)->scrolledContentOffset(); | 1280 offset -= toRenderBox(o)->scrolledContentOffset(); |
| 1313 | 1281 |
| 1314 if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->is
RenderInline()) | 1282 if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->is
RenderInline()) |
| 1315 offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this); | 1283 offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this); |
| 1316 | 1284 |
| 1317 return offset; | 1285 return offset; |
| 1318 } | 1286 } |
| 1319 | 1287 |
| (...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3297 } | 3265 } |
| 3298 | 3266 |
| 3299 return LayoutBoxExtent(top, right, bottom, left); | 3267 return LayoutBoxExtent(top, right, bottom, left); |
| 3300 } | 3268 } |
| 3301 | 3269 |
| 3302 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta) | 3270 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta) |
| 3303 { | 3271 { |
| 3304 // Only propagate layout overflow from the child if the child isn't clipping
its overflow. If it is, then | 3272 // Only propagate layout overflow from the child if the child isn't clipping
its overflow. If it is, then |
| 3305 // its overflow is internal to it, and we don't care about it. layoutOverfl
owRectForPropagation takes care of this | 3273 // its overflow is internal to it, and we don't care about it. layoutOverfl
owRectForPropagation takes care of this |
| 3306 // and just propagates the border box rect instead. | 3274 // and just propagates the border box rect instead. |
| 3307 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation
(style()); | 3275 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation
(); |
| 3308 childLayoutOverflowRect.move(delta); | 3276 childLayoutOverflowRect.move(delta); |
| 3309 addLayoutOverflow(childLayoutOverflowRect); | 3277 addLayoutOverflow(childLayoutOverflowRect); |
| 3310 | 3278 |
| 3311 // Add in visual overflow from the child. Even if the child clips its overf
low, it may still | 3279 // Add in visual overflow from the child. Even if the child clips its overf
low, it may still |
| 3312 // have visual overflow of its own set from box shadows or reflections. It
is unnecessary to propagate this | 3280 // have visual overflow of its own set from box shadows or reflections. It
is unnecessary to propagate this |
| 3313 // overflow if we are clipping our own overflow. | 3281 // overflow if we are clipping our own overflow. |
| 3314 if (child->hasSelfPaintingLayer()) | 3282 if (child->hasSelfPaintingLayer()) |
| 3315 return; | 3283 return; |
| 3316 LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation
(style()); | 3284 LayoutRect childVisualOverflowRect = child->visualOverflowRect(); |
| 3317 childVisualOverflowRect.move(delta); | 3285 childVisualOverflowRect.move(delta); |
| 3318 addContentsVisualOverflow(childVisualOverflowRect); | 3286 addContentsVisualOverflow(childVisualOverflowRect); |
| 3319 } | 3287 } |
| 3320 | 3288 |
| 3321 void RenderBox::addLayoutOverflow(const LayoutRect& rect) | 3289 void RenderBox::addLayoutOverflow(const LayoutRect& rect) |
| 3322 { | 3290 { |
| 3323 LayoutRect clientBox = noOverflowRect(); | 3291 LayoutRect clientBox = paddingBoxRect(); |
| 3324 if (clientBox.contains(rect) || rect.isEmpty()) | 3292 if (clientBox.contains(rect) || rect.isEmpty()) |
| 3325 return; | 3293 return; |
| 3326 | 3294 |
| 3327 // For overflow clip objects, we don't want to propagate overflow into unrea
chable areas. | 3295 // For overflow clip objects, we don't want to propagate overflow into unrea
chable areas. |
| 3328 LayoutRect overflowRect(rect); | 3296 LayoutRect overflowRect(rect); |
| 3329 if (hasOverflowClip() || isRenderView()) { | 3297 if (hasOverflowClip() || isRenderView()) { |
| 3330 // Overflow is in the block's coordinate space and thus is flipped for h
orizontal-bt and vertical-rl | 3298 // Overflow is in the block's coordinate space and thus is flipped for h
orizontal-bt and vertical-rl |
| 3331 // writing modes. At this stage that is actually a simplification, sinc
e we can treat horizontal-tb/bt as the same | 3299 // writing modes. At this stage that is actually a simplification, sinc
e we can treat horizontal-tb/bt as the same |
| 3332 // and vertical-lr/rl as the same. | 3300 // and vertical-lr/rl as the same. |
| 3333 bool hasTopOverflow = false; | 3301 bool hasTopOverflow = false; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3361 m_overflow->addLayoutOverflow(overflowRect); | 3329 m_overflow->addLayoutOverflow(overflowRect); |
| 3362 } | 3330 } |
| 3363 | 3331 |
| 3364 void RenderBox::addVisualOverflow(const LayoutRect& rect) | 3332 void RenderBox::addVisualOverflow(const LayoutRect& rect) |
| 3365 { | 3333 { |
| 3366 LayoutRect borderBox = borderBoxRect(); | 3334 LayoutRect borderBox = borderBoxRect(); |
| 3367 if (borderBox.contains(rect) || rect.isEmpty()) | 3335 if (borderBox.contains(rect) || rect.isEmpty()) |
| 3368 return; | 3336 return; |
| 3369 | 3337 |
| 3370 if (!m_overflow) | 3338 if (!m_overflow) |
| 3371 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox)); | 3339 m_overflow = adoptPtr(new RenderOverflow(paddingBoxRect(), borderBox)); |
| 3372 | 3340 |
| 3373 m_overflow->addVisualOverflow(rect); | 3341 m_overflow->addVisualOverflow(rect); |
| 3374 } | 3342 } |
| 3375 | 3343 |
| 3376 void RenderBox::addContentsVisualOverflow(const LayoutRect& rect) | 3344 void RenderBox::addContentsVisualOverflow(const LayoutRect& rect) |
| 3377 { | 3345 { |
| 3378 if (!hasOverflowClip()) { | 3346 if (!hasOverflowClip()) { |
| 3379 addVisualOverflow(rect); | 3347 addVisualOverflow(rect); |
| 3380 return; | 3348 return; |
| 3381 } | 3349 } |
| 3382 | 3350 |
| 3383 if (!m_overflow) | 3351 if (!m_overflow) |
| 3384 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBoxRect
())); | 3352 m_overflow = adoptPtr(new RenderOverflow(paddingBoxRect(), borderBoxRect
())); |
| 3385 m_overflow->addContentsVisualOverflow(rect); | 3353 m_overflow->addContentsVisualOverflow(rect); |
| 3386 } | 3354 } |
| 3387 | 3355 |
| 3388 void RenderBox::clearLayoutOverflow() | 3356 void RenderBox::clearLayoutOverflow() |
| 3389 { | 3357 { |
| 3390 if (!m_overflow) | 3358 if (!m_overflow) |
| 3391 return; | 3359 return; |
| 3392 | 3360 |
| 3393 if (!hasVisualOverflow() && contentsVisualOverflowRect().isEmpty()) { | 3361 if (!hasVisualOverflow() && contentsVisualOverflowRect().isEmpty()) { |
| 3394 clearAllOverflows(); | 3362 clearAllOverflows(); |
| 3395 return; | 3363 return; |
| 3396 } | 3364 } |
| 3397 | 3365 |
| 3398 m_overflow->setLayoutOverflow(noOverflowRect()); | 3366 m_overflow->setLayoutOverflow(paddingBoxRect()); |
| 3399 } | 3367 } |
| 3400 | 3368 |
| 3401 bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock*
containingBlock, bool isOutOfFlowPositioned) | 3369 bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock*
containingBlock, bool isOutOfFlowPositioned) |
| 3402 { | 3370 { |
| 3403 // In quirks mode, blocks with auto height are skipped, and we keep looking
for an enclosing | 3371 // In quirks mode, blocks with auto height are skipped, and we keep looking
for an enclosing |
| 3404 // block that may have a specified height and then use it. In strict mode, t
his violates the | 3372 // block that may have a specified height and then use it. In strict mode, t
his violates the |
| 3405 // specification, which states that percentage heights just revert to auto i
f the containing | 3373 // specification, which states that percentage heights just revert to auto i
f the containing |
| 3406 // block has an auto height. We still skip anonymous containing blocks in bo
th modes, though, and look | 3374 // block has an auto height. We still skip anonymous containing blocks in bo
th modes, though, and look |
| 3407 // only at explicit containers. | 3375 // only at explicit containers. |
| 3408 const RenderBlock* cb = containingBlock; | 3376 const RenderBlock* cb = containingBlock; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3460 const RenderObject* curr = this; | 3428 const RenderObject* curr = this; |
| 3461 while (curr) { | 3429 while (curr) { |
| 3462 RenderLayer* layer = curr->hasLayer() && curr->isBox() ? toRenderBox(cur
r)->layer() : 0; | 3430 RenderLayer* layer = curr->hasLayer() && curr->isBox() ? toRenderBox(cur
r)->layer() : 0; |
| 3463 if (layer && layer->isSelfPaintingLayer()) | 3431 if (layer && layer->isSelfPaintingLayer()) |
| 3464 return layer; | 3432 return layer; |
| 3465 curr = curr->parent(); | 3433 curr = curr->parent(); |
| 3466 } | 3434 } |
| 3467 return 0; | 3435 return 0; |
| 3468 } | 3436 } |
| 3469 | 3437 |
| 3470 LayoutRect RenderBox::logicalVisualOverflowRectForPropagation(RenderStyle* paren
tStyle) const | 3438 LayoutRect RenderBox::layoutOverflowRectForPropagation() const |
| 3471 { | |
| 3472 // FIXME(sky): Remove | |
| 3473 return visualOverflowRectForPropagation(parentStyle); | |
| 3474 } | |
| 3475 | |
| 3476 LayoutRect RenderBox::visualOverflowRectForPropagation(RenderStyle* parentStyle)
const | |
| 3477 { | |
| 3478 // FIXME(sky): Remove | |
| 3479 return visualOverflowRect(); | |
| 3480 } | |
| 3481 | |
| 3482 LayoutRect RenderBox::logicalLayoutOverflowRectForPropagation(RenderStyle* paren
tStyle) const | |
| 3483 { | |
| 3484 // FIXME(sky): Remove | |
| 3485 return layoutOverflowRectForPropagation(parentStyle); | |
| 3486 } | |
| 3487 | |
| 3488 LayoutRect RenderBox::layoutOverflowRectForPropagation(RenderStyle* parentStyle)
const | |
| 3489 { | 3439 { |
| 3490 // Only propagate interior layout overflow if we don't clip it. | 3440 // Only propagate interior layout overflow if we don't clip it. |
| 3491 LayoutRect rect = borderBoxRect(); | 3441 LayoutRect rect = borderBoxRect(); |
| 3492 rect.expand(LayoutSize(LayoutUnit(), marginAfter())); | 3442 rect.expand(LayoutSize(LayoutUnit(), marginAfter())); |
| 3493 | 3443 |
| 3494 if (!hasOverflowClip()) | 3444 if (!hasOverflowClip()) |
| 3495 rect.unite(layoutOverflowRect()); | 3445 rect.unite(layoutOverflowRect()); |
| 3496 | 3446 |
| 3497 bool hasTransform = hasLayer() && layer()->transform(); | 3447 bool hasTransform = hasLayer() && layer()->transform(); |
| 3498 if (isRelPositioned() || hasTransform) { | 3448 if (isRelPositioned() || hasTransform) { |
| 3499 if (hasTransform) | 3449 if (hasTransform) |
| 3500 rect = layer()->currentTransform().mapRect(rect); | 3450 rect = layer()->currentTransform().mapRect(rect); |
| 3501 | 3451 |
| 3502 if (isRelPositioned()) | 3452 if (isRelPositioned()) |
| 3503 rect.move(offsetForInFlowPosition()); | 3453 rect.move(offsetForInFlowPosition()); |
| 3504 } | 3454 } |
| 3505 | 3455 |
| 3506 return rect; | 3456 return rect; |
| 3507 } | 3457 } |
| 3508 | 3458 |
| 3509 LayoutRect RenderBox::noOverflowRect() const | |
| 3510 { | |
| 3511 // FIXME(sky): Replace with borderBoxRect? | |
| 3512 LayoutUnit left = borderLeft(); | |
| 3513 LayoutUnit top = borderTop(); | |
| 3514 LayoutUnit right = borderRight(); | |
| 3515 LayoutUnit bottom = borderBottom(); | |
| 3516 LayoutRect rect(left, top, width() - left - right, height() - top - bottom); | |
| 3517 return rect; | |
| 3518 } | |
| 3519 | |
| 3520 LayoutUnit RenderBox::offsetLeft() const | 3459 LayoutUnit RenderBox::offsetLeft() const |
| 3521 { | 3460 { |
| 3522 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).x(); | 3461 return adjustedPositionRelativeToOffsetParent(location()).x(); |
| 3523 } | 3462 } |
| 3524 | 3463 |
| 3525 LayoutUnit RenderBox::offsetTop() const | 3464 LayoutUnit RenderBox::offsetTop() const |
| 3526 { | 3465 { |
| 3527 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).y(); | 3466 return adjustedPositionRelativeToOffsetParent(location()).y(); |
| 3528 } | |
| 3529 | |
| 3530 LayoutPoint RenderBox::topLeftLocation() const | |
| 3531 { | |
| 3532 // FIXME(sky): Remove this. | |
| 3533 return location(); | |
| 3534 } | |
| 3535 | |
| 3536 LayoutSize RenderBox::topLeftLocationOffset() const | |
| 3537 { | |
| 3538 // FIXME(sky): Remove this. | |
| 3539 return locationOffset(); | |
| 3540 } | 3467 } |
| 3541 | 3468 |
| 3542 bool RenderBox::hasRelativeLogicalHeight() const | 3469 bool RenderBox::hasRelativeLogicalHeight() const |
| 3543 { | 3470 { |
| 3544 return style()->logicalHeight().isPercent() | 3471 return style()->logicalHeight().isPercent() |
| 3545 || style()->logicalMinHeight().isPercent() | 3472 || style()->logicalMinHeight().isPercent() |
| 3546 || style()->logicalMaxHeight().isPercent(); | 3473 || style()->logicalMaxHeight().isPercent(); |
| 3547 } | 3474 } |
| 3548 | 3475 |
| 3549 static void markBoxForRelayoutAfterSplit(RenderBox* box) | 3476 static void markBoxForRelayoutAfterSplit(RenderBox* box) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3625 | 3552 |
| 3626 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) | 3553 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) |
| 3627 { | 3554 { |
| 3628 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); | 3555 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); |
| 3629 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); | 3556 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); |
| 3630 ASSERT(hasBackground == style.hasBackground()); | 3557 ASSERT(hasBackground == style.hasBackground()); |
| 3631 hasBorder = style.hasBorder(); | 3558 hasBorder = style.hasBorder(); |
| 3632 } | 3559 } |
| 3633 | 3560 |
| 3634 } // namespace blink | 3561 } // namespace blink |
| OLD | NEW |