| 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" | |
| 60 #include "core/paint/BackgroundImageGeometry.h" | 59 #include "core/paint/BackgroundImageGeometry.h" |
| 61 #include "core/paint/BoxPainter.h" | 60 #include "core/paint/BoxPainter.h" |
| 62 #include "core/paint/PaintLayer.h" | 61 #include "core/paint/PaintLayer.h" |
| 63 #include "core/style/ShadowList.h" | 62 #include "core/style/ShadowList.h" |
| 64 #include "platform/LengthFunctions.h" | 63 #include "platform/LengthFunctions.h" |
| 65 #include "platform/geometry/DoubleRect.h" | 64 #include "platform/geometry/DoubleRect.h" |
| 66 #include "platform/geometry/FloatQuad.h" | 65 #include "platform/geometry/FloatQuad.h" |
| 67 #include "platform/geometry/FloatRoundedRect.h" | 66 #include "platform/geometry/FloatRoundedRect.h" |
| 68 #include "platform/geometry/TransformState.h" | 67 #include "platform/geometry/TransformState.h" |
| 69 #include "platform/graphics/GraphicsContext.h" | 68 #include "platform/graphics/GraphicsContext.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 unmarkOrthogonalWritingModeRoot(); | 138 unmarkOrthogonalWritingModeRoot(); |
| 140 | 139 |
| 141 ShapeOutsideInfo::removeInfo(*this); | 140 ShapeOutsideInfo::removeInfo(*this); |
| 142 | 141 |
| 143 LayoutBoxModelObject::willBeDestroyed(); | 142 LayoutBoxModelObject::willBeDestroyed(); |
| 144 } | 143 } |
| 145 | 144 |
| 146 void LayoutBox::insertedIntoTree() | 145 void LayoutBox::insertedIntoTree() |
| 147 { | 146 { |
| 148 LayoutBoxModelObject::insertedIntoTree(); | 147 LayoutBoxModelObject::insertedIntoTree(); |
| 149 addScrollSnapMapping(); | |
| 150 | 148 |
| 151 if (isOrthogonalWritingModeRoot()) | 149 if (isOrthogonalWritingModeRoot()) |
| 152 markOrthogonalWritingModeRoot(); | 150 markOrthogonalWritingModeRoot(); |
| 153 } | 151 } |
| 154 | 152 |
| 155 void LayoutBox::willBeRemovedFromTree() | 153 void LayoutBox::willBeRemovedFromTree() |
| 156 { | 154 { |
| 157 if (!documentBeingDestroyed() && isOrthogonalWritingModeRoot()) | 155 if (!documentBeingDestroyed() && isOrthogonalWritingModeRoot()) |
| 158 unmarkOrthogonalWritingModeRoot(); | 156 unmarkOrthogonalWritingModeRoot(); |
| 159 | 157 |
| 160 clearScrollSnapMapping(); | |
| 161 LayoutBoxModelObject::willBeRemovedFromTree(); | 158 LayoutBoxModelObject::willBeRemovedFromTree(); |
| 162 } | 159 } |
| 163 | 160 |
| 164 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() | 161 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() |
| 165 { | 162 { |
| 166 ASSERT(isFloatingOrOutOfFlowPositioned()); | 163 ASSERT(isFloatingOrOutOfFlowPositioned()); |
| 167 | 164 |
| 168 if (documentBeingDestroyed()) | 165 if (documentBeingDestroyed()) |
| 169 return; | 166 return; |
| 170 | 167 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 294 |
| 298 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) | 295 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) |
| 299 placeholder->layoutObjectInFlowThreadStyleDidChange(oldStyle); | 296 placeholder->layoutObjectInFlowThreadStyleDidChange(oldStyle); |
| 300 | 297 |
| 301 updateBackgroundAttachmentFixedStatusAfterStyleChange(); | 298 updateBackgroundAttachmentFixedStatusAfterStyleChange(); |
| 302 | 299 |
| 303 if (oldStyle) { | 300 if (oldStyle) { |
| 304 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 301 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 305 if (flowThread && flowThread != this) | 302 if (flowThread && flowThread != this) |
| 306 flowThread->flowThreadDescendantStyleDidChange(this, diff, *oldStyle
); | 303 flowThread->flowThreadDescendantStyleDidChange(this, diff, *oldStyle
); |
| 307 | |
| 308 updateScrollSnapMappingAfterStyleChange(&newStyle, oldStyle); | |
| 309 } | 304 } |
| 310 | 305 |
| 311 ASSERT(!isInline() || isAtomicInlineLevel()); // Non-atomic inlines should b
e LayoutInline or LayoutText, not LayoutBox. | 306 ASSERT(!isInline() || isAtomicInlineLevel()); // Non-atomic inlines should b
e LayoutInline or LayoutText, not LayoutBox. |
| 312 } | 307 } |
| 313 | 308 |
| 314 void LayoutBox::updateBackgroundAttachmentFixedStatusAfterStyleChange() | 309 void LayoutBox::updateBackgroundAttachmentFixedStatusAfterStyleChange() |
| 315 { | 310 { |
| 316 if (!frameView()) | 311 if (!frameView()) |
| 317 return; | 312 return; |
| 318 | 313 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 && oldStyle->gridRowEnd() == style()->gridRowEnd() | 366 && oldStyle->gridRowEnd() == style()->gridRowEnd() |
| 372 && oldStyle->order() == style()->order() | 367 && oldStyle->order() == style()->order() |
| 373 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) | 368 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) |
| 374 return; | 369 return; |
| 375 | 370 |
| 376 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). | 371 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). |
| 377 // For now, it's more simple to just always recompute the grid. | 372 // For now, it's more simple to just always recompute the grid. |
| 378 toLayoutGrid(parent())->dirtyGrid(); | 373 toLayoutGrid(parent())->dirtyGrid(); |
| 379 } | 374 } |
| 380 | 375 |
| 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 | |
| 413 void LayoutBox::updateFromStyle() | 376 void LayoutBox::updateFromStyle() |
| 414 { | 377 { |
| 415 LayoutBoxModelObject::updateFromStyle(); | 378 LayoutBoxModelObject::updateFromStyle(); |
| 416 | 379 |
| 417 const ComputedStyle& styleToUse = styleRef(); | 380 const ComputedStyle& styleToUse = styleRef(); |
| 418 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); | 381 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); |
| 419 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); | 382 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); |
| 420 setHasReflection(styleToUse.boxReflect()); | 383 setHasReflection(styleToUse.boxReflect()); |
| 421 } | 384 } |
| 422 | 385 |
| (...skipping 4385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4808 } | 4771 } |
| 4809 | 4772 |
| 4810 void LayoutBox::clearPercentHeightDescendants() | 4773 void LayoutBox::clearPercentHeightDescendants() |
| 4811 { | 4774 { |
| 4812 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { | 4775 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { |
| 4813 if (curr->isBox()) | 4776 if (curr->isBox()) |
| 4814 toLayoutBox(curr)->removeFromPercentHeightContainer(); | 4777 toLayoutBox(curr)->removeFromPercentHeightContainer(); |
| 4815 } | 4778 } |
| 4816 } | 4779 } |
| 4817 | 4780 |
| 4818 LayoutBox* LayoutBox::snapContainer() const | |
| 4819 { | |
| 4820 return m_rareData ? m_rareData->m_snapContainer : nullptr; | |
| 4821 } | |
| 4822 | |
| 4823 void LayoutBox::setSnapContainer(LayoutBox* newContainer) | |
| 4824 { | |
| 4825 LayoutBox* oldContainer = snapContainer(); | |
| 4826 if (oldContainer == newContainer) | |
| 4827 return; | |
| 4828 | |
| 4829 if (oldContainer) | |
| 4830 oldContainer->removeSnapArea(*this); | |
| 4831 | |
| 4832 ensureRareData().m_snapContainer = newContainer; | |
| 4833 | |
| 4834 if (newContainer) | |
| 4835 newContainer->addSnapArea(*this); | |
| 4836 } | |
| 4837 | |
| 4838 void LayoutBox::clearSnapAreas() | |
| 4839 { | |
| 4840 if (SnapAreaSet* areas = snapAreas()) { | |
| 4841 for (auto& snapArea : *areas) | |
| 4842 snapArea->m_rareData->m_snapContainer = nullptr; | |
| 4843 areas->clear(); | |
| 4844 } | |
| 4845 } | |
| 4846 | |
| 4847 void LayoutBox::addSnapArea(const LayoutBox& snapArea) | |
| 4848 { | |
| 4849 ensureRareData().ensureSnapAreas().add(&snapArea); | |
| 4850 } | |
| 4851 | |
| 4852 void LayoutBox::removeSnapArea(const LayoutBox& snapArea) | |
| 4853 { | |
| 4854 if (m_rareData && m_rareData->m_snapAreas) { | |
| 4855 m_rareData->m_snapAreas->remove(&snapArea); | |
| 4856 } | |
| 4857 } | |
| 4858 | |
| 4859 SnapAreaSet* LayoutBox::snapAreas() const | |
| 4860 { | |
| 4861 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; | |
| 4862 } | |
| 4863 | |
| 4864 } // namespace blink | 4781 } // namespace blink |
| OLD | NEW |