Node::document() should return a reference.
<https://webkit.org/b/120496>
Reviewed by Antti Koivisto.
Now that orphan DocumentType nodes also have document pointers, it's no longer
possible to have a null Node::document().
Cement this by making document() return a reference, and remove the various
null checks exposed by this.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/page/SpatialNavigation.cpp b/Source/WebCore/page/SpatialNavigation.cpp
index 7bc0234..5f007d6 100644
--- a/Source/WebCore/page/SpatialNavigation.cpp
+++ b/Source/WebCore/page/SpatialNavigation.cpp
@@ -292,7 +292,7 @@
// Get the FrameView in which |node| is (which means the current viewport if |node|
// is not in an inner document), so we can check if its content rect is visible
// before we actually move the focus to it.
- FrameView* frameView = node->document()->view();
+ FrameView* frameView = node->document().view();
if (!frameView)
return true;
@@ -437,7 +437,7 @@
Node* parent = node;
do {
if (parent->isDocumentNode())
- parent = toDocument(parent)->document()->frame()->ownerElement();
+ parent = toDocument(parent)->document().frame()->ownerElement();
else
parent = parent->parentNode();
} while (parent && !canScrollInDirection(parent, direction) && !parent->isDocumentNode());
@@ -519,11 +519,11 @@
LayoutRect nodeRectInAbsoluteCoordinates(Node* node, bool ignoreBorder)
{
- ASSERT(node && node->renderer() && !node->document()->view()->needsLayout());
+ ASSERT(node && node->renderer() && !node->document().view()->needsLayout());
if (node->isDocumentNode())
return frameRectInAbsoluteCoordinates(toDocument(node)->frame());
- LayoutRect rect = rectToAbsoluteCoordinates(node->document()->frame(), node->boundingBox());
+ LayoutRect rect = rectToAbsoluteCoordinates(node->document().frame(), node->boundingBox());
// For authors that use border instead of outline in their CSS, we compensate by ignoring the border when calculating
// the rect of the focused element.
@@ -697,7 +697,7 @@
float distance = euclidianDistance + sameAxisDistance + 2 * otherAxisDistance;
candidate.distance = roundf(distance);
- LayoutSize viewSize = candidate.visibleNode->document()->page()->mainFrame().view()->visibleContentRect().size();
+ LayoutSize viewSize = candidate.visibleNode->document().page()->mainFrame().view()->visibleContentRect().size();
candidate.alignment = alignmentForRects(direction, currentRect, nodeRect, viewSize);
}
@@ -753,7 +753,7 @@
ASSERT(area->imageElement());
// Area elements tend to overlap more than other focusable elements. We flatten the rect of the area elements
// to minimize the effect of overlapping areas.
- LayoutRect rect = virtualRectForDirection(direction, rectToAbsoluteCoordinates(area->document()->frame(), area->computeRect(area->imageElement()->renderer())), 1);
+ LayoutRect rect = virtualRectForDirection(direction, rectToAbsoluteCoordinates(area->document().frame(), area->computeRect(area->imageElement()->renderer())), 1);
return rect;
}