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

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

Issue 1330433003: [Line Layout API] Add textStartOffset to LineLayoutText (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ignore previous patch, review hypnotoad Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/layout/api/LineLayoutText.h » ('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 17 matching lines...) Expand all
28 #include "core/dom/AXObjectCache.h" 28 #include "core/dom/AXObjectCache.h"
29 #include "core/dom/Text.h" 29 #include "core/dom/Text.h"
30 #include "core/editing/VisiblePosition.h" 30 #include "core/editing/VisiblePosition.h"
31 #include "core/editing/iterators/TextIterator.h" 31 #include "core/editing/iterators/TextIterator.h"
32 #include "core/frame/FrameView.h" 32 #include "core/frame/FrameView.h"
33 #include "core/frame/Settings.h" 33 #include "core/frame/Settings.h"
34 #include "core/html/parser/TextResourceDecoder.h" 34 #include "core/html/parser/TextResourceDecoder.h"
35 #include "core/layout/LayoutBlock.h" 35 #include "core/layout/LayoutBlock.h"
36 #include "core/layout/LayoutTextCombine.h" 36 #include "core/layout/LayoutTextCombine.h"
37 #include "core/layout/LayoutView.h" 37 #include "core/layout/LayoutView.h"
38 #include "core/layout/api/LineLayoutBox.h"
38 #include "core/layout/line/AbstractInlineTextBox.h" 39 #include "core/layout/line/AbstractInlineTextBox.h"
39 #include "core/layout/line/EllipsisBox.h" 40 #include "core/layout/line/EllipsisBox.h"
40 #include "core/layout/line/GlyphOverflow.h" 41 #include "core/layout/line/GlyphOverflow.h"
41 #include "core/layout/line/InlineTextBox.h" 42 #include "core/layout/line/InlineTextBox.h"
42 #include "core/paint/DeprecatedPaintLayer.h" 43 #include "core/paint/DeprecatedPaintLayer.h"
43 #include "platform/fonts/Character.h" 44 #include "platform/fonts/Character.h"
44 #include "platform/fonts/FontCache.h" 45 #include "platform/fonts/FontCache.h"
45 #include "platform/geometry/FloatQuad.h" 46 #include "platform/geometry/FloatQuad.h"
46 #include "platform/text/BidiResolver.h" 47 #include "platform/text/BidiResolver.h"
47 #include "platform/text/TextBreakIterator.h" 48 #include "platform/text/TextBreakIterator.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 case AlwaysDownstream: 517 case AlwaysDownstream:
517 affinity = TextAffinity::Downstream; 518 affinity = TextAffinity::Downstream;
518 break; 519 break;
519 case AlwaysUpstream: 520 case AlwaysUpstream:
520 affinity = VP_UPSTREAM_IF_POSSIBLE; 521 affinity = VP_UPSTREAM_IF_POSSIBLE;
521 break; 522 break;
522 case UpstreamIfPositionIsNotAtStart: 523 case UpstreamIfPositionIsNotAtStart:
523 affinity = offset > box->caretMinOffset() ? VP_UPSTREAM_IF_POSSIBLE : Te xtAffinity::Downstream; 524 affinity = offset > box->caretMinOffset() ? VP_UPSTREAM_IF_POSSIBLE : Te xtAffinity::Downstream;
524 break; 525 break;
525 } 526 }
526 int textStartOffset = box->layoutObject().isText() ? toLayoutText(box->layou tObject()).textStartOffset() : 0; 527 int textStartOffset = box->lineLayoutItem().isText() ? LineLayoutText(box->l ineLayoutItem()).textStartOffset() : 0;
527 return box->layoutObject().createPositionWithAffinity(offset + textStartOffs et, affinity); 528 return box->layoutObject().createPositionWithAffinity(offset + textStartOffs et, affinity);
528 } 529 }
529 530
530 static PositionWithAffinity createPositionWithAffinityForBoxAfterAdjustingOffset ForBiDi(const InlineTextBox* box, int offset, ShouldAffinityBeDownstream shouldA ffinityBeDownstream) 531 static PositionWithAffinity createPositionWithAffinityForBoxAfterAdjustingOffset ForBiDi(const InlineTextBox* box, int offset, ShouldAffinityBeDownstream shouldA ffinityBeDownstream)
531 { 532 {
532 ASSERT(box); 533 ASSERT(box);
533 ASSERT(offset >= 0); 534 ASSERT(offset >= 0);
534 535
535 if (offset && static_cast<unsigned>(offset) < box->len()) 536 if (offset && static_cast<unsigned>(offset) < box->len())
536 return createPositionWithAffinityForBox(box, box->start() + offset, shou ldAffinityBeDownstream); 537 return createPositionWithAffinityForBox(box, box->start() + offset, shou ldAffinityBeDownstream);
537 538
538 bool positionIsAtStartOfBox = !offset; 539 bool positionIsAtStartOfBox = !offset;
539 if (positionIsAtStartOfBox == box->isLeftToRightDirection()) { 540 if (positionIsAtStartOfBox == box->isLeftToRightDirection()) {
540 // offset is on the left edge 541 // offset is on the left edge
541 542
542 const InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak(); 543 const InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak();
543 if ((prevBox && prevBox->bidiLevel() == box->bidiLevel()) 544 if ((prevBox && prevBox->bidiLevel() == box->bidiLevel())
544 || box->layoutObject().containingBlock()->style()->direction() == bo x->direction()) // FIXME: left on 12CBA 545 || box->lineLayoutItem().containingBlock().style()->direction() == b ox->direction()) // FIXME: left on 12CBA
545 return createPositionWithAffinityForBox(box, box->caretLeftmostOffse t(), shouldAffinityBeDownstream); 546 return createPositionWithAffinityForBox(box, box->caretLeftmostOffse t(), shouldAffinityBeDownstream);
546 547
547 if (prevBox && prevBox->bidiLevel() > box->bidiLevel()) { 548 if (prevBox && prevBox->bidiLevel() > box->bidiLevel()) {
548 // e.g. left of B in aDC12BAb 549 // e.g. left of B in aDC12BAb
549 const InlineBox* leftmostBox; 550 const InlineBox* leftmostBox;
550 do { 551 do {
551 leftmostBox = prevBox; 552 leftmostBox = prevBox;
552 prevBox = leftmostBox->prevLeafChildIgnoringLineBreak(); 553 prevBox = leftmostBox->prevLeafChildIgnoringLineBreak();
553 } while (prevBox && prevBox->bidiLevel() > box->bidiLevel()); 554 } while (prevBox && prevBox->bidiLevel() > box->bidiLevel());
554 return createPositionWithAffinityForBox(leftmostBox, leftmostBox->ca retRightmostOffset(), shouldAffinityBeDownstream); 555 return createPositionWithAffinityForBox(leftmostBox, leftmostBox->ca retRightmostOffset(), shouldAffinityBeDownstream);
555 } 556 }
556 557
557 if (!prevBox || prevBox->bidiLevel() < box->bidiLevel()) { 558 if (!prevBox || prevBox->bidiLevel() < box->bidiLevel()) {
558 // e.g. left of D in aDC12BAb 559 // e.g. left of D in aDC12BAb
559 const InlineBox* rightmostBox; 560 const InlineBox* rightmostBox;
560 const InlineBox* nextBox = box; 561 const InlineBox* nextBox = box;
561 do { 562 do {
562 rightmostBox = nextBox; 563 rightmostBox = nextBox;
563 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak(); 564 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak();
564 } while (nextBox && nextBox->bidiLevel() >= box->bidiLevel()); 565 } while (nextBox && nextBox->bidiLevel() >= box->bidiLevel());
565 return createPositionWithAffinityForBox(rightmostBox, 566 return createPositionWithAffinityForBox(rightmostBox,
566 box->isLeftToRightDirection() ? rightmostBox->caretMaxOffset() : rightmostBox->caretMinOffset(), shouldAffinityBeDownstream); 567 box->isLeftToRightDirection() ? rightmostBox->caretMaxOffset() : rightmostBox->caretMinOffset(), shouldAffinityBeDownstream);
567 } 568 }
568 569
569 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream); 570 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream);
570 } 571 }
571 572
572 const InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak(); 573 const InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak();
573 if ((nextBox && nextBox->bidiLevel() == box->bidiLevel()) 574 if ((nextBox && nextBox->bidiLevel() == box->bidiLevel())
574 || box->layoutObject().containingBlock()->style()->direction() == box->d irection()) 575 || box->lineLayoutItem().containingBlock().style()->direction() == box-> direction())
575 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream); 576 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream);
576 577
577 // offset is on the right edge 578 // offset is on the right edge
578 if (nextBox && nextBox->bidiLevel() > box->bidiLevel()) { 579 if (nextBox && nextBox->bidiLevel() > box->bidiLevel()) {
579 // e.g. right of C in aDC12BAb 580 // e.g. right of C in aDC12BAb
580 const InlineBox* rightmostBox; 581 const InlineBox* rightmostBox;
581 do { 582 do {
582 rightmostBox = nextBox; 583 rightmostBox = nextBox;
583 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak(); 584 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak();
584 } while (nextBox && nextBox->bidiLevel() > box->bidiLevel()); 585 } while (nextBox && nextBox->bidiLevel() > box->bidiLevel());
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 1880 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
1880 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1881 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1881 if (box->truncation() != cNoTruncation) { 1882 if (box->truncation() != cNoTruncation) {
1882 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) 1883 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox())
1883 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox); 1884 paintInvalidationContainer.invalidateDisplayItemClientOnBacking( *ellipsisBox);
1884 } 1885 }
1885 } 1886 }
1886 } 1887 }
1887 1888
1888 } // namespace blink 1889 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/layout/api/LineLayoutText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698