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 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 m_rareData->m_spannerPlaceholder = nullptr; | 1835 m_rareData->m_spannerPlaceholder = nullptr; |
1836 } | 1836 } |
1837 | 1837 |
1838 void LayoutBox::setPaginationStrut(LayoutUnit strut) | 1838 void LayoutBox::setPaginationStrut(LayoutUnit strut) |
1839 { | 1839 { |
1840 if (!strut && !m_rareData) | 1840 if (!strut && !m_rareData) |
1841 return; | 1841 return; |
1842 ensureRareData().m_paginationStrut = strut; | 1842 ensureRareData().m_paginationStrut = strut; |
1843 } | 1843 } |
1844 | 1844 |
1845 static bool isForcedBreakAllowed(const LayoutBox* child) | 1845 bool LayoutBox::isBreakBetweenControllable(EBreak breakValue) const |
1846 { | 1846 { |
1847 // We currently only support forced breaks on in-flow block level elements,
which is the minimum | 1847 if (breakValue == BreakAuto) |
1848 // requirement according to the spec. | 1848 return true; |
1849 if (child->isInline() || child->isFloatingOrOutOfFlowPositioned()) | 1849 // We currently only support non-auto break-before and break-after values on
in-flow block |
| 1850 // level elements, which is the minimum requirement according to the spec. |
| 1851 if (isInline() || isFloatingOrOutOfFlowPositioned()) |
1850 return false; | 1852 return false; |
1851 const LayoutBlock* curr = child->containingBlock(); | 1853 const LayoutBlock* curr = containingBlock(); |
1852 if (!curr || !curr->isLayoutBlockFlow()) | 1854 if (!curr || !curr->isLayoutBlockFlow()) |
1853 return false; | 1855 return false; |
1854 const LayoutView* layoutView = child->view(); | 1856 const LayoutView* layoutView = view(); |
1855 while (curr && curr != layoutView) { | 1857 bool viewIsPaginated = layoutView->fragmentationContext(); |
1856 if (curr->isLayoutFlowThread()) | 1858 if (!viewIsPaginated && !flowThreadContainingBlock()) |
1857 return true; | 1859 return false; |
| 1860 while (curr) { |
| 1861 if (curr == layoutView) |
| 1862 return viewIsPaginated && breakValue != BreakColumn && breakValue !=
BreakAvoidColumn; |
| 1863 if (curr->isLayoutFlowThread()) { |
| 1864 if (breakValue == BreakAvoid) // Valid in any kind of fragmentation
context. |
| 1865 return true; |
| 1866 bool isMulticolValue = breakValue == BreakColumn || breakValue == Br
eakAvoidColumn; |
| 1867 if (toLayoutFlowThread(curr)->isLayoutPagedFlowThread()) |
| 1868 return !isMulticolValue; |
| 1869 if (isMulticolValue) |
| 1870 return true; |
| 1871 // If this is a flow thread for a multicol container, and we have a
break value for |
| 1872 // paged, we need to keep looking. |
| 1873 } |
1858 if (curr->isFloatingOrOutOfFlowPositioned()) | 1874 if (curr->isFloatingOrOutOfFlowPositioned()) |
1859 return false; | 1875 return false; |
1860 curr = curr->containingBlock(); | 1876 curr = curr->containingBlock(); |
1861 } | 1877 } |
1862 return true; | 1878 ASSERT_NOT_REACHED(); |
| 1879 return false; |
| 1880 } |
| 1881 |
| 1882 bool LayoutBox::isBreakInsideControllable(EBreak breakValue) const |
| 1883 { |
| 1884 ASSERT(!isForcedFragmentainerBreakValue(breakValue)); |
| 1885 if (breakValue == BreakAuto) |
| 1886 return true; |
| 1887 // First check multicol. |
| 1888 const LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 1889 // 'avoid-column' is only valid in a multicol context. |
| 1890 if (breakValue == BreakAvoidColumn) |
| 1891 return flowThread && !flowThread->isLayoutPagedFlowThread(); |
| 1892 // 'avoid' is valid in any kind of fragmentation context. |
| 1893 if (breakValue == BreakAvoid && flowThread) |
| 1894 return true; |
| 1895 ASSERT(breakValue == BreakAvoidPage || breakValue == BreakAvoid); |
| 1896 if (view()->fragmentationContext()) |
| 1897 return true; // The view is paginated, probably because we're printing. |
| 1898 if (!flowThread) |
| 1899 return false; // We're not inside any pagination context |
| 1900 // We're inside a flow thread. We need to be contained by a flow thread for
paged overflow in |
| 1901 // order for pagination values to be valid, though. |
| 1902 for (const LayoutBlock* ancestor = flowThread; ancestor; ancestor = ancestor
->containingBlock()) { |
| 1903 if (ancestor->isLayoutFlowThread() && toLayoutFlowThread(ancestor)->isLa
youtPagedFlowThread()) |
| 1904 return true; |
| 1905 } |
| 1906 return false; |
| 1907 } |
| 1908 |
| 1909 EBreak LayoutBox::breakAfter() const |
| 1910 { |
| 1911 EBreak breakValue = style()->breakAfter(); |
| 1912 if (breakValue == BreakAuto || isBreakBetweenControllable(breakValue)) |
| 1913 return breakValue; |
| 1914 return BreakAuto; |
| 1915 } |
| 1916 |
| 1917 EBreak LayoutBox::breakBefore() const |
| 1918 { |
| 1919 EBreak breakValue = style()->breakBefore(); |
| 1920 if (breakValue == BreakAuto || isBreakBetweenControllable(breakValue)) |
| 1921 return breakValue; |
| 1922 return BreakAuto; |
| 1923 } |
| 1924 |
| 1925 EBreak LayoutBox::breakInside() const |
| 1926 { |
| 1927 EBreak breakValue = style()->breakInside(); |
| 1928 if (breakValue == BreakAuto || isBreakInsideControllable(breakValue)) |
| 1929 return breakValue; |
| 1930 return BreakAuto; |
1863 } | 1931 } |
1864 | 1932 |
1865 bool LayoutBox::hasForcedBreakBefore() const | 1933 bool LayoutBox::hasForcedBreakBefore() const |
1866 { | 1934 { |
1867 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 1935 return isForcedFragmentainerBreakValue(breakBefore()); |
1868 bool checkColumnBreaks = flowThread; | |
1869 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // TODO(mstensho): Once columns can print, we have to check this. | |
1870 bool checkBeforeAlways = (checkColumnBreaks && style()->breakBefore() == Bre
akColumn) | |
1871 || (checkPageBreaks && style()->breakBefore() == BreakPage); | |
1872 return checkBeforeAlways && isForcedBreakAllowed(this); | |
1873 } | 1936 } |
1874 | 1937 |
1875 bool LayoutBox::hasForcedBreakAfter() const | 1938 bool LayoutBox::hasForcedBreakAfter() const |
1876 { | 1939 { |
1877 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 1940 return isForcedFragmentainerBreakValue(breakAfter()); |
1878 bool checkColumnBreaks = flowThread; | |
1879 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // TODO(mstensho): Once columns can print, we have to check this. | |
1880 bool checkAfterAlways = (checkColumnBreaks && style()->breakAfter() == Break
Column) | |
1881 || (checkPageBreaks && style()->breakAfter() == BreakPage); | |
1882 return checkAfterAlways && isForcedBreakAllowed(this); | |
1883 } | 1941 } |
1884 | 1942 |
1885 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod
elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid
ationState) const | 1943 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod
elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid
ationState) const |
1886 { | 1944 { |
1887 if (style()->visibility() != VISIBLE) { | 1945 if (style()->visibility() != VISIBLE) { |
1888 PaintLayer* layer = enclosingLayer(); | 1946 PaintLayer* layer = enclosingLayer(); |
1889 layer->updateDescendantDependentFlags(); | 1947 layer->updateDescendantDependentFlags(); |
1890 if (layer->subtreeIsInvisible()) | 1948 if (layer->subtreeIsInvisible()) |
1891 return LayoutRect(); | 1949 return LayoutRect(); |
1892 } | 1950 } |
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4175 LayoutBox::PaginationBreakability LayoutBox::paginationBreakability() const | 4233 LayoutBox::PaginationBreakability LayoutBox::paginationBreakability() const |
4176 { | 4234 { |
4177 // TODO(mstensho): It is wrong to check isAtomicInlineLevel() as we | 4235 // TODO(mstensho): It is wrong to check isAtomicInlineLevel() as we |
4178 // actually look for replaced elements. | 4236 // actually look for replaced elements. |
4179 if (isAtomicInlineLevel() | 4237 if (isAtomicInlineLevel() |
4180 || hasUnsplittableScrollingOverflow() | 4238 || hasUnsplittableScrollingOverflow() |
4181 || (parent() && isWritingModeRoot()) | 4239 || (parent() && isWritingModeRoot()) |
4182 || (isOutOfFlowPositioned() && style()->position() == FixedPosition)) | 4240 || (isOutOfFlowPositioned() && style()->position() == FixedPosition)) |
4183 return ForbidBreaks; | 4241 return ForbidBreaks; |
4184 | 4242 |
4185 bool checkColumnBreaks = flowThreadContainingBlock(); | 4243 EBreak breakValue = breakInside(); |
4186 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); | 4244 if (breakValue == BreakAvoid || breakValue == BreakAvoidPage || breakValue =
= BreakAvoidColumn) |
4187 EBreak breakInside = style()->breakInside(); | |
4188 bool isUnsplittable = (checkColumnBreaks && (breakInside == BreakAvoid || br
eakInside == BreakAvoidColumn)) | |
4189 || (checkPageBreaks && (breakInside == BreakAvoid || breakInside == Brea
kAvoidPage)); | |
4190 if (isUnsplittable) | |
4191 return AvoidBreaks; | 4245 return AvoidBreaks; |
4192 return AllowAnyBreaks; | 4246 return AllowAnyBreaks; |
4193 } | 4247 } |
4194 | 4248 |
4195 LayoutUnit LayoutBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction
, LinePositionMode /*linePositionMode*/) const | 4249 LayoutUnit LayoutBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction
, LinePositionMode /*linePositionMode*/) const |
4196 { | 4250 { |
4197 if (isAtomicInlineLevel()) | 4251 if (isAtomicInlineLevel()) |
4198 return direction == HorizontalLine ? marginHeight() + size().height() :
marginWidth() + size().width(); | 4252 return direction == HorizontalLine ? marginHeight() + size().height() :
marginWidth() + size().width(); |
4199 return LayoutUnit(); | 4253 return LayoutUnit(); |
4200 } | 4254 } |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4682 } | 4736 } |
4683 | 4737 |
4684 void LayoutBox::IntrinsicSizingInfo::transpose() | 4738 void LayoutBox::IntrinsicSizingInfo::transpose() |
4685 { | 4739 { |
4686 size = size.transposedSize(); | 4740 size = size.transposedSize(); |
4687 aspectRatio = aspectRatio.transposedSize(); | 4741 aspectRatio = aspectRatio.transposedSize(); |
4688 std::swap(hasWidth, hasHeight); | 4742 std::swap(hasWidth, hasHeight); |
4689 } | 4743 } |
4690 | 4744 |
4691 } // namespace blink | 4745 } // namespace blink |
OLD | NEW |