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

Side by Side Diff: third_party/WebKit/Source/core/page/SpatialNavigation.cpp

Issue 2899573002: Clean up remaining uses of ASSERT in core (Closed)
Patch Set: Clean up remaining uses of ASSERT in core Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org> 3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org>
4 * 4 *
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 int dy = 0; 242 int dy = 0;
243 // TODO(leviw): Why are these values truncated (toInt) instead of rounding? 243 // TODO(leviw): Why are these values truncated (toInt) instead of rounding?
244 FrameView* frame_view = container->GetDocument().View(); 244 FrameView* frame_view = container->GetDocument().View();
245 int pixels_per_line_step = ScrollableArea::PixelsPerLineStep( 245 int pixels_per_line_step = ScrollableArea::PixelsPerLineStep(
246 frame_view ? frame_view->GetChromeClient() : nullptr); 246 frame_view ? frame_view->GetChromeClient() : nullptr);
247 switch (type) { 247 switch (type) {
248 case kWebFocusTypeLeft: 248 case kWebFocusTypeLeft:
249 dx = -pixels_per_line_step; 249 dx = -pixels_per_line_step;
250 break; 250 break;
251 case kWebFocusTypeRight: 251 case kWebFocusTypeRight:
252 ASSERT(container->GetLayoutBox()->ScrollWidth() > 252 DCHECK_GT(container->GetLayoutBox()->ScrollWidth(),
253 (container->GetLayoutBox()->ScrollLeft() + 253 (container->GetLayoutBox()->ScrollLeft() +
254 container->GetLayoutBox()->ClientWidth())); 254 container->GetLayoutBox()->ClientWidth()));
255 dx = pixels_per_line_step; 255 dx = pixels_per_line_step;
256 break; 256 break;
257 case kWebFocusTypeUp: 257 case kWebFocusTypeUp:
258 dy = -pixels_per_line_step; 258 dy = -pixels_per_line_step;
259 break; 259 break;
260 case kWebFocusTypeDown: 260 case kWebFocusTypeDown:
261 ASSERT(container->GetLayoutBox()->ScrollHeight() - 261 DCHECK(container->GetLayoutBox()->ScrollHeight() -
262 (container->GetLayoutBox()->ScrollTop() + 262 (container->GetLayoutBox()->ScrollTop() +
263 container->GetLayoutBox()->ClientHeight())); 263 container->GetLayoutBox()->ClientHeight()));
264 dy = pixels_per_line_step; 264 dy = pixels_per_line_step;
265 break; 265 break;
266 default: 266 default:
267 NOTREACHED(); 267 NOTREACHED();
268 return false; 268 return false;
269 } 269 }
270 270
271 container->GetLayoutBox()->ScrollByRecursively(ScrollOffset(dx, dy)); 271 container->GetLayoutBox()->ScrollByRecursively(ScrollOffset(dx, dy));
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 LayoutObject* layout_object = element->GetLayoutObject(); 401 LayoutObject* layout_object = element->GetLayoutObject();
402 element = layout_object ? layout_object->OffsetParent() : nullptr; 402 element = layout_object ? layout_object->OffsetParent() : nullptr;
403 } while (element); 403 } while (element);
404 rect.Move((-ToLocalFrame(frame)->View()->ScrollOffsetInt())); 404 rect.Move((-ToLocalFrame(frame)->View()->ScrollOffsetInt()));
405 } 405 }
406 } 406 }
407 return rect; 407 return rect;
408 } 408 }
409 409
410 LayoutRect NodeRectInAbsoluteCoordinates(Node* node, bool ignore_border) { 410 LayoutRect NodeRectInAbsoluteCoordinates(Node* node, bool ignore_border) {
411 ASSERT(node && node->GetLayoutObject() && 411 DCHECK(node);
412 !node->GetDocument().View()->NeedsLayout()); 412 DCHECK(node->GetLayoutObject());
413 DCHECK(!node->GetDocument().View()->NeedsLayout());
413 414
414 if (node->IsDocumentNode()) 415 if (node->IsDocumentNode())
415 return FrameRectInAbsoluteCoordinates(ToDocument(node)->GetFrame()); 416 return FrameRectInAbsoluteCoordinates(ToDocument(node)->GetFrame());
416 LayoutRect rect = RectToAbsoluteCoordinates(node->GetDocument().GetFrame(), 417 LayoutRect rect = RectToAbsoluteCoordinates(node->GetDocument().GetFrame(),
417 node->BoundingBox()); 418 node->BoundingBox());
418 419
419 // For authors that use border instead of outline in their CSS, we compensate 420 // For authors that use border instead of outline in their CSS, we compensate
420 // by ignoring the border when calculating the rect of the focused element. 421 // by ignoring the border when calculating the rect of the focused element.
421 if (ignore_border) { 422 if (ignore_border) {
422 rect.Move(node->GetLayoutObject()->Style()->BorderLeftWidth(), 423 rect.Move(node->GetLayoutObject()->Style()->BorderLeftWidth(),
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 double overlap = 618 double overlap =
618 (intersection_rect.Width() * intersection_rect.Height()).ToDouble(); 619 (intersection_rect.Width() * intersection_rect.Height()).ToDouble();
619 620
620 // Distance calculation is based on http://www.w3.org/TR/WICD/#focus-handling 621 // Distance calculation is based on http://www.w3.org/TR/WICD/#focus-handling
621 candidate.distance = sqrt(euclidian_distance_pow2) + 622 candidate.distance = sqrt(euclidian_distance_pow2) +
622 navigation_axis_distance + 623 navigation_axis_distance +
623 weighted_orthogonal_axis_distance - sqrt(overlap); 624 weighted_orthogonal_axis_distance - sqrt(overlap);
624 } 625 }
625 626
626 bool CanBeScrolledIntoView(WebFocusType type, const FocusCandidate& candidate) { 627 bool CanBeScrolledIntoView(WebFocusType type, const FocusCandidate& candidate) {
627 ASSERT(candidate.visible_node && candidate.is_offscreen); 628 DCHECK(candidate.visible_node);
629 DCHECK(candidate.is_offscreen);
628 LayoutRect candidate_rect = candidate.rect; 630 LayoutRect candidate_rect = candidate.rect;
629 for (Node& parent_node : 631 for (Node& parent_node :
630 NodeTraversal::AncestorsOf(*candidate.visible_node)) { 632 NodeTraversal::AncestorsOf(*candidate.visible_node)) {
631 LayoutRect parent_rect = NodeRectInAbsoluteCoordinates(&parent_node); 633 LayoutRect parent_rect = NodeRectInAbsoluteCoordinates(&parent_node);
632 if (!candidate_rect.Intersects(parent_rect)) { 634 if (!candidate_rect.Intersects(parent_rect)) {
633 if (((type == kWebFocusTypeLeft || type == kWebFocusTypeRight) && 635 if (((type == kWebFocusTypeLeft || type == kWebFocusTypeRight) &&
634 parent_node.GetLayoutObject()->Style()->OverflowX() == 636 parent_node.GetLayoutObject()->Style()->OverflowX() ==
635 EOverflow::kHidden) || 637 EOverflow::kHidden) ||
636 ((type == kWebFocusTypeUp || type == kWebFocusTypeDown) && 638 ((type == kWebFocusTypeUp || type == kWebFocusTypeDown) &&
637 parent_node.GetLayoutObject()->Style()->OverflowY() == 639 parent_node.GetLayoutObject()->Style()->OverflowY() ==
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 return rect; 691 return rect;
690 } 692 }
691 693
692 HTMLFrameOwnerElement* FrameOwnerElement(FocusCandidate& candidate) { 694 HTMLFrameOwnerElement* FrameOwnerElement(FocusCandidate& candidate) {
693 return candidate.IsFrameOwnerElement() 695 return candidate.IsFrameOwnerElement()
694 ? ToHTMLFrameOwnerElement(candidate.visible_node) 696 ? ToHTMLFrameOwnerElement(candidate.visible_node)
695 : nullptr; 697 : nullptr;
696 }; 698 };
697 699
698 } // namespace blink 700 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/FrameTree.cpp ('k') | third_party/WebKit/Source/core/page/TouchAdjustment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698