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

Side by Side Diff: Source/core/page/DOMSelection.cpp

Issue 23467007: Have Range constructor take a Document reference in argument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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) 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute( "getRangeAt", "Selection", String::number(index) + " is not a valid index.")); 374 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute( "getRangeAt", "Selection", String::number(index) + " is not a valid index."));
375 return 0; 375 return 0;
376 } 376 }
377 377
378 // If you're hitting this, you've added broken multi-range selection support 378 // If you're hitting this, you've added broken multi-range selection support
379 ASSERT(rangeCount() == 1); 379 ASSERT(rangeCount() == 1);
380 380
381 if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { 381 if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) {
382 ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree( ); 382 ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree( );
383 int offset = shadowAncestor->nodeIndex(); 383 int offset = shadowAncestor->nodeIndex();
384 return Range::create(&shadowAncestor->document(), container, offset, con tainer, offset); 384 return Range::create(shadowAncestor->document(), container, offset, cont ainer, offset);
385 } 385 }
386 386
387 const VisibleSelection& selection = m_frame->selection().selection(); 387 const VisibleSelection& selection = m_frame->selection().selection();
388 return selection.firstRange(); 388 return selection.firstRange();
389 } 389 }
390 390
391 void DOMSelection::removeAllRanges() 391 void DOMSelection::removeAllRanges()
392 { 392 {
393 if (!m_frame) 393 if (!m_frame)
394 return; 394 return;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 544
545 bool DOMSelection::isValidForPosition(Node* node) const 545 bool DOMSelection::isValidForPosition(Node* node) const
546 { 546 {
547 ASSERT(m_frame); 547 ASSERT(m_frame);
548 if (!node) 548 if (!node)
549 return true; 549 return true;
550 return &node->document() == m_frame->document(); 550 return &node->document() == m_frame->document();
551 } 551 }
552 552
553 } // namespace WebCore 553 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698