| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/layout/LayoutPart.h" | 49 #include "core/layout/LayoutPart.h" |
| 50 #include "core/layout/LayoutReplica.h" | 50 #include "core/layout/LayoutReplica.h" |
| 51 #include "core/layout/LayoutScrollbarPart.h" | 51 #include "core/layout/LayoutScrollbarPart.h" |
| 52 #include "core/layout/LayoutTableCell.h" | 52 #include "core/layout/LayoutTableCell.h" |
| 53 #include "core/layout/LayoutView.h" | 53 #include "core/layout/LayoutView.h" |
| 54 #include "core/layout/api/LineLayoutBox.h" | 54 #include "core/layout/api/LineLayoutBox.h" |
| 55 #include "core/layout/compositing/PaintLayerCompositor.h" | 55 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 56 #include "core/layout/shapes/ShapeOutsideInfo.h" | 56 #include "core/layout/shapes/ShapeOutsideInfo.h" |
| 57 #include "core/page/AutoscrollController.h" | 57 #include "core/page/AutoscrollController.h" |
| 58 #include "core/page/Page.h" | 58 #include "core/page/Page.h" |
| 59 #include "core/page/scrolling/SnapCoordinator.h" |
| 59 #include "core/paint/BackgroundImageGeometry.h" | 60 #include "core/paint/BackgroundImageGeometry.h" |
| 60 #include "core/paint/BoxPainter.h" | 61 #include "core/paint/BoxPainter.h" |
| 61 #include "core/paint/PaintLayer.h" | 62 #include "core/paint/PaintLayer.h" |
| 62 #include "core/style/ShadowList.h" | 63 #include "core/style/ShadowList.h" |
| 63 #include "platform/LengthFunctions.h" | 64 #include "platform/LengthFunctions.h" |
| 64 #include "platform/geometry/DoubleRect.h" | 65 #include "platform/geometry/DoubleRect.h" |
| 65 #include "platform/geometry/FloatQuad.h" | 66 #include "platform/geometry/FloatQuad.h" |
| 66 #include "platform/geometry/FloatRoundedRect.h" | 67 #include "platform/geometry/FloatRoundedRect.h" |
| 67 #include "platform/geometry/TransformState.h" | 68 #include "platform/geometry/TransformState.h" |
| 68 #include "platform/graphics/GraphicsContext.h" | 69 #include "platform/graphics/GraphicsContext.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 unmarkOrthogonalWritingModeRoot(); | 139 unmarkOrthogonalWritingModeRoot(); |
| 139 | 140 |
| 140 ShapeOutsideInfo::removeInfo(*this); | 141 ShapeOutsideInfo::removeInfo(*this); |
| 141 | 142 |
| 142 LayoutBoxModelObject::willBeDestroyed(); | 143 LayoutBoxModelObject::willBeDestroyed(); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void LayoutBox::insertedIntoTree() | 146 void LayoutBox::insertedIntoTree() |
| 146 { | 147 { |
| 147 LayoutBoxModelObject::insertedIntoTree(); | 148 LayoutBoxModelObject::insertedIntoTree(); |
| 149 addScrollSnapMapping(); |
| 148 | 150 |
| 149 if (isOrthogonalWritingModeRoot()) | 151 if (isOrthogonalWritingModeRoot()) |
| 150 markOrthogonalWritingModeRoot(); | 152 markOrthogonalWritingModeRoot(); |
| 151 } | 153 } |
| 152 | 154 |
| 153 void LayoutBox::willBeRemovedFromTree() | 155 void LayoutBox::willBeRemovedFromTree() |
| 154 { | 156 { |
| 155 if (!documentBeingDestroyed() && isOrthogonalWritingModeRoot()) | 157 if (!documentBeingDestroyed() && isOrthogonalWritingModeRoot()) |
| 156 unmarkOrthogonalWritingModeRoot(); | 158 unmarkOrthogonalWritingModeRoot(); |
| 157 | 159 |
| 160 clearScrollSnapMapping(); |
| 158 LayoutBoxModelObject::willBeRemovedFromTree(); | 161 LayoutBoxModelObject::willBeRemovedFromTree(); |
| 159 } | 162 } |
| 160 | 163 |
| 161 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() | 164 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() |
| 162 { | 165 { |
| 163 ASSERT(isFloatingOrOutOfFlowPositioned()); | 166 ASSERT(isFloatingOrOutOfFlowPositioned()); |
| 164 | 167 |
| 165 if (documentBeingDestroyed()) | 168 if (documentBeingDestroyed()) |
| 166 return; | 169 return; |
| 167 | 170 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 297 |
| 295 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) | 298 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) |
| 296 placeholder->layoutObjectInFlowThreadStyleDidChange(oldStyle); | 299 placeholder->layoutObjectInFlowThreadStyleDidChange(oldStyle); |
| 297 | 300 |
| 298 updateBackgroundAttachmentFixedStatusAfterStyleChange(); | 301 updateBackgroundAttachmentFixedStatusAfterStyleChange(); |
| 299 | 302 |
| 300 if (oldStyle) { | 303 if (oldStyle) { |
| 301 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 304 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 302 if (flowThread && flowThread != this) | 305 if (flowThread && flowThread != this) |
| 303 flowThread->flowThreadDescendantStyleDidChange(this, diff, *oldStyle
); | 306 flowThread->flowThreadDescendantStyleDidChange(this, diff, *oldStyle
); |
| 307 |
| 308 updateScrollSnapMappingAfterStyleChange(&newStyle, oldStyle); |
| 304 } | 309 } |
| 305 | 310 |
| 306 ASSERT(!isInline() || isAtomicInlineLevel()); // Non-atomic inlines should b
e LayoutInline or LayoutText, not LayoutBox. | 311 ASSERT(!isInline() || isAtomicInlineLevel()); // Non-atomic inlines should b
e LayoutInline or LayoutText, not LayoutBox. |
| 307 } | 312 } |
| 308 | 313 |
| 309 void LayoutBox::updateBackgroundAttachmentFixedStatusAfterStyleChange() | 314 void LayoutBox::updateBackgroundAttachmentFixedStatusAfterStyleChange() |
| 310 { | 315 { |
| 311 if (!frameView()) | 316 if (!frameView()) |
| 312 return; | 317 return; |
| 313 | 318 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 && oldStyle->gridRowEnd() == style()->gridRowEnd() | 371 && oldStyle->gridRowEnd() == style()->gridRowEnd() |
| 367 && oldStyle->order() == style()->order() | 372 && oldStyle->order() == style()->order() |
| 368 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) | 373 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) |
| 369 return; | 374 return; |
| 370 | 375 |
| 371 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). | 376 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). |
| 372 // For now, it's more simple to just always recompute the grid. | 377 // For now, it's more simple to just always recompute the grid. |
| 373 toLayoutGrid(parent())->dirtyGrid(); | 378 toLayoutGrid(parent())->dirtyGrid(); |
| 374 } | 379 } |
| 375 | 380 |
| 381 void LayoutBox::updateScrollSnapMappingAfterStyleChange(const ComputedStyle* new
Style, const ComputedStyle* oldStyle) |
| 382 { |
| 383 SnapCoordinator* snapCoordinator = document().snapCoordinator(); |
| 384 if (!snapCoordinator) |
| 385 return; |
| 386 |
| 387 // Scroll snap type has no effect on the viewport defining element instead |
| 388 // they are handled by the LayoutView. |
| 389 bool allowsSnapContainer = node() != document().viewportDefiningElement(); |
| 390 |
| 391 ScrollSnapType oldSnapType = oldStyle ? oldStyle->getScrollSnapType() : Scro
llSnapTypeNone; |
| 392 ScrollSnapType newSnapType = newStyle && allowsSnapContainer ? newStyle->get
ScrollSnapType() : ScrollSnapTypeNone; |
| 393 if (oldSnapType != newSnapType) |
| 394 snapCoordinator->snapContainerDidChange(*this, newSnapType); |
| 395 |
| 396 Vector<LengthPoint> emptyVector; |
| 397 const Vector<LengthPoint>& oldSnapCoordinate = oldStyle ? oldStyle->scrollSn
apCoordinate() : emptyVector; |
| 398 const Vector<LengthPoint>& newSnapCoordinate = newStyle ? newStyle->scrollSn
apCoordinate() : emptyVector; |
| 399 if (oldSnapCoordinate != newSnapCoordinate) |
| 400 snapCoordinator->snapAreaDidChange(*this, newSnapCoordinate); |
| 401 } |
| 402 |
| 403 void LayoutBox::addScrollSnapMapping() |
| 404 { |
| 405 updateScrollSnapMappingAfterStyleChange(style(), nullptr); |
| 406 } |
| 407 |
| 408 void LayoutBox::clearScrollSnapMapping() |
| 409 { |
| 410 updateScrollSnapMappingAfterStyleChange(nullptr, style()); |
| 411 } |
| 412 |
| 376 void LayoutBox::updateFromStyle() | 413 void LayoutBox::updateFromStyle() |
| 377 { | 414 { |
| 378 LayoutBoxModelObject::updateFromStyle(); | 415 LayoutBoxModelObject::updateFromStyle(); |
| 379 | 416 |
| 380 const ComputedStyle& styleToUse = styleRef(); | 417 const ComputedStyle& styleToUse = styleRef(); |
| 381 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); | 418 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); |
| 382 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); | 419 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); |
| 383 setHasReflection(styleToUse.boxReflect()); | 420 setHasReflection(styleToUse.boxReflect()); |
| 384 } | 421 } |
| 385 | 422 |
| (...skipping 4463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4849 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 4886 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 4850 if (!flowThread) { | 4887 if (!flowThread) { |
| 4851 // If there's no flow thread, we're not nested. All pages have the same
height. Give up. | 4888 // If there's no flow thread, we're not nested. All pages have the same
height. Give up. |
| 4852 return strutToNextPage; | 4889 return strutToNextPage; |
| 4853 } | 4890 } |
| 4854 // Start searching for a suitable offset at the top of the next page or colu
mn. | 4891 // Start searching for a suitable offset at the top of the next page or colu
mn. |
| 4855 LayoutUnit flowThreadOffset = offsetFromLogicalTopOfFirstPage() + nextPageLo
gicalTop; | 4892 LayoutUnit flowThreadOffset = offsetFromLogicalTopOfFirstPage() + nextPageLo
gicalTop; |
| 4856 return strutToNextPage + flowThread->nextLogicalTopForUnbreakableContent(flo
wThreadOffset, contentLogicalHeight) - flowThreadOffset; | 4893 return strutToNextPage + flowThread->nextLogicalTopForUnbreakableContent(flo
wThreadOffset, contentLogicalHeight) - flowThreadOffset; |
| 4857 } | 4894 } |
| 4858 | 4895 |
| 4896 LayoutBox* LayoutBox::snapContainer() const |
| 4897 { |
| 4898 return m_rareData ? m_rareData->m_snapContainer : nullptr; |
| 4899 } |
| 4900 |
| 4901 void LayoutBox::setSnapContainer(LayoutBox* newContainer) |
| 4902 { |
| 4903 LayoutBox* oldContainer = snapContainer(); |
| 4904 if (oldContainer == newContainer) |
| 4905 return; |
| 4906 |
| 4907 if (oldContainer) |
| 4908 oldContainer->removeSnapArea(*this); |
| 4909 |
| 4910 ensureRareData().m_snapContainer = newContainer; |
| 4911 |
| 4912 if (newContainer) |
| 4913 newContainer->addSnapArea(*this); |
| 4914 } |
| 4915 |
| 4916 void LayoutBox::clearSnapAreas() |
| 4917 { |
| 4918 if (SnapAreaSet* areas = snapAreas()) { |
| 4919 for (auto& snapArea : *areas) |
| 4920 snapArea->m_rareData->m_snapContainer = nullptr; |
| 4921 areas->clear(); |
| 4922 } |
| 4923 } |
| 4924 |
| 4925 void LayoutBox::addSnapArea(const LayoutBox& snapArea) |
| 4926 { |
| 4927 ensureRareData().ensureSnapAreas().add(&snapArea); |
| 4928 } |
| 4929 |
| 4930 void LayoutBox::removeSnapArea(const LayoutBox& snapArea) |
| 4931 { |
| 4932 if (m_rareData && m_rareData->m_snapAreas) { |
| 4933 m_rareData->m_snapAreas->remove(&snapArea); |
| 4934 } |
| 4935 } |
| 4936 |
| 4937 SnapAreaSet* LayoutBox::snapAreas() const |
| 4938 { |
| 4939 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; |
| 4940 } |
| 4941 |
| 4859 } // namespace blink | 4942 } // namespace blink |
| OLD | NEW |