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

Side by Side Diff: third_party/WebKit/WebCore/editing/htmlediting.cpp

Issue 21184: WebKit merge 40722:40785 (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 302
303 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo ckFlowOrTableElement are used. 303 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlo ckFlowOrTableElement are used.
304 // FIXME: Pass a position to this function. The enclosing block of [table, x] f or example, should be the 304 // FIXME: Pass a position to this function. The enclosing block of [table, x] f or example, should be the
305 // block that contains the table and not the table, and this function should be the only one responsible for 305 // block that contains the table and not the table, and this function should be the only one responsible for
306 // knowing about these kinds of special cases. 306 // knowing about these kinds of special cases.
307 Node* enclosingBlock(Node* node) 307 Node* enclosingBlock(Node* node)
308 { 308 {
309 return static_cast<Element*>(enclosingNodeOfType(Position(node, 0), isBlock) ); 309 return static_cast<Element*>(enclosingNodeOfType(Position(node, 0), isBlock) );
310 } 310 }
311 311
312 // Internally editing uses "invalid" positions for historical reasons. For
313 // example, in <div><img /></div>, Editing might use (img, 1) for the position
314 // after <img>, but we have to convert that to (div, 1) before handing the
315 // position to a Range object. Ideally all internal positions should
316 // be "range compliant" for simplicity.
312 Position rangeCompliantEquivalent(const Position& pos) 317 Position rangeCompliantEquivalent(const Position& pos)
313 { 318 {
314 if (pos.isNull()) 319 if (pos.isNull())
315 return Position(); 320 return Position();
316 321
317 Node *node = pos.node(); 322 Node* node = pos.node();
318 323
319 if (pos.offset() <= 0) { 324 if (pos.offset() <= 0) {
320 if (node->parentNode() && (editingIgnoresContent(node) || isTableElement (node))) 325 if (node->parentNode() && (editingIgnoresContent(node) || isTableElement (node)))
321 return positionBeforeNode(node); 326 return positionBeforeNode(node);
322 return Position(node, 0); 327 return Position(node, 0);
323 } 328 }
324 329
325 if (node->offsetInCharacters()) 330 if (node->offsetInCharacters())
326 return Position(node, min(node->maxCharacterOffset(), pos.offset())); 331 return Position(node, min(node->maxCharacterOffset(), pos.offset()));
327 332
328 int maxCompliantOffset = node->childNodeCount(); 333 int maxCompliantOffset = node->childNodeCount();
329 if (pos.offset() > maxCompliantOffset) { 334 if (pos.offset() > maxCompliantOffset) {
330 if (node->parentNode()) 335 if (node->parentNode())
331 return positionAfterNode(node); 336 return positionAfterNode(node);
332 337
333 // there is no other option at this point than to 338 // there is no other option at this point than to
334 // use the highest allowed position in the node 339 // use the highest allowed position in the node
335 return Position(node, maxCompliantOffset); 340 return Position(node, maxCompliantOffset);
336 } 341 }
337 342
338 // Editing should never generate positions like this. 343 // Editing should never generate positions like this.
339 if ((pos.offset() < maxCompliantOffset) && editingIgnoresContent(node)) { 344 if ((pos.offset() < maxCompliantOffset) && editingIgnoresContent(node)) {
340 ASSERT_NOT_REACHED(); 345 ASSERT_NOT_REACHED();
341 return node->parentNode() ? positionBeforeNode(node) : Position(node, 0) ; 346 return node->parentNode() ? positionBeforeNode(node) : Position(node, 0) ;
342 } 347 }
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 ASSERT(node->parentNode()); 1001 ASSERT(node->parentNode());
997 updatedSelection.setExtent(Position(node->parentNode(), node->nodeIndex( ))); 1002 updatedSelection.setExtent(Position(node->parentNode(), node->nodeIndex( )));
998 } 1003 }
999 1004
1000 return updatedSelection; 1005 return updatedSelection;
1001 } 1006 }
1002 1007
1003 } // namespace WebCore 1008 } // namespace WebCore
1004 1009
1005 1010
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/editing/TypingCommand.cpp ('k') | third_party/WebKit/WebCore/editing/markup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698