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

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

Issue 2776983003: Expand FrameSelection/SelectionEditor::firstRange() (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | third_party/WebKit/Source/core/editing/FrameSelection.h » ('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) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 Range* range = createRangeFromSelectionEditor(); 533 Range* range = createRangeFromSelectionEditor();
534 cacheRangeIfSelectionOfDocument(range); 534 cacheRangeIfSelectionOfDocument(range);
535 return range; 535 return range;
536 } 536 }
537 537
538 Range* DOMSelection::primaryRangeOrNull() const { 538 Range* DOMSelection::primaryRangeOrNull() const {
539 return rangeCount() > 0 ? getRangeAt(0, ASSERT_NO_EXCEPTION) : nullptr; 539 return rangeCount() > 0 ? getRangeAt(0, ASSERT_NO_EXCEPTION) : nullptr;
540 } 540 }
541 541
542 Range* DOMSelection::createRangeFromSelectionEditor() const { 542 Range* DOMSelection::createRangeFromSelectionEditor() const {
543 Position anchor = blink::anchorPosition(visibleSelection()); 543 const VisibleSelection& selection = visibleSelection();
544 const Position& anchor = blink::anchorPosition(selection);
544 if (isSelectionOfDocument() && !anchor.anchorNode()->isInShadowTree()) 545 if (isSelectionOfDocument() && !anchor.anchorNode()->isInShadowTree())
545 return frame()->selection().firstRange(); 546 return createRange(firstEphemeralRangeOf(selection));
546 547
547 Node* node = shadowAdjustedNode(anchor); 548 Node* const node = shadowAdjustedNode(anchor);
548 if (!node) // crbug.com/595100 549 if (!node) // crbug.com/595100
549 return nullptr; 550 return nullptr;
550 Position focus = focusPosition(visibleSelection()); 551 const Position& focus = focusPosition(selection);
551 if (!visibleSelection().isBaseFirst()) { 552 if (!selection.isBaseFirst()) {
552 return Range::create(*anchor.document(), shadowAdjustedNode(focus), 553 return Range::create(*anchor.document(), shadowAdjustedNode(focus),
553 shadowAdjustedOffset(focus), node, 554 shadowAdjustedOffset(focus), node,
554 shadowAdjustedOffset(anchor)); 555 shadowAdjustedOffset(anchor));
555 } 556 }
556 return Range::create(*anchor.document(), node, shadowAdjustedOffset(anchor), 557 return Range::create(*anchor.document(), node, shadowAdjustedOffset(anchor),
557 shadowAdjustedNode(focus), shadowAdjustedOffset(focus)); 558 shadowAdjustedNode(focus), shadowAdjustedOffset(focus));
558 } 559 }
559 560
560 bool DOMSelection::isSelectionOfDocument() const { 561 bool DOMSelection::isSelectionOfDocument() const {
561 return m_treeScope == m_treeScope->document(); 562 return m_treeScope == m_treeScope->document();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 m_treeScope->document().addConsoleMessage( 819 m_treeScope->document().addConsoleMessage(
819 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 820 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
820 } 821 }
821 822
822 DEFINE_TRACE(DOMSelection) { 823 DEFINE_TRACE(DOMSelection) {
823 visitor->trace(m_treeScope); 824 visitor->trace(m_treeScope);
824 ContextClient::trace(visitor); 825 ContextClient::trace(visitor);
825 } 826 }
826 827
827 } // namespace blink 828 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698