| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent; | 1874 bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent; |
| 1875 if (!renderRule) | 1875 if (!renderRule) |
| 1876 return; | 1876 return; |
| 1877 | 1877 |
| 1878 ColumnInfo* colInfo = columnInfo(); | 1878 ColumnInfo* colInfo = columnInfo(); |
| 1879 unsigned colCount = columnCount(colInfo); | 1879 unsigned colCount = columnCount(colInfo); |
| 1880 | 1880 |
| 1881 bool antialias = shouldAntialiasLines(paintInfo.context); | 1881 bool antialias = shouldAntialiasLines(paintInfo.context); |
| 1882 | 1882 |
| 1883 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { | 1883 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { |
| 1884 bool leftToRight = style()->isLeftToRightDirection() ^ colInfo->progress
ionIsReversed(); | 1884 bool leftToRight = style()->isLeftToRightDirection(); |
| 1885 LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentL
ogicalWidth(); | 1885 LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentL
ogicalWidth(); |
| 1886 LayoutUnit ruleAdd = logicalLeftOffsetForContent(); | 1886 LayoutUnit ruleAdd = logicalLeftOffsetForContent(); |
| 1887 LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogical
Width(); | 1887 LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogical
Width(); |
| 1888 LayoutUnit inlineDirectionSize = colInfo->desiredColumnWidth(); | 1888 LayoutUnit inlineDirectionSize = colInfo->desiredColumnWidth(); |
| 1889 BoxSide boxSide = isHorizontalWritingMode() | 1889 BoxSide boxSide = isHorizontalWritingMode() |
| 1890 ? leftToRight ? BSLeft : BSRight | 1890 ? leftToRight ? BSLeft : BSRight |
| 1891 : leftToRight ? BSTop : BSBottom; | 1891 : leftToRight ? BSTop : BSBottom; |
| 1892 | 1892 |
| 1893 for (unsigned i = 0; i < colCount; i++) { | 1893 for (unsigned i = 0; i < colCount; i++) { |
| 1894 // Move to the next position. | 1894 // Move to the next position. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1906 LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ru
leThickness : ruleLeft + contentWidth(); | 1906 LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ru
leThickness : ruleLeft + contentWidth(); |
| 1907 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y()
+ borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThicknes
s / 2 + ruleAdd; | 1907 LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y()
+ borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThicknes
s / 2 + ruleAdd; |
| 1908 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + co
ntentHeight() : ruleTop + ruleThickness; | 1908 LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + co
ntentHeight() : ruleTop + ruleThickness; |
| 1909 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule
Left, ruleTop, ruleRight, ruleBottom); | 1909 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule
Left, ruleTop, ruleRight, ruleBottom); |
| 1910 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(),
pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY
(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); | 1910 drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(),
pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY
(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); |
| 1911 } | 1911 } |
| 1912 | 1912 |
| 1913 ruleLogicalLeft = currLogicalLeftOffset; | 1913 ruleLogicalLeft = currLogicalLeftOffset; |
| 1914 } | 1914 } |
| 1915 } else { | 1915 } else { |
| 1916 bool topToBottom = !style()->isFlippedBlocksWritingMode() ^ colInfo->pro
gressionIsReversed(); | 1916 bool topToBottom = !style()->isFlippedBlocksWritingMode(); |
| 1917 LayoutUnit ruleLeft = isHorizontalWritingMode() | 1917 LayoutUnit ruleLeft = isHorizontalWritingMode() |
| 1918 ? borderLeft() + paddingLeft() | 1918 ? borderLeft() + paddingLeft() |
| 1919 : colGap / 2 - colGap - ruleThickness / 2 + (!colInfo->progressionIs
Reversed() ? borderBefore() + paddingBefore() : borderAfter() + paddingAfter()); | 1919 : colGap / 2 - colGap - ruleThickness / 2 + borderBefore() + padding
Before(); |
| 1920 LayoutUnit ruleWidth = isHorizontalWritingMode() ? contentWidth() : rule
Thickness; | 1920 LayoutUnit ruleWidth = isHorizontalWritingMode() ? contentWidth() : rule
Thickness; |
| 1921 LayoutUnit ruleTop = isHorizontalWritingMode() | 1921 LayoutUnit ruleTop = isHorizontalWritingMode() |
| 1922 ? colGap / 2 - colGap - ruleThickness / 2 + (!colInfo->progressionIs
Reversed() ? borderBefore() + paddingBefore() : borderAfter() + paddingAfter()) | 1922 ? colGap / 2 - colGap - ruleThickness / 2 + borderBefore() + padding
Before() |
| 1923 : borderStart() + paddingStart(); | 1923 : borderStart() + paddingStart(); |
| 1924 LayoutUnit ruleHeight = isHorizontalWritingMode() ? ruleThickness : cont
entHeight(); | 1924 LayoutUnit ruleHeight = isHorizontalWritingMode() ? ruleThickness : cont
entHeight(); |
| 1925 LayoutRect ruleRect(ruleLeft, ruleTop, ruleWidth, ruleHeight); | 1925 LayoutRect ruleRect(ruleLeft, ruleTop, ruleWidth, ruleHeight); |
| 1926 | 1926 |
| 1927 if (!topToBottom) { | 1927 if (!topToBottom) { |
| 1928 if (isHorizontalWritingMode()) | 1928 if (isHorizontalWritingMode()) |
| 1929 ruleRect.setY(height() - ruleRect.maxY()); | 1929 ruleRect.setY(height() - ruleRect.maxY()); |
| 1930 else | 1930 else |
| 1931 ruleRect.setX(width() - ruleRect.maxX()); | 1931 ruleRect.setX(width() - ruleRect.maxX()); |
| 1932 } | 1932 } |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3280 { | 3280 { |
| 3281 if (document().regionBasedColumnsEnabled()) | 3281 if (document().regionBasedColumnsEnabled()) |
| 3282 return; | 3282 return; |
| 3283 | 3283 |
| 3284 // Calculate our column width and column count. | 3284 // Calculate our column width and column count. |
| 3285 // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibli
ng4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744 | 3285 // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibli
ng4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744 |
| 3286 unsigned desiredColumnCount = 1; | 3286 unsigned desiredColumnCount = 1; |
| 3287 LayoutUnit desiredColumnWidth = contentLogicalWidth(); | 3287 LayoutUnit desiredColumnWidth = contentLogicalWidth(); |
| 3288 | 3288 |
| 3289 // For now, we don't support multi-column layouts when printing, since we ha
ve to do a lot of work for proper pagination. | 3289 // For now, we don't support multi-column layouts when printing, since we ha
ve to do a lot of work for proper pagination. |
| 3290 if (document().paginated() || (style()->hasAutoColumnCount() && style()->has
AutoColumnWidth()) || !style()->hasInlineColumnAxis()) { | 3290 if (document().paginated() || !style()->specifiesColumns()) { |
| 3291 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth); | 3291 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth); |
| 3292 return; | 3292 return; |
| 3293 } | 3293 } |
| 3294 | 3294 |
| 3295 LayoutUnit availWidth = desiredColumnWidth; | 3295 LayoutUnit availWidth = desiredColumnWidth; |
| 3296 LayoutUnit colGap = columnGap(); | 3296 LayoutUnit colGap = columnGap(); |
| 3297 LayoutUnit colWidth = max<LayoutUnit>(1, LayoutUnit(style()->columnWidth()))
; | 3297 LayoutUnit colWidth = max<LayoutUnit>(1, LayoutUnit(style()->columnWidth()))
; |
| 3298 int colCount = max<int>(1, style()->columnCount()); | 3298 int colCount = max<int>(1, style()->columnCount()); |
| 3299 | 3299 |
| 3300 if (style()->hasAutoColumnWidth() && !style()->hasAutoColumnCount()) { | 3300 if (style()->hasAutoColumnWidth() && !style()->hasAutoColumnCount()) { |
| 3301 desiredColumnCount = colCount; | 3301 desiredColumnCount = colCount; |
| 3302 desiredColumnWidth = max<LayoutUnit>(0, (availWidth - ((desiredColumnCou
nt - 1) * colGap)) / desiredColumnCount); | 3302 desiredColumnWidth = max<LayoutUnit>(0, (availWidth - ((desiredColumnCou
nt - 1) * colGap)) / desiredColumnCount); |
| 3303 } else if (!style()->hasAutoColumnWidth() && style()->hasAutoColumnCount())
{ | 3303 } else if (!style()->hasAutoColumnWidth() && style()->hasAutoColumnCount())
{ |
| 3304 desiredColumnCount = max<LayoutUnit>(1, (availWidth + colGap) / (colWidt
h + colGap)); | 3304 desiredColumnCount = max<LayoutUnit>(1, (availWidth + colGap) / (colWidt
h + colGap)); |
| 3305 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG
ap; | 3305 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG
ap; |
| 3306 } else { | 3306 } else { |
| 3307 desiredColumnCount = max<LayoutUnit>(min<LayoutUnit>(colCount, (availWid
th + colGap) / (colWidth + colGap)), 1); | 3307 desiredColumnCount = max<LayoutUnit>(min<LayoutUnit>(colCount, (availWid
th + colGap) / (colWidth + colGap)), 1); |
| 3308 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG
ap; | 3308 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colG
ap; |
| 3309 } | 3309 } |
| 3310 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth); | 3310 setDesiredColumnCountAndWidth(desiredColumnCount, desiredColumnWidth); |
| 3311 } | 3311 } |
| 3312 | 3312 |
| 3313 bool RenderBlock::requiresColumns(int desiredColumnCount) const | 3313 bool RenderBlock::requiresColumns(int desiredColumnCount) const |
| 3314 { | 3314 { |
| 3315 // Paged overflow is treated as multicol here, unless this element was the o
ne that got its | 3315 // Paged overflow is treated as multicol here, unless this element was the o
ne that got its |
| 3316 // overflow propagated to the viewport. | 3316 // overflow propagated to the viewport. |
| 3317 bool isPaginated = style()->isOverflowPaged() && node() != document().viewpo
rtDefiningElement(); | 3317 bool isPaginated = style()->isOverflowPaged() && node() != document().viewpo
rtDefiningElement(); |
| 3318 | 3318 |
| 3319 return firstChild() | 3319 return firstChild() |
| 3320 && (desiredColumnCount != 1 || !style()->hasAutoColumnWidth() || !style(
)->hasInlineColumnAxis() || isPaginated) | 3320 && (desiredColumnCount != 1 || !style()->hasAutoColumnWidth() || isPagin
ated) |
| 3321 && !firstChild()->isAnonymousColumnsBlock() | 3321 && !firstChild()->isAnonymousColumnsBlock() |
| 3322 && !firstChild()->isAnonymousColumnSpanBlock(); | 3322 && !firstChild()->isAnonymousColumnSpanBlock(); |
| 3323 } | 3323 } |
| 3324 | 3324 |
| 3325 void RenderBlock::setDesiredColumnCountAndWidth(int count, LayoutUnit width) | 3325 void RenderBlock::setDesiredColumnCountAndWidth(int count, LayoutUnit width) |
| 3326 { | 3326 { |
| 3327 bool destroyColumns = !requiresColumns(count); | 3327 bool destroyColumns = !requiresColumns(count); |
| 3328 if (destroyColumns) { | 3328 if (destroyColumns) { |
| 3329 if (hasColumns()) { | 3329 if (hasColumns()) { |
| 3330 gColumnInfoMap->take(this); | 3330 gColumnInfoMap->take(this); |
| 3331 setHasColumns(false); | 3331 setHasColumns(false); |
| 3332 } | 3332 } |
| 3333 } else { | 3333 } else { |
| 3334 ColumnInfo* info; | 3334 ColumnInfo* info; |
| 3335 if (hasColumns()) | 3335 if (hasColumns()) |
| 3336 info = gColumnInfoMap->get(this); | 3336 info = gColumnInfoMap->get(this); |
| 3337 else { | 3337 else { |
| 3338 if (!gColumnInfoMap) | 3338 if (!gColumnInfoMap) |
| 3339 gColumnInfoMap = new ColumnInfoMap; | 3339 gColumnInfoMap = new ColumnInfoMap; |
| 3340 info = new ColumnInfo; | 3340 info = new ColumnInfo; |
| 3341 gColumnInfoMap->add(this, adoptPtr(info)); | 3341 gColumnInfoMap->add(this, adoptPtr(info)); |
| 3342 setHasColumns(true); | 3342 setHasColumns(true); |
| 3343 } | 3343 } |
| 3344 info->setDesiredColumnWidth(width); | 3344 info->setDesiredColumnWidth(width); |
| 3345 if (style()->isOverflowPaged()) { | 3345 if (style()->isOverflowPaged()) { |
| 3346 info->setDesiredColumnCount(1); |
| 3346 info->setProgressionAxis(style()->hasInlinePaginationAxis() ? Column
Info::InlineAxis : ColumnInfo::BlockAxis); | 3347 info->setProgressionAxis(style()->hasInlinePaginationAxis() ? Column
Info::InlineAxis : ColumnInfo::BlockAxis); |
| 3347 } else { | 3348 } else { |
| 3348 info->setDesiredColumnCount(count); | 3349 info->setDesiredColumnCount(count); |
| 3349 info->setProgressionAxis(style()->hasInlineColumnAxis() ? ColumnInfo
::InlineAxis : ColumnInfo::BlockAxis); | 3350 info->setProgressionAxis(ColumnInfo::InlineAxis); |
| 3350 info->setProgressionIsReversed(style()->columnProgression() == Rever
seColumnProgression); | |
| 3351 } | 3351 } |
| 3352 } | 3352 } |
| 3353 } | 3353 } |
| 3354 | 3354 |
| 3355 LayoutUnit RenderBlock::desiredColumnWidth() const | 3355 LayoutUnit RenderBlock::desiredColumnWidth() const |
| 3356 { | 3356 { |
| 3357 if (!hasColumns()) | 3357 if (!hasColumns()) |
| 3358 return contentLogicalWidth(); | 3358 return contentLogicalWidth(); |
| 3359 return gColumnInfoMap->get(this)->desiredColumnWidth(); | 3359 return gColumnInfoMap->get(this)->desiredColumnWidth(); |
| 3360 } | 3360 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3377 { | 3377 { |
| 3378 ASSERT(hasColumns() && gColumnInfoMap->get(this) == colInfo); | 3378 ASSERT(hasColumns() && gColumnInfoMap->get(this) == colInfo); |
| 3379 | 3379 |
| 3380 // Compute the appropriate rect based off our information. | 3380 // Compute the appropriate rect based off our information. |
| 3381 LayoutUnit colLogicalWidth = colInfo->desiredColumnWidth(); | 3381 LayoutUnit colLogicalWidth = colInfo->desiredColumnWidth(); |
| 3382 LayoutUnit colLogicalHeight = colInfo->columnHeight(); | 3382 LayoutUnit colLogicalHeight = colInfo->columnHeight(); |
| 3383 LayoutUnit colLogicalTop = borderBefore() + paddingBefore(); | 3383 LayoutUnit colLogicalTop = borderBefore() + paddingBefore(); |
| 3384 LayoutUnit colLogicalLeft = logicalLeftOffsetForContent(); | 3384 LayoutUnit colLogicalLeft = logicalLeftOffsetForContent(); |
| 3385 LayoutUnit colGap = columnGap(); | 3385 LayoutUnit colGap = columnGap(); |
| 3386 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { | 3386 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { |
| 3387 if (style()->isLeftToRightDirection() ^ colInfo->progressionIsReversed()
) | 3387 if (style()->isLeftToRightDirection()) |
| 3388 colLogicalLeft += index * (colLogicalWidth + colGap); | 3388 colLogicalLeft += index * (colLogicalWidth + colGap); |
| 3389 else | 3389 else |
| 3390 colLogicalLeft += contentLogicalWidth() - colLogicalWidth - index *
(colLogicalWidth + colGap); | 3390 colLogicalLeft += contentLogicalWidth() - colLogicalWidth - index *
(colLogicalWidth + colGap); |
| 3391 } else { | 3391 } else { |
| 3392 if (!colInfo->progressionIsReversed()) | 3392 colLogicalTop += index * (colLogicalHeight + colGap); |
| 3393 colLogicalTop += index * (colLogicalHeight + colGap); | |
| 3394 else | |
| 3395 colLogicalTop += contentLogicalHeight() - colLogicalHeight - index *
(colLogicalHeight + colGap); | |
| 3396 } | 3393 } |
| 3397 | 3394 |
| 3398 if (isHorizontalWritingMode()) | 3395 if (isHorizontalWritingMode()) |
| 3399 return LayoutRect(colLogicalLeft, colLogicalTop, colLogicalWidth, colLog
icalHeight); | 3396 return LayoutRect(colLogicalLeft, colLogicalTop, colLogicalWidth, colLog
icalHeight); |
| 3400 return LayoutRect(colLogicalTop, colLogicalLeft, colLogicalHeight, colLogica
lWidth); | 3397 return LayoutRect(colLogicalTop, colLogicalLeft, colLogicalHeight, colLogica
lWidth); |
| 3401 } | 3398 } |
| 3402 | 3399 |
| 3403 void RenderBlock::adjustPointToColumnContents(LayoutPoint& point) const | 3400 void RenderBlock::adjustPointToColumnContents(LayoutPoint& point) const |
| 3404 { | 3401 { |
| 3405 // Just bail if we have no columns. | 3402 // Just bail if we have no columns. |
| (...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5025 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 5022 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
| 5026 { | 5023 { |
| 5027 showRenderObject(); | 5024 showRenderObject(); |
| 5028 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 5025 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 5029 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 5026 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 5030 } | 5027 } |
| 5031 | 5028 |
| 5032 #endif | 5029 #endif |
| 5033 | 5030 |
| 5034 } // namespace WebCore | 5031 } // namespace WebCore |
| OLD | NEW |