| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "CSSSegmentedFontFace.h" | 27 #include "CSSSegmentedFontFace.h" |
| 28 | 28 |
| 29 #include "CSSFontFace.h" | 29 #include "CSSFontFace.h" |
| 30 #include "CSSFontSelector.h" | 30 #include "CSSFontSelector.h" |
| 31 #include "Document.h" |
| 31 #include "FontDescription.h" | 32 #include "FontDescription.h" |
| 32 #include "SegmentedFontData.h" | 33 #include "SegmentedFontData.h" |
| 33 #include "SimpleFontData.h" | 34 #include "SimpleFontData.h" |
| 34 | 35 |
| 35 namespace WebCore { | 36 namespace WebCore { |
| 36 | 37 |
| 37 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) | 38 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) |
| 38 : m_fontSelector(fontSelector) | 39 : m_fontSelector(fontSelector) |
| 39 { | 40 { |
| 40 } | 41 } |
| 41 | 42 |
| 42 CSSSegmentedFontFace::~CSSSegmentedFontFace() | 43 CSSSegmentedFontFace::~CSSSegmentedFontFace() |
| 43 { | 44 { |
| 44 pruneTable(); | 45 pruneTable(); |
| 45 unsigned size = m_fontFaces.size(); | 46 unsigned size = m_fontFaces.size(); |
| 46 for (unsigned i = 0; i < size; i++) | 47 for (unsigned i = 0; i < size; i++) |
| 47 m_fontFaces[i]->removedFromSegmentedFontFace(this); | 48 m_fontFaces[i]->removedFromSegmentedFontFace(this); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void CSSSegmentedFontFace::pruneTable() | 51 void CSSSegmentedFontFace::pruneTable() |
| 51 { | 52 { |
| 52 // Make sure the glyph page tree prunes out all uses of this custom font. | 53 // Make sure the glyph page tree prunes out all uses of this custom font. |
| 53 if (m_fontDataTable.isEmpty()) | 54 if (m_fontDataTable.isEmpty()) |
| 54 return; | 55 return; |
| 55 | 56 |
| 56 HashMap<unsigned, SegmentedFontData*>::iterator end = m_fontDataTable.end(); | |
| 57 for (HashMap<unsigned, SegmentedFontData*>::iterator it = m_fontDataTable.be
gin(); it != end; ++it) | |
| 58 m_fontSelector->retireCustomFont(it->second); | |
| 59 | |
| 60 m_fontDataTable.clear(); | 57 m_fontDataTable.clear(); |
| 61 } | 58 } |
| 62 | 59 |
| 63 bool CSSSegmentedFontFace::isValid() const | 60 bool CSSSegmentedFontFace::isValid() const |
| 64 { | 61 { |
| 65 // Valid if at least one font face is valid. | 62 // Valid if at least one font face is valid. |
| 66 unsigned size = m_fontFaces.size(); | 63 unsigned size = m_fontFaces.size(); |
| 67 for (unsigned i = 0; i < size; i++) { | 64 for (unsigned i = 0; i < size; i++) { |
| 68 if (m_fontFaces[i]->isValid()) | 65 if (m_fontFaces[i]->isValid()) |
| 69 return true; | 66 return true; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 const Vector<CSSFontFace::UnicodeRange>& ranges = m_fontFaces[i]->ra
nges(); | 106 const Vector<CSSFontFace::UnicodeRange>& ranges = m_fontFaces[i]->ra
nges(); |
| 110 unsigned numRanges = ranges.size(); | 107 unsigned numRanges = ranges.size(); |
| 111 if (!numRanges) | 108 if (!numRanges) |
| 112 fontData->appendRange(FontDataRange(0, 0x7FFFFFFF, faceFontData)
); | 109 fontData->appendRange(FontDataRange(0, 0x7FFFFFFF, faceFontData)
); |
| 113 else { | 110 else { |
| 114 for (unsigned j = 0; j < numRanges; ++j) | 111 for (unsigned j = 0; j < numRanges; ++j) |
| 115 fontData->appendRange(FontDataRange(ranges[j].from(), ranges
[j].to(), faceFontData)); | 112 fontData->appendRange(FontDataRange(ranges[j].from(), ranges
[j].to(), faceFontData)); |
| 116 } | 113 } |
| 117 } | 114 } |
| 118 } | 115 } |
| 119 if (fontData->numRanges()) | 116 if (fontData->numRanges()) { |
| 120 m_fontDataTable.set(hashKey, fontData); | 117 m_fontDataTable.set(hashKey, fontData); |
| 121 else { | 118 ASSERT(m_fontSelector->document()); |
| 119 if (Document* doc = m_fontSelector->document()) |
| 120 doc->registerCustomFont(fontData); |
| 121 } else { |
| 122 delete fontData; | 122 delete fontData; |
| 123 fontData = 0; | 123 fontData = 0; |
| 124 } | 124 } |
| 125 | 125 |
| 126 return fontData; | 126 return fontData; |
| 127 } | 127 } |
| 128 | 128 |
| 129 } | 129 } |
| OLD | NEW |