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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2792953002: Fix unexpected erasing textQuad (Closed)
Patch Set: comment added. Created 3 years, 8 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 | « third_party/WebKit/Source/core/dom/RangeTest.cpp ('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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // coordinates are unsigneds, so changing this function to take ints causes 373 // coordinates are unsigneds, so changing this function to take ints causes
374 // various internal mismatches. But selectionRect takes ints, and passing 374 // various internal mismatches. But selectionRect takes ints, and passing
375 // UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take 375 // UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take
376 // unsigneds, but that would cause many ripple effects, so for now we'll just 376 // unsigneds, but that would cause many ripple effects, so for now we'll just
377 // clamp our unsigned parameters to INT_MAX. 377 // clamp our unsigned parameters to INT_MAX.
378 ASSERT(end == UINT_MAX || end <= INT_MAX); 378 ASSERT(end == UINT_MAX || end <= INT_MAX);
379 ASSERT(start <= INT_MAX); 379 ASSERT(start <= INT_MAX);
380 start = std::min(start, static_cast<unsigned>(INT_MAX)); 380 start = std::min(start, static_cast<unsigned>(INT_MAX));
381 end = std::min(end, static_cast<unsigned>(INT_MAX)); 381 end = std::min(end, static_cast<unsigned>(INT_MAX));
382 382
383 bool hasCheckedBoxInRange = false; 383 // This function is always called in sequence that this check should work.
384 bool hasCheckedBoxInRange = !rects.isEmpty();
384 385
385 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 386 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
386 // Note: box->end() returns the index of the last character, not the index 387 // Note: box->end() returns the index of the last character, not the index
387 // past it 388 // past it
388 if (start <= box->start() && box->end() < end) { 389 if (start <= box->start() && box->end() < end) {
389 FloatRect r(box->frameRect()); 390 FloatRect r(box->frameRect());
390 if (useSelectionHeight) { 391 if (useSelectionHeight) {
391 LayoutRect selectionRect = box->localSelectionRect(start, end); 392 LayoutRect selectionRect = box->localSelectionRect(start, end);
392 if (box->isHorizontal()) { 393 if (box->isHorizontal()) {
393 r.setHeight(selectionRect.height().toFloat()); 394 r.setHeight(selectionRect.height().toFloat());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 end = std::min(end, static_cast<unsigned>(INT_MAX)); 497 end = std::min(end, static_cast<unsigned>(INT_MAX));
497 498
498 const unsigned caretMinOffset = static_cast<unsigned>(this->caretMinOffset()); 499 const unsigned caretMinOffset = static_cast<unsigned>(this->caretMinOffset());
499 const unsigned caretMaxOffset = static_cast<unsigned>(this->caretMaxOffset()); 500 const unsigned caretMaxOffset = static_cast<unsigned>(this->caretMaxOffset());
500 501
501 // Narrows |start| and |end| into |caretMinOffset| and |careMaxOffset| 502 // Narrows |start| and |end| into |caretMinOffset| and |careMaxOffset|
502 // to ignore unrendered leading and trailing whitespaces. 503 // to ignore unrendered leading and trailing whitespaces.
503 start = std::min(std::max(caretMinOffset, start), caretMaxOffset); 504 start = std::min(std::max(caretMinOffset, start), caretMaxOffset);
504 end = std::min(std::max(caretMinOffset, end), caretMaxOffset); 505 end = std::min(std::max(caretMinOffset, end), caretMaxOffset);
505 506
506 bool hasCheckedBoxInRange = false; 507 // This function is always called in sequence that this check should work.
508 bool hasCheckedBoxInRange = !quads.isEmpty();
507 509
508 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 510 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
509 // Note: box->end() returns the index of the last character, not the index 511 // Note: box->end() returns the index of the last character, not the index
510 // past it 512 // past it
511 if (start <= box->start() && box->end() < end) { 513 if (start <= box->start() && box->end() < end) {
512 LayoutRect r(box->frameRect()); 514 LayoutRect r(box->frameRect());
513 if (useSelectionHeight) { 515 if (useSelectionHeight) {
514 LayoutRect selectionRect = box->localSelectionRect(start, end); 516 LayoutRect selectionRect = box->localSelectionRect(start, end);
515 if (box->isHorizontal()) { 517 if (box->isHorizontal()) {
516 r.setHeight(selectionRect.height()); 518 r.setHeight(selectionRect.height());
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 LayoutRect rect = LayoutRect( 2092 LayoutRect rect = LayoutRect(
2091 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 2093 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
2092 LayoutBlock* block = containingBlock(); 2094 LayoutBlock* block = containingBlock();
2093 if (block && hasTextBoxes()) 2095 if (block && hasTextBoxes())
2094 block->adjustChildDebugRect(rect); 2096 block->adjustChildDebugRect(rect);
2095 2097
2096 return rect; 2098 return rect;
2097 } 2099 }
2098 2100
2099 } // namespace blink 2101 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/RangeTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698