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