Modified: trunk/LayoutTests/ChangeLog (107098 => 107099)
--- trunk/LayoutTests/ChangeLog 2012-02-08 17:31:44 UTC (rev 107098)
+++ trunk/LayoutTests/ChangeLog 2012-02-08 17:34:22 UTC (rev 107099)
@@ -1,3 +1,15 @@
+2012-02-08 David Hyatt <hy...@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=78122
+
+ Add a new test that shows the "contains" value in action.
+
+ Reviewed by Adam Roben.
+
+ * fast/line-grid/line-grid-contains-value.html: Added.
+ * platform/mac/fast/line-grid/line-grid-contains-value-expected.png: Added.
+ * platform/mac/fast/line-grid/line-grid-contains-value-expected.txt: Added.
+
2012-02-08 Dan Bernstein <m...@apple.com>
Moved a Mac-specific test to platform/mac.
Added: trunk/LayoutTests/fast/line-grid/line-grid-contains-value.html (0 => 107099)
--- trunk/LayoutTests/fast/line-grid/line-grid-contains-value.html (rev 0)
+++ trunk/LayoutTests/fast/line-grid/line-grid-contains-value.html 2012-02-08 17:34:22 UTC (rev 107099)
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<style>
+.grid { -webkit-line-grid: simple; -webkit-line-grid-snap: baseline;
+ font-size:36px; position:absolute;
+ padding:10px; }
+</style>
+</head>
+<body>
+<div style="left:10px; top:10px; width:600px" class="grid">
+<div style="-webkit-line-grid-snap:contain;font-size:48px">
+This header should be centered in the grid lines.
+</div>
+<div style="font-size:12px">
+This text should snap<br>
+to a 36px font-size grid.<br>
+There should be lots of spacing between these lines.
+
+</div>
+</div>
+
+<div style="left:10px; top:10px; z-index:-1; width:600px" class="grid">
+<div style="font-family:'Ahem'; color:lime">
+xxxxxxxxxxxxxxxxx<br>
+xxxxxxxxxxxxxxxxx<br>
+xxxxxxxxxxxxxxxxx<br>
+xxxxxxxxxxxxxxxxx<br>
+xxxxxxxxxxxxxxxxx<br>
+xxxxxxxxxxxxxxxxx<br>
+xxxxxxxxxxxxxxxxx<br>
+</div>
+</div>
+
+</body>
+</html>
Added: trunk/LayoutTests/platform/mac/fast/line-grid/line-grid-contains-value-expected.txt (0 => 107099)
--- trunk/LayoutTests/platform/mac/fast/line-grid/line-grid-contains-value-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/line-grid/line-grid-contains-value-expected.txt 2012-02-08 17:34:22 UTC (rev 107099)
@@ -0,0 +1,45 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600 layerType: background only
+layer at (10,10) size 620x305
+ RenderBlock (positioned) zI: -1 {DIV} at (10,10) size 620x305
+ RenderBlock {DIV} at (10,10) size 600x285 [color=#00FF00]
+ RenderText {#text} at (0,3) size 612x36
+ text run at (0,3) width 612: "xxxxxxxxxxxxxxxxx"
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {#text} at (0,44) size 612x36
+ text run at (0,44) width 612: "xxxxxxxxxxxxxxxxx"
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {#text} at (0,85) size 612x36
+ text run at (0,85) width 612: "xxxxxxxxxxxxxxxxx"
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {#text} at (0,126) size 612x36
+ text run at (0,126) width 612: "xxxxxxxxxxxxxxxxx"
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {#text} at (0,167) size 612x36
+ text run at (0,167) width 612: "xxxxxxxxxxxxxxxxx"
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {#text} at (0,208) size 612x36
+ text run at (0,208) width 612: "xxxxxxxxxxxxxxxxx"
+ RenderBR {BR} at (0,0) size 0x0
+ RenderText {#text} at (0,249) size 612x36
+ text run at (0,249) width 612: "xxxxxxxxxxxxxxxxx"
+ RenderBR {BR} at (0,0) size 0x0
+layer at (0,0) size 800x600 layerType: foreground only
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+layer at (10,10) size 620x301
+ RenderBlock (positioned) {DIV} at (10,10) size 620x301
+ RenderBlock {DIV} at (10,10) size 600x150
+ RenderText {#text} at (0,13) size 594x137
+ text run at (0,13) width 594: "This header should be centered"
+ text run at (0,95) width 310: "in the grid lines."
+ RenderBlock {DIV} at (10,160) size 600x131
+ RenderText {#text} at (0,35) size 101x14
+ text run at (0,35) width 101: "This text should snap"
+ RenderBR {BR} at (101,46) size 0x0
+ RenderText {#text} at (0,76) size 113x14
+ text run at (0,76) width 113: "to a 36px font-size grid."
+ RenderBR {BR} at (113,87) size 0x0
+ RenderText {#text} at (0,117) size 245x14
+ text run at (0,117) width 245: "There should be lots of spacing between these lines."
Modified: trunk/Source/WebCore/ChangeLog (107098 => 107099)
--- trunk/Source/WebCore/ChangeLog 2012-02-08 17:31:44 UTC (rev 107098)
+++ trunk/Source/WebCore/ChangeLog 2012-02-08 17:34:22 UTC (rev 107099)
@@ -1,3 +1,18 @@
+2012-02-08 David Hyatt <hy...@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=78122
+
+ Add support for the "contains" value for line-grid-snap. This value centers the line box in between the
+ text-top and text-bottom of the minimum number of grid lines that enclose the line box. This is useful for
+ centering headers in a line grid.
+
+ Reviewed by Adam Roben.
+
+ Added a new test in fast/line-grid.
+
+ * rendering/RootInlineBox.cpp:
+ (WebCore::RootInlineBox::lineGridSnapAdjustment):
+
2012-02-08 Cary Clark <carycl...@google.com>
[Skia Mac] Make misspelling underline dots unclipped
Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (107098 => 107099)
--- trunk/Source/WebCore/rendering/RootInlineBox.cpp 2012-02-08 17:31:44 UTC (rev 107098)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp 2012-02-08 17:34:22 UTC (rev 107099)
@@ -330,7 +330,7 @@
{
// If our block doesn't have snapping turned on, do nothing.
// FIXME: Implement bounds snapping.
- if (block()->style()->lineGridSnap() != LineGridSnapBaseline)
+ if (block()->style()->lineGridSnap() == LineGridSnapNone)
return 0;
// Get the current line grid and offset.
@@ -352,33 +352,54 @@
// as established by the line box.
// FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume
// the grid should honor line-box-contain.
- LayoutUnit baselineMultiple = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading();
- if (!baselineMultiple)
+ LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading();
+ if (!gridLineHeight)
return 0;
- LayoutUnit lineGridAscent = lineGrid->style()->fontMetrics().ascent(baselineType());
- LayoutUnit firstBaselinePosition = lineGridBlockOffset + lineGridAscent + lineGridBox->logicalTop();
- LayoutUnit currentBaselinePosition = blockOffset + logicalTop() + delta + block()->style()->fontMetrics().ascent(baselineType());
+ LayoutUnit lineGridFontAscent = lineGrid->style()->fontMetrics().ascent(baselineType());
+ LayoutUnit lineGridFontHeight = lineGridBox->logicalHeight();
+ LayoutUnit firstTextTop = lineGridBlockOffset + lineGridBox->logicalTop();
+ LayoutUnit firstBaselinePosition = firstTextTop + lineGridFontAscent;
+ LayoutUnit currentTextTop = blockOffset + logicalTop() + delta;
+ LayoutUnit currentFontAscent = block()->style()->fontMetrics().ascent(baselineType());
+ LayoutUnit currentBaselinePosition = currentTextTop + currentFontAscent;
+
// If we're paginated, see if we're on a page after the first one. If so, the grid resets on subsequent pages.
// FIXME: If the grid is an ancestor of the pagination establisher, then this is incorrect.
LayoutUnit pageLogicalTop = 0;
if (layoutState->isPaginated() && layoutState->pageLogicalHeight()) {
pageLogicalTop = block()->pageLogicalTopForOffset(logicalTop() + delta);
- if (pageLogicalTop > lineGridBlockOffset + lineGridBox->logicalTop())
- firstBaselinePosition = lineGridAscent + pageLogicalTop + lineGridBox->logicalTop() - lineGrid->borderBefore() - lineGrid->paddingBefore();
+ if (pageLogicalTop > firstTextTop)
+ firstTextTop = pageLogicalTop + lineGridBox->logicalTop() - lineGrid->borderBefore() - lineGrid->paddingBefore();
}
-
+
+ if (block()->style()->lineGridSnap() == LineGridSnapContain) {
+ // Compute the desired offset from the text-top of a grid line.
+ // Look at our height (logicalHeight()).
+ // Look at the total available height. It's going to be (textBottom - textTop) + (n-1)*(multiple with leading)
+ // where n is number of grid lines required to enclose us.
+ if (logicalHeight() <= lineGridFontHeight)
+ firstTextTop += (lineGridFontHeight - logicalHeight()) / 2;
+ else {
+ LayoutUnit numberOfLinesWithLeading = ceilf(static_cast<float>(logicalHeight() - lineGridFontHeight) / gridLineHeight);
+ LayoutUnit totalHeight = lineGridFontHeight + numberOfLinesWithLeading * gridLineHeight;
+ firstTextTop += (totalHeight - logicalHeight()) / 2;
+ }
+ firstBaselinePosition = firstTextTop + currentFontAscent;
+ } else
+ firstBaselinePosition = firstTextTop + lineGridFontAscent;
+
// If we're above the first line, just push to the first line.
if (currentBaselinePosition < firstBaselinePosition)
return delta + firstBaselinePosition - currentBaselinePosition;
// Otherwise we're in the middle of the grid somewhere. Just push to the next line.
LayoutUnit baselineOffset = currentBaselinePosition - firstBaselinePosition;
- LayoutUnit remainder = baselineOffset % baselineMultiple;
+ LayoutUnit remainder = baselineOffset % gridLineHeight;
LayoutUnit result = delta;
if (remainder)
- result += baselineMultiple - remainder;
+ result += gridLineHeight - remainder;
// If we aren't paginated we can return the result.
if (!layoutState->isPaginated() || !layoutState->pageLogicalHeight() || result == delta)