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

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

Issue 2063813003: Guard against invalid glyph shaping results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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) 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 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 753
754 Vector<CharacterRange> Font::individualCharacterRanges(const TextRun& run) const 754 Vector<CharacterRange> Font::individualCharacterRanges(const TextRun& run) const
755 { 755 {
756 // TODO(pdr): Android is temporarily (crbug.com/577306) using the old simple 756 // TODO(pdr): Android is temporarily (crbug.com/577306) using the old simple
757 // shaper and using the complex shaper here can show differences between 757 // shaper and using the complex shaper here can show differences between
758 // the two shapers. This function is currently only called through SVG 758 // the two shapers. This function is currently only called through SVG
759 // which now exclusively uses the complex shaper, so the primary difference 759 // which now exclusively uses the complex shaper, so the primary difference
760 // will be improved shaping in SVG when compared to HTML. 760 // will be improved shaping in SVG when compared to HTML.
761 FontCachePurgePreventer purgePreventer; 761 FontCachePurgePreventer purgePreventer;
762 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription)); 762 CachingWordShaper shaper(m_fontFallbackList->shapeCache(m_fontDescription));
763 return shaper.individualCharacterRanges(this, run); 763 auto ranges = shaper.individualCharacterRanges(this, run);
764 DCHECK_EQ(ranges.size(), static_cast<unsigned>(run.length()));
765 return ranges;
764 } 766 }
765 767
766 float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont Data*>* fallbackFonts, FloatRect* glyphBounds) const 768 float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont Data*>* fallbackFonts, FloatRect* glyphBounds) const
767 { 769 {
768 SimpleShaper shaper(this, run, nullptr, fallbackFonts, glyphBounds); 770 SimpleShaper shaper(this, run, nullptr, fallbackFonts, glyphBounds);
769 shaper.advance(run.length()); 771 shaper.advance(run.length());
770 return shaper.runWidthSoFar(); 772 return shaper.runWidthSoFar();
771 } 773 }
772 774
773 FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& point, int h, int from, int to, bool accountForGlyphBounds) const 775 FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& point, int h, int from, int to, bool accountForGlyphBounds) const
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 { 842 {
841 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 843 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
842 } 844 }
843 845
844 bool Font::isFallbackValid() const 846 bool Font::isFallbackValid() const
845 { 847 {
846 return !m_fontFallbackList || m_fontFallbackList->isValid(); 848 return !m_fontFallbackList || m_fontFallbackList->isValid();
847 } 849 }
848 850
849 } // namespace blink 851 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698