Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 void SwapAndVerifyMiddleChildConsistency(const char* const message, | 314 void SwapAndVerifyMiddleChildConsistency(const char* const message, |
| 315 WebFrame* parent, | 315 WebFrame* parent, |
| 316 WebFrame* new_child); | 316 WebFrame* new_child); |
| 317 void SwapAndVerifyLastChildConsistency(const char* const message, | 317 void SwapAndVerifyLastChildConsistency(const char* const message, |
| 318 WebFrame* parent, | 318 WebFrame* parent, |
| 319 WebFrame* new_child); | 319 WebFrame* new_child); |
| 320 void SwapAndVerifySubframeConsistency(const char* const message, | 320 void SwapAndVerifySubframeConsistency(const char* const message, |
| 321 WebFrame* parent, | 321 WebFrame* parent, |
| 322 WebFrame* new_child); | 322 WebFrame* new_child); |
| 323 | 323 |
| 324 int NumMarkersInRange(const Document* document, | |
| 325 const EphemeralRange& range, | |
| 326 DocumentMarker::MarkerTypes marker_types) { | |
| 327 Node* start_container = range.StartPosition().ComputeContainerNode(); | |
| 328 unsigned start_offset = static_cast<unsigned>( | |
| 329 range.StartPosition().ComputeOffsetInContainerNode()); | |
| 330 | |
| 331 Node* end_container = range.EndPosition().ComputeContainerNode(); | |
| 332 unsigned end_offset = static_cast<unsigned>( | |
| 333 range.EndPosition().ComputeOffsetInContainerNode()); | |
| 334 | |
| 335 int node_count = 0; | |
| 336 for (Node& node : range.Nodes()) { | |
| 337 for (DocumentMarker* marker : | |
|
yosin_UTC9
2017/05/11 04:36:02
Can we use std::count_if()[1]?
[1] http://en.cppr
| |
| 338 document->Markers().MarkersFor(&node, marker_types)) { | |
| 339 if (node == start_container && marker->EndOffset() <= start_offset) | |
| 340 continue; | |
| 341 if (node == end_container && marker->StartOffset() >= end_offset) | |
| 342 continue; | |
| 343 ++node_count; | |
| 344 } | |
| 345 } | |
| 346 | |
| 347 return node_count; | |
| 348 } | |
| 349 | |
| 324 std::string base_url_; | 350 std::string base_url_; |
| 325 std::string not_base_url_; | 351 std::string not_base_url_; |
| 326 std::string chrome_url_; | 352 std::string chrome_url_; |
| 327 }; | 353 }; |
| 328 | 354 |
| 329 typedef bool TestParamRootLayerScrolling; | 355 typedef bool TestParamRootLayerScrolling; |
| 330 class ParameterizedWebFrameTest | 356 class ParameterizedWebFrameTest |
| 331 : public ::testing::WithParamInterface<TestParamRootLayerScrolling>, | 357 : public ::testing::WithParamInterface<TestParamRootLayerScrolling>, |
| 332 private ScopedRootLayerScrollingForTest, | 358 private ScopedRootLayerScrollingForTest, |
| 333 public WebFrameTest { | 359 public WebFrameTest { |
| (...skipping 6206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6540 const int kAllTextBeginOffset = 0; | 6566 const int kAllTextBeginOffset = 0; |
| 6541 const int kAllTextLength = 11; | 6567 const int kAllTextLength = 11; |
| 6542 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); | 6568 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); |
| 6543 EphemeralRange selection_range = | 6569 EphemeralRange selection_range = |
| 6544 frame->GetFrame() | 6570 frame->GetFrame() |
| 6545 ->Selection() | 6571 ->Selection() |
| 6546 .ComputeVisibleSelectionInDOMTreeDeprecated() | 6572 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 6547 .ToNormalizedEphemeralRange(); | 6573 .ToNormalizedEphemeralRange(); |
| 6548 | 6574 |
| 6549 EXPECT_EQ(1, textcheck.NumberOfTimesChecked()); | 6575 EXPECT_EQ(1, textcheck.NumberOfTimesChecked()); |
| 6550 EXPECT_EQ(1U, document->Markers() | 6576 EXPECT_EQ(1, NumMarkersInRange(document, selection_range, |
| 6551 .MarkersInRange(selection_range, DocumentMarker::kSpelling) | 6577 DocumentMarker::kSpelling)); |
| 6552 .size()); | |
| 6553 | 6578 |
| 6554 frame->ReplaceMisspelledRange("welcome"); | 6579 frame->ReplaceMisspelledRange("welcome"); |
| 6555 EXPECT_EQ("_welcome_.", | 6580 EXPECT_EQ("_welcome_.", |
| 6556 WebFrameContentDumper::DumpWebViewAsText( | 6581 WebFrameContentDumper::DumpWebViewAsText( |
| 6557 web_view_helper.WebView(), std::numeric_limits<size_t>::max()) | 6582 web_view_helper.WebView(), std::numeric_limits<size_t>::max()) |
| 6558 .Utf8()); | 6583 .Utf8()); |
| 6559 } | 6584 } |
| 6560 | 6585 |
| 6561 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { | 6586 TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) { |
| 6562 RegisterMockedHttpURLLoad("spell.html"); | 6587 RegisterMockedHttpURLLoad("spell.html"); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 6589 | 6614 |
| 6590 const int kAllTextBeginOffset = 0; | 6615 const int kAllTextBeginOffset = 0; |
| 6591 const int kAllTextLength = 11; | 6616 const int kAllTextLength = 11; |
| 6592 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); | 6617 frame->SelectRange(WebRange(kAllTextBeginOffset, kAllTextLength)); |
| 6593 EphemeralRange selection_range = | 6618 EphemeralRange selection_range = |
| 6594 frame->GetFrame() | 6619 frame->GetFrame() |
| 6595 ->Selection() | 6620 ->Selection() |
| 6596 .ComputeVisibleSelectionInDOMTreeDeprecated() | 6621 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 6597 .ToNormalizedEphemeralRange(); | 6622 .ToNormalizedEphemeralRange(); |
| 6598 | 6623 |
| 6599 EXPECT_EQ(0U, document->Markers() | 6624 EXPECT_EQ(0, NumMarkersInRange(document, selection_range, |
| 6600 .MarkersInRange(selection_range, DocumentMarker::kSpelling) | 6625 DocumentMarker::kSpelling)); |
| 6601 .size()); | |
| 6602 } | 6626 } |
| 6603 | 6627 |
| 6604 static void GetSpellingMarkerOffsets(WebVector<unsigned>* offsets, | 6628 static void GetSpellingMarkerOffsets(WebVector<unsigned>* offsets, |
| 6605 const Document& document) { | 6629 const Document& document) { |
| 6606 Vector<unsigned> result; | 6630 Vector<unsigned> result; |
| 6607 const DocumentMarkerVector& document_markers = document.Markers().Markers(); | 6631 const DocumentMarkerVector& document_markers = document.Markers().Markers(); |
| 6608 for (size_t i = 0; i < document_markers.size(); ++i) | 6632 for (size_t i = 0; i < document_markers.size(); ++i) |
| 6609 result.push_back(document_markers[i]->StartOffset()); | 6633 result.push_back(document_markers[i]->StartOffset()); |
| 6610 offsets->Assign(result); | 6634 offsets->Assign(result); |
| 6611 } | 6635 } |
| (...skipping 5431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12043 | 12067 |
| 12044 // Failing the original child frame navigation and trying to render fallback | 12068 // Failing the original child frame navigation and trying to render fallback |
| 12045 // content shouldn't crash. It should return NoLoadInProgress. This is so the | 12069 // content shouldn't crash. It should return NoLoadInProgress. This is so the |
| 12046 // caller won't attempt to replace the correctly empty frame with an error | 12070 // caller won't attempt to replace the correctly empty frame with an error |
| 12047 // page. | 12071 // page. |
| 12048 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, | 12072 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, |
| 12049 child->MaybeRenderFallbackContent(WebURLError())); | 12073 child->MaybeRenderFallbackContent(WebURLError())); |
| 12050 } | 12074 } |
| 12051 | 12075 |
| 12052 } // namespace blink | 12076 } // namespace blink |
| OLD | NEW |