| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef LayoutGrid_h | 26 #ifndef LayoutGrid_h |
| 27 #define LayoutGrid_h | 27 #define LayoutGrid_h |
| 28 | 28 |
| 29 #include "core/layout/BaselineAlignment.h" |
| 29 #include "core/layout/LayoutBlock.h" | 30 #include "core/layout/LayoutBlock.h" |
| 30 #include "core/layout/OrderIterator.h" | 31 #include "core/layout/OrderIterator.h" |
| 31 #include "core/style/GridPositionsResolver.h" | 32 #include "core/style/GridPositionsResolver.h" |
| 32 #include <memory> | 33 #include <memory> |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 struct ContentAlignmentData; | 37 struct ContentAlignmentData; |
| 37 struct GridArea; | 38 struct GridArea; |
| 38 struct GridSpan; | 39 struct GridSpan; |
| 39 class GridTrack; | 40 class GridTrack; |
| 40 | 41 |
| 41 enum TrackSizeComputationPhase { | 42 enum TrackSizeComputationPhase { |
| 42 ResolveIntrinsicMinimums, | 43 ResolveIntrinsicMinimums, |
| 43 ResolveContentBasedMinimums, | 44 ResolveContentBasedMinimums, |
| 44 ResolveMaxContentMinimums, | 45 ResolveMaxContentMinimums, |
| 45 ResolveIntrinsicMaximums, | 46 ResolveIntrinsicMaximums, |
| 46 ResolveMaxContentMaximums, | 47 ResolveMaxContentMaximums, |
| 47 MaximizeTracks, | 48 MaximizeTracks, |
| 48 }; | 49 }; |
| 49 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter }; | 50 enum GridAxisPosition { GridAxisStart, GridAxisEnd, GridAxisCenter }; |
| 51 enum GridAxis { GridRowAxis, GridColumnAxis }; |
| 50 | 52 |
| 51 class LayoutGrid final : public LayoutBlock { | 53 class LayoutGrid final : public LayoutBlock { |
| 52 public: | 54 public: |
| 53 explicit LayoutGrid(Element*); | 55 explicit LayoutGrid(Element*); |
| 54 ~LayoutGrid() override; | 56 ~LayoutGrid() override; |
| 55 | 57 |
| 56 static LayoutGrid* createAnonymous(Document*); | 58 static LayoutGrid* createAnonymous(Document*); |
| 57 const char* name() const override { return "LayoutGrid"; } | 59 const char* name() const override { return "LayoutGrid"; } |
| 58 | 60 |
| 59 void layoutBlock(bool relayoutChildren) override; | 61 void layoutBlock(bool relayoutChildren) override; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&); | 313 void updateAutoMarginsInColumnAxisIfNeeded(LayoutBox&); |
| 312 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&); | 314 void updateAutoMarginsInRowAxisIfNeeded(LayoutBox&); |
| 313 | 315 |
| 314 int baselinePosition( | 316 int baselinePosition( |
| 315 FontBaseline, | 317 FontBaseline, |
| 316 bool firstLine, | 318 bool firstLine, |
| 317 LineDirectionMode, | 319 LineDirectionMode, |
| 318 LinePositionMode = PositionOnContainingLine) const override; | 320 LinePositionMode = PositionOnContainingLine) const override; |
| 319 int firstLineBoxBaseline() const override; | 321 int firstLineBoxBaseline() const override; |
| 320 int inlineBlockBaseline(LineDirectionMode) const override; | 322 int inlineBlockBaseline(LineDirectionMode) const override; |
| 321 bool isInlineBaselineAlignedChild(const LayoutBox* child) const; | 323 |
| 324 bool isHorizontalGridAxis(GridAxis) const; |
| 325 bool isParallelToBlockAxisForChild(const LayoutBox&, GridAxis) const; |
| 326 bool isDescentBaselineForChild(const LayoutBox&, GridAxis) const; |
| 327 bool isBaselineAlignmentForChild(const LayoutBox&, |
| 328 GridAxis = GridColumnAxis) const; |
| 329 const BaselineGroup& getBaselineGroupForChild(const LayoutBox&, |
| 330 const GridSizingData&, |
| 331 GridAxis) const; |
| 332 |
| 333 LayoutUnit marginOverForChild(const LayoutBox&, GridAxis) const; |
| 334 LayoutUnit logicalAscentForChild(const LayoutBox&, GridAxis) const; |
| 335 LayoutUnit ascentForChild(const LayoutBox&, GridAxis) const; |
| 336 LayoutUnit descentForChild(const LayoutBox&, |
| 337 LayoutUnit ascent, |
| 338 GridAxis) const; |
| 339 |
| 340 bool isBaselineContextComputed(GridAxis) const; |
| 341 bool baselineMayAffectIntrinsicWidth() const; |
| 342 void computeBaselineAlignmentContext(GridSizingData&); |
| 343 void updateBaselineAlignmentContextIfNeeded(LayoutBox&, |
| 344 GridSizingData&, |
| 345 GridAxis); |
| 346 |
| 347 LayoutUnit columnAxisBaselineOffsetForChild(const LayoutBox&, |
| 348 const GridSizingData&) const; |
| 349 LayoutUnit rowAxisBaselineOffsetForChild(const LayoutBox&, |
| 350 const GridSizingData&) const; |
| 322 | 351 |
| 323 #if ENABLE(ASSERT) | 352 #if ENABLE(ASSERT) |
| 324 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, | 353 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, |
| 325 GridSizingData&) const; | 354 GridSizingData&) const; |
| 326 #endif | 355 #endif |
| 327 | 356 |
| 328 LayoutUnit gridGapForDirection(GridTrackSizingDirection, | 357 LayoutUnit gridGapForDirection(GridTrackSizingDirection, |
| 329 SizingOperation) const; | 358 SizingOperation) const; |
| 330 LayoutUnit guttersSize(const Grid&, | 359 LayoutUnit guttersSize(const Grid&, |
| 331 GridTrackSizingDirection, | 360 GridTrackSizingDirection, |
| 332 size_t startLine, | 361 size_t startLine, |
| 333 size_t span, | 362 size_t span, |
| 334 SizingOperation) const; | 363 SizingOperation) const; |
| 335 | 364 |
| 336 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); | 365 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); |
| 337 bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&, | 366 bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&, |
| 338 GridTrackSizingDirection, | 367 GridTrackSizingDirection, |
| 339 const GridSizingData&) const; | 368 const GridSizingData&) const; |
| 340 | 369 |
| 341 bool isOrthogonalChild(const LayoutBox&) const; | 370 bool isOrthogonalChild(const LayoutBox&) const; |
| 342 GridTrackSizingDirection flowAwareDirectionForChild( | 371 GridTrackSizingDirection flowAwareDirectionForChild( |
| 343 const LayoutBox&, | 372 const LayoutBox&, |
| 344 GridTrackSizingDirection) const; | 373 GridTrackSizingDirection) const; |
| 345 | 374 |
| 346 bool cachedHasDefiniteLogicalHeight() const; | 375 bool cachedHasDefiniteLogicalHeight() const; |
| 347 | 376 |
| 348 size_t numTracks(GridTrackSizingDirection, const Grid&) const; | 377 size_t numTracks(GridTrackSizingDirection, const Grid&) const; |
| 349 | 378 |
| 379 typedef HashMap<unsigned, |
| 380 std::unique_ptr<BaselineContext>, |
| 381 DefaultHash<unsigned>::Hash, |
| 382 WTF::UnsignedWithZeroKeyHashTraits<unsigned>> |
| 383 BaselineContextsMap; |
| 384 |
| 385 BaselineContextsMap m_rowAxisAlignmentContext; |
| 386 BaselineContextsMap m_colAxisAlignmentContext; |
| 387 |
| 350 // TODO(svillar): move into this class once GridIterator is added. | 388 // TODO(svillar): move into this class once GridIterator is added. |
| 351 typedef Vector<Vector<GridCell>> GridAsMatrix; | 389 typedef Vector<Vector<GridCell>> GridAsMatrix; |
| 352 class Grid final { | 390 class Grid final { |
| 353 public: | 391 public: |
| 354 Grid(const LayoutGrid* grid) : m_orderIterator(grid) {} | 392 Grid(const LayoutGrid* grid) : m_orderIterator(grid) {} |
| 355 | 393 |
| 356 size_t numTracks(GridTrackSizingDirection) const; | 394 size_t numTracks(GridTrackSizingDirection) const; |
| 357 | 395 |
| 358 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); | 396 void ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize); |
| 359 void insert(LayoutBox&, const GridArea&); | 397 void insert(LayoutBox&, const GridArea&); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 LayoutUnit m_maxContentHeight{-1}; | 474 LayoutUnit m_maxContentHeight{-1}; |
| 437 | 475 |
| 438 Optional<bool> m_hasDefiniteLogicalHeight; | 476 Optional<bool> m_hasDefiniteLogicalHeight; |
| 439 }; | 477 }; |
| 440 | 478 |
| 441 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); | 479 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); |
| 442 | 480 |
| 443 } // namespace blink | 481 } // namespace blink |
| 444 | 482 |
| 445 #endif // LayoutGrid_h | 483 #endif // LayoutGrid_h |
| OLD | NEW |