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

Unified Diff: Source/core/editing/VisibleUnits.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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/rendering/EllipsisBox.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/VisibleUnits.cpp
diff --git a/Source/core/editing/VisibleUnits.cpp b/Source/core/editing/VisibleUnits.cpp
index 5b889d78c5548aa42520fded0d76280dfc430105..1068c8cacefc50523d243891b7de309dca591c9e 100644
--- a/Source/core/editing/VisibleUnits.cpp
+++ b/Source/core/editing/VisibleUnits.cpp
@@ -216,7 +216,7 @@ static const InlineTextBox* logicallyPreviousBox(const VisiblePosition& visibleP
return previousBox;
while (1) {
- Node* startNode = startBox->renderer() ? startBox->renderer()->nonPseudoNode() : 0;
+ Node* startNode = startBox->renderer().nonPseudoNode();
if (!startNode)
break;
@@ -257,7 +257,7 @@ static const InlineTextBox* logicallyNextBox(const VisiblePosition& visiblePosit
return nextBox;
while (1) {
- Node* startNode = startBox->renderer() ? startBox->renderer()->nonPseudoNode() : 0;
+ Node* startNode =startBox->renderer().nonPseudoNode();
if (!startNode)
break;
@@ -295,10 +295,10 @@ static TextBreakIterator* wordBreakIteratorForMinOffsetBoundary(const VisiblePos
string.clear();
if (previousBox) {
previousBoxLength = previousBox->len();
- previousBox->textRenderer()->text().appendTo(string, previousBox->start(), previousBoxLength);
+ previousBox->textRenderer().text().appendTo(string, previousBox->start(), previousBoxLength);
len += previousBoxLength;
}
- textBox->textRenderer()->text().appendTo(string, textBox->start(), textBox->len());
+ textBox->textRenderer().text().appendTo(string, textBox->start(), textBox->len());
len += textBox->len();
return wordBreakIterator(string.data(), len);
@@ -314,10 +314,10 @@ static TextBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePos
int len = 0;
string.clear();
- textBox->textRenderer()->text().appendTo(string, textBox->start(), textBox->len());
+ textBox->textRenderer().text().appendTo(string, textBox->start(), textBox->len());
len += textBox->len();
if (nextBox) {
- nextBox->textRenderer()->text().appendTo(string, nextBox->start(), nextBox->len());
+ nextBox->textRenderer().text().appendTo(string, nextBox->start(), nextBox->len());
len += nextBox->len();
}
@@ -384,7 +384,7 @@ static VisiblePosition visualWordPosition(const VisiblePosition& visiblePosition
else if (offsetInBox == box->caretMaxOffset())
iter = wordBreakIteratorForMaxOffsetBoundary(visiblePosition, textBox, nextBoxInDifferentBlock, string, leafBoxes);
else if (movingIntoNewBox) {
- iter = wordBreakIterator(textBox->textRenderer()->text(), textBox->start(), textBox->len());
+ iter = wordBreakIterator(textBox->textRenderer().text(), textBox->start(), textBox->len());
previouslyVisitedBox = box;
}
@@ -737,11 +737,7 @@ static VisiblePosition startPositionForLine(const VisiblePosition& c, LineEndpoi
if (!startBox)
return VisiblePosition();
- RenderObject* startRenderer = startBox->renderer();
- if (!startRenderer)
- return VisiblePosition();
-
- startNode = startRenderer->nonPseudoNode();
+ startNode = startBox->renderer().nonPseudoNode();
if (startNode)
break;
@@ -808,11 +804,7 @@ static VisiblePosition endPositionForLine(const VisiblePosition& c, LineEndpoint
if (!endBox)
return VisiblePosition();
- RenderObject* endRenderer = endBox->renderer();
- if (!endRenderer)
- return VisiblePosition();
-
- endNode = endRenderer->nonPseudoNode();
+ endNode = endBox->renderer().nonPseudoNode();
if (endNode)
break;
@@ -907,12 +899,12 @@ bool isEndOfLine(const VisiblePosition &p)
static inline IntPoint absoluteLineDirectionPointToLocalPointInBlock(RootInlineBox* root, int lineDirectionPoint)
{
ASSERT(root);
- RenderBlockFlow* containingBlock = root->block();
- FloatPoint absoluteBlockPoint = containingBlock->localToAbsolute(FloatPoint());
- if (containingBlock->hasOverflowClip())
- absoluteBlockPoint -= containingBlock->scrolledContentOffset();
+ RenderBlockFlow& containingBlock = root->block();
+ FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint());
+ if (containingBlock.hasOverflowClip())
+ absoluteBlockPoint -= containingBlock.scrolledContentOffset();
- if (root->block()->isHorizontalWritingMode())
+ if (root->block().isHorizontalWritingMode())
return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->blockDirectionPointInLine());
return IntPoint(root->blockDirectionPointInLine(), lineDirectionPoint - absoluteBlockPoint.y());
@@ -957,11 +949,11 @@ VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
if (root) {
// FIXME: Can be wrong for multi-column layout and with transforms.
IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(root, lineDirectionPoint);
- RenderObject* renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
- Node* node = renderer->node();
+ RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
+ Node* node = renderer.node();
if (node && editingIgnoresContent(node))
return VisiblePosition(positionInParentBeforeNode(node));
- return VisiblePosition(renderer->positionForPoint(pointInLine));
+ return VisiblePosition(renderer.positionForPoint(pointInLine));
}
// Could not find a previous line. This means we must already be on the first line.
@@ -1015,11 +1007,11 @@ VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin
if (root) {
// FIXME: Can be wrong for multi-column layout and with transforms.
IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(root, lineDirectionPoint);
- RenderObject* renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
- Node* node = renderer->node();
+ RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
+ Node* node = renderer.node();
if (node && editingIgnoresContent(node))
return VisiblePosition(positionInParentBeforeNode(node));
- return VisiblePosition(renderer->positionForPoint(pointInLine));
+ return VisiblePosition(renderer.positionForPoint(pointInLine));
}
// Could not find a next line. This means we must already be on the last line.
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | Source/core/rendering/EllipsisBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698