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

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

Issue 2441693004: Make editingIgnoresContents() as global function (Closed)
Patch Set: 2016-10-21T14:45:18 Created 4 years, 1 month 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 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 return PositionTemplate<Strategy>(toText(nextNodeItreator), 1923 return PositionTemplate<Strategy>(toText(nextNodeItreator),
1924 i + text->textStartOffset()); 1924 i + text->textStartOffset());
1925 } 1925 }
1926 } 1926 }
1927 1927
1928 candidateNode = nextNodeItreator; 1928 candidateNode = nextNodeItreator;
1929 candidateType = PositionAnchorType::OffsetInAnchor; 1929 candidateType = PositionAnchorType::OffsetInAnchor;
1930 candidateOffset = 1930 candidateOffset =
1931 layoutObject->caretMaxOffset() + text->textStartOffset(); 1931 layoutObject->caretMaxOffset() + text->textStartOffset();
1932 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock); 1932 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock);
1933 } else if (Strategy::editingIgnoresContent(nextNodeItreator) || 1933 } else if (editingIgnoresContent(nextNodeItreator) ||
1934 isDisplayInsideTable(nextNodeItreator)) { 1934 isDisplayInsideTable(nextNodeItreator)) {
1935 candidateNode = nextNodeItreator; 1935 candidateNode = nextNodeItreator;
1936 candidateType = PositionAnchorType::AfterAnchor; 1936 candidateType = PositionAnchorType::AfterAnchor;
1937 nextNodeItreator = 1937 nextNodeItreator =
1938 Strategy::nextSkippingChildren(*nextNodeItreator, startBlock); 1938 Strategy::nextSkippingChildren(*nextNodeItreator, startBlock);
1939 } else { 1939 } else {
1940 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock); 1940 nextNodeItreator = Strategy::next(*nextNodeItreator, startBlock);
1941 } 1941 }
1942 } 1942 }
1943 1943
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 2840
2841 // Don't move past a position that is visually distinct. We could rely on 2841 // Don't move past a position that is visually distinct. We could rely on
2842 // code above to terminate and return lastVisible on the next iteration, but 2842 // code above to terminate and return lastVisible on the next iteration, but
2843 // we terminate early to avoid doing a nodeIndex() call. 2843 // we terminate early to avoid doing a nodeIndex() call.
2844 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && 2844 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) &&
2845 currentPos.atStartOfNode()) 2845 currentPos.atStartOfNode())
2846 return lastVisible.deprecatedComputePosition(); 2846 return lastVisible.deprecatedComputePosition();
2847 2847
2848 // Return position after tables and nodes which have content that can be 2848 // Return position after tables and nodes which have content that can be
2849 // ignored. 2849 // ignored.
2850 if (Strategy::editingIgnoresContent(currentNode) || 2850 if (editingIgnoresContent(currentNode) ||
2851 isDisplayInsideTable(currentNode)) { 2851 isDisplayInsideTable(currentNode)) {
2852 if (currentPos.atEndOfNode()) 2852 if (currentPos.atEndOfNode())
2853 return PositionTemplate<Strategy>::afterNode(currentNode); 2853 return PositionTemplate<Strategy>::afterNode(currentNode);
2854 continue; 2854 continue;
2855 } 2855 }
2856 2856
2857 // return current position if it is in laid out text 2857 // return current position if it is in laid out text
2858 if (layoutObject->isText() && toLayoutText(layoutObject)->firstTextBox()) { 2858 if (layoutObject->isText() && toLayoutText(layoutObject)->firstTextBox()) {
2859 LayoutText* const textLayoutObject = toLayoutText(layoutObject); 2859 LayoutText* const textLayoutObject = toLayoutText(layoutObject);
2860 const unsigned textStartOffset = textLayoutObject->textStartOffset(); 2860 const unsigned textStartOffset = textLayoutObject->textStartOffset();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 lastVisible = currentPos; 3017 lastVisible = currentPos;
3018 break; 3018 break;
3019 } 3019 }
3020 3020
3021 // track last visible streamer position 3021 // track last visible streamer position
3022 if (isStreamer<Strategy>(currentPos)) 3022 if (isStreamer<Strategy>(currentPos))
3023 lastVisible = currentPos; 3023 lastVisible = currentPos;
3024 3024
3025 // Return position before tables and nodes which have content that can be 3025 // Return position before tables and nodes which have content that can be
3026 // ignored. 3026 // ignored.
3027 if (Strategy::editingIgnoresContent(currentNode) || 3027 if (editingIgnoresContent(currentNode) ||
3028 isDisplayInsideTable(currentNode)) { 3028 isDisplayInsideTable(currentNode)) {
3029 if (currentPos.offsetInLeafNode() <= layoutObject->caretMinOffset()) 3029 if (currentPos.offsetInLeafNode() <= layoutObject->caretMinOffset())
3030 return PositionTemplate<Strategy>::editingPositionOf( 3030 return PositionTemplate<Strategy>::editingPositionOf(
3031 currentNode, layoutObject->caretMinOffset()); 3031 currentNode, layoutObject->caretMinOffset());
3032 continue; 3032 continue;
3033 } 3033 }
3034 3034
3035 // return current position if it is in laid out text 3035 // return current position if it is in laid out text
3036 if (layoutObject->isText() && toLayoutText(layoutObject)->firstTextBox()) { 3036 if (layoutObject->isText() && toLayoutText(layoutObject)->firstTextBox()) {
3037 LayoutText* const textLayoutObject = toLayoutText(layoutObject); 3037 LayoutText* const textLayoutObject = toLayoutText(layoutObject);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 if (layoutObject->isText()) 3165 if (layoutObject->isText())
3166 return layoutObject->isSelectable() && inRenderedText(position); 3166 return layoutObject->isSelectable() && inRenderedText(position);
3167 3167
3168 if (layoutObject->isSVG()) { 3168 if (layoutObject->isSVG()) {
3169 // We don't consider SVG elements are contenteditable except for 3169 // We don't consider SVG elements are contenteditable except for
3170 // associated |layoutObject| returns |isText()| true, 3170 // associated |layoutObject| returns |isText()| true,
3171 // e.g. |LayoutSVGInlineText|. 3171 // e.g. |LayoutSVGInlineText|.
3172 return false; 3172 return false;
3173 } 3173 }
3174 3174
3175 if (isDisplayInsideTable(anchorNode) || 3175 if (isDisplayInsideTable(anchorNode) || editingIgnoresContent(anchorNode)) {
3176 Strategy::editingIgnoresContent(anchorNode)) {
3177 if (!position.atFirstEditingPositionForNode() && 3176 if (!position.atFirstEditingPositionForNode() &&
3178 !position.atLastEditingPositionForNode()) 3177 !position.atLastEditingPositionForNode())
3179 return false; 3178 return false;
3180 const Node* parent = Strategy::parent(*anchorNode); 3179 const Node* parent = Strategy::parent(*anchorNode);
3181 return parent->layoutObject() && parent->layoutObject()->isSelectable(); 3180 return parent->layoutObject() && parent->layoutObject()->isSelectable();
3182 } 3181 }
3183 3182
3184 if (anchorNode->document().documentElement() == anchorNode || 3183 if (anchorNode->document().documentElement() == anchorNode ||
3185 anchorNode->isDocumentNode()) 3184 anchorNode->isDocumentNode())
3186 return false; 3185 return false;
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 3843
3845 VisiblePositionInFlatTree previousPositionOf( 3844 VisiblePositionInFlatTree previousPositionOf(
3846 const VisiblePositionInFlatTree& visiblePosition, 3845 const VisiblePositionInFlatTree& visiblePosition,
3847 EditingBoundaryCrossingRule rule) { 3846 EditingBoundaryCrossingRule rule) {
3848 DCHECK(visiblePosition.isValid()) << visiblePosition; 3847 DCHECK(visiblePosition.isValid()) << visiblePosition;
3849 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>( 3848 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(
3850 visiblePosition.deepEquivalent(), rule); 3849 visiblePosition.deepEquivalent(), rule);
3851 } 3850 }
3852 3851
3853 } // namespace blink 3852 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698