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

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

Issue 1616643002: Rename LineLayoutPaintShim -> LineLayoutAPIShim (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "core/frame/Settings.h" 46 #include "core/frame/Settings.h"
47 #include "core/html/HTMLBRElement.h" 47 #include "core/html/HTMLBRElement.h"
48 #include "core/html/HTMLTextFormControlElement.h" 48 #include "core/html/HTMLTextFormControlElement.h"
49 #include "core/layout/HitTestRequest.h" 49 #include "core/layout/HitTestRequest.h"
50 #include "core/layout/HitTestResult.h" 50 #include "core/layout/HitTestResult.h"
51 #include "core/layout/LayoutBlockFlow.h" 51 #include "core/layout/LayoutBlockFlow.h"
52 #include "core/layout/LayoutInline.h" 52 #include "core/layout/LayoutInline.h"
53 #include "core/layout/LayoutObject.h" 53 #include "core/layout/LayoutObject.h"
54 #include "core/layout/LayoutTextFragment.h" 54 #include "core/layout/LayoutTextFragment.h"
55 #include "core/layout/LayoutView.h" 55 #include "core/layout/LayoutView.h"
56 #include "core/layout/api/LineLayoutAPIShim.h"
56 #include "core/layout/api/LineLayoutItem.h" 57 #include "core/layout/api/LineLayoutItem.h"
57 #include "core/layout/line/InlineIterator.h" 58 #include "core/layout/line/InlineIterator.h"
58 #include "core/layout/line/InlineTextBox.h" 59 #include "core/layout/line/InlineTextBox.h"
59 #include "core/paint/LineLayoutPaintShim.h"
60 #include "core/paint/PaintLayer.h" 60 #include "core/paint/PaintLayer.h"
61 #include "platform/Logging.h" 61 #include "platform/Logging.h"
62 #include "platform/RuntimeEnabledFeatures.h" 62 #include "platform/RuntimeEnabledFeatures.h"
63 #include "platform/heap/Handle.h" 63 #include "platform/heap/Handle.h"
64 #include "platform/text/TextBoundaries.h" 64 #include "platform/text/TextBoundaries.h"
65 65
66 namespace blink { 66 namespace blink {
67 67
68 template <typename PositionType> 68 template <typename PositionType>
69 static PositionType canonicalizeCandidate(const PositionType& candidate) 69 static PositionType canonicalizeCandidate(const PositionType& candidate)
(...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 } 2117 }
2118 Node* node = position.position().anchorNode(); 2118 Node* node = position.position().anchorNode();
2119 2119
2120 layoutObject = node->layoutObject(); 2120 layoutObject = node->layoutObject();
2121 if (!layoutObject) 2121 if (!layoutObject)
2122 return LayoutRect(); 2122 return LayoutRect();
2123 2123
2124 InlineBoxPosition boxPosition = computeInlineBoxPosition(position.position() , position.affinity()); 2124 InlineBoxPosition boxPosition = computeInlineBoxPosition(position.position() , position.affinity());
2125 2125
2126 if (boxPosition.inlineBox) 2126 if (boxPosition.inlineBox)
2127 layoutObject = LineLayoutPaintShim::layoutObjectFrom(boxPosition.inlineB ox->lineLayoutItem()); 2127 layoutObject = LineLayoutAPIShim::layoutObjectFrom(boxPosition.inlineBox ->lineLayoutItem());
2128 2128
2129 return layoutObject->localCaretRect(boxPosition.inlineBox, boxPosition.offse tInBox); 2129 return layoutObject->localCaretRect(boxPosition.inlineBox, boxPosition.offse tInBox);
2130 } 2130 }
2131 2131
2132 LayoutRect localCaretRectOfPosition(const PositionWithAffinity& position, Layout Object*& layoutObject) 2132 LayoutRect localCaretRectOfPosition(const PositionWithAffinity& position, Layout Object*& layoutObject)
2133 { 2133 {
2134 return localCaretRectOfPositionTemplate<EditingStrategy>(position, layoutObj ect); 2134 return localCaretRectOfPositionTemplate<EditingStrategy>(position, layoutObj ect);
2135 } 2135 }
2136 2136
2137 LayoutRect localCaretRectOfPosition(const PositionInComposedTreeWithAffinity& po sition, LayoutObject*& layoutObject) 2137 LayoutRect localCaretRectOfPosition(const PositionInComposedTreeWithAffinity& po sition, LayoutObject*& layoutObject)
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 2529
2530 // The text continues on the next line only if the last text box is not on this line and 2530 // The text continues on the next line only if the last text box is not on this line and
2531 // none of the boxes on this line have a larger start offset. 2531 // none of the boxes on this line have a larger start offset.
2532 2532
2533 bool continuesOnNextLine = true; 2533 bool continuesOnNextLine = true;
2534 InlineBox* otherBox = box; 2534 InlineBox* otherBox = box;
2535 while (continuesOnNextLine) { 2535 while (continuesOnNextLine) {
2536 otherBox = otherBox->nextLeafChild(); 2536 otherBox = otherBox->nextLeafChild();
2537 if (!otherBox) 2537 if (!otherBox)
2538 break; 2538 break;
2539 if (otherBox == lastTextBox || (LineLayoutPaintShim::layoutO bjectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(oth erBox)->start() > textOffset)) 2539 if (otherBox == lastTextBox || (LineLayoutAPIShim::layoutObj ectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(other Box)->start() > textOffset))
2540 continuesOnNextLine = false; 2540 continuesOnNextLine = false;
2541 } 2541 }
2542 2542
2543 otherBox = box; 2543 otherBox = box;
2544 while (continuesOnNextLine) { 2544 while (continuesOnNextLine) {
2545 otherBox = otherBox->prevLeafChild(); 2545 otherBox = otherBox->prevLeafChild();
2546 if (!otherBox) 2546 if (!otherBox)
2547 break; 2547 break;
2548 if (otherBox == lastTextBox || (LineLayoutPaintShim::layoutO bjectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(oth erBox)->start() > textOffset)) 2548 if (otherBox == lastTextBox || (LineLayoutAPIShim::layoutObj ectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(other Box)->start() > textOffset))
2549 continuesOnNextLine = false; 2549 continuesOnNextLine = false;
2550 } 2550 }
2551 2551
2552 if (continuesOnNextLine) 2552 if (continuesOnNextLine)
2553 return currentPos.computePosition(); 2553 return currentPos.computePosition();
2554 } 2554 }
2555 } 2555 }
2556 } 2556 }
2557 return lastVisible.deprecatedComputePosition(); 2557 return lastVisible.deprecatedComputePosition();
2558 } 2558 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 2660
2661 // The text continues on the next line only if the last text box is not on this line and 2661 // The text continues on the next line only if the last text box is not on this line and
2662 // none of the boxes on this line have a larger start offset. 2662 // none of the boxes on this line have a larger start offset.
2663 2663
2664 bool continuesOnNextLine = true; 2664 bool continuesOnNextLine = true;
2665 InlineBox* otherBox = box; 2665 InlineBox* otherBox = box;
2666 while (continuesOnNextLine) { 2666 while (continuesOnNextLine) {
2667 otherBox = otherBox->nextLeafChild(); 2667 otherBox = otherBox->nextLeafChild();
2668 if (!otherBox) 2668 if (!otherBox)
2669 break; 2669 break;
2670 if (otherBox == lastTextBox || (LineLayoutPaintShim::layoutO bjectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(oth erBox)->start() >= textOffset)) 2670 if (otherBox == lastTextBox || (LineLayoutAPIShim::layoutObj ectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(other Box)->start() >= textOffset))
2671 continuesOnNextLine = false; 2671 continuesOnNextLine = false;
2672 } 2672 }
2673 2673
2674 otherBox = box; 2674 otherBox = box;
2675 while (continuesOnNextLine) { 2675 while (continuesOnNextLine) {
2676 otherBox = otherBox->prevLeafChild(); 2676 otherBox = otherBox->prevLeafChild();
2677 if (!otherBox) 2677 if (!otherBox)
2678 break; 2678 break;
2679 if (otherBox == lastTextBox || (LineLayoutPaintShim::layoutO bjectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(oth erBox)->start() >= textOffset)) 2679 if (otherBox == lastTextBox || (LineLayoutAPIShim::layoutObj ectFrom(otherBox->lineLayoutItem()) == textLayoutObject && toInlineTextBox(other Box)->start() >= textOffset))
2680 continuesOnNextLine = false; 2680 continuesOnNextLine = false;
2681 } 2681 }
2682 2682
2683 if (continuesOnNextLine) 2683 if (continuesOnNextLine)
2684 return currentPos.computePosition(); 2684 return currentPos.computePosition();
2685 } 2685 }
2686 } 2686 }
2687 } 2687 }
2688 2688
2689 return lastVisible.deprecatedComputePosition(); 2689 return lastVisible.deprecatedComputePosition();
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 TextDirection primaryDirection = primaryDirectionOf(*p.anchorNode()); 3077 TextDirection primaryDirection = primaryDirectionOf(*p.anchorNode());
3078 const TextAffinity affinity = visiblePosition.affinity(); 3078 const TextAffinity affinity = visiblePosition.affinity();
3079 3079
3080 while (true) { 3080 while (true) {
3081 InlineBoxPosition boxPosition = computeInlineBoxPosition(p, affinity, pr imaryDirection); 3081 InlineBoxPosition boxPosition = computeInlineBoxPosition(p, affinity, pr imaryDirection);
3082 InlineBox* box = boxPosition.inlineBox; 3082 InlineBox* box = boxPosition.inlineBox;
3083 int offset = boxPosition.offsetInBox; 3083 int offset = boxPosition.offsetInBox;
3084 if (!box) 3084 if (!box)
3085 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(deepP osition) : previousVisuallyDistinctCandidate(deepPosition); 3085 return primaryDirection == LTR ? nextVisuallyDistinctCandidate(deepP osition) : previousVisuallyDistinctCandidate(deepPosition);
3086 3086
3087 LayoutObject* layoutObject = LineLayoutPaintShim::layoutObjectFrom(box-> lineLayoutItem()); 3087 LayoutObject* layoutObject = LineLayoutAPIShim::layoutObjectFrom(box->li neLayoutItem());
3088 3088
3089 while (true) { 3089 while (true) {
3090 if ((layoutObject->isAtomicInlineLevel() || layoutObject->isBR()) && offset == box->caretLeftmostOffset()) 3090 if ((layoutObject->isAtomicInlineLevel() || layoutObject->isBR()) && offset == box->caretLeftmostOffset())
3091 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi date(deepPosition) : previousVisuallyDistinctCandidate(deepPosition); 3091 return box->isLeftToRightDirection() ? nextVisuallyDistinctCandi date(deepPosition) : previousVisuallyDistinctCandidate(deepPosition);
3092 3092
3093 if (!layoutObject->node()) { 3093 if (!layoutObject->node()) {
3094 box = box->nextLeafChild(); 3094 box = box->nextLeafChild();
3095 if (!box) 3095 if (!box)
3096 return primaryDirection == LTR ? nextVisuallyDistinctCandida te(deepPosition) : previousVisuallyDistinctCandidate(deepPosition); 3096 return primaryDirection == LTR ? nextVisuallyDistinctCandida te(deepPosition) : previousVisuallyDistinctCandidate(deepPosition);
3097 layoutObject = LineLayoutPaintShim::layoutObjectFrom(box->lineLa youtItem()); 3097 layoutObject = LineLayoutAPIShim::layoutObjectFrom(box->lineLayo utItem());
3098 offset = box->caretLeftmostOffset(); 3098 offset = box->caretLeftmostOffset();
3099 continue; 3099 continue;
3100 } 3100 }
3101 3101
3102 offset = box->isLeftToRightDirection() ? layoutObject->nextOffset(of fset) : layoutObject->previousOffset(offset); 3102 offset = box->isLeftToRightDirection() ? layoutObject->nextOffset(of fset) : layoutObject->previousOffset(offset);
3103 3103
3104 int caretMinOffset = box->caretMinOffset(); 3104 int caretMinOffset = box->caretMinOffset();
3105 int caretMaxOffset = box->caretMaxOffset(); 3105 int caretMaxOffset = box->caretMaxOffset();
3106 3106
3107 if (offset > caretMinOffset && offset < caretMaxOffset) 3107 if (offset > caretMinOffset && offset < caretMaxOffset)
3108 break; 3108 break;
3109 3109
3110 if (box->isLeftToRightDirection() ? offset > caretMaxOffset : offset < caretMinOffset) { 3110 if (box->isLeftToRightDirection() ? offset > caretMaxOffset : offset < caretMinOffset) {
3111 // Overshot to the right. 3111 // Overshot to the right.
3112 InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak(); 3112 InlineBox* nextBox = box->nextLeafChildIgnoringLineBreak();
3113 if (!nextBox) { 3113 if (!nextBox) {
3114 PositionTemplate<Strategy> positionOnRight = primaryDirectio n == LTR ? nextVisuallyDistinctCandidate(deepPosition) : previousVisuallyDistinc tCandidate(deepPosition); 3114 PositionTemplate<Strategy> positionOnRight = primaryDirectio n == LTR ? nextVisuallyDistinctCandidate(deepPosition) : previousVisuallyDistinc tCandidate(deepPosition);
3115 if (positionOnRight.isNull()) 3115 if (positionOnRight.isNull())
3116 return PositionTemplate<Strategy>(); 3116 return PositionTemplate<Strategy>();
3117 3117
3118 InlineBox* boxOnRight = computeInlineBoxPosition(positionOnR ight, affinity, primaryDirection).inlineBox; 3118 InlineBox* boxOnRight = computeInlineBoxPosition(positionOnR ight, affinity, primaryDirection).inlineBox;
3119 if (boxOnRight && boxOnRight->root() == box->root()) 3119 if (boxOnRight && boxOnRight->root() == box->root())
3120 return PositionTemplate<Strategy>(); 3120 return PositionTemplate<Strategy>();
3121 return positionOnRight; 3121 return positionOnRight;
3122 } 3122 }
3123 3123
3124 // Reposition at the other logical position corresponding to our 3124 // Reposition at the other logical position corresponding to our
3125 // edge's visual position and go for another round. 3125 // edge's visual position and go for another round.
3126 box = nextBox; 3126 box = nextBox;
3127 layoutObject = LineLayoutPaintShim::layoutObjectFrom(box->lineLa youtItem()); 3127 layoutObject = LineLayoutAPIShim::layoutObjectFrom(box->lineLayo utItem());
3128 offset = nextBox->caretLeftmostOffset(); 3128 offset = nextBox->caretLeftmostOffset();
3129 continue; 3129 continue;
3130 } 3130 }
3131 3131
3132 ASSERT(offset == box->caretRightmostOffset()); 3132 ASSERT(offset == box->caretRightmostOffset());
3133 3133
3134 unsigned char level = box->bidiLevel(); 3134 unsigned char level = box->bidiLevel();
3135 InlineBox* nextBox = box->nextLeafChild(); 3135 InlineBox* nextBox = box->nextLeafChild();
3136 3136
3137 if (box->direction() == primaryDirection) { 3137 if (box->direction() == primaryDirection) {
3138 if (!nextBox) { 3138 if (!nextBox) {
3139 InlineBox* logicalEnd = 0; 3139 InlineBox* logicalEnd = 0;
3140 if (primaryDirection == LTR ? box->root().getLogicalEndBoxWi thNode(logicalEnd) : box->root().getLogicalStartBoxWithNode(logicalEnd)) { 3140 if (primaryDirection == LTR ? box->root().getLogicalEndBoxWi thNode(logicalEnd) : box->root().getLogicalStartBoxWithNode(logicalEnd)) {
3141 box = logicalEnd; 3141 box = logicalEnd;
3142 layoutObject = LineLayoutPaintShim::layoutObjectFrom(box ->lineLayoutItem()); 3142 layoutObject = LineLayoutAPIShim::layoutObjectFrom(box-> lineLayoutItem());
3143 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->caretMinOffset(); 3143 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->caretMinOffset();
3144 } 3144 }
3145 break; 3145 break;
3146 } 3146 }
3147 3147
3148 if (nextBox->bidiLevel() >= level) 3148 if (nextBox->bidiLevel() >= level)
3149 break; 3149 break;
3150 3150
3151 level = nextBox->bidiLevel(); 3151 level = nextBox->bidiLevel();
3152 3152
3153 InlineBox* prevBox = box; 3153 InlineBox* prevBox = box;
3154 do { 3154 do {
3155 prevBox = prevBox->prevLeafChild(); 3155 prevBox = prevBox->prevLeafChild();
3156 } while (prevBox && prevBox->bidiLevel() > level); 3156 } while (prevBox && prevBox->bidiLevel() > level);
3157 3157
3158 // For example, abc FED 123 ^ CBA 3158 // For example, abc FED 123 ^ CBA
3159 if (prevBox && prevBox->bidiLevel() == level) 3159 if (prevBox && prevBox->bidiLevel() == level)
3160 break; 3160 break;
3161 3161
3162 // For example, abc 123 ^ CBA or 123 ^ CBA abc 3162 // For example, abc 123 ^ CBA or 123 ^ CBA abc
3163 box = nextBox; 3163 box = nextBox;
3164 layoutObject = LineLayoutPaintShim::layoutObjectFrom(box->lineLa youtItem()); 3164 layoutObject = LineLayoutAPIShim::layoutObjectFrom(box->lineLayo utItem());
3165 offset = box->caretLeftmostOffset(); 3165 offset = box->caretLeftmostOffset();
3166 if (box->direction() == primaryDirection) 3166 if (box->direction() == primaryDirection)
3167 break; 3167 break;
3168 continue; 3168 continue;
3169 } 3169 }
3170 3170
3171 while (nextBox && !nextBox->lineLayoutItem().node()) 3171 while (nextBox && !nextBox->lineLayoutItem().node())
3172 nextBox = nextBox->nextLeafChild(); 3172 nextBox = nextBox->nextLeafChild();
3173 3173
3174 if (nextBox) { 3174 if (nextBox) {
3175 box = nextBox; 3175 box = nextBox;
3176 layoutObject = LineLayoutPaintShim::layoutObjectFrom(box->lineLa youtItem()); 3176 layoutObject = LineLayoutAPIShim::layoutObjectFrom(box->lineLayo utItem());
3177 offset = box->caretLeftmostOffset(); 3177 offset = box->caretLeftmostOffset();
3178 3178
3179 if (box->bidiLevel() > level) { 3179 if (box->bidiLevel() > level) {
3180 do { 3180 do {
3181 nextBox = nextBox->nextLeafChild(); 3181 nextBox = nextBox->nextLeafChild();
3182 } while (nextBox && nextBox->bidiLevel() > level); 3182 } while (nextBox && nextBox->bidiLevel() > level);
3183 3183
3184 if (!nextBox || nextBox->bidiLevel() < level) 3184 if (!nextBox || nextBox->bidiLevel() < level)
3185 continue; 3185 continue;
3186 } 3186 }
(...skipping 10 matching lines...) Expand all
3197 level = box->bidiLevel(); 3197 level = box->bidiLevel();
3198 while (InlineBox* nextBox = box->nextLeafChild()) { 3198 while (InlineBox* nextBox = box->nextLeafChild()) {
3199 if (nextBox->bidiLevel() < level) 3199 if (nextBox->bidiLevel() < level)
3200 break; 3200 break;
3201 box = nextBox; 3201 box = nextBox;
3202 } 3202 }
3203 if (box->bidiLevel() == level) 3203 if (box->bidiLevel() == level)
3204 break; 3204 break;
3205 level = box->bidiLevel(); 3205 level = box->bidiLevel();
3206 } 3206 }
3207 layoutObject = LineLayoutPaintShim::layoutObjectFrom(box->lineLa youtItem()); 3207 layoutObject = LineLayoutAPIShim::layoutObjectFrom(box->lineLayo utItem());
3208 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset(); 3208 offset = primaryDirection == LTR ? box->caretMaxOffset() : box-> caretMinOffset();
3209 } 3209 }
3210 break; 3210 break;
3211 } 3211 }
3212 3212
3213 p = PositionTemplate<Strategy>::editingPositionOf(layoutObject->node(), offset); 3213 p = PositionTemplate<Strategy>::editingPositionOf(layoutObject->node(), offset);
3214 3214
3215 if ((isVisuallyEquivalentCandidate(p) && mostForwardCaretPosition(p) != downstreamStart) || p.atStartOfTree() || p.atEndOfTree()) 3215 if ((isVisuallyEquivalentCandidate(p) && mostForwardCaretPosition(p) != downstreamStart) || p.atStartOfTree() || p.atEndOfTree())
3216 return p; 3216 return p;
3217 3217
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 { 3327 {
3328 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); 3328 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule);
3329 } 3329 }
3330 3330
3331 VisiblePositionInComposedTree previousPositionOf(const VisiblePositionInComposed Tree& visiblePosition, EditingBoundaryCrossingRule rule) 3331 VisiblePositionInComposedTree previousPositionOf(const VisiblePositionInComposed Tree& visiblePosition, EditingBoundaryCrossingRule rule)
3332 { 3332 {
3333 return previousPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePos ition, rule); 3333 return previousPositionOfAlgorithm<EditingInComposedTreeStrategy>(visiblePos ition, rule);
3334 } 3334 }
3335 3335
3336 } // namespace blink 3336 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698