| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 | 26 |
| 27 #ifndef LayoutMultiColumnSet_h | 27 #ifndef LayoutMultiColumnSet_h |
| 28 #define LayoutMultiColumnSet_h | 28 #define LayoutMultiColumnSet_h |
| 29 | 29 |
| 30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
| 31 #include "core/layout/LayoutMultiColumnFlowThread.h" | 31 #include "core/layout/LayoutMultiColumnFlowThread.h" |
| 32 #include "core/layout/LayoutRegion.h" | |
| 33 #include "core/layout/MultiColumnFragmentainerGroup.h" | 32 #include "core/layout/MultiColumnFragmentainerGroup.h" |
| 34 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
| 35 | 34 |
| 36 namespace blink { | 35 namespace blink { |
| 37 | 36 |
| 38 // A set of columns in a multicol container. A column set is inserted as an anon
ymous child of the | 37 // A set of columns in a multicol container. A column set is inserted as an anon
ymous child of the |
| 39 // actual multicol container (i.e. the layoutObject whose style computes to non-
auto column-count and/or | 38 // actual multicol container (i.e. the layoutObject whose style computes to non-
auto column-count and/or |
| 40 // column-width), next to the flow thread. There'll be one column set for each c
ontiguous run of | 39 // column-width), next to the flow thread. There'll be one column set for each c
ontiguous run of |
| 41 // column content. The only thing that can interrupt a contiguous run of column
content is a column | 40 // column content. The only thing that can interrupt a contiguous run of column
content is a column |
| 42 // spanner, which means that if there are no spanners, there'll only be one colu
mn set. | 41 // spanner, which means that if there are no spanners, there'll only be one colu
mn set. |
| 43 // | 42 // |
| 44 // Since a spanner interrupts an otherwise contiguous run of column content, ins
erting one may | 43 // Since a spanner interrupts an otherwise contiguous run of column content, ins
erting one may |
| 45 // result in the creation of additional new column sets. A placeholder for the s
panning layoutObject has | 44 // result in the creation of additional new column sets. A placeholder for the s
panning layoutObject has |
| 46 // to be placed in between the column sets that come before and after the spanne
r, if there's | 45 // to be placed in between the column sets that come before and after the spanne
r, if there's |
| 47 // actually column content both before and after the spanner. | 46 // actually column content both before and after the spanner. |
| 48 // | 47 // |
| 49 // A column set has no children on its own, but is merely used to slice a portio
n of the tall | 48 // A column set has no children on its own, but is merely used to slice a portio
n of the tall |
| 50 // "single-column" flow thread into actual columns visually, to convert from flo
w thread coordinates | 49 // "single-column" flow thread into actual columns visually, to convert from flo
w thread coordinates |
| 51 // to visual ones. It is in charge of both positioning columns correctly relativ
ely to the parent | 50 // to visual ones. It is in charge of both positioning columns correctly relativ
ely to the parent |
| 52 // multicol container, and to calculate the correct translation for each column'
s contents, and to | 51 // multicol container, and to calculate the correct translation for each column'
s contents, and to |
| 53 // paint any rules between them. LayoutMultiColumnSet objects are used for paint
ing, hit testing, | 52 // paint any rules between them. LayoutMultiColumnSet objects are used for paint
ing, hit testing, |
| 54 // and any other type of operation that requires mapping from flow thread coordi
nates to visual | 53 // and any other type of operation that requires mapping from flow thread coordi
nates to visual |
| 55 // coordinates. | 54 // coordinates. |
| 56 // | 55 // |
| 57 // Columns are normally laid out in the inline progression direction, but if the
multicol container | 56 // Columns are normally laid out in the inline progression direction, but if the
multicol container |
| 58 // is inside another fragmentation context (e.g. paged media, or an another mult
icol container), we | 57 // is inside another fragmentation context (e.g. paged media, or an another mult
icol container), we |
| 59 // may need to group the columns, so that we get one MultiColumnFragmentainerGro
up for each outer | 58 // may need to group the columns, so that we get one MultiColumnFragmentainerGro
up for each outer |
| 60 // fragmentainer (page / column) that the inner multicol container lives in. Eac
h fragmentainer | 59 // fragmentainer (page / column) that the inner multicol container lives in. Eac
h fragmentainer |
| 61 // group has its own column height, but the column height is uniform within a gr
oup. | 60 // group has its own column height, but the column height is uniform within a gr
oup. |
| 62 class CORE_EXPORT LayoutMultiColumnSet : public LayoutRegion { | 61 class CORE_EXPORT LayoutMultiColumnSet : public LayoutBlockFlow { |
| 63 public: | 62 public: |
| 64 static LayoutMultiColumnSet* createAnonymous(LayoutFlowThread&, const Comput
edStyle& parentStyle); | 63 static LayoutMultiColumnSet* createAnonymous(LayoutFlowThread&, const Comput
edStyle& parentStyle); |
| 65 | 64 |
| 66 const MultiColumnFragmentainerGroup& firstFragmentainerGroup() const { retur
n m_fragmentainerGroups.first(); } | 65 const MultiColumnFragmentainerGroup& firstFragmentainerGroup() const { retur
n m_fragmentainerGroups.first(); } |
| 67 const MultiColumnFragmentainerGroup& lastFragmentainerGroup() const { return
m_fragmentainerGroups.last(); } | 66 const MultiColumnFragmentainerGroup& lastFragmentainerGroup() const { return
m_fragmentainerGroups.last(); } |
| 68 MultiColumnFragmentainerGroup& fragmentainerGroupAtFlowThreadOffset(LayoutUn
it); | 67 MultiColumnFragmentainerGroup& fragmentainerGroupAtFlowThreadOffset(LayoutUn
it); |
| 69 const MultiColumnFragmentainerGroup& fragmentainerGroupAtFlowThreadOffset(La
youtUnit) const; | 68 const MultiColumnFragmentainerGroup& fragmentainerGroupAtFlowThreadOffset(La
youtUnit) const; |
| 70 const MultiColumnFragmentainerGroup& fragmentainerGroupAtVisualPoint(const L
ayoutPoint&) const; | 69 const MultiColumnFragmentainerGroup& fragmentainerGroupAtVisualPoint(const L
ayoutPoint&) const; |
| 71 | 70 |
| 72 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectLayoutMultiColumnSet || LayoutRegion::isOfType(type); } | 71 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectLayoutMultiColumnSet || LayoutBlockFlow::isOfType(type); } |
| 72 virtual bool canHaveChildren() const override final { return false; } |
| 73 | 73 |
| 74 virtual LayoutUnit pageLogicalWidth() const final { return flowThread()->log
icalWidth(); } | 74 // Return the width and height of a single column or page in the set. |
| 75 virtual LayoutUnit pageLogicalHeight() const final; | 75 LayoutUnit pageLogicalWidth() const { return flowThread()->logicalWidth(); } |
| 76 LayoutUnit pageLogicalHeight() const; |
| 77 |
| 78 LayoutFlowThread* flowThread() const { return m_flowThread; } |
| 76 | 79 |
| 77 LayoutBlockFlow* multiColumnBlockFlow() const { return toLayoutBlockFlow(par
ent()); } | 80 LayoutBlockFlow* multiColumnBlockFlow() const { return toLayoutBlockFlow(par
ent()); } |
| 78 LayoutMultiColumnFlowThread* multiColumnFlowThread() const | 81 LayoutMultiColumnFlowThread* multiColumnFlowThread() const |
| 79 { | 82 { |
| 80 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isLayout
MultiColumnFlowThread()); | 83 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isLayout
MultiColumnFlowThread()); |
| 81 return static_cast<LayoutMultiColumnFlowThread*>(flowThread()); | 84 return static_cast<LayoutMultiColumnFlowThread*>(flowThread()); |
| 82 } | 85 } |
| 83 | 86 |
| 84 LayoutMultiColumnSet* nextSiblingMultiColumnSet() const; | 87 LayoutMultiColumnSet* nextSiblingMultiColumnSet() const; |
| 85 LayoutMultiColumnSet* previousSiblingMultiColumnSet() const; | 88 LayoutMultiColumnSet* previousSiblingMultiColumnSet() const; |
| 86 | 89 |
| 87 LayoutUnit logicalTopInFlowThread() const; | 90 LayoutUnit logicalTopInFlowThread() const; |
| 88 LayoutUnit logicalBottomInFlowThread() const; | 91 LayoutUnit logicalBottomInFlowThread() const; |
| 89 LayoutUnit logicalHeightInFlowThread() const { return logicalBottomInFlowThr
ead() - logicalTopInFlowThread(); } | 92 LayoutUnit logicalHeightInFlowThread() const { return logicalBottomInFlowThr
ead() - logicalTopInFlowThread(); } |
| 93 LayoutRect flowThreadPortionRect() const; |
| 94 LayoutRect flowThreadPortionOverflowRect() const; |
| 95 LayoutRect overflowRectForFlowThreadPortion(const LayoutRect& flowThreadPort
ionRect, bool isFirstPortion, bool isLastPortion) const; |
| 90 | 96 |
| 91 // The used CSS value of column-count, i.e. how many columns there are room
for without overflowing. | 97 // The used CSS value of column-count, i.e. how many columns there are room
for without overflowing. |
| 92 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou
nt(); } | 98 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou
nt(); } |
| 93 | 99 |
| 94 bool heightIsAuto() const; | 100 bool heightIsAuto() const; |
| 95 | 101 |
| 96 // Find the column that contains the given block offset, and return the tran
slation needed to | 102 // Find the column that contains the given block offset, and return the tran
slation needed to |
| 97 // get from flow thread coordinates to visual coordinates. | 103 // get from flow thread coordinates to visual coordinates. |
| 98 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; | 104 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; |
| 99 | 105 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 128 | 134 |
| 129 // Layout of flow thread content that was to be rendered inside this column
set has | 135 // Layout of flow thread content that was to be rendered inside this column
set has |
| 130 // finished. This happens at end of flow thread layout, and when advancing t
o the next column | 136 // finished. This happens at end of flow thread layout, and when advancing t
o the next column |
| 131 // set or spanner. | 137 // set or spanner. |
| 132 void endFlow(LayoutUnit offsetInFlowThread); | 138 void endFlow(LayoutUnit offsetInFlowThread); |
| 133 | 139 |
| 134 // Expand this set's flow thread portion rectangle to contain all trailing f
low thread | 140 // Expand this set's flow thread portion rectangle to contain all trailing f
low thread |
| 135 // overflow. Only to be called on the last set. | 141 // overflow. Only to be called on the last set. |
| 136 void expandToEncompassFlowThreadContentsIfNeeded(); | 142 void expandToEncompassFlowThreadContentsIfNeeded(); |
| 137 | 143 |
| 138 void attachRegion(); | 144 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const override final; |
| 139 void detachRegion(); | |
| 140 | 145 |
| 141 // The top of the nearest page inside the region. For LayoutRegions, this is
just the logical top of the | 146 void attachToFlowThread(); |
| 142 // flow thread portion we contain. For sets, we have to figure out the top o
f the nearest column or | 147 void detachFromFlowThread(); |
| 143 // page. | 148 |
| 149 // The top of the page nearest to the specified block offset. All in flowthr
ead coordinates. |
| 144 LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const; | 150 LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const; |
| 145 | 151 |
| 146 void collectLayerFragments(DeprecatedPaintLayerFragments&, const LayoutRect&
layerBoundingBox, const LayoutRect& dirtyRect); | 152 void collectLayerFragments(DeprecatedPaintLayerFragments&, const LayoutRect&
layerBoundingBox, const LayoutRect& dirtyRect); |
| 147 | 153 |
| 148 LayoutUnit columnGap() const; | 154 LayoutUnit columnGap() const; |
| 149 | 155 |
| 150 // The "CSS actual" value of column-count. This includes overflowing columns
, if any. | 156 // The "CSS actual" value of column-count. This includes overflowing columns
, if any. |
| 151 unsigned actualColumnCount() const; | 157 unsigned actualColumnCount() const; |
| 152 | 158 |
| 153 virtual const char* name() const override { return "LayoutMultiColumnSet"; } | 159 virtual const char* name() const override { return "LayoutMultiColumnSet"; } |
| 154 | 160 |
| 155 protected: | 161 protected: |
| 156 LayoutMultiColumnSet(LayoutFlowThread*); | 162 LayoutMultiColumnSet(LayoutFlowThread*); |
| 157 | 163 |
| 158 private: | 164 private: |
| 159 virtual void insertedIntoTree() override final; | 165 virtual void insertedIntoTree() override final; |
| 160 virtual void willBeRemovedFromTree() override final; | 166 virtual void willBeRemovedFromTree() override final; |
| 161 | 167 |
| 162 virtual bool isSelfCollapsingBlock() const override { return false; } | 168 virtual bool isSelfCollapsingBlock() const override { return false; } |
| 163 | 169 |
| 164 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const override; | 170 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const override; |
| 165 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) override; | 171 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) override; |
| 166 | 172 |
| 167 virtual void paintObject(const PaintInfo&, const LayoutPoint& paintOffset) o
verride; | 173 virtual void paintObject(const PaintInfo&, const LayoutPoint& paintOffset) o
verride; |
| 168 | 174 |
| 169 virtual void addOverflowFromChildren() override; | 175 virtual void addOverflowFromChildren() override; |
| 170 | 176 |
| 171 virtual LayoutRect flowThreadPortionRect() const override; | |
| 172 | |
| 173 MultiColumnFragmentainerGroupList m_fragmentainerGroups; | 177 MultiColumnFragmentainerGroupList m_fragmentainerGroups; |
| 178 LayoutFlowThread* m_flowThread; |
| 174 }; | 179 }; |
| 175 | 180 |
| 176 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutMultiColumnSet, isLayoutMultiColumnSet()); | 181 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutMultiColumnSet, isLayoutMultiColumnSet()); |
| 177 | 182 |
| 178 } // namespace blink | 183 } // namespace blink |
| 179 | 184 |
| 180 #endif // LayoutMultiColumnSet_h | 185 #endif // LayoutMultiColumnSet_h |
| 181 | 186 |
| OLD | NEW |