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

Unified Diff: Source/core/layout/LayoutText.cpp

Issue 361683002: Make LayoutText::absoluteQuadsForRange to consider leading/trailing whitespaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-19T15:06:27 Follow review comments Created 5 years, 4 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 | « LayoutTests/fast/dom/Range/getClientRects-leading-trailing-whitespaces.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « LayoutTests/fast/dom/Range/getClientRects-leading-trailing-whitespaces.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698