Commit 648b73b1 authored by mitz@apple.com's avatar mitz@apple.com

WebCore:

        Reviewed by Dave Hyatt.

        - <rdar://problem/5665216> Support the unicode-range property in @font-face rules

        * GNUmakefile.am:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * bindings/objc/DOM.mm:
        * bridge/mac/WebCoreAXObject.mm:
        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        * css/CSSFontFace.cpp:
        (WebCore::CSSFontFace::fontLoaded): Changed to call the owning segmented
        font face.
        (WebCore::CSSFontFace::getFontData):
        * css/CSSFontFace.h:
        (WebCore::CSSFontFace::CSSFontFace):
        (WebCore::CSSFontFace::setSegmentedFontFace):
        * css/CSSFontFaceSource.cpp:
        (WebCore::CSSFontFaceSource::pruneTable): Removed the calls to
        GlyphPageTreeNode::pruneTreeCustomFontData because the fonts in the
        font table are not exposed in the glyph page tree. Only the segmented
        font is, and that is taken care of by the segmented font face.
        (WebCore::CSSFontFaceSource::getFontData):
        * css/CSSFontFaceSource.h:
        * css/CSSFontSelector.cpp:
        (WebCore::CSSFontSelector::addFontFaceRule): Changed to collect
        @font-face rules with the same family and traits into a single
        segmented font face, instead of just retaining the most recent one.
        (WebCore::CSSFontSelector::fontLoaded):
        (WebCore::CSSFontSelector::getFontData):
        * css/CSSFontSelector.h:
        * css/CSSGrammar.y:
        * css/CSSParser.cpp:
        (WebCore::CSSParser::parseValue):
        (WebCore::CSSParser::parseFontFaceUnicodeRange): Added. Parses a unicode
        range value.
        * css/CSSParser.h:
        * css/CSSPrimitiveValue.h:
        (WebCore::CSSPrimitiveValue::):
        * css/CSSPropertyNames.in:
        * css/CSSSegmentedFontFace.cpp: Added.
        (WebCore::CSSSegmentedFontFace::CSSSegmentedFontFace):
        (WebCore::CSSSegmentedFontFace::~CSSSegmentedFontFace):
        (WebCore::CSSSegmentedFontFace::pruneTable):
        (WebCore::CSSSegmentedFontFace::isLoaded):
        (WebCore::CSSSegmentedFontFace::isValid):
        (WebCore::CSSSegmentedFontFace::fontLoaded):
        (WebCore::CSSSegmentedFontFace::overlayRange):
        (WebCore::CSSSegmentedFontFace::getFontData):
        * css/CSSSegmentedFontFace.h: Added.
        (WebCore::FontFaceRange::FontFaceRange):
        (WebCore::FontFaceRange::from):
        (WebCore::FontFaceRange::to):
        (WebCore::FontFaceRange::fontFace):
        (WebCore::CSSSegmentedFontFace::fontSelector):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applyProperty):
        * css/CSSUnicodeRangeValue.cpp: Added.
        (WebCore::CSSUnicodeRangeValue::~CSSUnicodeRangeValue):
        (WebCore::CSSUnicodeRangeValue::cssText):
        * css/CSSUnicodeRangeValue.h: Added.
        (WebCore::CSSUnicodeRangeValue::CSSUnicodeRangeValue):
        (WebCore::CSSUnicodeRangeValue::from):
        (WebCore::CSSUnicodeRangeValue::to):
        * css/SVGCSSFontFace.cpp:
        (WebCore::SVGCSSFontFace::getFontData):
        * css/SVGCSSFontFace.h:
        * editing/Editor.cpp:
        (WebCore::Editor::fontForSelection):
        * editing/Editor.h:
        * page/mac/FrameMac.mm:
        * page/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge fontForSelection:]):
        * platform/graphics/Font.cpp:
        (WebCore::WidthIterator::advance):
        (WebCore::Font::glyphDataForCharacter):
        (WebCore::Font::primaryFont): Changed to return the simple font data
        used for the space character.
        (WebCore::Font::fontDataAt):
        (WebCore::Font::fontDataForCharacters):
        (WebCore::Font::drawGlyphBuffer):
        * platform/graphics/Font.h:
        * platform/graphics/FontCache.cpp:
        (WebCore::FontCache::getCachedFontData):
        (WebCore::FontCache::getFontData):
        * platform/graphics/FontCache.h:
        * platform/graphics/FontData.cpp: Renamed to SimpleFontData.cpp
        * platform/graphics/FontData.h: Renamed to SimpleFontData.cpp.
        * platform/graphics/FontDataBaseClass.cpp: Added. This will be renamed
        FontData.cpp.
        (WebCore::FontData::~FontData):
        * platform/graphics/FontDataBaseClass.h: Added. This will be renamed
        FontData.h.
        * platform/graphics/FontFallbackList.cpp:
        (WebCore::FontFallbackList::determinePitch):
        (WebCore::FontFallbackList::fontDataAt):
        (WebCore::FontFallbackList::fontDataForCharacters):
        * platform/graphics/FontFallbackList.h:
        (WebCore::FontFallbackList::primaryFont):
        * platform/graphics/FontSelector.h:
        * platform/graphics/GlyphBuffer.h:
        (WebCore::GlyphBuffer::fontDataAt):
        (WebCore::GlyphBuffer::swap):
        (WebCore::GlyphBuffer::add):
        * platform/graphics/GlyphPageTreeNode.cpp:
        (WebCore::GlyphPageTreeNode::pruneTreeCustomFontData):
        (WebCore::GlyphPageTreeNode::initializePage): Added code to initialize
        pages for segmented font data.
        (WebCore::GlyphPageTreeNode::getChild):
        (WebCore::GlyphPageTreeNode::pruneCustomFontData):
        * platform/graphics/GlyphPageTreeNode.h:
        (WebCore::GlyphPage::setGlyphDataForCharacter):
        (WebCore::GlyphPage::setGlyphDataForIndex):
        (WebCore::GlyphPageTreeNode::getRootChild):
        * platform/graphics/SegmentedFontData.cpp: Added.
        (WebCore::SegmentedFontData::~SegmentedFontData):
        (WebCore::SegmentedFontData::fontDataForCharacter):
        (WebCore::SegmentedFontData::containsCharacters):
        (WebCore::SegmentedFontData::isCustomFont):
        (WebCore::SegmentedFontData::isLoading):
        (WebCore::SegmentedFontData::isSegmented):
        * platform/graphics/SegmentedFontData.h: Added.
        (WebCore::FontDataRange::FontDataRange):
        (WebCore::FontDataRange::from):
        (WebCore::FontDataRange::to):
        (WebCore::FontDataRange::fontData):
        (WebCore::SegmentedFontData::appendRange):
        (WebCore::SegmentedFontData::numRanges):
        (WebCore::SegmentedFontData::rangeAt):
        * platform/graphics/SimpleFontData.cpp: Copied from WebCore/platform/graphics/FontData.cpp.
        (WebCore::SimpleFontData::SimpleFontData):
        (WebCore::SimpleFontData::~SimpleFontData):
        (WebCore::SimpleFontData::ascent):
        (WebCore::SimpleFontData::descent):
        (WebCore::SimpleFontData::widthForGlyph):
        (WebCore::SimpleFontData::fontDataForCharacter):
        (WebCore::SimpleFontData::isSegmented):
        * platform/graphics/SimpleFontData.h: Copied from WebCore/platform/graphics/FontData.h.
        (WebCore::SimpleFontData::isCustomFont):
        (WebCore::SimpleFontData::isLoading):
        * platform/graphics/cairo/GraphicsContextCairo.cpp:
        (WebCore::GraphicsContext::setPlatformFont):
        * platform/graphics/gtk/FontCacheGtk.cpp:
        (WebCore::FontCache::getFontDataForCharacters):
        * platform/graphics/gtk/FontDataGtk.cpp: Renamed to
        SimpleFontDataGtk.cpp.
        * platform/graphics/gtk/FontGtk.cpp:
        (WebCore::Font::drawGlyphs):
        * platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp:
        (WebCore::GlyphPage::fill):
        * platform/graphics/gtk/SimpleFontDataGtk.cpp: Copied from WebCore/platform/graphics/gtk/FontDataGtk.cpp.
        (WebCore::SimpleFontData::platformInit):
        (WebCore::SimpleFontData::platformDestroy):
        (WebCore::SimpleFontData::smallCapsFontData):
        (WebCore::SimpleFontData::containsCharacters):
        (WebCore::SimpleFontData::determinePitch):
        (WebCore::SimpleFontData::platformWidthForGlyph):
        (WebCore::SimpleFontData::setFont):
        * platform/graphics/mac/FontCacheMac.mm:
        (WebCore::FontCache::getFontDataForCharacters):
        * platform/graphics/mac/FontDataMac.mm: Renamed to SimpleFontDataMac.mm.
        * platform/graphics/mac/FontMac.mm:
        (WebCore::initializeATSUStyle):
        (WebCore::overrideLayoutOperation):
        (WebCore::ATSULayoutParameters::initialize):
        (WebCore::Font::drawGlyphs):
        * platform/graphics/mac/GlyphPageTreeNodeMac.cpp:
        (WebCore::GlyphPage::fill):
        * platform/graphics/mac/SimpleFontDataMac.mm: Copied from WebCore/platform/graphics/mac/FontDataMac.mm.
        (WebCore::initFontData):
        (WebCore::SimpleFontData::platformInit):
        (WebCore::SimpleFontData::platformDestroy):
        (WebCore::SimpleFontData::smallCapsFontData):
        (WebCore::SimpleFontData::containsCharacters):
        (WebCore::SimpleFontData::determinePitch):
        (WebCore::SimpleFontData::platformWidthForGlyph):
        (WebCore::SimpleFontData::checkShapesArabic):
        * platform/graphics/qt/FontDataQt.cpp: Renamed to SimpleFontDataQt.cpp.
        * platform/graphics/qt/GlyphPageTreeNodeQt.cpp:
        (WebCore::GlyphPageTreeNode::pruneTreeCustomFontData):
        * platform/graphics/qt/SimpleFontDataQt.cpp: Copied from WebCore/platform/graphics/qt/FontDataQt.cpp.
        * platform/graphics/win/FontCacheWin.cpp:
        (WebCore::FontCache::getFontDataForCharacters):
        * platform/graphics/win/FontDataWin.cpp: Renamed to
        SimpleFontDataWin.cpp.
        * platform/graphics/win/FontWin.cpp:
        (WebCore::Font::drawGlyphs):
        * platform/graphics/win/GlyphPageTreeNodeWin.cpp:
        (WebCore::GlyphPage::fill):
        * platform/graphics/win/SimpleFontDataWin.cpp: Copied from WebCore/platform/graphics/win/FontDataWin.cpp.
        (WebCore::SimpleFontData::setShouldApplyMacAscentHack):
        (WebCore::SimpleFontData::platformInit):
        (WebCore::SimpleFontData::platformDestroy):
        (WebCore::SimpleFontData::smallCapsFontData):
        (WebCore::SimpleFontData::containsCharacters):
        (WebCore::SimpleFontData::determinePitch):
        (WebCore::SimpleFontData::platformWidthForGlyph):
        (WebCore::SimpleFontData::scriptFontProperties):
        * platform/graphics/wx/FontCacheWx.cpp:
        (WebCore::FontCache::getFontDataForCharacters):
        * platform/graphics/wx/FontDataWx.cpp: Renamed to SimpleFontDataWx.cpp.
        * platform/graphics/wx/FontWx.cpp:
        (WebCore::Font::drawGlyphs):
        * platform/graphics/wx/GlyphMapWx.cpp:
        (WebCore::GlyphPage::fill):
        * platform/graphics/wx/SimpleFontDataWx.cpp: Copied from WebCore/platform/graphics/wx/FontDataWx.cpp.
        (WebCore::SimpleFontData::platformInit):
        (WebCore::SimpleFontData::platformDestroy):
        (WebCore::SimpleFontData::smallCapsFontData):
        (WebCore::SimpleFontData::containsCharacters):
        (WebCore::SimpleFontData::determinePitch):
        (WebCore::SimpleFontData::platformWidthForGlyph):
        * platform/mac/FileChooserMac.mm:
        * platform/mac/PopupMenuMac.mm:
        * platform/mac/WebCoreTextRenderer.mm:
        * platform/win/PopupMenuWin.cpp:
        * platform/win/UniscribeController.cpp:
        (WebCore::UniscribeController::advance):
        (WebCore::UniscribeController::itemizeShapeAndPlace):
        (WebCore::UniscribeController::shapeAndPlaceItem):
        (WebCore::UniscribeController::shape):
        * platform/win/UniscribeController.h:
        * svg/SVGFont.cpp:
        (WebCore::Font::drawGlyphsWithSVGFont):
        * svg/SVGFontElement.cpp:
        (WebCore::SVGFontElement::collectGlyphs):
        * svg/SVGFontFaceElement.cpp:
        (WebCore::SVGFontFaceElement::createFontData):
        * svg/SVGFontFaceElement.h:
        * svg/SVGGlyphElement.cpp:

