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

Unified Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.h

Issue 2153643003: Change ShapeResultShaping::computeSpacing to use TextRun::operator[] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.h
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.h b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.h
index 926d8fb6698d135ebd54fbbfc3cbb9e9046b9138..2f2ccf9299787a8b9dd303e7e5139a9991369b76 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.h
+++ b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.h
@@ -27,14 +27,10 @@ public:
private:
bool hasExpansion() const { return m_expansionOpportunityCount; }
bool isAfterExpansion() const { return m_isAfterExpansion; }
- template <typename CharType>
- bool isFirstRun(const CharType*) const;
+ bool isFirstRun(const TextRun&) const;
float nextExpansion();
- template <typename CharType>
- float computeSpacing(const CharType*, size_t, size_t index, float& offset);
-
const TextRun& m_textRun;
float m_letterSpacing;
float m_wordSpacing;
@@ -49,72 +45,6 @@ private:
bool m_isVerticalOffset;
};
-template <>
-inline bool ShapeResultSpacing::isFirstRun(const LChar* p) const
-{
- return p == m_textRun.characters8();
-}
-
-template <>
-inline bool ShapeResultSpacing::isFirstRun(const UChar* p) const
-{
- return p == m_textRun.characters16();
-}
-
-template <typename CharType>
-float ShapeResultSpacing::computeSpacing(const CharType* characters,
- size_t size, size_t index, float& offset)
-{
- characters += index;
- UChar32 character = characters[0];
- bool treatAsSpace = (Character::treatAsSpace(character)
- || (m_normalizeSpace && Character::isNormalizedCanvasSpaceCharacter(character)))
- && (character != '\t' || !m_allowTabs);
- if (treatAsSpace && character != noBreakSpaceCharacter)
- character = spaceCharacter;
-
- float spacing = 0;
- if (m_letterSpacing && !Character::treatAsZeroWidthSpace(character))
- spacing += m_letterSpacing;
-
- if (treatAsSpace && (index || !isFirstRun(characters) || character == noBreakSpaceCharacter))
- spacing += m_wordSpacing;
-
- if (!hasExpansion())
- return spacing;
-
- if (treatAsSpace)
- return spacing + nextExpansion();
-
- if (sizeof(CharType) == sizeof(LChar)
- || m_textJustify != TextJustify::TextJustifyAuto) {
- return spacing;
- }
-
- // isCJKIdeographOrSymbol() has expansion opportunities both before and
- // after each character.
- // http://www.w3.org/TR/jlreq/#line_adjustment
- if (U16_IS_LEAD(character) && index + 1 < size && U16_IS_TRAIL(characters[1]))
- character = U16_GET_SUPPLEMENTARY(character, characters[1]);
- if (!Character::isCJKIdeographOrSymbol(character)) {
- m_isAfterExpansion = false;
- return spacing;
- }
-
- if (!m_isAfterExpansion) {
- // Take the expansion opportunity before this ideograph.
- float expandBefore = nextExpansion();
- if (expandBefore) {
- offset += expandBefore;
- spacing += expandBefore;
- }
- if (!hasExpansion())
- return spacing;
- }
-
- return spacing + nextExpansion();
-}
-
} // namespace blink
#endif
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698