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

Unified Diff: Source/core/editing/VisibleUnits.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/VisibleSelection.cpp ('k') | Source/core/editing/WrapContentsInDummySpanCommand.cpp » ('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 fa94d0c52f8e2f39ed369bb9a680fbc5d830820c..235136fcf2259271a533df7765f9219e84460317 100644
--- a/Source/core/editing/VisibleUnits.cpp
+++ b/Source/core/editing/VisibleUnits.cpp
@@ -452,17 +452,17 @@ static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
if (!boundary)
return VisiblePosition();
- Document* d = boundary->document();
+ Document& d = boundary->document();
Position start = createLegacyEditingPosition(boundary, 0).parentAnchoredEquivalent();
Position end = pos.parentAnchoredEquivalent();
- RefPtr<Range> searchRange = Range::create(d);
+ RefPtr<Range> searchRange = Range::create(&d);
Vector<UChar, 1024> string;
unsigned suffixLength = 0;
TrackExceptionState es;
if (requiresContextForWordBoundary(c.characterBefore())) {
- RefPtr<Range> forwardsScanRange(d->createRange());
+ RefPtr<Range> forwardsScanRange(d.createRange());
forwardsScanRange->setEndAfter(boundary, es);
forwardsScanRange->setStart(end.deprecatedNode(), end.deprecatedEditingOffset(), es);
TextIterator forwardsIterator(forwardsScanRange.get());
@@ -533,15 +533,15 @@ static VisiblePosition nextBoundary(const VisiblePosition& c, BoundarySearchFunc
if (!boundary)
return VisiblePosition();
- Document* d = boundary->document();
- RefPtr<Range> searchRange(d->createRange());
+ Document& d = boundary->document();
+ RefPtr<Range> searchRange(d.createRange());
Position start(pos.parentAnchoredEquivalent());
Vector<UChar, 1024> string;
unsigned prefixLength = 0;
if (requiresContextForWordBoundary(c.characterAfter())) {
- RefPtr<Range> backwardsScanRange(d->createRange());
+ RefPtr<Range> backwardsScanRange(d.createRange());
backwardsScanRange->setEnd(start.deprecatedNode(), start.deprecatedEditingOffset(), IGNORE_EXCEPTION);
SimplifiedBackwardsTextIterator backwardsIterator(backwardsScanRange.get());
while (!backwardsIterator.atEnd()) {
@@ -931,7 +931,7 @@ VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
if (!node)
return VisiblePosition();
- node->document()->updateLayoutIgnorePendingStylesheets();
+ node->document().updateLayoutIgnorePendingStylesheets();
RenderObject* renderer = node->renderer();
if (!renderer)
@@ -972,7 +972,7 @@ VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
// Could not find a previous line. This means we must already be on the first line.
// Move to the start of the content in this block, which effectively moves us
// to the start of the line we're on.
- Element* rootElement = node->rendererIsEditable(editableType) ? node->rootEditableElement(editableType) : node->document()->documentElement();
+ Element* rootElement = node->rendererIsEditable(editableType) ? node->rootEditableElement(editableType) : node->document().documentElement();
if (!rootElement)
return VisiblePosition();
return VisiblePosition(firstPositionInNode(rootElement), DOWNSTREAM);
@@ -986,7 +986,7 @@ VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin
if (!node)
return VisiblePosition();
- node->document()->updateLayoutIgnorePendingStylesheets();
+ node->document().updateLayoutIgnorePendingStylesheets();
RenderObject* renderer = node->renderer();
if (!renderer)
@@ -1030,7 +1030,7 @@ VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin
// Could not find a next line. This means we must already be on the last line.
// Move to the end of the content in this block, which effectively moves us
// to the end of the line we're on.
- Element* rootElement = node->rendererIsEditable(editableType) ? node->rootEditableElement(editableType) : node->document()->documentElement();
+ Element* rootElement = node->rendererIsEditable(editableType) ? node->rootEditableElement(editableType) : node->document().documentElement();
if (!rootElement)
return VisiblePosition();
return VisiblePosition(lastPositionInNode(rootElement), DOWNSTREAM);
@@ -1329,10 +1329,10 @@ bool isEndOfBlock(const VisiblePosition &pos)
VisiblePosition startOfDocument(const Node* node)
{
- if (!node || !node->document()->documentElement())
+ if (!node || !node->document().documentElement())
return VisiblePosition();
- return VisiblePosition(firstPositionInNode(node->document()->documentElement()), DOWNSTREAM);
+ return VisiblePosition(firstPositionInNode(node->document().documentElement()), DOWNSTREAM);
}
VisiblePosition startOfDocument(const VisiblePosition &c)
@@ -1342,10 +1342,10 @@ VisiblePosition startOfDocument(const VisiblePosition &c)
VisiblePosition endOfDocument(const Node* node)
{
- if (!node || !node->document()->documentElement())
+ if (!node || !node->document().documentElement())
return VisiblePosition();
- Element* doc = node->document()->documentElement();
+ Element* doc = node->document().documentElement();
return VisiblePosition(lastPositionInNode(doc), DOWNSTREAM);
}
@@ -1365,7 +1365,7 @@ bool inSameDocument(const VisiblePosition &a, const VisiblePosition &b)
if (an == bn)
return true;
- return an->document() == bn->document();
+ return &an->document() == &bn->document();
}
bool isStartOfDocument(const VisiblePosition &p)
« no previous file with comments | « Source/core/editing/VisibleSelection.cpp ('k') | Source/core/editing/WrapContentsInDummySpanCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698