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

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

Issue 1203613003: Make inSameLine() in VisibleUnits.cpp to work with positions in composed tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-24T17:52:54 Get rid of redundant explict in RenderedPosition Created 5 years, 6 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
« no previous file with comments | « Source/core/editing/VisibleUnits.h ('k') | Source/core/editing/VisibleUnitsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 771 }
772 772
773 return honorEditingBoundaryAtOrBeforeOf(visPos, c.position()); 773 return honorEditingBoundaryAtOrBeforeOf(visPos, c.position());
774 } 774 }
775 775
776 static PositionWithAffinity startOfLine(const PositionWithAffinity& currentPosit ion) 776 static PositionWithAffinity startOfLine(const PositionWithAffinity& currentPosit ion)
777 { 777 {
778 return startOfLine(currentPosition, UseInlineBoxOrdering); 778 return startOfLine(currentPosition, UseInlineBoxOrdering);
779 } 779 }
780 780
781 static PositionInComposedTreeWithAffinity startOfLine(const PositionInComposedTr eeWithAffinity& currentPosition)
782 {
783 return startOfLine(currentPosition, UseInlineBoxOrdering);
784 }
785
781 // FIXME: Rename this function to reflect the fact it ignores bidi levels. 786 // FIXME: Rename this function to reflect the fact it ignores bidi levels.
782 VisiblePosition startOfLine(const VisiblePosition& currentPosition) 787 VisiblePosition startOfLine(const VisiblePosition& currentPosition)
783 { 788 {
784 return VisiblePosition(startOfLine(PositionWithAffinity(currentPosition.deep Equivalent(), currentPosition.affinity()), UseInlineBoxOrdering)); 789 return VisiblePosition(startOfLine(PositionWithAffinity(currentPosition.deep Equivalent(), currentPosition.affinity()), UseInlineBoxOrdering));
785 } 790 }
786 791
787 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition) 792 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition)
788 { 793 {
789 return VisiblePosition(startOfLine(PositionWithAffinity(currentPosition.deep Equivalent(), currentPosition.affinity()), UseLogicalOrdering)); 794 return VisiblePosition(startOfLine(PositionWithAffinity(currentPosition.deep Equivalent(), currentPosition.affinity()), UseLogicalOrdering));
790 } 795 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 VisiblePosition logicalEndOfLine(const VisiblePosition& currentPosition) 898 VisiblePosition logicalEndOfLine(const VisiblePosition& currentPosition)
894 { 899 {
895 return endOfLine(currentPosition, UseLogicalOrdering); 900 return endOfLine(currentPosition, UseLogicalOrdering);
896 } 901 }
897 902
898 template <typename PositionWithAffinityType> 903 template <typename PositionWithAffinityType>
899 bool inSameLineAlgorithm(const PositionWithAffinityType& position1, const Positi onWithAffinityType& position2) 904 bool inSameLineAlgorithm(const PositionWithAffinityType& position1, const Positi onWithAffinityType& position2)
900 { 905 {
901 if (position1.isNull() || position2.isNull()) 906 if (position1.isNull() || position2.isNull())
902 return false; 907 return false;
903 PositionWithAffinity startOfLine1 = startOfLine(position1); 908 PositionWithAffinityType startOfLine1 = startOfLine(position1);
904 PositionWithAffinity startOfLine2 = startOfLine(position2); 909 PositionWithAffinityType startOfLine2 = startOfLine(position2);
905 if (startOfLine1 == startOfLine2) 910 if (startOfLine1 == startOfLine2)
906 return true; 911 return true;
907 typename PositionWithAffinityType::PositionType canonicalized1 = canonicalPo sitionOf(startOfLine1.position()); 912 typename PositionWithAffinityType::PositionType canonicalized1 = canonicalPo sitionOf(startOfLine1.position());
908 if (canonicalized1 == startOfLine2.position()) 913 if (canonicalized1 == startOfLine2.position())
909 return true; 914 return true;
910 return canonicalized1 == canonicalPositionOf(startOfLine2.position()); 915 return canonicalized1 == canonicalPositionOf(startOfLine2.position());
911 } 916 }
912 917
913 bool inSameLine(const PositionWithAffinity& a, const PositionWithAffinity& b) 918 bool inSameLine(const PositionWithAffinity& a, const PositionWithAffinity& b)
914 { 919 {
915 return inSameLineAlgorithm(a, b); 920 return inSameLineAlgorithm(a, b);
916 } 921 }
917 922
923 bool inSameLine(const PositionInComposedTreeWithAffinity& position1, const Posit ionInComposedTreeWithAffinity& position2)
924 {
925 return inSameLineAlgorithm(position1, position2);
926 }
927
918 bool inSameLine(const VisiblePosition &a, const VisiblePosition &b) 928 bool inSameLine(const VisiblePosition &a, const VisiblePosition &b)
919 { 929 {
920 return inSameLine(PositionWithAffinity(a.deepEquivalent(), a.affinity()), Po sitionWithAffinity(b.deepEquivalent(), b.affinity())); 930 return inSameLine(PositionWithAffinity(a.deepEquivalent(), a.affinity()), Po sitionWithAffinity(b.deepEquivalent(), b.affinity()));
921 } 931 }
922 932
923 bool isStartOfLine(const VisiblePosition &p) 933 bool isStartOfLine(const VisiblePosition &p)
924 { 934 {
925 return p.isNotNull() && p == startOfLine(p); 935 return p.isNotNull() && p == startOfLine(p);
926 } 936 }
927 937
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H itTestRequest::Active | HitTestRequest::IgnoreClipping; 1462 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H itTestRequest::Active | HitTestRequest::IgnoreClipping;
1453 HitTestResult result(request, contentsPoint); 1463 HitTestResult result(request, contentsPoint);
1454 frame->document()->layoutView()->hitTest(result); 1464 frame->document()->layoutView()->hitTest(result);
1455 1465
1456 if (Node* node = result.innerNode()) 1466 if (Node* node = result.innerNode())
1457 return frame->selection().selection().visiblePositionRespectingEditingBo undary(result.localPoint(), node); 1467 return frame->selection().selection().visiblePositionRespectingEditingBo undary(result.localPoint(), node);
1458 return VisiblePosition(); 1468 return VisiblePosition();
1459 } 1469 }
1460 1470
1461 } 1471 }
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleUnits.h ('k') | Source/core/editing/VisibleUnitsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698