Index: Source/core/layout/LayoutText.cpp |
diff --git a/Source/core/layout/LayoutText.cpp b/Source/core/layout/LayoutText.cpp |
index ac36dc083ba35685a1bf8b5d22a0079e180c6ea5..41bbbbe289bc12a8de78ad0f66f28360f73c1f8f 100644 |
--- a/Source/core/layout/LayoutText.cpp |
+++ b/Source/core/layout/LayoutText.cpp |
@@ -441,6 +441,14 @@ void LayoutText::absoluteQuadsForRange(Vector<FloatQuad>& quads, unsigned start, |
start = std::min(start, static_cast<unsigned>(INT_MAX)); |
end = std::min(end, static_cast<unsigned>(INT_MAX)); |
+ const unsigned caretMinOffset = static_cast<unsigned>(this->caretMinOffset()); |
+ const unsigned caretMaxOffset = static_cast<unsigned>(this->caretMaxOffset()); |
+ |
+ // Narrows |start| and |end| into |caretMinOffset| and |careMaxOffset| |
+ // to ignore unrendered leading and trailing whitespaces. |
+ start = std::min(std::max(caretMinOffset, start), caretMaxOffset); |
+ end = std::min(std::max(caretMinOffset, end), caretMaxOffset); |
+ |
for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { |
// Note: box->end() returns the index of the last character, not the index past it |
if (start <= box->start() && box->end() < end) { |