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

Side by Side Diff: Source/core/dom/Position.cpp

Issue 302433015: Use correct offset when attribute auto is present (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated tests to pass on mac and windows. Also a condition in HTMLElement which sets any direction … Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2009 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (!renderer) 72 if (!renderer)
73 continue; 73 continue;
74 if (!node->rendererIsEditable()) 74 if (!node->rendererIsEditable())
75 continue; 75 continue;
76 if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox())) 76 if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox()))
77 return node; 77 return node;
78 } 78 }
79 return 0; 79 return 0;
80 } 80 }
81 81
82 static bool hasDirectionAutoAttribute(Node* node)
83 {
84 if (node->selfOrAncestorHasDirAutoAttribute())
85 return true;
86 if (node->isInShadowTree()) {
87 while (node) {
88 if (node->isShadowRoot())
esprehn 2014/06/11 00:58:01 This can just be node->containingShadowRoot() whic
Habib Virji 2014/06/11 08:56:01 Done.
89 return node->shadowHost()->selfOrAncestorHasDirAutoAttribute();
90 node = node->parentNode();
91 }
92 }
93 return false;
94 }
95
82 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset) 96 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset)
83 : m_anchorNode(anchorNode) 97 : m_anchorNode(anchorNode)
84 , m_offset(offset.value()) 98 , m_offset(offset.value())
85 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et)) 99 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et))
86 , m_isLegacyEditingPosition(true) 100 , m_isLegacyEditingPosition(true)
87 { 101 {
88 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); 102 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement());
89 } 103 }
90 104
91 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, AnchorType anchorTyp e) 105 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, AnchorType anchorTyp e)
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 } 1267 }
1254 } else { 1268 } else {
1255 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak(); 1269 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak();
1256 if (!nextBox || nextBox->bidiLevel() < level) { 1270 if (!nextBox || nextBox->bidiLevel() < level) {
1257 // Right edge of a secondary run. Set to the left edge of the entire run. 1271 // Right edge of a secondary run. Set to the left edge of the entire run.
1258 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) { 1272 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) {
1259 if (prevBox->bidiLevel() < level) 1273 if (prevBox->bidiLevel() < level)
1260 break; 1274 break;
1261 inlineBox = prevBox; 1275 inlineBox = prevBox;
1262 } 1276 }
1263 caretOffset = inlineBox->caretLeftmostOffset(); 1277 if (hasDirectionAutoAttribute(m_anchorNode.get()))
1278 caretOffset = (inlineBox->bidiLevel() < level) ? inlineBox->care tLeftmostOffset() : inlineBox->caretRightmostOffset();
1279 else
1280 caretOffset = inlineBox->caretLeftmostOffset();
1264 } else if (nextBox->bidiLevel() > level) { 1281 } else if (nextBox->bidiLevel() > level) {
1265 // Left edge of a "tertiary" run. Set to the right edge of that run. 1282 // Left edge of a "tertiary" run. Set to the right edge of that run.
1266 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) { 1283 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) {
1267 if (tertiaryBox->bidiLevel() <= level) 1284 if (tertiaryBox->bidiLevel() <= level)
1268 break; 1285 break;
1269 inlineBox = tertiaryBox; 1286 inlineBox = tertiaryBox;
1270 } 1287 }
1271 caretOffset = inlineBox->caretRightmostOffset(); 1288 caretOffset = inlineBox->caretRightmostOffset();
1272 } 1289 }
1273 } 1290 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 pos.showTreeForThis(); 1381 pos.showTreeForThis();
1365 } 1382 }
1366 1383
1367 void showTree(const WebCore::Position* pos) 1384 void showTree(const WebCore::Position* pos)
1368 { 1385 {
1369 if (pos) 1386 if (pos)
1370 pos->showTreeForThis(); 1387 pos->showTreeForThis();
1371 } 1388 }
1372 1389
1373 #endif 1390 #endif
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/caret-in-textarea-auto-expected.txt ('k') | Source/core/html/HTMLElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698