| 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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 LayoutBlock* containingBlock = this->containingBlock(); | 563 LayoutBlock* containingBlock = this->containingBlock(); |
| 564 | 564 |
| 565 // Objects that shrink to avoid floats normally use available line width whe
n computing containing block width. However | 565 // Objects that shrink to avoid floats normally use available line width whe
n computing containing block width. However |
| 566 // in the case of relative positioning using percentages, we can't do this.
The offset should always be resolved using the | 566 // in the case of relative positioning using percentages, we can't do this.
The offset should always be resolved using the |
| 567 // available width of the containing block. Therefore we don't use containi
ngBlockLogicalWidthForContent() here, but instead explicitly | 567 // available width of the containing block. Therefore we don't use containi
ngBlockLogicalWidthForContent() here, but instead explicitly |
| 568 // call availableWidth on our containing block. | 568 // call availableWidth on our containing block. |
| 569 if (!style()->left().isAuto()) { | 569 if (!style()->left().isAuto()) { |
| 570 if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRig
htDirection()) | 570 if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRig
htDirection()) |
| 571 offset.setWidth(-valueForLength(style()->right(), containingBlock->a
vailableWidth())); | 571 offset.setWidth(-valueForLength(style()->right(), containingBlock->a
vailableWidth())); |
| 572 else | 572 else |
| 573 offset.expand(valueForLength(style()->left(), containingBlock->avail
ableWidth()), 0); | 573 offset.expand(valueForLength(style()->left(), containingBlock->avail
ableWidth()), LayoutUnit()); |
| 574 } else if (!style()->right().isAuto()) { | 574 } else if (!style()->right().isAuto()) { |
| 575 offset.expand(-valueForLength(style()->right(), containingBlock->availab
leWidth()), 0); | 575 offset.expand(-valueForLength(style()->right(), containingBlock->availab
leWidth()), LayoutUnit()); |
| 576 } | 576 } |
| 577 | 577 |
| 578 // If the containing block of a relatively positioned element does not | 578 // If the containing block of a relatively positioned element does not |
| 579 // specify a height, a percentage top or bottom offset should be resolved as | 579 // specify a height, a percentage top or bottom offset should be resolved as |
| 580 // auto. An exception to this is if the containing block has the WinIE quirk | 580 // auto. An exception to this is if the containing block has the WinIE quirk |
| 581 // where <html> and <body> assume the size of the viewport. In this case, | 581 // where <html> and <body> assume the size of the viewport. In this case, |
| 582 // calculate the percent offset based on this height. | 582 // calculate the percent offset based on this height. |
| 583 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. | 583 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. |
| 584 if (!style()->top().isAuto() | 584 if (!style()->top().isAuto() |
| 585 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() | 585 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() |
| 586 || !style()->top().hasPercent() | 586 || !style()->top().hasPercent() |
| 587 || containingBlock->stretchesToViewport())) | 587 || containingBlock->stretchesToViewport())) |
| 588 offset.expand(0, valueForLength(style()->top(), containingBlock->availab
leHeight())); | 588 offset.expand(LayoutUnit(), valueForLength(style()->top(), containingBlo
ck->availableHeight())); |
| 589 | 589 |
| 590 else if (!style()->bottom().isAuto() | 590 else if (!style()->bottom().isAuto() |
| 591 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() | 591 && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() |
| 592 || !style()->bottom().hasPercent() | 592 || !style()->bottom().hasPercent() |
| 593 || containingBlock->stretchesToViewport())) | 593 || containingBlock->stretchesToViewport())) |
| 594 offset.expand(0, -valueForLength(style()->bottom(), containingBlock->ava
ilableHeight())); | 594 offset.expand(LayoutUnit(), -valueForLength(style()->bottom(), containin
gBlock->availableHeight())); |
| 595 | 595 |
| 596 return offset; | 596 return offset; |
| 597 } | 597 } |
| 598 | 598 |
| 599 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeToOffsetParent(const L
ayoutPoint& startPoint) const | 599 LayoutPoint LayoutBoxModelObject::adjustedPositionRelativeToOffsetParent(const L
ayoutPoint& startPoint) const |
| 600 { | 600 { |
| 601 // If the element is the HTML body element or doesn't have a parent | 601 // If the element is the HTML body element or doesn't have a parent |
| 602 // return 0 and stop this algorithm. | 602 // return 0 and stop this algorithm. |
| 603 if (isBody() || !parent()) | 603 if (isBody() || !parent()) |
| 604 return LayoutPoint(); | 604 return LayoutPoint(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 return snapSizeToPixel(offsetWidth(), offsetLeft()); | 662 return snapSizeToPixel(offsetWidth(), offsetLeft()); |
| 663 } | 663 } |
| 664 | 664 |
| 665 int LayoutBoxModelObject::pixelSnappedOffsetHeight() const | 665 int LayoutBoxModelObject::pixelSnappedOffsetHeight() const |
| 666 { | 666 { |
| 667 return snapSizeToPixel(offsetHeight(), offsetTop()); | 667 return snapSizeToPixel(offsetHeight(), offsetTop()); |
| 668 } | 668 } |
| 669 | 669 |
| 670 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const | 670 LayoutUnit LayoutBoxModelObject::computedCSSPadding(const Length& padding) const |
| 671 { | 671 { |
| 672 LayoutUnit w = 0; | 672 LayoutUnit w; |
| 673 if (padding.hasPercent()) | 673 if (padding.hasPercent()) |
| 674 w = containingBlockLogicalWidthForContent(); | 674 w = containingBlockLogicalWidthForContent(); |
| 675 return minimumValueForLength(padding, w); | 675 return minimumValueForLength(padding, w); |
| 676 } | 676 } |
| 677 | 677 |
| 678 static inline LayoutUnit resolveWidthForRatio(LayoutUnit height, const FloatSize
& intrinsicRatio) | 678 static inline LayoutUnit resolveWidthForRatio(LayoutUnit height, const FloatSize
& intrinsicRatio) |
| 679 { | 679 { |
| 680 return height * intrinsicRatio.width() / intrinsicRatio.height(); | 680 return LayoutUnit(height * intrinsicRatio.width() / intrinsicRatio.height())
; |
| 681 } | 681 } |
| 682 | 682 |
| 683 static inline LayoutUnit resolveHeightForRatio(LayoutUnit width, const FloatSize
& intrinsicRatio) | 683 static inline LayoutUnit resolveHeightForRatio(LayoutUnit width, const FloatSize
& intrinsicRatio) |
| 684 { | 684 { |
| 685 return width * intrinsicRatio.height() / intrinsicRatio.width(); | 685 return LayoutUnit(width * intrinsicRatio.height() / intrinsicRatio.width()); |
| 686 } | 686 } |
| 687 | 687 |
| 688 static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const Layo
utSize& size, const FloatSize& intrinsicRatio, LayoutUnit useWidth, LayoutUnit u
seHeight) | 688 static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const Layo
utSize& size, const FloatSize& intrinsicRatio, LayoutUnit useWidth, LayoutUnit u
seHeight) |
| 689 { | 689 { |
| 690 if (intrinsicRatio.isEmpty()) { | 690 if (intrinsicRatio.isEmpty()) { |
| 691 if (useWidth) | 691 if (useWidth) |
| 692 return LayoutSize(useWidth, size.height()); | 692 return LayoutSize(useWidth, size.height()); |
| 693 return LayoutSize(size.width(), useHeight); | 693 return LayoutSize(size.width(), useHeight); |
| 694 } | 694 } |
| 695 | 695 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 x += textIndentOffset / 2; | 906 x += textIndentOffset / 2; |
| 907 else | 907 else |
| 908 x -= textIndentOffset / 2; | 908 x -= textIndentOffset / 2; |
| 909 break; | 909 break; |
| 910 case AlignRight: | 910 case AlignRight: |
| 911 x = maxX - caretWidth(); | 911 x = maxX - caretWidth(); |
| 912 if (!currentStyle.isLeftToRightDirection()) | 912 if (!currentStyle.isLeftToRightDirection()) |
| 913 x -= textIndentOffset; | 913 x -= textIndentOffset; |
| 914 break; | 914 break; |
| 915 } | 915 } |
| 916 x = std::min(x, (maxX - caretWidth()).clampToZero()); | 916 x = std::min(x, (maxX - caretWidth()).clampNegativeToZero()); |
| 917 | 917 |
| 918 LayoutUnit height = LayoutUnit(style()->fontMetrics().height()); | 918 LayoutUnit height = LayoutUnit(style()->fontMetrics().height()); |
| 919 LayoutUnit verticalSpace = lineHeight(true, currentStyle.isHorizontalWriting
Mode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes) - height; | 919 LayoutUnit verticalSpace = lineHeight(true, currentStyle.isHorizontalWriting
Mode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes) - height; |
| 920 LayoutUnit y = paddingTop() + borderTop() + (verticalSpace / 2); | 920 LayoutUnit y = paddingTop() + borderTop() + (verticalSpace / 2); |
| 921 return currentStyle.isHorizontalWritingMode() ? LayoutRect(x, y, caretWidth(
), height) : LayoutRect(y, x, height, caretWidth()); | 921 return currentStyle.isHorizontalWritingMode() ? LayoutRect(x, y, caretWidth(
), height) : LayoutRect(y, x, height, caretWidth()); |
| 922 } | 922 } |
| 923 | 923 |
| 924 void LayoutBoxModelObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, Tra
nsformState& transformState) const | 924 void LayoutBoxModelObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, Tra
nsformState& transformState) const |
| 925 { | 925 { |
| 926 LayoutObject* o = container(); | 926 LayoutObject* o = container(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 if (rootElementStyle->hasBackground()) | 1059 if (rootElementStyle->hasBackground()) |
| 1060 return false; | 1060 return false; |
| 1061 | 1061 |
| 1062 if (node() != document().firstBodyElement()) | 1062 if (node() != document().firstBodyElement()) |
| 1063 return false; | 1063 return false; |
| 1064 | 1064 |
| 1065 return true; | 1065 return true; |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 } // namespace blink | 1068 } // namespace blink |
| OLD | NEW |