Commit MetaInfo

Revisionbd858c95529ea79b6b1c613db6ad1d6f343364cb (tree)
Time2017-07-03 00:54:01
Author <exeal@user...>

Log Message

fixed: viewer.locations.nextVisualLine function might return an invalid position.

Change Summary

Incremental Difference

diff -r 745365eacc21 -r bd858c95529e ascension/src/viewer/visual-point.cpp
--- a/ascension/src/viewer/visual-point.cpp Sun Jul 02 23:39:37 2017 +0900
+++ b/ascension/src/viewer/visual-point.cpp Mon Jul 03 00:54:01 2017 +0900
@@ -585,7 +585,6 @@
585585 * @see kernel#locations#nextLine
586586 */
587587 VisualDestinationProxy nextVisualLine(const VisualPoint& p, Direction direction, Index lines /* = 1 */) {
588- // ISSUE: LineLayoutVector.offsetVisualLine(VisualLine&, SignedIndex) does not use calculated layouts.
589588 const auto hit(p.hit());
590589 auto line(kernel::line(hit.characterIndex()));
591590 auto inlineHit(hit.isLeadingEdge() ?
@@ -603,18 +602,17 @@
603602 }
604603 graphics::font::VisualLine visualLine(line, subline);
605604 renderer->layouts().offsetVisualLine(visualLine,
606- (direction == Direction::forward()) ? static_cast<SignedIndex>(lines) : -static_cast<SignedIndex>(lines));
605+ (direction == Direction::forward()) ? static_cast<SignedIndex>(lines) : -static_cast<SignedIndex>(lines)); // ISSUE: This uses USE_CALCULATED_LAYOUT.
607606 if(p.positionInVisualLine_ == boost::none)
608607 const_cast<viewer::VisualPoint&>(p).rememberPositionInVisualLine();
609608 line = visualLine.line;
610- if(nullptr != (layout = renderer->layouts().at(visualLine.line))) {
611- inlineHit = layout->hitTestCharacter(
612- presentation::FlowRelativeTwoAxes<graphics::Scalar>(
613- presentation::_ipd = *p.positionInVisualLine_ - graphics::font::lineStartEdge(*layout, p.textArea().viewport()->contentMeasure()),
614- presentation::_bpd = graphics::font::TextLayout::LineMetricsIterator(*layout, visualLine.subline).baselineOffset()));
615-// if(layout->lineAt(inlineHit) != visualLine.subline)
616-// np = nextCharacter(p.document(), np, Direction::backward(), GRAPHEME_CLUSTER);
617- }
609+ layout = &const_cast<graphics::font::LineLayoutVector&>(renderer->layouts()).at(visualLine.line, graphics::font::LineLayoutVector::USE_CALCULATED_LAYOUT);
610+ inlineHit = layout->hitTestCharacter(
611+ presentation::FlowRelativeTwoAxes<graphics::Scalar>(
612+ presentation::_ipd = *p.positionInVisualLine_ - graphics::font::lineStartEdge(*layout, p.textArea().viewport()->contentMeasure()),
613+ presentation::_bpd = graphics::font::TextLayout::LineMetricsIterator(*layout, visualLine.subline).baselineOffset()));
614+// if(layout->lineAt(inlineHit) != visualLine.subline)
615+// np = nextCharacter(p.document(), np, Direction::backward(), GRAPHEME_CLUSTER);
618616
619617 const kernel::Position temp(line, inlineHit.characterIndex());
620618 return viewer::detail::VisualDestinationProxyMaker::make(
Show on old repository browser