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

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

Issue 2518363003: Refactor InlineBox::calculateBoundaries() (Closed)
Patch Set: Rebase Created 4 years 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
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // clamp our unsigned parameters to INT_MAX. 366 // clamp our unsigned parameters to INT_MAX.
367 ASSERT(end == UINT_MAX || end <= INT_MAX); 367 ASSERT(end == UINT_MAX || end <= INT_MAX);
368 ASSERT(start <= INT_MAX); 368 ASSERT(start <= INT_MAX);
369 start = std::min(start, static_cast<unsigned>(INT_MAX)); 369 start = std::min(start, static_cast<unsigned>(INT_MAX));
370 end = std::min(end, static_cast<unsigned>(INT_MAX)); 370 end = std::min(end, static_cast<unsigned>(INT_MAX));
371 371
372 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 372 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
373 // Note: box->end() returns the index of the last character, not the index 373 // Note: box->end() returns the index of the last character, not the index
374 // past it 374 // past it
375 if (start <= box->start() && box->end() < end) { 375 if (start <= box->start() && box->end() < end) {
376 FloatRect r(box->calculateBoundaries()); 376 FloatRect r(box->frameRect());
377 if (useSelectionHeight) { 377 if (useSelectionHeight) {
378 LayoutRect selectionRect = box->localSelectionRect(start, end); 378 LayoutRect selectionRect = box->localSelectionRect(start, end);
379 if (box->isHorizontal()) { 379 if (box->isHorizontal()) {
380 r.setHeight(selectionRect.height().toFloat()); 380 r.setHeight(selectionRect.height().toFloat());
381 r.setY(selectionRect.y().toFloat()); 381 r.setY(selectionRect.y().toFloat());
382 } else { 382 } else {
383 r.setWidth(selectionRect.width().toFloat()); 383 r.setWidth(selectionRect.width().toFloat());
384 r.setX(selectionRect.x().toFloat()); 384 r.setX(selectionRect.x().toFloat());
385 } 385 }
386 } 386 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 return ellipsis->selectionRect(); 418 return ellipsis->selectionRect();
419 } 419 }
420 420
421 return IntRect(); 421 return IntRect();
422 } 422 }
423 423
424 void LayoutText::quads(Vector<FloatQuad>& quads, 424 void LayoutText::quads(Vector<FloatQuad>& quads,
425 ClippingOption option, 425 ClippingOption option,
426 LocalOrAbsoluteOption localOrAbsolute) const { 426 LocalOrAbsoluteOption localOrAbsolute) const {
427 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 427 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
428 FloatRect boundaries(box->calculateBoundaries()); 428 FloatRect boundaries(box->frameRect());
429 429
430 // Shorten the width of this text box if it ends in an ellipsis. 430 // Shorten the width of this text box if it ends in an ellipsis.
431 // FIXME: ellipsisRectForBox should switch to return FloatRect soon with the 431 // FIXME: ellipsisRectForBox should switch to return FloatRect soon with the
432 // subpixellayout branch. 432 // subpixellayout branch.
433 IntRect ellipsisRect = (option == ClipToEllipsis) 433 IntRect ellipsisRect = (option == ClipToEllipsis)
434 ? ellipsisRectForBox(box, 0, textLength()) 434 ? ellipsisRectForBox(box, 0, textLength())
435 : IntRect(); 435 : IntRect();
436 if (!ellipsisRect.isEmpty()) { 436 if (!ellipsisRect.isEmpty()) {
437 if (style()->isHorizontalWritingMode()) 437 if (style()->isHorizontalWritingMode())
438 boundaries.setWidth(ellipsisRect.maxX() - boundaries.x()); 438 boundaries.setWidth(ellipsisRect.maxX() - boundaries.x());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 471
472 // Narrows |start| and |end| into |caretMinOffset| and |careMaxOffset| 472 // Narrows |start| and |end| into |caretMinOffset| and |careMaxOffset|
473 // to ignore unrendered leading and trailing whitespaces. 473 // to ignore unrendered leading and trailing whitespaces.
474 start = std::min(std::max(caretMinOffset, start), caretMaxOffset); 474 start = std::min(std::max(caretMinOffset, start), caretMaxOffset);
475 end = std::min(std::max(caretMinOffset, end), caretMaxOffset); 475 end = std::min(std::max(caretMinOffset, end), caretMaxOffset);
476 476
477 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 477 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
478 // Note: box->end() returns the index of the last character, not the index 478 // Note: box->end() returns the index of the last character, not the index
479 // past it 479 // past it
480 if (start <= box->start() && box->end() < end) { 480 if (start <= box->start() && box->end() < end) {
481 LayoutRect r(box->calculateBoundaries()); 481 LayoutRect r(box->frameRect());
482 if (useSelectionHeight) { 482 if (useSelectionHeight) {
483 LayoutRect selectionRect = box->localSelectionRect(start, end); 483 LayoutRect selectionRect = box->localSelectionRect(start, end);
484 if (box->isHorizontal()) { 484 if (box->isHorizontal()) {
485 r.setHeight(selectionRect.height()); 485 r.setHeight(selectionRect.height());
486 r.setY(selectionRect.y()); 486 r.setY(selectionRect.y());
487 } else { 487 } else {
488 r.setWidth(selectionRect.width()); 488 r.setWidth(selectionRect.width());
489 r.setX(selectionRect.x()); 489 r.setX(selectionRect.x());
490 } 490 }
491 } 491 }
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 LayoutRect rect = LayoutRect( 1974 LayoutRect rect = LayoutRect(
1975 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 1975 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
1976 LayoutBlock* block = containingBlock(); 1976 LayoutBlock* block = containingBlock();
1977 if (block && hasTextBoxes()) 1977 if (block && hasTextBoxes())
1978 block->adjustChildDebugRect(rect); 1978 block->adjustChildDebugRect(rect);
1979 1979
1980 return rect; 1980 return rect;
1981 } 1981 }
1982 1982
1983 } // namespace blink 1983 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp ('k') | third_party/WebKit/Source/core/layout/ScrollAnchor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698