| 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 11266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11277 web_view->UpdateAllLifecyclePhases(); | 11277 web_view->UpdateAllLifecyclePhases(); |
| 11278 | 11278 |
| 11279 Document* document = web_view->MainFrameImpl()->GetFrame()->GetDocument(); | 11279 Document* document = web_view->MainFrameImpl()->GetFrame()->GetDocument(); |
| 11280 Element* a_tag = document->getElementById("a"); | 11280 Element* a_tag = document->getElementById("a"); |
| 11281 | 11281 |
| 11282 // Ensure hittest only has scrollbar. | 11282 // Ensure hittest only has scrollbar. |
| 11283 HitTestResult hit_test_result = | 11283 HitTestResult hit_test_result = |
| 11284 web_view->CoreHitTestResultAt(WebPoint(18, a_tag->OffsetTop())); | 11284 web_view->CoreHitTestResultAt(WebPoint(18, a_tag->OffsetTop())); |
| 11285 | 11285 |
| 11286 EXPECT_FALSE(hit_test_result.URLElement()); | 11286 EXPECT_FALSE(hit_test_result.URLElement()); |
| 11287 EXPECT_FALSE(hit_test_result.InnerElement()); | 11287 EXPECT_TRUE(hit_test_result.InnerElement()); |
| 11288 EXPECT_TRUE(hit_test_result.GetScrollbar()); | 11288 EXPECT_TRUE(hit_test_result.GetScrollbar()); |
| 11289 EXPECT_FALSE(hit_test_result.GetScrollbar()->IsCustomScrollbar()); | 11289 EXPECT_FALSE(hit_test_result.GetScrollbar()->IsCustomScrollbar()); |
| 11290 | 11290 |
| 11291 // Mouse over link. Mouse cursor should be hand. | 11291 // Mouse over link. Mouse cursor should be hand. |
| 11292 WebMouseEvent mouse_move_over_link_event( | 11292 WebMouseEvent mouse_move_over_link_event( |
| 11293 WebInputEvent::kMouseMove, | 11293 WebInputEvent::kMouseMove, |
| 11294 WebFloatPoint(a_tag->OffsetLeft(), a_tag->OffsetTop()), | 11294 WebFloatPoint(a_tag->OffsetLeft(), a_tag->OffsetTop()), |
| 11295 WebFloatPoint(a_tag->OffsetLeft(), a_tag->OffsetTop()), | 11295 WebFloatPoint(a_tag->OffsetLeft(), a_tag->OffsetTop()), |
| 11296 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | 11296 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, |
| 11297 TimeTicks::Now().InSeconds()); | 11297 TimeTicks::Now().InSeconds()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 11322 | 11322 |
| 11323 WebMouseEvent mouse_press_event( | 11323 WebMouseEvent mouse_press_event( |
| 11324 WebInputEvent::kMouseDown, WebFloatPoint(18, a_tag->OffsetTop()), | 11324 WebInputEvent::kMouseDown, WebFloatPoint(18, a_tag->OffsetTop()), |
| 11325 WebFloatPoint(18, a_tag->OffsetTop()), | 11325 WebFloatPoint(18, a_tag->OffsetTop()), |
| 11326 WebPointerProperties::Button::kLeft, 0, | 11326 WebPointerProperties::Button::kLeft, 0, |
| 11327 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 11327 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); |
| 11328 mouse_press_event.SetFrameScale(1); | 11328 mouse_press_event.SetFrameScale(1); |
| 11329 document->GetFrame()->GetEventHandler().HandleMousePressEvent( | 11329 document->GetFrame()->GetEventHandler().HandleMousePressEvent( |
| 11330 mouse_press_event); | 11330 mouse_press_event); |
| 11331 | 11331 |
| 11332 EXPECT_FALSE(document->ActiveHoverElement()); | 11332 EXPECT_TRUE(document->ActiveHoverElement()); |
| 11333 EXPECT_FALSE(document->HoverElement()); | 11333 EXPECT_TRUE(document->HoverElement()); |
| 11334 | 11334 |
| 11335 WebMouseEvent mouse_release_event( | 11335 WebMouseEvent mouse_release_event( |
| 11336 WebInputEvent::kMouseUp, WebFloatPoint(18, a_tag->OffsetTop()), | 11336 WebInputEvent::kMouseUp, WebFloatPoint(18, a_tag->OffsetTop()), |
| 11337 WebFloatPoint(18, a_tag->OffsetTop()), | 11337 WebFloatPoint(18, a_tag->OffsetTop()), |
| 11338 WebPointerProperties::Button::kLeft, 0, | 11338 WebPointerProperties::Button::kLeft, 0, |
| 11339 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); | 11339 WebInputEvent::Modifiers::kLeftButtonDown, TimeTicks::Now().InSeconds()); |
| 11340 mouse_release_event.SetFrameScale(1); | 11340 mouse_release_event.SetFrameScale(1); |
| 11341 document->GetFrame()->GetEventHandler().HandleMouseReleaseEvent( | 11341 document->GetFrame()->GetEventHandler().HandleMouseReleaseEvent( |
| 11342 mouse_release_event); | 11342 mouse_release_event); |
| 11343 | 11343 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11459 TimeTicks::Now().InSeconds()); | 11459 TimeTicks::Now().InSeconds()); |
| 11460 mouse_move_over_i_frame.SetFrameScale(1); | 11460 mouse_move_over_i_frame.SetFrameScale(1); |
| 11461 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 11461 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( |
| 11462 mouse_move_over_i_frame, Vector<WebMouseEvent>()); | 11462 mouse_move_over_i_frame, Vector<WebMouseEvent>()); |
| 11463 | 11463 |
| 11464 // IFRAME hover. | 11464 // IFRAME hover. |
| 11465 EXPECT_EQ(document->HoverElement(), iframe); | 11465 EXPECT_EQ(document->HoverElement(), iframe); |
| 11466 | 11466 |
| 11467 // Ensure hittest has scrollbar. | 11467 // Ensure hittest has scrollbar. |
| 11468 hit_test_result = web_view->CoreHitTestResultAt(WebPoint(195, 5)); | 11468 hit_test_result = web_view->CoreHitTestResultAt(WebPoint(195, 5)); |
| 11469 EXPECT_FALSE(hit_test_result.InnerElement()); | 11469 EXPECT_TRUE(hit_test_result.InnerElement()); |
| 11470 EXPECT_TRUE(hit_test_result.GetScrollbar()); | 11470 EXPECT_TRUE(hit_test_result.GetScrollbar()); |
| 11471 EXPECT_TRUE(hit_test_result.GetScrollbar()->Enabled()); | 11471 EXPECT_TRUE(hit_test_result.GetScrollbar()->Enabled()); |
| 11472 | 11472 |
| 11473 // Mouse over scrollbar. | 11473 // Mouse over scrollbar. |
| 11474 WebMouseEvent mouse_move_over_i_frame_and_scrollbar( | 11474 WebMouseEvent mouse_move_over_i_frame_and_scrollbar( |
| 11475 WebInputEvent::kMouseMove, WebFloatPoint(195, 5), WebFloatPoint(195, 5), | 11475 WebInputEvent::kMouseMove, WebFloatPoint(195, 5), WebFloatPoint(195, 5), |
| 11476 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, | 11476 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, |
| 11477 TimeTicks::Now().InSeconds()); | 11477 TimeTicks::Now().InSeconds()); |
| 11478 mouse_move_over_i_frame_and_scrollbar.SetFrameScale(1); | 11478 mouse_move_over_i_frame_and_scrollbar.SetFrameScale(1); |
| 11479 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 11479 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11583 EXPECT_LT(hit_test_result.InnerElement()->clientWidth(), 180); | 11583 EXPECT_LT(hit_test_result.InnerElement()->clientWidth(), 180); |
| 11584 | 11584 |
| 11585 // Mouse over disabled scrollbar. | 11585 // Mouse over disabled scrollbar. |
| 11586 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( | 11586 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( |
| 11587 mouse_move_over_div_and_scrollbar, Vector<WebMouseEvent>()); | 11587 mouse_move_over_div_and_scrollbar, Vector<WebMouseEvent>()); |
| 11588 | 11588 |
| 11589 // Not change the DIV :hover. | 11589 // Not change the DIV :hover. |
| 11590 EXPECT_EQ(document->HoverElement(), parent_div); | 11590 EXPECT_EQ(document->HoverElement(), parent_div); |
| 11591 } | 11591 } |
| 11592 | 11592 |
| 11593 // Makes sure that mouse over a root scrollbar also hover the html element. |
| 11594 TEST_F(WebFrameTest, MouseOverRootScrollbar) { |
| 11595 RegisterMockedHttpURLLoad("hover-root-scrollbar.html"); |
| 11596 FrameTestHelpers::WebViewHelper web_view_helper; |
| 11597 WebViewBase* web_view = web_view_helper.InitializeAndLoad( |
| 11598 base_url_ + "hover-root-scrollbar.html"); |
| 11599 |
| 11600 web_view_helper.Resize(WebSize(200, 200)); |
| 11601 |
| 11602 web_view->UpdateAllLifecyclePhases(); |
| 11603 |
| 11604 Document* document = |
| 11605 ToLocalFrame(web_view->GetPage()->MainFrame())->GetDocument(); |
| 11606 |
| 11607 // Ensure hittest has HTML element and scrollbar. |
| 11608 HitTestResult hit_test_result = |
| 11609 web_view->CoreHitTestResultAt(WebPoint(195, 5)); |
| 11610 |
| 11611 EXPECT_TRUE(hit_test_result.InnerElement()); |
| 11612 EXPECT_EQ(hit_test_result.InnerElement(), document->documentElement()); |
| 11613 EXPECT_TRUE(hit_test_result.GetScrollbar()); |
| 11614 |
| 11615 // Mouse over scrollbar. |
| 11616 WebMouseEvent mouse_move_over_div_and_scrollbar( |
| 11617 WebInputEvent::kMouseMove, WebFloatPoint(195, 5), WebFloatPoint(195, 5), |
| 11618 WebPointerProperties::Button::kNoButton, 0, WebInputEvent::kNoModifiers, |
| 11619 TimeTicks::Now().InSeconds()); |
| 11620 mouse_move_over_div_and_scrollbar.SetFrameScale(1); |
| 11621 document->GetFrame()->GetEventHandler().HandleMouseMoveEvent( |
| 11622 mouse_move_over_div_and_scrollbar, Vector<WebMouseEvent>()); |
| 11623 |
| 11624 // Hover HTML element. |
| 11625 EXPECT_EQ(document->HoverElement(), document->documentElement()); |
| 11626 } |
| 11627 |
| 11593 TEST_F(WebFrameTest, MouseReleaseUpdatesScrollbarHoveredPart) { | 11628 TEST_F(WebFrameTest, MouseReleaseUpdatesScrollbarHoveredPart) { |
| 11594 RegisterMockedHttpURLLoad("custom-scrollbar-hover.html"); | 11629 RegisterMockedHttpURLLoad("custom-scrollbar-hover.html"); |
| 11595 FrameTestHelpers::WebViewHelper web_view_helper; | 11630 FrameTestHelpers::WebViewHelper web_view_helper; |
| 11596 WebViewBase* web_view = web_view_helper.InitializeAndLoad( | 11631 WebViewBase* web_view = web_view_helper.InitializeAndLoad( |
| 11597 base_url_ + "custom-scrollbar-hover.html"); | 11632 base_url_ + "custom-scrollbar-hover.html"); |
| 11598 | 11633 |
| 11599 web_view_helper.Resize(WebSize(200, 200)); | 11634 web_view_helper.Resize(WebSize(200, 200)); |
| 11600 | 11635 |
| 11601 web_view->UpdateAllLifecyclePhases(); | 11636 web_view->UpdateAllLifecyclePhases(); |
| 11602 | 11637 |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12185 if (obj->IsText()) { | 12220 if (obj->IsText()) { |
| 12186 LayoutText* layout_text = ToLayoutText(obj); | 12221 LayoutText* layout_text = ToLayoutText(obj); |
| 12187 text = layout_text->GetText(); | 12222 text = layout_text->GetText(); |
| 12188 break; | 12223 break; |
| 12189 } | 12224 } |
| 12190 } | 12225 } |
| 12191 EXPECT_EQ("foo alt", text.Utf8()); | 12226 EXPECT_EQ("foo alt", text.Utf8()); |
| 12192 } | 12227 } |
| 12193 | 12228 |
| 12194 } // namespace blink | 12229 } // namespace blink |
| OLD | NEW |