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

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

Issue 1299873002: ALL-IN-ONE Introduce enum class TextAffinity (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-19T18:08:52 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 | « Source/core/layout/LayoutObject.cpp ('k') | Source/core/layout/LayoutTreeAsText.cpp » ('j') | 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 486 }
487 487
488 // box is first on line 488 // box is first on line
489 // and the x coordinate is to the left of the first text box left edge 489 // and the x coordinate is to the left of the first text box left edge
490 if (!box->prevLeafChildIgnoringLineBreak() && pointLineDirection < box->logi calLeft()) 490 if (!box->prevLeafChildIgnoringLineBreak() && pointLineDirection < box->logi calLeft())
491 return true; 491 return true;
492 492
493 if (!box->nextLeafChildIgnoringLineBreak()) { 493 if (!box->nextLeafChildIgnoringLineBreak()) {
494 // box is last on line 494 // box is last on line
495 // and the x coordinate is to the right of the last text box right edge 495 // and the x coordinate is to the right of the last text box right edge
496 // generate VisiblePosition, use UPSTREAM affinity if possible 496 // generate VisiblePosition, use TextAffinity::Upstream affinity if poss ible
497 shouldAffinityBeDownstream = UpstreamIfPositionIsNotAtStart; 497 shouldAffinityBeDownstream = UpstreamIfPositionIsNotAtStart;
498 return true; 498 return true;
499 } 499 }
500 500
501 return false; 501 return false;
502 } 502 }
503 503
504 static PositionWithAffinity createPositionWithAffinityForBox(const InlineBox* bo x, int offset, ShouldAffinityBeDownstream shouldAffinityBeDownstream) 504 static PositionWithAffinity createPositionWithAffinityForBox(const InlineBox* bo x, int offset, ShouldAffinityBeDownstream shouldAffinityBeDownstream)
505 { 505 {
506 EAffinity affinity = VP_DEFAULT_AFFINITY; 506 TextAffinity affinity = VP_DEFAULT_AFFINITY;
507 switch (shouldAffinityBeDownstream) { 507 switch (shouldAffinityBeDownstream) {
508 case AlwaysDownstream: 508 case AlwaysDownstream:
509 affinity = DOWNSTREAM; 509 affinity = TextAffinity::Downstream;
510 break; 510 break;
511 case AlwaysUpstream: 511 case AlwaysUpstream:
512 affinity = VP_UPSTREAM_IF_POSSIBLE; 512 affinity = VP_UPSTREAM_IF_POSSIBLE;
513 break; 513 break;
514 case UpstreamIfPositionIsNotAtStart: 514 case UpstreamIfPositionIsNotAtStart:
515 affinity = offset > box->caretMinOffset() ? VP_UPSTREAM_IF_POSSIBLE : DO WNSTREAM; 515 affinity = offset > box->caretMinOffset() ? VP_UPSTREAM_IF_POSSIBLE : Te xtAffinity::Downstream;
516 break; 516 break;
517 } 517 }
518 int textStartOffset = box->layoutObject().isText() ? toLayoutText(box->layou tObject()).textStartOffset() : 0; 518 int textStartOffset = box->layoutObject().isText() ? toLayoutText(box->layou tObject()).textStartOffset() : 0;
519 return box->layoutObject().createPositionWithAffinity(offset + textStartOffs et, affinity); 519 return box->layoutObject().createPositionWithAffinity(offset + textStartOffs et, affinity);
520 } 520 }
521 521
522 static PositionWithAffinity createPositionWithAffinityForBoxAfterAdjustingOffset ForBiDi(const InlineTextBox* box, int offset, ShouldAffinityBeDownstream shouldA ffinityBeDownstream) 522 static PositionWithAffinity createPositionWithAffinityForBoxAfterAdjustingOffset ForBiDi(const InlineTextBox* box, int offset, ShouldAffinityBeDownstream shouldA ffinityBeDownstream)
523 { 523 {
524 ASSERT(box); 524 ASSERT(box);
525 ASSERT(offset >= 0); 525 ASSERT(offset >= 0);
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 1876 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
1877 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1877 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1878 if (box->truncation() != cNoTruncation) { 1878 if (box->truncation() != cNoTruncation) {
1879 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) 1879 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox())
1880 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox); 1880 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox);
1881 } 1881 }
1882 } 1882 }
1883 } 1883 }
1884 1884
1885 } // namespace blink 1885 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutObject.cpp ('k') | Source/core/layout/LayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698