[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

brettw at chromium.org brettw at chromium.org
Wed Dec 22 11:30:52 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 08a103e4515d0bd46cdcc95518be5876130d1b06
Author: brettw at chromium.org <brettw at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jul 27 21:30:36 2010 +0000

    2010-07-27  Brett Wilson  <brettw at chromium.org>
    
            Reviewed by Darin Fisher.
    
            Add the ability to select fonts and do basic text drawing to the
            Chromium WebKit API.
            https://bugs.webkit.org/show_bug.cgi?id=42999
    
            * WebKit.gyp:
            * public/WebFloatPoint.h: Added.
            (WebKit::WebFloatPoint::WebFloatPoint):
            (WebKit::WebFloatPoint::operator=):
            (WebKit::WebFloatPoint::operator WebCore::FloatPoint):
            (WebKit::operator==):
            (WebKit::operator!=):
            * public/WebFloatRect.h: Added.
            (WebKit::WebFloatRect::isEmpty):
            (WebKit::WebFloatRect::WebFloatRect):
            (WebKit::WebFloatRect::operator=):
            (WebKit::WebFloatRect::operator WebCore::FloatRect):
            (WebKit::operator==):
            (WebKit::operator!=):
            * public/WebFont.h: Added.
            * public/WebFontDescription.h: Added.
            (WebKit::WebFontDescription::):
            (WebKit::WebFontDescription::WebFontDescription):
            * public/WebTextRun.h: Added.
            (WebKit::WebTextRun::WebTextRun):
            * src/AssertMatchingEnums.cpp:
            * src/WebFontDescription.cpp: Added.
            (WebKit::WebFontDescription::WebFontDescription):
            (WebKit::WebFontDescription::operator WebCore::FontDescription):
            * src/WebFontImpl.cpp: Added.
            (WebKit::WebFont::Create):
            (WebKit::WebFontImpl::WebFontImpl):
            (WebKit::WebFontImpl::fontDescription):
            (WebKit::WebFontImpl::ascent):
            (WebKit::WebFontImpl::descent):
            (WebKit::WebFontImpl::height):
            (WebKit::WebFontImpl::lineSpacing):
            (WebKit::WebFontImpl::xHeight):
            (WebKit::WebFontImpl::drawText):
            (WebKit::WebFontImpl::computeWidth):
            (WebKit::WebFontImpl::offsetForPosition):
            (WebKit::WebFontImpl::selectionRectForText):
            * src/WebFontImpl.h: Added.
            * src/WebTextRun.cpp: Added.
            (WebKit::WebTextRun::operator WebCore::TextRun):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64160 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 74d92db..e6b2b9c 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,52 @@
+2010-07-27  Brett Wilson  <brettw at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Add the ability to select fonts and do basic text drawing to the
+        Chromium WebKit API.
+        https://bugs.webkit.org/show_bug.cgi?id=42999
+
+        * WebKit.gyp:
+        * public/WebFloatPoint.h: Added.
+        (WebKit::WebFloatPoint::WebFloatPoint):
+        (WebKit::WebFloatPoint::operator=):
+        (WebKit::WebFloatPoint::operator WebCore::FloatPoint):
+        (WebKit::operator==):
+        (WebKit::operator!=):
+        * public/WebFloatRect.h: Added.
+        (WebKit::WebFloatRect::isEmpty):
+        (WebKit::WebFloatRect::WebFloatRect):
+        (WebKit::WebFloatRect::operator=):
+        (WebKit::WebFloatRect::operator WebCore::FloatRect):
+        (WebKit::operator==):
+        (WebKit::operator!=):
+        * public/WebFont.h: Added.
+        * public/WebFontDescription.h: Added.
+        (WebKit::WebFontDescription::):
+        (WebKit::WebFontDescription::WebFontDescription):
+        * public/WebTextRun.h: Added.
+        (WebKit::WebTextRun::WebTextRun):
+        * src/AssertMatchingEnums.cpp:
+        * src/WebFontDescription.cpp: Added.
+        (WebKit::WebFontDescription::WebFontDescription):
+        (WebKit::WebFontDescription::operator WebCore::FontDescription):
+        * src/WebFontImpl.cpp: Added.
+        (WebKit::WebFont::Create):
+        (WebKit::WebFontImpl::WebFontImpl):
+        (WebKit::WebFontImpl::fontDescription):
+        (WebKit::WebFontImpl::ascent):
+        (WebKit::WebFontImpl::descent):
+        (WebKit::WebFontImpl::height):
+        (WebKit::WebFontImpl::lineSpacing):
+        (WebKit::WebFontImpl::xHeight):
+        (WebKit::WebFontImpl::drawText):
+        (WebKit::WebFontImpl::width):
+        (WebKit::WebFontImpl::offsetForPosition):
+        (WebKit::WebFontImpl::selectionRectForText):
+        * src/WebFontImpl.h: Added.
+        * src/WebTextRun.cpp: Added.
+        (WebKit::WebTextRun::operator WebCore::TextRun):
+
 2010-07-27  Dumitru Daniliuc  <dumi at chromium.org>
 
         Reviewed by David Levin.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index 795abbb..97efddc 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -156,6 +156,10 @@
                 'public/WebFileInfo.h',
                 'public/WebFileSystem.h',
                 'public/WebFindOptions.h',
+                'public/WebFloatPoint.h',
+                'public/WebFloatRect.h',
+                'public/WebFont.h',
+                'public/WebFontDescription.h',
                 'public/WebFrame.h',
                 'public/WebFrameClient.h',
                 'public/WebFontCache.h',
@@ -247,6 +251,7 @@
                 'public/WebTextCaseSensitivity.h',
                 'public/WebTextDirection.h',
                 'public/WebTextInputType.h',
+                'public/WebTextRun.h',
                 'public/WebThemeEngine.h',
                 'public/WebURL.h',
                 'public/WebURLError.h',
@@ -391,6 +396,9 @@
                 'src/WebFileChooserCompletionImpl.cpp',
                 'src/WebFileChooserCompletionImpl.h',
                 'src/WebFontCache.cpp',
+                'src/WebFontDescription.cpp',
+                'src/WebFontImpl.cpp',
+                'src/WebFontImpl.h',
                 'src/WebFormControlElement.cpp',
                 'src/WebFormElement.cpp',
                 'src/WebFrameImpl.cpp',
@@ -472,6 +480,7 @@
                 'src/WebStorageNamespaceImpl.cpp',
                 'src/WebStorageNamespaceImpl.h',
                 'src/WebString.cpp',
+                'src/WebTextRun.cpp',
                 'src/WebURL.cpp',
                 'src/WebURLLoadTiming.cpp',
                 'src/WebURLRequest.cpp',
diff --git a/WebKit/chromium/public/WebFloatPoint.h b/WebKit/chromium/public/WebFloatPoint.h
new file mode 100644
index 0000000..c053ed6
--- /dev/null
+++ b/WebKit/chromium/public/WebFloatPoint.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebFloatPoint_h
+#define WebFloatPoint_h
+
+#include "WebCommon.h"
+
+#if WEBKIT_IMPLEMENTATION
+#include "IntPoint.h"
+#endif
+
+namespace WebKit {
+
+struct WebFloatPoint {
+    float x;
+    float y;
+
+    WebFloatPoint()
+        : x(0.0f)
+        , y(0.0f)
+    {
+    }
+
+    WebFloatPoint(float x, float y)
+        : x(x)
+        , y(y)
+    {
+    }
+
+#if WEBKIT_IMPLEMENTATION
+    WebFloatPoint(const WebCore::FloatPoint& p)
+        : x(p.x())
+        , y(p.y())
+    {
+    }
+
+    WebFloatPoint& operator=(const WebCore::FloatPoint& p)
+    {
+        x = p.x();
+        y = p.y();
+        return *this;
+    }
+
+    operator WebCore::FloatPoint() const
+    {
+        return WebCore::FloatPoint(x, y);
+    }
+#endif
+};
+
+inline bool operator==(const WebFloatPoint& a, const WebFloatPoint& b)
+{
+    return a.x == b.x && a.y == b.y;
+}
+
+inline bool operator!=(const WebFloatPoint& a, const WebFloatPoint& b)
+{
+    return !(a == b);
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/public/WebFloatRect.h b/WebKit/chromium/public/WebFloatRect.h
new file mode 100644
index 0000000..a883513
--- /dev/null
+++ b/WebKit/chromium/public/WebFloatRect.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebFloatRect_h
+#define WebFloatRect_h
+
+#include "WebCommon.h"
+
+#if WEBKIT_IMPLEMENTATION
+#include "FloatRect.h"
+#endif
+
+namespace WebKit {
+
+struct WebFloatRect {
+    float x;
+    float y;
+    float width;
+    float height;
+
+    bool isEmpty() const { return width <= 0 || height <= 0; }
+
+    WebFloatRect()
+        : x(0.0f)
+        , y(0.0f)
+        , width(0.0f)
+        , height(0.0f)
+    {
+    }
+
+    WebFloatRect(float x, float y, float width, float height)
+        : x(x)
+        , y(y)
+        , width(width)
+        , height(height)
+    {
+    }
+
+#if WEBKIT_IMPLEMENTATION
+    WebFloatRect(const WebCore::FloatRect& r)
+        : x(r.x())
+        , y(r.y())
+        , width(r.width())
+        , height(r.height())
+    {
+    }
+
+    WebFloatRect& operator=(const WebCore::FloatRect& r)
+    {
+        x = r.x();
+        y = r.y();
+        width = r.width();
+        height = r.height();
+        return *this;
+    }
+
+    operator WebCore::FloatRect() const
+    {
+        return WebCore::FloatRect(x, y, width, height);
+    }
+#endif
+};
+
+inline bool operator==(const WebFloatRect& a, const WebFloatRect& b)
+{
+    return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
+}
+
+inline bool operator!=(const WebFloatRect& a, const WebFloatRect& b)
+{
+    return !(a == b);
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/public/WebFont.h b/WebKit/chromium/public/WebFont.h
new file mode 100644
index 0000000..f5b7de1
--- /dev/null
+++ b/WebKit/chromium/public/WebFont.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebFont_h
+#define WebFont_h
+
+#include "WebCanvas.h"
+#include "WebColor.h"
+#include "WebCommon.h"
+
+namespace WebKit {
+
+class WebFontDescription;
+class WebFloatPoint;
+class WebFloatRect;
+class WebPoint;
+class WebRect;
+struct WebTextRun;
+
+class WebFont {
+public:
+    virtual ~WebFont() { }
+
+    WEBKIT_API static WebFont* create(const WebFontDescription&);
+
+    virtual WebFontDescription fontDescription() const = 0;
+
+    virtual int ascent() const = 0;
+    virtual int descent() const = 0;
+    virtual int height() const = 0;
+    virtual int lineSpacing() const = 0;
+    virtual float xHeight() const = 0;
+
+    // Draws the text run to the given canvas. The text is positioned at the
+    // given left-hand point at the baseline.
+    //
+    // The text will be clipped to the given clip rect. |canvasIsOpaque| is
+    // used to control whether subpixel antialiasing is possible. If there is a
+    // possibility the area drawn could be semi-transparent, subpixel
+    // antialiasing will be disabled.
+    //
+    // |from| and |to| allow the caller to specify a subrange of the given text
+    // run to draw. If |to| is -1, the entire run will be drawn.
+    virtual void drawText(WebCanvas*, const WebTextRun&, const WebFloatPoint& leftBaseline, WebColor,
+                          const WebRect& clip, bool canvasIsOpaque,
+                          int from = 0, int to = -1) const = 0;
+
+    // Measures the width in pixels of the given text run.
+    virtual int calculateWidth(const WebTextRun&) const = 0;
+
+    // Returns the character offset corresponding to the given horizontal pixel
+    // position as measured from from the left of the run.
+    virtual int offsetForPosition(const WebTextRun&, float position) const = 0;
+
+    // Returns the rectangle representing the selection rect for the subrange
+    // |from| -> |to| of the given text run. You can use -1 for |to| to specify
+    // the entire run (this will do something similar to calling width()).
+    //
+    // The rect will be positioned as if the text was drawn at the given
+    // |leftBaseline| position. |height| indicates the height of the selection
+    // rect you want, typically this will just be the height() of this font.
+    //
+    // To get the pixel offset of some character (the opposite of
+    // offsetForPosition()), pass in a |leftBaseline| = (0, 0), |from| = 0, and
+    // |to| = the character you want. The right edge of the resulting selection
+    // rect will tell you the right side of the character.
+    virtual WebFloatRect selectionRectForText(const WebTextRun&, const WebFloatPoint& leftBaseline,
+                                              int height, int from = 0, int to = -1) const = 0;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/public/WebFontDescription.h b/WebKit/chromium/public/WebFontDescription.h
new file mode 100644
index 0000000..d4bb07e
--- /dev/null
+++ b/WebKit/chromium/public/WebFontDescription.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebFontDescription_h
+#define WebFontDescription_h
+
+#include "WebString.h"
+
+#if WEBKIT_IMPLEMENTATION
+namespace WebCore { class FontDescription; }
+#endif
+
+namespace WebKit {
+
+struct WebFontDescription {
+    enum GenericFamily {
+        GenericFamilyNone,
+        GenericFamilyStandard,
+        GenericFamilySerif,
+        GenericFamilySansSerif,
+        GenericFamilyMonospace,
+        GenericFamilyCursive,
+        GenericFamilyFantasy
+    };
+
+    enum Smoothing {
+        SmoothingAuto,
+        SmoothingNone,
+        SmoothingGrayscale,
+        SmoothingSubpixel
+    };
+
+    enum Weight { 
+        Weight100,
+        Weight200,
+        Weight300,
+        Weight400,
+        Weight500,
+        Weight600,
+        Weight700,
+        Weight800,
+        Weight900,
+        WeightNormal = Weight400,
+        WeightBold = Weight700
+    };
+
+    WebFontDescription()
+        : genericFamily(GenericFamilyNone)
+        , size(0)
+        , italic(false)
+        , smallCaps(false)
+        , weight(WeightNormal)
+        , smoothing(SmoothingAuto)
+        , letterSpacing(0)
+        , wordSpacing(0)
+    {
+    }
+
+    WebString family;
+    GenericFamily genericFamily;
+    float size;
+    bool italic;
+    bool smallCaps;
+    Weight weight;
+    Smoothing smoothing;
+
+    short letterSpacing;
+    short wordSpacing;
+
+#if WEBKIT_IMPLEMENTATION
+    WebFontDescription(const WebCore::FontDescription&, short fontLetterSpacing, short fontWordSpacing);
+
+    operator WebCore::FontDescription() const;
+#endif
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/public/WebTextRun.h b/WebKit/chromium/public/WebTextRun.h
new file mode 100644
index 0000000..cb1373a
--- /dev/null
+++ b/WebKit/chromium/public/WebTextRun.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebTextRun_h
+#define WebTextRun_h
+
+#include "WebString.h"
+
+#ifdef WEBKIT_IMPLEMENTATION
+namespace WebCore { class TextRun; }
+#endif
+
+namespace WebKit {
+
+struct WebTextRun {
+    WebTextRun(const WebString& t, bool isRTL, bool hasDirectionalOverride)
+        : text(t)
+        , rtl(isRTL)
+        , directionalOverride(hasDirectionalOverride)
+    {
+    }
+    WebTextRun()
+        : rtl(false)
+        , directionalOverride(false)
+    {
+    }
+
+    WebString text;
+    bool rtl;
+    bool directionalOverride;
+
+#ifdef WEBKIT_IMPLEMENTATION
+    // The resulting WebCore::TextRun will refer to the text in this
+    // struct, so "this" must outlive the WebCore text run.
+    operator WebCore::TextRun() const;
+#endif
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/AssertMatchingEnums.cpp b/WebKit/chromium/src/AssertMatchingEnums.cpp
index 1f946f3..093ac11 100644
--- a/WebKit/chromium/src/AssertMatchingEnums.cpp
+++ b/WebKit/chromium/src/AssertMatchingEnums.cpp
@@ -36,6 +36,8 @@
 #include "AccessibilityObject.h"
 #include "ApplicationCacheHost.h"
 #include "EditorInsertAction.h"
+#include "FontDescription.h"
+#include "FontSmoothingMode.h"
 #include "HTMLInputElement.h"
 #include "IDBKey.h"
 #include "MediaPlayer.h"
@@ -52,6 +54,7 @@
 #include "WebClipboard.h"
 #include "WebCursorInfo.h"
 #include "WebEditingAction.h"
+#include "WebFontDescription.h"
 #include "WebIDBKey.h"
 #include "WebInputElement.h"
 #include "WebMediaPlayer.h"
@@ -235,6 +238,31 @@ COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionTyped, EditorInsertActionTyped);
 COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionPasted, EditorInsertActionPasted);
 COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped);
 
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyNone, FontDescription::NoFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyStandard, FontDescription::StandardFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilySerif, FontDescription::SerifFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilySansSerif, FontDescription::SansSerifFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyMonospace, FontDescription::MonospaceFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyCursive, FontDescription::CursiveFamily);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::GenericFamilyFantasy, FontDescription::FantasyFamily);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingAuto, AutoSmoothing);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingNone, NoSmoothing);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingGrayscale, Antialiased);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::SmoothingSubpixel, SubpixelAntialiased);
+
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight100, FontWeight100);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight200, FontWeight200);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight300, FontWeight300);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight400, FontWeight400);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight500, FontWeight500);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight600, FontWeight600);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight700, FontWeight700);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight800, FontWeight800);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::Weight900, FontWeight900);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::WeightNormal, FontWeightNormal);
+COMPILE_ASSERT_MATCHING_ENUM(WebFontDescription::WeightBold, FontWeightBold);
+
 COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Text, HTMLInputElement::TEXT);
 COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Password, HTMLInputElement::PASSWORD);
 COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::IsIndex, HTMLInputElement::ISINDEX);
