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

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 to latest master 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
« no previous file with comments | « LayoutTests/editing/selection/caret-in-textarea-auto-expected.txt ('k') | no next file » | 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, 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 isTextDirectionHasAutoAttribute(Node *node)
Inactive 2014/06/02 15:15:08 nit: star on wrong side. nit: "isTextDirectionHasA
Habib Virji 2014/06/02 15:23:52 Done.
83 {
84 bool isAuto = node->selfOrAncestorHasDirAutoAttribute();
85 if (node->isInShadowTree()) {
Inactive 2014/06/02 15:15:08 nit: No need for curly brackets.
Habib Virji 2014/06/02 15:23:52 Done.
86 isAuto = equalIgnoringCase(node->shadowHost()->fastGetAttribute(dirAttr) , "auto");
87 }
88 return isAuto;
89 }
90
82 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset) 91 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset)
83 : m_anchorNode(anchorNode) 92 : m_anchorNode(anchorNode)
84 , m_offset(offset.value()) 93 , m_offset(offset.value())
85 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et)) 94 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et))
86 , m_isLegacyEditingPosition(true) 95 , m_isLegacyEditingPosition(true)
87 { 96 {
88 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); 97 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement());
89 } 98 }
90 99
91 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, AnchorType anchorTyp e) 100 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, AnchorType anchorTyp e)
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 } 1262 }
1254 } else { 1263 } else {
1255 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak(); 1264 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak();
1256 if (!nextBox || nextBox->bidiLevel() < level) { 1265 if (!nextBox || nextBox->bidiLevel() < level) {
1257 // Right edge of a secondary run. Set to the left edge of the entire run. 1266 // Right edge of a secondary run. Set to the left edge of the entire run.
1258 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) { 1267 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) {
1259 if (prevBox->bidiLevel() < level) 1268 if (prevBox->bidiLevel() < level)
1260 break; 1269 break;
1261 inlineBox = prevBox; 1270 inlineBox = prevBox;
1262 } 1271 }
1263 caretOffset = inlineBox->caretLeftmostOffset(); 1272 if (isTextDirectionHasAutoAttribute(m_anchorNode.get()))
1273 caretOffset = (inlineBox->bidiLevel() < level) ? inlineBox->care tLeftmostOffset() : inlineBox->caretRightmostOffset();
1274 else
1275 caretOffset = inlineBox->caretLeftmostOffset();
1264 } else if (nextBox->bidiLevel() > level) { 1276 } else if (nextBox->bidiLevel() > level) {
1265 // Left edge of a "tertiary" run. Set to the right edge of that run. 1277 // Left edge of a "tertiary" run. Set to the right edge of that run.
1266 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) { 1278 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) {
1267 if (tertiaryBox->bidiLevel() <= level) 1279 if (tertiaryBox->bidiLevel() <= level)
1268 break; 1280 break;
1269 inlineBox = tertiaryBox; 1281 inlineBox = tertiaryBox;
1270 } 1282 }
1271 caretOffset = inlineBox->caretRightmostOffset(); 1283 caretOffset = inlineBox->caretRightmostOffset();
1272 } 1284 }
1273 } 1285 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 pos.showTreeForThis(); 1376 pos.showTreeForThis();
1365 } 1377 }
1366 1378
1367 void showTree(const WebCore::Position* pos) 1379 void showTree(const WebCore::Position* pos)
1368 { 1380 {
1369 if (pos) 1381 if (pos)
1370 pos->showTreeForThis(); 1382 pos->showTreeForThis();
1371 } 1383 }
1372 1384
1373 #endif 1385 #endif
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/caret-in-textarea-auto-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698