| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 3466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3477 webView->settings()->setDefaultFontSize(12); | 3477 webView->settings()->setDefaultFontSize(12); |
| 3478 webView->resize(WebSize(400, 400)); | 3478 webView->resize(WebSize(400, 400)); |
| 3479 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3479 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3480 FrameView* frameView = frame->frame()->view(); | 3480 FrameView* frameView = frame->frame()->view(); |
| 3481 | 3481 |
| 3482 WebPoint baselinePoint; | 3482 WebPoint baselinePoint; |
| 3483 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr
ame, 10, 3, &baselinePoint); | 3483 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr
ame, 10, 3, &baselinePoint); |
| 3484 ASSERT_TRUE(!!result); | 3484 ASSERT_TRUE(!!result); |
| 3485 | 3485 |
| 3486 WebPoint point(baselinePoint.x, frameView->height() - baselinePoint.y); | 3486 WebPoint point(baselinePoint.x, frameView->height() - baselinePoint.y); |
| 3487 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3487 result = WebSubstringUtil::attributedWordAtPoint(frame->frameWidget(), point
, baselinePoint); |
| 3488 ASSERT_TRUE(!!result); | 3488 ASSERT_TRUE(!!result); |
| 3489 | 3489 |
| 3490 webView->setZoomLevel(3); | 3490 webView->setZoomLevel(3); |
| 3491 | 3491 |
| 3492 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline
Point); | 3492 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline
Point); |
| 3493 ASSERT_TRUE(!!result); | 3493 ASSERT_TRUE(!!result); |
| 3494 | 3494 |
| 3495 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); | 3495 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); |
| 3496 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3496 result = WebSubstringUtil::attributedWordAtPoint(frame->frameWidget(), point
, baselinePoint); |
| 3497 ASSERT_TRUE(!!result); | 3497 ASSERT_TRUE(!!result); |
| 3498 } | 3498 } |
| 3499 | 3499 |
| 3500 TEST_F(WebViewTest, WebSubstringUtilIframe) | 3500 TEST_F(WebViewTest, WebSubstringUtilIframe) |
| 3501 { | 3501 { |
| 3502 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("single_iframe.html")); | 3502 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("single_iframe.html")); |
| 3503 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("visible_iframe.html")); | 3503 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("visible_iframe.html")); |
| 3504 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "single
_iframe.html"); | 3504 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "single
_iframe.html"); |
| 3505 webView->settings()->setDefaultFontSize(12); | 3505 webView->settings()->setDefaultFontSize(12); |
| 3506 webView->settings()->setJavaScriptEnabled(true); | 3506 webView->settings()->setJavaScriptEnabled(true); |
| 3507 webView->resize(WebSize(400, 400)); | 3507 webView->resize(WebSize(400, 400)); |
| 3508 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); | 3508 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); |
| 3509 WebLocalFrameImpl* childFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(ma
inFrame->frame()->tree().firstChild())); | 3509 WebLocalFrameImpl* childFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(ma
inFrame->frame()->tree().firstChild())); |
| 3510 | 3510 |
| 3511 WebPoint baselinePoint; | 3511 WebPoint baselinePoint; |
| 3512 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(ch
ildFrame, 11, 7, &baselinePoint); | 3512 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(ch
ildFrame, 11, 7, &baselinePoint); |
| 3513 ASSERT_NE(result, nullptr); | 3513 ASSERT_NE(result, nullptr); |
| 3514 | 3514 |
| 3515 WebPoint point(baselinePoint.x, mainFrame->frameView()->height() - baselineP
oint.y); | 3515 WebPoint point(baselinePoint.x, mainFrame->frameView()->height() - baselineP
oint.y); |
| 3516 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3516 result = WebSubstringUtil::attributedWordAtPoint(mainFrame->frameWidget(), p
oint, baselinePoint); |
| 3517 ASSERT_NE(result, nullptr); | 3517 ASSERT_NE(result, nullptr); |
| 3518 | 3518 |
| 3519 int yBeforeChange = baselinePoint.y; | 3519 int yBeforeChange = baselinePoint.y; |
| 3520 | 3520 |
| 3521 // Now move the <iframe> down by 100px. | 3521 // Now move the <iframe> down by 100px. |
| 3522 mainFrame->executeScript(WebScriptSource( | 3522 mainFrame->executeScript(WebScriptSource( |
| 3523 "document.querySelector('iframe').style.marginTop = '100px';")); | 3523 "document.querySelector('iframe').style.marginTop = '100px';")); |
| 3524 | 3524 |
| 3525 point = WebPoint(point.x, point.y + 100); | 3525 point = WebPoint(point.x, point.y + 100); |
| 3526 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3526 result = WebSubstringUtil::attributedWordAtPoint(mainFrame->frameWidget(), p
oint, baselinePoint); |
| 3527 ASSERT_NE(result, nullptr); | 3527 ASSERT_NE(result, nullptr); |
| 3528 | 3528 |
| 3529 EXPECT_EQ(yBeforeChange, baselinePoint.y + 100); | 3529 EXPECT_EQ(yBeforeChange, baselinePoint.y + 100); |
| 3530 } | 3530 } |
| 3531 | 3531 |
| 3532 #endif | 3532 #endif |
| 3533 | 3533 |
| 3534 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3534 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
| 3535 { | 3535 { |
| 3536 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); | 3536 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3611 EXPECT_TRUE(webView->page()->defersLoading()); | 3611 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3612 } | 3612 } |
| 3613 | 3613 |
| 3614 EXPECT_TRUE(webView->page()->defersLoading()); | 3614 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3615 } | 3615 } |
| 3616 | 3616 |
| 3617 EXPECT_FALSE(webView->page()->defersLoading()); | 3617 EXPECT_FALSE(webView->page()->defersLoading()); |
| 3618 } | 3618 } |
| 3619 | 3619 |
| 3620 } // namespace blink | 3620 } // namespace blink |
| OLD | NEW |