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

Side by Side Diff: third_party/WebKit/Source/core/dom/Range.cpp

Issue 2747113003: Let Range::expand not crash when Range's start node is not connected to document. (Closed)
Patch Set: Created 3 years, 9 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/dom/RangeTest.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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
5 * (C) 2001 Peter Kelly (pmk@post.com) 5 * (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 DCHECK_EQ(oldNode.document(), m_ownerDocument); 1637 DCHECK_EQ(oldNode.document(), m_ownerDocument);
1638 DCHECK(oldNode.parentNode()); 1638 DCHECK(oldNode.parentNode());
1639 DCHECK(oldNode.nextSibling()); 1639 DCHECK(oldNode.nextSibling());
1640 DCHECK(oldNode.nextSibling()->isTextNode()); 1640 DCHECK(oldNode.nextSibling()->isTextNode());
1641 boundaryTextNodeSplit(m_start, oldNode); 1641 boundaryTextNodeSplit(m_start, oldNode);
1642 boundaryTextNodeSplit(m_end, oldNode); 1642 boundaryTextNodeSplit(m_end, oldNode);
1643 DCHECK(boundaryPointsValid()); 1643 DCHECK(boundaryPointsValid());
1644 } 1644 }
1645 1645
1646 void Range::expand(const String& unit, ExceptionState& exceptionState) { 1646 void Range::expand(const String& unit, ExceptionState& exceptionState) {
1647 if (!startPosition().isConnected() || !endPosition().isConnected())
1648 return;
1647 m_ownerDocument->updateStyleAndLayoutIgnorePendingStylesheets(); 1649 m_ownerDocument->updateStyleAndLayoutIgnorePendingStylesheets();
1648
1649 VisiblePosition start = createVisiblePosition(startPosition()); 1650 VisiblePosition start = createVisiblePosition(startPosition());
1650 VisiblePosition end = createVisiblePosition(endPosition()); 1651 VisiblePosition end = createVisiblePosition(endPosition());
1651 if (unit == "word") { 1652 if (unit == "word") {
1652 start = startOfWord(start); 1653 start = startOfWord(start);
1653 end = endOfWord(end); 1654 end = endOfWord(end);
1654 } else if (unit == "sentence") { 1655 } else if (unit == "sentence") {
1655 start = startOfSentence(start); 1656 start = startOfSentence(start);
1656 end = endOfSentence(end); 1657 end = endOfSentence(end);
1657 } else if (unit == "block") { 1658 } else if (unit == "block") {
1658 start = startOfParagraph(start); 1659 start = startOfParagraph(start);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 .data() 1802 .data()
1802 << "start offset: " << range->startOffset() 1803 << "start offset: " << range->startOffset()
1803 << ", end offset: " << range->endOffset(); 1804 << ", end offset: " << range->endOffset();
1804 } else { 1805 } else {
1805 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " 1806 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are "
1806 "invalid."; 1807 "invalid.";
1807 } 1808 }
1808 } 1809 }
1809 1810
1810 #endif 1811 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/RangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698