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

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

Issue 1201403002: Make VisiblePosition constructor to canonicalize a position in composed tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-25T17:29:10 Update use-events-crash.svg expectations Created 5 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 | « Source/core/dom/Position.h ('k') | Source/core/editing/StyledMarkupSerializer.cpp » ('j') | 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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 lastPosition = position; 1197 lastPosition = position;
1198 position = position.upstream(CanCrossEditingBoundary); 1198 position = position.upstream(CanCrossEditingBoundary);
1199 } 1199 }
1200 return position; 1200 return position;
1201 } 1201 }
1202 1202
1203 template <typename Strategy> 1203 template <typename Strategy>
1204 void PositionAlgorithm<Strategy>::getInlineBoxAndOffset(EAffinity affinity, Text Direction primaryDirection, InlineBox*& inlineBox, int& caretOffset) const 1204 void PositionAlgorithm<Strategy>::getInlineBoxAndOffset(EAffinity affinity, Text Direction primaryDirection, InlineBox*& inlineBox, int& caretOffset) const
1205 { 1205 {
1206 caretOffset = deprecatedEditingOffset(); 1206 caretOffset = deprecatedEditingOffset();
1207 LayoutObject* layoutObject = deprecatedNode()->layoutObject(); 1207 LayoutObject* layoutObject = m_anchorNode->isShadowRoot() ? toShadowRoot(m_a nchorNode)->host()->layoutObject() : m_anchorNode->layoutObject();
1208 1208
1209 if (!layoutObject->isText()) { 1209 if (!layoutObject->isText()) {
1210 inlineBox = 0; 1210 inlineBox = 0;
1211 if (canHaveChildrenForEditing(deprecatedNode()) && layoutObject->isLayou tBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(layoutObject)) { 1211 if (canHaveChildrenForEditing(deprecatedNode()) && layoutObject->isLayou tBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(layoutObject)) {
1212 // Try a visually equivalent position with possibly opposite editabi lity. This helps in case |this| is in 1212 // Try a visually equivalent position with possibly opposite editabi lity. This helps in case |this| is in
1213 // an editable block but surrounded by non-editable positions. It ac ts to negate the logic at the beginning 1213 // an editable block but surrounded by non-editable positions. It ac ts to negate the logic at the beginning
1214 // of LayoutObject::createVisiblePosition(). 1214 // of LayoutObject::createVisiblePosition().
1215 PositionType thisPosition = PositionType(*this); 1215 PositionType thisPosition = PositionType(*this);
1216 PositionType equivalent = downstreamIgnoringEditingBoundaries<typena me Strategy::PositionType>(thisPosition); 1216 PositionType equivalent = downstreamIgnoringEditingBoundaries<typena me Strategy::PositionType>(thisPosition);
1217 if (equivalent == thisPosition) { 1217 if (equivalent == thisPosition) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 Node* child = NodeTraversal::childAt(*anchor, pos.computeOffsetInContain erNode()); 1411 Node* child = NodeTraversal::childAt(*anchor, pos.computeOffsetInContain erNode());
1412 if (!child) 1412 if (!child)
1413 return PositionInComposedTree(anchor, PositionInComposedTree::Positi onIsAfterChildren); 1413 return PositionInComposedTree(anchor, PositionInComposedTree::Positi onIsAfterChildren);
1414 child->updateDistribution(); 1414 child->updateDistribution();
1415 return PositionInComposedTree(ComposedTreeTraversal::parent(*child), Com posedTreeTraversal::index(*child), PositionInComposedTree::PositionIsOffsetInAnc hor); 1415 return PositionInComposedTree(ComposedTreeTraversal::parent(*child), Com posedTreeTraversal::index(*child), PositionInComposedTree::PositionIsOffsetInAnc hor);
1416 } 1416 }
1417 1417
1418 return PositionInComposedTree(pos.anchorNode(), static_cast<PositionInCompos edTree::AnchorType>(pos.anchorType())); 1418 return PositionInComposedTree(pos.anchorNode(), static_cast<PositionInCompos edTree::AnchorType>(pos.anchorType()));
1419 } 1419 }
1420 1420
1421 Position toPositionInDOMTree(const Position& position)
1422 {
1423 return position;
1424 }
1425
1421 Position toPositionInDOMTree(const PositionInComposedTree& position) 1426 Position toPositionInDOMTree(const PositionInComposedTree& position)
1422 { 1427 {
1423 if (position.isNull()) 1428 if (position.isNull())
1424 return Position(); 1429 return Position();
1425 1430
1426 Node* anchorNode = position.anchorNode(); 1431 Node* anchorNode = position.anchorNode();
1427 1432
1428 switch (position.anchorType()) { 1433 switch (position.anchorType()) {
1429 case PositionInComposedTree::PositionIsAfterChildren: 1434 case PositionInComposedTree::PositionIsAfterChildren:
1430 // FIXME: When anchorNode is <img>, assertion fails in the constructor. 1435 // FIXME: When anchorNode is <img>, assertion fails in the constructor.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 1540
1536 void showTree(const blink::Position* pos) 1541 void showTree(const blink::Position* pos)
1537 { 1542 {
1538 if (pos) 1543 if (pos)
1539 pos->showTreeForThis(); 1544 pos->showTreeForThis();
1540 else 1545 else
1541 fprintf(stderr, "Cannot showTree for (nil)\n"); 1546 fprintf(stderr, "Cannot showTree for (nil)\n");
1542 } 1547 }
1543 1548
1544 #endif 1549 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Position.h ('k') | Source/core/editing/StyledMarkupSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698