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

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

Issue 2181953004: Changed ComputedStyle's EVisibility to be an enum class and fixed naming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_move_computedstyle_around
Patch Set: Rebase Created 4 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 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 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 if (!prevousNodeIterator || !prevousNodeIterator->isDescendantOf(hig hestRoot)) 1504 if (!prevousNodeIterator || !prevousNodeIterator->isDescendantOf(hig hestRoot))
1505 break; 1505 break;
1506 } 1506 }
1507 1507
1508 const LayoutItem layoutItem = LayoutItem(prevousNodeIterator->layoutObje ct()); 1508 const LayoutItem layoutItem = LayoutItem(prevousNodeIterator->layoutObje ct());
1509 if (layoutItem.isNull()) { 1509 if (layoutItem.isNull()) {
1510 prevousNodeIterator = Strategy::previousPostOrder(*prevousNodeIterat or, startBlock); 1510 prevousNodeIterator = Strategy::previousPostOrder(*prevousNodeIterat or, startBlock);
1511 continue; 1511 continue;
1512 } 1512 }
1513 const ComputedStyle& style = layoutItem.styleRef(); 1513 const ComputedStyle& style = layoutItem.styleRef();
1514 if (style.visibility() != VISIBLE) { 1514 if (style.visibility() != EVisibility::Visible) {
1515 prevousNodeIterator = Strategy::previousPostOrder(*prevousNodeIterat or, startBlock); 1515 prevousNodeIterator = Strategy::previousPostOrder(*prevousNodeIterat or, startBlock);
1516 continue; 1516 continue;
1517 } 1517 }
1518 1518
1519 if (layoutItem.isBR() || isEnclosingBlock(prevousNodeIterator)) 1519 if (layoutItem.isBR() || isEnclosingBlock(prevousNodeIterator))
1520 break; 1520 break;
1521 1521
1522 if (layoutItem.isText() && toLayoutText(prevousNodeIterator->layoutObjec t())->resolvedTextLength()) { 1522 if (layoutItem.isText() && toLayoutText(prevousNodeIterator->layoutObjec t())->resolvedTextLength()) {
1523 SECURITY_DCHECK(prevousNodeIterator->isTextNode()); 1523 SECURITY_DCHECK(prevousNodeIterator->isTextNode());
1524 if (style.preserveNewline()) { 1524 if (style.preserveNewline()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 if (!nextNodeItreator || !nextNodeItreator->isDescendantOf(highestRo ot)) 1595 if (!nextNodeItreator || !nextNodeItreator->isDescendantOf(highestRo ot))
1596 break; 1596 break;
1597 } 1597 }
1598 1598
1599 LayoutObject* const layoutObject = nextNodeItreator->layoutObject(); 1599 LayoutObject* const layoutObject = nextNodeItreator->layoutObject();
1600 if (!layoutObject) { 1600 if (!layoutObject) {
1601 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock); 1601 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock);
1602 continue; 1602 continue;
1603 } 1603 }
1604 const ComputedStyle& style = layoutObject->styleRef(); 1604 const ComputedStyle& style = layoutObject->styleRef();
1605 if (style.visibility() != VISIBLE) { 1605 if (style.visibility() != EVisibility::Visible) {
1606 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock); 1606 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock);
1607 continue; 1607 continue;
1608 } 1608 }
1609 1609
1610 if (layoutObject->isBR() || isEnclosingBlock(nextNodeItreator)) 1610 if (layoutObject->isBR() || isEnclosingBlock(nextNodeItreator))
1611 break; 1611 break;
1612 1612
1613 // FIXME: We avoid returning a position where the layoutObject can't acc ept the caret. 1613 // FIXME: We avoid returning a position where the layoutObject can't acc ept the caret.
1614 if (layoutObject->isText() && toLayoutText(layoutObject)->resolvedTextLe ngth()) { 1614 if (layoutObject->isText() && toLayoutText(layoutObject)->resolvedTextLe ngth()) {
1615 SECURITY_DCHECK(nextNodeItreator->isTextNode()); 1615 SECURITY_DCHECK(nextNodeItreator->isTextNode());
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 lastNode = currentNode; 2390 lastNode = currentNode;
2391 } 2391 }
2392 2392
2393 // If we've moved to a position that is visually distinct, return the la st saved position. There 2393 // If we've moved to a position that is visually distinct, return the la st saved position. There
2394 // is code below that terminates early if we're *about* to move to a vis ually distinct position. 2394 // is code below that terminates early if we're *about* to move to a vis ually distinct position.
2395 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary) 2395 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary)
2396 return lastVisible.deprecatedComputePosition(); 2396 return lastVisible.deprecatedComputePosition();
2397 2397
2398 // skip position in non-laid out or invisible node 2398 // skip position in non-laid out or invisible node
2399 LayoutObject* layoutObject = associatedLayoutObjectOf(*currentNode, curr entPos.offsetInLeafNode()); 2399 LayoutObject* layoutObject = associatedLayoutObjectOf(*currentNode, curr entPos.offsetInLeafNode());
2400 if (!layoutObject || layoutObject->style()->visibility() != VISIBLE) 2400 if (!layoutObject || layoutObject->style()->visibility() != EVisibility: :Visible)
2401 continue; 2401 continue;
2402 2402
2403 if (rule == CanCrossEditingBoundary && boundaryCrossed) { 2403 if (rule == CanCrossEditingBoundary && boundaryCrossed) {
2404 lastVisible = currentPos; 2404 lastVisible = currentPos;
2405 break; 2405 break;
2406 } 2406 }
2407 2407
2408 // track last visible streamer position 2408 // track last visible streamer position
2409 if (isStreamer<Strategy>(currentPos)) 2409 if (isStreamer<Strategy>(currentPos))
2410 lastVisible = currentPos; 2410 lastVisible = currentPos;
(...skipping 27 matching lines...) Expand all
2438 DCHECK_GE(currentPos.offsetInLeafNode(), static_cast<int>(textStartO ffset)); 2438 DCHECK_GE(currentPos.offsetInLeafNode(), static_cast<int>(textStartO ffset));
2439 const unsigned textOffset = currentPos.offsetInLeafNode() - textStar tOffset; 2439 const unsigned textOffset = currentPos.offsetInLeafNode() - textStar tOffset;
2440 InlineTextBox* lastTextBox = textLayoutObject->lastTextBox(); 2440 InlineTextBox* lastTextBox = textLayoutObject->lastTextBox();
2441 for (InlineTextBox* box = textLayoutObject->firstTextBox(); box; box = box->nextTextBox()) { 2441 for (InlineTextBox* box = textLayoutObject->firstTextBox(); box; box = box->nextTextBox()) {
2442 if (textOffset == box->start()) { 2442 if (textOffset == box->start()) {
2443 if (textLayoutObject->isTextFragment() && toLayoutTextFragme nt(layoutObject)->isRemainingTextLayoutObject()) { 2443 if (textLayoutObject->isTextFragment() && toLayoutTextFragme nt(layoutObject)->isRemainingTextLayoutObject()) {
2444 // |currentPos| is at start of remaining text of 2444 // |currentPos| is at start of remaining text of
2445 // |Text| node with :first-letter. 2445 // |Text| node with :first-letter.
2446 DCHECK_GE(currentPos.offsetInLeafNode(), 1); 2446 DCHECK_GE(currentPos.offsetInLeafNode(), 1);
2447 LayoutObject* firstLetterLayoutObject = toLayoutTextFrag ment(layoutObject)->firstLetterPseudoElement()->layoutObject(); 2447 LayoutObject* firstLetterLayoutObject = toLayoutTextFrag ment(layoutObject)->firstLetterPseudoElement()->layoutObject();
2448 if (firstLetterLayoutObject && firstLetterLayoutObject-> style()->visibility() == VISIBLE) 2448 if (firstLetterLayoutObject && firstLetterLayoutObject-> style()->visibility() == EVisibility::Visible)
2449 return currentPos.computePosition(); 2449 return currentPos.computePosition();
2450 } 2450 }
2451 continue; 2451 continue;
2452 } 2452 }
2453 if (textOffset <= box->start() + box->len()) { 2453 if (textOffset <= box->start() + box->len()) {
2454 if (textOffset > box->start()) 2454 if (textOffset > box->start())
2455 return currentPos.computePosition(); 2455 return currentPos.computePosition();
2456 continue; 2456 continue;
2457 } 2457 }
2458 2458
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary) 2541 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary)
2542 return lastVisible.deprecatedComputePosition(); 2542 return lastVisible.deprecatedComputePosition();
2543 // Do not move past a visually disinct position. 2543 // Do not move past a visually disinct position.
2544 // Note: The first position after the last in a node whose ends are visu ally distinct 2544 // Note: The first position after the last in a node whose ends are visu ally distinct
2545 // positions will be [boundary->parentNode(), originalBlock->nodeIndex() + 1]. 2545 // positions will be [boundary->parentNode(), originalBlock->nodeIndex() + 1].
2546 if (boundary && Strategy::parent(*boundary) == currentNode) 2546 if (boundary && Strategy::parent(*boundary) == currentNode)
2547 return lastVisible.deprecatedComputePosition(); 2547 return lastVisible.deprecatedComputePosition();
2548 2548
2549 // skip position in non-laid out or invisible node 2549 // skip position in non-laid out or invisible node
2550 LayoutObject* layoutObject = associatedLayoutObjectOf(*currentNode, curr entPos.offsetInLeafNode()); 2550 LayoutObject* layoutObject = associatedLayoutObjectOf(*currentNode, curr entPos.offsetInLeafNode());
2551 if (!layoutObject || layoutObject->style()->visibility() != VISIBLE) 2551 if (!layoutObject || layoutObject->style()->visibility() != EVisibility: :Visible)
2552 continue; 2552 continue;
2553 2553
2554 if (rule == CanCrossEditingBoundary && boundaryCrossed) { 2554 if (rule == CanCrossEditingBoundary && boundaryCrossed) {
2555 lastVisible = currentPos; 2555 lastVisible = currentPos;
2556 break; 2556 break;
2557 } 2557 }
2558 2558
2559 // track last visible streamer position 2559 // track last visible streamer position
2560 if (isStreamer<Strategy>(currentPos)) 2560 if (isStreamer<Strategy>(currentPos))
2561 lastVisible = currentPos; 2561 lastVisible = currentPos;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 static bool isVisuallyEquivalentCandidateAlgorithm(const PositionTemplate<Strate gy>& position) 2659 static bool isVisuallyEquivalentCandidateAlgorithm(const PositionTemplate<Strate gy>& position)
2660 { 2660 {
2661 Node* const anchorNode = position.anchorNode(); 2661 Node* const anchorNode = position.anchorNode();
2662 if (!anchorNode) 2662 if (!anchorNode)
2663 return false; 2663 return false;
2664 2664
2665 LayoutObject* layoutObject = anchorNode->layoutObject(); 2665 LayoutObject* layoutObject = anchorNode->layoutObject();
2666 if (!layoutObject) 2666 if (!layoutObject)
2667 return false; 2667 return false;
2668 2668
2669 if (layoutObject->style()->visibility() != VISIBLE) 2669 if (layoutObject->style()->visibility() != EVisibility::Visible)
2670 return false; 2670 return false;
2671 2671
2672 if (layoutObject->isBR()) { 2672 if (layoutObject->isBR()) {
2673 // TODO(leviw) The condition should be 2673 // TODO(leviw) The condition should be
2674 // m_anchorType == PositionAnchorType::BeforeAnchor, but for now we 2674 // m_anchorType == PositionAnchorType::BeforeAnchor, but for now we
2675 // still need to support legacy positions. 2675 // still need to support legacy positions.
2676 if (position.isAfterAnchor()) 2676 if (position.isAfterAnchor())
2677 return false; 2677 return false;
2678 if (position.computeEditingOffset()) 2678 if (position.computeEditingOffset())
2679 return false; 2679 return false;
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 { 3260 {
3261 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3261 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3262 } 3262 }
3263 3263
3264 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule) 3264 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi siblePosition, EditingBoundaryCrossingRule rule)
3265 { 3265 {
3266 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule); 3266 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio n, rule);
3267 } 3267 }
3268 3268
3269 } // namespace blink 3269 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698