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

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

Issue 2902053003: Refactor LayoutText::AbsoluteQuadsForRange()
Patch Set: Created 3 years, 6 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 | « no previous file | 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 end = std::min(std::max(caret_min_offset, end), caret_max_offset); 482 end = std::min(std::max(caret_min_offset, end), caret_max_offset);
483 483
484 // This function is always called in sequence that this check should work. 484 // This function is always called in sequence that this check should work.
485 bool has_checked_box_in_range = !quads.IsEmpty(); 485 bool has_checked_box_in_range = !quads.IsEmpty();
486 486
487 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) { 487 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) {
488 // Note: box->end() returns the index of the last character, not the index 488 // Note: box->end() returns the index of the last character, not the index
489 // past it 489 // past it
490 if (start <= box->Start() && box->end() < end) { 490 if (start <= box->Start() && box->end() < end) {
491 LayoutRect r(box->FrameRect()); 491 LayoutRect r(box->FrameRect());
492 if (!has_checked_box_in_range) { 492 has_checked_box_in_range = true;
493 has_checked_box_in_range = true;
494 quads.clear();
495 }
496 quads.push_back(LocalToAbsoluteQuad(FloatRect(r))); 493 quads.push_back(LocalToAbsoluteQuad(FloatRect(r)));
497 } else if ((box->Start() <= start && start <= box->end()) || 494 } else if ((box->Start() <= start && start <= box->end()) ||
498 (box->Start() < end && end <= box->end())) { 495 (box->Start() < end && end <= box->end())) {
499 FloatRect rect = LocalQuadForTextBox(box, start, end); 496 FloatRect rect = LocalQuadForTextBox(box, start, end);
500 if (!rect.IsZero()) { 497 if (!rect.IsZero()) {
501 if (!has_checked_box_in_range) { 498 has_checked_box_in_range = true;
502 has_checked_box_in_range = true;
503 quads.clear();
504 }
505 quads.push_back(LocalToAbsoluteQuad(rect)); 499 quads.push_back(LocalToAbsoluteQuad(rect));
506 } 500 }
507 } else if (!has_checked_box_in_range) { 501 } else if (!has_checked_box_in_range) {
508 // consider when the offset of range is area of leading or trailing 502 // consider when the offset of range is area of leading or trailing
509 // whitespace 503 // whitespace
510 FloatRect rect = LocalQuadForTextBox(box, start, end); 504 FloatRect rect = LocalQuadForTextBox(box, start, end);
511 if (!rect.IsZero()) 505 if (!rect.IsZero())
512 quads.push_back(LocalToAbsoluteQuad(rect).EnclosingBoundingBox()); 506 quads.push_back(LocalToAbsoluteQuad(rect).EnclosingBoundingBox());
513 } 507 }
514 } 508 }
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 LayoutRect rect = LayoutRect( 2043 LayoutRect rect = LayoutRect(
2050 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); 2044 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height()));
2051 LayoutBlock* block = ContainingBlock(); 2045 LayoutBlock* block = ContainingBlock();
2052 if (block && HasTextBoxes()) 2046 if (block && HasTextBoxes())
2053 block->AdjustChildDebugRect(rect); 2047 block->AdjustChildDebugRect(rect);
2054 2048
2055 return rect; 2049 return rect;
2056 } 2050 }
2057 2051
2058 } // namespace blink 2052 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698