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 3197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3208 webView->settings()->setDefaultFontSize(12); | 3208 webView->settings()->setDefaultFontSize(12); |
3209 webView->resize(WebSize(400, 400)); | 3209 webView->resize(WebSize(400, 400)); |
3210 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3210 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
3211 FrameView* frameView = frame->frame()->view(); | 3211 FrameView* frameView = frame->frame()->view(); |
3212 | 3212 |
3213 WebPoint baselinePoint; | 3213 WebPoint baselinePoint; |
3214 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr
ame, 10, 3, &baselinePoint); | 3214 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(fr
ame, 10, 3, &baselinePoint); |
3215 ASSERT_TRUE(!!result); | 3215 ASSERT_TRUE(!!result); |
3216 | 3216 |
3217 WebPoint point(baselinePoint.x, frameView->height() - baselinePoint.y); | 3217 WebPoint point(baselinePoint.x, frameView->height() - baselinePoint.y); |
3218 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3218 result = WebSubstringUtil::attributedWordAtPoint(webView, nullptr, point, ba
selinePoint); |
3219 ASSERT_TRUE(!!result); | 3219 ASSERT_TRUE(!!result); |
3220 | 3220 |
3221 webView->setZoomLevel(3); | 3221 webView->setZoomLevel(3); |
3222 | 3222 |
3223 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline
Point); | 3223 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline
Point); |
3224 ASSERT_TRUE(!!result); | 3224 ASSERT_TRUE(!!result); |
3225 | 3225 |
3226 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); | 3226 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); |
3227 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3227 result = WebSubstringUtil::attributedWordAtPoint(webView, nullptr, point, ba
selinePoint); |
3228 ASSERT_TRUE(!!result); | 3228 ASSERT_TRUE(!!result); |
3229 } | 3229 } |
3230 | 3230 |
3231 TEST_F(WebViewTest, WebSubstringUtilIframe) | 3231 TEST_F(WebViewTest, WebSubstringUtilIframe) |
3232 { | 3232 { |
3233 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("single_iframe.html")); | 3233 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("single_iframe.html")); |
3234 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("visible_iframe.html")); | 3234 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("visible_iframe.html")); |
3235 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "single
_iframe.html"); | 3235 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "single
_iframe.html"); |
3236 webView->settings()->setDefaultFontSize(12); | 3236 webView->settings()->setDefaultFontSize(12); |
3237 webView->settings()->setJavaScriptEnabled(true); | 3237 webView->settings()->setJavaScriptEnabled(true); |
3238 webView->resize(WebSize(400, 400)); | 3238 webView->resize(WebSize(400, 400)); |
3239 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); | 3239 WebLocalFrameImpl* mainFrame = webView->mainFrameImpl(); |
3240 WebLocalFrameImpl* childFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(ma
inFrame->frame()->tree().firstChild())); | 3240 WebLocalFrameImpl* childFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(ma
inFrame->frame()->tree().firstChild())); |
3241 | 3241 |
3242 WebPoint baselinePoint; | 3242 WebPoint baselinePoint; |
3243 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(ch
ildFrame, 11, 7, &baselinePoint); | 3243 NSAttributedString* result = WebSubstringUtil::attributedSubstringInRange(ch
ildFrame, 11, 7, &baselinePoint); |
3244 ASSERT_NE(result, nullptr); | 3244 ASSERT_NE(result, nullptr); |
3245 | 3245 |
3246 WebPoint point(baselinePoint.x, mainFrame->frameView()->height() - baselineP
oint.y); | 3246 WebPoint point(baselinePoint.x, mainFrame->frameView()->height() - baselineP
oint.y); |
3247 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3247 result = WebSubstringUtil::attributedWordAtPoint(webView, nullptr, point, ba
selinePoint); |
3248 ASSERT_NE(result, nullptr); | 3248 ASSERT_NE(result, nullptr); |
3249 | 3249 |
3250 int yBeforeChange = baselinePoint.y; | 3250 int yBeforeChange = baselinePoint.y; |
3251 | 3251 |
3252 // Now move the <iframe> down by 100px. | 3252 // Now move the <iframe> down by 100px. |
3253 mainFrame->executeScript(WebScriptSource( | 3253 mainFrame->executeScript(WebScriptSource( |
3254 "document.querySelector('iframe').style.marginTop = '100px';")); | 3254 "document.querySelector('iframe').style.marginTop = '100px';")); |
3255 | 3255 |
3256 point = WebPoint(point.x, point.y + 100); | 3256 point = WebPoint(point.x, point.y + 100); |
3257 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi
nt); | 3257 result = WebSubstringUtil::attributedWordAtPoint(webView, nullptr, point, ba
selinePoint); |
3258 ASSERT_NE(result, nullptr); | 3258 ASSERT_NE(result, nullptr); |
3259 | 3259 |
3260 EXPECT_EQ(yBeforeChange, baselinePoint.y + 100); | 3260 EXPECT_EQ(yBeforeChange, baselinePoint.y + 100); |
3261 } | 3261 } |
3262 | 3262 |
3263 #endif | 3263 #endif |
3264 | 3264 |
3265 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3265 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
3266 { | 3266 { |
3267 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); | 3267 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... |
3342 EXPECT_TRUE(webView->page()->defersLoading()); | 3342 EXPECT_TRUE(webView->page()->defersLoading()); |
3343 } | 3343 } |
3344 | 3344 |
3345 EXPECT_TRUE(webView->page()->defersLoading()); | 3345 EXPECT_TRUE(webView->page()->defersLoading()); |
3346 } | 3346 } |
3347 | 3347 |
3348 EXPECT_FALSE(webView->page()->defersLoading()); | 3348 EXPECT_FALSE(webView->page()->defersLoading()); |
3349 } | 3349 } |
3350 | 3350 |
3351 } // namespace blink | 3351 } // namespace blink |
OLD | NEW |