Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/GlyphPageTreeNode.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
34 #include "wtf/text/CString.h" 35 #include "wtf/text/CString.h"
35 #include "wtf/text/CharacterNames.h" 36 #include "wtf/text/CharacterNames.h"
36 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
38 #include <memory>
37 #include <stdio.h> 39 #include <stdio.h>
38 40
39 namespace blink { 41 namespace blink {
40 42
41 using std::max; 43 using std::max;
42 using std::min; 44 using std::min;
43 45
44 HashMap<int, GlyphPageTreeNode*>* GlyphPageTreeNode::roots = 0; 46 HashMap<int, GlyphPageTreeNode*>* GlyphPageTreeNode::roots = 0;
45 GlyphPageTreeNode* GlyphPageTreeNode::pageZeroRoot = 0; 47 GlyphPageTreeNode* GlyphPageTreeNode::pageZeroRoot = 0;
46 48
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 350
349 GlyphPageTreeNode* child = new GlyphPageTreeNode(this); 351 GlyphPageTreeNode* child = new GlyphPageTreeNode(this);
350 if (fontData->isCustomFont()) { 352 if (fontData->isCustomFont()) {
351 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) 353 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
352 curr->m_customFontCount++; 354 curr->m_customFontCount++;
353 } 355 }
354 356
355 #if ENABLE(ASSERT) 357 #if ENABLE(ASSERT)
356 child->m_pageNumber = m_pageNumber; 358 child->m_pageNumber = m_pageNumber;
357 #endif 359 #endif
358 m_children.set(fontData, adoptPtr(child)); 360 m_children.set(fontData, wrapUnique(child));
359 fontData->setMaxGlyphPageTreeLevel(max(fontData->maxGlyphPageTreeLevel(), ch ild->m_level)); 361 fontData->setMaxGlyphPageTreeLevel(max(fontData->maxGlyphPageTreeLevel(), ch ild->m_level));
360 child->initializePage(fontData, pageNumber); 362 child->initializePage(fontData, pageNumber);
361 return child; 363 return child;
362 } 364 }
363 365
364 SystemFallbackGlyphPageTreeNode* GlyphPageTreeNode::getSystemFallbackChild(unsig ned pageNumber) 366 SystemFallbackGlyphPageTreeNode* GlyphPageTreeNode::getSystemFallbackChild(unsig ned pageNumber)
365 { 367 {
366 ASSERT(pageNumber == m_pageNumber); 368 ASSERT(pageNumber == m_pageNumber);
367 369
368 if (m_systemFallbackChild) 370 if (m_systemFallbackChild)
369 return m_systemFallbackChild.get(); 371 return m_systemFallbackChild.get();
370 372
371 SystemFallbackGlyphPageTreeNode* child = new SystemFallbackGlyphPageTreeNode (this); 373 SystemFallbackGlyphPageTreeNode* child = new SystemFallbackGlyphPageTreeNode (this);
372 m_systemFallbackChild = adoptPtr(child); 374 m_systemFallbackChild = wrapUnique(child);
373 #if ENABLE(ASSERT) 375 #if ENABLE(ASSERT)
374 child->m_pageNumber = m_pageNumber; 376 child->m_pageNumber = m_pageNumber;
375 #endif 377 #endif
376 return child; 378 return child;
377 } 379 }
378 380
379 void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData) 381 void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData)
380 { 382 {
381 if (!fontData || !m_customFontCount) 383 if (!fontData || !m_customFontCount)
382 return; 384 return;
383 385
384 // Prune any branch that contains this FontData. 386 // Prune any branch that contains this FontData.
385 if (OwnPtr<GlyphPageTreeNode> node = m_children.take(fontData)) { 387 if (std::unique_ptr<GlyphPageTreeNode> node = m_children.take(fontData)) {
386 if (unsigned customFontCount = node->m_customFontCount + 1) { 388 if (unsigned customFontCount = node->m_customFontCount + 1) {
387 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) 389 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
388 curr->m_customFontCount -= customFontCount; 390 curr->m_customFontCount -= customFontCount;
389 } 391 }
390 } 392 }
391 393
392 // Check any branches that remain that still have custom fonts underneath th em. 394 // Check any branches that remain that still have custom fonts underneath th em.
393 if (!m_customFontCount) 395 if (!m_customFontCount)
394 return; 396 return;
395 397
396 GlyphPageTreeNodeMap::iterator end = m_children.end(); 398 GlyphPageTreeNodeMap::iterator end = m_children.end();
397 for (GlyphPageTreeNodeMap::iterator it = m_children.begin(); it != end; ++it ) 399 for (GlyphPageTreeNodeMap::iterator it = m_children.begin(); it != end; ++it )
398 it->value->pruneCustomFontData(fontData); 400 it->value->pruneCustomFontData(fontData);
399 } 401 }
400 402
401 void GlyphPageTreeNode::pruneFontData(const SimpleFontData* fontData, unsigned l evel) 403 void GlyphPageTreeNode::pruneFontData(const SimpleFontData* fontData, unsigned l evel)
402 { 404 {
403 ASSERT(fontData); 405 ASSERT(fontData);
404 406
405 // Prune fall back child (if any) of this font. 407 // Prune fall back child (if any) of this font.
406 if (m_systemFallbackChild) 408 if (m_systemFallbackChild)
407 m_systemFallbackChild->pruneFontData(fontData); 409 m_systemFallbackChild->pruneFontData(fontData);
408 410
409 // Prune from m_page if it's a mixed page. 411 // Prune from m_page if it's a mixed page.
410 if (m_page && m_page->hasPerGlyphFontData()) 412 if (m_page && m_page->hasPerGlyphFontData())
411 m_page->removePerGlyphFontData(fontData); 413 m_page->removePerGlyphFontData(fontData);
412 414
413 // Prune any branch that contains this FontData. 415 // Prune any branch that contains this FontData.
414 if (OwnPtr<GlyphPageTreeNode> node = m_children.take(fontData)) { 416 if (std::unique_ptr<GlyphPageTreeNode> node = m_children.take(fontData)) {
415 if (unsigned customFontCount = node->m_customFontCount) { 417 if (unsigned customFontCount = node->m_customFontCount) {
416 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent) 418 for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
417 curr->m_customFontCount -= customFontCount; 419 curr->m_customFontCount -= customFontCount;
418 } 420 }
419 } 421 }
420 422
421 level++; 423 level++;
422 if (level > fontData->maxGlyphPageTreeLevel()) 424 if (level > fontData->maxGlyphPageTreeLevel())
423 return; 425 return;
424 426
(...skipping 26 matching lines...) Expand all
451 // entries may use different fonts depending on character. If the Font 453 // entries may use different fonts depending on character. If the Font
452 // ever finds it needs a glyph out of the system fallback page, it will 454 // ever finds it needs a glyph out of the system fallback page, it will
453 // ask the system for the best font to use and fill that glyph in for us. 455 // ask the system for the best font to use and fill that glyph in for us.
454 if (GlyphPage* parentPage = m_parent->page()) 456 if (GlyphPage* parentPage = m_parent->page())
455 return parentPage->createCopiedSystemFallbackPage(this); 457 return parentPage->createCopiedSystemFallbackPage(this);
456 return GlyphPage::createForMixedFontData(this); 458 return GlyphPage::createForMixedFontData(this);
457 } 459 }
458 460
459 } // namespace blink 461 } // namespace blink
460 462
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698