[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

adele at apple.com adele at apple.com
Wed Apr 7 23:41:55 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 4de4f2960cafce04c47e00ea19d8951646a9f1bc
Author: adele at apple.com <adele at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Nov 14 20:55:09 2009 +0000

    WebCore: Fix for <rdar://problem/6946165> Would like to be able to specify the number of visible lines when using -webkit-line-clamp
    
    Reviewed by Dan Bernstein.
    
    Test: fast/overflow/line-clamp.html
    
    * css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Updated to handle different types of values.
    * css/CSSParser.cpp: (WebCore::CSSParser::parseValue): ditto.
    * css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applyProperty): ditto.
    
    * rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::layoutVerticalBox):
    Use the line count value if available.  Otherwise, convert the percentage to the line count, as we did before.  Also,
    if there is anchor as the last child box, still allow adding the ellipsis.
    
    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::scrollByRecursively): Call isNone on the LineClampValue to see if the line-clamp property has been set.
    (WebCore::RenderLayer::scrollRectToVisible): ditto.
    
    * WebCore.xcodeproj/project.pbxproj: Added LineClampValue.h
    * rendering/style/LineClampValue.h: Added.
    (WebCore::LineClampValue::LineClampValue):
    (WebCore::LineClampValue::value):
    (WebCore::LineClampValue::isPercentage):
    (WebCore::LineClampValue::isNone):
    (WebCore::LineClampValue::operator==):
    (WebCore::LineClampValue::operator!=):
    * rendering/style/RenderStyleConstants.h: (WebCore::): Define ELineClampType enum for percentage or line count.
    
    * rendering/style/RenderStyle.h: Use LineClampValue.
    (WebCore::InheritedFlags::lineClamp):
    (WebCore::InheritedFlags::setLineClamp):
    (WebCore::InheritedFlags::initialLineClamp):
    * rendering/style/StyleRareNonInheritedData.h:
    
    LayoutTests: Test for <rdar://problem/6946165> Would like to be able to specify the number of visible lines when using -webkit-line-clamp
    
    Reviewed by Dan Bernstein.
    
    * fast/overflow/line-clamp.html: Added.
    * platform/mac/fast/overflow/line-clamp-expected.checksum: Added.
    * platform/mac/fast/overflow/line-clamp-expected.png: Added.
    * platform/mac/fast/overflow/line-clamp-expected.txt: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50998 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1f1b590..d8854fa 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-14  Adele Peterson  <adele at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Test for <rdar://problem/6946165> Would like to be able to specify the number of visible lines when using -webkit-line-clamp
+
+        * fast/overflow/line-clamp.html: Added.
+        * platform/mac/fast/overflow/line-clamp-expected.checksum: Added.
+        * platform/mac/fast/overflow/line-clamp-expected.png: Added.
+        * platform/mac/fast/overflow/line-clamp-expected.txt: Added.
+
 2009-11-14  Kent Tamura  <tkent at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/overflow/line-clamp.html b/LayoutTests/fast/overflow/line-clamp.html
