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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX 434 // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX
435 // to mean "all the way to the end". InlineTextBox coordinates are unsigneds , so changing this 435 // to mean "all the way to the end". InlineTextBox coordinates are unsigneds , so changing this
436 // function to take ints causes various internal mismatches. But selectionRe ct takes ints, and 436 // function to take ints causes various internal mismatches. But selectionRe ct takes ints, and
437 // passing UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take unsigneds, but 437 // passing UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take unsigneds, but
438 // that would cause many ripple effects, so for now we'll just clamp our uns igned parameters to INT_MAX. 438 // that would cause many ripple effects, so for now we'll just clamp our uns igned parameters to INT_MAX.
439 ASSERT(end == UINT_MAX || end <= INT_MAX); 439 ASSERT(end == UINT_MAX || end <= INT_MAX);
440 ASSERT(start <= INT_MAX); 440 ASSERT(start <= INT_MAX);
441 start = std::min(start, static_cast<unsigned>(INT_MAX)); 441 start = std::min(start, static_cast<unsigned>(INT_MAX));
442 end = std::min(end, static_cast<unsigned>(INT_MAX)); 442 end = std::min(end, static_cast<unsigned>(INT_MAX));
443 443
444 const unsigned caretMinOffset = static_cast<unsigned>(this->caretMinOffset() );
445 const unsigned caretMaxOffset = static_cast<unsigned>(this->caretMaxOffset() );
446
447 // Narrows |start| and |end| into |caretMinOffset| and |careMaxOffset|
448 // to ignore unrendered leading and trailing whitespaces.
449 start = std::min(std::max(caretMinOffset, start), caretMaxOffset);
450 end = std::min(std::max(caretMinOffset, end), caretMaxOffset);
451
444 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 452 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
445 // Note: box->end() returns the index of the last character, not the ind ex past it 453 // Note: box->end() returns the index of the last character, not the ind ex past it
446 if (start <= box->start() && box->end() < end) { 454 if (start <= box->start() && box->end() < end) {
447 LayoutRect r(box->calculateBoundaries()); 455 LayoutRect r(box->calculateBoundaries());
448 if (useSelectionHeight) { 456 if (useSelectionHeight) {
449 LayoutRect selectionRect = box->localSelectionRect(start, end); 457 LayoutRect selectionRect = box->localSelectionRect(start, end);
450 if (box->isHorizontal()) { 458 if (box->isHorizontal()) {
451 r.setHeight(selectionRect.height()); 459 r.setHeight(selectionRect.height());
452 r.setY(selectionRect.y()); 460 r.setY(selectionRect.y());
453 } else { 461 } else {
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 1884 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
1877 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1885 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1878 if (box->truncation() != cNoTruncation) { 1886 if (box->truncation() != cNoTruncation) {
1879 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) 1887 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox())
1880 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox); 1888 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox);
1881 } 1889 }
1882 } 1890 }
1883 } 1891 }
1884 1892
1885 } // namespace blink 1893 } // namespace blink
OLDNEW
« 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