| 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 28 matching lines...) Expand all Loading... |
| 39 #include "RuntimeEnabledFeatures.h" | 39 #include "RuntimeEnabledFeatures.h" |
| 40 #include "SkBitmap.h" | 40 #include "SkBitmap.h" |
| 41 #include "SkCanvas.h" | 41 #include "SkCanvas.h" |
| 42 #include "URLTestHelpers.h" | 42 #include "URLTestHelpers.h" |
| 43 #include "UserAgentStyleSheets.h" | 43 #include "UserAgentStyleSheets.h" |
| 44 #include "WebDataSource.h" | 44 #include "WebDataSource.h" |
| 45 #include "WebDocument.h" | 45 #include "WebDocument.h" |
| 46 #include "WebFindOptions.h" | 46 #include "WebFindOptions.h" |
| 47 #include "WebFormElement.h" | 47 #include "WebFormElement.h" |
| 48 #include "WebFrameClient.h" | 48 #include "WebFrameClient.h" |
| 49 #include "WebFrameImpl.h" | |
| 50 #include "WebHistoryItem.h" | 49 #include "WebHistoryItem.h" |
| 50 #include "WebLocalFrameImpl.h" |
| 51 #include "WebRange.h" | 51 #include "WebRange.h" |
| 52 #include "WebScriptSource.h" | 52 #include "WebScriptSource.h" |
| 53 #include "WebSearchableFormData.h" | 53 #include "WebSearchableFormData.h" |
| 54 #include "WebSecurityOrigin.h" | 54 #include "WebSecurityOrigin.h" |
| 55 #include "WebSecurityPolicy.h" | 55 #include "WebSecurityPolicy.h" |
| 56 #include "WebSettings.h" | 56 #include "WebSettings.h" |
| 57 #include "WebSpellCheckClient.h" | 57 #include "WebSpellCheckClient.h" |
| 58 #include "WebTextCheckingCompletion.h" | 58 #include "WebTextCheckingCompletion.h" |
| 59 #include "WebTextCheckingResult.h" | 59 #include "WebTextCheckingResult.h" |
| 60 #include "WebViewClient.h" | 60 #include "WebViewClient.h" |
| (...skipping 3120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3181 webViewHelper.webView()->layout(); | 3181 webViewHelper.webView()->layout(); |
| 3182 runPendingTasks(); | 3182 runPendingTasks(); |
| 3183 | 3183 |
| 3184 // Note that the 'result 19' in the <select> element is not expected to prod
uce a match. | 3184 // Note that the 'result 19' in the <select> element is not expected to prod
uce a match. |
| 3185 static const char* kFindString = "result"; | 3185 static const char* kFindString = "result"; |
| 3186 static const int kFindIdentifier = 12345; | 3186 static const int kFindIdentifier = 12345; |
| 3187 static const int kNumResults = 19; | 3187 static const int kNumResults = 19; |
| 3188 | 3188 |
| 3189 WebFindOptions options; | 3189 WebFindOptions options; |
| 3190 WebString searchText = WebString::fromUTF8(kFindString); | 3190 WebString searchText = WebString::fromUTF8(kFindString); |
| 3191 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame(
)); | 3191 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3192 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3192 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3193 | 3193 |
| 3194 mainFrame->resetMatchCount(); | 3194 mainFrame->resetMatchCount(); |
| 3195 | 3195 |
| 3196 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3196 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3197 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3197 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3198 | 3198 |
| 3199 runPendingTasks(); | 3199 runPendingTasks(); |
| 3200 EXPECT_TRUE(client.findResultsAreReady()); | 3200 EXPECT_TRUE(client.findResultsAreReady()); |
| 3201 | 3201 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3298 webViewHelper.webView()->resize(WebSize(640, 480)); | 3298 webViewHelper.webView()->resize(WebSize(640, 480)); |
| 3299 webViewHelper.webView()->layout(); | 3299 webViewHelper.webView()->layout(); |
| 3300 runPendingTasks(); | 3300 runPendingTasks(); |
| 3301 | 3301 |
| 3302 static const char* kFindString = "hello"; | 3302 static const char* kFindString = "hello"; |
| 3303 static const int kFindIdentifier = 12345; | 3303 static const int kFindIdentifier = 12345; |
| 3304 static const int kNumResults = 1; | 3304 static const int kNumResults = 1; |
| 3305 | 3305 |
| 3306 WebFindOptions options; | 3306 WebFindOptions options; |
| 3307 WebString searchText = WebString::fromUTF8(kFindString); | 3307 WebString searchText = WebString::fromUTF8(kFindString); |
| 3308 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame(
)); | 3308 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3309 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3309 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3310 | 3310 |
| 3311 mainFrame->resetMatchCount(); | 3311 mainFrame->resetMatchCount(); |
| 3312 | 3312 |
| 3313 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3313 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3314 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3314 frame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3315 | 3315 |
| 3316 runPendingTasks(); | 3316 runPendingTasks(); |
| 3317 EXPECT_TRUE(client.findResultsAreReady()); | 3317 EXPECT_TRUE(client.findResultsAreReady()); |
| 3318 EXPECT_EQ(kNumResults, client.count()); | 3318 EXPECT_EQ(kNumResults, client.count()); |
| 3319 } | 3319 } |
| 3320 | 3320 |
| 3321 TEST_F(WebFrameTest, FindOnDetachedFrame) | 3321 TEST_F(WebFrameTest, FindOnDetachedFrame) |
| 3322 { | 3322 { |
| 3323 registerMockedHttpURLLoad("find_in_page.html"); | 3323 registerMockedHttpURLLoad("find_in_page.html"); |
| 3324 registerMockedHttpURLLoad("find_in_page_frame.html"); | 3324 registerMockedHttpURLLoad("find_in_page_frame.html"); |
| 3325 | 3325 |
| 3326 FindUpdateWebFrameClient client; | 3326 FindUpdateWebFrameClient client; |
| 3327 FrameTestHelpers::WebViewHelper webViewHelper; | 3327 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3328 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3328 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
| 3329 webViewHelper.webView()->resize(WebSize(640, 480)); | 3329 webViewHelper.webView()->resize(WebSize(640, 480)); |
| 3330 webViewHelper.webView()->layout(); | 3330 webViewHelper.webView()->layout(); |
| 3331 runPendingTasks(); | 3331 runPendingTasks(); |
| 3332 | 3332 |
| 3333 static const char* kFindString = "result"; | 3333 static const char* kFindString = "result"; |
| 3334 static const int kFindIdentifier = 12345; | 3334 static const int kFindIdentifier = 12345; |
| 3335 | 3335 |
| 3336 WebFindOptions options; | 3336 WebFindOptions options; |
| 3337 WebString searchText = WebString::fromUTF8(kFindString); | 3337 WebString searchText = WebString::fromUTF8(kFindString); |
| 3338 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame(
)); | 3338 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3339 RefPtr<WebFrameImpl> secondFrame = toWebFrameImpl(mainFrame->traverseNext(fa
lse)); | 3339 RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->trave
rseNext(false)); |
| 3340 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3340 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); |
| 3341 | 3341 |
| 3342 // Detach the frame before finding. | 3342 // Detach the frame before finding. |
| 3343 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3343 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
| 3344 | 3344 |
| 3345 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3345 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3346 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); | 3346 EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false,
0)); |
| 3347 | 3347 |
| 3348 runPendingTasks(); | 3348 runPendingTasks(); |
| 3349 EXPECT_FALSE(client.findResultsAreReady()); | 3349 EXPECT_FALSE(client.findResultsAreReady()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3369 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3369 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
| 3370 webViewHelper.webView()->resize(WebSize(640, 480)); | 3370 webViewHelper.webView()->resize(WebSize(640, 480)); |
| 3371 webViewHelper.webView()->layout(); | 3371 webViewHelper.webView()->layout(); |
| 3372 runPendingTasks(); | 3372 runPendingTasks(); |
| 3373 | 3373 |
| 3374 static const char* kFindString = "result"; | 3374 static const char* kFindString = "result"; |
| 3375 static const int kFindIdentifier = 12345; | 3375 static const int kFindIdentifier = 12345; |
| 3376 | 3376 |
| 3377 WebFindOptions options; | 3377 WebFindOptions options; |
| 3378 WebString searchText = WebString::fromUTF8(kFindString); | 3378 WebString searchText = WebString::fromUTF8(kFindString); |
| 3379 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame(
)); | 3379 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3380 WebFrameImpl* secondFrame = toWebFrameImpl(mainFrame->traverseNext(false)); | 3380 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
| 3381 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3381 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); |
| 3382 | 3382 |
| 3383 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3383 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3384 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3384 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3385 | 3385 |
| 3386 runPendingTasks(); | 3386 runPendingTasks(); |
| 3387 EXPECT_FALSE(client.findResultsAreReady()); | 3387 EXPECT_FALSE(client.findResultsAreReady()); |
| 3388 | 3388 |
| 3389 // Detach the frame between finding and scoping. | 3389 // Detach the frame between finding and scoping. |
| 3390 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); | 3390 EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3410 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); | 3410 webViewHelper.initializeAndLoad(m_baseURL + "find_in_page.html", true, &clie
nt); |
| 3411 webViewHelper.webView()->resize(WebSize(640, 480)); | 3411 webViewHelper.webView()->resize(WebSize(640, 480)); |
| 3412 webViewHelper.webView()->layout(); | 3412 webViewHelper.webView()->layout(); |
| 3413 runPendingTasks(); | 3413 runPendingTasks(); |
| 3414 | 3414 |
| 3415 static const char* kFindString = "result"; | 3415 static const char* kFindString = "result"; |
| 3416 static const int kFindIdentifier = 12345; | 3416 static const int kFindIdentifier = 12345; |
| 3417 | 3417 |
| 3418 WebFindOptions options; | 3418 WebFindOptions options; |
| 3419 WebString searchText = WebString::fromUTF8(kFindString); | 3419 WebString searchText = WebString::fromUTF8(kFindString); |
| 3420 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame(
)); | 3420 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3421 WebFrameImpl* secondFrame = toWebFrameImpl(mainFrame->traverseNext(false)); | 3421 WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext
(false)); |
| 3422 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); | 3422 RefPtr<WebCore::LocalFrame> holdSecondFrame = secondFrame->frame(); |
| 3423 | 3423 |
| 3424 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) | 3424 for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
| 3425 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; | 3425 EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3426 | 3426 |
| 3427 runPendingTasks(); | 3427 runPendingTasks(); |
| 3428 EXPECT_FALSE(client.findResultsAreReady()); | 3428 EXPECT_FALSE(client.findResultsAreReady()); |
| 3429 | 3429 |
| 3430 mainFrame->resetMatchCount(); | 3430 mainFrame->resetMatchCount(); |
| 3431 | 3431 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3450 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); | 3450 webViewHelper.initializeAndLoad(m_baseURL + "find.html", true, &client); |
| 3451 webViewHelper.webView()->resize(WebSize(640, 480)); | 3451 webViewHelper.webView()->resize(WebSize(640, 480)); |
| 3452 webViewHelper.webView()->layout(); | 3452 webViewHelper.webView()->layout(); |
| 3453 runPendingTasks(); | 3453 runPendingTasks(); |
| 3454 | 3454 |
| 3455 static const char* kFindString = "foo"; | 3455 static const char* kFindString = "foo"; |
| 3456 static const int kFindIdentifier = 12345; | 3456 static const int kFindIdentifier = 12345; |
| 3457 | 3457 |
| 3458 WebFindOptions options; | 3458 WebFindOptions options; |
| 3459 WebString searchText = WebString::fromUTF8(kFindString); | 3459 WebString searchText = WebString::fromUTF8(kFindString); |
| 3460 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame(
)); | 3460 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3461 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; | 3461 EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0))
; |
| 3462 | 3462 |
| 3463 mainFrame->resetMatchCount(); | 3463 mainFrame->resetMatchCount(); |
| 3464 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); | 3464 mainFrame->scopeStringMatches(kFindIdentifier, searchText, options, true); |
| 3465 | 3465 |
| 3466 runPendingTasks(); | 3466 runPendingTasks(); |
| 3467 EXPECT_TRUE(client.findResultsAreReady()); | 3467 EXPECT_TRUE(client.findResultsAreReady()); |
| 3468 | 3468 |
| 3469 // Get the tickmarks for the original find request. | 3469 // Get the tickmarks for the original find request. |
| 3470 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); | 3470 WebCore::FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()
->frameView(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3739 return WebCore::VisiblePosition(renderer->positionForPoint(WebCore::LayoutPo
int(x, y))).deepEquivalent().computeOffsetInContainerNode(); | 3739 return WebCore::VisiblePosition(renderer->positionForPoint(WebCore::LayoutPo
int(x, y))).deepEquivalent().computeOffsetInContainerNode(); |
| 3740 } | 3740 } |
| 3741 | 3741 |
| 3742 // positionForPoint returns the wrong values for contenteditable spans. See | 3742 // positionForPoint returns the wrong values for contenteditable spans. See |
| 3743 // http://crbug.com/238334. | 3743 // http://crbug.com/238334. |
| 3744 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) | 3744 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) |
| 3745 { | 3745 { |
| 3746 registerMockedHttpURLLoad("select_range_span_editable.html"); | 3746 registerMockedHttpURLLoad("select_range_span_editable.html"); |
| 3747 FrameTestHelpers::WebViewHelper webViewHelper; | 3747 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3748 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); | 3748 initializeTextSelectionWebView(m_baseURL + "select_range_span_editable.html"
, &webViewHelper); |
| 3749 WebFrameImpl* mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame(
)); | 3749 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->
mainFrame()); |
| 3750 WebCore::RenderObject* renderer = mainFrame->frame()->selection().rootEditab
leElement()->renderer(); | 3750 WebCore::RenderObject* renderer = mainFrame->frame()->selection().rootEditab
leElement()->renderer(); |
| 3751 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 3751 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
| 3752 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 3752 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
| 3753 | 3753 |
| 3754 registerMockedHttpURLLoad("select_range_div_editable.html"); | 3754 registerMockedHttpURLLoad("select_range_div_editable.html"); |
| 3755 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); | 3755 initializeTextSelectionWebView(m_baseURL + "select_range_div_editable.html",
&webViewHelper); |
| 3756 mainFrame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 3756 mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
| 3757 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; | 3757 renderer = mainFrame->frame()->selection().rootEditableElement()->renderer()
; |
| 3758 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); | 3758 EXPECT_EQ(0, computeOffset(renderer, -1, -1)); |
| 3759 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); | 3759 EXPECT_EQ(64, computeOffset(renderer, 1000, 1000)); |
| 3760 } | 3760 } |
| 3761 | 3761 |
| 3762 #if !OS(MACOSX) && !OS(LINUX) | 3762 #if !OS(MACOSX) && !OS(LINUX) |
| 3763 TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) | 3763 TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) |
| 3764 { | 3764 { |
| 3765 registerMockedHttpURLLoad("move_caret.html"); | 3765 registerMockedHttpURLLoad("move_caret.html"); |
| 3766 | 3766 |
| 3767 FrameTestHelpers::WebViewHelper webViewHelper; | 3767 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3768 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); | 3768 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); |
| 3769 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 3769 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 3770 | 3770 |
| 3771 WebRect initialStartRect; | 3771 WebRect initialStartRect; |
| 3772 WebRect initialEndRect; | 3772 WebRect initialEndRect; |
| 3773 WebRect startRect; | 3773 WebRect startRect; |
| 3774 WebRect endRect; | 3774 WebRect endRect; |
| 3775 | 3775 |
| 3776 frame->executeScript(WebScriptSource("selectRange();")); | 3776 frame->executeScript(WebScriptSource("selectRange();")); |
| 3777 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); | 3777 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); |
| 3778 WebPoint movedStart(topLeft(initialStartRect)); | 3778 WebPoint movedStart(topLeft(initialStartRect)); |
| 3779 | 3779 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3799 | 3799 |
| 3800 movedEnd.y -= 80; | 3800 movedEnd.y -= 80; |
| 3801 frame->selectRange(topLeft(initialStartRect), movedEnd); | 3801 frame->selectRange(topLeft(initialStartRect), movedEnd); |
| 3802 webViewHelper.webView()->selectionBounds(startRect, endRect); | 3802 webViewHelper.webView()->selectionBounds(startRect, endRect); |
| 3803 EXPECT_EQ(startRect, initialStartRect); | 3803 EXPECT_EQ(startRect, initialStartRect); |
| 3804 EXPECT_EQ(endRect, initialEndRect); | 3804 EXPECT_EQ(endRect, initialEndRect); |
| 3805 } | 3805 } |
| 3806 | 3806 |
| 3807 TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) | 3807 TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) |
| 3808 { | 3808 { |
| 3809 WebFrameImpl* frame; | 3809 WebLocalFrameImpl* frame; |
| 3810 registerMockedHttpURLLoad("move_caret.html"); | 3810 registerMockedHttpURLLoad("move_caret.html"); |
| 3811 | 3811 |
| 3812 FrameTestHelpers::WebViewHelper webViewHelper; | 3812 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3813 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); | 3813 initializeTextSelectionWebView(m_baseURL + "move_caret.html", &webViewHelper
); |
| 3814 frame = (WebFrameImpl*)webViewHelper.webView()->mainFrame(); | 3814 frame = (WebLocalFrameImpl*)webViewHelper.webView()->mainFrame(); |
| 3815 | 3815 |
| 3816 WebRect initialStartRect; | 3816 WebRect initialStartRect; |
| 3817 WebRect initialEndRect; | 3817 WebRect initialEndRect; |
| 3818 WebRect startRect; | 3818 WebRect startRect; |
| 3819 WebRect endRect; | 3819 WebRect endRect; |
| 3820 | 3820 |
| 3821 frame->executeScript(WebScriptSource("selectCaret();")); | 3821 frame->executeScript(WebScriptSource("selectCaret();")); |
| 3822 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); | 3822 webViewHelper.webView()->selectionBounds(initialStartRect, initialEndRect); |
| 3823 WebPoint moveTo(topLeft(initialStartRect)); | 3823 WebPoint moveTo(topLeft(initialStartRect)); |
| 3824 | 3824 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4201 }; | 4201 }; |
| 4202 | 4202 |
| 4203 TEST_F(WebFrameTest, ReplaceMisspelledRange) | 4203 TEST_F(WebFrameTest, ReplaceMisspelledRange) |
| 4204 { | 4204 { |
| 4205 registerMockedHttpURLLoad("spell.html"); | 4205 registerMockedHttpURLLoad("spell.html"); |
| 4206 FrameTestHelpers::WebViewHelper webViewHelper; | 4206 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4207 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4207 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 4208 SpellCheckClient spellcheck; | 4208 SpellCheckClient spellcheck; |
| 4209 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 4209 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
| 4210 | 4210 |
| 4211 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 4211 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 4212 Document* document = frame->frame()->document(); | 4212 Document* document = frame->frame()->document(); |
| 4213 Element* element = document->getElementById("data"); | 4213 Element* element = document->getElementById("data"); |
| 4214 | 4214 |
| 4215 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); | 4215 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); |
| 4216 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); | 4216 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); |
| 4217 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 4217 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
| 4218 | 4218 |
| 4219 element->focus(); | 4219 element->focus(); |
| 4220 document->execCommand("InsertText", false, "_wellcome_."); | 4220 document->execCommand("InsertText", false, "_wellcome_."); |
| 4221 | 4221 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4232 } | 4232 } |
| 4233 | 4233 |
| 4234 TEST_F(WebFrameTest, RemoveSpellingMarkers) | 4234 TEST_F(WebFrameTest, RemoveSpellingMarkers) |
| 4235 { | 4235 { |
| 4236 registerMockedHttpURLLoad("spell.html"); | 4236 registerMockedHttpURLLoad("spell.html"); |
| 4237 FrameTestHelpers::WebViewHelper webViewHelper; | 4237 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4238 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4238 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 4239 SpellCheckClient spellcheck; | 4239 SpellCheckClient spellcheck; |
| 4240 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 4240 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
| 4241 | 4241 |
| 4242 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 4242 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 4243 Document* document = frame->frame()->document(); | 4243 Document* document = frame->frame()->document(); |
| 4244 Element* element = document->getElementById("data"); | 4244 Element* element = document->getElementById("data"); |
| 4245 | 4245 |
| 4246 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); | 4246 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); |
| 4247 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); | 4247 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); |
| 4248 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 4248 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
| 4249 | 4249 |
| 4250 element->focus(); | 4250 element->focus(); |
| 4251 document->execCommand("InsertText", false, "_wellcome_."); | 4251 document->execCommand("InsertText", false, "_wellcome_."); |
| 4252 | 4252 |
| 4253 frame->removeSpellingMarkers(); | 4253 frame->removeSpellingMarkers(); |
| 4254 | 4254 |
| 4255 const int allTextBeginOffset = 0; | 4255 const int allTextBeginOffset = 0; |
| 4256 const int allTextLength = 11; | 4256 const int allTextLength = 11; |
| 4257 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al
lTextLength)); | 4257 frame->selectRange(WebRange::fromDocumentRange(frame, allTextBeginOffset, al
lTextLength)); |
| 4258 RefPtrWillBeRawPtr<Range> selectionRange = frame->frame()->selection().toNor
malizedRange(); | 4258 RefPtrWillBeRawPtr<Range> selectionRange = frame->frame()->selection().toNor
malizedRange(); |
| 4259 | 4259 |
| 4260 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange.get(), Docum
entMarker::Spelling).size()); | 4260 EXPECT_EQ(0U, document->markers().markersInRange(selectionRange.get(), Docum
entMarker::Spelling).size()); |
| 4261 } | 4261 } |
| 4262 | 4262 |
| 4263 TEST_F(WebFrameTest, MarkerHashIdentifiers) { | 4263 TEST_F(WebFrameTest, MarkerHashIdentifiers) { |
| 4264 registerMockedHttpURLLoad("spell.html"); | 4264 registerMockedHttpURLLoad("spell.html"); |
| 4265 FrameTestHelpers::WebViewHelper webViewHelper; | 4265 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4266 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4266 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 4267 | 4267 |
| 4268 static const uint32_t kHash = 42; | 4268 static const uint32_t kHash = 42; |
| 4269 SpellCheckClient spellcheck(kHash); | 4269 SpellCheckClient spellcheck(kHash); |
| 4270 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 4270 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
| 4271 | 4271 |
| 4272 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 4272 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 4273 Document* document = frame->frame()->document(); | 4273 Document* document = frame->frame()->document(); |
| 4274 Element* element = document->getElementById("data"); | 4274 Element* element = document->getElementById("data"); |
| 4275 | 4275 |
| 4276 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); | 4276 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); |
| 4277 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); | 4277 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); |
| 4278 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 4278 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
| 4279 | 4279 |
| 4280 element->focus(); | 4280 element->focus(); |
| 4281 document->execCommand("InsertText", false, "wellcome."); | 4281 document->execCommand("InsertText", false, "wellcome."); |
| 4282 | 4282 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4337 | 4337 |
| 4338 TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) | 4338 TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) |
| 4339 { | 4339 { |
| 4340 registerMockedHttpURLLoad("spell.html"); | 4340 registerMockedHttpURLLoad("spell.html"); |
| 4341 FrameTestHelpers::WebViewHelper webViewHelper; | 4341 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4342 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4342 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 4343 | 4343 |
| 4344 StubbornSpellCheckClient spellcheck; | 4344 StubbornSpellCheckClient spellcheck; |
| 4345 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 4345 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
| 4346 | 4346 |
| 4347 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 4347 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 4348 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); | 4348 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); |
| 4349 Document* document = frame->frame()->document(); | 4349 Document* document = frame->frame()->document(); |
| 4350 Element* element = document->getElementById("data"); | 4350 Element* element = document->getElementById("data"); |
| 4351 | 4351 |
| 4352 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); | 4352 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); |
| 4353 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); | 4353 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); |
| 4354 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 4354 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
| 4355 | 4355 |
| 4356 element->focus(); | 4356 element->focus(); |
| 4357 document->execCommand("InsertText", false, "wellcome "); | 4357 document->execCommand("InsertText", false, "wellcome "); |
| 4358 webInputElement.setSelectionRange(0, 0); | 4358 webInputElement.setSelectionRange(0, 0); |
| 4359 document->execCommand("InsertText", false, "he"); | 4359 document->execCommand("InsertText", false, "he"); |
| 4360 | 4360 |
| 4361 spellcheck.kick(); | 4361 spellcheck.kick(); |
| 4362 | 4362 |
| 4363 WebVector<uint32_t> documentMarkers; | 4363 WebVector<uint32_t> documentMarkers; |
| 4364 webViewHelper.webView()->spellingMarkers(&documentMarkers); | 4364 webViewHelper.webView()->spellingMarkers(&documentMarkers); |
| 4365 EXPECT_EQ(0U, documentMarkers.size()); | 4365 EXPECT_EQ(0U, documentMarkers.size()); |
| 4366 } | 4366 } |
| 4367 | 4367 |
| 4368 // This test verifies that cancelling spelling request does not cause a | 4368 // This test verifies that cancelling spelling request does not cause a |
| 4369 // write-after-free when there's no spellcheck client set. | 4369 // write-after-free when there's no spellcheck client set. |
| 4370 TEST_F(WebFrameTest, CancelSpellingRequestCrash) | 4370 TEST_F(WebFrameTest, CancelSpellingRequestCrash) |
| 4371 { | 4371 { |
| 4372 registerMockedHttpURLLoad("spell.html"); | 4372 registerMockedHttpURLLoad("spell.html"); |
| 4373 FrameTestHelpers::WebViewHelper webViewHelper; | 4373 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4374 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4374 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 4375 webViewHelper.webView()->setSpellCheckClient(0); | 4375 webViewHelper.webView()->setSpellCheckClient(0); |
| 4376 | 4376 |
| 4377 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 4377 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 4378 Document* document = frame->frame()->document(); | 4378 Document* document = frame->frame()->document(); |
| 4379 Element* element = document->getElementById("data"); | 4379 Element* element = document->getElementById("data"); |
| 4380 | 4380 |
| 4381 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); | 4381 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); |
| 4382 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); | 4382 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); |
| 4383 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 4383 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
| 4384 | 4384 |
| 4385 element->focus(); | 4385 element->focus(); |
| 4386 frame->frame()->editor().replaceSelectionWithText("A", false, false); | 4386 frame->frame()->editor().replaceSelectionWithText("A", false, false); |
| 4387 frame->frame()->spellChecker().cancelCheck(); | 4387 frame->frame()->spellChecker().cancelCheck(); |
| 4388 } | 4388 } |
| 4389 | 4389 |
| 4390 TEST_F(WebFrameTest, SpellcheckResultErasesMarkers) | 4390 TEST_F(WebFrameTest, SpellcheckResultErasesMarkers) |
| 4391 { | 4391 { |
| 4392 registerMockedHttpURLLoad("spell.html"); | 4392 registerMockedHttpURLLoad("spell.html"); |
| 4393 FrameTestHelpers::WebViewHelper webViewHelper; | 4393 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4394 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4394 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 4395 | 4395 |
| 4396 StubbornSpellCheckClient spellcheck; | 4396 StubbornSpellCheckClient spellcheck; |
| 4397 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 4397 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
| 4398 | 4398 |
| 4399 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 4399 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 4400 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); | 4400 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); |
| 4401 Document* document = frame->frame()->document(); | 4401 Document* document = frame->frame()->document(); |
| 4402 Element* element = document->getElementById("data"); | 4402 Element* element = document->getElementById("data"); |
| 4403 | 4403 |
| 4404 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); | 4404 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); |
| 4405 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); | 4405 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); |
| 4406 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 4406 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
| 4407 | 4407 |
| 4408 element->focus(); | 4408 element->focus(); |
| 4409 document->execCommand("InsertText", false, "welcome "); | 4409 document->execCommand("InsertText", false, "welcome "); |
| 4410 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu
mentMarker::Spelling); | 4410 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu
mentMarker::Spelling); |
| 4411 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu
mentMarker::Grammar); | 4411 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu
mentMarker::Grammar); |
| 4412 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu
mentMarker::InvisibleSpellcheck); | 4412 document->markers().addMarker(rangeOfContents(element->toNode()).get(), Docu
mentMarker::InvisibleSpellcheck); |
| 4413 EXPECT_EQ(3U, document->markers().markers().size()); | 4413 EXPECT_EQ(3U, document->markers().markers().size()); |
| 4414 | 4414 |
| 4415 spellcheck.kickNoResults(); | 4415 spellcheck.kickNoResults(); |
| 4416 EXPECT_EQ(0U, document->markers().markers().size()); | 4416 EXPECT_EQ(0U, document->markers().markers().size()); |
| 4417 } | 4417 } |
| 4418 | 4418 |
| 4419 TEST_F(WebFrameTest, SpellcheckResultsSavedInDocument) | 4419 TEST_F(WebFrameTest, SpellcheckResultsSavedInDocument) |
| 4420 { | 4420 { |
| 4421 registerMockedHttpURLLoad("spell.html"); | 4421 registerMockedHttpURLLoad("spell.html"); |
| 4422 FrameTestHelpers::WebViewHelper webViewHelper; | 4422 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4423 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); | 4423 webViewHelper.initializeAndLoad(m_baseURL + "spell.html"); |
| 4424 | 4424 |
| 4425 StubbornSpellCheckClient spellcheck; | 4425 StubbornSpellCheckClient spellcheck; |
| 4426 webViewHelper.webView()->setSpellCheckClient(&spellcheck); | 4426 webViewHelper.webView()->setSpellCheckClient(&spellcheck); |
| 4427 | 4427 |
| 4428 WebFrameImpl* frame = toWebFrameImpl(webViewHelper.webView()->mainFrame()); | 4428 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); |
| 4429 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); | 4429 WebInputElement webInputElement = frame->document().getElementById("data").t
o<WebInputElement>(); |
| 4430 Document* document = frame->frame()->document(); | 4430 Document* document = frame->frame()->document(); |
| 4431 Element* element = document->getElementById("data"); | 4431 Element* element = document->getElementById("data"); |
| 4432 | 4432 |
| 4433 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); | 4433 webViewHelper.webView()->settings()->setAsynchronousSpellCheckingEnabled(tru
e); |
| 4434 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); | 4434 webViewHelper.webView()->settings()->setUnifiedTextCheckerEnabled(true); |
| 4435 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); | 4435 webViewHelper.webView()->settings()->setEditingBehavior(WebSettings::Editing
BehaviorWin); |
| 4436 | 4436 |
| 4437 element->focus(); | 4437 element->focus(); |
| 4438 document->execCommand("InsertText", false, "wellcome "); | 4438 document->execCommand("InsertText", false, "wellcome "); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4619 } | 4619 } |
| 4620 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } | 4620 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } |
| 4621 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } | 4621 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } |
| 4622 | 4622 |
| 4623 // WebFrameClient: | 4623 // WebFrameClient: |
| 4624 virtual void didChangeScrollOffset(WebLocalFrame* frame) OVERRIDE | 4624 virtual void didChangeScrollOffset(WebLocalFrame* frame) OVERRIDE |
| 4625 { | 4625 { |
| 4626 if (frame->parent()) | 4626 if (frame->parent()) |
| 4627 return; | 4627 return; |
| 4628 EXPECT_FALSE(m_didScrollMainFrame); | 4628 EXPECT_FALSE(m_didScrollMainFrame); |
| 4629 WebCore::FrameView* view = toWebFrameImpl(frame)->frameView(); | 4629 WebCore::FrameView* view = toWebLocalFrameImpl(frame)->frameView(); |
| 4630 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect | 4630 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect |
| 4631 // which is called from LocalFrame::createView (before the frame is asso
ciated | 4631 // which is called from LocalFrame::createView (before the frame is asso
ciated |
| 4632 // with the the view). | 4632 // with the the view). |
| 4633 if (view) { | 4633 if (view) { |
| 4634 m_didScrollMainFrame = true; | 4634 m_didScrollMainFrame = true; |
| 4635 m_wasProgrammaticScroll = view->inProgrammaticScroll(); | 4635 m_wasProgrammaticScroll = view->inProgrammaticScroll(); |
| 4636 } | 4636 } |
| 4637 } | 4637 } |
| 4638 private: | 4638 private: |
| 4639 bool m_didScrollMainFrame; | 4639 bool m_didScrollMainFrame; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4673 EXPECT_FALSE(client.wasUserScroll()); | 4673 EXPECT_FALSE(client.wasUserScroll()); |
| 4674 EXPECT_FALSE(client.wasProgrammaticScroll()); | 4674 EXPECT_FALSE(client.wasProgrammaticScroll()); |
| 4675 client.reset(); | 4675 client.reset(); |
| 4676 | 4676 |
| 4677 // Non zero page scale and scroll. | 4677 // Non zero page scale and scroll. |
| 4678 webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(9, 13), 0.6f); | 4678 webViewHelper.webViewImpl()->applyScrollAndScale(WebSize(9, 13), 0.6f); |
| 4679 EXPECT_TRUE(client.wasUserScroll()); | 4679 EXPECT_TRUE(client.wasUserScroll()); |
| 4680 client.reset(); | 4680 client.reset(); |
| 4681 | 4681 |
| 4682 // Programmatic scroll. | 4682 // Programmatic scroll. |
| 4683 WebFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); | 4683 WebLocalFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); |
| 4684 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 4684 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
| 4685 EXPECT_FALSE(client.wasUserScroll()); | 4685 EXPECT_FALSE(client.wasUserScroll()); |
| 4686 EXPECT_TRUE(client.wasProgrammaticScroll()); | 4686 EXPECT_TRUE(client.wasProgrammaticScroll()); |
| 4687 client.reset(); | 4687 client.reset(); |
| 4688 | 4688 |
| 4689 // Programmatic scroll to same offset. No scroll event should be generated. | 4689 // Programmatic scroll to same offset. No scroll event should be generated. |
| 4690 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 4690 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
| 4691 EXPECT_FALSE(client.wasProgrammaticScroll()); | 4691 EXPECT_FALSE(client.wasProgrammaticScroll()); |
| 4692 EXPECT_FALSE(client.wasUserScroll()); | 4692 EXPECT_FALSE(client.wasUserScroll()); |
| 4693 client.reset(); | 4693 client.reset(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4961 { | 4961 { |
| 4962 registerMockedHttpURLLoad("iframe_reload.html"); | 4962 registerMockedHttpURLLoad("iframe_reload.html"); |
| 4963 registerMockedHttpURLLoad("visible_iframe.html"); | 4963 registerMockedHttpURLLoad("visible_iframe.html"); |
| 4964 TestCachePolicyWebFrameClient mainClient; | 4964 TestCachePolicyWebFrameClient mainClient; |
| 4965 TestCachePolicyWebFrameClient childClient; | 4965 TestCachePolicyWebFrameClient childClient; |
| 4966 mainClient.setChildWebFrameClient(&childClient); | 4966 mainClient.setChildWebFrameClient(&childClient); |
| 4967 | 4967 |
| 4968 FrameTestHelpers::WebViewHelper webViewHelper; | 4968 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4969 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 4969 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
| 4970 | 4970 |
| 4971 WebFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 4971 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
| 4972 RefPtr<WebFrameImpl> childFrame = toWebFrameImpl(mainFrame->firstChild()); | 4972 RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); |
| 4973 ASSERT_EQ(childFrame->client(), &childClient); | 4973 ASSERT_EQ(childFrame->client(), &childClient); |
| 4974 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 4974 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
| 4975 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 4975 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
| 4976 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); | 4976 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); |
| 4977 | 4977 |
| 4978 mainFrame->reload(false); | 4978 mainFrame->reload(false); |
| 4979 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 4979 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
| 4980 | 4980 |
| 4981 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 4981 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
| 4982 ASSERT_NE(childFrame, toWebFrameImpl(mainFrame->firstChild())); | 4982 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
| 4983 ASSERT_EQ(toWebFrameImpl(mainFrame->firstChild())->client(), &childClient); | 4983 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); |
| 4984 | 4984 |
| 4985 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 4985 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
| 4986 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 4986 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
| 4987 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; | 4987 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; |
| 4988 } | 4988 } |
| 4989 | 4989 |
| 4990 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { | 4990 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { |
| 4991 public: | 4991 public: |
| 4992 TestSameDocumentWebFrameClient() | 4992 TestSameDocumentWebFrameClient() |
| 4993 : m_frameLoadTypeSameSeen(false) | 4993 : m_frameLoadTypeSameSeen(false) |
| 4994 { | 4994 { |
| 4995 } | 4995 } |
| 4996 | 4996 |
| 4997 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) | 4997 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) |
| 4998 { | 4998 { |
| 4999 if (toWebFrameImpl(frame)->frame()->loader().loadType() == WebCore::Fram
eLoadTypeSame) | 4999 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == WebCore:
:FrameLoadTypeSame) |
| 5000 m_frameLoadTypeSameSeen = true; | 5000 m_frameLoadTypeSameSeen = true; |
| 5001 } | 5001 } |
| 5002 | 5002 |
| 5003 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } | 5003 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } |
| 5004 | 5004 |
| 5005 private: | 5005 private: |
| 5006 bool m_frameLoadTypeSameSeen; | 5006 bool m_frameLoadTypeSameSeen; |
| 5007 }; | 5007 }; |
| 5008 | 5008 |
| 5009 TEST_F(WebFrameTest, NavigateToSame) | 5009 TEST_F(WebFrameTest, NavigateToSame) |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5220 WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); | 5220 WebCore::RenderLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); |
| 5221 ASSERT_TRUE(compositor->scrollLayer()); | 5221 ASSERT_TRUE(compositor->scrollLayer()); |
| 5222 | 5222 |
| 5223 // Verify that the WebLayer is not scrollable initially. | 5223 // Verify that the WebLayer is not scrollable initially. |
| 5224 WebCore::GraphicsLayer* scrollLayer = compositor->scrollLayer(); | 5224 WebCore::GraphicsLayer* scrollLayer = compositor->scrollLayer(); |
| 5225 WebLayer* webScrollLayer = scrollLayer->platformLayer(); | 5225 WebLayer* webScrollLayer = scrollLayer->platformLayer(); |
| 5226 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); | 5226 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
| 5227 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); | 5227 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); |
| 5228 | 5228 |
| 5229 // Call javascript to make the layer scrollable, and verify it. | 5229 // Call javascript to make the layer scrollable, and verify it. |
| 5230 WebFrameImpl* frame = (WebFrameImpl*)webViewHelper.webView()->mainFrame(); | 5230 WebLocalFrameImpl* frame = (WebLocalFrameImpl*)webViewHelper.webView()->main
Frame(); |
| 5231 frame->executeScript(WebScriptSource("allowScroll();")); | 5231 frame->executeScript(WebScriptSource("allowScroll();")); |
| 5232 webViewHelper.webView()->layout(); | 5232 webViewHelper.webView()->layout(); |
| 5233 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); | 5233 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
| 5234 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); | 5234 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
| 5235 } | 5235 } |
| 5236 | 5236 |
| 5237 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. | 5237 // Test that currentHistoryItem reflects the current page, not the provisional l
oad. |
| 5238 TEST_F(WebFrameTest, CurrentHistoryItem) | 5238 TEST_F(WebFrameTest, CurrentHistoryItem) |
| 5239 { | 5239 { |
| 5240 registerMockedHttpURLLoad("fixed_layout.html"); | 5240 registerMockedHttpURLLoad("fixed_layout.html"); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5293 { | 5293 { |
| 5294 UseMockScrollbarSettings mockScrollbarSettings; | 5294 UseMockScrollbarSettings mockScrollbarSettings; |
| 5295 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); | 5295 registerMockedHttpURLLoad("fixed-position-in-fixed-viewport.html"); |
| 5296 FrameTestHelpers::WebViewHelper webViewHelper; | 5296 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5297 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor
t.html", true, 0, 0, enableViewportSettings); | 5297 webViewHelper.initializeAndLoad(m_baseURL + "fixed-position-in-fixed-viewpor
t.html", true, 0, 0, enableViewportSettings); |
| 5298 | 5298 |
| 5299 WebView* webView = webViewHelper.webView(); | 5299 WebView* webView = webViewHelper.webView(); |
| 5300 webView->resize(WebSize(100, 100)); | 5300 webView->resize(WebSize(100, 100)); |
| 5301 webView->layout(); | 5301 webView->layout(); |
| 5302 | 5302 |
| 5303 Document* document = toWebFrameImpl(webView->mainFrame())->frame()->document
(); | 5303 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc
ument(); |
| 5304 Element* bottomFixed = document->getElementById("bottom-fixed"); | 5304 Element* bottomFixed = document->getElementById("bottom-fixed"); |
| 5305 Element* topBottomFixed = document->getElementById("top-bottom-fixed"); | 5305 Element* topBottomFixed = document->getElementById("top-bottom-fixed"); |
| 5306 Element* rightFixed = document->getElementById("right-fixed"); | 5306 Element* rightFixed = document->getElementById("right-fixed"); |
| 5307 Element* leftRightFixed = document->getElementById("left-right-fixed"); | 5307 Element* leftRightFixed = document->getElementById("left-right-fixed"); |
| 5308 | 5308 |
| 5309 webView->resize(WebSize(100, 200)); | 5309 webView->resize(WebSize(100, 200)); |
| 5310 webView->layout(); | 5310 webView->layout(); |
| 5311 EXPECT_EQ(200, bottomFixed->offsetTop() + bottomFixed->offsetHeight()); | 5311 EXPECT_EQ(200, bottomFixed->offsetTop() + bottomFixed->offsetHeight()); |
| 5312 EXPECT_EQ(200, topBottomFixed->offsetHeight()); | 5312 EXPECT_EQ(200, topBottomFixed->offsetHeight()); |
| 5313 | 5313 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5343 { | 5343 { |
| 5344 FakeCompositingWebViewClient client; | 5344 FakeCompositingWebViewClient client; |
| 5345 registerMockedHttpURLLoad("fullscreen_div.html"); | 5345 registerMockedHttpURLLoad("fullscreen_div.html"); |
| 5346 FrameTestHelpers::WebViewHelper webViewHelper; | 5346 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5347 int viewportWidth = 640; | 5347 int viewportWidth = 640; |
| 5348 int viewportHeight = 480; | 5348 int viewportHeight = 480; |
| 5349 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); | 5349 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full
screen_div.html", true, 0, &client, &configueCompositingWebView); |
| 5350 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); | 5350 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| 5351 webViewImpl->layout(); | 5351 webViewImpl->layout(); |
| 5352 | 5352 |
| 5353 Document* document = toWebFrameImpl(webViewImpl->mainFrame())->frame()->docu
ment(); | 5353 Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()-
>document(); |
| 5354 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); | 5354 WebCore::UserGestureIndicator gesture(WebCore::DefinitelyProcessingUserGestu
re); |
| 5355 Element* divFullscreen = document->getElementById("div1"); | 5355 Element* divFullscreen = document->getElementById("div1"); |
| 5356 divFullscreen->webkitRequestFullscreen(); | 5356 divFullscreen->webkitRequestFullscreen(); |
| 5357 webViewImpl->willEnterFullScreen(); | 5357 webViewImpl->willEnterFullScreen(); |
| 5358 webViewImpl->didEnterFullScreen(); | 5358 webViewImpl->didEnterFullScreen(); |
| 5359 webViewImpl->layout(); | 5359 webViewImpl->layout(); |
| 5360 | 5360 |
| 5361 // Verify that the main frame is not scrollable. | 5361 // Verify that the main frame is not scrollable. |
| 5362 ASSERT_TRUE(WebCore::FullscreenElementStack::isFullScreen(*document)); | 5362 ASSERT_TRUE(WebCore::FullscreenElementStack::isFullScreen(*document)); |
| 5363 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); | 5363 WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platfor
mLayer(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5375 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) | 5375 TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) |
| 5376 { | 5376 { |
| 5377 registerMockedHttpURLLoad("percent-height-descendants.html"); | 5377 registerMockedHttpURLLoad("percent-height-descendants.html"); |
| 5378 FrameTestHelpers::WebViewHelper webViewHelper; | 5378 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5379 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); | 5379 webViewHelper.initializeAndLoad(m_baseURL + "percent-height-descendants.html
"); |
| 5380 | 5380 |
| 5381 WebView* webView = webViewHelper.webView(); | 5381 WebView* webView = webViewHelper.webView(); |
| 5382 webView->resize(WebSize(800, 800)); | 5382 webView->resize(WebSize(800, 800)); |
| 5383 webView->layout(); | 5383 webView->layout(); |
| 5384 | 5384 |
| 5385 Document* document = toWebFrameImpl(webView->mainFrame())->frame()->document
(); | 5385 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc
ument(); |
| 5386 WebCore::RenderBlock* container = WebCore::toRenderBlock(document->getElemen
tById("container")->renderer()); | 5386 WebCore::RenderBlock* container = WebCore::toRenderBlock(document->getElemen
tById("container")->renderer()); |
| 5387 WebCore::RenderBox* percentHeightInAnonymous = WebCore::toRenderBox(document
->getElementById("percent-height-in-anonymous")->renderer()); | 5387 WebCore::RenderBox* percentHeightInAnonymous = WebCore::toRenderBox(document
->getElementById("percent-height-in-anonymous")->renderer()); |
| 5388 WebCore::RenderBox* percentHeightDirectChild = WebCore::toRenderBox(document
->getElementById("percent-height-direct-child")->renderer()); | 5388 WebCore::RenderBox* percentHeightDirectChild = WebCore::toRenderBox(document
->getElementById("percent-height-direct-child")->renderer()); |
| 5389 | 5389 |
| 5390 EXPECT_TRUE(WebCore::RenderBlock::hasPercentHeightDescendant(percentHeightIn
Anonymous)); | 5390 EXPECT_TRUE(WebCore::RenderBlock::hasPercentHeightDescendant(percentHeightIn
Anonymous)); |
| 5391 EXPECT_TRUE(WebCore::RenderBlock::hasPercentHeightDescendant(percentHeightDi
rectChild)); | 5391 EXPECT_TRUE(WebCore::RenderBlock::hasPercentHeightDescendant(percentHeightDi
rectChild)); |
| 5392 | 5392 |
| 5393 ASSERT_TRUE(container->percentHeightDescendants()); | 5393 ASSERT_TRUE(container->percentHeightDescendants()); |
| 5394 ASSERT_TRUE(container->hasPercentHeightDescendants()); | 5394 ASSERT_TRUE(container->hasPercentHeightDescendants()); |
| 5395 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); | 5395 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); |
| 5396 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); | 5396 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); |
| 5397 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); | 5397 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); |
| 5398 | 5398 |
| 5399 WebCore::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingB
lock(); | 5399 WebCore::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingB
lock(); |
| 5400 EXPECT_TRUE(anonymousBlock->isAnonymous()); | 5400 EXPECT_TRUE(anonymousBlock->isAnonymous()); |
| 5401 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); | 5401 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); |
| 5402 } | 5402 } |
| 5403 | 5403 |
| 5404 } // namespace | 5404 } // namespace |
| OLD | NEW |