Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: Source/core/layout/LayoutMultiColumnSet.cpp

Issue 978603003: [New Multicolumn] Make positionForPoint() work. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 #include "config.h" 26 #include "config.h"
27 #include "core/layout/LayoutMultiColumnSet.h" 27 #include "core/layout/LayoutMultiColumnSet.h"
28 28
29 #include "core/editing/PositionWithAffinity.h"
29 #include "core/layout/LayoutMultiColumnFlowThread.h" 30 #include "core/layout/LayoutMultiColumnFlowThread.h"
30 #include "core/layout/MultiColumnFragmentainerGroup.h" 31 #include "core/layout/MultiColumnFragmentainerGroup.h"
31 #include "core/paint/MultiColumnSetPainter.h" 32 #include "core/paint/MultiColumnSetPainter.h"
32 33
33 namespace blink { 34 namespace blink {
34 35
35 LayoutMultiColumnSet::LayoutMultiColumnSet(LayoutFlowThread* flowThread) 36 LayoutMultiColumnSet::LayoutMultiColumnSet(LayoutFlowThread* flowThread)
36 : LayoutRegion(0, flowThread) 37 : LayoutRegion(0, flowThread)
37 , m_fragmentainerGroups(*this) 38 , m_fragmentainerGroups(*this)
38 { 39 {
(...skipping 13 matching lines...) Expand all
52 // FIXME: implement this, once we have support for multiple rows. 53 // FIXME: implement this, once we have support for multiple rows.
53 return m_fragmentainerGroups.first(); 54 return m_fragmentainerGroups.first();
54 } 55 }
55 56
56 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtF lowThreadOffset(LayoutUnit) const 57 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtF lowThreadOffset(LayoutUnit) const
57 { 58 {
58 // FIXME: implement this, once we have support for multiple rows. 59 // FIXME: implement this, once we have support for multiple rows.
59 return m_fragmentainerGroups.first(); 60 return m_fragmentainerGroups.first();
60 } 61 }
61 62
63 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtV isualPoint(const LayoutPoint&) const
64 {
65 // FIXME: implement this, once we have support for multiple rows.
66 return m_fragmentainerGroups.first();
67 }
68
62 LayoutUnit LayoutMultiColumnSet::pageLogicalHeight() const 69 LayoutUnit LayoutMultiColumnSet::pageLogicalHeight() const
63 { 70 {
64 // FIXME: pageLogicalHeight() needs to take a flow thread offset parameter, so that we can 71 // FIXME: pageLogicalHeight() needs to take a flow thread offset parameter, so that we can
65 // locate the right row. 72 // locate the right row.
66 return firstFragmentainerGroup().logicalHeight(); 73 return firstFragmentainerGroup().logicalHeight();
67 } 74 }
68 75
69 LayoutMultiColumnSet* LayoutMultiColumnSet::nextSiblingMultiColumnSet() const 76 LayoutMultiColumnSet* LayoutMultiColumnSet::nextSiblingMultiColumnSet() const
70 { 77 {
71 for (LayoutObject* sibling = nextSibling(); sibling; sibling = sibling->next Sibling()) { 78 for (LayoutObject* sibling = nextSibling(); sibling; sibling = sibling->next Sibling()) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 185
179 void LayoutMultiColumnSet::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTo p, LogicalExtentComputedValues& computedValues) const 186 void LayoutMultiColumnSet::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTo p, LogicalExtentComputedValues& computedValues) const
180 { 187 {
181 LayoutUnit logicalHeight; 188 LayoutUnit logicalHeight;
182 for (const auto& group : m_fragmentainerGroups) 189 for (const auto& group : m_fragmentainerGroups)
183 logicalHeight += group.logicalHeight(); 190 logicalHeight += group.logicalHeight();
184 computedValues.m_extent = logicalHeight; 191 computedValues.m_extent = logicalHeight;
185 computedValues.m_position = logicalTop; 192 computedValues.m_position = logicalTop;
186 } 193 }
187 194
195 PositionWithAffinity LayoutMultiColumnSet::positionForPoint(const LayoutPoint& p oint)
196 {
197 // Convert the visual point to a flow thread point.
198 const MultiColumnFragmentainerGroup& row = fragmentainerGroupAtVisualPoint(p oint);
199 LayoutPoint flowThreadPoint = row.visualPointToFlowThreadPoint(point + row.o ffsetFromColumnSet());
200 // Then drill into the flow thread, where we'll find the actual content.
201 return flowThread()->positionForPoint(flowThreadPoint);
202 }
203
188 LayoutUnit LayoutMultiColumnSet::columnGap() const 204 LayoutUnit LayoutMultiColumnSet::columnGap() const
189 { 205 {
190 LayoutBlockFlow* parentBlock = multiColumnBlockFlow(); 206 LayoutBlockFlow* parentBlock = multiColumnBlockFlow();
191 if (parentBlock->style()->hasNormalColumnGap()) 207 if (parentBlock->style()->hasNormalColumnGap())
192 return parentBlock->style()->fontDescription().computedPixelSize(); // " 1em" is recommended as the normal gap setting. Matches <p> margins. 208 return parentBlock->style()->fontDescription().computedPixelSize(); // " 1em" is recommended as the normal gap setting. Matches <p> margins.
193 return parentBlock->style()->columnGap(); 209 return parentBlock->style()->columnGap();
194 } 210 }
195 211
196 unsigned LayoutMultiColumnSet::actualColumnCount() const 212 unsigned LayoutMultiColumnSet::actualColumnCount() const
197 { 213 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 279
264 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const 280 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const
265 { 281 {
266 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi dth(), logicalHeightInFlowThread()); 282 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi dth(), logicalHeightInFlowThread());
267 if (!isHorizontalWritingMode()) 283 if (!isHorizontalWritingMode())
268 return portionRect.transposedRect(); 284 return portionRect.transposedRect();
269 return portionRect; 285 return portionRect;
270 } 286 }
271 287
272 } 288 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutMultiColumnSet.h ('k') | Source/core/layout/MultiColumnFragmentainerGroup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698