= Line Breaking in WebKit = {{{ #!div class="important" **WARNING:** This page contains forward looking statements, which should ''not yet'' be considered an accurate description of WebKit. }}} == Line Breaking == [http://dev.w3.org/csswg/css3-text/ CSS3 Text] defines a set of rules governing [http://dev.w3.org/csswg/css3-text/#line-break-details default line breaking behavior], some of which is very specific, i.e., testable and repeatable among browsers, and some of which is generic, i.e., not standardized. An example of the former is that the non-tailorable line breaking classes defined by the Unicode Line Breaking Algorithm, Unicode Technical Report #14 [http://www.unicode.org/reports/tr14/ UAX14], must be honored; an example of the latter is that [http://dev.w3.org/csswg/css3-text/#soft-wrap-opportunity soft break opportunities] are not concretely defined. === The `line-break` property === In order to customize line breaking behavior, CSS3 Text introduces the inheritable [http://dev.w3.org/csswg/css3-text/#line-break line-break] property, with the following standard values: * `auto` * `loose` * `normal` * `strict` If not specified, the initial (default) value is `auto`. CSS3 Text does not fully define line breaking behavior for any of these values. Rather, it specifies certain constraints or absence of constraints that are expected to operate as an additional layer of behavior on top of the [http://dev.w3.org/csswg/css3-text/#line-break-details default line breaking behavior] rules. In addition, CSS3 Text does not define the meaning of `auto` other than saying "the UA determines the set of line-breaking restrictions to use". Since these definitions leave a great deal of latitude on the part of the browser (UA implementation), WebKit must make specific choices in how to interpret these values, about which see more below. === The former `-webkit-line-break` property === Since Safari 3.0, WebKit has supported a non-standard `-webkit-line-break` property, based on the earlier `-khtml-line-break` property in Safari 2.0, which accepted one of two values: * `normal` (default) * `after-white-space` The behavior for `normal` was defined by the [http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html#//apple_ref/css/property/-webkit-line-break Safari CSS Reference] as "a standard line-breaking rule", while `after-white-space` was defined as "the line breaks after white space", neither of which definitions are sufficiently precise to obtain interoperability. === The new `-webkit-line-break` property === With the introduction of CSS3 Text features, and since its properties have not yet been designated non-prefixed by the CSS Working Group, it is necessary to merge the value space of the former `-webkit-line-break` property and the new `line-break` property into a newly defined `-webkit-line-break` property that accepts the following values: * `auto` (default) * `loose` * `normal` * `strict` * `after-white-space` Note that this functional merger results in the value `auto` being returned as the default value instead of the former `normal` value. The following table describes how WebKit interprets the above values. || **Value** || **Interpretation** || || `auto` || use ICU default rules || || `loose` || use ICU default rules as modified by CSS3 Text semantics for `loose` || || `normal` || use ICU default rules as modified by CSS3 Text semantics for `normal` || || `strict` || use ICU default rules as modified by CSS3 Text semantics for `strict` || || `after-white-space` || break only after specific white space characters || See [[LineBreakingCSS3Mapping|Line Breaking Behavior Details]] for further details of the interpretation of these values. === Implementation Details === When WebKit needs to render a block of text, it uses the [http://icu-project.org/ ICU] library to determine where line breaks are mandatory, forbidden, or optional (see {{{RenderBlock::LineBreaker::nextLineBreak}}}). This library provides a number of rule sets, keyed by the locale's primary language sub tag, to determine line break boundaries, where this language sub tag is determined by rules specific to the document language definition. For example, for HTML5 see [http://www.w3.org/TR/html5/global-attributes.html#the-lang-and-xml:lang-attributes the lang and xml:lang attributes]. In the current release for [http://icu-project.org/apiref/icu4c50m1/ ICU] (version 50), the following line break rule sets are provided: * [http://source.icu-project.org/repos/icu/icu/trunk/source/data/brkitr/line.txt line.txt] primary language unspecified or no tailored rule set exists * [http://source.icu-project.org/repos/icu/icu/trunk/source/data/brkitr/line_fi.txt line_fi.txt] primary language is Finnish (`fi`) * [http://source.icu-project.org/repos/icu/icu/trunk/source/data/brkitr/line_ja.txt line_ja.txt] primary language is Japanese (`ja`) In general, these rule sets attempt to implement the rules defined by [http://www.unicode.org/reports/tr14/ UAX14]. In order to support the ''new'' `-webkit-line-break` property defined above, WebKit implements the specific behavior defined in [[LineBreakingCSS3Mapping|Line Breaking Behavior Details]]. == References == 1. [=#css3text http://dev.w3.org/csswg/css3-text/] 1. [=#uax14 http://www.unicode.org/reports/tr14/] 1. [=#icu http://site.icu-project.org] 1. [=#html5lang http://www.w3.org/TR/html5/global-attributes.html]