new file mode 100644
index 0000000..d16540d
--- /dev/null
+++ b/LayoutTests/fast/overflow/line-clamp.html
@@ -0,0 +1,46 @@
+<html>
+    <head>
+        <style>
+        div {
+            display: -webkit-inline-box;
+            width: 100px;
+            -webkit-box-orient: vertical;
+            overflow: hidden; 
+            border: solid thin grey; 
+        }
+        </style>
+    </head>
+    <body>
+        This tests the -webkit-line-clamp property<br><br>
+        <div style="-webkit-line-clamp: 50%;">
+            50% truncation.  This is an example of ellipsis-truncation of multi-line text.<a href="#">More</a>
+        </div>
+        <div style="-webkit-line-clamp: 0%;">
+            0% truncation.  This does the most truncation possible, truncating to 1 line.<a href="#">More</a>
+        </div>
+        <div style="-webkit-line-clamp: 2;">
+            2 lines.  This is an example of ellipsis-truncation of multi-line text.<a href="#">More</a>
+        </div>
+        <div style="-webkit-line-clamp: 0%; -webkit-line-clamp: 3;">
+            Backwards compatible truncation.  3 lines on the latest version of WebKit.  1 line on older versions of WebKit.<a href="#">More</a>
+        </div>
+        <div style="-webkit-line-clamp: 30%;">
+            30% truncation.  No link at the end.  This is an example of ellipsis-truncation of multi-line text.
+        </div>
+        <div style="-webkit-line-clamp: 3">
+            3 lines.  No link at the end.  This is an example of ellipsis-truncation of multi-line text.
+        </div>
+        <div style="-webkit-line-clamp: 0;">
+            0 lines.  This is an invalid value for -webkit-line-clamp.
+        </div>
+        <div style="-webkit-line-clamp: -1;">
+            -1 lines.  This is an invalid value for -webkit-line-clamp.
+        </div>
+        <div style="-webkit-line-clamp: -1%;">
+            -1%.  This is an invalid value for -webkit-line-clamp.
+        </div>
+        <div style="-webkit-line-clamp: 150%;">
+            150% truncation.  This does the least truncation possible, truncating nothing.
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.checksum b/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.checksum
new file mode 100644
index 0000000..a626c9b
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.checksum
@@ -0,0 +1 @@
+f486f919806694b3c879ed875cde448d
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.png b/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.png
new file mode 100644
index 0000000..07d125b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.txt b/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.txt
new file mode 100644
index 0000000..11232ad
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/overflow/line-clamp-expected.txt
@@ -0,0 +1,155 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderText {#text} at (0,0) size 262x18
+        text run at (0,0) width 262: "This tests the -webkit-line-clamp property"
+      RenderBR {BR} at (262,14) size 0x0
+      RenderBR {BR} at (0,18) size 0x18
+      RenderText {#text} at (102,96) size 4x18
+        text run at (102,96) width 4: " "
+      RenderText {#text} at (208,96) size 4x18
+        text run at (208,96) width 4: " "
+      RenderText {#text} at (314,96) size 4x18
+        text run at (314,96) width 4: " "
+      RenderText {#text} at (420,96) size 4x18
+        text run at (420,96) width 4: " "
+      RenderText {#text} at (526,96) size 4x18
+        text run at (526,96) width 4: " "
+      RenderText {#text} at (632,96) size 4x18
+        text run at (632,96) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (102,224) size 4x18
+        text run at (102,224) width 4: " "
+      RenderText {#text} at (208,224) size 4x18
+        text run at (208,224) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+layer at (8,44) size 102x74 clip at (9,45) size 100x72 scrollHeight 126
+  RenderFlexibleBox {DIV} at (0,36) size 102x74 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x72
+      RenderText {#text} at (0,0) size 100x126
+        text run at (0,0) width 100: "50% truncation."
+        text run at (0,18) width 61: "This is an"
+        text run at (0,36) width 70: "example of"
+        text run at (0,54) width 48: "ellipsis-"
+        text run at (0,72) width 80: "truncation of"
+        text run at (0,90) width 60: "multi-line"
+        text run at (0,108) width 27: "text."
+      RenderInline {A} at (0,0) size 34x18 [color=#0000EE]
+        RenderText {#text} at (27,108) size 34x18
+          text run at (27,108) width 34: "More"
+      RenderText {#text} at (0,0) size 0x0
+layer at (114,98) size 102x20 clip at (115,99) size 100x18 scrollHeight 108
+  RenderFlexibleBox {DIV} at (106,90) size 102x20 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x18
+      RenderText {#text} at (0,0) size 97x108
+        text run at (0,0) width 92: "0% truncation."
+        text run at (0,18) width 84: "This does the"
+        text run at (0,36) width 97: "most truncation"
+        text run at (0,54) width 55: "possible,"
+        text run at (0,72) width 91: "truncating to 1"
+        text run at (0,90) width 27: "line."
+      RenderInline {A} at (0,0) size 34x18 [color=#0000EE]
+        RenderText {#text} at (27,90) size 34x18
+          text run at (27,90) width 34: "More"
+      RenderText {#text} at (0,0) size 0x0
+layer at (220,80) size 102x38 clip at (221,81) size 100x36 scrollHeight 108
+  RenderFlexibleBox {DIV} at (212,72) size 102x38 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x36
+      RenderText {#text} at (0,0) size 91x108
+        text run at (0,0) width 49: "2 lines. "
+        text run at (49,0) width 42: "This is"
+        text run at (0,18) width 89: "an example of"
+        text run at (0,36) width 48: "ellipsis-"
+        text run at (0,54) width 80: "truncation of"
+        text run at (0,72) width 60: "multi-line"
+        text run at (0,90) width 27: "text."
+      RenderInline {A} at (0,0) size 34x18 [color=#0000EE]
+        RenderText {#text} at (27,90) size 34x18
+          text run at (27,90) width 34: "More"
+      RenderText {#text} at (0,0) size 0x0
+layer at (326,62) size 102x56 clip at (327,63) size 100x54 scrollHeight 162
+  RenderFlexibleBox {DIV} at (318,54) size 102x56 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x54
+      RenderText {#text} at (0,0) size 99x162
+        text run at (0,0) width 71: "Backwards"
+        text run at (0,18) width 69: "compatible"
+        text run at (0,36) width 71: "truncation. "
+        text run at (71,36) width 8: "3"
+        text run at (0,54) width 72: "lines on the"
+        text run at (0,72) width 99: "latest version of"
+        text run at (0,90) width 58: "WebKit. "
+        text run at (58,90) width 35: "1 line"
+        text run at (0,108) width 52: "on older"
+        text run at (0,126) width 69: "versions of"
+        text run at (0,144) width 54: "WebKit."
+      RenderInline {A} at (0,0) size 34x18 [color=#0000EE]
+        RenderText {#text} at (54,144) size 34x18
+          text run at (54,144) width 34: "More"
+      RenderText {#text} at (0,0) size 0x0
+layer at (432,80) size 102x38 clip at (433,81) size 100x36 scrollHeight 126
+  RenderFlexibleBox {DIV} at (424,72) size 102x38 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x36
+      RenderText {#text} at (0,0) size 100x126
+        text run at (0,0) width 100: "30% truncation."
+        text run at (0,18) width 86: "No link at the"
+        text run at (0,36) width 31: "end. "
+        text run at (31,36) width 61: "This is an"
+        text run at (0,54) width 70: "example of"
+        text run at (0,72) width 48: "ellipsis-"
+        text run at (0,90) width 80: "truncation of"
+        text run at (0,108) width 91: "multi-line text."
+layer at (538,62) size 102x56 clip at (539,63) size 100x54 scrollHeight 108
+  RenderFlexibleBox {DIV} at (530,54) size 102x56 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x54
+      RenderText {#text} at (0,0) size 97x108
+        text run at (0,0) width 49: "3 lines. "
+        text run at (49,0) width 48: "No link"
+        text run at (0,18) width 69: "at the end. "
+        text run at (69,18) width 28: "This"
+        text run at (0,36) width 86: "is an example"
+        text run at (0,54) width 65: "of ellipsis-"
+        text run at (0,72) width 80: "truncation of"
+        text run at (0,90) width 91: "multi-line text."
+layer at (644,49) size 102x74 clip at (645,50) size 100x72
+  RenderFlexibleBox {DIV} at (636,41) size 102x74 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x72
+      RenderText {#text} at (0,0) size 100x72
+        text run at (0,0) width 49: "0 lines. "
+        text run at (49,0) width 42: "This is"
+        text run at (0,18) width 100: "an invalid value"
+        text run at (0,36) width 75: "for -webkit-"
+        text run at (0,54) width 70: "line-clamp."
+layer at (8,177) size 102x74 clip at (9,178) size 100x72
+  RenderFlexibleBox {DIV} at (0,169) size 102x74 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x72
+      RenderText {#text} at (0,0) size 100x72
+        text run at (0,0) width 54: "-1 lines. "
+        text run at (54,0) width 42: "This is"
+        text run at (0,18) width 100: "an invalid value"
+        text run at (0,36) width 75: "for -webkit-"
+        text run at (0,54) width 70: "line-clamp."
+layer at (114,177) size 102x74 clip at (115,178) size 100x72
+  RenderFlexibleBox {DIV} at (106,169) size 102x74 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x72
+      RenderText {#text} at (0,0) size 95x72
+        text run at (0,0) width 34: "-1%. "
+        text run at (34,0) width 61: "This is an"
+        text run at (0,18) width 81: "invalid value"
+        text run at (0,36) width 75: "for -webkit-"
+        text run at (0,54) width 70: "line-clamp."
+layer at (220,123) size 102x128 clip at (221,124) size 100x126
+  RenderFlexibleBox {DIV} at (212,115) size 102x128 [border: (1px solid #808080)]
+    RenderBlock (anonymous) at (1,1) size 100x126
+      RenderText {#text} at (0,0) size 99x126
+        text run at (0,0) width 37: "150%"
+        text run at (0,18) width 71: "truncation. "
+        text run at (71,18) width 28: "This"
+        text run at (0,36) width 84: "does the least"
+        text run at (0,54) width 63: "truncation"
+        text run at (0,72) width 55: "possible,"
+        text run at (0,90) width 63: "truncating"
+        text run at (0,108) width 52: "nothing."
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6f54f39..b9cbeb8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,39 @@
+2009-11-14  Adele Peterson  <adele at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Fix for <rdar://problem/6946165> Would like to be able to specify the number of visible lines when using -webkit-line-clamp
+
+        Test: fast/overflow/line-clamp.html
+
+        * css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Updated to handle different types of values.
+        * css/CSSParser.cpp: (WebCore::CSSParser::parseValue): ditto.
+        * css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applyProperty): ditto.
+
+        * rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::layoutVerticalBox):
+        Use the line count value if available.  Otherwise, convert the percentage to the line count, as we did before.  Also,
+        if there is anchor as the last child box, still allow adding the ellipsis.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollByRecursively): Call isNone on the LineClampValue to see if the line-clamp property has been set.
+        (WebCore::RenderLayer::scrollRectToVisible): ditto.
+
+        * WebCore.xcodeproj/project.pbxproj: Added LineClampValue.h
+        * rendering/style/LineClampValue.h: Added.
+        (WebCore::LineClampValue::LineClampValue):
+        (WebCore::LineClampValue::value):
+        (WebCore::LineClampValue::isPercentage):
+        (WebCore::LineClampValue::isNone):
+        (WebCore::LineClampValue::operator==):
+        (WebCore::LineClampValue::operator!=):
+        * rendering/style/RenderStyleConstants.h: (WebCore::): Define ELineClampType enum for percentage or line count.
+
+        * rendering/style/RenderStyle.h: Use LineClampValue.
+        (WebCore::InheritedFlags::lineClamp):
+        (WebCore::InheritedFlags::setLineClamp):
+        (WebCore::InheritedFlags::initialLineClamp):
+        * rendering/style/StyleRareNonInheritedData.h:
+
 2009-11-14  Eric Carlson  <eric.carlson at apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 1ff1bcf..b63263a 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -3272,6 +3272,7 @@
 		AB23A32809BBA7D00067CC53 /* BeforeTextInsertedEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEvent.h */; };
 		AB247A6C0AFD6383003FA5FD /* RenderSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB247A6A0AFD6383003FA5FD /* RenderSlider.cpp */; };
 		AB247A6D0AFD6383003FA5FD /* RenderSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = AB247A6B0AFD6383003FA5FD /* RenderSlider.h */; };
+		AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AB31C91D10AE1B8E000C7B92 /* LineClampValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		AB40484D0E083FA8007D6920 /* MediaDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB40484B0E083FA8007D6920 /* MediaDocument.cpp */; };
 		AB40484E0E083FA8007D6920 /* MediaDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = AB40484C0E083FA8007D6920 /* MediaDocument.h */; };
 		AB4261D80A2F6C9700BDD17D /* missingImage.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AB4261D70A2F6C9700BDD17D /* missingImage.tiff */; };
@@ -8253,6 +8254,7 @@
 		AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = BeforeTextInsertedEvent.h; sourceTree = "<group>"; };
 		AB247A6A0AFD6383003FA5FD /* RenderSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSlider.cpp; sourceTree = "<group>"; };
 		AB247A6B0AFD6383003FA5FD /* RenderSlider.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSlider.h; sourceTree = "<group>"; };
+		AB31C91D10AE1B8E000C7B92 /* LineClampValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LineClampValue.h; path = style/LineClampValue.h; sourceTree = "<group>"; };
 		AB40484B0E083FA8007D6920 /* MediaDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaDocument.cpp; sourceTree = "<group>"; };
 		AB40484C0E083FA8007D6920 /* MediaDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDocument.h; sourceTree = "<group>"; };
 		AB4261D70A2F6C9700BDD17D /* missingImage.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = missingImage.tiff; sourceTree = "<group>"; };
@@ -14542,6 +14544,7 @@
 				BC5EB69D0E81DAEB00B25965 /* FillLayer.h */,
 				BC5EBA0E0E823E4700B25965 /* KeyframeList.cpp */,
 				BC5EBA0F0E823E4700B25965 /* KeyframeList.h */,
+				AB31C91D10AE1B8E000C7B92 /* LineClampValue.h */,
 				BCEF43DF0E674110001C1287 /* NinePieceImage.cpp */,
 				BCEF43DC0E674012001C1287 /* NinePieceImage.h */,
 				BC5EB5DC0E81B8DD00B25965 /* OutlineValue.h */,
@@ -18123,6 +18126,7 @@
 				1479FAF4109AE37500DED655 /* RenderRubyText.h in Headers */,
 				E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */,
 				9382DF5810A8D5C900925652 /* ColorSpace.h in Headers */,
+				AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/css/CSSComputedStyleDeclaration.cpp b/WebCore/css/CSSComputedStyleDeclaration.cpp
index 28a57c4..e056da4 100644
--- a/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -900,9 +900,9 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
             return CSSPrimitiveValue::create(style->letterSpacing(), CSSPrimitiveValue::CSS_PX);
         case CSSPropertyWebkitLineClamp:
-            if (style->lineClamp() == -1)
+            if (style->lineClamp().isNone())
                 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
-            return CSSPrimitiveValue::create(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE);
+            return CSSPrimitiveValue::create(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyLineHeight: {
             Length length = style->lineHeight();
             if (length.isNegative())
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index 897fdd8..878d61c 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -1492,7 +1492,9 @@ bool CSSParser::parseValue(int propId, bool important)
     // Apple specific properties.  These will never be standardized and are purely to
     // support custom WebKit-based Apple applications.
     case CSSPropertyWebkitLineClamp:
-        valid_primitive = (!id && validUnit(value, FPercent, false));
+        // When specifying number of lines, don't allow 0 as a valid value
+        // When specifying either type of unit, require non-negative integers
+        valid_primitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg, false));
         break;
     case CSSPropertyWebkitTextSizeAdjust:
         if (id == CSSValueAuto || id == CSSValueNone)
diff --git a/WebCore/css/CSSStyleSelector.cpp b/WebCore/css/CSSStyleSelector.cpp
index 2ed58e5..9de4928 100644
--- a/WebCore/css/CSSStyleSelector.cpp
+++ b/WebCore/css/CSSStyleSelector.cpp
@@ -5000,13 +5000,15 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     case CSSPropertyWebkitMarginBottomCollapse:
         HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(marginBottomCollapse, MarginBottomCollapse)
         return;
-
-    // Apple-specific changes.  Do not merge these properties into KHTML.
     case CSSPropertyWebkitLineClamp: {
         HANDLE_INHERIT_AND_INITIAL(lineClamp, LineClamp)
         if (!primitiveValue)
             return;
-        m_style->setLineClamp(primitiveValue->getIntValue(CSSPrimitiveValue::CSS_PERCENTAGE));
+        int type = primitiveValue->primitiveType();
+        if (type == CSSPrimitiveValue::CSS_NUMBER)
+            m_style->setLineClamp(LineClampValue(primitiveValue->getIntValue(CSSPrimitiveValue::CSS_NUMBER), LineClampLineCount));
+        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
+            m_style->setLineClamp(LineClampValue(primitiveValue->getIntValue(CSSPrimitiveValue::CSS_PERCENTAGE), LineClampPercentage));
         return;
     }
     case CSSPropertyWebkitHighlight: {
diff --git a/WebCore/rendering/RenderFlexibleBox.cpp b/WebCore/rendering/RenderFlexibleBox.cpp
index df0b7ed..7991b61 100644
--- a/WebCore/rendering/RenderFlexibleBox.cpp
+++ b/WebCore/rendering/RenderFlexibleBox.cpp
@@ -645,7 +645,7 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
 
     // We confine the line clamp ugliness to vertical flexible boxes (thus keeping it out of
     // mainstream block layout); this is not really part of the XUL box model.
-    bool haveLineClamp = style()->lineClamp() >= 0 && style()->lineClamp() <= 100;
+    bool haveLineClamp = !style()->lineClamp().isNone();
     if (haveLineClamp) {
         int maxLineCount = 0;
         child = iterator.first();
@@ -670,7 +670,8 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
         
         // Get the # of lines and then alter all block flow children with auto height to use the
         // specified height. We always try to leave room for at least one line.
-        int numVisibleLines = max(1, static_cast<int>((maxLineCount + 1) * style()->lineClamp() / 100.0));
+        LineClampValue lineClamp = style()->lineClamp();
+        int numVisibleLines = lineClamp.isPercentage() ? max(1, (maxLineCount + 1) * lineClamp.value() / 100) : lineClamp.value();
         if (numVisibleLines < maxLineCount) {
             for (child = iterator.first(); child; child = iterator.next()) {
                 if (child->isPositioned() || !child->style()->height().isAuto() || !child->isBlockFlow())
@@ -701,28 +702,25 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
                 if (!lastLine)
                     continue;
                 
-                // See if the last item is an anchor
-                InlineBox* anchorBox = lastLine->lastChild();
-                if (!anchorBox)
-                    continue;
-                if (!anchorBox->renderer()->node())
-                    continue;
-                if (!anchorBox->renderer()->node()->isLink())
-                    continue;
-                
                 RootInlineBox* lastVisibleLine = blockChild->lineAtIndex(numVisibleLines-1);
                 if (!lastVisibleLine)
                     continue;
 
                 const UChar ellipsisAndSpace[2] = { horizontalEllipsis, ' ' };
                 DEFINE_STATIC_LOCAL(AtomicString, ellipsisAndSpaceStr, (ellipsisAndSpace, 2));
-
+                DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1));
                 const Font& font = style(numVisibleLines == 1)->font();
-                int ellipsisAndSpaceWidth = font.width(TextRun(ellipsisAndSpace, 2));
 
-                // Get ellipsis width + " " + anchor width
-                int totalWidth = ellipsisAndSpaceWidth + anchorBox->width();
-                
+                // Get ellipsis width, and if the last child is an anchor, it will go after the ellipsis, so add in a space and the anchor width too 
+                int totalWidth;
+                InlineBox* anchorBox = lastLine->lastChild();
+                if (anchorBox && anchorBox->renderer()->node() && anchorBox->renderer()->node()->isLink())
+                    totalWidth = anchorBox->width() + font.width(TextRun(ellipsisAndSpace, 2));
+                else {
+                    anchorBox = 0;
+                    totalWidth = font.width(TextRun(&horizontalEllipsis, 1));
+                }
+                                
                 // See if this width can be accommodated on the last visible line
                 RenderBlock* destBlock = toRenderBlock(lastVisibleLine->renderer());
                 RenderBlock* srcBlock = toRenderBlock(lastLine->renderer());
@@ -744,7 +742,7 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
                     continue;
 
                 // Let the truncation code kick in.
-                lastVisibleLine->placeEllipsis(ellipsisAndSpaceStr, ltr, blockLeftEdge, blockRightEdge, totalWidth, anchorBox);
+                lastVisibleLine->placeEllipsis(anchorBox ? ellipsisAndSpaceStr : ellipsisStr, ltr, blockLeftEdge, blockRightEdge, totalWidth, anchorBox);
                 destBlock->setHasMarkupTruncation(true);
             }
         }
diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp
index 94a831f..3932cb6 100644
--- a/WebCore/rendering/RenderLayer.cpp
+++ b/WebCore/rendering/RenderLayer.cpp
@@ -1054,7 +1054,7 @@ void RenderLayer::scrollByRecursively(int xDelta, int yDelta)
 
     bool restrictedByLineClamp = false;
     if (renderer()->parent())
-        restrictedByLineClamp = renderer()->parent()->style()->lineClamp() >= 0;
+        restrictedByLineClamp = !renderer()->parent()->style()->lineClamp().isNone();
 
     if (renderer()->hasOverflowClip() && !restrictedByLineClamp) {
         int newOffsetX = scrollXOffset() + xDelta;
@@ -1198,7 +1198,7 @@ void RenderLayer::scrollRectToVisible(const IntRect &rect, bool scrollToAnchor,
     bool restrictedByLineClamp = false;
     if (renderer()->parent()) {
         parentLayer = renderer()->parent()->enclosingLayer();
-        restrictedByLineClamp = renderer()->parent()->style()->lineClamp() >= 0;
+        restrictedByLineClamp = !renderer()->parent()->style()->lineClamp().isNone();
     }
 
     if (renderer()->hasOverflowClip() && !restrictedByLineClamp) {
diff --git a/WebCore/rendering/style/LineClampValue.h b/WebCore/rendering/style/LineClampValue.h
new file mode 100644
index 0000000..2119ca2
--- /dev/null
+++ b/WebCore/rendering/style/LineClampValue.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LineClampValue_h
+#define LineClampValue_h
+
+#include "RenderStyleConstants.h"
+
+namespace WebCore {
+    
+class LineClampValue {
+public:
+    LineClampValue()
+        : m_type(LineClampLineCount)
+        , m_value(-1)
+    {
+    }
+    
+    LineClampValue(int value, ELineClampType type)
+        : m_type(type)
+        , m_value(value)
+    {
+    }
+    
+    int value() const { return m_value; }
+    
+    bool isPercentage() const { return m_type == LineClampPercentage; }
+
+    bool isNone() const { return m_value == -1; }
+
+    bool operator==(const LineClampValue& o) const
+    {
+        return value() == o.value() && isPercentage() == o.isPercentage();
+    }
+    
+    bool operator!=(const LineClampValue& o) const
+    {
+        return !(*this == o);
+    }
+    
+private:
+    ELineClampType m_type;
+    int m_value;
+};
+    
+} // namespace WebCore
+
+#endif // LineClampValue_h
diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h
index e497be8..40cf1cd 100644
--- a/WebCore/rendering/style/RenderStyle.h
+++ b/WebCore/rendering/style/RenderStyle.h
@@ -50,6 +50,7 @@
 #include "Length.h"
 #include "LengthBox.h"
 #include "LengthSize.h"
+#include "LineClampValue.h"
 #include "NinePieceImage.h"
 #include "OutlineValue.h"
 #include "Pair.h"
@@ -695,7 +696,7 @@ public:
     bool isRunningAcceleratedAnimation() const { return rareNonInheritedData->m_runningAcceleratedAnimation; }
 #endif
 
-    int lineClamp() const { return rareNonInheritedData->lineClamp; }
+    const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; }
     bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
     ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
 
@@ -1012,7 +1013,7 @@ public:
     void setIsRunningAcceleratedAnimation(bool b = true) { SET_VAR(rareNonInheritedData, m_runningAcceleratedAnimation, b); }
 #endif
 
-    void setLineClamp(int c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
+    void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
     void setTextSizeAdjust(bool b) { SET_VAR(rareInheritedData, textSizeAdjust, b); }
     void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
 
@@ -1184,7 +1185,7 @@ public:
     static Color initialBackgroundColor() { return Color::transparent; }
 
     // Keep these at the end.
-    static int initialLineClamp() { return -1; }
+    static LineClampValue initialLineClamp() { return LineClampValue(); }
     static bool initialTextSizeAdjust() { return true; }
     static ETextSecurity initialTextSecurity() { return TSNONE; }
 #if ENABLE(DASHBOARD_SUPPORT)
diff --git a/WebCore/rendering/style/RenderStyleConstants.h b/WebCore/rendering/style/RenderStyleConstants.h
index 3010947..38f245c 100644
--- a/WebCore/rendering/style/RenderStyleConstants.h
+++ b/WebCore/rendering/style/RenderStyleConstants.h
@@ -321,6 +321,8 @@ enum ETransformStyle3D {
 enum EBackfaceVisibility {
     BackfaceVisibilityVisible, BackfaceVisibilityHidden
 };
+    
+enum ELineClampType { LineClampLineCount, LineClampPercentage };
 
 } // namespace WebCore
 
diff --git a/WebCore/rendering/style/StyleRareNonInheritedData.h b/WebCore/rendering/style/StyleRareNonInheritedData.h
index 8dd22b3..452b273 100644
--- a/WebCore/rendering/style/StyleRareNonInheritedData.h
+++ b/WebCore/rendering/style/StyleRareNonInheritedData.h
@@ -29,6 +29,7 @@
 #include "CursorData.h"
 #include "DataRef.h"
 #include "FillLayer.h"
+#include "LineClampValue.h"
 #include "NinePieceImage.h"
 #include "StyleTransformData.h"
 #include <wtf/OwnPtr.h>
@@ -77,7 +78,7 @@ public:
     bool animationDataEquivalent(const StyleRareNonInheritedData&) const;
     bool transitionDataEquivalent(const StyleRareNonInheritedData&) const;
 
-    int lineClamp; // An Apple extension.
+    LineClampValue lineClamp; // An Apple extension.
 #if ENABLE(DASHBOARD_SUPPORT)
     Vector<StyleDashboardRegion> m_dashboardRegions;
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list