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

Side by Side Diff: sky/engine/core/rendering/RenderObject.cpp

Issue 878303002: Remove more scrolling code from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
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
« no previous file with comments | « sky/engine/core/rendering/RenderObject.h ('k') | sky/engine/core/rendering/RenderTheme.h » ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 24 matching lines...) Expand all
35 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 35 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
36 #include "sky/engine/core/editing/EditingBoundary.h" 36 #include "sky/engine/core/editing/EditingBoundary.h"
37 #include "sky/engine/core/editing/FrameSelection.h" 37 #include "sky/engine/core/editing/FrameSelection.h"
38 #include "sky/engine/core/editing/htmlediting.h" 38 #include "sky/engine/core/editing/htmlediting.h"
39 #include "sky/engine/core/fetch/ResourceLoader.h" 39 #include "sky/engine/core/fetch/ResourceLoader.h"
40 #include "sky/engine/core/frame/FrameView.h" 40 #include "sky/engine/core/frame/FrameView.h"
41 #include "sky/engine/core/frame/LocalFrame.h" 41 #include "sky/engine/core/frame/LocalFrame.h"
42 #include "sky/engine/core/frame/Settings.h" 42 #include "sky/engine/core/frame/Settings.h"
43 #include "sky/engine/core/html/HTMLAnchorElement.h" 43 #include "sky/engine/core/html/HTMLAnchorElement.h"
44 #include "sky/engine/core/html/HTMLElement.h" 44 #include "sky/engine/core/html/HTMLElement.h"
45 #include "sky/engine/core/page/AutoscrollController.h"
46 #include "sky/engine/core/page/EventHandler.h" 45 #include "sky/engine/core/page/EventHandler.h"
47 #include "sky/engine/core/page/Page.h" 46 #include "sky/engine/core/page/Page.h"
48 #include "sky/engine/core/rendering/HitTestResult.h" 47 #include "sky/engine/core/rendering/HitTestResult.h"
49 #include "sky/engine/core/rendering/RenderFlexibleBox.h" 48 #include "sky/engine/core/rendering/RenderFlexibleBox.h"
50 #include "sky/engine/core/rendering/RenderGeometryMap.h" 49 #include "sky/engine/core/rendering/RenderGeometryMap.h"
51 #include "sky/engine/core/rendering/RenderImage.h" 50 #include "sky/engine/core/rendering/RenderImage.h"
52 #include "sky/engine/core/rendering/RenderImageResourceStyleImage.h" 51 #include "sky/engine/core/rendering/RenderImageResourceStyleImage.h"
53 #include "sky/engine/core/rendering/RenderInline.h" 52 #include "sky/engine/core/rendering/RenderInline.h"
54 #include "sky/engine/core/rendering/RenderLayer.h" 53 #include "sky/engine/core/rendering/RenderLayer.h"
55 #include "sky/engine/core/rendering/RenderObjectInlines.h" 54 #include "sky/engine/core/rendering/RenderObjectInlines.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 for (const RenderObject* current = this; current; current = current->parent( )) { 404 for (const RenderObject* current = this; current; current = current->parent( )) {
406 if (current->hasLayer()) 405 if (current->hasLayer())
407 return toRenderLayerModelObject(current)->layer(); 406 return toRenderLayerModelObject(current)->layer();
408 } 407 }
409 // FIXME: We should remove the one caller that triggers this case and make 408 // FIXME: We should remove the one caller that triggers this case and make
410 // this function return a reference. 409 // this function return a reference.
411 ASSERT(!m_parent && !isRenderView()); 410 ASSERT(!m_parent && !isRenderView());
412 return 0; 411 return 0;
413 } 412 }
414 413
415 bool RenderObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign ment& alignX, const ScrollAlignment& alignY)
416 {
417 RenderBox* enclosingBox = this->enclosingBox();
418 if (!enclosingBox)
419 return false;
420
421 enclosingBox->scrollRectToVisible(rect, alignX, alignY);
422 return true;
423 }
424
425 RenderBox* RenderObject::enclosingBox() const 414 RenderBox* RenderObject::enclosingBox() const
426 { 415 {
427 RenderObject* curr = const_cast<RenderObject*>(this); 416 RenderObject* curr = const_cast<RenderObject*>(this);
428 while (curr) { 417 while (curr) {
429 if (curr->isBox()) 418 if (curr->isBox())
430 return toRenderBox(curr); 419 return toRenderBox(curr);
431 curr = curr->parent(); 420 curr = curr->parent();
432 } 421 }
433 422
434 ASSERT_NOT_REACHED(); 423 ASSERT_NOT_REACHED();
435 return 0; 424 return 0;
436 } 425 }
437 426
438 RenderBoxModelObject* RenderObject::enclosingBoxModelObject() const 427 RenderBoxModelObject* RenderObject::enclosingBoxModelObject() const
439 { 428 {
440 RenderObject* curr = const_cast<RenderObject*>(this); 429 RenderObject* curr = const_cast<RenderObject*>(this);
441 while (curr) { 430 while (curr) {
442 if (curr->isBoxModelObject()) 431 if (curr->isBoxModelObject())
443 return toRenderBoxModelObject(curr); 432 return toRenderBoxModelObject(curr);
444 curr = curr->parent(); 433 curr = curr->parent();
445 } 434 }
446 435
447 ASSERT_NOT_REACHED(); 436 ASSERT_NOT_REACHED();
448 return 0; 437 return 0;
449 } 438 }
450 439
451 RenderBox* RenderObject::enclosingScrollableBox() const
452 {
453 // FIXME(sky): Remove.
454 return 0;
455 }
456
457 bool RenderObject::skipInvalidationWhenLaidOutChildren() const 440 bool RenderObject::skipInvalidationWhenLaidOutChildren() const
458 { 441 {
459 if (!neededLayoutBecauseOfChildren()) 442 if (!neededLayoutBecauseOfChildren())
460 return false; 443 return false;
461 444
462 // SVG renderers need to be invalidated when their children are laid out. 445 // SVG renderers need to be invalidated when their children are laid out.
463 // RenderBlocks with line boxes are responsible to invalidate them so we can 't ignore them. 446 // RenderBlocks with line boxes are responsible to invalidate them so we can 't ignore them.
464 if (isRenderBlockFlow() && toRenderBlockFlow(this)->firstLineBox()) 447 if (isRenderBlockFlow() && toRenderBlockFlow(this)->firstLineBox())
465 return false; 448 return false;
466 449
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 void RenderObject::mapLocalToContainer(const RenderLayerModelObject* paintInvali dationContainer, TransformState& transformState, MapCoordinatesFlags mode) const 1395 void RenderObject::mapLocalToContainer(const RenderLayerModelObject* paintInvali dationContainer, TransformState& transformState, MapCoordinatesFlags mode) const
1413 { 1396 {
1414 if (paintInvalidationContainer == this) 1397 if (paintInvalidationContainer == this)
1415 return; 1398 return;
1416 1399
1417 RenderObject* o = parent(); 1400 RenderObject* o = parent();
1418 if (!o) 1401 if (!o)
1419 return; 1402 return;
1420 1403
1421 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1404 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called.
1422 if (mode & ApplyContainerFlip && o->isBox()) { 1405 if (mode & ApplyContainerFlip && o->isBox())
1423 mode &= ~ApplyContainerFlip; 1406 mode &= ~ApplyContainerFlip;
1424 }
1425
1426 if (o->hasOverflowClip())
1427 transformState.move(-toRenderBox(o)->scrolledContentOffset());
1428 1407
1429 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode); 1408 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode);
1430 } 1409 }
1431 1410
1432 const RenderObject* RenderObject::pushMappingToContainer(const RenderLayerModelO bject* ancestorToStopAt, RenderGeometryMap& geometryMap) const 1411 const RenderObject* RenderObject::pushMappingToContainer(const RenderLayerModelO bject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
1433 { 1412 {
1434 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this); 1413 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this);
1435 1414
1436 RenderObject* container = parent(); 1415 RenderObject* container = parent();
1437 if (!container) 1416 if (!container)
1438 return 0; 1417 return 0;
1439 1418 // FIXME(sky): Do we need to make this call?
1440 // FIXME: this should call offsetFromContainer to share code, but I'm not su re it's ever called. 1419 geometryMap.push(this, LayoutSize(), false);
1441 LayoutSize offset;
1442 if (container->hasOverflowClip())
1443 offset = -toRenderBox(container)->scrolledContentOffset();
1444
1445 geometryMap.push(this, offset, false);
1446
1447 return container; 1420 return container;
1448 } 1421 }
1449 1422
1450 void RenderObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformSt ate& transformState) const 1423 void RenderObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformSt ate& transformState) const
1451 { 1424 {
1452 RenderObject* o = parent(); 1425 RenderObject* o = parent();
1453 if (o) { 1426 if (o)
1454 o->mapAbsoluteToLocalPoint(mode, transformState); 1427 o->mapAbsoluteToLocalPoint(mode, transformState);
1455 if (o->hasOverflowClip())
1456 transformState.move(toRenderBox(o)->scrolledContentOffset());
1457 }
1458 } 1428 }
1459 1429
1460 bool RenderObject::shouldUseTransformFromContainer(const RenderObject* container Object) const 1430 bool RenderObject::shouldUseTransformFromContainer(const RenderObject* container Object) const
1461 { 1431 {
1462 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform, 1432 // hasTransform() indicates whether the object has transform, transform-styl e or perspective. We just care about transform,
1463 // so check the layer's transform directly. 1433 // so check the layer's transform directly.
1464 return (hasLayer() && toRenderLayerModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective()); 1434 return (hasLayer() && toRenderLayerModelObject(this)->layer()->transform()) || (containerObject && containerObject->style()->hasPerspective());
1465 } 1435 }
1466 1436
1467 void RenderObject::getTransformFromContainer(const RenderObject* containerObject , const LayoutSize& offsetInContainer, TransformationMatrix& transform) const 1437 void RenderObject::getTransformFromContainer(const RenderObject* containerObject , const LayoutSize& offsetInContainer, TransformationMatrix& transform) const
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 TransformState transformState(TransformState::ApplyTransformDirection, local Point); 1472 TransformState transformState(TransformState::ApplyTransformDirection, local Point);
1503 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms); 1473 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply ContainerFlip | UseTransforms);
1504 transformState.flatten(); 1474 transformState.flatten();
1505 1475
1506 return transformState.lastPlanarPoint(); 1476 return transformState.lastPlanarPoint();
1507 } 1477 }
1508 1478
1509 LayoutSize RenderObject::offsetFromContainer(const RenderObject* o, const Layout Point& point, bool* offsetDependsOnPoint) const 1479 LayoutSize RenderObject::offsetFromContainer(const RenderObject* o, const Layout Point& point, bool* offsetDependsOnPoint) const
1510 { 1480 {
1511 ASSERT(o == container()); 1481 ASSERT(o == container());
1512
1513 LayoutSize offset; 1482 LayoutSize offset;
1514
1515 if (o->hasOverflowClip())
1516 offset -= toRenderBox(o)->scrolledContentOffset();
1517
1518 if (offsetDependsOnPoint) 1483 if (offsetDependsOnPoint)
1519 *offsetDependsOnPoint = false; 1484 *offsetDependsOnPoint = false;
1520
1521 return offset; 1485 return offset;
1522 } 1486 }
1523 1487
1524 LayoutSize RenderObject::offsetFromAncestorContainer(const RenderObject* contain er) const 1488 LayoutSize RenderObject::offsetFromAncestorContainer(const RenderObject* contain er) const
1525 { 1489 {
1526 LayoutSize offset; 1490 LayoutSize offset;
1527 LayoutPoint referencePoint; 1491 LayoutPoint referencePoint;
1528 const RenderObject* currContainer = this; 1492 const RenderObject* currContainer = this;
1529 do { 1493 do {
1530 const RenderObject* nextContainer = currContainer->container(); 1494 const RenderObject* nextContainer = currContainer->container();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 } 1598 }
1635 } 1599 }
1636 1600
1637 void RenderObject::willBeDestroyed() 1601 void RenderObject::willBeDestroyed()
1638 { 1602 {
1639 // Destroy any leftover anonymous children. 1603 // Destroy any leftover anonymous children.
1640 RenderObjectChildList* children = virtualChildren(); 1604 RenderObjectChildList* children = virtualChildren();
1641 if (children) 1605 if (children)
1642 children->destroyLeftoverChildren(); 1606 children->destroyLeftoverChildren();
1643 1607
1644 // If this renderer is being autoscrolled, stop the autoscrolling.
1645 if (LocalFrame* frame = this->frame()) {
1646 if (frame->page())
1647 frame->page()->autoscrollController().stopAutoscrollIfNeeded(this);
1648 }
1649
1650 remove(); 1608 remove();
1651
1652 setAncestorLineBoxDirty(false); 1609 setAncestorLineBoxDirty(false);
1653
1654 clearLayoutRootIfNeeded(); 1610 clearLayoutRootIfNeeded();
1655 } 1611 }
1656 1612
1657 void RenderObject::insertedIntoTree() 1613 void RenderObject::insertedIntoTree()
1658 { 1614 {
1659 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion. 1615 // FIXME: We should ASSERT(isRooted()) here but generated content makes some out-of-order insertion.
1660 1616
1661 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children 1617 // Keep our layer hierarchy updated. Optimize for the common case where we d on't have any children
1662 // and don't have a layer attached to ourselves. 1618 // and don't have a layer attached to ourselves.
1663 RenderLayer* layer = 0; 1619 RenderLayer* layer = 0;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 { 2008 {
2053 if (object1) { 2009 if (object1) {
2054 const blink::RenderObject* root = object1; 2010 const blink::RenderObject* root = object1;
2055 while (root->parent()) 2011 while (root->parent())
2056 root = root->parent(); 2012 root = root->parent();
2057 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 2013 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
2058 } 2014 }
2059 } 2015 }
2060 2016
2061 #endif 2017 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderObject.h ('k') | sky/engine/core/rendering/RenderTheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698