Rendering text-justify:none

When the value of text-justify is 'none',
we don't need to touch anything related to the expansion opportunity.
We just need to leave the expansion opportunity as 0,
so that justification doesn't work for this case.

BUG=248894

Review URL: https://codereview.chromium.org/50413008

git-svn-id: svn://svn.chromium.org/blink/trunk@161006 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/LayoutTests/fast/css3-text/css3-text-justify/resources/text-justify.css b/LayoutTests/fast/css3-text/css3-text-justify/resources/text-justify.css
new file mode 100644
index 0000000..383c038
--- /dev/null
+++ b/LayoutTests/fast/css3-text/css3-text-justify/resources/text-justify.css
@@ -0,0 +1,18 @@
+.testDiv {
+    width: 300px;
+    border: 1px solid #000000;
+    font-family: "Courier New", Courier, monospace;
+    font-size: 12px;
+}
+
+.alignStart {
+    text-align: start;
+}
+
+.alignJustify {
+    text-align: justify;
+}
+
+.justifyNone {
+    text-justify: none;
+}
diff --git a/LayoutTests/fast/css3-text/css3-text-justify/text-justify-none-expected.html b/LayoutTests/fast/css3-text/css3-text-justify/text-justify-none-expected.html
new file mode 100644
index 0000000..0b1b7c9
--- /dev/null
+++ b/LayoutTests/fast/css3-text/css3-text-justify/text-justify-none-expected.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <link href="resources/text-justify.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+<h1 style="font-size: 1em;">
+text-justify: none <br><br>
+
+This test checks that the 'none' value for text-justify property works properly.<br>
+All of the lines with the value should <b>NOT</b> be justified.<br>
+</h1>
+
+<div class='testDiv alignJustify'>
+text-align:justify<br/><br/>
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.
+</div>
+
+<div class='testDiv alignStart'>
+text-align:justify, text-justify:none<br/><br/>
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.
+</div>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/css3-text/css3-text-justify/text-justify-none.html b/LayoutTests/fast/css3-text/css3-text-justify/text-justify-none.html
new file mode 100644
index 0000000..43ab1407
--- /dev/null
+++ b/LayoutTests/fast/css3-text/css3-text-justify/text-justify-none.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <link href="resources/text-justify.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+<h1 style="font-size: 1em;">
+text-justify: none <br><br>
+
+This test checks that the 'none' value for text-justify property works properly.<br>
+All of the lines with the value should <b>NOT</b> be justified.<br>
+</h1>
+
+<div class='testDiv alignJustify'>
+text-align:justify<br/><br/>
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.
+</div>
+
+<div class='testDiv alignJustify justifyNone'>
+text-align:justify, text-justify:none<br/><br/>
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.
+</div>
+
+</body>
+</html>
diff --git a/Source/core/rendering/RenderBlockLineLayout.cpp b/Source/core/rendering/RenderBlockLineLayout.cpp
index 6a93057..bebfadc 100644
--- a/Source/core/rendering/RenderBlockLineLayout.cpp
+++ b/Source/core/rendering/RenderBlockLineLayout.cpp
@@ -1013,6 +1013,7 @@
     bool isAfterExpansion = true;
     Vector<unsigned, 16> expansionOpportunities;
     RenderObject* previousObject = 0;
+    TextJustify textJustify = style()->textJustify();
 
     BidiRun* r = firstRun;
     for (; r; r = r->next()) {
@@ -1026,7 +1027,7 @@
                       // Similarly, line break boxes have no effect on the width.
         if (r->m_object->isText()) {
             RenderText* rt = toRenderText(r->m_object);
-            if (textAlign == JUSTIFY && r != trailingSpaceRun) {
+            if (textAlign == JUSTIFY && r != trailingSpaceRun && textJustify != TextJustifyNone) {
                 if (!isAfterExpansion)
                     toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true);
                 unsigned opportunitiesInRun;