@@ -326,3 +354,5 @@ COMPILE_ASSERT_MATCHING_ENUM(WebView::UserContentInjectInTopFrameOnly, InjectInT
 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::NullType, IDBKey::NullType);
 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::StringType, IDBKey::StringType);
 COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::NumberType, IDBKey::NumberType);
+
+
diff --git a/WebKit/chromium/src/WebFontDescription.cpp b/WebKit/chromium/src/WebFontDescription.cpp
new file mode 100644
index 0000000..18f6830
--- /dev/null
+++ b/WebKit/chromium/src/WebFontDescription.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebFontDescription.h"
+
+#include "FontDescription.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebFontDescription::WebFontDescription(const FontDescription& desc,
+                                       short fontLetterSpacing, short fontWordSpacing)
+{
+    family = desc.family().family();
+    genericFamily = static_cast<GenericFamily>(desc.genericFamily());
+    size = desc.specifiedSize();
+    italic = desc.italic();
+    smallCaps = desc.smallCaps();
+    weight = static_cast<Weight>(desc.weight());
+    smoothing = static_cast<Smoothing>(desc.fontSmoothing());
+    letterSpacing = fontLetterSpacing;
+    wordSpacing = fontWordSpacing;
+}
+
+WebFontDescription::operator WebCore::FontDescription() const
+{
+    FontFamily fontFamily;
+    fontFamily.setFamily(family);
+
+    FontDescription desc;
+    desc.setFamily(fontFamily);
+    desc.setGenericFamily(static_cast<FontDescription::GenericFamilyType>(genericFamily));
+    desc.setSpecifiedSize(size);
+    desc.setComputedSize(size);
+    desc.setItalic(italic);
+    desc.setSmallCaps(smallCaps);
+    desc.setWeight(static_cast<FontWeight>(weight));
+    desc.setFontSmoothing(static_cast<FontSmoothingMode>(smoothing));
+    return desc;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebFontImpl.cpp b/WebKit/chromium/src/WebFontImpl.cpp
new file mode 100644
index 0000000..6fa5494
--- /dev/null
+++ b/WebKit/chromium/src/WebFontImpl.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebFontImpl.h"
+
+#include "Font.h"
+#include "FontDescription.h"
+#include "GraphicsContext.h"
+#include "PlatformContextSkia.h"
+#include "WebFloatPoint.h"
+#include "WebFloatRect.h"
+#include "WebFontDescription.h"
+#include "WebRect.h"
+#include "WebTextRun.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebFont* WebFont::create(const WebFontDescription& desc)
+{
+    return new WebFontImpl(desc, desc.letterSpacing, desc.wordSpacing);
+}
+
+WebFontImpl::WebFontImpl(const FontDescription& desc, short letterSpacing, short wordSpacing)
+    : m_font(desc, letterSpacing, wordSpacing)
+{
+    m_font.update(0);
+}
+
+WebFontDescription WebFontImpl::fontDescription() const
+{
+    return WebFontDescription(m_font.fontDescription(), m_font.letterSpacing(), m_font.wordSpacing());
+}
+
+int WebFontImpl::ascent() const
+{
+    return m_font.ascent();
+}
+
+int WebFontImpl::descent() const
+{
+    return m_font.descent();
+}
+
+int WebFontImpl::height() const
+{
+    return m_font.height();
+}
+
+int WebFontImpl::lineSpacing() const
+{
+    return m_font.lineSpacing();
+}
+
+float WebFontImpl::xHeight() const
+{
+    return m_font.xHeight();
+}
+
+void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFloatPoint& leftBaseline,
+                           WebColor color, const WebRect& clip, bool canvasIsOpaque,
+                           int from, int to) const
+{
+    // FIXME hook canvasIsOpaque up to the platform-specific indicators for
+    // whether subpixel AA can be used for this draw. On Windows, this is
+    // PlatformContextSkia::setDrawingToImageBuffer.
+#if WEBKIT_USING_CG
+    GraphicsContext gc(canvas);
+#elif WEBKIT_USING_SKIA
+    PlatformContextSkia context(canvas);
+    // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
+    GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+#else
+    notImplemented();
+#endif
+
+    gc.setFillColor(color, DeviceColorSpace);
+    gc.clip(WebCore::FloatRect(clip));
+    m_font.drawText(&gc, run, leftBaseline, from, to);
+}
+
+int WebFontImpl::calculateWidth(const WebTextRun& run) const
+{
+    return m_font.width(run, 0);
+}
+
+int WebFontImpl::offsetForPosition(const WebTextRun& run, float position) const
+{
+    return m_font.offsetForPosition(run, position, true);
+}
+
+WebFloatRect WebFontImpl::selectionRectForText(const WebTextRun& run, const WebFloatPoint& leftBaseline, int height, int from, int to) const
+{
+    return m_font.selectionRectForText(run, leftBaseline, height, from, to);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebFontImpl.h b/WebKit/chromium/src/WebFontImpl.h
new file mode 100644
index 0000000..3ac9031
--- /dev/null
+++ b/WebKit/chromium/src/WebFontImpl.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebFontImpl_h
+#define WebFontImpl_h
+
+#include "Font.h"
+#include "WebFont.h"
+
+namespace WebCore { class FontDescription; }
+
+namespace WebKit {
+
+class WebFontImpl : public WebFont {
+public:
+    WebFontImpl(const WebCore::FontDescription&, short letterSpacing, short wordSpacing);
+
+    virtual WebFontDescription fontDescription() const;
+
+    virtual int ascent() const;
+    virtual int descent() const;
+    virtual int height() const;
+    virtual int lineSpacing() const;
+    virtual float xHeight() const;
+
+    virtual void drawText(WebCanvas*, const WebTextRun&, const WebFloatPoint& leftBaseline, WebColor,
+                          const WebRect& clip, bool canvasIsOpaque, int from = 0, int to = -1) const;
+    virtual int calculateWidth(const WebTextRun&) const;
+    virtual int offsetForPosition(const WebTextRun&, float position) const;
+    virtual WebFloatRect selectionRectForText(const WebTextRun&, const WebFloatPoint& leftBaseline,
+                                              int height, int from = 0, int to = -1) const;
+
+private:
+    WebCore::Font m_font;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebTextRun.cpp b/WebKit/chromium/src/WebTextRun.cpp
new file mode 100644
index 0000000..58d9fac
--- /dev/null
+++ b/WebKit/chromium/src/WebTextRun.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebTextRun.h"
+
+#include "TextRun.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebTextRun::operator WebCore::TextRun() const
+{
+    return TextRun(text, false, 0, 0, rtl, directionalOverride);
+}
+
+} // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list