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

Side by Side Diff: Source/web/WebFrameImpl.cpp

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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/web/WebElement.cpp ('k') | Source/web/WebNode.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 if (!frame->view()) 215 if (!frame->view())
216 return; 216 return;
217 217
218 // TextIterator iterates over the visual representation of the DOM. As such, 218 // TextIterator iterates over the visual representation of the DOM. As such,
219 // it requires you to do a layout before using it (otherwise it'll crash). 219 // it requires you to do a layout before using it (otherwise it'll crash).
220 document->updateLayout(); 220 document->updateLayout();
221 221
222 // Select the document body. 222 // Select the document body.
223 RefPtr<Range> range(document->createRange()); 223 RefPtr<Range> range(document->createRange());
224 TrackExceptionState es; 224 TrackExceptionState exceptionState;
225 range->selectNodeContents(document->body(), es); 225 range->selectNodeContents(document->body(), exceptionState);
226 226
227 if (!es.hadException()) { 227 if (!exceptionState.hadException()) {
228 // The text iterator will walk nodes giving us text. This is similar to 228 // The text iterator will walk nodes giving us text. This is similar to
229 // the plainText() function in core/editing/TextIterator.h, but we imple ment the maximum 229 // the plainText() function in core/editing/TextIterator.h, but we imple ment the maximum
230 // size and also copy the results directly into a wstring, avoiding the 230 // size and also copy the results directly into a wstring, avoiding the
231 // string conversion. 231 // string conversion.
232 for (TextIterator it(range.get()); !it.atEnd(); it.advance()) { 232 for (TextIterator it(range.get()); !it.atEnd(); it.advance()) {
233 it.appendTextToStringBuilder(output, 0, maxChars - output.length()); 233 it.appendTextToStringBuilder(output, 0, maxChars - output.length());
234 if (output.length() >= maxChars) 234 if (output.length() >= maxChars)
235 return; // Filled up the buffer. 235 return; // Filled up the buffer.
236 } 236 }
237 } 237 }
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 finishCurrentScopingEffort(identifier); 1594 finishCurrentScopingEffort(identifier);
1595 return; 1595 return;
1596 } 1596 }
1597 1597
1598 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); 1598 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl();
1599 RefPtr<Range> searchRange(rangeOfContents(frame()->document())); 1599 RefPtr<Range> searchRange(rangeOfContents(frame()->document()));
1600 1600
1601 Node* originalEndContainer = searchRange->endContainer(); 1601 Node* originalEndContainer = searchRange->endContainer();
1602 int originalEndOffset = searchRange->endOffset(); 1602 int originalEndOffset = searchRange->endOffset();
1603 1603
1604 TrackExceptionState es, es2; 1604 TrackExceptionState exceptionState, es2;
1605 if (m_resumeScopingFromRange) { 1605 if (m_resumeScopingFromRange) {
1606 // This is a continuation of a scoping operation that timed out and didn 't 1606 // This is a continuation of a scoping operation that timed out and didn 't
1607 // complete last time around, so we should start from where we left off. 1607 // complete last time around, so we should start from where we left off.
1608 searchRange->setStart(m_resumeScopingFromRange->startContainer(), m_resu meScopingFromRange->startOffset(es2) + 1, es); 1608 searchRange->setStart(m_resumeScopingFromRange->startContainer(), m_resu meScopingFromRange->startOffset(es2) + 1, exceptionState);
1609 if (es.hadException() || es2.hadException()) { 1609 if (exceptionState.hadException() || es2.hadException()) {
1610 if (es2.hadException()) // A non-zero |es| happens when navigating d uring search. 1610 if (es2.hadException()) // A non-zero |exceptionState| happens when navigating during search.
1611 ASSERT_NOT_REACHED(); 1611 ASSERT_NOT_REACHED();
1612 return; 1612 return;
1613 } 1613 }
1614 } 1614 }
1615 1615
1616 // This timeout controls how long we scope before releasing control. This 1616 // This timeout controls how long we scope before releasing control. This
1617 // value does not prevent us from running for longer than this, but it is 1617 // value does not prevent us from running for longer than this, but it is
1618 // periodically checked to see if we have exceeded our allocated time. 1618 // periodically checked to see if we have exceeded our allocated time.
1619 const double maxScopingDuration = 0.1; // seconds 1619 const double maxScopingDuration = 0.1; // seconds
1620 1620
1621 int matchCount = 0; 1621 int matchCount = 0;
1622 bool timedOut = false; 1622 bool timedOut = false;
1623 double startTime = currentTime(); 1623 double startTime = currentTime();
1624 do { 1624 do {
1625 // Find next occurrence of the search string. 1625 // Find next occurrence of the search string.
1626 // FIXME: (http://b/1088245) This WebKit operation may run for longer 1626 // FIXME: (http://b/1088245) This WebKit operation may run for longer
1627 // than the timeout value, and is not interruptible as it is currently 1627 // than the timeout value, and is not interruptible as it is currently
1628 // written. We may need to rewrite it with interruptibility in mind, or 1628 // written. We may need to rewrite it with interruptibility in mind, or
1629 // find an alternative. 1629 // find an alternative.
1630 RefPtr<Range> resultRange(findPlainText(searchRange.get(), 1630 RefPtr<Range> resultRange(findPlainText(searchRange.get(),
1631 searchText, 1631 searchText,
1632 options.matchCase ? 0 : CaseInse nsitive)); 1632 options.matchCase ? 0 : CaseInse nsitive));
1633 if (resultRange->collapsed(es)) { 1633 if (resultRange->collapsed(exceptionState)) {
1634 if (!resultRange->startContainer()->isInShadowTree()) 1634 if (!resultRange->startContainer()->isInShadowTree())
1635 break; 1635 break;
1636 1636
1637 searchRange->setStartAfter( 1637 searchRange->setStartAfter(
1638 resultRange->startContainer()->deprecatedShadowAncestorNode(), e s); 1638 resultRange->startContainer()->deprecatedShadowAncestorNode(), e xceptionState);
1639 searchRange->setEnd(originalEndContainer, originalEndOffset, es); 1639 searchRange->setEnd(originalEndContainer, originalEndOffset, excepti onState);
1640 continue; 1640 continue;
1641 } 1641 }
1642 1642
1643 ++matchCount; 1643 ++matchCount;
1644 1644
1645 // Catch a special case where Find found something but doesn't know what 1645 // Catch a special case where Find found something but doesn't know what
1646 // the bounding box for it is. In this case we set the first match we fi nd 1646 // the bounding box for it is. In this case we set the first match we fi nd
1647 // as the active rect. 1647 // as the active rect.
1648 IntRect resultBounds = resultRange->boundingBox(); 1648 IntRect resultBounds = resultRange->boundingBox();
1649 IntRect activeSelectionRect; 1649 IntRect activeSelectionRect;
(...skipping 24 matching lines...) Expand all
1674 } 1674 }
1675 1675
1676 addMarker(resultRange.get(), foundActiveMatch); 1676 addMarker(resultRange.get(), foundActiveMatch);
1677 1677
1678 m_findMatchesCache.append(FindMatch(resultRange.get(), m_lastMatchCount + matchCount)); 1678 m_findMatchesCache.append(FindMatch(resultRange.get(), m_lastMatchCount + matchCount));
1679 1679
1680 // Set the new start for the search range to be the end of the previous 1680 // Set the new start for the search range to be the end of the previous
1681 // result range. There is no need to use a VisiblePosition here, 1681 // result range. There is no need to use a VisiblePosition here,
1682 // since findPlainText will use a TextIterator to go over the visible 1682 // since findPlainText will use a TextIterator to go over the visible
1683 // text nodes. 1683 // text nodes.
1684 searchRange->setStart(resultRange->endContainer(es), resultRange->endOff set(es), es); 1684 searchRange->setStart(resultRange->endContainer(exceptionState), resultR ange->endOffset(exceptionState), exceptionState);
1685 1685
1686 Node* shadowTreeRoot = searchRange->shadowRoot(); 1686 Node* shadowTreeRoot = searchRange->shadowRoot();
1687 if (searchRange->collapsed(es) && shadowTreeRoot) 1687 if (searchRange->collapsed(exceptionState) && shadowTreeRoot)
1688 searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount() , es); 1688 searchRange->setEnd(shadowTreeRoot, shadowTreeRoot->childNodeCount() , exceptionState);
1689 1689
1690 m_resumeScopingFromRange = resultRange; 1690 m_resumeScopingFromRange = resultRange;
1691 timedOut = (currentTime() - startTime) >= maxScopingDuration; 1691 timedOut = (currentTime() - startTime) >= maxScopingDuration;
1692 } while (!timedOut); 1692 } while (!timedOut);
1693 1693
1694 // Remember what we search for last time, so we can skip searching if more 1694 // Remember what we search for last time, so we can skip searching if more
1695 // letters are added to the search string (and last outcome was 0). 1695 // letters are added to the search string (and last outcome was 0).
1696 m_lastSearchString = searchText; 1696 m_lastSearchString = searchText;
1697 1697
1698 if (matchCount > 0) { 1698 if (matchCount > 0) {
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 2517
2518 // There is a possibility that the frame being detached was the only 2518 // There is a possibility that the frame being detached was the only
2519 // pending one. We need to make sure final replies can be sent. 2519 // pending one. We need to make sure final replies can be sent.
2520 flushCurrentScopingEffort(m_findRequestIdentifier); 2520 flushCurrentScopingEffort(m_findRequestIdentifier);
2521 2521
2522 cancelPendingScopingEffort(); 2522 cancelPendingScopingEffort();
2523 } 2523 }
2524 } 2524 }
2525 2525
2526 } // namespace blink 2526 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebElement.cpp ('k') | Source/web/WebNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698