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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2354893002: Introduce VisiblePosition::isValid (Closed)
Patch Set: Further fix compile... Created 4 years, 3 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) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 absoluteBlockPoint -= FloatSize(containingBlock.scrolledContentOffset()) ; 1330 absoluteBlockPoint -= FloatSize(containingBlock.scrolledContentOffset()) ;
1331 1331
1332 if (root->block().isHorizontalWritingMode()) 1332 if (root->block().isHorizontalWritingMode())
1333 return LayoutPoint(LayoutUnit(lineDirectionPoint - absoluteBlockPoint.x( )), root->blockDirectionPointInLine()); 1333 return LayoutPoint(LayoutUnit(lineDirectionPoint - absoluteBlockPoint.x( )), root->blockDirectionPointInLine());
1334 1334
1335 return LayoutPoint(root->blockDirectionPointInLine(), LayoutUnit(lineDirecti onPoint - absoluteBlockPoint.y())); 1335 return LayoutPoint(root->blockDirectionPointInLine(), LayoutUnit(lineDirecti onPoint - absoluteBlockPoint.y()));
1336 } 1336 }
1337 1337
1338 VisiblePosition previousLinePosition(const VisiblePosition& visiblePosition, Lay outUnit lineDirectionPoint, EditableType editableType) 1338 VisiblePosition previousLinePosition(const VisiblePosition& visiblePosition, Lay outUnit lineDirectionPoint, EditableType editableType)
1339 { 1339 {
1340 DCHECK(visiblePosition.isValid());
yosin_UTC9 2016/09/20 13:55:51 We should add |DCHECK(vp.isValid())| all functions
Xiaocheng 2016/09/21 06:31:49 Unfortunately we are not having such a gigantic pa
1341
1340 Position p = visiblePosition.deepEquivalent(); 1342 Position p = visiblePosition.deepEquivalent();
1341 Node* node = p.anchorNode(); 1343 Node* node = p.anchorNode();
1342 1344
1343 if (!node) 1345 if (!node)
1344 return VisiblePosition(); 1346 return VisiblePosition();
1345 1347
1346 DCHECK(!node->document().needsLayoutTreeUpdate());
1347
1348 LayoutObject* layoutObject = node->layoutObject(); 1348 LayoutObject* layoutObject = node->layoutObject();
1349 if (!layoutObject) 1349 if (!layoutObject)
1350 return VisiblePosition(); 1350 return VisiblePosition();
1351 1351
1352 RootInlineBox* root = 0; 1352 RootInlineBox* root = 0;
1353 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox; 1353 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox;
1354 if (box) { 1354 if (box) {
1355 root = box->root().prevRootBox(); 1355 root = box->root().prevRootBox();
1356 // We want to skip zero height boxes. 1356 // We want to skip zero height boxes.
1357 // This could happen in case it is a TrailingFloatsRootInlineBox. 1357 // This could happen in case it is a TrailingFloatsRootInlineBox.
(...skipping 25 matching lines...) Expand all
1383 // Move to the start of the content in this block, which effectively moves u s 1383 // Move to the start of the content in this block, which effectively moves u s
1384 // to the start of the line we're on. 1384 // to the start of the line we're on.
1385 Element* rootElement = hasEditableStyle(*node, editableType) ? rootEditableE lement(*node, editableType) : node->document().documentElement(); 1385 Element* rootElement = hasEditableStyle(*node, editableType) ? rootEditableE lement(*node, editableType) : node->document().documentElement();
1386 if (!rootElement) 1386 if (!rootElement)
1387 return VisiblePosition(); 1387 return VisiblePosition();
1388 return VisiblePosition::firstPositionInNode(rootElement); 1388 return VisiblePosition::firstPositionInNode(rootElement);
1389 } 1389 }
1390 1390
1391 VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, LayoutU nit lineDirectionPoint, EditableType editableType) 1391 VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, LayoutU nit lineDirectionPoint, EditableType editableType)
1392 { 1392 {
1393 DCHECK(visiblePosition.isValid());
1394
1393 Position p = visiblePosition.deepEquivalent(); 1395 Position p = visiblePosition.deepEquivalent();
1394 Node* node = p.anchorNode(); 1396 Node* node = p.anchorNode();
1395 1397
1396 if (!node) 1398 if (!node)
1397 return VisiblePosition(); 1399 return VisiblePosition();
1398 1400
1399 DCHECK(!node->document().needsLayoutTreeUpdate());
1400
1401 LayoutObject* layoutObject = node->layoutObject(); 1401 LayoutObject* layoutObject = node->layoutObject();
1402 if (!layoutObject) 1402 if (!layoutObject)
1403 return VisiblePosition(); 1403 return VisiblePosition();
1404 1404
1405 RootInlineBox* root = 0; 1405 RootInlineBox* root = 0;
1406 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox; 1406 InlineBox* box = computeInlineBoxPosition(visiblePosition).inlineBox;
1407 if (box) { 1407 if (box) {
1408 root = box->root().nextRootBox(); 1408 root = box->root().nextRootBox();
1409 // We want to skip zero height boxes. 1409 // We want to skip zero height boxes.
1410 // This could happen in case it is a TrailingFloatsRootInlineBox. 1410 // This could happen in case it is a TrailingFloatsRootInlineBox.
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 { 3319 {
3320 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3320 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3321 } 3321 }
3322 3322
3323 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule) 3323 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule)
3324 { 3324 {
3325 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule); 3325 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule);
3326 } 3326 }
3327 3327
3328 } // namespace blink 3328 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698