Title: [109267] trunk
Revision
109267
Author
[email protected]
Date
2012-02-29 14:44:33 -0800 (Wed, 29 Feb 2012)

Log Message

Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=79940
<rdar://problem/10080189>
        
Add support in WebKit for an intra-line character grid for Japanese text layout.
        
Patch logicalLeftOffsetForLine and logicalRightOffsetForLine in order to get the
basic edge snapping grid functionality up and running. See all the FIXMEs in the function for
some of the issues that still have to be dealt with for it to really work well.

Reviewed by Dan Bernstein.

Added new tests in fast/line-grid.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::logicalLeftOffsetForLine):
(WebCore::RenderBlock::logicalRightOffsetForLine):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=79940
<rdar://problem/10080189>
        
Add support in WebKit for an intra-line character grid for Japanese text layout.
        
New tests for basic left and right alignment of lines in the presence of
floating and positioned objects as well as objects with margins and borders.

Reviewed by Dan Bernstein.

* fast/line-grid/line-align-left-edges.html: Added.
* fast/line-grid/line-align-right-edges.html: Added.
* platform/mac/fast/line-grid/line-align-left-edges-expected.png: Added.
* platform/mac/fast/line-grid/line-align-left-edges-expected.txt: Added.
* platform/mac/fast/line-grid/line-align-right-edges-expected.png: Added.
* platform/mac/fast/line-grid/line-align-right-edges-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109266 => 109267)


--- trunk/LayoutTests/ChangeLog	2012-02-29 22:43:27 UTC (rev 109266)
+++ trunk/LayoutTests/ChangeLog	2012-02-29 22:44:33 UTC (rev 109267)
@@ -1,3 +1,22 @@
+2012-02-29  David Hyatt  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=79940
+        <rdar://problem/10080189>
+        
+        Add support in WebKit for an intra-line character grid for Japanese text layout.
+        
+        New tests for basic left and right alignment of lines in the presence of
+        floating and positioned objects as well as objects with margins and borders.
+
+        Reviewed by Dan Bernstein.
+
+        * fast/line-grid/line-align-left-edges.html: Added.
+        * fast/line-grid/line-align-right-edges.html: Added.
+        * platform/mac/fast/line-grid/line-align-left-edges-expected.png: Added.
+        * platform/mac/fast/line-grid/line-align-left-edges-expected.txt: Added.
+        * platform/mac/fast/line-grid/line-align-right-edges-expected.png: Added.
+        * platform/mac/fast/line-grid/line-align-right-edges-expected.txt: Added.
+
 2012-02-29  Adam Klein  <[email protected]>
 
         Unreviewed gardening, remove some more stale expectations (mostly mac repaint tests).

Added: trunk/LayoutTests/fast/line-grid/line-align-left-edges.html (0 => 109267)


--- trunk/LayoutTests/fast/line-grid/line-align-left-edges.html	                        (rev 0)
+++ trunk/LayoutTests/fast/line-grid/line-align-left-edges.html	2012-02-29 22:44:33 UTC (rev 109267)
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+<head>
+<title>Left Edge Alignment Test</title>
+</head>
+<body>
+<div style="-webkit-line-grid:grid; font-family:'Ahem'; color:green; -webkit-line-align:edges;line-height:1.25; zoom: 1.5; position:relative">
+X X X X X X X
+<div style="border:2px solid black;margin:25px;">X X X X X X</div>
+<div style="float:left;width:52px;height:52px;background-color:yellow;"></div>X X X X X<br>
+<div style="float:left;width:52px;height:52px;background-color:purple;"></div>X X X X X
+<div style="position:absolute;top:200px;width:200px; left:115px; background-color:#dddddd">X X X</div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/line-grid/line-align-right-edges.html (0 => 109267)


--- trunk/LayoutTests/fast/line-grid/line-align-right-edges.html	                        (rev 0)
+++ trunk/LayoutTests/fast/line-grid/line-align-right-edges.html	2012-02-29 22:44:33 UTC (rev 109267)
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+<head>
+<title>Right Edge Alignment Test</title>
+</head>
+<body>
+<div style="-webkit-line-grid:grid; font-family:'Ahem'; color:green; -webkit-line-align:edges;line-height:1.25; zoom: 1.5; position:relative; text-align:right">
+X X X X X X X
+<div style="border:2px solid black;margin:30px;">X X X X X X</div>
+<div style="float:right;width:52px;height:52px;background-color:yellow;"></div>X X X X X<br>
+<div style="float:right;width:52px;height:52px;background-color:purple;"></div>X X X X X
+<div style="position:absolute;width:200px; top:200px;right:100px; background-color:#dddddd">X X X</div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac/fast/line-grid/line-align-left-edges-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/line-grid/line-align-left-edges-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/line-grid/line-align-left-edges-expected.txt (0 => 109267)


