Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: Source/web/tests/ScrollingCoordinatorTest.cpp

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/tests/PinchViewportTest.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 scrollableElement->setScrollTop(1.0); 161 scrollableElement->setScrollTop(1.0);
162 scrollableElement->setScrollLeft(1.0); 162 scrollableElement->setScrollLeft(1.0);
163 forceFullCompositingUpdate(); 163 forceFullCompositingUpdate();
164 164
165 // Make sure the fractional scroll offset change 1.0 -> 1.2 gets propagated 165 // Make sure the fractional scroll offset change 1.0 -> 1.2 gets propagated
166 // to compositor. 166 // to compositor.
167 scrollableElement->setScrollTop(1.2); 167 scrollableElement->setScrollTop(1.2);
168 scrollableElement->setScrollLeft(1.2); 168 scrollableElement->setScrollLeft(1.2);
169 forceFullCompositingUpdate(); 169 forceFullCompositingUpdate();
170 170
171 RenderObject* renderer = scrollableElement->renderer(); 171 LayoutObject* renderer = scrollableElement->renderer();
172 ASSERT_TRUE(renderer->isBox()); 172 ASSERT_TRUE(renderer->isBox());
173 RenderBox* box = toRenderBox(renderer); 173 RenderBox* box = toRenderBox(renderer);
174 ASSERT_TRUE(box->usesCompositedScrolling()); 174 ASSERT_TRUE(box->usesCompositedScrolling());
175 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 175 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
176 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); 176 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer());
177 ASSERT(compositedLayerMapping->scrollingContentsLayer()); 177 ASSERT(compositedLayerMapping->scrollingContentsLayer());
178 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer(); 178 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer();
179 ASSERT_TRUE(webScrollLayer); 179 ASSERT_TRUE(webScrollLayer);
180 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().x, 0.01); 180 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().x, 0.01);
181 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().y, 0.01); 181 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().y, 0.01);
182 } 182 }
183 183
184 static WebLayer* webLayerFromElement(Element* element) 184 static WebLayer* webLayerFromElement(Element* element)
185 { 185 {
186 if (!element) 186 if (!element)
187 return 0; 187 return 0;
188 RenderObject* renderer = element->renderer(); 188 LayoutObject* renderer = element->renderer();
189 if (!renderer || !renderer->isBoxModelObject()) 189 if (!renderer || !renderer->isBoxModelObject())
190 return 0; 190 return 0;
191 Layer* layer = toRenderBoxModelObject(renderer)->layer(); 191 Layer* layer = toRenderBoxModelObject(renderer)->layer();
192 if (!layer) 192 if (!layer)
193 return 0; 193 return 0;
194 if (!layer->hasCompositedLayerMapping()) 194 if (!layer->hasCompositedLayerMapping())
195 return 0; 195 return 0;
196 CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMappi ng(); 196 CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMappi ng();
197 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); 197 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer();
198 if (!graphicsLayer) 198 if (!graphicsLayer)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 WebLayer* rootScrollLayer = getRootScrollLayer(); 346 WebLayer* rootScrollLayer = getRootScrollLayer();
347 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); 347 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size());
348 } 348 }
349 349
350 TEST_F(ScrollingCoordinatorTest, overflowScrolling) 350 TEST_F(ScrollingCoordinatorTest, overflowScrolling)
351 { 351 {
352 registerMockedHttpURLLoad("overflow-scrolling.html"); 352 registerMockedHttpURLLoad("overflow-scrolling.html");
353 navigateTo(m_baseURL + "overflow-scrolling.html"); 353 navigateTo(m_baseURL + "overflow-scrolling.html");
354 forceFullCompositingUpdate(); 354 forceFullCompositingUpdate();
355 355
356 // Verify the properties of the accelerated scrolling element starting from the RenderObject 356 // Verify the properties of the accelerated scrolling element starting from the LayoutObject
357 // all the way to the WebLayer. 357 // all the way to the WebLayer.
358 Element* scrollableElement = frame()->document()->getElementById("scrollable "); 358 Element* scrollableElement = frame()->document()->getElementById("scrollable ");
359 ASSERT(scrollableElement); 359 ASSERT(scrollableElement);
360 360
361 RenderObject* renderer = scrollableElement->renderer(); 361 LayoutObject* renderer = scrollableElement->renderer();
362 ASSERT_TRUE(renderer->isBox()); 362 ASSERT_TRUE(renderer->isBox());
363 ASSERT_TRUE(renderer->hasLayer()); 363 ASSERT_TRUE(renderer->hasLayer());
364 364
365 RenderBox* box = toRenderBox(renderer); 365 RenderBox* box = toRenderBox(renderer);
366 ASSERT_TRUE(box->usesCompositedScrolling()); 366 ASSERT_TRUE(box->usesCompositedScrolling());
367 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); 367 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState());
368 368
369 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 369 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
370 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); 370 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer());
371 ASSERT(compositedLayerMapping->scrollingContentsLayer()); 371 ASSERT(compositedLayerMapping->scrollingContentsLayer());
(...skipping 14 matching lines...) Expand all
386 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents Layer()); 386 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents Layer());
387 #endif 387 #endif
388 } 388 }
389 389
390 TEST_F(ScrollingCoordinatorTest, overflowHidden) 390 TEST_F(ScrollingCoordinatorTest, overflowHidden)
391 { 391 {
392 registerMockedHttpURLLoad("overflow-hidden.html"); 392 registerMockedHttpURLLoad("overflow-hidden.html");
393 navigateTo(m_baseURL + "overflow-hidden.html"); 393 navigateTo(m_baseURL + "overflow-hidden.html");
394 forceFullCompositingUpdate(); 394 forceFullCompositingUpdate();
395 395
396 // Verify the properties of the accelerated scrolling element starting from the RenderObject 396 // Verify the properties of the accelerated scrolling element starting from the LayoutObject
397 // all the way to the WebLayer. 397 // all the way to the WebLayer.
398 Element* overflowElement = frame()->document()->getElementById("unscrollable -y"); 398 Element* overflowElement = frame()->document()->getElementById("unscrollable -y");
399 ASSERT(overflowElement); 399 ASSERT(overflowElement);
400 400
401 RenderObject* renderer = overflowElement->renderer(); 401 LayoutObject* renderer = overflowElement->renderer();
402 ASSERT_TRUE(renderer->isBox()); 402 ASSERT_TRUE(renderer->isBox());
403 ASSERT_TRUE(renderer->hasLayer()); 403 ASSERT_TRUE(renderer->hasLayer());
404 404
405 RenderBox* box = toRenderBox(renderer); 405 RenderBox* box = toRenderBox(renderer);
406 ASSERT_TRUE(box->usesCompositedScrolling()); 406 ASSERT_TRUE(box->usesCompositedScrolling());
407 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); 407 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState());
408 408
409 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 409 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
410 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); 410 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer());
411 ASSERT(compositedLayerMapping->scrollingContentsLayer()); 411 ASSERT(compositedLayerMapping->scrollingContentsLayer());
(...skipping 30 matching lines...) Expand all
442 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 442 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
443 } 443 }
444 444
445 TEST_F(ScrollingCoordinatorTest, iframeScrolling) 445 TEST_F(ScrollingCoordinatorTest, iframeScrolling)
446 { 446 {
447 registerMockedHttpURLLoad("iframe-scrolling.html"); 447 registerMockedHttpURLLoad("iframe-scrolling.html");
448 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); 448 registerMockedHttpURLLoad("iframe-scrolling-inner.html");
449 navigateTo(m_baseURL + "iframe-scrolling.html"); 449 navigateTo(m_baseURL + "iframe-scrolling.html");
450 forceFullCompositingUpdate(); 450 forceFullCompositingUpdate();
451 451
452 // Verify the properties of the accelerated scrolling element starting from the RenderObject 452 // Verify the properties of the accelerated scrolling element starting from the LayoutObject
453 // all the way to the WebLayer. 453 // all the way to the WebLayer.
454 Element* scrollableFrame = frame()->document()->getElementById("scrollable") ; 454 Element* scrollableFrame = frame()->document()->getElementById("scrollable") ;
455 ASSERT_TRUE(scrollableFrame); 455 ASSERT_TRUE(scrollableFrame);
456 456
457 RenderObject* renderer = scrollableFrame->renderer(); 457 LayoutObject* renderer = scrollableFrame->renderer();
458 ASSERT_TRUE(renderer); 458 ASSERT_TRUE(renderer);
459 ASSERT_TRUE(renderer->isRenderPart()); 459 ASSERT_TRUE(renderer->isRenderPart());
460 460
461 RenderPart* renderPart = toRenderPart(renderer); 461 RenderPart* renderPart = toRenderPart(renderer);
462 ASSERT_TRUE(renderPart); 462 ASSERT_TRUE(renderPart);
463 ASSERT_TRUE(renderPart->widget()); 463 ASSERT_TRUE(renderPart->widget());
464 ASSERT_TRUE(renderPart->widget()->isFrameView()); 464 ASSERT_TRUE(renderPart->widget()->isFrameView());
465 465
466 FrameView* innerFrameView = toFrameView(renderPart->widget()); 466 FrameView* innerFrameView = toFrameView(renderPart->widget());
467 RenderView* innerRenderView = innerFrameView->renderView(); 467 RenderView* innerRenderView = innerFrameView->renderView();
(...skipping 18 matching lines...) Expand all
486 #endif 486 #endif
487 } 487 }
488 488
489 TEST_F(ScrollingCoordinatorTest, rtlIframe) 489 TEST_F(ScrollingCoordinatorTest, rtlIframe)
490 { 490 {
491 registerMockedHttpURLLoad("rtl-iframe.html"); 491 registerMockedHttpURLLoad("rtl-iframe.html");
492 registerMockedHttpURLLoad("rtl-iframe-inner.html"); 492 registerMockedHttpURLLoad("rtl-iframe-inner.html");
493 navigateTo(m_baseURL + "rtl-iframe.html"); 493 navigateTo(m_baseURL + "rtl-iframe.html");
494 forceFullCompositingUpdate(); 494 forceFullCompositingUpdate();
495 495
496 // Verify the properties of the accelerated scrolling element starting from the RenderObject 496 // Verify the properties of the accelerated scrolling element starting from the LayoutObject
497 // all the way to the WebLayer. 497 // all the way to the WebLayer.
498 Element* scrollableFrame = frame()->document()->getElementById("scrollable") ; 498 Element* scrollableFrame = frame()->document()->getElementById("scrollable") ;
499 ASSERT_TRUE(scrollableFrame); 499 ASSERT_TRUE(scrollableFrame);
500 500
501 RenderObject* renderer = scrollableFrame->renderer(); 501 LayoutObject* renderer = scrollableFrame->renderer();
502 ASSERT_TRUE(renderer); 502 ASSERT_TRUE(renderer);
503 ASSERT_TRUE(renderer->isRenderPart()); 503 ASSERT_TRUE(renderer->isRenderPart());
504 504
505 RenderPart* renderPart = toRenderPart(renderer); 505 RenderPart* renderPart = toRenderPart(renderer);
506 ASSERT_TRUE(renderPart); 506 ASSERT_TRUE(renderPart);
507 ASSERT_TRUE(renderPart->widget()); 507 ASSERT_TRUE(renderPart->widget());
508 ASSERT_TRUE(renderPart->widget()->isFrameView()); 508 ASSERT_TRUE(renderPart->widget()->isFrameView());
509 509
510 FrameView* innerFrameView = toFrameView(renderPart->widget()); 510 FrameView* innerFrameView = toFrameView(renderPart->widget());
511 RenderView* innerRenderView = innerFrameView->renderView(); 511 RenderView* innerRenderView = innerFrameView->renderView();
(...skipping 27 matching lines...) Expand all
539 blink::FrameTestHelpers::UseMockScrollbarSettings mockScrollbarSettings; 539 blink::FrameTestHelpers::UseMockScrollbarSettings mockScrollbarSettings;
540 540
541 registerMockedHttpURLLoad("trivial-scroller.html"); 541 registerMockedHttpURLLoad("trivial-scroller.html");
542 navigateTo(m_baseURL + "trivial-scroller.html"); 542 navigateTo(m_baseURL + "trivial-scroller.html");
543 forceFullCompositingUpdate(); 543 forceFullCompositingUpdate();
544 544
545 Document* document = frame()->document(); 545 Document* document = frame()->document();
546 Element* scrollableElement = document->getElementById("scroller"); 546 Element* scrollableElement = document->getElementById("scroller");
547 ASSERT(scrollableElement); 547 ASSERT(scrollableElement);
548 548
549 RenderObject* renderer = scrollableElement->renderer(); 549 LayoutObject* renderer = scrollableElement->renderer();
550 ASSERT_TRUE(renderer->isBox()); 550 ASSERT_TRUE(renderer->isBox());
551 RenderBox* box = toRenderBox(renderer); 551 RenderBox* box = toRenderBox(renderer);
552 ASSERT_TRUE(box->usesCompositedScrolling()); 552 ASSERT_TRUE(box->usesCompositedScrolling());
553 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 553 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
554 GraphicsLayerForScrollTesting* scrollbarGraphicsLayer = static_cast<Graphics LayerForScrollTesting*>(compositedLayerMapping->layerForVerticalScrollbar()); 554 GraphicsLayerForScrollTesting* scrollbarGraphicsLayer = static_cast<Graphics LayerForScrollTesting*>(compositedLayerMapping->layerForVerticalScrollbar());
555 ASSERT_TRUE(scrollbarGraphicsLayer); 555 ASSERT_TRUE(scrollbarGraphicsLayer);
556 556
557 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent(); 557 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent();
558 ASSERT_TRUE(hasWebScrollbarLayer || scrollbarGraphicsLayer->platformLayer()- >shouldScrollOnMainThread()); 558 ASSERT_TRUE(hasWebScrollbarLayer || scrollbarGraphicsLayer->platformLayer()- >shouldScrollOnMainThread());
559 } 559 }
(...skipping 20 matching lines...) Expand all
580 WebLayer* contentsLayer = scrollbarGraphicsLayer->contentsLayer(); 580 WebLayer* contentsLayer = scrollbarGraphicsLayer->contentsLayer();
581 ASSERT_TRUE(contentsLayer); 581 ASSERT_TRUE(contentsLayer);
582 582
583 // After scrollableAreaScrollbarLayerDidChange, 583 // After scrollableAreaScrollbarLayerDidChange,
584 // if the main frame's scrollbarLayer is opaque, 584 // if the main frame's scrollbarLayer is opaque,
585 // contentsLayer should be opaque too. 585 // contentsLayer should be opaque too.
586 ASSERT_EQ(platformLayer->opaque(), contentsLayer->opaque()); 586 ASSERT_EQ(platformLayer->opaque(), contentsLayer->opaque());
587 } 587 }
588 588
589 } // namespace 589 } // namespace
OLDNEW
« no previous file with comments | « Source/web/tests/PinchViewportTest.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698