WebKit/mac:

        Reviewed by Dave Hyatt.

        - <rdar://problem/5665216> Support the unicode-range property in @font-face rules

        * Misc/WebNSAttributedStringExtras.mm:

WebKit/win:

        Reviewed by Dave Hyatt.

        - <rdar://problem/5665216> Support the unicode-range property in @font-face rules

        * WebView.cpp:
        (WebView::setShouldApplyMacFontAscentHack):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29250 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3406c238
This diff is collapsed.
......@@ -522,12 +522,14 @@ webcore_sources += \
WebCore/css/CSSRule.cpp \
WebCore/css/CSSRuleList.cpp \
WebCore/css/CSSSelector.cpp \
WebCore/css/CSSSegmentedFontFace.cpp \
WebCore/css/CSSStyleDeclaration.cpp \
WebCore/css/CSSStyleRule.cpp \
WebCore/css/CSSStyleSelector.cpp \
WebCore/css/CSSStyleSheet.cpp \
WebCore/css/CSSTimingFunctionValue.cpp \
WebCore/css/CSSTransformValue.cpp \
WebCore/css/CSSUnicodeRangeValue.cpp \
WebCore/css/CSSValueList.cpp \
WebCore/css/FontFamilyValue.cpp \
WebCore/css/FontValue.cpp \
......@@ -911,8 +913,10 @@ webkitgtk_sources += \
WebCore/platform/graphics/GlyphWidthMap.cpp \
WebCore/platform/graphics/FontCache.cpp \
WebCore/platform/graphics/Font.cpp \
WebCore/platform/graphics/FontData.cpp \
WebCore/platform/graphics/FontDataBaseClass.cpp \
WebCore/platform/graphics/FontFallbackList.cpp \
WebCore/platform/graphics/SegmentedFontData.cpp \
WebCore/platform/graphics/SimpleFontData.cpp \
WebCore/platform/graphics/StringTruncator.cpp \
WebCore/platform/text/TextCodecICU.cpp \
WebCore/platform/text/TextBoundariesICU.cpp \
......@@ -930,10 +934,10 @@ webkitgtk_sources += \
WebCore/platform/gtk/FileChooserGtk.cpp \
WebCore/platform/gtk/FileSystemGtk.cpp \
WebCore/platform/graphics/gtk/FontCacheGtk.cpp \
WebCore/platform/graphics/gtk/FontDataGtk.cpp \
WebCore/platform/graphics/gtk/FontGtk.cpp \
WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp \
WebCore/platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp \
WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp \
WebCore/platform/gtk/KeyEventGtk.cpp \
WebCore/platform/gtk/Language.cpp \
WebCore/platform/gtk/LocalizedStringsGtk.cpp \
......
......@@ -451,12 +451,14 @@ SOURCES += \
css/CSSRule.cpp \
css/CSSRuleList.cpp \
css/CSSSelector.cpp \
css/CSSSegmentedFontFace.cpp \
css/CSSStyleDeclaration.cpp \
css/CSSStyleRule.cpp \
css/CSSStyleSelector.cpp \
css/CSSStyleSheet.cpp \
css/CSSTimingFunctionValue.cpp \
css/CSSTransformValue.cpp \
css/CSSUnicodeRangeValue.cpp \
css/CSSValueList.cpp \
css/FontFamilyValue.cpp \
css/FontValue.cpp \
......@@ -860,8 +862,10 @@ gtk-port {
platform/graphics/GlyphWidthMap.cpp \
platform/graphics/FontCache.cpp \
platform/graphics/Font.cpp \
platform/graphics/FontData.cpp \
platform/graphics/FontFallbackList.cpp
platform/graphics/FontDataBaseClass.cpp \
platform/graphics/FontFallbackList.cpp \
platform/graphics/SegmentedFontData.cpp \
platfomr/graphics/SimpleFontData.cpp
}
qt-port {
......@@ -916,9 +920,9 @@ qt-port {
platform/qt/FileSystemQt.cpp \
platform/graphics/qt/FontCacheQt.cpp \
platform/graphics/qt/FontCustomPlatformData.cpp \
platform/graphics/qt/FontDataQt.cpp \
platform/graphics/qt/FontQt.cpp \
platform/graphics/qt/GlyphPageTreeNodeQt.cpp \
platform/graphics/qt/SimpleFontDataQt.cpp \
platform/qt/Localizations.cpp \
platform/qt/MIMETypeRegistryQt.cpp \
platform/qt/PasteboardQt.cpp \
......@@ -1001,10 +1005,10 @@ gtk-port {
platform/gtk/FileChooserGtk.cpp \
platform/gtk/FileSystemGtk.cpp \
platform/graphics/gtk/FontCacheGtk.cpp \
platform/graphics/gtk/FontDataGtk.cpp \
platform/graphics/gtk/FontGtk.cpp \
platform/graphics/gtk/FontPlatformDataGtk.cpp \
platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp \
platform/graphics/gtk/SimpleFontDataGtk.cpp \
platform/gtk/KeyEventGtk.cpp \
platform/gtk/Language.cpp \
platform/gtk/LocalizedStringsGtk.cpp \
......
......@@ -3286,14 +3286,6 @@
RelativePath="..\platform\graphics\FontCache.h"
>
</File>
<File
RelativePath="..\platform\graphics\FontData.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\FontData.h"
>
</File>
<File
RelativePath="..\platform\graphics\FontDescription.h"
>
......@@ -3812,6 +3804,14 @@
RelativePath="..\platform\graphics\FloatSize.h"
>
</File>
<File
RelativePath="..\platform\graphics\FontDataBaseClass.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\FontDataBaseClass.h"
>
</File>
<File
RelativePath="..\platform\graphics\GraphicsContext.cpp"
>
......@@ -3904,6 +3904,22 @@
RelativePath="..\platform\graphics\Pen.h"
>
</File>
<File
RelativePath="..\platform\graphics\SegmentedFontData.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\SegmentedFontData.h"
>
</File>
<File
RelativePath="..\platform\graphics\SimpleFontData.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\SimpleFontData.h"
>
</File>
<Filter
Name="win"
>
......@@ -3931,10 +3947,6 @@
RelativePath="..\platform\graphics\win\FontDatabase.h"
>
</File>
<File
RelativePath="..\platform\graphics\win\FontDataWin.cpp"
>
</File>
<File
RelativePath="..\platform\graphics\win\FontPlatformData.h"
>
......@@ -4003,6 +4015,10 @@
RelativePath="..\platform\graphics\win\MediaPlayerPrivateQuickTimeWin.h"
>
</File>
<File
RelativePath="..\platform\graphics\win\SimpleFontDataWin.cpp"
>
</File>
</Filter>
<Filter
Name="cg"
......@@ -4709,6 +4725,14 @@
RelativePath="..\css\CSSSelector.h"
>
</File>
<File
RelativePath="..\css\CSSSegmentedFontFace.cpp"
>
</File>
<File
RelativePath="..\css\CSSSegmentedFontFace.h"
>
</File>
<File
RelativePath="..\css\CSSStyleDeclaration.cpp"
>
......@@ -4761,6 +4785,14 @@
RelativePath="..\css\CSSTransformValue.h"
>
</File>
<File
RelativePath="..\css\CSSUnicodeRangeValue.cpp"
>
</File>
<File
RelativePath="..\css\CSSUnicodeRangeValue.h"
>
</File>
<File
RelativePath="..\css\CSSUnknownRule.h"
>
......
This diff is collapsed.
......@@ -120,12 +120,14 @@ This file contains the list of files needed to build WebCore.
css/CSSRule.cpp
css/CSSRuleList.cpp
css/CSSSelector.cpp
css/CSSSegmentedFontFace.cpp
css/CSSStyleDeclaration.cpp
css/CSSStyleRule.cpp
css/CSSStyleSelector.cpp
css/CSSStyleSheet.cpp
css/CSSTransformValue.cpp
css/CSSTimingFunctionValue.cpp
css/CSSUnicodeRangeValue.cpp
css/CSSValueList.cpp
css/FontFamilyValue.cpp
css/FontValue.cpp
......@@ -569,11 +571,13 @@ This file contains the list of files needed to build WebCore.
platform/FileChooser.cpp
platform/graphics/Font.cpp
platform/graphics/FontCache.cpp
platform/graphics/FontData.cpp
platform/graphics/FontDataBaseClass.cpp
platform/graphics/FontFallbackList.cpp
platform/graphics/FontFamily.cpp
platform/graphics/GlyphPageTreeNode.cpp
platform/graphics/GlyphWidthMap.cpp
platform/graphics/SegmentedFontData.cpp
platform/graphics/SimpleFontData.cpp
platform/KURL.cpp
platform/Logging.cpp
platform/MIMETypeRegistry.cpp
......
......@@ -43,7 +43,6 @@
#import "EventListener.h"
#import "EventTarget.h"
#import "ExceptionHandlers.h"
#import "FontData.h"
#import "FoundationExtras.h"
#import "Frame.h"
#import "FrameView.h"
......@@ -61,6 +60,7 @@
#import "Range.h"
#import "RenderImage.h"
#import "RenderView.h"
#import "SimpleFontData.h"
#import "Text.h"
#import "TreeWalker.h"
#import "WebScriptObjectPrivate.h"
......
......@@ -31,7 +31,6 @@
#import "Document.h"
#import "EventNames.h"
#import "FocusController.h"
#import "FontData.h"
#import "Frame.h"
#import "FrameLoader.h"
#import "FrameView.h"
......@@ -58,6 +57,7 @@
#import "RenderView.h"
#import "RenderWidget.h"
#import "SelectionController.h"
#import "SimpleFontData.h"
#import "TextIterator.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreFrameView.h"
......
......@@ -893,6 +893,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
case CSS_PROP_TEXT_UNDERLINE_MODE:
case CSS_PROP_TEXT_UNDERLINE_STYLE:
case CSS_PROP_TEXT_UNDERLINE_WIDTH:
case CSS_PROP_UNICODE_RANGE: // Only used in @font-face rules.
case CSS_PROP__WEBKIT_BORDER_IMAGE:
case CSS_PROP__WEBKIT_BORDER_RADIUS:
case CSS_PROP__WEBKIT_COLUMNS:
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -27,17 +27,12 @@
#include "CSSFontFace.h"
#include "CSSFontFaceSource.h"
#include "CSSFontSelector.h"
#include "FontData.h"
#include "CSSSegmentedFontFace.h"
#include "FontDescription.h"
#include "SimpleFontData.h"
namespace WebCore {
CSSFontFace::CSSFontFace(CSSFontSelector* selector)
: m_fontSelector(selector)
{
}
CSSFontFace::~CSSFontFace()
{
deleteAllValues(m_sources);
......@@ -74,19 +69,19 @@ void CSSFontFace::addSource(CSSFontFaceSource* source)
void CSSFontFace::fontLoaded(CSSFontFaceSource*)
{
if (isLoaded())
return m_fontSelector->fontLoaded(this);
return m_segmentedFontFace->fontLoaded(this);
}
FontData* CSSFontFace::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic)
SimpleFontData* CSSFontFace::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic)
{
if (!isValid())
return 0;
// If we hit a local font, we know it is valid, and can just return it.
FontData* result = 0;
SimpleFontData* result = 0;
unsigned size = m_sources.size();
for (unsigned i = 0; i < size && !result; i++)
result = m_sources[i]->getFontData(fontDescription, syntheticBold, syntheticItalic, m_fontSelector);
result = m_sources[i]->getFontData(fontDescription, syntheticBold, syntheticItalic, m_segmentedFontFace->fontSelector());
return result;
}
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -26,21 +26,27 @@
#ifndef CSSFontFace_h
#define CSSFontFace_h
#include <wtf/Vector.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace WebCore {
class CSSFontFaceSource;
class CSSFontSelector;
class FontData;
class CSSSegmentedFontFace;
class FontDescription;
class SimpleFontData;
class CSSFontFace : public RefCounted<CSSFontFace> {
public:
CSSFontFace(CSSFontSelector*);
CSSFontFace()
: m_segmentedFontFace(0)
{
}
virtual ~CSSFontFace();
void setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) { m_segmentedFontFace = segmentedFontFace; }
bool isLoaded() const;
virtual bool isValid() const;
......@@ -48,11 +54,11 @@ public:
void fontLoaded(CSSFontFaceSource*);
virtual FontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);
virtual SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);
private:
CSSSegmentedFontFace* m_segmentedFontFace;
Vector<CSSFontFaceSource*> m_sources;
CSSFontSelector* m_fontSelector;
};
}
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -31,7 +31,7 @@
#include "CSSFontSelector.h"
#include "DocLoader.h"
#include "FontCache.h"
#include "FontData.h"
#include "SimpleFontData.h"
#include "FontDescription.h"
#include "GlyphPageTreeNode.h"
......@@ -55,12 +55,8 @@ CSSFontFaceSource::~CSSFontFaceSource()
void CSSFontFaceSource::pruneTable()
{
// Make sure the glyph page tree prunes out all uses of these custom fonts.
if (m_fontDataTable.isEmpty())
return;
HashMap<int, FontData*>::iterator end = m_fontDataTable.end();
for (HashMap<int, FontData*>::iterator it = m_fontDataTable.begin(); it != end; ++it)
GlyphPageTreeNode::pruneTreeCustomFontData(it->second);
deleteAllValues(m_fontDataTable);
m_fontDataTable.clear();
}
......@@ -86,18 +82,18 @@ void CSSFontFaceSource::fontLoaded(CachedFont*)
m_face->fontLoaded(this);
}
FontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
// If the font hasn't loaded or an error occurred, then we've got nothing.
if (!isValid())
return 0;
if (!m_font)
// We're local. Just return a FontData from the normal cache.
// We're local. Just return a SimpleFontData from the normal cache.
return FontCache::getCachedFontData(FontCache::getCachedFontPlatformData(fontDescription, m_string));
// See if we have a mapping in our FontData cache.
FontData* cachedData = m_fontDataTable.get(fontDescription.computedPixelSize());
SimpleFontData* cachedData = m_fontDataTable.get(fontDescription.computedPixelSize());
if (cachedData)
return cachedData;
......@@ -106,7 +102,7 @@ FontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription,
// Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
if (!m_font->ensureCustomFontData())
return 0;
cachedData = new FontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false);
cachedData = new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic), true, false);
} else {
// Kick off the load now.
m_font->beginLoadIfNeeded(fontSelector->docLoader());
......@@ -114,7 +110,7 @@ FontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription,
FontPlatformData* tempData = FontCache::getCachedFontPlatformData(fontDescription, m_string);
if (!tempData)
tempData = FontCache::getLastResortFallbackFont(fontDescription);
cachedData = new FontData(*tempData, true, true);
cachedData = new SimpleFontData(*tempData, true, true);
}
m_fontDataTable.set(fontDescription.computedPixelSize(), cachedData);
......
......@@ -35,8 +35,8 @@ namespace WebCore {
class CachedFont;
class CSSFontFace;
class CSSFontSelector;
class FontData;
class FontDescription;
class SimpleFontData;
class CSSFontFaceSource : public CachedResourceClient {
public:
......@@ -52,7 +52,7 @@ public:
virtual void fontLoaded(CachedFont*);
FontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*);
SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic, CSSFontSelector*);
void pruneTable();
......@@ -60,7 +60,7 @@ private:
AtomicString m_string; // URI for remote, built-in font name for local.
CachedFont* m_font; // For remote fonts, a pointer to our cached resource.
CSSFontFace* m_face; // Our owning font face.
HashMap<int, FontData*> m_fontDataTable; // A cache of FontDatas for various pixel sizes.
HashMap<int, SimpleFontData*> m_fontDataTable; // A cache of FontDatas for various pixel sizes.
};
}
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
*
* Redistribution and use in source and binary forms, with or without
......@@ -36,6 +36,8 @@
#include "CSSMutableStyleDeclaration.h"
#include "CSSPrimitiveValue.h"
#include "CSSPropertyNames.h"
#include "CSSSegmentedFontFace.h"
#include "CSSUnicodeRangeValue.h"
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "DocLoader.h"
......@@ -45,10 +47,11 @@
#include "Frame.h"
#include "NodeList.h"
#include "RenderObject.h"
#include "Settings.h"
#include "SVGCSSFontFace.h"
#include "SVGFontFaceElement.h"
#include "SVGNames.h"
#include "Settings.h"
#include "SimpleFontData.h"
namespace WebCore {
......@@ -86,8 +89,9 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
// Obtain the font-family property and the src property. Both must be defined.
const CSSMutableStyleDeclaration* style = fontFaceRule->style();
RefPtr<CSSValue> fontFamily = style->getPropertyCSSValue(CSS_PROP_FONT_FAMILY);
RefPtr<CSSValue> src = style->getPropertyCSSValue(CSS_PROP_SRC);
if (!fontFamily || !src || !fontFamily->isValueList() || !src->isValueList())
RefPtr<CSSValue> src = style->getPropertyCSSValue(CSS_PROP_SRC);
RefPtr<CSSValue> unicodeRange = style->getPropertyCSSValue(CSS_PROP_UNICODE_RANGE);
if (!fontFamily || !src || !fontFamily->isValueList() || !src->isValueList() || unicodeRange && !unicodeRange->isValueList())
return;
CSSValueList* familyList = static_cast<CSSValueList*>(fontFamily.get());
......@@ -98,6 +102,8 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
if (!srcList->length())
return;
CSSValueList* rangeList = static_cast<CSSValueList*>(unicodeRange.get());
// Create a FontDescription for this font and set up bold/italic info properly.
FontDescription fontDescription;
......@@ -172,7 +178,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
fontFace = new SVGCSSFontFace(this, svgFontFaceElement);
else
#endif
fontFace = new CSSFontFace(this);
fontFace = new CSSFontFace();
}
if (source)
......@@ -231,12 +237,24 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
if (svgFontFaceElement && fontDescription.smallCaps())
familyName += "-webkit-svg-small-caps";
#endif
m_fonts.set(hashForFont(familyName.lower(), fontDescription.bold(), fontDescription.italic()), fontFace);
String hash = hashForFont(familyName.lower(), fontDescription.bold(), fontDescription.italic());
CSSSegmentedFontFace* segmentedFontFace = m_fonts.get(hash).get();
if (!segmentedFontFace) {
segmentedFontFace = new CSSSegmentedFontFace(this);
m_fonts.set(hash, segmentedFontFace);
}
if (rangeList) {
unsigned numRanges = rangeList->length();
for (unsigned i = 0; i < numRanges; i++) {
CSSUnicodeRangeValue* range = static_cast<CSSUnicodeRangeValue*>(rangeList->item(i));
segmentedFontFace->overlayRange(range->from(), range->to(), fontFace);
}
} else
segmentedFontFace->overlayRange(0, 0x7FFFFFFF, fontFace);
}
}
void CSSFontSelector::fontLoaded(CSSFontFace*)
void CSSFontSelector::fontLoaded(CSSSegmentedFontFace*)
{
if (m_document->inPageCache())
return;
......@@ -266,7 +284,7 @@ FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, c
} else
face = m_fonts.get(hashForFont(family, bold, italic));
#else
RefPtr<CSSFontFace> face = m_fonts.get(hashForFont(family, bold, italic));
RefPtr<CSSSegmentedFontFace> face = m_fonts.get(hashForFont(family, bold, italic));
#endif
// If we don't find a face, and if bold/italic are set, we should try other variants.
......
......@@ -35,8 +35,8 @@
namespace WebCore {
class AtomicString;
class CSSFontFace;
class CSSFontFaceRule;
class CSSSegmentedFontFace;
class Document;
class DocLoader;
class FontDescription;
......@@ -51,7 +51,7 @@ public:
void addFontFaceRule(const CSSFontFaceRule*);
void fontLoaded(CSSFontFace*);
void fontLoaded(CSSSegmentedFontFace*);
bool isEmpty() const;
......@@ -59,7 +59,7 @@ public:
protected:
Document* m_document; // No need to ref, since we will always get destroyed before the document does.
HashMap<String, RefPtr<CSSFontFace> > m_fonts;
HashMap<String, RefPtr<CSSSegmentedFontFace> > m_fonts;
};
} // namespace WebCore
......
......@@ -1056,7 +1056,7 @@ term:
| DIMEN maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_DIMENSION }
| unary_operator DIMEN maybe_space { $$.id = 0; $$.string = $2; $$.unit = CSSPrimitiveValue::CSS_DIMENSION }
| URI maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_URI; }
| UNICODERANGE maybe_space { $$.id = 0; $$.iValue = 0; $$.unit = CSSPrimitiveValue::CSS_UNKNOWN;/* ### */ }
| UNICODERANGE maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_UNICODE_RANGE }
| hexcolor { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_RGBCOLOR; }
| '#' maybe_space { $$.id = 0; $$.string = ParseString(); $$.unit = CSSPrimitiveValue::CSS_RGBCOLOR; } /* Handle error case: "color: #;" */
/* FIXME: according to the specs a function can have a unary_operator in front. I know no case where this makes sense */
......
/*
* Copyright (C) 2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
* Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -44,6 +44,7 @@
#include "CSSStyleRule.h"
#include "CSSStyleSheet.h"
#include "CSSTransformValue.h"
#include "CSSUnicodeRangeValue.h"
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "Counter.h"
......@@ -1071,6 +1072,9 @@ bool CSSParser::parseValue(int propId, bool important)
case CSS_PROP_SRC: // Only used within @font-face, so cannot use inherit | initial or be !important. This is a list of urls or local references.
return parseFontFaceSrc();
case CSS_PROP_UNICODE_RANGE:
return parseFontFaceUnicodeRange();
/* CSS3 properties */
case CSS_PROP__WEBKIT_APPEARANCE:
if ((id >= CSS_VAL_CHECKBOX && id <= CSS_VAL_TEXTAREA) || id == CSS_VAL_NONE)
......@@ -2812,6 +2816,95 @@ bool CSSParser::parseFontFaceSrc()
return false;
}
bool CSSParser::parseFontFaceUnicodeRange()
{
CSSValueList* values = new CSSValueList();
Value* currentValue;
bool failed = false;
while ((currentValue = valueList->current())) {
if (valueList->current()->unit != CSSPrimitiveValue::CSS_UNICODE_RANGE) {
failed = true;
break;
}
String rangeString = domString(valueList->current()->string);
UChar32 from = 0;
UChar32 to = 0;
unsigned length = rangeString.length();
if (length < 3) {
failed = true;
break;
}
unsigned i = 2;
while (i < length) {
UChar c = rangeString[i];
if (c == '-' || c == '?')
break;
from *= 16;
if (c >= '0' && c <= '9')
from += c - '0';
else if (c >= 'A' && c <= 'F')
from += 10 + c - 'A';
else if (c >= 'a' && c <= 'f')
from += 10 + c - 'a';
else {
failed = true;