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) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 --gDelayUpdateScrollInfo; | 870 --gDelayUpdateScrollInfo; |
871 ASSERT(gDelayUpdateScrollInfo >= 0); | 871 ASSERT(gDelayUpdateScrollInfo >= 0); |
872 if (gDelayUpdateScrollInfo == 0) { | 872 if (gDelayUpdateScrollInfo == 0) { |
873 ASSERT(gDelayedUpdateScrollInfoSet); | 873 ASSERT(gDelayedUpdateScrollInfoSet); |
874 | 874 |
875 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll
InfoSet)); | 875 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll
InfoSet)); |
876 gDelayedUpdateScrollInfoSet = nullptr; | 876 gDelayedUpdateScrollInfoSet = nullptr; |
877 | 877 |
878 for (auto* block : *infoSet) { | 878 for (auto* block : *infoSet) { |
879 if (block->hasOverflowClip()) { | 879 if (block->hasOverflowClip()) { |
880 childrenMarkedForRelayout |= block->layer()->scrollableArea()->u
pdateAfterLayout(layoutScope); | 880 childrenMarkedForRelayout |= block->layer()->getScrollableArea()
->updateAfterLayout(layoutScope); |
881 } | 881 } |
882 } | 882 } |
883 } | 883 } |
884 return childrenMarkedForRelayout; | 884 return childrenMarkedForRelayout; |
885 } | 885 } |
886 | 886 |
887 void LayoutBlock::updateScrollInfoAfterLayout() | 887 void LayoutBlock::updateScrollInfoAfterLayout() |
888 { | 888 { |
889 if (hasOverflowClip()) { | 889 if (hasOverflowClip()) { |
890 if (style()->isFlippedBlocksWritingMode()) { | 890 if (style()->isFlippedBlocksWritingMode()) { |
891 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 | 891 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 |
892 // Workaround for now. We cannot delay the scroll info for overflow | 892 // Workaround for now. We cannot delay the scroll info for overflow |
893 // for items with opposite writing directions, as the contents needs | 893 // for items with opposite writing directions, as the contents needs |
894 // to overflow in that direction | 894 // to overflow in that direction |
895 layer()->scrollableArea()->updateAfterLayout(); | 895 layer()->getScrollableArea()->updateAfterLayout(); |
896 return; | 896 return; |
897 } | 897 } |
898 | 898 |
899 if (gDelayUpdateScrollInfo) | 899 if (gDelayUpdateScrollInfo) |
900 gDelayedUpdateScrollInfoSet->add(this); | 900 gDelayedUpdateScrollInfoSet->add(this); |
901 else | 901 else |
902 layer()->scrollableArea()->updateAfterLayout(); | 902 layer()->getScrollableArea()->updateAfterLayout(); |
903 } | 903 } |
904 } | 904 } |
905 | 905 |
906 void LayoutBlock::layout() | 906 void LayoutBlock::layout() |
907 { | 907 { |
908 LayoutAnalyzer::Scope analyzer(*this); | 908 LayoutAnalyzer::Scope analyzer(*this); |
909 | 909 |
910 bool needsScrollAnchoring = RuntimeEnabledFeatures::scrollAnchoringEnabled()
&& hasOverflowClip(); | 910 bool needsScrollAnchoring = RuntimeEnabledFeatures::scrollAnchoringEnabled()
&& hasOverflowClip(); |
911 if (needsScrollAnchoring) | 911 if (needsScrollAnchoring) |
912 scrollableArea()->scrollAnchor().save(); | 912 getScrollableArea()->scrollAnchor().save(); |
913 | 913 |
914 // Table cells call layoutBlock directly, so don't add any logic here. Put
code into | 914 // Table cells call layoutBlock directly, so don't add any logic here. Put
code into |
915 // layoutBlock(). | 915 // layoutBlock(). |
916 layoutBlock(false); | 916 layoutBlock(false); |
917 | 917 |
918 // It's safe to check for control clip here, since controls can never be tab
le cells. | 918 // It's safe to check for control clip here, since controls can never be tab
le cells. |
919 // If we have a lightweight clip, there can never be any overflow from child
ren. | 919 // If we have a lightweight clip, there can never be any overflow from child
ren. |
920 if (hasControlClip() && m_overflow) | 920 if (hasControlClip() && m_overflow) |
921 clearLayoutOverflow(); | 921 clearLayoutOverflow(); |
922 | 922 |
923 invalidateBackgroundObscurationStatus(); | 923 invalidateBackgroundObscurationStatus(); |
924 | 924 |
925 if (needsScrollAnchoring) | 925 if (needsScrollAnchoring) |
926 scrollableArea()->scrollAnchor().restore(); | 926 getScrollableArea()->scrollAnchor().restore(); |
927 | 927 |
928 m_heightAvailableToChildrenChanged = false; | 928 m_heightAvailableToChildrenChanged = false; |
929 } | 929 } |
930 | 930 |
931 bool LayoutBlock::widthAvailableToChildrenHasChanged() | 931 bool LayoutBlock::widthAvailableToChildrenHasChanged() |
932 { | 932 { |
933 // TODO(robhogan): Does m_widthAvailableToChildrenChanged always get reset w
hen it needs to? | 933 // TODO(robhogan): Does m_widthAvailableToChildrenChanged always get reset w
hen it needs to? |
934 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged; | 934 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged; |
935 m_widthAvailableToChildrenChanged = false; | 935 m_widthAvailableToChildrenChanged = false; |
936 | 936 |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 afterLowest->markDirty(); | 1596 afterLowest->markDirty(); |
1597 afterLowest = afterLowest->prevRootBox(); | 1597 afterLowest = afterLowest->prevRootBox(); |
1598 } | 1598 } |
1599 } | 1599 } |
1600 | 1600 |
1601 bool LayoutBlock::isPointInOverflowControl(HitTestResult& result, const LayoutPo
int& locationInContainer, const LayoutPoint& accumulatedOffset) const | 1601 bool LayoutBlock::isPointInOverflowControl(HitTestResult& result, const LayoutPo
int& locationInContainer, const LayoutPoint& accumulatedOffset) const |
1602 { | 1602 { |
1603 if (!scrollsOverflow()) | 1603 if (!scrollsOverflow()) |
1604 return false; | 1604 return false; |
1605 | 1605 |
1606 return layer()->scrollableArea()->hitTestOverflowControls(result, roundedInt
Point(locationInContainer - toLayoutSize(accumulatedOffset))); | 1606 return layer()->getScrollableArea()->hitTestOverflowControls(result, rounded
IntPoint(locationInContainer - toLayoutSize(accumulatedOffset))); |
1607 } | 1607 } |
1608 | 1608 |
1609 Node* LayoutBlock::nodeForHitTest() const | 1609 Node* LayoutBlock::nodeForHitTest() const |
1610 { | 1610 { |
1611 // If we are in the margins of block elements that are part of a | 1611 // If we are in the margins of block elements that are part of a |
1612 // continuation we're actually still inside the enclosing element | 1612 // continuation we're actually still inside the enclosing element |
1613 // that was split. Use the appropriate inner node. | 1613 // that was split. Use the appropriate inner node. |
1614 return isAnonymousBlockContinuation() ? continuation()->node() : node(); | 1614 return isAnonymousBlockContinuation() ? continuation()->node() : node(); |
1615 } | 1615 } |
1616 | 1616 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 | 1918 |
1919 if (hasOverflowClip()) | 1919 if (hasOverflowClip()) |
1920 offset += LayoutSize(scrolledContentOffset()); | 1920 offset += LayoutSize(scrolledContentOffset()); |
1921 | 1921 |
1922 offset = flipForWritingMode(offset); | 1922 offset = flipForWritingMode(offset); |
1923 } | 1923 } |
1924 | 1924 |
1925 int LayoutBlock::columnGap() const | 1925 int LayoutBlock::columnGap() const |
1926 { | 1926 { |
1927 if (style()->hasNormalColumnGap()) | 1927 if (style()->hasNormalColumnGap()) |
1928 return style()->fontDescription().computedPixelSize(); // "1em" is recom
mended as the normal gap setting. Matches <p> margins. | 1928 return style()->getFontDescription().computedPixelSize(); // "1em" is re
commended as the normal gap setting. Matches <p> margins. |
1929 return static_cast<int>(style()->columnGap()); | 1929 return static_cast<int>(style()->columnGap()); |
1930 } | 1930 } |
1931 | 1931 |
1932 void LayoutBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay
outUnit& maxLogicalWidth) const | 1932 void LayoutBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay
outUnit& maxLogicalWidth) const |
1933 { | 1933 { |
1934 // Layout-contained elements don't consider their contents for preferred siz
ing. | 1934 // Layout-contained elements don't consider their contents for preferred siz
ing. |
1935 if (style()->containsLayout()) | 1935 if (style()->containsLayout()) |
1936 return; | 1936 return; |
1937 | 1937 |
1938 if (childrenInline()) { | 1938 if (childrenInline()) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2176 if (baselinePos != -1) | 2176 if (baselinePos != -1) |
2177 return beforeMarginInLineDirection(direction) + baselinePos; | 2177 return beforeMarginInLineDirection(direction) + baselinePos; |
2178 | 2178 |
2179 return LayoutBox::baselinePosition(baselineType, firstLine, direction, l
inePositionMode); | 2179 return LayoutBox::baselinePosition(baselineType, firstLine, direction, l
inePositionMode); |
2180 } | 2180 } |
2181 | 2181 |
2182 // If we're not replaced, we'll only get called with PositionOfInteriorLineB
oxes. | 2182 // If we're not replaced, we'll only get called with PositionOfInteriorLineB
oxes. |
2183 // Note that inline-block counts as replaced here. | 2183 // Note that inline-block counts as replaced here. |
2184 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); | 2184 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); |
2185 | 2185 |
2186 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); | 2186 const FontMetrics& fontMetrics = style(firstLine)->getFontMetrics(); |
2187 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; | 2187 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; |
2188 } | 2188 } |
2189 | 2189 |
2190 LayoutUnit LayoutBlock::minLineHeightForReplacedObject(bool isFirstLine, LayoutU
nit replacedHeight) const | 2190 LayoutUnit LayoutBlock::minLineHeightForReplacedObject(bool isFirstLine, LayoutU
nit replacedHeight) const |
2191 { | 2191 { |
2192 if (!document().inNoQuirksMode() && replacedHeight) | 2192 if (!document().inNoQuirksMode() && replacedHeight) |
2193 return replacedHeight; | 2193 return replacedHeight; |
2194 | 2194 |
2195 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo
ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes))
; | 2195 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo
ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes))
; |
2196 } | 2196 } |
2197 | 2197 |
2198 int LayoutBlock::firstLineBoxBaseline() const | 2198 int LayoutBlock::firstLineBoxBaseline() const |
2199 { | 2199 { |
2200 if (isWritingModeRoot() && !isRubyRun()) | 2200 if (isWritingModeRoot() && !isRubyRun()) |
2201 return -1; | 2201 return -1; |
2202 | 2202 |
2203 if (childrenInline()) { | 2203 if (childrenInline()) { |
2204 if (firstLineBox()) | 2204 if (firstLineBox()) |
2205 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc
ent(firstRootBox()->baselineType()); | 2205 return firstLineBox()->logicalTop() + style(true)->getFontMetrics().
ascent(firstRootBox()->baselineType()); |
2206 return -1; | 2206 return -1; |
2207 } | 2207 } |
2208 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox())
{ | 2208 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox())
{ |
2209 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 2209 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
2210 int result = curr->firstLineBoxBaseline(); | 2210 int result = curr->firstLineBoxBaseline(); |
2211 if (result != -1) | 2211 if (result != -1) |
2212 return curr->logicalTop() + result; // Translate to our coordina
te space. | 2212 return curr->logicalTop() + result; // Translate to our coordina
te space. |
2213 } | 2213 } |
2214 } | 2214 } |
2215 return -1; | 2215 return -1; |
(...skipping 13 matching lines...) Expand all Loading... |
2229 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline
BlockBaseline()) || style()->containsLayout()) { | 2229 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline
BlockBaseline()) || style()->containsLayout()) { |
2230 // We are not calling LayoutBox::baselinePosition here because the calle
r should add the margin-top/margin-right, not us. | 2230 // We are not calling LayoutBox::baselinePosition here because the calle
r should add the margin-top/margin-right, not us. |
2231 return lineDirection == HorizontalLine ? size().height() + marginBottom(
) : size().width() + marginLeft(); | 2231 return lineDirection == HorizontalLine ? size().height() + marginBottom(
) : size().width() + marginLeft(); |
2232 } | 2232 } |
2233 | 2233 |
2234 if (isWritingModeRoot() && !isRubyRun()) | 2234 if (isWritingModeRoot() && !isRubyRun()) |
2235 return -1; | 2235 return -1; |
2236 | 2236 |
2237 if (childrenInline()) { | 2237 if (childrenInline()) { |
2238 if (!firstLineBox() && hasLineIfEmpty()) { | 2238 if (!firstLineBox() && hasLineIfEmpty()) { |
2239 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); | 2239 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); |
2240 return fontMetrics.ascent() | 2240 return fontMetrics.ascent() |
2241 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes)
- fontMetrics.height()) / 2 | 2241 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes)
- fontMetrics.height()) / 2 |
2242 + (lineDirection == HorizontalLine ? borderTop() + paddingTop()
: borderRight() + paddingRight()); | 2242 + (lineDirection == HorizontalLine ? borderTop() + paddingTop()
: borderRight() + paddingRight()); |
2243 } | 2243 } |
2244 if (lastLineBox()) | 2244 if (lastLineBox()) |
2245 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin
eBox())->fontMetrics().ascent(lastRootBox()->baselineType()); | 2245 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin
eBox())->getFontMetrics().ascent(lastRootBox()->baselineType()); |
2246 return -1; | 2246 return -1; |
2247 } | 2247 } |
2248 | 2248 |
2249 bool haveNormalFlowChild = false; | 2249 bool haveNormalFlowChild = false; |
2250 for (LayoutBox* curr = lastChildBox(); curr; curr = curr->previousSiblingBox
()) { | 2250 for (LayoutBox* curr = lastChildBox(); curr; curr = curr->previousSiblingBox
()) { |
2251 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 2251 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
2252 haveNormalFlowChild = true; | 2252 haveNormalFlowChild = true; |
2253 int result = curr->inlineBlockBaseline(lineDirection); | 2253 int result = curr->inlineBlockBaseline(lineDirection); |
2254 if (result != -1) | 2254 if (result != -1) |
2255 return curr->logicalTop() + result; // Translate to our coordina
te space. | 2255 return curr->logicalTop() + result; // Translate to our coordina
te space. |
2256 } | 2256 } |
2257 } | 2257 } |
2258 if (!haveNormalFlowChild && hasLineIfEmpty()) { | 2258 if (!haveNormalFlowChild && hasLineIfEmpty()) { |
2259 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); | 2259 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); |
2260 return fontMetrics.ascent() | 2260 return fontMetrics.ascent() |
2261 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fo
ntMetrics.height()) / 2 | 2261 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fo
ntMetrics.height()) / 2 |
2262 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : bo
rderRight() + paddingRight()); | 2262 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : bo
rderRight() + paddingRight()); |
2263 } | 2263 } |
2264 return -1; | 2264 return -1; |
2265 } | 2265 } |
2266 | 2266 |
2267 LayoutBlock* LayoutBlock::enclosingFirstLineStyleBlock() const | 2267 LayoutBlock* LayoutBlock::enclosingFirstLineStyleBlock() const |
2268 { | 2268 { |
2269 LayoutBlock* firstLineBlock = const_cast<LayoutBlock*>(this); | 2269 LayoutBlock* firstLineBlock = const_cast<LayoutBlock*>(this); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2797 clearSelfNeedsOverflowRecalcAfterStyleChange(); | 2797 clearSelfNeedsOverflowRecalcAfterStyleChange(); |
2798 // If the current block needs layout, overflow will be recalculated during | 2798 // If the current block needs layout, overflow will be recalculated during |
2799 // layout time anyway. We can safely exit here. | 2799 // layout time anyway. We can safely exit here. |
2800 if (needsLayout()) | 2800 if (needsLayout()) |
2801 return false; | 2801 return false; |
2802 | 2802 |
2803 LayoutUnit oldClientAfterEdge = hasOverflowModel() ? m_overflow->layoutClien
tAfterEdge() : clientLogicalBottom(); | 2803 LayoutUnit oldClientAfterEdge = hasOverflowModel() ? m_overflow->layoutClien
tAfterEdge() : clientLogicalBottom(); |
2804 computeOverflow(oldClientAfterEdge, true); | 2804 computeOverflow(oldClientAfterEdge, true); |
2805 | 2805 |
2806 if (hasOverflowClip()) | 2806 if (hasOverflowClip()) |
2807 layer()->scrollableArea()->updateAfterOverflowRecalc(); | 2807 layer()->getScrollableArea()->updateAfterOverflowRecalc(); |
2808 | 2808 |
2809 return !hasOverflowClip(); | 2809 return !hasOverflowClip(); |
2810 } | 2810 } |
2811 | 2811 |
2812 // Called when a positioned object moves but doesn't necessarily change size. A
simplified layout is attempted | 2812 // Called when a positioned object moves but doesn't necessarily change size. A
simplified layout is attempted |
2813 // that just updates the object's position. If the size does change, the object
remains dirty. | 2813 // that just updates the object's position. If the size does change, the object
remains dirty. |
2814 bool LayoutBlock::tryLayoutDoingPositionedMovementOnly() | 2814 bool LayoutBlock::tryLayoutDoingPositionedMovementOnly() |
2815 { | 2815 { |
2816 LayoutUnit oldWidth = logicalWidth(); | 2816 LayoutUnit oldWidth = logicalWidth(); |
2817 LogicalExtentComputedValues computedValues; | 2817 LogicalExtentComputedValues computedValues; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2865 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2865 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
2866 { | 2866 { |
2867 showLayoutObject(); | 2867 showLayoutObject(); |
2868 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2868 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
2869 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2869 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
2870 } | 2870 } |
2871 | 2871 |
2872 #endif | 2872 #endif |
2873 | 2873 |
2874 } // namespace blink | 2874 } // namespace blink |
OLD | NEW |