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

Side by Side Diff: Source/core/rendering/RenderText.cpp

Issue 184023003: Make InlineBox::renderer() and related subclass methods return reference. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: No reference reassignment. Created 6 years, 9 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/rendering/RenderReplaced.cpp ('k') | Source/core/rendering/RootInlineBox.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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 case AlwaysDownstream: 529 case AlwaysDownstream:
530 affinity = DOWNSTREAM; 530 affinity = DOWNSTREAM;
531 break; 531 break;
532 case AlwaysUpstream: 532 case AlwaysUpstream:
533 affinity = VP_UPSTREAM_IF_POSSIBLE; 533 affinity = VP_UPSTREAM_IF_POSSIBLE;
534 break; 534 break;
535 case UpstreamIfPositionIsNotAtStart: 535 case UpstreamIfPositionIsNotAtStart:
536 affinity = offset > box->caretMinOffset() ? VP_UPSTREAM_IF_POSSIBLE : DO WNSTREAM; 536 affinity = offset > box->caretMinOffset() ? VP_UPSTREAM_IF_POSSIBLE : DO WNSTREAM;
537 break; 537 break;
538 } 538 }
539 int textStartOffset = box->renderer()->isText() ? toRenderText(box->renderer ())->textStartOffset() : 0; 539 int textStartOffset = box->renderer().isText() ? toRenderText(box->renderer( )).textStartOffset() : 0;
540 return box->renderer()->createPositionWithAffinity(offset + textStartOffset, affinity); 540 return box->renderer().createPositionWithAffinity(offset + textStartOffset, affinity);
541 } 541 }
542 542
543 static PositionWithAffinity createPositionWithAffinityForBoxAfterAdjustingOffset ForBiDi(const InlineTextBox* box, int offset, ShouldAffinityBeDownstream shouldA ffinityBeDownstream) 543 static PositionWithAffinity createPositionWithAffinityForBoxAfterAdjustingOffset ForBiDi(const InlineTextBox* box, int offset, ShouldAffinityBeDownstream shouldA ffinityBeDownstream)
544 { 544 {
545 ASSERT(box); 545 ASSERT(box);
546 ASSERT(box->renderer());
547 ASSERT(offset >= 0); 546 ASSERT(offset >= 0);
548 547
549 if (offset && static_cast<unsigned>(offset) < box->len()) 548 if (offset && static_cast<unsigned>(offset) < box->len())
550 return createPositionWithAffinityForBox(box, box->start() + offset, shou ldAffinityBeDownstream); 549 return createPositionWithAffinityForBox(box, box->start() + offset, shou ldAffinityBeDownstream);
551 550
552 bool positionIsAtStartOfBox = !offset; 551 bool positionIsAtStartOfBox = !offset;
553 if (positionIsAtStartOfBox == box->isLeftToRightDirection()) { 552 if (positionIsAtStartOfBox == box->isLeftToRightDirection()) {
554 // offset is on the left edge 553 // offset is on the left edge
555 554
556 const InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak(); 555 const InlineBox* prevBox = box->prevLeafChildIgnoringLineBreak();
557 if ((prevBox && prevBox->bidiLevel() == box->bidiLevel()) 556 if ((prevBox && prevBox->bidiLevel() == box->bidiLevel())
558 || box->renderer()->containingBlock()->style()->direction() == box-> direction()) // FIXME: left on 12CBA 557 || box->renderer().containingBlock()->style()->direction() == box->d irection()) // FIXME: left on 12CBA
559 return createPositionWithAffinityForBox(box, box->caretLeftmostOffse t(), shouldAffinityBeDownstream); 558 return createPositionWithAffinityForBox(box, box->caretLeftmostOffse t(), shouldAffinityBeDownstream);
560 559
561 if (prevBox && prevBox->bidiLevel() > box->bidiLevel()) { 560 if (prevBox && prevBox->bidiLevel() > box->bidiLevel()) {
562 // e.g. left of B in aDC12BAb 561 // e.g. left of B in aDC12BAb
563 const InlineBox* leftmostBox; 562 const InlineBox* leftmostBox;
564 do { 563 do {
565 leftmostBox = prevBox; 564 leftmostBox = prevBox;
566 prevBox = leftmostBox->prevLeafChildIgnoringLineBreak(); 565 prevBox = leftmostBox->prevLeafChildIgnoringLineBreak();
567 } while (prevBox && prevBox->bidiLevel() > box->bidiLevel()); 566 } while (prevBox && prevBox->bidiLevel() > box->bidiLevel());
568 return createPositionWithAffinityForBox(leftmostBox, leftmostBox->ca retRightmostOffset(), shouldAffinityBeDownstream); 567 return createPositionWithAffinityForBox(leftmostBox, leftmostBox->ca retRightmostOffset(), shouldAffinityBeDownstream);
569 } 568 }
570 569
571 if (!prevBox || prevBox->bidiLevel() < box->bidiLevel()) { 570 if (!prevBox || prevBox->bidiLevel() < box->bidiLevel()) {
572 // e.g. left of D in aDC12BAb 571 // e.g. left of D in aDC12BAb
573 const InlineBox* rightmostBox; 572 const InlineBox* rightmostBox;
574 const InlineBox* nextBox = box; 573 const InlineBox* nextBox = box;
575 do { 574 do {
576 rightmostBox = nextBox; 575 rightmostBox = nextBox;
577 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak(); 576 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak();
578 } while (nextBox && nextBox->bidiLevel() >= box->bidiLevel()); 577 } while (nextBox && nextBox->bidiLevel() >= box->bidiLevel());
579 return createPositionWithAffinityForBox(rightmostBox, 578 return createPositionWithAffinityForBox(rightmostBox,
580 box->isLeftToRightDirection() ? rightmostBox->caretMaxOffset() : rightmostBox->caretMinOffset(), shouldAffinityBeDownstream); 579 box->isLeftToRightDirection() ? rightmostBox->caretMaxOffset() : rightmostBox->caretMinOffset(), shouldAffinityBeDownstream);
581 } 580 }
582 581
583 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream); 582 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream);
584 } 583 }
585 584
586 const InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak(); 585 const InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak();
587 if ((nextBox && nextBox->bidiLevel() == box->bidiLevel()) 586 if ((nextBox && nextBox->bidiLevel() == box->bidiLevel())
588 || box->renderer()->containingBlock()->style()->direction() == box->dire ction()) 587 || box->renderer().containingBlock()->style()->direction() == box->direc tion())
589 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream); 588 return createPositionWithAffinityForBox(box, box->caretRightmostOffset() , shouldAffinityBeDownstream);
590 589
591 // offset is on the right edge 590 // offset is on the right edge
592 if (nextBox && nextBox->bidiLevel() > box->bidiLevel()) { 591 if (nextBox && nextBox->bidiLevel() > box->bidiLevel()) {
593 // e.g. right of C in aDC12BAb 592 // e.g. right of C in aDC12BAb
594 const InlineBox* rightmostBox; 593 const InlineBox* rightmostBox;
595 do { 594 do {
596 rightmostBox = nextBox; 595 rightmostBox = nextBox;
597 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak(); 596 nextBox = rightmostBox->nextLeafChildIgnoringLineBreak();
598 } while (nextBox && nextBox->bidiLevel() > box->bidiLevel()); 597 } while (nextBox && nextBox->bidiLevel() > box->bidiLevel());
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 deleteTextBoxes(); 1421 deleteTextBoxes();
1423 else if (!m_linesDirty) { 1422 else if (!m_linesDirty) {
1424 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) 1423 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
1425 box->dirtyLineBoxes(); 1424 box->dirtyLineBoxes();
1426 } 1425 }
1427 m_linesDirty = false; 1426 m_linesDirty = false;
1428 } 1427 }
1429 1428
1430 InlineTextBox* RenderText::createTextBox() 1429 InlineTextBox* RenderText::createTextBox()
1431 { 1430 {
1432 return new InlineTextBox(this); 1431 return new InlineTextBox(*this);
1433 } 1432 }
1434 1433
1435 InlineTextBox* RenderText::createInlineTextBox() 1434 InlineTextBox* RenderText::createInlineTextBox()
1436 { 1435 {
1437 InlineTextBox* textBox = createTextBox(); 1436 InlineTextBox* textBox = createTextBox();
1438 if (!m_firstTextBox) 1437 if (!m_firstTextBox)
1439 m_firstTextBox = m_lastTextBox = textBox; 1438 m_firstTextBox = m_lastTextBox = textBox;
1440 else { 1439 else {
1441 m_lastTextBox->setNextTextBox(textBox); 1440 m_lastTextBox->setNextTextBox(textBox);
1442 textBox->setPreviousTextBox(m_lastTextBox); 1441 textBox->setPreviousTextBox(m_lastTextBox);
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 } 1866 }
1868 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 1867 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
1869 } 1868 }
1870 1869
1871 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() 1870 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox()
1872 { 1871 {
1873 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); 1872 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox);
1874 } 1873 }
1875 1874
1876 } // namespace WebCore 1875 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderReplaced.cpp ('k') | Source/core/rendering/RootInlineBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698