summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderMultiColumnSet.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-22 13:36:28 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-22 13:36:28 +0200
commitc311cf639cc1d6570d67b0a80a8ba04dc992a658 (patch)
tree6e16fefc7ece11ce4ec1e475a58a537a7acebaf8 /Source/WebCore/rendering/RenderMultiColumnSet.cpp
parent5ef7c8a6a70875d4430752d146bdcb069605d71d (diff)
downloadqtwebkit-c311cf639cc1d6570d67b0a80a8ba04dc992a658.tar.gz
Imported WebKit commit 35255d8c2fd37ba4359e75fe0ebe6aec87687f9c (http://svn.webkit.org/repository/webkit/trunk@126284)
New snapshot that includes MSVC 64-bit build fix
Diffstat (limited to 'Source/WebCore/rendering/RenderMultiColumnSet.cpp')
-rw-r--r--Source/WebCore/rendering/RenderMultiColumnSet.cpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/Source/WebCore/rendering/RenderMultiColumnSet.cpp b/Source/WebCore/rendering/RenderMultiColumnSet.cpp
index b25222415..3ac55cc9e 100644
--- a/Source/WebCore/rendering/RenderMultiColumnSet.cpp
+++ b/Source/WebCore/rendering/RenderMultiColumnSet.cpp
@@ -24,6 +24,8 @@
*/
#include "config.h"
+#include "PaintInfo.h"
+#include "RenderMultiColumnFlowThread.h"
#include "RenderMultiColumnSet.h"
#include "RenderMultiColumnBlock.h"
@@ -60,6 +62,106 @@ void RenderMultiColumnSet::computeLogicalHeight()
setLogicalHeight(columnHeight());
}
+LayoutUnit RenderMultiColumnSet::columnGap() const
+{
+ if (style()->hasNormalColumnGap())
+ return style()->fontDescription().computedPixelSize(); // "1em" is recommended as the normal gap setting. Matches <p> margins.
+ return static_cast<int>(style()->columnGap());
+}
+
+LayoutRect RenderMultiColumnSet::columnRectAt(unsigned index) const
+{
+ LayoutUnit colLogicalWidth = columnWidth();
+ LayoutUnit colLogicalHeight = columnHeight();
+ LayoutUnit colLogicalTop = borderBefore() + paddingBefore();
+ LayoutUnit colLogicalLeft = borderAndPaddingLogicalLeft();
+ int colGap = columnGap();
+ if (style()->isLeftToRightDirection())
+ colLogicalLeft += index * (colLogicalWidth + colGap);
+ else
+ colLogicalLeft += contentLogicalWidth() - colLogicalWidth - index * (colLogicalWidth + colGap);
+
+ if (isHorizontalWritingMode())
+ return LayoutRect(colLogicalLeft, colLogicalTop, colLogicalWidth, colLogicalHeight);
+ return LayoutRect(colLogicalTop, colLogicalLeft, colLogicalHeight, colLogicalWidth);
+}
+
+void RenderMultiColumnSet::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ // FIXME: RenderRegions are replaced elements right now and so they only paint in the foreground phase.
+ // Columns should technically respect phases and allow for background/float/foreground overlap etc., just like
+ // RenderBlocks do. We can't correct this, however, until RenderRegions are changed to actually be
+ // RenderBlocks. Note this is a pretty minor issue, since the old column implementation clipped columns
+ // anyway, thus making it impossible for them to overlap one another. It's also really unlikely that the columns
+ // would overlap another block.
+ setRegionObjectsRegionStyle();
+ paintColumnRules(paintInfo, paintOffset);
+ paintColumnContents(paintInfo, paintOffset);
+ restoreRegionObjectsOriginalStyle();
+}
+
+void RenderMultiColumnSet::paintColumnRules(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ if (paintInfo.context->paintingDisabled())
+ return;
+
+ RenderStyle* blockStyle = toRenderMultiColumnBlock(parent())->style();
+ const Color& ruleColor = blockStyle->visitedDependentColor(CSSPropertyWebkitColumnRuleColor);
+ bool ruleTransparent = blockStyle->columnRuleIsTransparent();
+ EBorderStyle ruleStyle = blockStyle->columnRuleStyle();
+ LayoutUnit ruleThickness = blockStyle->columnRuleWidth();
+ LayoutUnit colGap = columnGap();
+ bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent && ruleThickness <= colGap;
+ if (!renderRule)
+ return;
+
+ unsigned colCount = columnCount();
+
+ bool antialias = shouldAntialiasLines(paintInfo.context);
+
+ bool leftToRight = style()->isLeftToRightDirection();
+ LayoutUnit currLogicalLeftOffset = leftToRight ? ZERO_LAYOUT_UNIT : contentLogicalWidth();
+ LayoutUnit ruleAdd = borderAndPaddingLogicalLeft();
+ LayoutUnit ruleLogicalLeft = leftToRight ? ZERO_LAYOUT_UNIT : contentLogicalWidth();
+ LayoutUnit inlineDirectionSize = columnWidth();
+ BoxSide boxSide = isHorizontalWritingMode()
+ ? leftToRight ? BSLeft : BSRight
+ : leftToRight ? BSTop : BSBottom;
+
+ for (unsigned i = 0; i < colCount; i++) {
+ // Move to the next position.
+ if (leftToRight) {
+ ruleLogicalLeft += inlineDirectionSize + colGap / 2;
+ currLogicalLeftOffset += inlineDirectionSize + colGap;
+ } else {
+ ruleLogicalLeft -= (inlineDirectionSize + colGap / 2);
+ currLogicalLeftOffset -= (inlineDirectionSize + colGap);
+ }
+
+ // Now paint the column rule.
+ if (i < colCount - 1) {
+ LayoutUnit ruleLeft = isHorizontalWritingMode() ? paintOffset.x() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd : paintOffset.x() + borderLeft() + paddingLeft();
+ LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ruleThickness : ruleLeft + contentWidth();
+ LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y() + borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd;
+ LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + contentHeight() : ruleTop + ruleThickness;
+ IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(ruleLeft, ruleTop, ruleRight, ruleBottom);
+ drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias);
+ }
+
+ ruleLogicalLeft = currLogicalLeftOffset;
+ }
+}
+
+void RenderMultiColumnSet::paintColumnContents(PaintInfo& /* paintInfo */, const LayoutPoint& /* paintOffset */)
+{
+ // For each rectangle, set it as the region rectangle and then let flow thread painting do the rest.
+ // We make multiple calls to paintIntoRegion, changing the rectangles each time.
+ if (!columnCount())
+ return;
+
+ // FIXME: Implement.
+}
+
const char* RenderMultiColumnSet::renderName() const
{
return "RenderMultiColumnSet";