--- trunk/LayoutTests/platform/mac/fast/line-grid/line-align-left-edges-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/line-grid/line-align-left-edges-expected.txt	2012-02-29 22:44:33 UTC (rev 109267)
@@ -0,0 +1,25 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x256
+  RenderBlock {HTML} at (0,0) size 800x256
+    RenderBody {BODY} at (8,8) size 784x200
+layer at (8,8) size 784x200
+  RenderBlock (relative positioned) {DIV} at (0,0) size 784x200 [color=#008000]
+    RenderBlock (anonymous) at (0,0) size 784x30
+      RenderText {#text} at (0,3) size 312x24
+        text run at (0,3) width 312: "X X X X X X X"
+    RenderBlock {DIV} at (37,67) size 710x36 [border: (3px solid #000000)]
+      RenderText {#text} at (11,6) size 264x24
+        text run at (11,6) width 264: "X X X X X X"
+    RenderBlock (floating) {DIV} at (0,140) size 78x78 [bgcolor=#FFFF00]
+    RenderBlock (anonymous) at (0,140) size 784x60
+      RenderText {#text} at (96,3) size 216x24
+        text run at (96,3) width 216: "X X X X X"
+      RenderBR {BR} at (312,3) size 0x24
+      RenderBlock (floating) {DIV} at (96,30) size 78x78 [bgcolor=#800080]
+      RenderText {#text} at (192,33) size 216x24
+        text run at (192,33) width 216: "X X X X X"
+layer at (180,308) size 300x30
+  RenderBlock (positioned) {DIV} at (172,300) size 300x30 [bgcolor=#DDDDDD]
+    RenderText {#text} at (20,3) size 120x24
+      text run at (20,3) width 120: "X X X"

Added: trunk/LayoutTests/platform/mac/fast/line-grid/line-align-right-edges-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/line-grid/line-align-right-edges-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/line-grid/line-align-right-edges-expected.txt (0 => 109267)


--- trunk/LayoutTests/platform/mac/fast/line-grid/line-align-right-edges-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/line-grid/line-align-right-edges-expected.txt	2012-02-29 22:44:33 UTC (rev 109267)
@@ -0,0 +1,25 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x272
+  RenderBlock {HTML} at (0,0) size 800x272
+    RenderBody {BODY} at (8,8) size 784x216
+layer at (8,8) size 784x216
+  RenderBlock (relative positioned) {DIV} at (0,0) size 784x216 [color=#008000]
+    RenderBlock (anonymous) at (0,0) size 784x30
+      RenderText {#text} at (456,3) size 312x24
+        text run at (456,3) width 312: "X X X X X X X"
+    RenderBlock {DIV} at (45,75) size 694x36 [border: (3px solid #000000)]
+      RenderText {#text} at (411,6) size 264x24
+        text run at (411,6) width 264: "X X X X X X"
+    RenderBlock (floating) {DIV} at (690,156) size 78x78 [bgcolor=#FFFF00]
+    RenderBlock (anonymous) at (0,156) size 784x60
+      RenderText {#text} at (456,3) size 216x24
+        text run at (456,3) width 216: "X X X X X"
+      RenderBR {BR} at (672,3) size 0x24
+      RenderBlock (floating) {DIV} at (594,30) size 78x78 [bgcolor=#800080]
+      RenderText {#text} at (360,33) size 216x24
+        text run at (360,33) width 216: "X X X X X"
+layer at (342,308) size 300x30
+  RenderBlock (positioned) {DIV} at (334,300) size 300x30 [bgcolor=#DDDDDD]
+    RenderText {#text} at (170,3) size 120x24
+      text run at (170,3) width 120: "X X X"

Modified: trunk/Source/WebCore/ChangeLog (109266 => 109267)


--- trunk/Source/WebCore/ChangeLog	2012-02-29 22:43:27 UTC (rev 109266)
+++ trunk/Source/WebCore/ChangeLog	2012-02-29 22:44:33 UTC (rev 109267)
@@ -1,3 +1,22 @@
+2012-02-29  David Hyatt  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=79940
+        <rdar://problem/10080189>
+        
+        Add support in WebKit for an intra-line character grid for Japanese text layout.
+        
+        Patch logicalLeftOffsetForLine and logicalRightOffsetForLine in order to get the
+        basic edge snapping grid functionality up and running. See all the FIXMEs in the function for
+        some of the issues that still have to be dealt with for it to really work well.
+
+        Reviewed by Dan Bernstein.
+
+        Added new tests in fast/line-grid.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::logicalLeftOffsetForLine):
+        (WebCore::RenderBlock::logicalRightOffsetForLine):
+
 2012-02-29  Anders Carlsson  <[email protected]>
 
         [Chromium] Some Layout Tests in platform/chromium/rubberbanding and platform/chromium/compositing/rubberbanding are failing

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (109266 => 109267)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-02-29 22:43:27 UTC (rev 109266)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-02-29 22:44:33 UTC (rev 109267)
@@ -3866,6 +3866,36 @@
     if (applyTextIndent && style()->isLeftToRightDirection())
         left += textIndentOffset();
 
+    if (style()->lineAlign() == LineAlignNone)
+        return left;
+    
+    // Push in our left offset so that it is aligned with the character grid.
+    LayoutState* layoutState = view()->layoutState();
+    if (!layoutState)
+        return left;
+
+    RenderBlock* lineGrid = layoutState->lineGrid();
+    if (!lineGrid || lineGrid->style()->writingMode() != style()->writingMode())
+        return left;
+
+    // FIXME: Should letter-spacing apply? This is complicated since it doesn't apply at the edge?
+    float maxCharWidth = lineGrid->style()->font().primaryFont()->maxCharWidth();
+    if (!maxCharWidth)
+        return left;
+
+    LayoutUnit lineGridOffset = lineGrid->isHorizontalWritingMode() ? layoutState->lineGridOffset().width(): layoutState->lineGridOffset().height();
+    LayoutUnit layoutOffset = lineGrid->isHorizontalWritingMode() ? layoutState->layoutOffset().width() : layoutState->layoutOffset().height();
+    
+    // Push in to the nearest character width (truncated so that we pixel snap left).
+    // FIXME: Should be patched when subpixel layout lands, since this calculation doesn't have to pixel snap
+    // any more (https://bugs.webkit.org/show_bug.cgi?id=79946).
+    // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=79945).
+    // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org/show_bug.cgi?id=79942).
+    // FIXME: This doesn't work when the inline position of the object isn't set ahead of time.
+    // FIXME: Dynamic changes to the font or to the inline position need to result in a deep relayout.
+    // (https://bugs.webkit.org/show_bug.cgi?id=79944)
+    float remainder = fmodf(maxCharWidth - fmodf(left + layoutOffset - lineGridOffset, maxCharWidth), maxCharWidth);
+    left += remainder;
     return left;
 }
 
@@ -3885,6 +3915,36 @@
     if (applyTextIndent && !style()->isLeftToRightDirection())
         right -= textIndentOffset();
     
+    if (style()->lineAlign() == LineAlignNone)
+        return right;
+    
+    // Push in our right offset so that it is aligned with the character grid.
+    LayoutState* layoutState = view()->layoutState();
+    if (!layoutState)
+        return right;
+
+    RenderBlock* lineGrid = layoutState->lineGrid();
+    if (!lineGrid || lineGrid->style()->writingMode() != style()->writingMode())
+        return right;
+
+    // FIXME: Should letter-spacing apply? This is complicated since it doesn't apply at the edge?
+    float maxCharWidth = lineGrid->style()->font().primaryFont()->maxCharWidth();
+    if (!maxCharWidth)
+        return right;
+
+    LayoutUnit lineGridOffset = lineGrid->isHorizontalWritingMode() ? layoutState->lineGridOffset().width(): layoutState->lineGridOffset().height();
+    LayoutUnit layoutOffset = lineGrid->isHorizontalWritingMode() ? layoutState->layoutOffset().width() : layoutState->layoutOffset().height();
+    
+    // Push in to the nearest character width (truncated so that we pixel snap right).
+    // FIXME: Should be patched when subpixel layout lands, since this calculation doesn't have to pixel snap
+    // any more (https://bugs.webkit.org/show_bug.cgi?id=79946).
+    // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=79945).
+    // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org/show_bug.cgi?id=79942).
+    // FIXME: This doesn't work when the inline position of the object isn't set ahead of time.
+    // FIXME: Dynamic changes to the font or to the inline position need to result in a deep relayout.
+    // (https://bugs.webkit.org/show_bug.cgi?id=79944)
+    float remainder = fmodf(fmodf(right + layoutOffset - lineGridOffset, maxCharWidth), maxCharWidth);
+    right -= ceilf(remainder);
     return right;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to