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

Side by Side Diff: webkit/glue/webframe_impl.cc

Issue 20028: Fix a crash where we would try to add a DocumentMarker with a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 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 | « no previous file | no next file » | 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2006 Apple Computer, 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 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 for (; !markedText.atEnd(); markedText.advance()) { 950 for (; !markedText.atEnd(); markedText.advance()) {
951 RefPtr<Range> textPiece = markedText.range(); 951 RefPtr<Range> textPiece = markedText.range();
952 int exception = 0; 952 int exception = 0;
953 953
954 WebCore::DocumentMarker marker = { 954 WebCore::DocumentMarker marker = {
955 WebCore::DocumentMarker::TextMatch, 955 WebCore::DocumentMarker::TextMatch,
956 textPiece->startOffset(exception), 956 textPiece->startOffset(exception),
957 textPiece->endOffset(exception), 957 textPiece->endOffset(exception),
958 "" }; 958 "" };
959 959
960 // Find the node to add a marker to and add it. 960 if (marker.endOffset > marker.startOffset) {
961 Node* node = textPiece->startContainer(exception); 961 // Find the node to add a marker to and add it.
962 frame()->document()->addMarker(node, marker); 962 Node* node = textPiece->startContainer(exception);
963 frame()->document()->addMarker(node, marker);
963 964
964 // Rendered rects for markers in WebKit are not populated until each time 965 // Rendered rects for markers in WebKit are not populated until each time
965 // the markers are painted. However, we need it to happen sooner, because 966 // the markers are painted. However, we need it to happen sooner, because
966 // the whole purpose of tickmarks on the scrollbar is to show where matches 967 // the whole purpose of tickmarks on the scrollbar is to show where
967 // off-screen are (that haven't been painted yet). 968 // matches off-screen are (that haven't been painted yet).
968 Vector<WebCore::DocumentMarker> markers = 969 Vector<WebCore::DocumentMarker> markers =
969 frame()->document()->markersForNode(node); 970 frame()->document()->markersForNode(node);
970 frame()->document()->setRenderedRectForMarker( 971 frame()->document()->setRenderedRectForMarker(
971 textPiece->startContainer(exception), 972 textPiece->startContainer(exception),
972 markers[markers.size() - 1], 973 markers[markers.size() - 1],
973 range->boundingBox()); 974 range->boundingBox());
975 }
974 } 976 }
975 } 977 }
976 978
977 void WebFrameImpl::ScopeStringMatches(FindInPageRequest request, 979 void WebFrameImpl::ScopeStringMatches(FindInPageRequest request,
978 bool reset) { 980 bool reset) {
979 if (!ShouldScopeMatches(request)) 981 if (!ShouldScopeMatches(request))
980 return; 982 return;
981 983
982 WebFrameImpl* main_frame_impl = 984 WebFrameImpl* main_frame_impl =
983 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); 985 static_cast<WebFrameImpl*>(GetView()->GetMainFrame());
(...skipping 28 matching lines...) Expand all
1012 RefPtr<Range> search_range(rangeOfContents(frame()->document())); 1014 RefPtr<Range> search_range(rangeOfContents(frame()->document()));
1013 1015
1014 ExceptionCode ec = 0, ec2 = 0; 1016 ExceptionCode ec = 0, ec2 = 0;
1015 if (!reset && resume_scoping_from_range_.get()) { 1017 if (!reset && resume_scoping_from_range_.get()) {
1016 // This is a continuation of a scoping operation that timed out and didn't 1018 // This is a continuation of a scoping operation that timed out and didn't
1017 // complete last time around, so we should start from where we left off. 1019 // complete last time around, so we should start from where we left off.
1018 search_range->setStart(resume_scoping_from_range_->startContainer(), 1020 search_range->setStart(resume_scoping_from_range_->startContainer(),
1019 resume_scoping_from_range_->startOffset(ec2) + 1, 1021 resume_scoping_from_range_->startOffset(ec2) + 1,
1020 ec); 1022 ec);
1021 if (ec != 0 || ec2 != 0) { 1023 if (ec != 0 || ec2 != 0) {
1022 NOTREACHED(); 1024 if (ec2 != 0) // A non-zero |ec| happens when navigating during search.
1025 NOTREACHED();
1023 return; 1026 return;
1024 } 1027 }
1025 } 1028 }
1026 1029
1027 // This timeout controls how long we scope (in ms) before releasing control. 1030 // This timeout controls how long we scope (in ms) before releasing control.
1028 // This value does not prevent us from running for longer than this, but it 1031 // This value does not prevent us from running for longer than this, but it
1029 // is periodically checked to see if we have exceeded our allocated time. 1032 // is periodically checked to see if we have exceeded our allocated time.
1030 static const int kTimeout = 100; // ms 1033 static const int kTimeout = 100; // ms
1031 1034
1032 int match_count = 0; 1035 int match_count = 0;
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 return password_listeners_.get(input_element); 1827 return password_listeners_.get(input_element);
1825 } 1828 }
1826 1829
1827 void WebFrameImpl::ClearPasswordListeners() { 1830 void WebFrameImpl::ClearPasswordListeners() {
1828 for (PasswordListenerMap::iterator iter = password_listeners_.begin(); 1831 for (PasswordListenerMap::iterator iter = password_listeners_.begin();
1829 iter != password_listeners_.end(); ++iter) { 1832 iter != password_listeners_.end(); ++iter) {
1830 delete iter->second; 1833 delete iter->second;
1831 } 1834 }
1832 password_listeners_.clear(); 1835 password_listeners_.clear();
1833 } 1836 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698