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

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: Position trying to look in multiple level for direction auto 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* anchorNode)
83 {
84 Node* node = anchorNode;
85 while (node) {
86 if (node->selfOrAncestorHasDirAutoAttribute())
87 return true;
88 if (node->isInShadowTree()) {
leviw_travelin_and_unemployed 2014/06/04 17:16:32 If you're scoping your NodeTraversal to your ancho
Habib Virji 2014/06/05 18:57:53 Ok thanks, i have corrected it.
89 if (equalIgnoringCase(node->shadowHost()->fastGetAttribute(dirAttr), "auto"))
leviw_travelin_and_unemployed 2014/06/04 17:16:32 is fastGetAttribute(dirAttr) == "auto" ever true w
Habib Virji 2014/06/05 18:57:53 @leviw: Yes it does work and satisfy the bug test
leviw_travelin_and_unemployed 2014/06/05 21:14:05 If while walking you come across an ancestor with
Habib Virji 2014/06/06 13:52:31 Done. Thanks, updated code to check if direction
90 return true;
91 }
92 node = NodeTraversal::next(*node, anchorNode);
leviw_travelin_and_unemployed 2014/06/04 17:16:32 Why are you using anchorNode as your container? Th
Habib Virji 2014/06/05 18:57:53 @leviw: i was trying to address, esphern comment a
leviw_travelin_and_unemployed 2014/06/05 21:14:05 I understand what you wanted to address, but this
Habib Virji 2014/06/06 13:52:31 Done. Corrected now.
93 }
94 return false;
95 }
96
82 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset) 97 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset)
83 : m_anchorNode(anchorNode) 98 : m_anchorNode(anchorNode)
84 , m_offset(offset.value()) 99 , m_offset(offset.value())
85 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et)) 100 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et))
86 , m_isLegacyEditingPosition(true) 101 , m_isLegacyEditingPosition(true)
87 { 102 {
88 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); 103 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement());
89 } 104 }
90 105
91 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, AnchorType anchorTyp e) 106 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, AnchorType anchorTyp e)
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 } 1268 }
1254 } else { 1269 } else {
1255 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak(); 1270 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak();
1256 if (!nextBox || nextBox->bidiLevel() < level) { 1271 if (!nextBox || nextBox->bidiLevel() < level) {
1257 // Right edge of a secondary run. Set to the left edge of the entire run. 1272 // Right edge of a secondary run. Set to the left edge of the entire run.
1258 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) { 1273 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) {
1259 if (prevBox->bidiLevel() < level) 1274 if (prevBox->bidiLevel() < level)
1260 break; 1275 break;
1261 inlineBox = prevBox; 1276 inlineBox = prevBox;
1262 } 1277 }
1263 caretOffset = inlineBox->caretLeftmostOffset(); 1278 if (hasDirectionAutoAttribute(m_anchorNode.get()))
1279 caretOffset = (inlineBox->bidiLevel() < level) ? inlineBox->care tLeftmostOffset() : inlineBox->caretRightmostOffset();
1280 else
1281 caretOffset = inlineBox->caretLeftmostOffset();
1264 } else if (nextBox->bidiLevel() > level) { 1282 } else if (nextBox->bidiLevel() > level) {
1265 // Left edge of a "tertiary" run. Set to the right edge of that run. 1283 // Left edge of a "tertiary" run. Set to the right edge of that run.
1266 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) { 1284 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) {
1267 if (tertiaryBox->bidiLevel() <= level) 1285 if (tertiaryBox->bidiLevel() <= level)
1268 break; 1286 break;
1269 inlineBox = tertiaryBox; 1287 inlineBox = tertiaryBox;
1270 } 1288 }
1271 caretOffset = inlineBox->caretRightmostOffset(); 1289 caretOffset = inlineBox->caretRightmostOffset();
1272 } 1290 }
1273 } 1291 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 pos.showTreeForThis(); 1382 pos.showTreeForThis();
1365 } 1383 }
1366 1384
1367 void showTree(const WebCore::Position* pos) 1385 void showTree(const WebCore::Position* pos)
1368 { 1386 {
1369 if (pos) 1387 if (pos)
1370 pos->showTreeForThis(); 1388 pos->showTreeForThis();
1371 } 1389 }
1372 1390
1373 #endif 1391 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698