| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "platform/fonts/GlyphPageTreeNode.h" | 29 #include "platform/fonts/GlyphPageTreeNode.h" |
| 30 | 30 |
| 31 #include "platform/fonts/SegmentedFontData.h" | 31 #include "platform/fonts/SegmentedFontData.h" |
| 32 #include "platform/fonts/SimpleFontData.h" | 32 #include "platform/fonts/SimpleFontData.h" |
| 33 #include "platform/fonts/opentype/OpenTypeVerticalData.h" | 33 #include "platform/fonts/opentype/OpenTypeVerticalData.h" |
| 34 #include "wtf/PtrUtil.h" | |
| 35 #include "wtf/text/CString.h" | 34 #include "wtf/text/CString.h" |
| 36 #include "wtf/text/CharacterNames.h" | 35 #include "wtf/text/CharacterNames.h" |
| 37 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
| 38 #include <memory> | |
| 39 #include <stdio.h> | 37 #include <stdio.h> |
| 40 | 38 |
| 41 namespace blink { | 39 namespace blink { |
| 42 | 40 |
| 43 using std::max; | 41 using std::max; |
| 44 using std::min; | 42 using std::min; |
| 45 | 43 |
| 46 HashMap<int, GlyphPageTreeNode*>* GlyphPageTreeNode::roots = 0; | 44 HashMap<int, GlyphPageTreeNode*>* GlyphPageTreeNode::roots = 0; |
| 47 GlyphPageTreeNode* GlyphPageTreeNode::pageZeroRoot = 0; | 45 GlyphPageTreeNode* GlyphPageTreeNode::pageZeroRoot = 0; |
| 48 | 46 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 348 |
| 351 GlyphPageTreeNode* child = new GlyphPageTreeNode(this); | 349 GlyphPageTreeNode* child = new GlyphPageTreeNode(this); |
| 352 if (fontData->isCustomFont()) { | 350 if (fontData->isCustomFont()) { |
| 353 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) | 351 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) |
| 354 curr->m_customFontCount++; | 352 curr->m_customFontCount++; |
| 355 } | 353 } |
| 356 | 354 |
| 357 #if ENABLE(ASSERT) | 355 #if ENABLE(ASSERT) |
| 358 child->m_pageNumber = m_pageNumber; | 356 child->m_pageNumber = m_pageNumber; |
| 359 #endif | 357 #endif |
| 360 m_children.set(fontData, wrapUnique(child)); | 358 m_children.set(fontData, adoptPtr(child)); |
| 361 fontData->setMaxGlyphPageTreeLevel(max(fontData->maxGlyphPageTreeLevel(), ch
ild->m_level)); | 359 fontData->setMaxGlyphPageTreeLevel(max(fontData->maxGlyphPageTreeLevel(), ch
ild->m_level)); |
| 362 child->initializePage(fontData, pageNumber); | 360 child->initializePage(fontData, pageNumber); |
| 363 return child; | 361 return child; |
| 364 } | 362 } |
| 365 | 363 |
| 366 SystemFallbackGlyphPageTreeNode* GlyphPageTreeNode::getSystemFallbackChild(unsig
ned pageNumber) | 364 SystemFallbackGlyphPageTreeNode* GlyphPageTreeNode::getSystemFallbackChild(unsig
ned pageNumber) |
| 367 { | 365 { |
| 368 ASSERT(pageNumber == m_pageNumber); | 366 ASSERT(pageNumber == m_pageNumber); |
| 369 | 367 |
| 370 if (m_systemFallbackChild) | 368 if (m_systemFallbackChild) |
| 371 return m_systemFallbackChild.get(); | 369 return m_systemFallbackChild.get(); |
| 372 | 370 |
| 373 SystemFallbackGlyphPageTreeNode* child = new SystemFallbackGlyphPageTreeNode
(this); | 371 SystemFallbackGlyphPageTreeNode* child = new SystemFallbackGlyphPageTreeNode
(this); |
| 374 m_systemFallbackChild = wrapUnique(child); | 372 m_systemFallbackChild = adoptPtr(child); |
| 375 #if ENABLE(ASSERT) | 373 #if ENABLE(ASSERT) |
| 376 child->m_pageNumber = m_pageNumber; | 374 child->m_pageNumber = m_pageNumber; |
| 377 #endif | 375 #endif |
| 378 return child; | 376 return child; |
| 379 } | 377 } |
| 380 | 378 |
| 381 void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData) | 379 void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData) |
| 382 { | 380 { |
| 383 if (!fontData || !m_customFontCount) | 381 if (!fontData || !m_customFontCount) |
| 384 return; | 382 return; |
| 385 | 383 |
| 386 // Prune any branch that contains this FontData. | 384 // Prune any branch that contains this FontData. |
| 387 if (std::unique_ptr<GlyphPageTreeNode> node = m_children.take(fontData)) { | 385 if (OwnPtr<GlyphPageTreeNode> node = m_children.take(fontData)) { |
| 388 if (unsigned customFontCount = node->m_customFontCount + 1) { | 386 if (unsigned customFontCount = node->m_customFontCount + 1) { |
| 389 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) | 387 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) |
| 390 curr->m_customFontCount -= customFontCount; | 388 curr->m_customFontCount -= customFontCount; |
| 391 } | 389 } |
| 392 } | 390 } |
| 393 | 391 |
| 394 // Check any branches that remain that still have custom fonts underneath th
em. | 392 // Check any branches that remain that still have custom fonts underneath th
em. |
| 395 if (!m_customFontCount) | 393 if (!m_customFontCount) |
| 396 return; | 394 return; |
| 397 | 395 |
| 398 GlyphPageTreeNodeMap::iterator end = m_children.end(); | 396 GlyphPageTreeNodeMap::iterator end = m_children.end(); |
| 399 for (GlyphPageTreeNodeMap::iterator it = m_children.begin(); it != end; ++it
) | 397 for (GlyphPageTreeNodeMap::iterator it = m_children.begin(); it != end; ++it
) |
| 400 it->value->pruneCustomFontData(fontData); | 398 it->value->pruneCustomFontData(fontData); |
| 401 } | 399 } |
| 402 | 400 |
| 403 void GlyphPageTreeNode::pruneFontData(const SimpleFontData* fontData, unsigned l
evel) | 401 void GlyphPageTreeNode::pruneFontData(const SimpleFontData* fontData, unsigned l
evel) |
| 404 { | 402 { |
| 405 ASSERT(fontData); | 403 ASSERT(fontData); |
| 406 | 404 |
| 407 // Prune fall back child (if any) of this font. | 405 // Prune fall back child (if any) of this font. |
| 408 if (m_systemFallbackChild) | 406 if (m_systemFallbackChild) |
| 409 m_systemFallbackChild->pruneFontData(fontData); | 407 m_systemFallbackChild->pruneFontData(fontData); |
| 410 | 408 |
| 411 // Prune from m_page if it's a mixed page. | 409 // Prune from m_page if it's a mixed page. |
| 412 if (m_page && m_page->hasPerGlyphFontData()) | 410 if (m_page && m_page->hasPerGlyphFontData()) |
| 413 m_page->removePerGlyphFontData(fontData); | 411 m_page->removePerGlyphFontData(fontData); |
| 414 | 412 |
| 415 // Prune any branch that contains this FontData. | 413 // Prune any branch that contains this FontData. |
| 416 if (std::unique_ptr<GlyphPageTreeNode> node = m_children.take(fontData)) { | 414 if (OwnPtr<GlyphPageTreeNode> node = m_children.take(fontData)) { |
| 417 if (unsigned customFontCount = node->m_customFontCount) { | 415 if (unsigned customFontCount = node->m_customFontCount) { |
| 418 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) | 416 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) |
| 419 curr->m_customFontCount -= customFontCount; | 417 curr->m_customFontCount -= customFontCount; |
| 420 } | 418 } |
| 421 } | 419 } |
| 422 | 420 |
| 423 level++; | 421 level++; |
| 424 if (level > fontData->maxGlyphPageTreeLevel()) | 422 if (level > fontData->maxGlyphPageTreeLevel()) |
| 425 return; | 423 return; |
| 426 | 424 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 453 // entries may use different fonts depending on character. If the Font | 451 // entries may use different fonts depending on character. If the Font |
| 454 // ever finds it needs a glyph out of the system fallback page, it will | 452 // ever finds it needs a glyph out of the system fallback page, it will |
| 455 // ask the system for the best font to use and fill that glyph in for us. | 453 // ask the system for the best font to use and fill that glyph in for us. |
| 456 if (GlyphPage* parentPage = m_parent->page()) | 454 if (GlyphPage* parentPage = m_parent->page()) |
| 457 return parentPage->createCopiedSystemFallbackPage(this); | 455 return parentPage->createCopiedSystemFallbackPage(this); |
| 458 return GlyphPage::createForMixedFontData(this); | 456 return GlyphPage::createForMixedFontData(this); |
| 459 } | 457 } |
| 460 | 458 |
| 461 } // namespace blink | 459 } // namespace blink |
| 462 | 460 |
| OLD | NEW |