<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[37550] trunk/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/37550">37550</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2008-10-12 18:37:13 -0700 (Sun, 12 Oct 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>2008-10-12  Darin Adler  &lt;darin@apple.com&gt;

        Based on work by Holger Freyther.

        - part of https://bugs.webkit.org/show_bug.cgi?id=20953
          Split WidthIterator into its own source file.

        * GNUmakefile.am: Added new source files.
        * WebCore.vcproj/WebCore.vcproj: Ditto.
        * WebCore.xcodeproj/project.pbxproj: Ditto.
        * WebCoreSources.bkl: Ditto.

        * platform/graphics/Font.cpp: Use WidthIterator from its new place.
        * platform/graphics/WidthIterator.cpp: Added.
        * platform/graphics/WidthIterator.h: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreGNUmakefileam">trunk/WebCore/GNUmakefile.am</a></li>
<li><a href="#trunkWebCoreWebCorevcprojWebCorevcproj">trunk/WebCore/WebCore.vcproj/WebCore.vcproj</a></li>
<li><a href="#trunkWebCoreWebCorexcodeprojprojectpbxproj">trunk/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkWebCoreWebCoreSourcesbkl">trunk/WebCore/WebCoreSources.bkl</a></li>
<li><a href="#trunkWebCoreplatformgraphicsFontcpp">trunk/WebCore/platform/graphics/Font.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebCoreplatformgraphicsWidthIteratorcpp">trunk/WebCore/platform/graphics/WidthIterator.cpp</a></li>
<li><a href="#trunkWebCoreplatformgraphicsWidthIteratorh">trunk/WebCore/platform/graphics/WidthIterator.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (37549 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2008-10-13 01:29:37 UTC (rev 37549)
+++ trunk/WebCore/ChangeLog        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2008-10-12  Darin Adler  &lt;darin@apple.com&gt;
+
+        Based on work by Holger Freyther.
+
+        - part of https://bugs.webkit.org/show_bug.cgi?id=20953
+          Split WidthIterator into its own source file.
+
+        * GNUmakefile.am: Added new source files.
+        * WebCore.vcproj/WebCore.vcproj: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * WebCoreSources.bkl: Ditto.
+
+        * platform/graphics/Font.cpp: Use WidthIterator from its new place.
+        * platform/graphics/WidthIterator.cpp: Added.
+        * platform/graphics/WidthIterator.h: Added.
+
</ins><span class="cx"> 2008-10-12  Tony Chang  &lt;tony@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Sam Weinig.
</span></span></pre></div>
<a id="trunkWebCoreGNUmakefileam"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/GNUmakefile.am (37549 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/GNUmakefile.am        2008-10-13 01:29:37 UTC (rev 37549)
+++ trunk/WebCore/GNUmakefile.am        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -1353,6 +1353,8 @@
</span><span class="cx">         WebCore/platform/graphics/StringTruncator.h \
</span><span class="cx">         WebCore/platform/graphics/TextRun.h \
</span><span class="cx">         WebCore/platform/graphics/UnitBezier.h \
</span><ins>+        WebCore/platform/graphics/WidthIterator.cpp \
+        WebCore/platform/graphics/WidthIterator.h \
</ins><span class="cx">         WebCore/platform/graphics/filters/FEBlend.h \
</span><span class="cx">         WebCore/platform/graphics/filters/FEColorMatrix.h \
</span><span class="cx">         WebCore/platform/graphics/filters/FEComponentTransfer.h \
</span></span></pre></div>
<a id="trunkWebCoreWebCorevcprojWebCorevcproj"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.vcproj/WebCore.vcproj (37549 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.vcproj/WebCore.vcproj        2008-10-13 01:29:37 UTC (rev 37549)
+++ trunk/WebCore/WebCore.vcproj/WebCore.vcproj        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -6065,6 +6065,14 @@
</span><span class="cx">                                         &gt;
</span><span class="cx">                                 &lt;/File&gt;
</span><span class="cx">                                 &lt;File
</span><ins>+                                        RelativePath=&quot;..\platform\graphics\WidthIterator.cpp&quot;
+                                        &gt;
+                                &lt;/File&gt;
+                                &lt;File
+                                        RelativePath=&quot;..\platform\graphics\WidthIterator.h&quot;
+                                        &gt;
+                                &lt;/File&gt;
+                                &lt;File
</ins><span class="cx">                                         RelativePath=&quot;..\platform\text\TextBoundaries.h&quot;
</span><span class="cx">                                         &gt;
</span><span class="cx">                                 &lt;/File&gt;
</span></span></pre></div>
<a id="trunkWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.xcodeproj/project.pbxproj (37549 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.xcodeproj/project.pbxproj        2008-10-13 01:29:37 UTC (rev 37549)
+++ trunk/WebCore/WebCore.xcodeproj/project.pbxproj        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -1804,6 +1804,8 @@
</span><span class="cx">                 9392F1500AD1862300691BD4 /* CounterNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9392F14F0AD1862300691BD4 /* CounterNode.cpp */; };
</span><span class="cx">                 939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939885C108B7E3D100E707C4 /* EventNames.cpp */; };
</span><span class="cx">                 939885C408B7E3D100E707C4 /* EventNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 939885C208B7E3D100E707C4 /* EventNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939B02EC0EA2DBC400C54570 /* WidthIterator.cpp */; };
+                939B02EF0EA2DBC400C54570 /* WidthIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 939B02ED0EA2DBC400C54570 /* WidthIterator.h */; };
</ins><span class="cx">                 939B3E4E0D3C1E8400B4A92B /* StringBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 939B3E4D0D3C1E8400B4A92B /* StringBuffer.h */; };
</span><span class="cx">                 93A38B4B0D0E5808006872C2 /* EditorCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A38B4A0D0E5808006872C2 /* EditorCommand.cpp */; };
</span><span class="cx">                 93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -6483,6 +6485,8 @@
</span><span class="cx">                 93955A4203D72932008635CE /* RenderTreeAsText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeAsText.cpp; sourceTree = &quot;&lt;group&gt;&quot;; tabWidth = 8; usesTabs = 0; };
</span><span class="cx">                 939885C108B7E3D100E707C4 /* EventNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventNames.cpp; sourceTree = &quot;&lt;group&gt;&quot;; tabWidth = 8; usesTabs = 0; };
</span><span class="cx">                 939885C208B7E3D100E707C4 /* EventNames.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = EventNames.h; sourceTree = &quot;&lt;group&gt;&quot;; tabWidth = 8; usesTabs = 0; };
</span><ins>+                939B02EC0EA2DBC400C54570 /* WidthIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidthIterator.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                939B02ED0EA2DBC400C54570 /* WidthIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidthIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 939B3E4D0D3C1E8400B4A92B /* StringBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringBuffer.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93A38B4A0D0E5808006872C2 /* EditorCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditorCommand.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ContextMenu.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -12589,6 +12593,8 @@
</span><span class="cx">                                 B27535530B053814002CE64F /* Path.h */,
</span><span class="cx">                                 A88DD4880B4629B000C02990 /* PathTraversalState.cpp */,
</span><span class="cx">                                 A88DD4860B4629A300C02990 /* PathTraversalState.h */,
</span><ins>+                                A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
+                                A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
</ins><span class="cx">                                 B27535540B053814002CE64F /* Pen.cpp */,
</span><span class="cx">                                 B27535550B053814002CE64F /* Pen.h */,
</span><span class="cx">                                 371F4FFB0D25E7F300ECE0D5 /* SegmentedFontData.cpp */,
</span><span class="lines">@@ -12599,8 +12605,8 @@
</span><span class="cx">                                 B23540F10D00782E002382FA /* StringTruncator.h */,
</span><span class="cx">                                 A824B4640E2EF2EA0081A7B7 /* TextRun.h */,
</span><span class="cx">                                 E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
</span><del>-                                A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
-                                A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
</del><ins>+                                939B02EC0EA2DBC400C54570 /* WidthIterator.cpp */,
+                                939B02ED0EA2DBC400C54570 /* WidthIterator.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = graphics;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -15988,6 +15994,7 @@
</span><span class="cx">                                 1CF6BDFA0E9BB26A0025E1CD /* ObjCEventListener.h in Headers */,
</span><span class="cx">                                 1CF6BE150E9BB4670025E1CD /* ObjCNodeFilterCondition.h in Headers */,
</span><span class="cx">                                 A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */,
</span><ins>+                                939B02EF0EA2DBC400C54570 /* WidthIterator.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><span class="lines">@@ -17855,6 +17862,7 @@
</span><span class="cx">                                 1CF6BDFB0E9BB26A0025E1CD /* ObjCEventListener.mm in Sources */,
</span><span class="cx">                                 1CF6BE140E9BB4670025E1CD /* ObjCNodeFilterCondition.mm in Sources */,
</span><span class="cx">                                 BC80FA130EA287B000B0821D /* Length.cpp in Sources */,
</span><ins>+                                939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span></span></pre></div>
<a id="trunkWebCoreWebCoreSourcesbkl"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCoreSources.bkl (37549 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCoreSources.bkl        2008-10-13 01:29:37 UTC (rev 37549)
+++ trunk/WebCore/WebCoreSources.bkl        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -702,6 +702,7 @@
</span><span class="cx">         platform/graphics/GlyphWidthMap.cpp
</span><span class="cx">         platform/graphics/SegmentedFontData.cpp
</span><span class="cx">         platform/graphics/SimpleFontData.cpp
</span><ins>+        platform/graphics/WidthIterator.cpp
</ins><span class="cx">         platform/KURL.cpp
</span><span class="cx">         platform/Logging.cpp
</span><span class="cx">         platform/MIMETypeRegistry.cpp
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsFontcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/Font.cpp (37549 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/Font.cpp        2008-10-13 01:29:37 UTC (rev 37549)
+++ trunk/WebCore/platform/graphics/Font.cpp        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -1,10 +1,8 @@
</span><del>-/**
- * This file is part of the html renderer for KDE.
- *
</del><ins>+/*
</ins><span class="cx">  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><span class="cx">  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><span class="cx">  *           (C) 2000 Dirk Mueller (mueller@kde.org)
</span><del>- * Copyright (C) 2003, 2006 Apple Computer, Inc.
</del><ins>+ * Copyright (C) 2003, 2006 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -32,21 +30,14 @@
</span><span class="cx"> #include &quot;FontFallbackList.h&quot;
</span><span class="cx"> #include &quot;IntPoint.h&quot;
</span><span class="cx"> #include &quot;GlyphBuffer.h&quot;
</span><del>-#include &lt;wtf/unicode/Unicode.h&gt;
</del><ins>+#include &quot;WidthIterator.h&quot;
</ins><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> 
</span><del>-#if USE(ICU_UNICODE)
-#include &lt;unicode/unorm.h&gt;
-#endif
-
</del><span class="cx"> using namespace WTF;
</span><span class="cx"> using namespace Unicode;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-// According to http://www.unicode.org/Public/UNIDATA/UCD.html#Canonical_Combining_Class_Values
-const uint8_t hiraganaKatakanaVoicingMarksCombiningClass = 8;
-
</del><span class="cx"> const uint8_t Font::gRoundingHackCharacterTable[256] = {
</span><span class="cx">     0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*\t*/, 1 /*\n*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
</span><span class="cx">     1 /*space*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*-*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*?*/,
</span><span class="lines">@@ -60,215 +51,6 @@
</span><span class="cx"> 
</span><span class="cx"> Font::CodePath Font::s_codePath = Auto;
</span><span class="cx"> 
</span><del>-struct WidthIterator {
-    WidthIterator(const Font* font, const TextRun&amp; run);
-
-    void advance(int to, GlyphBuffer* glyphBuffer = 0);
-    bool advanceOneCharacter(float&amp; width, GlyphBuffer* glyphBuffer = 0);
-    
-    const Font* m_font;
-
-    const TextRun&amp; m_run;
-    int m_end;
-
-    unsigned m_currentCharacter;
-    float m_runWidthSoFar;
-    float m_padding;
-    float m_padPerSpace;
-    float m_finalRoundingWidth;
-    
-private:
-    UChar32 normalizeVoicingMarks(int currentCharacter);
-};
-
-WidthIterator::WidthIterator(const Font* font, const TextRun&amp; run)
-    : m_font(font)
-    , m_run(run)
-    , m_end(run.length())
-    , m_currentCharacter(0)
-    , m_runWidthSoFar(0)
-    , m_finalRoundingWidth(0)
-{
-    // If the padding is non-zero, count the number of spaces in the run
-    // and divide that by the padding for per space addition.
-    m_padding = m_run.padding();
-    if (!m_padding)
-        m_padPerSpace = 0;
-    else {
-        float numSpaces = 0;
-        for (int i = 0; i &lt; run.length(); i++)
-            if (Font::treatAsSpace(m_run[i]))
-                numSpaces++;
-
-        if (numSpaces == 0)
-            m_padPerSpace = 0;
-        else
-            m_padPerSpace = ceilf(m_run.padding() / numSpaces);
-    }
-}
-
-void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
-{
-    if (offset &gt; m_end)
-        offset = m_end;
-
-    int currentCharacter = m_currentCharacter;
-    const UChar* cp = m_run.data(currentCharacter);
-
-    bool rtl = m_run.rtl();
-    bool hasExtraSpacing = (m_font-&gt;letterSpacing() || m_font-&gt;wordSpacing() || m_padding) &amp;&amp; !m_run.spacingDisabled();
-
-    float runWidthSoFar = m_runWidthSoFar;
-    float lastRoundingWidth = m_finalRoundingWidth;
-    
-    while (currentCharacter &lt; offset) {
-        UChar32 c = *cp;
-        unsigned clusterLength = 1;
-        if (c &gt;= 0x3041) {
-            if (c &lt;= 0x30FE) {
-                // Deal with Hiragana and Katakana voiced and semi-voiced syllables.
-                // Normalize into composed form, and then look for glyph with base + combined mark.
-                // Check above for character range to minimize performance impact.
-                UChar32 normalized = normalizeVoicingMarks(currentCharacter);
-                if (normalized) {
-                    c = normalized;
-                    clusterLength = 2;
-                }
-            } else if (U16_IS_SURROGATE(c)) {
-                if (!U16_IS_SURROGATE_LEAD(c))
-                    break;
-
-                // Do we have a surrogate pair?  If so, determine the full Unicode (32 bit)
-                // code point before glyph lookup.
-                // Make sure we have another character and it's a low surrogate.
-                if (currentCharacter + 1 &gt;= m_run.length())
-                    break;
-                UChar low = cp[1];
-                if (!U16_IS_TRAIL(low))
-                    break;
-                c = U16_GET_SUPPLEMENTARY(c, low);
-                clusterLength = 2;
-            }
-        }
-
-        const GlyphData&amp; glyphData = m_font-&gt;glyphDataForCharacter(c, rtl);
-        Glyph glyph = glyphData.glyph;
-        const SimpleFontData* fontData = glyphData.fontData;
-
-        ASSERT(fontData);
-
-        // Now that we have a glyph and font data, get its width.
-        float width;
-        if (c == '\t' &amp;&amp; m_run.allowTabs()) {
-            float tabWidth = m_font-&gt;tabWidth();
-            width = tabWidth - fmodf(m_run.xPos() + runWidthSoFar, tabWidth);
-        } else {
-            width = fontData-&gt;widthForGlyph(glyph);
-            // We special case spaces in two ways when applying word rounding.
-            // First, we round spaces to an adjusted width in all fonts.
-            // Second, in fixed-pitch fonts we ensure that all characters that
-            // match the width of the space character have the same width as the space character.
-            if (width == fontData-&gt;m_spaceWidth &amp;&amp; (fontData-&gt;m_treatAsFixedPitch || glyph == fontData-&gt;m_spaceGlyph) &amp;&amp; m_run.applyWordRounding())
-                width = fontData-&gt;m_adjustedSpaceWidth;
-        }
-
-        if (hasExtraSpacing) {
-            // Account for letter-spacing.
-            if (width &amp;&amp; m_font-&gt;letterSpacing())
-                width += m_font-&gt;letterSpacing();
-
-            if (Font::treatAsSpace(c)) {
-                // Account for padding. WebCore uses space padding to justify text.
-                // We distribute the specified padding over the available spaces in the run.
-                if (m_padding) {
-                    // Use left over padding if not evenly divisible by number of spaces.
-                    if (m_padding &lt; m_padPerSpace) {
-                        width += m_padding;
-                        m_padding = 0;
-                    } else {
-                        width += m_padPerSpace;
-                        m_padding -= m_padPerSpace;
-                    }
-                }
-
-                // Account for word spacing.
-                // We apply additional space between &quot;words&quot; by adding width to the space character.
-                if (currentCharacter != 0 &amp;&amp; !Font::treatAsSpace(cp[-1]) &amp;&amp; m_font-&gt;wordSpacing())
-                    width += m_font-&gt;wordSpacing();
-            }
-        }
-
-        // Advance past the character we just dealt with.
-        cp += clusterLength;
-        currentCharacter += clusterLength;
-
-        // Account for float/integer impedance mismatch between CG and KHTML. &quot;Words&quot; (characters 
-        // followed by a character defined by isRoundingHackCharacter()) are always an integer width.
-        // We adjust the width of the last character of a &quot;word&quot; to ensure an integer width.
-        // If we move KHTML to floats we can remove this (and related) hacks.
-
-        float oldWidth = width;
-
-        // Force characters that are used to determine word boundaries for the rounding hack
-        // to be integer width, so following words will start on an integer boundary.
-        if (m_run.applyWordRounding() &amp;&amp; Font::isRoundingHackCharacter(c))
-            width = ceilf(width);
-
-        // Check to see if the next character is a &quot;rounding hack character&quot;, if so, adjust
-        // width so that the total run width will be on an integer boundary.
-        if ((m_run.applyWordRounding() &amp;&amp; currentCharacter &lt; m_run.length() &amp;&amp; Font::isRoundingHackCharacter(*cp))
-                || (m_run.applyRunRounding() &amp;&amp; currentCharacter &gt;= m_end)) {
-            float totalWidth = runWidthSoFar + width;
-            width += ceilf(totalWidth) - totalWidth;
-        }
-
-        runWidthSoFar += width;
-
-        if (glyphBuffer)
-            glyphBuffer-&gt;add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
-
-        lastRoundingWidth = width - oldWidth;
-    }
-
-    m_currentCharacter = currentCharacter;
-    m_runWidthSoFar = runWidthSoFar;
-    m_finalRoundingWidth = lastRoundingWidth;
-}
-
-bool WidthIterator::advanceOneCharacter(float&amp; width, GlyphBuffer* glyphBuffer)
-{
-    glyphBuffer-&gt;clear();
-    advance(m_currentCharacter + 1, glyphBuffer);
-    float w = 0;
-    for (int i = 0; i &lt; glyphBuffer-&gt;size(); ++i)
-        w += glyphBuffer-&gt;advanceAt(i);
-    width = w;
-    return !glyphBuffer-&gt;isEmpty();
-}
-
-UChar32 WidthIterator::normalizeVoicingMarks(int currentCharacter)
-{
-    if (currentCharacter + 1 &lt; m_end) {
-        if (combiningClass(m_run[currentCharacter + 1]) == hiraganaKatakanaVoicingMarksCombiningClass) {
-#if USE(ICU_UNICODE)
-            // Normalize into composed form using 3.2 rules.
-            UChar normalizedCharacters[2] = { 0, 0 };
-            UErrorCode uStatus = U_ZERO_ERROR;  
-            int32_t resultLength = unorm_normalize(m_run.data(currentCharacter), 2,
-                UNORM_NFC, UNORM_UNICODE_3_2, &amp;normalizedCharacters[0], 2, &amp;uStatus);
-            if (resultLength == 1 &amp;&amp; uStatus == 0)
-                return normalizedCharacters[0];
-#elif USE(QT4_UNICODE)
-            QString tmp(reinterpret_cast&lt;const QChar*&gt;(m_run.data(currentCharacter)), 2);
-            QString res = tmp.normalized(QString::NormalizationForm_C, QChar::Unicode_3_2);
-            if (res.length() == 1)
-                return res.at(0).unicode();
-#endif
-        }
-    }
-    return 0;
-}
-
</del><span class="cx"> // ============================================================================================
</span><span class="cx"> // Font Implementation (Cross-Platform Portion)
</span><span class="cx"> // ============================================================================================
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsWidthIteratorcpp"></a>
<div class="addfile"><h4>Added: trunk/WebCore/platform/graphics/WidthIterator.cpp (0 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/WidthIterator.cpp                                (rev 0)
+++ trunk/WebCore/platform/graphics/WidthIterator.cpp        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -0,0 +1,230 @@
</span><ins>+/*
+ * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include &quot;config.h&quot;
+#include &quot;WidthIterator.h&quot;
+
+#include &quot;Font.h&quot;
+#include &quot;GlyphBuffer.h&quot;
+#include &quot;SimpleFontData.h&quot;
+#include &lt;wtf/MathExtras.h&gt;
+
+#if USE(ICU_UNICODE)
+#include &lt;unicode/unorm.h&gt;
+#endif
+
+using namespace WTF;
+using namespace Unicode;
+
+namespace WebCore {
+
+// According to http://www.unicode.org/Public/UNIDATA/UCD.html#Canonical_Combining_Class_Values
+static const uint8_t hiraganaKatakanaVoicingMarksCombiningClass = 8;
+
+WidthIterator::WidthIterator(const Font* font, const TextRun&amp; run)
+    : m_font(font)
+    , m_run(run)
+    , m_end(run.length())
+    , m_currentCharacter(0)
+    , m_runWidthSoFar(0)
+    , m_finalRoundingWidth(0)
+{
+    // If the padding is non-zero, count the number of spaces in the run
+    // and divide that by the padding for per space addition.
+    m_padding = m_run.padding();
+    if (!m_padding)
+        m_padPerSpace = 0;
+    else {
+        float numSpaces = 0;
+        for (int i = 0; i &lt; run.length(); i++)
+            if (Font::treatAsSpace(m_run[i]))
+                numSpaces++;
+
+        if (numSpaces == 0)
+            m_padPerSpace = 0;
+        else
+            m_padPerSpace = ceilf(m_run.padding() / numSpaces);
+    }
+}
+
+void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
+{
+    if (offset &gt; m_end)
+        offset = m_end;
+
+    int currentCharacter = m_currentCharacter;
+    const UChar* cp = m_run.data(currentCharacter);
+
+    bool rtl = m_run.rtl();
+    bool hasExtraSpacing = (m_font-&gt;letterSpacing() || m_font-&gt;wordSpacing() || m_padding) &amp;&amp; !m_run.spacingDisabled();
+
+    float runWidthSoFar = m_runWidthSoFar;
+    float lastRoundingWidth = m_finalRoundingWidth;
+    
+    while (currentCharacter &lt; offset) {
+        UChar32 c = *cp;
+        unsigned clusterLength = 1;
+        if (c &gt;= 0x3041) {
+            if (c &lt;= 0x30FE) {
+                // Deal with Hiragana and Katakana voiced and semi-voiced syllables.
+                // Normalize into composed form, and then look for glyph with base + combined mark.
+                // Check above for character range to minimize performance impact.
+                UChar32 normalized = normalizeVoicingMarks(currentCharacter);
+                if (normalized) {
+                    c = normalized;
+                    clusterLength = 2;
+                }
+            } else if (U16_IS_SURROGATE(c)) {
+                if (!U16_IS_SURROGATE_LEAD(c))
+                    break;
+
+                // Do we have a surrogate pair?  If so, determine the full Unicode (32 bit)
+                // code point before glyph lookup.
+                // Make sure we have another character and it's a low surrogate.
+                if (currentCharacter + 1 &gt;= m_run.length())
+                    break;
+                UChar low = cp[1];
+                if (!U16_IS_TRAIL(low))
+                    break;
+                c = U16_GET_SUPPLEMENTARY(c, low);
+                clusterLength = 2;
+            }
+        }
+
+        const GlyphData&amp; glyphData = m_font-&gt;glyphDataForCharacter(c, rtl);
+        Glyph glyph = glyphData.glyph;
+        const SimpleFontData* fontData = glyphData.fontData;
+
+        ASSERT(fontData);
+
+        // Now that we have a glyph and font data, get its width.
+        float width;
+        if (c == '\t' &amp;&amp; m_run.allowTabs()) {
+            float tabWidth = m_font-&gt;tabWidth();
+            width = tabWidth - fmodf(m_run.xPos() + runWidthSoFar, tabWidth);
+        } else {
+            width = fontData-&gt;widthForGlyph(glyph);
+            // We special case spaces in two ways when applying word rounding.
+            // First, we round spaces to an adjusted width in all fonts.
+            // Second, in fixed-pitch fonts we ensure that all characters that
+            // match the width of the space character have the same width as the space character.
+            if (width == fontData-&gt;m_spaceWidth &amp;&amp; (fontData-&gt;m_treatAsFixedPitch || glyph == fontData-&gt;m_spaceGlyph) &amp;&amp; m_run.applyWordRounding())
+                width = fontData-&gt;m_adjustedSpaceWidth;
+        }
+
+        if (hasExtraSpacing) {
+            // Account for letter-spacing.
+            if (width &amp;&amp; m_font-&gt;letterSpacing())
+                width += m_font-&gt;letterSpacing();
+
+            if (Font::treatAsSpace(c)) {
+                // Account for padding. WebCore uses space padding to justify text.
+                // We distribute the specified padding over the available spaces in the run.
+                if (m_padding) {
+                    // Use left over padding if not evenly divisible by number of spaces.
+                    if (m_padding &lt; m_padPerSpace) {
+                        width += m_padding;
+                        m_padding = 0;
+                    } else {
+                        width += m_padPerSpace;
+                        m_padding -= m_padPerSpace;
+                    }
+                }
+
+                // Account for word spacing.
+                // We apply additional space between &quot;words&quot; by adding width to the space character.
+                if (currentCharacter != 0 &amp;&amp; !Font::treatAsSpace(cp[-1]) &amp;&amp; m_font-&gt;wordSpacing())
+                    width += m_font-&gt;wordSpacing();
+            }
+        }
+
+        // Advance past the character we just dealt with.
+        cp += clusterLength;
+        currentCharacter += clusterLength;
+
+        // Account for float/integer impedance mismatch between CG and KHTML. &quot;Words&quot; (characters 
+        // followed by a character defined by isRoundingHackCharacter()) are always an integer width.
+        // We adjust the width of the last character of a &quot;word&quot; to ensure an integer width.
+        // If we move KHTML to floats we can remove this (and related) hacks.
+
+        float oldWidth = width;
+
+        // Force characters that are used to determine word boundaries for the rounding hack
+        // to be integer width, so following words will start on an integer boundary.
+        if (m_run.applyWordRounding() &amp;&amp; Font::isRoundingHackCharacter(c))
+            width = ceilf(width);
+
+        // Check to see if the next character is a &quot;rounding hack character&quot;, if so, adjust
+        // width so that the total run width will be on an integer boundary.
+        if ((m_run.applyWordRounding() &amp;&amp; currentCharacter &lt; m_run.length() &amp;&amp; Font::isRoundingHackCharacter(*cp))
+                || (m_run.applyRunRounding() &amp;&amp; currentCharacter &gt;= m_end)) {
+            float totalWidth = runWidthSoFar + width;
+            width += ceilf(totalWidth) - totalWidth;
+        }
+
+        runWidthSoFar += width;
+
+        if (glyphBuffer)
+            glyphBuffer-&gt;add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
+
+        lastRoundingWidth = width - oldWidth;
+    }
+
+    m_currentCharacter = currentCharacter;
+    m_runWidthSoFar = runWidthSoFar;
+    m_finalRoundingWidth = lastRoundingWidth;
+}
+
+bool WidthIterator::advanceOneCharacter(float&amp; width, GlyphBuffer* glyphBuffer)
+{
+    glyphBuffer-&gt;clear();
+    advance(m_currentCharacter + 1, glyphBuffer);
+    float w = 0;
+    for (int i = 0; i &lt; glyphBuffer-&gt;size(); ++i)
+        w += glyphBuffer-&gt;advanceAt(i);
+    width = w;
+    return !glyphBuffer-&gt;isEmpty();
+}
+
+UChar32 WidthIterator::normalizeVoicingMarks(int currentCharacter)
+{
+    if (currentCharacter + 1 &lt; m_end) {
+        if (combiningClass(m_run[currentCharacter + 1]) == hiraganaKatakanaVoicingMarksCombiningClass) {
+#if USE(ICU_UNICODE)
+            // Normalize into composed form using 3.2 rules.
+            UChar normalizedCharacters[2] = { 0, 0 };
+            UErrorCode uStatus = U_ZERO_ERROR;  
+            int32_t resultLength = unorm_normalize(m_run.data(currentCharacter), 2,
+                UNORM_NFC, UNORM_UNICODE_3_2, &amp;normalizedCharacters[0], 2, &amp;uStatus);
+            if (resultLength == 1 &amp;&amp; uStatus == 0)
+                return normalizedCharacters[0];
+#elif USE(QT4_UNICODE)
+            QString tmp(reinterpret_cast&lt;const QChar*&gt;(m_run.data(currentCharacter)), 2);
+            QString res = tmp.normalized(QString::NormalizationForm_C, QChar::Unicode_3_2);
+            if (res.length() == 1)
+                return res.at(0).unicode();
+#endif
+        }
+    }
+    return 0;
+}
+
+}
</ins><span class="cx">Property changes on: trunk/WebCore/platform/graphics/WidthIterator.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkWebCoreplatformgraphicsWidthIteratorh"></a>
<div class="addfile"><h4>Added: trunk/WebCore/platform/graphics/WidthIterator.h (0 => 37550)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/WidthIterator.h                                (rev 0)
+++ trunk/WebCore/platform/graphics/WidthIterator.h        2008-10-13 01:37:13 UTC (rev 37550)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WidthIterator_h
+#define WidthIterator_h
+
+#include &lt;wtf/unicode/Unicode.h&gt;
+
+namespace WebCore {
+
+class Font;
+class GlyphBuffer;
+class TextRun;
+
+struct WidthIterator {
+    WidthIterator(const Font*, const TextRun&amp;);
+
+    void advance(int to, GlyphBuffer* = 0);
+    bool advanceOneCharacter(float&amp; width, GlyphBuffer* = 0);
+
+    const Font* m_font;
+
+    const TextRun&amp; m_run;
+    int m_end;
+
+    unsigned m_currentCharacter;
+    float m_runWidthSoFar;
+    float m_padding;
+    float m_padPerSpace;
+    float m_finalRoundingWidth;
+
+private:
+    UChar32 normalizeVoicingMarks(int currentCharacter);
+};
+
+}
+
+#endif
</ins><span class="cx">Property changes on: trunk/WebCore/platform/graphics/WidthIterator.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
</div>

</body>
</html>