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

Side by Side Diff: third_party/WebKit/Source/core/editing/Position.cpp

Issue 1489433002: Support the essential part of Shadow DOM v1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert Internals.* Created 5 years 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 PositionInComposedTree toPositionInComposedTree(const Position& pos) 387 PositionInComposedTree toPositionInComposedTree(const Position& pos)
388 { 388 {
389 if (pos.isNull()) 389 if (pos.isNull())
390 return PositionInComposedTree(); 390 return PositionInComposedTree();
391 391
392 if (pos.isOffsetInAnchor()) { 392 if (pos.isOffsetInAnchor()) {
393 Node* anchor = pos.anchorNode(); 393 Node* anchor = pos.anchorNode();
394 if (anchor->offsetInCharacters()) 394 if (anchor->offsetInCharacters())
395 return PositionInComposedTree(anchor, pos.computeOffsetInContainerNo de()); 395 return PositionInComposedTree(anchor, pos.computeOffsetInContainerNo de());
396 ASSERT(!isActiveInsertionPoint(*anchor)); 396 ASSERT(!anchor->isSlotOrActiveInsertionPoint());
397 int offset = pos.computeOffsetInContainerNode(); 397 int offset = pos.computeOffsetInContainerNode();
398 Node* child = NodeTraversal::childAt(*anchor, offset); 398 Node* child = NodeTraversal::childAt(*anchor, offset);
399 if (!child) { 399 if (!child) {
400 if (anchor->isShadowRoot()) 400 if (anchor->isShadowRoot())
401 return PositionInComposedTree(anchor->shadowHost(), PositionAnch orType::AfterChildren); 401 return PositionInComposedTree(anchor->shadowHost(), PositionAnch orType::AfterChildren);
402 return PositionInComposedTree(anchor, PositionAnchorType::AfterChild ren); 402 return PositionInComposedTree(anchor, PositionAnchorType::AfterChild ren);
403 } 403 }
404 child->updateDistribution(); 404 child->updateDistribution();
405 if (isActiveInsertionPoint(*child)) { 405 if (child->isSlotOrActiveInsertionPoint()) {
406 if (anchor->isShadowRoot()) 406 if (anchor->isShadowRoot())
407 return PositionInComposedTree(anchor->shadowHost(), offset); 407 return PositionInComposedTree(anchor->shadowHost(), offset);
408 return PositionInComposedTree(anchor, offset); 408 return PositionInComposedTree(anchor, offset);
409 } 409 }
410 if (Node* parent = ComposedTreeTraversal::parent(*child)) 410 if (Node* parent = ComposedTreeTraversal::parent(*child))
411 return PositionInComposedTree(parent, ComposedTreeTraversal::index(* child)); 411 return PositionInComposedTree(parent, ComposedTreeTraversal::index(* child));
412 // When |pos| isn't appeared in composed tree, we map |pos| to after 412 // When |pos| isn't appeared in composed tree, we map |pos| to after
413 // children of shadow host. 413 // children of shadow host.
414 // e.g. "foo",0 in <progress>foo</progress> 414 // e.g. "foo",0 in <progress>foo</progress>
415 if (anchor->isShadowRoot()) 415 if (anchor->isShadowRoot())
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 540
541 void showTree(const blink::Position* pos) 541 void showTree(const blink::Position* pos)
542 { 542 {
543 if (pos) 543 if (pos)
544 pos->showTreeForThis(); 544 pos->showTreeForThis();
545 else 545 else
546 fprintf(stderr, "Cannot showTree for (nil)\n"); 546 fprintf(stderr, "Cannot showTree for (nil)\n");
547 } 547 }
548 548
549 #endif 549 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698