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

Side by Side Diff: Source/core/editing/FrameSelection.cpp

Issue 252783002: Make Range.detach() a no-op (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 7 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
« no previous file with comments | « Source/core/editing/FormatBlockCommand.cpp ('k') | Source/core/editing/SpellChecker.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, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 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 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, SetSelec tionOptions options) 1402 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, SetSelec tionOptions options)
1403 { 1403 {
1404 if (!range || !range->startContainer() || !range->endContainer()) 1404 if (!range || !range->startContainer() || !range->endContainer())
1405 return false; 1405 return false;
1406 ASSERT(range->startContainer()->document() == range->endContainer()->documen t()); 1406 ASSERT(range->startContainer()->document() == range->endContainer()->documen t());
1407 1407
1408 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 1408 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1409 1409
1410 // Non-collapsed ranges are not allowed to start at the end of a line that i s wrapped, 1410 // Non-collapsed ranges are not allowed to start at the end of a line that i s wrapped,
1411 // they start at the beginning of the next line instead 1411 // they start at the beginning of the next line instead
1412 TrackExceptionState exceptionState;
1413 bool collapsed = range->collapsed(exceptionState);
1414 if (exceptionState.hadException())
1415 return false;
1416
1417 m_logicalRange = nullptr; 1412 m_logicalRange = nullptr;
1418 stopObservingVisibleSelectionChangeIfNecessary(); 1413 stopObservingVisibleSelectionChangeIfNecessary();
1419 1414
1420 // FIXME: Can we provide extentAffinity? 1415 // FIXME: Can we provide extentAffinity?
1421 VisiblePosition visibleStart(range->startPosition(), collapsed ? affinity : DOWNSTREAM); 1416 VisiblePosition visibleStart(range->startPosition(), range->collapsed() ? af finity : DOWNSTREAM);
1422 VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY); 1417 VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY);
1423 setSelection(VisibleSelection(visibleStart, visibleEnd), options); 1418 setSelection(VisibleSelection(visibleStart, visibleEnd), options);
1424 1419
1425 m_logicalRange = range->cloneRange(ASSERT_NO_EXCEPTION); 1420 m_logicalRange = range->cloneRange();
1426 startObservingVisibleSelectionChange(); 1421 startObservingVisibleSelectionChange();
1427 1422
1428 return true; 1423 return true;
1429 } 1424 }
1430 1425
1431 PassRefPtrWillBeRawPtr<Range> FrameSelection::firstRange() const 1426 PassRefPtrWillBeRawPtr<Range> FrameSelection::firstRange() const
1432 { 1427 {
1433 if (m_logicalRange) 1428 if (m_logicalRange)
1434 return m_logicalRange->cloneRange(ASSERT_NO_EXCEPTION); 1429 return m_logicalRange->cloneRange();
1435 return m_selection.firstRange(); 1430 return m_selection.firstRange();
1436 } 1431 }
1437 1432
1438 bool FrameSelection::isInPasswordField() const 1433 bool FrameSelection::isInPasswordField() const
1439 { 1434 {
1440 HTMLTextFormControlElement* textControl = enclosingTextFormControl(start()); 1435 HTMLTextFormControlElement* textControl = enclosingTextFormControl(start());
1441 return isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->i sPasswordField(); 1436 return isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->i sPasswordField();
1442 } 1437 }
1443 1438
1444 void FrameSelection::notifyAccessibilityForSelectionChange() 1439 void FrameSelection::notifyAccessibilityForSelectionChange()
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 sel.showTreeForThis(); 1872 sel.showTreeForThis();
1878 } 1873 }
1879 1874
1880 void showTree(const WebCore::FrameSelection* sel) 1875 void showTree(const WebCore::FrameSelection* sel)
1881 { 1876 {
1882 if (sel) 1877 if (sel)
1883 sel->showTreeForThis(); 1878 sel->showTreeForThis();
1884 } 1879 }
1885 1880
1886 #endif 1881 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/FormatBlockCommand.cpp ('k') | Source/core/editing/SpellChecker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698