| 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 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 | 369 |
| 370 static bool hasPercentageTransform(const ComputedStyle& style) | 370 static bool hasPercentageTransform(const ComputedStyle& style) |
| 371 { | 371 { |
| 372 if (TransformOperation* translate = style.translate()) { | 372 if (TransformOperation* translate = style.translate()) { |
| 373 if (translate->dependsOnBoxSize()) | 373 if (translate->dependsOnBoxSize()) |
| 374 return true; | 374 return true; |
| 375 } | 375 } |
| 376 return style.transform().dependsOnBoxSize() | 376 return style.transform().dependsOnBoxSize() |
| 377 || (style.transformOriginX() != Length(50, Percent) && style.transformOr
iginX().hasPercent()) | 377 || (style.transformOriginX() != Length(50, Percent) && style.transformOr
iginX().isPercentOrCalc()) |
| 378 || (style.transformOriginY() != Length(50, Percent) && style.transformOr
iginY().hasPercent()); | 378 || (style.transformOriginY() != Length(50, Percent) && style.transformOr
iginY().isPercentOrCalc()); |
| 379 } | 379 } |
| 380 | 380 |
| 381 void LayoutBoxModelObject::invalidateTreeIfNeeded(const PaintInvalidationState&
paintInvalidationState) | 381 void LayoutBoxModelObject::invalidateTreeIfNeeded(const PaintInvalidationState&
paintInvalidationState) |
| 382 { | 382 { |
| 383 ensureIsReadyForPaintInvalidation(); | 383 ensureIsReadyForPaintInvalidation(); |
| 384 | 384 |
| 385 PaintInvalidationState newPaintInvalidationState(paintInvalidationState, *th
is); | 385 PaintInvalidationState newPaintInvalidationState(paintInvalidationState, *th
is); |
| 386 if (!shouldCheckForPaintInvalidation(newPaintInvalidationState)) | 386 if (!shouldCheckForPaintInvalidation(newPaintInvalidationState)) |
| 387 return; | 387 return; |
| 388 | 388 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 { | 496 { |
| 497 return child->isOutOfFlowPositioned() && !child->style()->logicalTop().isAut
o() && !child->style()->logicalBottom().isAuto(); | 497 return child->isOutOfFlowPositioned() && !child->style()->logicalTop().isAut
o() && !child->style()->logicalBottom().isAuto(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 LayoutBlock* LayoutBoxModelObject::containingBlockForAutoHeightDetection(Length
logicalHeight) const | 500 LayoutBlock* LayoutBoxModelObject::containingBlockForAutoHeightDetection(Length
logicalHeight) const |
| 501 { | 501 { |
| 502 // For percentage heights: The percentage is calculated with respect to the
height of the generated box's | 502 // For percentage heights: The percentage is calculated with respect to the
height of the generated box's |
| 503 // containing block. If the height of the containing block is not specified
explicitly (i.e., it depends | 503 // containing block. If the height of the containing block is not specified
explicitly (i.e., it depends |
| 504 // on content height), and this element is not absolutely positioned, the u
sed height is calculated | 504 // on content height), and this element is not absolutely positioned, the u
sed height is calculated |
| 505 // as if 'auto' was specified. | 505 // as if 'auto' was specified. |
| 506 if (!logicalHeight.hasPercent() || isOutOfFlowPositioned()) | 506 if (!logicalHeight.isPercentOrCalc() || isOutOfFlowPositioned()) |
| 507 return nullptr; | 507 return nullptr; |
| 508 | 508 |
| 509 // Anonymous block boxes are ignored when resolving percentage values that w
ould refer to it: | 509 // Anonymous block boxes are ignored when resolving percentage values that w
ould refer to it: |
| 510 // the closest non-anonymous ancestor box is used instead. | 510 // the closest non-anonymous ancestor box is used instead. |
| 511 LayoutBlock* cb = containingBlock(); | 511 LayoutBlock* cb = containingBlock(); |
| 512 while (cb->isAnonymous()) | 512 while (cb->isAnonymous()) |
| 513 cb = cb->containingBlock(); | 513 cb = cb->containingBlock(); |
| 514 | 514 |
| 515 // Matching LayoutBox::percentageLogicalHeightIsResolvableFromBlock() by | 515 // Matching LayoutBox::percentageLogicalHeightIsResolvableFromBlock() by |
| 516 // ignoring table cell's attribute value, where it says that table cells vio
late | 516 // ignoring table cell's attribute value, where it says that table cells vio
late |
| (...skipping 12 matching lines...) Expand all Loading... |
| 529 | 529 |
| 530 return cb; | 530 return cb; |
| 531 } | 531 } |
| 532 | 532 |
| 533 bool LayoutBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight(bool che
ckingContainingBlock) const | 533 bool LayoutBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight(bool che
ckingContainingBlock) const |
| 534 { | 534 { |
| 535 // TODO(rego): Check if we can somehow reuse LayoutBlock::availableLogicalHe
ightForPercentageComputation() (see http://crbug.com/635655). | 535 // TODO(rego): Check if we can somehow reuse LayoutBlock::availableLogicalHe
ightForPercentageComputation() (see http://crbug.com/635655). |
| 536 const LayoutBox* thisBox = isBox() ? toLayoutBox(this) : nullptr; | 536 const LayoutBox* thisBox = isBox() ? toLayoutBox(this) : nullptr; |
| 537 Length logicalHeightLength = style()->logicalHeight(); | 537 Length logicalHeightLength = style()->logicalHeight(); |
| 538 LayoutBlock* cb = containingBlockForAutoHeightDetection(logicalHeightLength)
; | 538 LayoutBlock* cb = containingBlockForAutoHeightDetection(logicalHeightLength)
; |
| 539 if (logicalHeightLength.hasPercent() && cb && isBox()) | 539 if (logicalHeightLength.isPercentOrCalc() && cb && isBox()) |
| 540 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(toLayoutBox(this))
); | 540 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(toLayoutBox(this))
); |
| 541 if (thisBox && thisBox->isFlexItem()) { | 541 if (thisBox && thisBox->isFlexItem()) { |
| 542 LayoutFlexibleBox& flexBox = toLayoutFlexibleBox(*parent()); | 542 LayoutFlexibleBox& flexBox = toLayoutFlexibleBox(*parent()); |
| 543 if (flexBox.childLogicalHeightForPercentageResolution(*thisBox) != Layou
tUnit(-1)) | 543 if (flexBox.childLogicalHeightForPercentageResolution(*thisBox) != Layou
tUnit(-1)) |
| 544 return false; | 544 return false; |
| 545 } | 545 } |
| 546 if (thisBox && thisBox->isGridItem()) { | 546 if (thisBox && thisBox->isGridItem()) { |
| 547 if (checkingContainingBlock && thisBox->hasOverrideLogicalContentHeight(
)) | 547 if (checkingContainingBlock && thisBox->hasOverrideLogicalContentHeight(
)) |
| 548 return false; | 548 return false; |
| 549 if (!checkingContainingBlock && thisBox->hasOverrideContainingBlockLogic
alHeight()) | 549 if (!checkingContainingBlock && thisBox->hasOverrideContainingBlockLogic
alHeight()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 } | 586 } |
| 587 | 587 |
| 588 // If the containing block of a relatively positioned element does not | 588 // If the containing block of a relatively positioned element does not |
| 589 // specify a height, a percentage top or bottom offset should be resolved as | 589 // specify a height, a percentage top or bottom offset should be resolved as |
| 590 // auto. An exception to this is if the containing block has the WinIE quirk | 590 // auto. An exception to this is if the containing block has the WinIE quirk |
| 591 // where <html> and <body> assume the size of the viewport. In this case, | 591 // where <html> and <body> assume the size of the viewport. In this case, |
| 592 // calculate the percent offset based on this height. | 592 // calculate the percent offset based on this height. |
| 593 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. | 593 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. |
| 594 if (!style()->top().isAuto() | 594 if (!style()->top().isAuto() |
| 595 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() | 595 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() |
| 596 || !style()->top().hasPercent() | 596 || !style()->top().isPercentOrCalc() |
| 597 || containingBlock->stretchesToViewport())) | 597 || containingBlock->stretchesToViewport())) |
| 598 offset.expand(LayoutUnit(), valueForLength(style()->top(), containingBlo
ck->availableHeight())); | 598 offset.expand(LayoutUnit(), valueForLength(style()->top(), containingBlo
ck->availableHeight())); |
| 599 | 599 |
| 600 else if (!style()->bottom().isAuto() | 600 else if (!style()->bottom().isAuto() |
| 601 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() | 601 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() |
| 602 || !style()->bottom().hasPercent() | 602 || !style()->bottom().isPercentOrCalc() |
| 603 || containingBlock->stretchesToViewport())) | 603 || containingBlock->stretchesToViewport())) |
| 604 offset.expand(LayoutUnit(), -valueForLength(style()->bottom(), containin
gBlock->availableHeight())); | 604 offset.expand(LayoutUnit(), -valueForLength(style()->bottom(), containin
gBlock->availableHeight())); |
| 605 | 605 |
| 606 return offset; | 606 return offset; |
| 607 } | 607 } |
| 608 | 608 |
| 609 void LayoutBoxModelObject::updateStickyPositionConstraints() const | 609 void LayoutBoxModelObject::updateStickyPositionConstraints() const |
| 610 { | 610 { |
| 611 const FloatSize constrainingSize = computeStickyConstrainingRect().size(); | 611 const FloatSize constrainingSize = computeStickyConstrainingRect().size(); |
| 612 | 612 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 } | 816 } |
| 817 | 817 |
| 818 int LayoutBoxModelObject::pixelSnappedOffsetHeight(const Element* parent) const | 818 int LayoutBoxModelObject::pixelSnappedOffsetHeight(const Element* parent) const |
| 819 { | 819 { |
| 820 return snapSizeToPixel(offsetHeight(), offsetTop(parent)); | 820 return snapSizeToPixel(offsetHeight(), offsetTop(parent)); |
| 821 } | 821 } |
| 822 | 822 |
| 823 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const | 823 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const |
| 824 { | 824 { |
| 825 LayoutUnit w; | 825 LayoutUnit w; |
| 826 if (padding.hasPercent()) | 826 if (padding.isPercentOrCalc()) |
| 827 w = containingBlockLogicalWidthForContent(); | 827 w = containingBlockLogicalWidthForContent(); |
| 828 return minimumValueForLength(padding, w); | 828 return minimumValueForLength(padding, w); |
| 829 } | 829 } |
| 830 | 830 |
| 831 bool LayoutBoxModelObject::boxShadowShouldBeAppliedToBackground(BackgroundBleedA
voidance bleedAvoidance, const InlineFlowBox* inlineFlowBox) const | 831 bool LayoutBoxModelObject::boxShadowShouldBeAppliedToBackground(BackgroundBleedA
voidance bleedAvoidance, const InlineFlowBox* inlineFlowBox) const |
| 832 { | 832 { |
| 833 if (bleedAvoidance != BackgroundBleedNone) | 833 if (bleedAvoidance != BackgroundBleedNone) |
| 834 return false; | 834 return false; |
| 835 | 835 |
| 836 if (style()->hasAppearance()) | 836 if (style()->hasAppearance()) |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 if (rootElementStyle->hasBackground()) | 1111 if (rootElementStyle->hasBackground()) |
| 1112 return false; | 1112 return false; |
| 1113 | 1113 |
| 1114 if (node() != document().firstBodyElement()) | 1114 if (node() != document().firstBodyElement()) |
| 1115 return false; | 1115 return false; |
| 1116 | 1116 |
| 1117 return true; | 1117 return true; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 } // namespace blink | 1120 } // namespace blink |
| OLD | NEW |