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

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

Issue 1774943003: blink: Rename platform/ methods to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-platform: rebase-yayyyyyyyy Created 4 years, 9 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 { 80 {
81 m_fontDescription = other.m_fontDescription; 81 m_fontDescription = other.m_fontDescription;
82 m_fontFallbackList = other.m_fontFallbackList; 82 m_fontFallbackList = other.m_fontFallbackList;
83 m_canShapeWordByWord = other.m_canShapeWordByWord; 83 m_canShapeWordByWord = other.m_canShapeWordByWord;
84 m_shapeWordByWordComputed = other.m_shapeWordByWordComputed; 84 m_shapeWordByWordComputed = other.m_shapeWordByWordComputed;
85 return *this; 85 return *this;
86 } 86 }
87 87
88 bool Font::operator==(const Font& other) const 88 bool Font::operator==(const Font& other) const
89 { 89 {
90 FontSelector* first = m_fontFallbackList ? m_fontFallbackList->fontSelector( ) : 0; 90 FontSelector* first = m_fontFallbackList ? m_fontFallbackList->getFontSelect or() : 0;
91 FontSelector* second = other.m_fontFallbackList ? other.m_fontFallbackList-> fontSelector() : 0; 91 FontSelector* second = other.m_fontFallbackList ? other.m_fontFallbackList-> getFontSelector() : 0;
92 92
93 return first == second 93 return first == second
94 && m_fontDescription == other.m_fontDescription 94 && m_fontDescription == other.m_fontDescription
95 && (m_fontFallbackList ? m_fontFallbackList->fontSelectorVersion() : 0) == (other.m_fontFallbackList ? other.m_fontFallbackList->fontSelectorVersion() : 0) 95 && (m_fontFallbackList ? m_fontFallbackList->fontSelectorVersion() : 0) == (other.m_fontFallbackList ? other.m_fontFallbackList->fontSelectorVersion() : 0)
96 && (m_fontFallbackList ? m_fontFallbackList->generation() : 0) == (other .m_fontFallbackList ? other.m_fontFallbackList->generation() : 0); 96 && (m_fontFallbackList ? m_fontFallbackList->generation() : 0) == (other .m_fontFallbackList ? other.m_fontFallbackList->generation() : 0);
97 } 97 }
98 98
99 void Font::update(PassRefPtrWillBeRawPtr<FontSelector> fontSelector) const 99 void Font::update(PassRefPtrWillBeRawPtr<FontSelector> fontSelector) const
100 { 100 {
101 // FIXME: It is pretty crazy that we are willing to just poke into a RefPtr, but it ends up 101 // FIXME: It is pretty crazy that we are willing to just poke into a RefPtr, but it ends up
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 const uint16_t* glyphs = m_buffer.glyphs(start); 312 const uint16_t* glyphs = m_buffer.glyphs(start);
313 const float* offsets = m_buffer.offsets(start); 313 const float* offsets = m_buffer.offsets(start);
314 std::copy(glyphs, glyphs + count, buffer.glyphs); 314 std::copy(glyphs, glyphs + count, buffer.glyphs);
315 315
316 if (m_rotation == NoRotation) { 316 if (m_rotation == NoRotation) {
317 std::copy(offsets, offsets + (m_hasVerticalOffsets ? 2 * count : cou nt), buffer.pos); 317 std::copy(offsets, offsets + (m_hasVerticalOffsets ? 2 * count : cou nt), buffer.pos);
318 } else { 318 } else {
319 ASSERT(m_hasVerticalOffsets); 319 ASSERT(m_hasVerticalOffsets);
320 320
321 const float verticalBaselineXOffset = fontData->fontMetrics().floatA scent() 321 const float verticalBaselineXOffset = fontData->getFontMetrics().flo atAscent()
322 - fontData->fontMetrics().floatAscent(IdeographicBaseline); 322 - fontData->getFontMetrics().floatAscent(IdeographicBaseline);
323 323
324 // TODO(fmalita): why don't we apply this adjustment when building t he glyph buffer? 324 // TODO(fmalita): why don't we apply this adjustment when building t he glyph buffer?
325 for (unsigned i = 0; i < 2 * count; i += 2) { 325 for (unsigned i = 0; i < 2 * count; i += 2) {
326 buffer.pos[i] = SkFloatToScalar(offsets[i] + verticalBaselineXOf fset); 326 buffer.pos[i] = SkFloatToScalar(offsets[i] + verticalBaselineXOf fset);
327 buffer.pos[i + 1] = SkFloatToScalar(offsets[i + 1]); 327 buffer.pos[i + 1] = SkFloatToScalar(offsets[i + 1]);
328 } 328 }
329 } 329 }
330 } 330 }
331 331
332 const GlyphBuffer& m_buffer; 332 const GlyphBuffer& m_buffer;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 if (codePath(runInfo) != ComplexPath) 396 if (codePath(runInfo) != ComplexPath)
397 return pixelSnappedSelectionRect(selectionRectForSimpleText(run, point, h, from, to, accountForGlyphBounds)); 397 return pixelSnappedSelectionRect(selectionRectForSimpleText(run, point, h, from, to, accountForGlyphBounds));
398 return pixelSnappedSelectionRect(selectionRectForComplexText(run, point, h, from, to)); 398 return pixelSnappedSelectionRect(selectionRectForComplexText(run, point, h, from, to));
399 } 399 }
400 400
401 int Font::offsetForPosition(const TextRun& run, float x, bool includePartialGlyp hs) const 401 int Font::offsetForPosition(const TextRun& run, float x, bool includePartialGlyp hs) const
402 { 402 {
403 FontCachePurgePreventer purgePreventer; 403 FontCachePurgePreventer purgePreventer;
404 404
405 if (codePath(TextRunPaintInfo(run)) != ComplexPath && !fontDescription().get TypesettingFeatures()) 405 if (codePath(TextRunPaintInfo(run)) != ComplexPath && !getFontDescription(). getTypesettingFeatures())
406 return offsetForPositionForSimpleText(run, x, includePartialGlyphs); 406 return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
407 407
408 return offsetForPositionForComplexText(run, x, includePartialGlyphs); 408 return offsetForPositionForComplexText(run, x, includePartialGlyphs);
409 } 409 }
410 410
411 CodePath Font::codePath(const TextRunPaintInfo& runInfo) const 411 CodePath Font::codePath(const TextRunPaintInfo& runInfo) const
412 { 412 {
413 // TODO(eae): Disable the always use complex text feature on Android for now as 413 // TODO(eae): Disable the always use complex text feature on Android for now as
414 // it caused a memory regression for webview. crbug.com/577306 414 // it caused a memory regression for webview. crbug.com/577306
415 #if !OS(ANDROID) 415 #if !OS(ANDROID)
416 if (RuntimeEnabledFeatures::alwaysUseComplexTextEnabled() 416 if (RuntimeEnabledFeatures::alwaysUseComplexTextEnabled()
417 || LayoutTestSupport::alwaysUseComplexTextForTest()) { 417 || LayoutTestSupport::alwaysUseComplexTextForTest()) {
418 return ComplexPath; 418 return ComplexPath;
419 } 419 }
420 #endif 420 #endif
421 421
422 const TextRun& run = runInfo.run; 422 const TextRun& run = runInfo.run;
423 423
424 if (fontDescription().getTypesettingFeatures() && (runInfo.from || runInfo.t o != run.length())) 424 if (getFontDescription().getTypesettingFeatures() && (runInfo.from || runInf o.to != run.length()))
425 return ComplexPath; 425 return ComplexPath;
426 426
427 if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings ()->size() > 0) 427 if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings ()->size() > 0)
428 return ComplexPath; 428 return ComplexPath;
429 429
430 if (m_fontDescription.isVerticalBaseline()) 430 if (m_fontDescription.isVerticalBaseline())
431 return ComplexPath; 431 return ComplexPath;
432 432
433 if (m_fontDescription.widthVariant() != RegularWidth) 433 if (m_fontDescription.widthVariant() != RegularWidth)
434 return ComplexPath; 434 return ComplexPath;
435 435
436 if (run.length() > 1 && fontDescription().getTypesettingFeatures()) 436 if (run.length() > 1 && getFontDescription().getTypesettingFeatures())
437 return ComplexPath; 437 return ComplexPath;
438 438
439 // FIXME: This really shouldn't be needed but for some reason the 439 // FIXME: This really shouldn't be needed but for some reason the
440 // TextRendering setting doesn't propagate to typesettingFeatures in time 440 // TextRendering setting doesn't propagate to typesettingFeatures in time
441 // for the prefs width calculation. 441 // for the prefs width calculation.
442 if (fontDescription().textRendering() == OptimizeLegibility || fontDescripti on().textRendering() == GeometricPrecision) 442 if (getFontDescription().textRendering() == OptimizeLegibility || getFontDes cription().textRendering() == GeometricPrecision)
443 return ComplexPath; 443 return ComplexPath;
444 444
445 if (run.is8Bit()) 445 if (run.is8Bit())
446 return SimplePath; 446 return SimplePath;
447 447
448 // Start from 0 since drawing and highlighting also measure the characters b efore run->from. 448 // Start from 0 since drawing and highlighting also measure the characters b efore run->from.
449 return Character::characterRangeCodePath(run.characters16(), run.length()); 449 return Character::characterRangeCodePath(run.characters16(), run.length());
450 } 450 }
451 451
452 bool Font::canShapeWordByWord() const 452 bool Font::canShapeWordByWord() const
453 { 453 {
454 if (!m_shapeWordByWordComputed) { 454 if (!m_shapeWordByWordComputed) {
455 m_canShapeWordByWord = computeCanShapeWordByWord(); 455 m_canShapeWordByWord = computeCanShapeWordByWord();
456 m_shapeWordByWordComputed = true; 456 m_shapeWordByWordComputed = true;
457 } 457 }
458 return m_canShapeWordByWord; 458 return m_canShapeWordByWord;
459 }; 459 };
460 460
461 bool Font::computeCanShapeWordByWord() const 461 bool Font::computeCanShapeWordByWord() const
462 { 462 {
463 if (!fontDescription().getTypesettingFeatures()) 463 if (!getFontDescription().getTypesettingFeatures())
464 return true; 464 return true;
465 465
466 const FontPlatformData& platformData = primaryFont()->platformData(); 466 const FontPlatformData& platformData = primaryFont()->platformData();
467 TypesettingFeatures features = fontDescription().getTypesettingFeatures(); 467 TypesettingFeatures features = getFontDescription().getTypesettingFeatures() ;
468 return !platformData.hasSpaceInLigaturesOrKerning(features); 468 return !platformData.hasSpaceInLigaturesOrKerning(features);
469 }; 469 };
470 470
471 void Font::willUseFontData(UChar32 character) const 471 void Font::willUseFontData(UChar32 character) const
472 { 472 {
473 const FontFamily& family = fontDescription().family(); 473 const FontFamily& family = getFontDescription().family();
474 if (m_fontFallbackList && m_fontFallbackList->fontSelector() && !family.fami lyIsEmpty()) 474 if (m_fontFallbackList && m_fontFallbackList->getFontSelector() && !family.f amilyIsEmpty())
475 m_fontFallbackList->fontSelector()->willUseFontData(fontDescription(), f amily.family(), character); 475 m_fontFallbackList->getFontSelector()->willUseFontData(getFontDescriptio n(), family.family(), character);
476 } 476 }
477 477
478 static inline GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32 character, bool isUpright, GlyphData& data, unsigned pageNumber) 478 static inline GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32 character, bool isUpright, GlyphData& data, unsigned pageNumber)
479 { 479 {
480 if (isUpright) { 480 if (isUpright) {
481 RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientati onFontData(); 481 RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientati onFontData();
482 GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getNormalRootChild(u prightFontData.get(), pageNumber); 482 GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getNormalRootChild(u prightFontData.get(), pageNumber);
483 GlyphPage* uprightPage = uprightNode->page(); 483 GlyphPage* uprightPage = uprightNode->page();
484 if (uprightPage) { 484 if (uprightPage) {
485 GlyphData uprightData = uprightPage->glyphDataForCharacter(character ); 485 GlyphData uprightData = uprightPage->glyphDataForCharacter(character );
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 686
687 GlyphData markGlyphData; 687 GlyphData markGlyphData;
688 if (!getEmphasisMarkGlyphData(mark, markGlyphData)) 688 if (!getEmphasisMarkGlyphData(mark, markGlyphData))
689 return 0; 689 return 0;
690 690
691 const SimpleFontData* markFontData = markGlyphData.fontData; 691 const SimpleFontData* markFontData = markGlyphData.fontData;
692 ASSERT(markFontData); 692 ASSERT(markFontData);
693 if (!markFontData) 693 if (!markFontData)
694 return 0; 694 return 0;
695 695
696 return markFontData->fontMetrics().ascent(); 696 return markFontData->getFontMetrics().ascent();
697 } 697 }
698 698
699 int Font::emphasisMarkDescent(const AtomicString& mark) const 699 int Font::emphasisMarkDescent(const AtomicString& mark) const
700 { 700 {
701 FontCachePurgePreventer purgePreventer; 701 FontCachePurgePreventer purgePreventer;
702 702
703 GlyphData markGlyphData; 703 GlyphData markGlyphData;
704 if (!getEmphasisMarkGlyphData(mark, markGlyphData)) 704 if (!getEmphasisMarkGlyphData(mark, markGlyphData))
705 return 0; 705 return 0;
706 706
707 const SimpleFontData* markFontData = markGlyphData.fontData; 707 const SimpleFontData* markFontData = markGlyphData.fontData;
708 ASSERT(markFontData); 708 ASSERT(markFontData);
709 if (!markFontData) 709 if (!markFontData)
710 return 0; 710 return 0;
711 711
712 return markFontData->fontMetrics().descent(); 712 return markFontData->getFontMetrics().descent();
713 } 713 }
714 714
715 int Font::emphasisMarkHeight(const AtomicString& mark) const 715 int Font::emphasisMarkHeight(const AtomicString& mark) const
716 { 716 {
717 FontCachePurgePreventer purgePreventer; 717 FontCachePurgePreventer purgePreventer;
718 718
719 GlyphData markGlyphData; 719 GlyphData markGlyphData;
720 if (!getEmphasisMarkGlyphData(mark, markGlyphData)) 720 if (!getEmphasisMarkGlyphData(mark, markGlyphData))
721 return 0; 721 return 0;
722 722
723 const SimpleFontData* markFontData = markGlyphData.fontData; 723 const SimpleFontData* markFontData = markGlyphData.fontData;
724 ASSERT(markFontData); 724 ASSERT(markFontData);
725 if (!markFontData) 725 if (!markFontData)
726 return 0; 726 return 0;
727 727
728 return markFontData->fontMetrics().height(); 728 return markFontData->getFontMetrics().height();
729 } 729 }
730 730
731 float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon tData*>* fallbackFonts, FloatRect* glyphBounds) const 731 float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon tData*>* fallbackFonts, FloatRect* glyphBounds) const
732 { 732 {
733 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 733 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription));
734 float width = shaper.width(this, run, fallbackFonts, glyphBounds); 734 float width = shaper.width(this, run, fallbackFonts, glyphBounds);
735 return width; 735 return width;
736 } 736 }
737 737
738 // Return the code point index for the given |x| offset into the text run. 738 // Return the code point index for the given |x| offset into the text run.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 { 829 {
830 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 830 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
831 } 831 }
832 832
833 bool Font::isFallbackValid() const 833 bool Font::isFallbackValid() const
834 { 834 {
835 return !m_fontFallbackList || m_fontFallbackList->isValid(); 835 return !m_fontFallbackList || m_fontFallbackList->isValid();
836 } 836 }
837 837
838 } // namespace blink 838 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Font.h ('k') | third_party/WebKit/Source/platform/fonts/FontFallbackIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698