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

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

Issue 2691913002: Introduce computePositionForNodeRemoval() as replacement of updatePositionForNodeRemoval() (Closed)
Patch Set: 2017-02-24T16:31:47 Created 3 years, 10 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 FloatPoint absolutePoint = targetNode->layoutObject()->localToAbsolute( 1732 FloatPoint absolutePoint = targetNode->layoutObject()->localToAbsolute(
1733 FloatPoint(selectionEndPoint)); 1733 FloatPoint(selectionEndPoint));
1734 selectionEndPoint = LayoutPoint( 1734 selectionEndPoint = LayoutPoint(
1735 editableElement->layoutObject()->absoluteToLocal(absolutePoint)); 1735 editableElement->layoutObject()->absoluteToLocal(absolutePoint));
1736 targetNode = editableElement; 1736 targetNode = editableElement;
1737 } 1737 }
1738 1738
1739 return targetNode->layoutObject()->positionForPoint(selectionEndPoint); 1739 return targetNode->layoutObject()->positionForPoint(selectionEndPoint);
1740 } 1740 }
1741 1741
1742 void updatePositionForNodeRemoval(Position& position, Node& node) { 1742 Position computePositionForNodeRemoval(const Position& position, Node& node) {
1743 if (position.isNull()) 1743 if (position.isNull())
1744 return; 1744 return position;
1745 switch (position.anchorType()) { 1745 switch (position.anchorType()) {
1746 case PositionAnchorType::BeforeChildren: 1746 case PositionAnchorType::BeforeChildren:
1747 if (node.isShadowIncludingInclusiveAncestorOf( 1747 if (!node.isShadowIncludingInclusiveAncestorOf(
1748 position.computeContainerNode())) 1748 position.computeContainerNode())) {
1749 position = Position::inParentBeforeNode(node); 1749 return position;
1750 break; 1750 }
1751 return Position::inParentBeforeNode(node);
1751 case PositionAnchorType::AfterChildren: 1752 case PositionAnchorType::AfterChildren:
1752 if (node.isShadowIncludingInclusiveAncestorOf( 1753 if (!node.isShadowIncludingInclusiveAncestorOf(
1753 position.computeContainerNode())) 1754 position.computeContainerNode())) {
1754 position = Position::inParentAfterNode(node); 1755 return position;
1755 break; 1756 }
1757 return Position::inParentAfterNode(node);
1756 case PositionAnchorType::OffsetInAnchor: 1758 case PositionAnchorType::OffsetInAnchor:
1757 if (position.computeContainerNode() == node.parentNode() && 1759 if (position.computeContainerNode() == node.parentNode() &&
1758 static_cast<unsigned>(position.offsetInContainerNode()) > 1760 static_cast<unsigned>(position.offsetInContainerNode()) >
1759 node.nodeIndex()) 1761 node.nodeIndex()) {
1760 position = Position(position.computeContainerNode(), 1762 return Position(position.computeContainerNode(),
1761 position.offsetInContainerNode() - 1); 1763 position.offsetInContainerNode() - 1);
1762 else if (node.isShadowIncludingInclusiveAncestorOf( 1764 }
1763 position.computeContainerNode())) 1765 if (!node.isShadowIncludingInclusiveAncestorOf(
1764 position = Position::inParentBeforeNode(node); 1766 position.computeContainerNode())) {
1765 break; 1767 return position;
1768 }
1769 return Position::inParentBeforeNode(node);
1766 case PositionAnchorType::AfterAnchor: 1770 case PositionAnchorType::AfterAnchor:
1767 if (node.isShadowIncludingInclusiveAncestorOf(position.anchorNode())) 1771 if (!node.isShadowIncludingInclusiveAncestorOf(position.anchorNode()))
1768 position = Position::inParentAfterNode(node); 1772 return position;
1769 break; 1773 return Position::inParentAfterNode(node);
1770 case PositionAnchorType::BeforeAnchor: 1774 case PositionAnchorType::BeforeAnchor:
1771 if (node.isShadowIncludingInclusiveAncestorOf(position.anchorNode())) 1775 if (!node.isShadowIncludingInclusiveAncestorOf(position.anchorNode()))
1772 position = Position::inParentBeforeNode(node); 1776 return position;
1773 break; 1777 return Position::inParentBeforeNode(node);
1774 } 1778 }
1779 NOTREACHED() << "We should handle all PositionAnchorType";
1780 return position;
1775 } 1781 }
1776 1782
1777 bool isMailHTMLBlockquoteElement(const Node* node) { 1783 bool isMailHTMLBlockquoteElement(const Node* node) {
1778 if (!node || !node->isHTMLElement()) 1784 if (!node || !node->isHTMLElement())
1779 return false; 1785 return false;
1780 1786
1781 const HTMLElement& element = toHTMLElement(*node); 1787 const HTMLElement& element = toHTMLElement(*node);
1782 return element.hasTagName(blockquoteTag) && 1788 return element.hasTagName(blockquoteTag) &&
1783 element.getAttribute("type") == "cite"; 1789 element.getAttribute("type") == "cite";
1784 } 1790 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 return InputType::DeleteWordBackward; 2159 return InputType::DeleteWordBackward;
2154 if (granularity == LineBoundary) 2160 if (granularity == LineBoundary)
2155 return InputType::DeleteLineBackward; 2161 return InputType::DeleteLineBackward;
2156 return InputType::DeleteContentBackward; 2162 return InputType::DeleteContentBackward;
2157 default: 2163 default:
2158 return InputType::None; 2164 return InputType::None;
2159 } 2165 }
2160 } 2166 }
2161 2167
2162 } // namespace blink 2168 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingUtilities.h ('k') | third_party/WebKit/Source/core/editing/SelectionEditor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698