Cache should work with INF values

Change-Id: I1ae8d95bb85d28fdce9e0cf270583f0224e4dfed
Bug: skia:9874
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268938
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/modules/skparagraph/src/Run.cpp b/modules/skparagraph/src/Run.cpp
index 8d9ad08..bc1618e 100644
--- a/modules/skparagraph/src/Run.cpp
+++ b/modules/skparagraph/src/Run.cpp
@@ -47,7 +47,7 @@
     fOffsets[info.glyphCount] = { 0, 0};
     fClusterIndexes[info.glyphCount] = this->leftToRight() ? info.utf8Range.end() : info.utf8Range.begin();
     fEllipsis = false;
-    fPlaceholder = nullptr;
+    fPlaceholderIndex = std::numeric_limits<size_t>::max();
 }
 
 SkShaper::RunHandler::Buffer Run::newRunBuffer() {
@@ -238,9 +238,11 @@
 
 void Run::updateMetrics(InternalLineMetrics* endlineMetrics) {
 
+    SkASSERT(isPlaceholder());
+    auto placeholderStyle = this->placeholderStyle();
     // Difference between the placeholder baseline and the line bottom
     SkScalar baselineAdjustment = 0;
-    switch (fPlaceholder->fBaseline) {
+    switch (placeholderStyle->fBaseline) {
         case TextBaseline::kAlphabetic:
             break;
 
@@ -249,11 +251,11 @@
             break;
     }
 
-    auto height = fPlaceholder->fHeight;
-    auto offset = fPlaceholder->fBaselineOffset;
+    auto height = placeholderStyle->fHeight;
+    auto offset = placeholderStyle->fBaselineOffset;
 
     fFontMetrics.fLeading = 0;
-    switch (fPlaceholder->fAlignment) {
+    switch (placeholderStyle->fAlignment) {
         case PlaceholderAlignment::kBaseline:
             fFontMetrics.fAscent = baselineAdjustment - offset;
             fFontMetrics.fDescent = baselineAdjustment + height - offset;
@@ -339,6 +341,14 @@
     return posX(pos) + fShifts[pos] + fMaster->posShift(fIndex, pos);
 }
 
+PlaceholderStyle* Run::placeholderStyle() const {
+    if (isPlaceholder()) {
+        return &fMaster->placeholders()[fPlaceholderIndex].fStyle;
+    } else {
+        return nullptr;
+    }
+}
+
 Run* Cluster::run() const {
     if (fRunIndex >= fMaster->runs().size()) {
         return nullptr;