- Revision
- 118839
- Author
- [email protected]
- Date
- 2012-05-29 15:22:42 -0700 (Tue, 29 May 2012)
Log Message
https://bugs.webkit.org/show_bug.cgi?id=87787
[New Multicolumn] Refactor the region and flow thread code so that it can pick up the correct column widths
and heights when determining the logical width and height of the flow thread itself.
This patch adds new virtual methods to RenderRegion: logicalWidthForFlowThreadContent and logicalHeightForFlowThreadContent.
For normal regions, these methods return the contentWidth and contentHeight of the regions themselves. For column sets,
however, these methods actually return the column widths and heights.
This allows the flow thread to properly lay out according to the column width.
Region invalidation is also done properly by using these new methods.
In some cases the code is actually simplified, since we can get rid of some isHorizontalWritingMode() switching.
With this patch the flow thread now actually lays out and paints at the right width (spilling out of the region set in a single unbroken
column).
Reviewed by Dan Bernstein.
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::layout):
(WebCore::RenderFlowThread::computeLogicalWidth):
(WebCore::RenderFlowThread::computeLogicalHeight):
* rendering/RenderMultiColumnBlock.cpp:
(WebCore::RenderMultiColumnBlock::ensureColumnSets):
* rendering/RenderMultiColumnBlock.h:
(WebCore::RenderMultiColumnBlock::isRenderMultiColumnBlock):
(RenderMultiColumnBlock):
(WebCore::toRenderMultiColumnBlock):
(WebCore):
* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::computeLogicalWidth):
(WebCore):
(WebCore::RenderMultiColumnSet::computeLogicalHeight):
* rendering/RenderMultiColumnSet.h:
(WebCore::RenderMultiColumnSet::setColumnWidthAndCount):
(RenderMultiColumnSet):
* rendering/RenderObject.h:
(WebCore::RenderObject::isRenderMultiColumnBlock):
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::logicalWidthForFlowThreadContent):
(WebCore):
(WebCore::RenderRegion::logicalHeightForFlowThreadContent):
(WebCore::RenderRegion::layout):
* rendering/RenderRegion.h:
(RenderRegion):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (118838 => 118839)
--- trunk/Source/WebCore/ChangeLog 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/ChangeLog 2012-05-29 22:22:42 UTC (rev 118839)
@@ -1,3 +1,53 @@
+2012-05-29 David Hyatt <[email protected]>
+
+ https://bugs.webkit.org/show_bug.cgi?id=87787
+
+ [New Multicolumn] Refactor the region and flow thread code so that it can pick up the correct column widths
+ and heights when determining the logical width and height of the flow thread itself.
+
+ This patch adds new virtual methods to RenderRegion: logicalWidthForFlowThreadContent and logicalHeightForFlowThreadContent.
+ For normal regions, these methods return the contentWidth and contentHeight of the regions themselves. For column sets,
+ however, these methods actually return the column widths and heights.
+
+ This allows the flow thread to properly lay out according to the column width.
+
+ Region invalidation is also done properly by using these new methods.
+
+ In some cases the code is actually simplified, since we can get rid of some isHorizontalWritingMode() switching.
+
+ With this patch the flow thread now actually lays out and paints at the right width (spilling out of the region set in a single unbroken
+ column).
+
+ Reviewed by Dan Bernstein.
+
+ * rendering/RenderFlowThread.cpp:
+ (WebCore::RenderFlowThread::layout):
+ (WebCore::RenderFlowThread::computeLogicalWidth):
+ (WebCore::RenderFlowThread::computeLogicalHeight):
+ * rendering/RenderMultiColumnBlock.cpp:
+ (WebCore::RenderMultiColumnBlock::ensureColumnSets):
+ * rendering/RenderMultiColumnBlock.h:
+ (WebCore::RenderMultiColumnBlock::isRenderMultiColumnBlock):
+ (RenderMultiColumnBlock):
+ (WebCore::toRenderMultiColumnBlock):
+ (WebCore):
+ * rendering/RenderMultiColumnSet.cpp:
+ (WebCore::RenderMultiColumnSet::computeLogicalWidth):
+ (WebCore):
+ (WebCore::RenderMultiColumnSet::computeLogicalHeight):
+ * rendering/RenderMultiColumnSet.h:
+ (WebCore::RenderMultiColumnSet::setColumnWidthAndCount):
+ (RenderMultiColumnSet):
+ * rendering/RenderObject.h:
+ (WebCore::RenderObject::isRenderMultiColumnBlock):
+ * rendering/RenderRegion.cpp:
+ (WebCore::RenderRegion::logicalWidthForFlowThreadContent):
+ (WebCore):
+ (WebCore::RenderRegion::logicalHeightForFlowThreadContent):
+ (WebCore::RenderRegion::layout):
+ * rendering/RenderRegion.h:
+ (RenderRegion):
+
2012-05-29 Alec Flett <[email protected]>
IndexedDB: Align codes and names for IDB-specific and DOM-specific errors/exceptions
Modified: trunk/Source/WebCore/rendering/RenderFlowThread.cpp (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderFlowThread.cpp 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.cpp 2012-05-29 22:22:42 UTC (rev 118839)
@@ -169,17 +169,9 @@
region->deleteAllRenderBoxRegionInfo();
- LayoutUnit regionLogicalWidth;
- LayoutUnit regionLogicalHeight;
+ LayoutUnit regionLogicalWidth = region->logicalWidthForFlowThreadContent();
+ LayoutUnit regionLogicalHeight = region->logicalHeightForFlowThreadContent();
- if (isHorizontalWritingMode()) {
- regionLogicalWidth = region->contentWidth();
- regionLogicalHeight = region->contentHeight();
- } else {
- regionLogicalWidth = region->contentHeight();
- regionLogicalHeight = region->contentWidth();
- }
-
if (!m_hasValidRegions)
m_hasValidRegions = true;
else {
@@ -199,15 +191,13 @@
RenderRegion* region = *iter;
if (!region->isValid())
continue;
- LayoutRect regionRect;
- if (isHorizontalWritingMode()) {
- regionRect = LayoutRect(style()->direction() == LTR ? ZERO_LAYOUT_UNIT : logicalWidth() - region->contentWidth(), logicalHeight, region->contentWidth(), region->contentHeight());
- logicalHeight += regionRect.height();
- } else {
- regionRect = LayoutRect(logicalHeight, style()->direction() == LTR ? ZERO_LAYOUT_UNIT : logicalWidth() - region->contentHeight(), region->contentWidth(), region->contentHeight());
- logicalHeight += regionRect.width();
- }
- region->setRegionRect(regionRect);
+
+ LayoutUnit regionLogicalWidth = region->logicalWidthForFlowThreadContent();
+ LayoutUnit regionLogicalHeight = region->logicalHeightForFlowThreadContent();
+
+ LayoutRect regionRect(style()->direction() == LTR ? ZERO_LAYOUT_UNIT : logicalWidth() - regionLogicalWidth, logicalHeight, regionLogicalWidth, regionLogicalHeight);
+ region->setRegionRect(isHorizontalWritingMode() ? regionRect : regionRect.transposedRect());
+ logicalHeight += regionLogicalHeight;
}
}
}
@@ -235,7 +225,7 @@
if (!region->isValid())
continue;
ASSERT(!region->needsLayout());
- logicalWidth = max(isHorizontalWritingMode() ? region->contentWidth() : region->contentHeight(), logicalWidth);
+ logicalWidth = max(region->logicalWidthForFlowThreadContent(), logicalWidth);
}
setLogicalWidth(logicalWidth);
@@ -245,7 +235,7 @@
if (!region->isValid())
continue;
- LayoutUnit regionLogicalWidth = isHorizontalWritingMode() ? region->contentWidth() : region->contentHeight();
+ LayoutUnit regionLogicalWidth = region->logicalWidthForFlowThreadContent();
if (regionLogicalWidth != logicalWidth) {
LayoutUnit logicalLeft = style()->direction() == LTR ? ZERO_LAYOUT_UNIT : logicalWidth - regionLogicalWidth;
region->setRenderBoxRegionInfo(this, logicalLeft, regionLogicalWidth, false);
@@ -262,7 +252,7 @@
if (!region->isValid())
continue;
ASSERT(!region->needsLayout());
- logicalHeight += isHorizontalWritingMode() ? region->contentHeight() : region->contentWidth();
+ logicalHeight += region->logicalHeightForFlowThreadContent();
}
setLogicalHeight(logicalHeight);
Modified: trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnBlock.cpp 2012-05-29 22:22:42 UTC (rev 118839)
@@ -137,8 +137,6 @@
if (flowThread() && !firstChild()->isRenderMultiColumnSet()) {
RenderMultiColumnSet* columnSet = new (renderArena()) RenderMultiColumnSet(document(), flowThread());
columnSet->setStyle(RenderStyle::createAnonymousStyleWithDisplay(style(), BLOCK));
- columnSet->setColumnWidthAndCount(columnWidth(), columnCount()); // FIXME: This will eventually vary if we are contained inside regions.
- columnSet->setColumnHeight(columnHeight()); // FIXME: Once we make more than one column set, this will become variable.
RenderBlock::addChild(columnSet, firstChild());
flowThread()->addRegionToThread(columnSet);
}
Modified: trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnBlock.h 2012-05-29 22:22:42 UTC (rev 118839)
@@ -44,6 +44,8 @@
unsigned columnCount() const { return m_columnCount; }
private:
+ virtual bool isRenderMultiColumnBlock() const { return true; }
+
virtual const char* renderName() const;
virtual bool recomputeLogicalWidth();
@@ -64,6 +66,21 @@
LayoutUnit m_columnHeight; // The current column height.
};
+inline RenderMultiColumnBlock* toRenderMultiColumnBlock(RenderObject* object)
+{
+ ASSERT(!object || object->isRenderMultiColumnBlock());
+ return static_cast<RenderMultiColumnBlock*>(object);
+}
+
+inline const RenderMultiColumnBlock* toRenderMultiColumnBlock(const RenderObject* object)
+{
+ ASSERT(!object || object->isRenderMultiColumnBlock());
+ return static_cast<const RenderMultiColumnBlock*>(object);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toRenderMultiColumnBlock(const RenderMultiColumnBlock*);
+
} // namespace WebCore
#endif // RenderMultiColumnBlock_h
Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp 2012-05-29 22:22:42 UTC (rev 118839)
@@ -25,6 +25,7 @@
#include "config.h"
#include "RenderMultiColumnSet.h"
+#include "RenderMultiColumnBlock.h"
namespace WebCore {
@@ -36,6 +37,29 @@
{
}
+void RenderMultiColumnSet::computeLogicalWidth()
+{
+ // Our logical width starts off matching the column block itself.
+ // This width will be fixed up after the flow thread lays out once it is determined exactly how many
+ // columns we ended up holding.
+ // FIXME: When we add regions support, we'll start it off at the width of the multi-column
+ // block in that particular region.
+ setLogicalWidth(parentBox()->contentLogicalWidth());
+
+ RenderMultiColumnBlock* parentBlock = toRenderMultiColumnBlock(parent());
+ setColumnWidthAndCount(parentBlock->columnWidth(), parentBlock->columnCount()); // FIXME: This will eventually vary if we are contained inside regions.
+}
+
+void RenderMultiColumnSet::computeLogicalHeight()
+{
+ // Make sure our column height is up to date.
+ RenderMultiColumnBlock* parentBlock = toRenderMultiColumnBlock(parent());
+ setColumnHeight(parentBlock->columnHeight()); // FIXME: Once we make more than one column set, this will become variable.
+
+ // Our logical height is always just the height of our columns.
+ setLogicalHeight(columnHeight());
+}
+
const char* RenderMultiColumnSet::renderName() const
{
return "RenderMultiColumnSet";
Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.h (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.h 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.h 2012-05-29 22:22:42 UTC (rev 118839)
@@ -51,10 +51,10 @@
LayoutUnit columnWidth() const { return m_columnWidth; }
LayoutUnit columnHeight() const { return m_columnHeight; }
- void setColumnWidthAndCount(unsigned count, LayoutUnit width)
+ void setColumnWidthAndCount(LayoutUnit width, unsigned count)
{
+ m_columnWidth = width;
m_columnCount = count;
- m_columnWidth = width;
}
void setColumnHeight(LayoutUnit height)
{
@@ -62,6 +62,12 @@
}
private:
+ virtual void computeLogicalWidth() OVERRIDE;
+ virtual void computeLogicalHeight() OVERRIDE;
+
+ virtual LayoutUnit logicalWidthForFlowThreadContent() const OVERRIDE { return m_columnWidth; }
+ virtual LayoutUnit logicalHeightForFlowThreadContent() const OVERRIDE { return m_columnHeight; } // FIXME: Will be wrong once we have multiple sets.
+
virtual const char* renderName() const;
unsigned m_columnCount;
Modified: trunk/Source/WebCore/rendering/RenderObject.h (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderObject.h 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2012-05-29 22:22:42 UTC (rev 118839)
@@ -363,6 +363,7 @@
virtual bool isRenderFlowThread() const { return false; }
virtual bool isRenderNamedFlowThread() const { return false; }
+ virtual bool isRenderMultiColumnBlock() const { return false; }
virtual bool isRenderMultiColumnSet() const { return false; }
virtual bool isRenderScrollbarPart() const { return false; }
Modified: trunk/Source/WebCore/rendering/RenderRegion.cpp (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderRegion.cpp 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderRegion.cpp 2012-05-29 22:22:42 UTC (rev 118839)
@@ -53,6 +53,16 @@
{
}
+LayoutUnit RenderRegion::logicalWidthForFlowThreadContent() const
+{
+ return m_flowThread->isHorizontalWritingMode() ? contentWidth() : contentHeight();
+}
+
+LayoutUnit RenderRegion::logicalHeightForFlowThreadContent() const
+{
+ return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
+}
+
LayoutRect RenderRegion::regionOverflowRect() const
{
// FIXME: Would like to just use hasOverflowClip() but we aren't a block yet. When RenderRegion is eliminated and
@@ -147,7 +157,10 @@
{
RenderReplaced::layout();
if (m_flowThread && isValid()) {
- if (regionRect().width() != contentWidth() || regionRect().height() != contentHeight())
+ LayoutRect oldRegionRect(regionRect());
+ if (!isHorizontalWritingMode())
+ oldRegionRect = oldRegionRect.transposedRect();
+ if (oldRegionRect.width() != logicalWidthForFlowThreadContent() || oldRegionRect.height() != logicalHeightForFlowThreadContent())
m_flowThread->invalidateRegions();
}
Modified: trunk/Source/WebCore/rendering/RenderRegion.h (118838 => 118839)
--- trunk/Source/WebCore/rendering/RenderRegion.h 2012-05-29 21:46:29 UTC (rev 118838)
+++ trunk/Source/WebCore/rendering/RenderRegion.h 2012-05-29 22:22:42 UTC (rev 118839)
@@ -95,6 +95,10 @@
void setRegionState(RegionState regionState) { m_regionState = regionState; }
void setDispatchRegionLayoutUpdateEvent(bool value) { m_dispatchRegionLayoutUpdateEvent = value; }
bool shouldDispatchRegionLayoutUpdateEvent() { return m_dispatchRegionLayoutUpdateEvent; }
+
+ virtual LayoutUnit logicalWidthForFlowThreadContent() const;
+ virtual LayoutUnit logicalHeightForFlowThreadContent() const;
+
private:
virtual const char* renderName() const { return "RenderRegion"; }