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

Unified Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2674673004: Consider editability when looking for a caret position (Closed)
Patch Set: Include editing boundaries when looking for a better match on inline-box position. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
index 8abdcb4c98eaff5baac6ead9d0b929fd4ad0cf91..ae37d3d18e9ba048f1e0c508897f2a077d313a3a 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -2241,7 +2241,9 @@ static bool isNonTextLeafChild(LayoutObject* object) {
return true;
}
-static InlineTextBox* searchAheadForBetterMatch(LayoutObject* layoutObject) {
+static InlineTextBox* searchAheadForBetterMatch(
+ LayoutObject* layoutObject,
+ EditingBoundaryCrossingRule rule) {
LayoutBlock* container = layoutObject->containingBlock();
for (LayoutObject* next = layoutObject->nextInPreOrder(container); next;
next = next->nextInPreOrder(container)) {
@@ -2252,6 +2254,9 @@ static InlineTextBox* searchAheadForBetterMatch(LayoutObject* layoutObject) {
if (isNonTextLeafChild(next))
return 0;
if (next->isText()) {
+ if (rule == CannotCrossEditingBoundary &&
+ next->style()->userModify() == READ_ONLY)
+ return 0;
InlineTextBox* match = 0;
int minOffset = INT_MAX;
for (InlineTextBox* box = toLayoutText(next)->firstTextBox(); box;
@@ -2324,6 +2329,10 @@ static InlineBoxPosition computeInlineBoxPositionTemplate(
if (canHaveChildrenForEditing(anchorNode) &&
layoutObject->isLayoutBlockFlow() &&
hasRenderedNonAnonymousDescendantsWithHeight(layoutObject)) {
+ if (layoutObject->isLayoutBlock() &&
+ toLayoutBlock(layoutObject)->childrenInline()) {
+ return InlineBoxPosition(inlineBox, caretOffset);
+ }
// Try a visually equivalent position with possibly opposite
// editability. This helps in case |this| is in an editable block
// but surrounded by non-editable positions. It acts to negate the
@@ -2377,7 +2386,10 @@ static InlineBoxPosition computeInlineBoxPositionTemplate(
}
if (candidate && candidate == textLayoutObject->lastTextBox() &&
affinity == TextAffinity::Downstream) {
- box = searchAheadForBetterMatch(textLayoutObject);
+ box = searchAheadForBetterMatch(textLayoutObject,
+ hasEditableStyle(*anchorNode)
+ ? CannotCrossEditingBoundary
+ : CanCrossEditingBoundary);
if (box)
caretOffset = box->caretMinOffset();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698